Git Product home page Git Product logo

recyclerviewutils's People

Contributors

alexanderls avatar captain-miao avatar jjhesk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

recyclerviewutils's Issues

定制头部有很大局限性

尝试着把HeaderRecyclerView的头布局改成listview或者gridview或者其他滚动控件,无法友好加载头部

Should not be modified itemViewType

supclass get item view type from RecyclerView.ViewHolder is not correct,not equals i provider in getContentViewType(int dataListIndex) method.i think should use other method to separate content view item type from header view type and footer view type without modification content item view type.

我english很差,你将就着看

Multiple dex files define

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;

Load more view 的 view holder 不应该是 UnRecyclableViewHolder 吧?

你好 :) 最近在参考这个 RecyclerViewUtils 改进自己的 RecyclerView 工具集,但发现 BaseWrapperRecyclerAdapter 中用了比较多的 notifyDataSetChanged(),动画蛮不自然的,尤其是 这里 以及其中提到的 #3

后来发现 这里 的 Load more view 的 view holder 不应该是 UnRecyclableViewHolder;换成 return new RecyclerView.ViewHolder(mLoadMoreFooterView) {}; 应该就可以了。

如果这个 ViewHolder 不能 recycle 的话,hideLoadMoreView() 再 showLoadMoreView() 就会出现 #3 提到的问题。

这样很多地方的 notifyDataSetChanged() 都能用细粒度的 notify 方法替代掉吧,感觉效果会好一些?

很久没更新了

这个项目很久没有更新了,不知道这段时间有没有更好的优化呢?
发现几处需要优化的地方:
1.拖住不放会出现列表抖动的情况;
2.建议上拉和下拉进度条分开,上下各一个;
3.回弹效果和拉的不够顺畅;

有时间可否一起优化下

RecyclerView: Cannot call this method in a scroll callback.

W/RecyclerView: Cannot call this method in a scroll callback. Scroll callbacks might be run during a measure & layout pass where you cannot change the RecyclerView data. Any method call that might change the structure of the RecyclerView or the adapter contents should be postponed to the next frame.
java.lang.IllegalStateException:
at android.support.v7.widget.RecyclerView.assertNotInLayoutOrScroll(RecyclerView.java:2403)
at android.support.v7.widget.RecyclerView$RecyclerViewDataObserver.onItemRangeInserted(RecyclerView.java:4631)
at android.support.v7.widget.RecyclerView$AdapterDataObservable.notifyItemRangeInserted(RecyclerView.java:10469)
at android.support.v7.widget.RecyclerView$Adapter.notifyItemInserted(RecyclerView.java:6211)
at com.github.captain_miao.recyclerviewutils.BaseWrapperRecyclerAdapter.showLoadMoreView(BaseWrapperRecyclerAdapter.java:433)
at
...
at com.github.captain_miao.recyclerviewutils.WrapperRecyclerView$2.onLoadMore(WrapperRecyclerView.java:130)
at com.github.captain_miao.recyclerviewutils.listener.LinearLayoutWithRecyclerOnScrollListener.onScrolled(LinearLayoutWithRecyclerOnScrollListener.java:66)
at android.support.v7.widget.RecyclerView.dispatchOnScrolled(RecyclerView.java:4305)
at android.support.v7.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:4463)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:603)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

addAll method update for twice

public void addAll(List list, boolean notifyDataChange) {
if (list == null || list.isEmpty()) {
return;
}
mItemList.addAll(list); //(1)
if(notifyDataChange) {
try {
notifyItemRangeInserted(mHeaderSize + getBasicItemCount(), list.size());//(2)
} catch (Exception e) {
Log.w(TAG, "notifyItemRangeInserted failure");
e.printStackTrace();
notifyDataSetChanged();
}
notifyDataSetChanged();
}
}

in addAll method, after notifyItemRangeInserted method ,call notifyDataSetChanged is redundant.

英文环境下自己程序中的@string/app_name被覆盖

由于英文环境下values-en的优先级比values高,资源覆盖顺序会出现如下问题:
RecyclerViewUtils/library/src/main/res/values-en/strings.xml 优先级最高
MyApp/src/main/res/values/strings.xml 优先级次之
RecyclerViewUtils/library/src/main/res/values/strings.xml 优先级最低
结果就是我的app_name变成RALMDemo了。

解决方法也有:就是我自己再定义一个values-en/strings.xml,或者不用app_name这个字串。

不过我想作为一个公用的库,app_name这种常用字符串还是不要占用了吧:)

refreshRecycleView加载更多

你好,我在使用你的demo过程中遇到一个问题:在使用RefreshRecycleView 只加载了两页的数据,后面的数据不加载了,不知道什么原因造成的。

