From 2ab0df08aef6ddea82a5a5995ae471d788f47f1a Mon Sep 17 00:00:00 2001 From: lzx <573842281@qq.com> Date: Tue, 20 Sep 2016 17:08:35 +0800 Subject: [PATCH] fix bug --- .../java/com/github/jdsjlzx/recyclerview/LRecyclerView.java | 5 ++++- .../java/com/github/jdsjlzx/recyclerview/LuRecyclerView.java | 5 ++++- .../java/com/lzx/demo/ui/EndlessLinearLayoutActivity.java | 4 ++-- .../java/com/lzx/demo/ui/SwipeRefreshLayoutActivity.java | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/LRecyclerview_library/src/main/java/com/github/jdsjlzx/recyclerview/LRecyclerView.java b/LRecyclerview_library/src/main/java/com/github/jdsjlzx/recyclerview/LRecyclerView.java index 04b70a2..a1d8aad 100644 --- a/LRecyclerview_library/src/main/java/com/github/jdsjlzx/recyclerview/LRecyclerView.java +++ b/LRecyclerview_library/src/main/java/com/github/jdsjlzx/recyclerview/LRecyclerView.java @@ -362,7 +362,10 @@ public void onScrolled(int dx, int dy) { public void onScrollStateChanged(int state) { super.onScrollStateChanged(state); currentScrollState = state; - mWrapAdapter.setScrollState(state); + + if (mWrapAdapter != null) { + mWrapAdapter.setScrollState(state); + } if (mLScrollListener != null) { mLScrollListener.onScrollStateChanged(state); diff --git a/LRecyclerview_library/src/main/java/com/github/jdsjlzx/recyclerview/LuRecyclerView.java b/LRecyclerview_library/src/main/java/com/github/jdsjlzx/recyclerview/LuRecyclerView.java index 3755277..d407303 100644 --- a/LRecyclerview_library/src/main/java/com/github/jdsjlzx/recyclerview/LuRecyclerView.java +++ b/LRecyclerview_library/src/main/java/com/github/jdsjlzx/recyclerview/LuRecyclerView.java @@ -252,7 +252,10 @@ public void onScrolled(int dx, int dy) { public void onScrollStateChanged(int state) { super.onScrollStateChanged(state); currentScrollState = state; - mWrapAdapter.setScrollState(state); + + if (mWrapAdapter != null) { + mWrapAdapter.setScrollState(state); + } if (mLScrollListener != null) { mLScrollListener.onScrollStateChanged(state); diff --git a/app/src/main/java/com/lzx/demo/ui/EndlessLinearLayoutActivity.java b/app/src/main/java/com/lzx/demo/ui/EndlessLinearLayoutActivity.java index c882940..5943324 100644 --- a/app/src/main/java/com/lzx/demo/ui/EndlessLinearLayoutActivity.java +++ b/app/src/main/java/com/lzx/demo/ui/EndlessLinearLayoutActivity.java @@ -304,8 +304,8 @@ public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { finish(); } else if (item.getItemId() == R.id.menu_refresh) { - //mRecyclerView.forceToRefresh(); - mDataAdapter.remove(mLRecyclerViewAdapter.getAdapterPosition(false,3)); + mRecyclerView.forceToRefresh(); + //mDataAdapter.remove(mLRecyclerViewAdapter.getAdapterPosition(false,3)); } return true; } diff --git a/app/src/main/java/com/lzx/demo/ui/SwipeRefreshLayoutActivity.java b/app/src/main/java/com/lzx/demo/ui/SwipeRefreshLayoutActivity.java index 2ca697d..8824f6c 100644 --- a/app/src/main/java/com/lzx/demo/ui/SwipeRefreshLayoutActivity.java +++ b/app/src/main/java/com/lzx/demo/ui/SwipeRefreshLayoutActivity.java @@ -154,7 +154,7 @@ public void onScrollStateChanged(int state) { }); - onRefresh(); + //onRefresh(); } @Override