Search in sources :

Example 41 with CompositeSubscription

use of rx.subscriptions.CompositeSubscription in project twicalico by moko256.

the class ShowUserActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_show_user);
    subscription = new CompositeSubscription();
    setSupportActionBar(findViewById(R.id.toolbar_show_user));
    actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeAsUpIndicator(R.drawable.ic_back_white_24dp);
    viewPager = findViewById(R.id.show_user_view_pager);
    viewPager.setOffscreenPageLimit(1);
    tabLayout = findViewById(R.id.tab_show_user);
    tabLayout.setupWithViewPager(viewPager);
    tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
    tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {

        @Override
        public void onTabSelected(TabLayout.Tab tab) {
        }

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {
        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {
            Fragment fragment = ((FragmentPagerAdapter) viewPager.getAdapter()).getFragment(tab.getPosition());
            if (fragment instanceof MovableTopInterface) {
                ((MovableTopInterface) fragment).moveToTop();
            }
        }
    });
    tweetListViewPool = new RecyclerView.RecycledViewPool();
    userListViewPool = new RecyclerView.RecycledViewPool();
    findViewById(R.id.activity_show_user_fab).setOnClickListener(v -> {
        if (user != null) {
            startActivity(PostActivity.getIntent(this, TwitterStringUtils.plusAtMark(user.getScreenName()) + " "));
        }
    });
    userScreenName = getIntent().getStringExtra("userScreenName");
    userId = getIntent().getLongExtra("userId", -1);
    if (userId != -1) {
        user = GlobalApplication.userCache.get(userId);
    }
    if (user != null) {
        new ShowUserFragmentsPagerAdapter(getSupportFragmentManager(), this, user.getId()).initAdapter(viewPager);
    } else {
        subscription.add(getUserSingle().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(it -> {
            user = it;
            new ShowUserFragmentsPagerAdapter(getSupportFragmentManager(), this, it.getId()).initAdapter(viewPager);
        }, e -> Snackbar.make(findViewById(getSnackBarParentContainerId()), TwitterStringUtils.convertErrorToText(e), Snackbar.LENGTH_INDEFINITE).show()));
    }
}
Also used : Completable(rx.Completable) Context(android.content.Context) Type(com.github.moko256.twicalico.entity.Type) Bundle(android.os.Bundle) ViewPager(android.support.v4.view.ViewPager) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) Intent(android.content.Intent) TwitterStringUtils(com.github.moko256.twicalico.text.TwitterStringUtils) MenuItem(android.view.MenuItem) TabLayout(android.support.design.widget.TabLayout) Single(rx.Single) MastodonTwitterImpl(com.github.moko256.mastodon.MastodonTwitterImpl) AppCustomTabsKt(com.github.moko256.twicalico.intent.AppCustomTabsKt) Toast(android.widget.Toast) Menu(android.view.Menu) Schedulers(rx.schedulers.Schedulers) User(twitter4j.User) TwitterException(twitter4j.TwitterException) ActionBar(android.support.v7.app.ActionBar) Fragment(android.support.v4.app.Fragment) Twitter(twitter4j.Twitter) AppCompatActivity(android.support.v7.app.AppCompatActivity) CompositeSubscription(rx.subscriptions.CompositeSubscription) RecyclerView(android.support.v7.widget.RecyclerView) AlertDialog(android.support.v7.app.AlertDialog) FragmentPagerAdapter(com.github.moko256.twicalico.widget.FragmentPagerAdapter) Snackbar(android.support.design.widget.Snackbar) CompositeSubscription(rx.subscriptions.CompositeSubscription) TabLayout(android.support.design.widget.TabLayout) RecyclerView(android.support.v7.widget.RecyclerView) Fragment(android.support.v4.app.Fragment)

Example 42 with CompositeSubscription

use of rx.subscriptions.CompositeSubscription in project twicalico by moko256.

the class TrendsFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    list = new ArrayList<>();
    subscription = new CompositeSubscription();
    helper = new CachedTrendsSQLiteOpenHelper(getContext(), GlobalApplication.userId);
    if (savedInstanceState == null) {
        List<Trend> trends = helper.getTrends();
        if (trends.size() > 0) {
            list = trends;
            setRefreshing(false);
        }
    }
    super.onCreate(savedInstanceState);
}
Also used : CompositeSubscription(rx.subscriptions.CompositeSubscription) Trend(twitter4j.Trend) CachedTrendsSQLiteOpenHelper(com.github.moko256.twicalico.database.CachedTrendsSQLiteOpenHelper)

Example 43 with CompositeSubscription

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

the class LogsDialog method onStart.

@Override
protected void onStart() {
    super.onStart();
    adapter.setLogs(lumberYard.bufferedLogs());
    subscriptions = new CompositeSubscription();
    subscriptions.add(// 
    lumberYard.logs().observeOn(// 
    AndroidSchedulers.mainThread()).subscribe(adapter));
}
Also used : CompositeSubscription(rx.subscriptions.CompositeSubscription)

Example 44 with CompositeSubscription

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

the class ChatInputView method onAttachedToWindow.

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

Example 45 with CompositeSubscription

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

the class CurrencyPresenter method initLongLivingObjects.

private void initLongLivingObjects() {
    this.subscriptions = new CompositeSubscription();
    this.currencies = new ArrayList<>();
}
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