use of com.kickstarter.libs.SwipeRefresher in project android-oss by kickstarter.
the class ActivityFeedActivity method onCreate.
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((KSApplication) getApplication()).component().inject(this);
setContentView(R.layout.activity_feed_layout);
ButterKnife.bind(this);
adapter = new ActivityFeedAdapter(viewModel.inputs);
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerViewPaginator = new RecyclerViewPaginator(recyclerView, viewModel.inputs::nextPage);
swipeRefresher = new SwipeRefresher(this, swipeRefreshLayout, viewModel.inputs::refresh, viewModel.outputs::isFetchingActivities);
// Only allow refreshing if there's a current user
currentUser.observable().map(ObjectUtils::isNotNull).compose(bindToLifecycle()).compose(observeForUI()).subscribe(swipeRefreshLayout::setEnabled);
viewModel.outputs.activities().compose(bindToLifecycle()).compose(observeForUI()).subscribe(this::showActivities);
viewModel.outputs.loggedOutEmptyStateIsVisible().compose(bindToLifecycle()).compose(observeForUI()).subscribe(adapter::showLoggedOutEmptyState);
viewModel.outputs.loggedInEmptyStateIsVisible().compose(bindToLifecycle()).compose(observeForUI()).subscribe(adapter::showLoggedInEmptyState);
viewModel.outputs.goToDiscovery().compose(bindToLifecycle()).compose(observeForUI()).subscribe(__ -> resumeDiscoveryActivity());
viewModel.outputs.goToLogin().compose(bindToLifecycle()).compose(observeForUI()).subscribe(__ -> startActivityFeedLogin());
viewModel.outputs.goToProject().compose(bindToLifecycle()).compose(observeForUI()).subscribe(this::startProjectActivity);
viewModel.outputs.goToProjectUpdate().compose(bindToLifecycle()).compose(observeForUI()).subscribe(this::startProjectUpdateActivity);
}
use of com.kickstarter.libs.SwipeRefresher in project android-oss by kickstarter.
the class CommentsActivity method onCreate.
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.comments_layout);
ButterKnife.bind(this);
adapter = new CommentsAdapter(this);
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerViewPaginator = new RecyclerViewPaginator(recyclerView, viewModel.inputs::nextPage);
swipeRefresher = new SwipeRefresher(this, swipeRefreshLayout, viewModel.inputs::refresh, viewModel.outputs::isFetchingComments);
final Observable<TextView> commentBodyEditText = alertDialog.map(a -> ButterKnife.findById(a, R.id.comment_body));
final Observable<TextView> postCommentButton = alertDialog.map(a -> ButterKnife.findById(a, R.id.post_button));
final Observable<TextView> cancelButton = alertDialog.map(a -> ButterKnife.findById(a, R.id.cancel_button));
cancelButton.switchMap(RxView::clicks).observeOn(AndroidSchedulers.mainThread()).compose(bindToLifecycle()).subscribe(__ -> viewModel.inputs.commentDialogDismissed());
postCommentButton.switchMap(RxView::clicks).compose(bindToLifecycle()).subscribe(__ -> viewModel.inputs.postCommentClicked());
commentBodyEditText.switchMap(t -> RxTextView.textChanges(t).skip(1)).map(CharSequence::toString).compose(bindToLifecycle()).subscribe(viewModel.inputs::commentBodyChanged);
viewModel.outputs.currentCommentBody().compose(Transformers.takePairWhen(commentBodyEditText)).observeOn(AndroidSchedulers.mainThread()).compose(bindToLifecycle()).subscribe(ce -> ce.second.append(ce.first));
viewModel.outputs.commentsData().compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(adapter::takeData);
viewModel.outputs.enablePostButton().compose(Transformers.combineLatestPair(postCommentButton)).compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(bb -> setPostButtonEnabled(bb.second, bb.first));
viewModel.outputs.showCommentButton().map(show -> show ? View.VISIBLE : View.GONE).compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(commentButtonTextView::setVisibility);
viewModel.outputs.showCommentDialog().filter(projectAndShow -> projectAndShow != null).map(projectAndShow -> projectAndShow.first).compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(this::showCommentDialog);
alertDialog.compose(Transformers.takeWhen(viewModel.outputs.dismissCommentDialog())).observeOn(AndroidSchedulers.mainThread()).compose(bindToLifecycle()).subscribe(this::dismissCommentDialog);
lifecycle().compose(Transformers.combineLatestPair(alertDialog)).filter(ad -> ad.first == ActivityEvent.DESTROY).map(ad -> ad.second).observeOn(AndroidSchedulers.mainThread()).take(1).subscribe(this::dismissCommentDialog);
toastMessages().compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(ViewUtils.showToast(this));
}
Aggregations