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();
}
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();
}
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();
}
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);
}
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);
})));
}
Aggregations