请求的数据回调:
@OverRide
public void getMsg(List messages) {

    if(currentpage ==1){
        simpleAdapter.clear();
    }

    simpleAdapter.appendToList(messages);
    simpleAdapter.notifyDataSetChanged();

    mWrapperRecyclerView.refreshComplete();
}
@Override
public void onRefresh() {
    currentpage = 1;
     msgIPresenter.getData(currentpage);
    simpleAdapter.hideFooterView();
    mWrapperRecyclerView.getRecyclerView().scrollToPosition(0);
}

@Override
public void onLoadMore(final int pagination, int pageSize) {

    mWrapperRecyclerView.postDelayed(new Runnable() {
        @Override
        public void run() {
            currentpage++;

//开始请求数据
msgIPresenter.getData(pagination);

            simpleAdapter.showLoadMoreView();
            simpleAdapter.hideFooterView();
        }
    },1000);

}

Bug:当firstItem或Header的高度超过RecyclerView的显示高度时,会在没有滚至顶部时就拉出下拉刷新

原因:EndlessRecyclerOnScrollListener的checkCanBePulledDown方法仅对firstCompletelyVisibleItemPosition做了判断,当该值小于等于0,则判断为可拉出下拉刷新控件
public boolean checkCanBePulledDown() {
int firstPos = mLinearLayoutManager.findFirstCompletelyVisibleItemPosition();
return firstPos <= 0;
}
这样当item或header的高度超过一屏时,完全可见的item不存在,于是出现没有滚至顶部时就拉出下拉刷新的BUG。

解决方法如下
在WrapperRecyclerView中:
return mEndlessRecyclerOnScrollListener.checkCanBePulledDown();

替换为:
if(getChildCount() == 0) return true;
int firstVisiblePosition = linearLayoutManager.findFirstVisibleItemPosition();
if(firstVisiblePosition != 0) return false;
View firstVisibleView = linearLayoutManager.findViewByPosition(firstVisiblePosition);
int top = firstVisibleView.getTop();
return top >= 0;

加载超时设置

大哥,能做个加载超时的功能吗,有些时候没有网络时,会一直在加载状态。顺便问下大哥做android多久了,我还是小弟呢。

Cannot call this method in a scroll callback.

Cannot call this method in a scroll callback. Scroll callbacks mightbe run during a measure & layout pass where you cannot change theRecyclerView data. Any method call that might change the structureof the RecyclerView or the adapter contents should be postponed tothe next frame.
java.lang.IllegalStateException:
at android.support.v7.widget.RecyclerView.assertNotInLayoutOrScroll(RecyclerView.java:2581)
at android.support.v7.widget.RecyclerView$RecyclerViewDataObserver.onItemRangeInserted(RecyclerView.java:4951)
at android.support.v7.widget.RecyclerView$AdapterDataObservable.notifyItemRangeInserted(RecyclerView.java:11383)
at android.support.v7.widget.RecyclerView$Adapter.notifyItemInserted(RecyclerView.java:6745)
at com.github.captain_miao.recyclerviewutils.BaseWrapperRecyclerAdapter.showLoadMoreView(BaseWrapperRecyclerAdapter.java:433)
at com.github.captain_miao.recyclerviewutils.WrapperRecyclerView.showLoadMoreView(WrapperRecyclerView.java:259)
at com.github.captain_miao.agera.tutorial.recycleview.ComplexRecycleViewActivity.onLoadMore(ComplexRecycleViewActivity.java:65)
at com.github.captain_miao.recyclerviewutils.WrapperRecyclerView$2.onLoadMore(WrapperRecyclerView.java:129)
at com.github.captain_miao.recyclerviewutils.listener.LinearLayoutWithRecyclerOnScrollListener.onScrolled(LinearLayoutWithRecyclerOnScrollListener.java:66)
at android.support.v7.widget.RecyclerView.dispatchOnScrolled(RecyclerView.java:4618)
at android.support.v7.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:4776)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:860)
at android.view.Choreographer.doCallbacks(Choreographer.java:672)
at android.view.Choreographer.doFrame(Choreographer.java:605)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:846)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5442)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)

Simple Expandable adapter is having problem with notifyDataSetChanged();

  1. We are passing list within the constructor of simple expandable adapter. Everything seems fine.
  2. On click event of item view, we are adding data to the existing list and calling notifyDataSetChanged(); but it seems the adapter is not getting that and hence, not updating the existing list!

Caused by: android.view.InflateException: Binary XML file

Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class com.github.captain_miao.recyclerviewutils.WrapperRecyclerView
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 

grid extensive testing feature request

is that possible to make combinations of these items for demo.

header footer grid
grid index
grid header sticky index
grid index
grid header footer index

java.lang.NullPointerException: Attempt to write to field 'int android.support.v7.widget.RecyclerView$ViewHolder.mItemViewType' on a null object reference

