Search in sources :

Example 11 with SubmissionsView

use of me.ccrama.redditslide.Fragments.SubmissionsView in project Slide by ccrama.

the class MainActivity method scrollToTop.

public void scrollToTop() {
    int[] firstVisibleItems;
    int pastVisiblesItems = 0;
    if (((adapter.getCurrentFragment()) == null))
        return;
    firstVisibleItems = ((CatchStaggeredGridLayoutManager) (((SubmissionsView) adapter.getCurrentFragment()).rv.getLayoutManager())).findFirstVisibleItemPositions(null);
    if (firstVisibleItems != null && firstVisibleItems.length > 0) {
        for (int firstVisibleItem : firstVisibleItems) {
            pastVisiblesItems = firstVisibleItem;
        }
    }
    if (pastVisiblesItems > 8) {
        ((SubmissionsView) adapter.getCurrentFragment()).rv.scrollToPosition(0);
        header.animate().translationY(header.getHeight()).setInterpolator(new LinearInterpolator()).setDuration(0);
    } else {
        ((SubmissionsView) adapter.getCurrentFragment()).rv.smoothScrollToPosition(0);
    }
    ((SubmissionsView) adapter.getCurrentFragment()).resetScroll();
}
Also used : LinearInterpolator(android.view.animation.LinearInterpolator) SubmissionsView(me.ccrama.redditslide.Fragments.SubmissionsView) Point(android.graphics.Point)

Aggregations

SubmissionsView (me.ccrama.redditslide.Fragments.SubmissionsView)11 View (android.view.View)6 TextView (android.widget.TextView)6 Point (android.graphics.Point)5 HorizontalScrollView (android.widget.HorizontalScrollView)5 ImageView (android.widget.ImageView)5 SpoilerRobotoTextView (me.ccrama.redditslide.SpoilerRobotoTextView)5 DialogInterface (android.content.DialogInterface)4 Intent (android.content.Intent)4 AlertDialogWrapper (com.afollestad.materialdialogs.AlertDialogWrapper)4 ActivityNotFoundException (android.content.ActivityNotFoundException)3 Snackbar (android.support.design.widget.Snackbar)3 CardView (android.support.v7.widget.CardView)3 LinearInterpolator (android.view.animation.LinearInterpolator)3 AutoCompleteTextView (android.widget.AutoCompleteTextView)3 ListView (android.widget.ListView)3 DialogAction (com.afollestad.materialdialogs.DialogAction)3 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)3 CatchStaggeredGridLayoutManager (me.ccrama.redditslide.Views.CatchStaggeredGridLayoutManager)3 Submission (net.dean.jraw.models.Submission)3