Android Open Source - material-dialogs Recycler Util






From Project

Back to project page material-dialogs.

License

The source code is released under:

MIT License

If you think the Android project material-dialogs listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.afollestad.materialdialogs.util;
/* w w w.j  a  v  a  2 s.  c  om*/
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.afollestad.materialdialogs.MaterialDialog;

public class RecyclerUtil {

    public static boolean canRecyclerViewScroll(View view) {

        RecyclerView rv = (RecyclerView) view;

        final RecyclerView.LayoutManager lm = rv.getLayoutManager();
        final int count = rv.getAdapter().getItemCount();
        int lastVisible;

        if (lm instanceof LinearLayoutManager) {
            LinearLayoutManager llm = (LinearLayoutManager) lm;
            lastVisible = llm.findLastVisibleItemPosition();
        } else if (lm instanceof GridLayoutManager) {
            GridLayoutManager glm = (GridLayoutManager) lm;
            lastVisible = glm.findLastVisibleItemPosition();
        } else {
            throw new MaterialDialog.NotImplementedException("Material Dialogs currently only supports LinearLayoutManager and GridLayoutManager. Please report any new layout managers.");
        }

        if (lastVisible == -1)
            return false;
        /* We scroll if the last item is not visible */
        final boolean lastItemVisible = lastVisible == count - 1;
        return !lastItemVisible || rv.getChildAt(rv.getChildCount() - 1).getBottom() > rv.getHeight() - rv.getPaddingBottom();
    }

    public static boolean isRecyclerView(View view) {
        return view instanceof RecyclerView;
    }
}




Java Source Code List

com.afollestad.materialdialogs.ApplicationTest.java
com.afollestad.materialdialogs.DialogAction.java
com.afollestad.materialdialogs.GravityEnum.java
com.afollestad.materialdialogs.MaterialDialogCompat.java
com.afollestad.materialdialogs.MaterialDialog.java
com.afollestad.materialdialogs.ThemeSingleton.java
com.afollestad.materialdialogs.Theme.java
com.afollestad.materialdialogs.base.DialogBase.java
com.afollestad.materialdialogs.util.DialogUtils.java
com.afollestad.materialdialogs.util.RecyclerUtil.java
com.afollestad.materialdialogs.util.TypefaceHelper.java
com.afollestad.materialdialogssample.ApplicationTest.java
com.afollestad.materialdialogssample.ButtonItemAdapter.java
com.afollestad.materialdialogssample.ColorChooserDialog.java
com.afollestad.materialdialogssample.FolderSelectorDialog.java
com.afollestad.materialdialogssample.MainActivity.java