Search in sources :

Example 26 with CompositeSubscription

use of rx.subscriptions.CompositeSubscription in project sbt-android by scala-android.

the class DebugAppContainer method bind.

@Override
public ViewGroup bind(final Activity activity) {
    activity.setContentView(R.layout.debug_activity_frame);
    final ViewHolder viewHolder = new ViewHolder();
    ButterKnife.bind(viewHolder, activity);
    final Context drawerContext = new ContextThemeWrapper(activity, R.style.Theme_U2020_Debug);
    final DebugView debugView = new DebugView(drawerContext);
    viewHolder.debugDrawer.addView(debugView);
    // Set up the contextual actions to watch views coming in and out of the content area.
    ContextualDebugActions contextualActions = debugView.getContextualDebugActions();
    contextualActions.setActionClickListener(v -> viewHolder.drawerLayout.closeDrawers());
    viewHolder.content.setOnHierarchyChangeListener(HierarchyTreeChangeListener.wrap(contextualActions));
    viewHolder.drawerLayout.setDrawerShadow(R.drawable.debug_drawer_shadow, GravityCompat.END);
    viewHolder.drawerLayout.setDrawerListener(new DebugDrawerLayout.SimpleDrawerListener() {

        @Override
        public void onDrawerOpened(View drawerView) {
            debugView.onDrawerOpened();
        }
    });
    // Clean up any old screenshots.
    TelescopeLayout.cleanUp(activity);
    viewHolder.telescopeLayout.setLens(new BugReportLens(activity, lumberYard));
    // If you have not seen the debug drawer before, show it with a message
    if (!seenDebugDrawer.get()) {
        viewHolder.drawerLayout.postDelayed(() -> {
            viewHolder.drawerLayout.openDrawer(GravityCompat.END);
            Toast.makeText(drawerContext, R.string.debug_drawer_welcome, Toast.LENGTH_LONG).show();
        }, 1000);
        seenDebugDrawer.set(true);
    }
    final CompositeSubscription subscriptions = new CompositeSubscription();
    setupMadge(viewHolder, subscriptions);
    setupScalpel(viewHolder, subscriptions);
    final Application app = activity.getApplication();
    app.registerActivityLifecycleCallbacks(new EmptyActivityLifecycleCallbacks() {

        @Override
        public void onActivityDestroyed(Activity lifecycleActivity) {
            if (lifecycleActivity == activity) {
                subscriptions.unsubscribe();
                app.unregisterActivityLifecycleCallbacks(this);
            }
        }
    });
    riseAndShine(activity);
    return viewHolder.content;
}
Also used : Context(android.content.Context) EmptyActivityLifecycleCallbacks(com.jakewharton.u2020.util.EmptyActivityLifecycleCallbacks) Activity(android.app.Activity) View(android.view.View) BugReportLens(com.jakewharton.u2020.ui.bugreport.BugReportLens) ContextThemeWrapper(android.view.ContextThemeWrapper) CompositeSubscription(rx.subscriptions.CompositeSubscription) Application(android.app.Application)

Example 27 with CompositeSubscription

use of rx.subscriptions.CompositeSubscription in project toshi-android-client by toshiapp.

the class BalanceBar method onAttachedToWindow.

@Override
public void onAttachedToWindow() {
    super.onAttachedToWindow();
    this.subscriptions = new CompositeSubscription();
    attachBalanceSubscriber();
}
Also used : CompositeSubscription(rx.subscriptions.CompositeSubscription)

Example 28 with CompositeSubscription

use of rx.subscriptions.CompositeSubscription in project AndroidQuick by ddnosh.

the class Network2Fragment method initViewsAndEvents.

