com.trello.rxlifecycle2.android.ActivityEvent Java Examples
The following examples show how to use
com.trello.rxlifecycle2.android.ActivityEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SuperActivity.java From AndroidBase with Apache License 2.0 | 6 votes |
@Override @CallSuper protected void onDestroy() { mLifecycleSubject.onNext(ActivityEvent.DESTROY); NetworkStateReceiver.unRegisterNetworkStateReceiver(this); ButterKnife.unbind(this); Glide.get(this).clearMemory(); AppManager.getAppManager().finishActivity(this); super.onDestroy(); if (isFinishing()) { if (!AppManager.getAppManager().has()) { if (getApplication() instanceof BaseApplication) { ((BaseApplication) getApplication()).onDestory(); } } } }
Example #2
Source File: LifeCycleActivity.java From My-MVP with Apache License 2.0 | 6 votes |
@Override public void onClick(View v) { int id = v.getId(); switch (id) { case R.id.simple: Observable.interval(1, TimeUnit.SECONDS) .doOnDispose(() -> { Log.e(TAG, "auto disposed"); }) .compose(bindUntilEvent(ActivityEvent.DESTROY)) .subscribe(aLong -> Log.e(TAG, "accept: " + aLong)); break; case R.id.simple_1: Observable.interval(1, TimeUnit.SECONDS) .doOnDispose(() -> Log.e(TAG, "auto disposed")) .compose(bindToLifecycle()) .subscribe(aLong -> Log.e(TAG, "accept: " + aLong)); break; default: break; } }
Example #3
Source File: RxLifecycleActivity.java From JianshuApp with GNU General Public License v3.0 | 5 votes |
@Override @NonNull @CheckResult public final <T> LifecycleTransformer<T> bindToLifecycle() { //return RxLifecycleAndroid.bindActivity(lifecycleSubject); return bindUntilEvent(ActivityEvent.DESTROY); }
Example #4
Source File: FileManagerActivityBase.java From edslite with GNU General Public License v2.0 | 5 votes |
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); setIntent(intent); lifecycle(). filter(event -> event == ActivityEvent.RESUME). firstElement(). subscribe(res -> startAction(null), err -> { if(!(err instanceof CancellationException)) Logger.log(err); }); }
Example #5
Source File: ViewModel.java From Building-Professional-Android-Applications with MIT License | 5 votes |
public void bind(ViewActivity<T> activity) { this.activity = activity; disposable = activity.lifecycle() .filter(activityEvent -> activityEvent.equals(ActivityEvent.START)) .flatMap((at) -> dataSubject) .observeOn(AndroidSchedulers.mainThread()) .subscribe(activity::render, this::handleError); }
Example #6
Source File: ViewModel.java From Building-Professional-Android-Applications with MIT License | 5 votes |
public void bind(ViewActivity<T> activity) { this.activity = activity; disposable = activity.lifecycle() .filter(activityEvent -> activityEvent.equals(ActivityEvent.START)) .flatMap((at) -> dataSubject) .observeOn(AndroidSchedulers.mainThread()) .subscribe(activity::render, this::handleError); }
Example #7
Source File: ViewModel.java From Building-Professional-Android-Applications with MIT License | 5 votes |
public void bind(ViewActivity<T> activity) { this.activity = activity; disposable = activity.lifecycle() .filter(activityEvent -> activityEvent.equals(ActivityEvent.START)) .flatMap((at) -> dataSubject) .observeOn(AndroidSchedulers.mainThread()) .subscribe(activity::render, this::handleError); }
Example #8
Source File: ViewModel.java From Building-Professional-Android-Applications with MIT License | 5 votes |
public void bind(ViewActivity<T> activity) { this.activity = activity; disposable = activity.lifecycle() .filter(activityEvent -> activityEvent.equals(ActivityEvent.START)) .flatMap((at) -> dataSubject) .observeOn(AndroidSchedulers.mainThread()) .subscribe(activity::render, this::handleError); }
Example #9
Source File: ViewModel.java From Building-Professional-Android-Applications with MIT License | 5 votes |
public void bind(ViewActivity<T> activity) { this.activity = activity; disposable = activity.lifecycle() .filter(activityEvent -> activityEvent.equals(ActivityEvent.START)) .flatMap((at) -> dataSubject) .observeOn(AndroidSchedulers.mainThread()) .subscribe(activity::render, this::handleError); }
Example #10
Source File: ViewModel.java From Building-Professional-Android-Applications with MIT License | 5 votes |
public void bind(ViewActivity<T> activity) { this.activity = activity; disposable = activity.lifecycle() .filter(activityEvent -> activityEvent.equals(ActivityEvent.START)) .flatMap((at) -> dataSubject) .observeOn(AndroidSchedulers.mainThread()) .subscribe(activity::render, this::handleError); }
Example #11
Source File: ViewModel.java From Building-Professional-Android-Applications with MIT License | 5 votes |
public void bind(ViewActivity<T> activity) { this.activity = activity; disposable = activity.lifecycle() .filter(activityEvent -> activityEvent.equals(ActivityEvent.START)) .flatMap((at) -> dataSubject) .observeOn(AndroidSchedulers.mainThread()) .subscribe(activity::render, this::handleError); }
Example #12
Source File: ViewModel.java From Building-Professional-Android-Applications with MIT License | 5 votes |
public void bind(ViewActivity<T> activity) { this.activity = activity; disposable = activity.lifecycle() .filter(activityEvent -> activityEvent.equals(ActivityEvent.START)) .flatMap((at) -> dataSubject) .observeOn(AndroidSchedulers.mainThread()) .subscribe(activity::render, this::handleError); }
Example #13
Source File: ViewModel.java From Building-Professional-Android-Applications with MIT License | 5 votes |
public void bind(ViewActivity<T> activity) { this.activity = activity; disposable = activity.lifecycle() .filter(activityEvent -> activityEvent.equals(ActivityEvent.START)) .flatMap((at) -> dataSubject) .observeOn(AndroidSchedulers.mainThread()) .subscribe(activity::render, this::handleError); }
Example #14
Source File: ViewModel.java From Building-Professional-Android-Applications with MIT License | 5 votes |
public void bind(ViewActivity<T> activity) { this.activity = activity; disposable = activity.lifecycle() .filter(activityEvent -> activityEvent.equals(ActivityEvent.START)) .flatMap((at) -> dataSubject) .observeOn(AndroidSchedulers.mainThread()) .subscribe(activity::render, this::handleError); }
Example #15
Source File: UserPresenter.java From Protein with Apache License 2.0 | 5 votes |
@Override public void start() { view.setupView(user); if (AccountManager.getInstance().getMe() == null || AccountManager.getInstance().getMe().equals(user)) { view.setFollowButtonVisibility(false); } else { view.setFollowButtonVisibility(true); if (followingChecked) { view.setFollowButtonEnabled(true); view.setFollowing(following); } else { repository.isFollowing(user.id()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .compose(((LifecycleProvider<ActivityEvent>) view.getContext()) .bindUntilEvent(ActivityEvent.DESTROY)) .subscribe(response -> { followingChecked = true; view.setFollowButtonEnabled(true); if (response.code() == 204) { following = true; view.setFollowing(true); } else if (response.code() == 404) { following = false; view.setFollowing(false); } }, throwable -> { view.setFollowButtonEnabled(true); view.setFollowing(false); }); } } view.showUser(user); }
Example #16
Source File: ViewModel.java From Building-Professional-Android-Applications with MIT License | 5 votes |
public void bind(ViewActivity<T> activity) { this.activity = activity; disposable = activity.lifecycle() .filter(activityEvent -> activityEvent.equals(ActivityEvent.START)) .flatMap((at) -> dataSubject) .observeOn(AndroidSchedulers.mainThread()) .subscribe(activity::render, this::handleError); }
Example #17
Source File: ActivityLifecycleForRxLifecycle.java From Aurora with Apache License 2.0 | 5 votes |
/** * 通过桥梁对象 {@code BehaviorSubject<ActivityEvent> mLifecycleSubject} * 在每个 Activity 的生命周期中发出对应的生命周期事件 */ @Override public void onActivityCreated(Activity activity, Bundle savedInstanceState) { if (activity instanceof ActivityLifecycleable) { obtainSubject(activity).onNext(ActivityEvent.CREATE); if (activity instanceof FragmentActivity){ if (mFragmentLifecycle == null) { mFragmentLifecycle = new FragmentLifecycleForRxLifecycle(); } ((FragmentActivity) activity).getSupportFragmentManager().registerFragmentLifecycleCallbacks(mFragmentLifecycle, true); } } }
Example #18
Source File: ViewModel.java From Building-Professional-Android-Applications with MIT License | 5 votes |
public void bind(ViewActivity<T> activity) { this.activity = activity; disposable = activity.lifecycle() .filter(activityEvent -> activityEvent.equals(ActivityEvent.START)) .flatMap((at) -> dataSubject) .observeOn(AndroidSchedulers.mainThread()) .subscribe(activity::render, this::handleError); }
Example #19
Source File: RxLifecycleUtils.java From Aurora with Apache License 2.0 | 5 votes |
/** * 绑定 Activity 的指定生命周期 * * @param view * @param event * @param <T> * @return */ public static <T> LifecycleTransformer<T> bindUntilEvent(@NonNull final IView view, final ActivityEvent event) { Preconditions.checkNotNull(view, "view == null"); if (view instanceof ActivityLifecycleable) { return bindUntilEvent((ActivityLifecycleable) view, event); } else { throw new IllegalArgumentException("view isn't ActivityLifecycleable"); } }
Example #20
Source File: MemoryLeakWithRx2Activity.java From My-MVP with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_memory_leak_with_rx2); Observable.interval(1, TimeUnit.SECONDS) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .compose(this.bindUntilEvent(ActivityEvent.DESTROY)) .subscribe(aLong -> Log.e(TAG, "accept: "+aLong )); }
Example #21
Source File: SuperActivity.java From AndroidBase with Apache License 2.0 | 5 votes |
@Override @CallSuper protected void onPause() { InputMethodUtils.hideSoftInput(this); mLifecycleSubject.onNext(ActivityEvent.PAUSE); super.onPause(); }
Example #22
Source File: BaseActivity.java From QuickDevFramework with Apache License 2.0 | 5 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); lifecycleSubject.onNext(ActivityEvent.CREATE); if (printLifeCycle) { Log.d(TAG, "onCreate"); } TAG = this.getClass().getSimpleName(); IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_EXIT_APPLICATION); mReceiver = new ActivityBaseReceiver(); registerReceiver(mReceiver, filter); }
Example #23
Source File: BaseActivity.java From QuickDevFramework with Apache License 2.0 | 5 votes |
@Override protected void onStart() { super.onStart(); lifecycleSubject.onNext(ActivityEvent.START); if (printLifeCycle) { Log.d(TAG, "onStart"); } }
Example #24
Source File: BaseActivity.java From QuickDevFramework with Apache License 2.0 | 5 votes |
@Override protected void onResume() { super.onResume(); lifecycleSubject.onNext(ActivityEvent.RESUME); if (printLifeCycle) { Log.d(TAG, "onResume"); } }
Example #25
Source File: BaseActivity.java From QuickDevFramework with Apache License 2.0 | 5 votes |
@Override protected void onPause() { super.onPause(); lifecycleSubject.onNext(ActivityEvent.PAUSE); if (printLifeCycle) { Log.d(TAG, "onPause"); } }
Example #26
Source File: BaseActivity.java From QuickDevFramework with Apache License 2.0 | 5 votes |
@Override protected void onStop() { super.onStop(); lifecycleSubject.onNext(ActivityEvent.STOP); if (printLifeCycle) { Log.d(TAG, "onStop"); } }
Example #27
Source File: BaseActivity.java From QuickDevFramework with Apache License 2.0 | 5 votes |
@Override protected void onDestroy() { super.onDestroy(); lifecycleSubject.onNext(ActivityEvent.DESTROY); if (printLifeCycle) { Log.d(TAG, "onDestroy"); } unregisterReceiver(mReceiver); }
Example #28
Source File: ActivityLifecycleForRxLifecycle.java From MVPArms with Apache License 2.0 | 5 votes |
/** * 通过桥梁对象 {@code BehaviorSubject<ActivityEvent> mLifecycleSubject} * 在每个 Activity 的生命周期中发出对应的生命周期事件 */ @Override public void onActivityCreated(Activity activity, Bundle savedInstanceState) { if (activity instanceof ActivityLifecycleable) { obtainSubject(activity).onNext(ActivityEvent.CREATE); if (activity instanceof FragmentActivity) { ((FragmentActivity) activity).getSupportFragmentManager().registerFragmentLifecycleCallbacks(mFragmentLifecycle.get(), true); } } }
Example #29
Source File: SuperActivity.java From AndroidBase with Apache License 2.0 | 5 votes |
@Override @CallSuper protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); AppManager.getAppManager().addActivity(this); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { //新版本的转场动画 getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS); } onBeforeSetContentView(); setContentView(getContentViewId()); ButterKnife.bind(this); NetworkStateReceiver.registerNetworkStateReceiver(this); mLifecycleSubject.onNext(ActivityEvent.CREATE); }
Example #30
Source File: RxLifecycleUtils.java From MVPArms with Apache License 2.0 | 5 votes |
/** * 绑定 Activity 的指定生命周期 * * @param view * @param event * @param <T> * @return */ public static <T> LifecycleTransformer<T> bindUntilEvent(@NonNull final IView view, final ActivityEvent event) { Preconditions.checkNotNull(view, "view == null"); if (view instanceof ActivityLifecycleable) { return bindUntilEvent((ActivityLifecycleable) view, event); } else { throw new IllegalArgumentException("view isn't ActivityLifecycleable"); } }