浏览代码

Remove remaining RecyclerView refs out of MaterialDialog.java

This is the safest way, only Recyclerutil.java has access to it and it will only ever be used it it's already been determined that RecyclerView is in the classpath

I also removed it from the sample, since it doesn't actually use RecyclerView. This also is a good way to test that it works, as the sample now has no RecyclerView dependency in it (either explicitly delcared or from the underlying library)
Henri Sweers 10 年之前
父节点
当前提交
d59fadc62f

+ 2 - 3
library/src/main/java/com/afollestad/materialdialogs/MaterialDialog.java

@@ -20,7 +20,6 @@ import android.support.annotation.LayoutRes;
 import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
 import android.support.annotation.StringRes;
-import android.support.v7.widget.RecyclerView;
 import android.text.method.LinkMovementMethod;
 import android.view.ContextThemeWrapper;
 import android.view.Gravity;
@@ -522,7 +521,7 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
         } else if (view instanceof WebView) {
             return canWebViewScroll((WebView) view);
         } else if (isRecyclerView(view)) {
-            return RecyclerUtil.canRecyclerViewScroll((RecyclerView) view);
+            return RecyclerUtil.canRecyclerViewScroll(view);
         } else {
             if (atBottom) {
                 return canViewOrChildScroll(getBottomView((ViewGroup) view), true);
@@ -538,7 +537,7 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
             Class.forName("android.support.v7.widget.RecyclerView");
 
             // We got here, so now we can safely check
-            isRecyclerView = view instanceof RecyclerView;
+            isRecyclerView = RecyclerUtil.isRecyclerView(view);
         } catch (ClassNotFoundException ignored) {}
 
         return isRecyclerView;

+ 9 - 1
library/src/main/java/com/afollestad/materialdialogs/RecyclerUtil.java

@@ -3,9 +3,13 @@ package com.afollestad.materialdialogs;
 import android.support.v7.widget.GridLayoutManager;
 import android.support.v7.widget.LinearLayoutManager;
 import android.support.v7.widget.RecyclerView;
+import android.view.View;
 
 public class RecyclerUtil {
-    static boolean canRecyclerViewScroll(RecyclerView rv) {
+    static boolean canRecyclerViewScroll(View view) {
+
+        RecyclerView rv = (RecyclerView) view;
+
         final RecyclerView.LayoutManager lm = rv.getLayoutManager();
         final int count = rv.getAdapter().getItemCount();
         int lastVisible;
@@ -26,4 +30,8 @@ public class RecyclerUtil {
         final boolean lastItemVisible = lastVisible == count - 1;
         return !lastItemVisible || rv.getChildAt(rv.getChildCount() - 1).getBottom() > rv.getHeight() - rv.getPaddingBottom();
     }
+
+    static boolean isRecyclerView(View view) {
+        return view instanceof RecyclerView;
+    }
 }

+ 0 - 1
sample/build.gradle

@@ -19,5 +19,4 @@ android {
 dependencies {
     compile fileTree(dir: 'libs', include: ['*.jar'])
     compile project(':library')
-    compile 'com.android.support:recyclerview-v7:21.0.3'
 }