E/AndroidRuntime(17504): java.lang.NullPointerException: Attempt to write to field 'int android.support.v7.widget.RecyclerView$ViewHolder.mItemViewType' on a null object reference
E/AndroidRuntime(17504): at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:5837)
E/AndroidRuntime(17504): at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5060)
E/AndroidRuntime(17504): at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4970)
E/AndroidRuntime(17504): at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2029)
E/AndroidRuntime(17504): at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1414)
E/AndroidRuntime(17504): at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1377)
E/AndroidRuntime(17504): at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:578)
E/AndroidRuntime(17504): at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3315)
E/AndroidRuntime(17504): at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:2843)
E/AndroidRuntime(17504): at android.view.View.measure(View.java:17573)
E/AndroidRuntime(17504): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5547)
E/AndroidRuntime(17504): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
E/AndroidRuntime(17504): at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
E/AndroidRuntime(17504): at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
E/AndroidRuntime(17504): at android.view.View.measure(View.java:17573)
E/AndroidRuntime(17504): at in.srain.cube.views.ptr.PtrFrameLayout.measureContentView(PtrFrameLayout.java:248)
E/AndroidRuntime(17504): at in.srain.cube.views.ptr.PtrFrameLayout.onMeasure(PtrFrameLayout.java:226)
E/AndroidRuntime(17504): at android.view.View.measure(View.java:17573)
E/AndroidRuntime(17504): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5547)
E/AndroidRuntime(17504): at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
E/AndroidRuntime(17504): at android.view.View.measure(View.java:17573)
E/AndroidRuntime(17504): at android.widget.RelativeLayout.measureChild(RelativeLayout.java:698)
E/AndroidRuntime(17504): at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:482)
E/AndroidRuntime(17504): at android.view.View.measure(View.java:17573)
E/AndroidRuntime(17504): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5547)
E/AndroidRuntime(17504): at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
E/AndroidRuntime(17504): at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
E/AndroidRuntime(17504): at android.view.View.measure(View.java:17573)
E/AndroidRuntime(17504): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5547)
E/AndroidRuntime(17504): at android.support.v7.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:389)
E/AndroidRuntime(17504): at android.view.View.measure(View.java:17573)
E/AndroidRuntime(17504): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5547)
E/AndroidRuntime(17504): at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
E/AndroidRuntime(17504): at android.view.View.measure(View.java:17573)
E/AndroidRuntime(17504): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5547)
E/AndroidRuntime(17504): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
E/AndroidRuntime(17504): at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
E/AndroidRuntime(17504): at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
E/AndroidRuntime(17504): at android.view.View.measure(View.java:17573)
E/AndroidRuntime(17504): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5547)
E/AndroidRuntime(17504): at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
E/AndroidRuntime(17504): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2692)
E/AndroidRuntime(17504): at android.view.View.measure(View.java:17573)
E/AndroidRuntime(17504): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2166)
E/AndroidRuntime(17504): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1278)
E/AndroidRuntime(17504): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1523)
E/AndroidRuntime(17504): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1166)
E/AndroidRuntime(17504): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6195)
E/AndroidRuntime(17504): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:773)
E/AndroidRuntime(17504): at android.view.Choreographer.doCallbacks(Choreographer.java:586)
E/AndroidRuntime(17504): at android.view.Choreographer.doFrame(Choreographer.java:556)
E/AndroidRuntime(17504): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:759)
E/AndroidRuntime(17504): at android.os.Handler.handleCallback(Handler.java:739)
E/AndroidRuntime(17504): at android.os.Handler.dispatchMessage(Handler.java:95)
E/AndroidRuntime(17504): at android.os.

scroll upward

added header view in the grid layout manager. it has problem when it scrolling upward after the refresh is pulled. constantly appears. repeating the header view.

上拉到底部,加载更多的时候,快速往上划一下,有时会触发两次onLoadNextPage,导致数据重复

可能是我没用对,也可能确有bug

目前暂时解决办法是在EndlessRecyclerOnScrollListener中的onScrollStateChanged()方法中进行判断;
如果距上次触发onScrollStateChanged()时间不到1秒就直接return.
不知道有没有更好的解决办法
我用的不是最新版,由于我目前是直接改了EndlessRecyclerOnScrollListener, 并没有直接换最新.
不知道最新版还有没有这个问题

// 找到了解决办法
//另外,
//有时候划动到底部已经没有更多数据,但footer仍然是loading状态, 需要稍微下拉再上划才变成end状态

Added View has RecyclerView as parent but view is not a real child

java.lang.IllegalStateException: Added View has RecyclerView as parent but view is not a real child. Unfiltered index:0
at android.support.v7.widget.RecyclerView$LayoutManager.addViewInt(RecyclerView.java:6720)
at android.support.v7.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:6686)
at android.support.v7.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:6674)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1404)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1353)
at android.support.v7.widget.LinearLayoutManager.scrollBy(LinearLayoutManager.java:1180)
at android.support.v7.widget.LinearLayoutManager.scrollVerticallyBy(LinearLayoutManager.java:1031)
at android.support.v7.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:4061)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:603)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.