Search in sources :

Example 16 with CompositeSubscription

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

the class PlaylistDetailPresenter method attachView.

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

Example 17 with CompositeSubscription

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

the class PlaylistPresenter method attachView.

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

Example 18 with CompositeSubscription

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

the class QuickControlsPresenter method attachView.

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

Example 19 with CompositeSubscription

use of rx.subscriptions.CompositeSubscription in project realm-java by realm.

the class DetailsPresenter method onResume.

@Override
public void onResume() {
    // Show story details
    Subscription detailsSubscription = model.getStory(storyId).subscribe(new Action1<NYTimesStory>() {

        @Override
        public void call(NYTimesStory story) {
            view.hideLoader();
            view.showStory(story);
            view.setRead(story.isRead());
        }
    });
    // Mark story as read if screen is visible for 2 seconds
    Subscription timerSubscription = Observable.timer(2, TimeUnit.SECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Long>() {

        @Override
        public void call(Long aLong) {
            model.markAsRead(storyId, true);
        }
    });
    subscriptions = new CompositeSubscription(detailsSubscription, timerSubscription);
}
Also used : NYTimesStory(io.realm.examples.newsreader.model.entity.NYTimesStory) CompositeSubscription(rx.subscriptions.CompositeSubscription) CompositeSubscription(rx.subscriptions.CompositeSubscription) Subscription(rx.Subscription)

Example 20 with CompositeSubscription

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

the class ShowTweetActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_show_tweet);
    subscriptions = new CompositeSubscription();
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeAsUpIndicator(R.drawable.ic_back_white_24dp);
    }
    statusId = getIntent().getLongExtra("statusId", -1);
    if (statusId == -1) {
        ShowTweetActivity.this.finish();
        return;
    }
    Status status = GlobalApplication.statusCache.get(statusId);
    if (status == null) {
        subscriptions.add(updateStatus().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(result -> {
            if (result == null) {
                finish();
                return;
            }
            updateView(result);
        }, e -> {
            e.printStackTrace();
            finish();
        }));
    } else {
        updateView(status);
    }
    SwipeRefreshLayout swipeRefreshLayout = findViewById(R.id.tweet_show_swipe_refresh);
    swipeRefreshLayout.setColorSchemeResources(R.color.color_primary);
    swipeRefreshLayout.setOnRefreshListener(() -> subscriptions.add(updateStatus().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(result -> {
        if (result == null) {
            finish();
            return;
        }
        updateView(result);
        swipeRefreshLayout.setRefreshing(false);
    }, e -> {
        e.printStackTrace();
        Toast.makeText(this, R.string.error_occurred, Toast.LENGTH_SHORT).show();
        swipeRefreshLayout.setRefreshing(false);
    })));
}
Also used : Status(twitter4j.Status) Context(android.content.Context) Bundle(android.os.Bundle) PostTweetModel(com.github.moko256.twicalico.model.base.PostTweetModel) FrameLayout(android.widget.FrameLayout) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) Intent(android.content.Intent) LinkMovementMethod(android.text.method.LinkMovementMethod) TwitterStringUtils(com.github.moko256.twicalico.text.TwitterStringUtils) UserMentionEntity(twitter4j.UserMentionEntity) MenuItem(android.view.MenuItem) AppCompatButton(android.support.v7.widget.AppCompatButton) Single(rx.Single) AppCustomTabsKt(com.github.moko256.twicalico.intent.AppCustomTabsKt) Toast(android.widget.Toast) Menu(android.view.Menu) Schedulers(rx.schedulers.Schedulers) TwitterException(twitter4j.TwitterException) VISIBLE(android.view.View.VISIBLE) ActionBar(android.support.v7.app.ActionBar) DateFormat(java.text.DateFormat) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) StatusCacheMap(com.github.moko256.twicalico.cacheMap.StatusCacheMap) AppCompatActivity(android.support.v7.app.AppCompatActivity) ViewGroup(android.view.ViewGroup) CompositeSubscription(rx.subscriptions.CompositeSubscription) TextView(android.widget.TextView) GONE(android.view.View.GONE) Html(android.text.Html) Status(twitter4j.Status) PostTweetModelCreator(com.github.moko256.twicalico.model.impl.PostTweetModelCreator) AppCompatEditText(android.support.v7.widget.AppCompatEditText) CompositeSubscription(rx.subscriptions.CompositeSubscription) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) ActionBar(android.support.v7.app.ActionBar)

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