本文整理汇总了Java中com.trello.rxlifecycle.ActivityEvent类的典型用法代码示例。如果您正苦于以下问题:Java ActivityEvent类的具体用法?Java ActivityEvent怎么用?Java ActivityEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ActivityEvent类属于com.trello.rxlifecycle包,在下文中一共展示了ActivityEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getVoiceResponse
import com.trello.rxlifecycle.ActivityEvent; //导入依赖的package包/类
public void getVoiceResponse(String text) {
voiceMainApi.getVoiceResponse(text)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.compose(mActivityLifecycleProvider.bindUntilEvent(ActivityEvent.DESTROY))
.filter(stickerAdapt2Result -> {
if (stickerAdapt2Result == null) {
ProgressBarHelper.getInstance(true).dismiss();
return false;
}
return true;
})
.subscribe(dataResponse -> {
if (isViewBound()) {
mStickerAdapt2Result = dataResponse;
addPaintData(mStickerAdapt2Result);
mViewport.bindVoiceData(mStickerAdapt2Result);
}
}, throwable -> {
EventBus.getDefault().post(new EventVoiceResponseError(true));
ProgressBarHelper.getInstance(true).dismiss();
throwable.printStackTrace();
});
}
示例2: onCreate
import com.trello.rxlifecycle.ActivityEvent; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_stop);
textView = (TextView) findViewById(R.id.textview);
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity( new Intent( StopActivity.this , OtherActivity.class));
}
});
//循环发送数字
Observable.interval(0, 1, TimeUnit.SECONDS)
.subscribeOn( Schedulers.io())
.compose(this.<Long>bindUntilEvent(ActivityEvent.STOP )) //当Activity执行Onstop()方法是解除订阅关系
.observeOn( AndroidSchedulers.mainThread())
.subscribe(new Action1<Long>() {
@Override
public void call(Long aLong) {
System.out.println("lifecycle-stop-" + aLong);
textView.setText( "" + aLong );
}
});
}
示例3: getBalancesPage
import com.trello.rxlifecycle.ActivityEvent; //导入依赖的package包/类
private void getBalancesPage() {
showProgressBar();
RetrofitManager.api().getBalance().cache()
.retry(2)
.compose(this.bindUntilEvent(ActivityEvent.STOP))
.compose(applySchedulers())
.cast(Document.class)
.subscribe(new HandlerSubscriber() {
@Override
public void onException(Throwable e) {
super.onException(e);
onFailed(R.string.connection_error, new View.OnClickListener() {
@Override
public void onClick(View v) {
getBalancesPage();
}
});
}
@Override
public void onDone(Document document) {
super.onDone(document);
parseAndUpdateUI(document);
}
});
}
示例4: onCreate
import com.trello.rxlifecycle.ActivityEvent; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ButterKnife.bind(this);
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.frame_container, Fragment.instantiate(this, CmmFragment.class.getName()))
.replace(R.id.frame_keyboard, Fragment.instantiate(this, KeyboardFragment.class.getName()))
.commit();
ViewCompat.setElevation(mToolbar, 7);
RxBus.getInstance().toObservable()
.compose(bindUntilEvent(ActivityEvent.DESTROY))
.filter(events -> events.what == Events.EventEnum.WE_HIDE_ALL)
.subscribe(events -> {
finish();
});
}
示例5: onDestroy
import com.trello.rxlifecycle.ActivityEvent; //导入依赖的package包/类
@CallSuper
@Override
protected void onDestroy() {
this.lifecycle.onNext(ActivityEvent.DESTROY);
super.onDestroy();
Timber.d("onDestroy %s", this.toString());
this.subscriptions.clear();
if (isFinishing()) {
if (this.viewModel != null) {
ActivityViewModelManager.getInstance().destroy(this.viewModel);
this.viewModel = null;
}
}
}
示例6: onCreate
import com.trello.rxlifecycle.ActivityEvent; //导入依赖的package包/类
@Override
public void onCreate(final @Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.video_player_layout);
ButterKnife.bind(this);
this.viewModel.outputs.preparePlayerWithUrl()
.compose(Transformers.takeWhen(lifecycle().filter(ActivityEvent.RESUME::equals)))
.compose(bindToLifecycle())
.subscribe(this::preparePlayer);
this.mediaController = new MediaController(this);
this.mediaController.setAnchorView(this.rootView);
RxView.clicks(this.rootView)
.compose(bindToLifecycle())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(__ -> toggleControlsVisibility());
}
示例7: subscribe
import com.trello.rxlifecycle.ActivityEvent; //导入依赖的package包/类
public Observable subscribe(Observable mObservable, Observer observer) {
mObservable.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.compose(getActivityLifecycleProvider().bindUntilEvent(ActivityEvent.DESTROY))
.subscribe(observer);
return mObservable;
}
示例8: onCreate
import com.trello.rxlifecycle.ActivityEvent; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mActivity = this;
activityManagerUtil = ActivityManagerUtil.getInstance();
activityManagerUtil.pushOneActivity(this);
lifecycleSubject.onNext(ActivityEvent.CREATE);
requestWindowFeature(Window.FEATURE_NO_TITLE);// 去掉标题栏
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
mToast = DrawerToast.getInstance(getApplicationContext());
}
示例9: showItemsMenu
import com.trello.rxlifecycle.ActivityEvent; //导入依赖的package包/类
private void showItemsMenu(final MyMenusItem item, final String menuType) {
String date = Utils.myMenusDateFormat.format(item.date.getTime());
String url = user.getBaseUrl() + "/yemekliste.aspx?tarih=" + date + "&ogun=" + menuType;
RetrofitManager.api().getRequest(url)
.compose(this.bindUntilEvent(ActivityEvent.STOP))
.cast(Document.class)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Subscriber<Document>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
Toast.makeText(MyMenusActivity.this, R.string.error_tryagain, Toast.LENGTH_SHORT).show();
}
@Override
public void onNext(Document document) {
String menu, title = document.select("[id=Label1]").text();
Element table = document.select("[id=lblTable]").first();
if (table.children().size() == 0)
menu = getString(R.string.no_menu_found);
else {
Elements menuRows = table.select("tbody").first().children();
menuRows.remove(0);
menu = title + "\n\n";
for (Element menuRow : menuRows) {
menu += menuRow.text() + "\n";
}
}
makeDialog(item.dateString + menuType, menu);
}
});
}
示例10: postItem
import com.trello.rxlifecycle.ActivityEvent; //导入依赖的package包/类
private void postItem(String name, final int pos) {
hideFab();
FormEncodingBuilder feb = ConnectionUtils.febWithViewStates(user.getViewStates());
boolean hasCheckedItem = false;
for (OrderItem orderItem : orderItems) {
if (orderItem.isChecked) {
feb.add(orderItem.name, ON);
hasCheckedItem = true;
}
}
final boolean finalHasCheckItem = hasCheckedItem;
RequestBody formBody = feb.add(EVENT_TARGET, name)
.add(EVENT_ARG, "").build();
Subscription sub = RetrofitManager.api().postOrder(formBody)
.retry(1)
.compose(this.bindUntilEvent(ActivityEvent.STOP))
.cast(Document.class)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Subscriber<Document>() {
@Override
public void onCompleted() {
if (finalHasCheckItem) showFab();
}
@Override
public void onError(Throwable e) {
if (finalHasCheckItem) showFab();
rvAdapter.progressDone(false, pos);
}
@Override
public void onNext(Document document) {
rvAdapter.progressDone(true, pos);
harcananText.setText(document.getElementById(HARCANAN_BAKIYE).text().replace("TL", " TL"));
kalanText.setText(document.getElementById(KALAN_BAKIYE).text().replace("TL", " TL"));
}
});
subs.add(sub);
}
示例11: onCreate
import com.trello.rxlifecycle.ActivityEvent; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
mCatalog = getIntent().getIntExtra(TYPE_KEY, TYPE_TEXT);
super.onCreate(savedInstanceState);
ButterKnife.bind(this);
getSupportFragmentManager().beginTransaction()
.replace(R.id.frame_emotion_panel, Fragment.instantiate(this, EmotionPanelFragment.class.getName()))
.commit();
mDelegation = new KeyboardActionDelegation(this, mInput, mEmotionBtn, mEmotionFrame);
switch (mCatalog){
case TYPE_IMAGE:
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType("image/*");
if (intent.resolveActivity(getPackageManager())!=null){
startActivityForResult(Intent.createChooser(intent, "选择图片"), REQUEST_CODE_PICK_IMAGE);
}
break;
}
RxBus.with(this)
.setEvent(Events.EventEnum.DELIVER_SELECT_EMOTION)
.setEndEvent(ActivityEvent.DESTROY)
.onNext((events -> {
EmotionRules emotion = events.<EmotionRules>getMessage();
mDelegation.onEmotionItemSelected(emotion);
})).create();
}
示例12: initSubscribers
import com.trello.rxlifecycle.ActivityEvent; //导入依赖的package包/类
private void initSubscribers() {
// 接受订阅, 无论在哪里登录, 都能够接收到这个事件, 并且更新侧滑抽屉的View
RxBus.with(this)
.setEvent(Events.EventEnum.DELIVER_LOGIN)
.setEndEvent(ActivityEvent.DESTROY)
.onNext((events)->{
initLogin();
}).create();
}
示例13: onCreate
import com.trello.rxlifecycle.ActivityEvent; //导入依赖的package包/类
@CallSuper
@Override
protected void onCreate(final @Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Timber.d("onCreate %s", this.toString());
this.lifecycle.onNext(ActivityEvent.CREATE);
assignViewModel(savedInstanceState);
this.viewModel.intent(getIntent());
}
示例14: onStart
import com.trello.rxlifecycle.ActivityEvent; //导入依赖的package包/类
@CallSuper
@Override
protected void onStart() {
super.onStart();
Timber.d("onStart %s", this.toString());
this.lifecycle.onNext(ActivityEvent.START);
this.back
.compose(bindUntilEvent(ActivityEvent.STOP))
.observeOn(AndroidSchedulers.mainThread())
.subscribe(__ -> goBack());
}
示例15: onResume
import com.trello.rxlifecycle.ActivityEvent; //导入依赖的package包/类
@CallSuper
@Override
protected void onResume() {
super.onResume();
Timber.d("onResume %s", this.toString());
this.lifecycle.onNext(ActivityEvent.RESUME);
assignViewModel(null);
if (this.viewModel != null) {
this.viewModel.onResume(this);
}
}