@Override
protected void initViewsAndEvents() {
    DialogUtil.showLoadingDialog(mContext, "加载中...");
    mTestBeanList = new ArrayList<>();
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    mRecyclerView.setHasFixedSize(true);
    mCommonAdapter = new CommonAdapter<TestBean>(getActivity(), R.layout.item_common_adapter_2, mTestBeanList) {

        @Override
        public void convert(CommonViewHolder holder, final TestBean bean) {
            holder.setText(R.id.tv_login, bean.getLogin());
            holder.setText(R.id.tv_id, bean.getId() + "");
            holder.setImageResourceWithGlide(R.id.iv_avatar, bean.getAvatar_url());
            holder.setOnClickListener(R.id.ll_rv_common_adapter_item, new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    LogUtil.d(TAG, "onItemClick");
                    ToastUtil.showToast(bean.getLogin() + " clicked!");
                    bean.setLogin(bean.getLogin() + " clicked!");
                    notifyDataSetChanged();
                }
            });
        }
    };
    mRecyclerView.setAdapter(mCommonAdapter);
    mCompositeSubscription = new CompositeSubscription();
    mRetrofitManager = new RetrofitManager();
    Subscription subscription = mRetrofitManager.createApi(MyApplication.getInstance().getApplicationContext(), TestApis.class).getOctocat("https://api.github.com/repos/octocat/Hello-World/contributors").subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new BaseSubscriber<List<TestBean>>() {

        @Override
        public void onNext(List<TestBean> list) {
            DialogUtil.dismissLoadingDialog(mContext);
            LogUtil.i(TAG, list.toString());
            // 不能这样赋值:mTestBeanList = list;
            // 方法一
            // mTestBeanList.clear();
            // mTestBeanList.addAll(list);
            // mCommonAdapter.notifyDataSetChanged();
            // 方法二
            mCommonAdapter.update(list);
        }

        @Override
        public void onError(Throwable e) {
            super.onError(e);
            DialogUtil.dismissLoadingDialog(mContext);
        }
    });
    mCompositeSubscription.add(subscription);
}
Also used : CommonViewHolder(la.xiong.androidquick.ui.adapter.CommonViewHolder) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) BindView(butterknife.BindView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) RetrofitManager(la.xiong.androidquick.network.RetrofitManager) TestBean(la.xiong.androidquick.demo.bean.TestBean) CompositeSubscription(rx.subscriptions.CompositeSubscription) ArrayList(java.util.ArrayList) List(java.util.List) CompositeSubscription(rx.subscriptions.CompositeSubscription) Subscription(rx.Subscription)

Example 29 with CompositeSubscription

use of rx.subscriptions.CompositeSubscription in project ListenerMusicPlayer by hefuyicoder.

the class AlbumDetailPresenter method attachView.

@Override
public void attachView(AlbumDetailContract.View view) {
    mView = view;
    mCompositeSubscription = new CompositeSubscription();
}
Also used : CompositeSubscription(rx.subscriptions.CompositeSubscription)

Example 30 with CompositeSubscription

use of rx.subscriptions.CompositeSubscription in project ListenerMusicPlayer by hefuyicoder.

the class ArtistSongPresenter method attachView.

@Override
public void attachView(ArtistSongContract.View view) {
    mView = view;
    mCompositeSubscription = new CompositeSubscription();
}
Also used : CompositeSubscription(rx.subscriptions.CompositeSubscription)

Aggregations

CompositeSubscription (rx.subscriptions.CompositeSubscription)49 ArrayList (java.util.ArrayList)9 View (android.view.View)7 Subscription (rx.Subscription)7 Context (android.content.Context)6 Bundle (android.os.Bundle)6 AndroidSchedulers (rx.android.schedulers.AndroidSchedulers)6 Intent (android.content.Intent)5 AppCompatActivity (android.support.v7.app.AppCompatActivity)5 RecyclerView (android.support.v7.widget.RecyclerView)5 ViewGroup (android.view.ViewGroup)5 List (java.util.List)5 Schedulers (rx.schedulers.Schedulers)5 MenuItem (android.view.MenuItem)4 Issue (com.kboyarshinov.realmrxjavaexample.model.Issue)4 ActionBar (android.support.v7.app.ActionBar)3 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)3 Menu (android.view.Menu)3 TextView (android.widget.TextView)3 TwitterStringUtils (com.github.moko256.twicalico.text.TwitterStringUtils)3