Search in sources :

Example 1 with ObservableScoper

use of com.uber.autodispose.ObservableScoper in project Conductor by bluelinelabs.

the class AutodisposeController method onCreateView.

@NonNull
@Override
protected View onCreateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container) {
    Log.i(TAG, "onCreateView() called");
    View view = inflater.inflate(R.layout.controller_lifecycle, container, false);
    view.setBackgroundColor(ContextCompat.getColor(container.getContext(), R.color.purple_300));
    unbinder = ButterKnife.bind(this, view);
    tvTitle.setText(getResources().getString(R.string.rxlifecycle_title, TAG));
    Observable.interval(1, TimeUnit.SECONDS).doOnDispose(new Action() {

        @Override
        public void run() {
            Log.i(TAG, "Disposing from onCreateView()");
        }
    }).to(new ObservableScoper<Long>(scopeProvider)).subscribe(new Consumer<Long>() {

        @Override
        public void accept(Long num) {
            Log.i(TAG, "Started in onCreateView(), running until onDestroyView(): " + num);
        }
    });
    return view;
}
Also used : Action(io.reactivex.functions.Action) BindView(butterknife.BindView) View(android.view.View) TextView(android.widget.TextView) ObservableScoper(com.uber.autodispose.ObservableScoper) NonNull(android.support.annotation.NonNull)

Example 2 with ObservableScoper

use of com.uber.autodispose.ObservableScoper in project Conductor by bluelinelabs.

the class AutodisposeController method onAttach.

@Override
protected void onAttach(@NonNull View view) {
    super.onAttach(view);
    Log.i(TAG, "onAttach() called");
    (((ActionBarProvider) getActivity()).getSupportActionBar()).setTitle("Autodispose Demo");
    Observable.interval(1, TimeUnit.SECONDS).doOnDispose(new Action() {

        @Override
        public void run() {
            Log.i(TAG, "Disposing from onAttach()");
        }
    }).to(new ObservableScoper<Long>(scopeProvider)).subscribe(new Consumer<Long>() {

        @Override
        public void accept(Long num) {
            Log.i(TAG, "Started in onAttach(), running until onDetach(): " + num);
        }
    });
}
Also used : Action(io.reactivex.functions.Action) ActionBarProvider(com.bluelinelabs.conductor.demo.ActionBarProvider) ObservableScoper(com.uber.autodispose.ObservableScoper)

Aggregations

ObservableScoper (com.uber.autodispose.ObservableScoper)2 Action (io.reactivex.functions.Action)2 NonNull (android.support.annotation.NonNull)1 View (android.view.View)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1 ActionBarProvider (com.bluelinelabs.conductor.demo.ActionBarProvider)1