From 40665d5f11d50a2e96c13a8e68798711ba88917f Mon Sep 17 00:00:00 2001 From: "yan.kong" Date: Tue, 7 Jul 2020 09:31:02 +0800 Subject: [PATCH] =?UTF-8?q?fix(setNoScrolling):=20=E8=A7=A3=E5=86=B3Virtua?= =?UTF-8?q?lLayoutManager.setNoScrolling(=E8=AE=A9recyclerView=E7=BB=98?= =?UTF-8?q?=E5=88=B6=E6=89=80=E6=9C=89item)=E4=B8=8D=E7=94=9F=E6=95=88?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E4=B8=94=E6=97=A0=E9=99=90=E5=BE=AA=E7=8E=AF?= =?UTF-8?q?onMeasure=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vlayout/example/VLayoutActivity.java | 65 ++++++----- .../res/layout/main_noscroll_activity.xml | 107 ++++++++++++++++++ .../android/vlayout/VirtualLayoutManager.java | 15 ++- 3 files changed, 156 insertions(+), 31 deletions(-) create mode 100644 examples/src/main/res/layout/main_noscroll_activity.xml diff --git a/examples/src/main/java/com/alibaba/android/vlayout/example/VLayoutActivity.java b/examples/src/main/java/com/alibaba/android/vlayout/example/VLayoutActivity.java index daeb7975..03bcf27f 100644 --- a/examples/src/main/java/com/alibaba/android/vlayout/example/VLayoutActivity.java +++ b/examples/src/main/java/com/alibaba/android/vlayout/example/VLayoutActivity.java @@ -24,27 +24,6 @@ package com.alibaba.android.vlayout.example; -import com.alibaba.android.vlayout.DelegateAdapter; -import com.alibaba.android.vlayout.LayoutHelper; -import com.alibaba.android.vlayout.RecyclablePagerAdapter; -import com.alibaba.android.vlayout.VirtualLayoutManager; -import com.alibaba.android.vlayout.VirtualLayoutManager.LayoutParams; -import com.alibaba.android.vlayout.extend.LayoutManagerCanScrollListener; -import com.alibaba.android.vlayout.extend.PerformanceMonitor; -import com.alibaba.android.vlayout.extend.ViewLifeCycleListener; -import com.alibaba.android.vlayout.layout.ColumnLayoutHelper; -import com.alibaba.android.vlayout.layout.FixLayoutHelper; -import com.alibaba.android.vlayout.layout.FloatLayoutHelper; -import com.alibaba.android.vlayout.layout.GridLayoutHelper; -import com.alibaba.android.vlayout.layout.LinearLayoutHelper; -import com.alibaba.android.vlayout.layout.OnePlusNLayoutHelper; -import com.alibaba.android.vlayout.layout.RangeGridLayoutHelper; -import com.alibaba.android.vlayout.layout.RangeGridLayoutHelper.GridRangeStyle; -import com.alibaba.android.vlayout.layout.ScrollFixLayoutHelper; -import com.alibaba.android.vlayout.layout.SingleLayoutHelper; -import com.alibaba.android.vlayout.layout.StaggeredGridLayoutHelper; -import com.alibaba.android.vlayout.layout.StickyLayoutHelper; - import android.app.Activity; import android.content.Context; import android.graphics.Color; @@ -59,7 +38,6 @@ import android.support.v7.widget.RecyclerView; import android.text.TextUtils; import android.util.Log; -import android.util.Pair; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -67,7 +45,27 @@ import android.widget.EditText; import android.widget.TextView; -import java.util.ArrayList; +import com.alibaba.android.vlayout.DelegateAdapter; +import com.alibaba.android.vlayout.LayoutHelper; +import com.alibaba.android.vlayout.RecyclablePagerAdapter; +import com.alibaba.android.vlayout.VirtualLayoutManager; +import com.alibaba.android.vlayout.VirtualLayoutManager.LayoutParams; +import com.alibaba.android.vlayout.extend.LayoutManagerCanScrollListener; +import com.alibaba.android.vlayout.extend.PerformanceMonitor; +import com.alibaba.android.vlayout.extend.ViewLifeCycleListener; +import com.alibaba.android.vlayout.layout.ColumnLayoutHelper; +import com.alibaba.android.vlayout.layout.FixLayoutHelper; +import com.alibaba.android.vlayout.layout.FloatLayoutHelper; +import com.alibaba.android.vlayout.layout.GridLayoutHelper; +import com.alibaba.android.vlayout.layout.LinearLayoutHelper; +import com.alibaba.android.vlayout.layout.OnePlusNLayoutHelper; +import com.alibaba.android.vlayout.layout.RangeGridLayoutHelper; +import com.alibaba.android.vlayout.layout.RangeGridLayoutHelper.GridRangeStyle; +import com.alibaba.android.vlayout.layout.ScrollFixLayoutHelper; +import com.alibaba.android.vlayout.layout.SingleLayoutHelper; +import com.alibaba.android.vlayout.layout.StaggeredGridLayoutHelper; +import com.alibaba.android.vlayout.layout.StickyLayoutHelper; + import java.util.LinkedList; import java.util.List; @@ -76,15 +74,17 @@ */ public class VLayoutActivity extends Activity { + private static final boolean TEST_NO_SCROLLING = false; + private static final boolean BANNER_LAYOUT = true; - private static final boolean FIX_LAYOUT = true; + private static final boolean FIX_LAYOUT = true && !TEST_NO_SCROLLING; private static final boolean LINEAR_LAYOUT = true; private static final boolean SINGLE_LAYOUT = true; - private static final boolean FLOAT_LAYOUT = true; + private static final boolean FLOAT_LAYOUT = true && !TEST_NO_SCROLLING; private static final boolean ONEN_LAYOUT = true; @@ -92,7 +92,7 @@ public class VLayoutActivity extends Activity { private static final boolean GRID_LAYOUT = true; - private static final boolean STICKY_LAYOUT = true; + private static final boolean STICKY_LAYOUT = true && !TEST_NO_SCROLLING; private static final boolean STAGGER_LAYOUT = true; @@ -110,10 +110,14 @@ public class VLayoutActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.main_activity); + if (TEST_NO_SCROLLING) { + setContentView(R.layout.main_noscroll_activity); + } else { + setContentView(R.layout.main_activity); + } mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container); - ; + mFirstText = (TextView) findViewById(R.id.first); mLastText = (TextView) findViewById(R.id.last); mCountText = (TextView) findViewById(R.id.count); @@ -122,6 +126,11 @@ protected void onCreate(Bundle savedInstanceState) { final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.main_view); final VirtualLayoutManager layoutManager = new VirtualLayoutManager(this); + + if (TEST_NO_SCROLLING) { + layoutManager.setNoScrolling(true); + } + layoutManager.setPerformanceMonitor(new PerformanceMonitor() { long start; diff --git a/examples/src/main/res/layout/main_noscroll_activity.xml b/examples/src/main/res/layout/main_noscroll_activity.xml new file mode 100644 index 00000000..8d54025e --- /dev/null +++ b/examples/src/main/res/layout/main_noscroll_activity.xml @@ -0,0 +1,107 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +