florent37.github.com.rxlifecycle.RxLifecycle Java Examples

The following examples show how to use florent37.github.com.rxlifecycle.RxLifecycle. 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: TabbedMainActivity.java    From ShapeOfView with Apache License 2.0 8 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.shape_of_view_tabbed_activity_main);
    ButterKnife.bind(this);
    Mapbox.getInstance(this, "pk.eyJ1IjoiY2hpY2tpbm5pY2siLCJhIjoiY2pka3U2YTdiMDE1YTJ4cjA0YzVyYnpoMSJ9.xlyPakmrR_N4bNqIGe6AKg");
    viewPager.setAdapter(new FakeAdapter(getSupportFragmentManager()));

    tabLayout.setupWithViewPager(viewPager);

    TabIndicatorFollower.setupWith(tabLayout, triangle);
    mapView = (MapView) findViewById(R.id.mapView);
    mapView.onCreate(savedInstanceState);

    RxLifecycle.with(this).onResume().subscribe(event -> mapView.onResume());
    RxLifecycle.with(this).onPause().subscribe(event -> mapView.onPause());
    RxLifecycle.with(this).onStop().subscribe(event -> mapView.onStop());
    RxLifecycle.with(this).onDestroy().subscribe(event -> mapView.onDestroy());
}
 
Example #2
Source File: AbstractPresenter.java    From Open-Mam with Apache License 2.0 5 votes vote down vote up
public void bind(LifecycleRegistry lifecycle, V view) {
    unbind();
    this.viewReference = new WeakReference<V>(view);
    RxLifecycle.with(lifecycle)
            .onDestroy()
            .doOnSubscribe(this::call)
            .subscribe(x -> unbind());
}