cymcsg / ultimaterecyclerview Goto Github PK
View Code? Open in Web Editor NEWA RecyclerView(advanced and flexible version of ListView in Android) with refreshing,loading more,animation and many other features.
License: Apache License 2.0
A RecyclerView(advanced and flexible version of ListView in Android) with refreshing,loading more,animation and many other features.
License: Apache License 2.0
Hi, according to my test, the OnLoadMoreListener gets called several times when you scroll up and down the recyclerView several times.
like this
I'm using this lib with CardView - and I can't set the background color of the view.
Not the background of the cards!
if i want to set up two different itemview to the UltimateRecyclerView,how should i do
@cymcsg please add this method if it is not available as implemented here https://github.com/wdullaer/SwipeActionAdapter Thanks
It seems that the library is compatible with API 11 or higher only (because of many animations)
On Android Arsenal is written "API 7".
I'm fetching files from a folder to recyclerview if the folder doesn't contain any files then i'd like to show empty view. Emptyview is shown if the adapter is set to null right? but when i try to ultimateRecyclerView.setAdapter(null); it crashes.
Is there a solution to show empty view when adapter is set null or it can be empty by default?
Ho to change color in default swiperefresh (google refresh)? I can't find a method that can to change it.
Thanks cymcsg
I try to create an adapter which extends UltimateViewAdapter,and I want to load different layout file.So I overwrite the function:getItemViewType(),but I find out that the function:onCreateViewHolder() only have one paramater,not contain viewType.
Please give me some suggesttions,thanks a lot.
app:recyclerviewClipToPadding="true"
Pulling to refresh and immediatly scrolling will cause the given exception:
java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid item position 6(offset:6).state:13
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4041)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:3999)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1892)
at android.support.v7.widget.GridLayoutManager.layoutChunk(GridLayoutManager.java:419)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1301)
at android.support.v7.widget.LinearLayoutManager.scrollBy(LinearLayoutManager.java:1128)
at android.support.v7.widget.LinearLayoutManager.scrollVerticallyBy(LinearLayoutManager.java:985)
at android.support.v7.widget.RecyclerView.scrollByInternal(RecyclerView.java:1204)
at android.support.v7.widget.RecyclerView.onTouchEvent(RecyclerView.java:1951)
at android.view.View.dispatchTouchEvent(View.java:7713)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2210)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1945)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2329)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1568)
at android.app.Activity.dispatchTouchEvent(Activity.java:2458)
at android.support.v7.internal.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:59)
at android.support.v7.internal.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:59)
at android.support.v7.internal.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:59)
at android.support.v7.internal.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:59)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2277)
at android.view.View.dispatchPointerEvent(View.java:7893)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:3947)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3826)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3392)
at android.v
My code just work fine before adding these lines but I get this error when adding load more:
mRecyclerView.enableLoadmore();
adapter.setCustomLoadMoreView(LayoutInflater.from(getActivity())
.inflate(R.layout.progressbar_bottom_load_more_recycler_view, null));
mRecyclerView.setOnLoadMoreListener(new UltimateRecyclerView.OnLoadMoreListener() {
@Override
public void loadMore(int itemsCount, final int maxLastVisiblePosition) {
new Handler().postDelayed(new Runnable() {
public void run() {
// todo: insert new items at the end of list....
// adapter.insert("More " + moreNum++, simpleRecyclerViewAdapter.getAdapterItemCount());
CallLogAdapter.HistoryItem historyItem = new CallLogAdapter.HistoryItem();
adapter.insert(historyItem, adapter.getAdapterItemCount());
adapter.insert(historyItem, adapter.getAdapterItemCount());
adapter.insert(historyItem, adapter.getAdapterItemCount());
}
}, 3000);
}
The error:
06-02 10:50:49.217 9898-9898/co.a.m E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: co.a.m , PID: 9898
java.lang.IndexOutOfBoundsException: Invalid index 30, size is 30
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
at co.a.m.view.adapter.CallLogAdapter.getItem(CallLogAdapter.java:105)
at co.a.m.view.adapter.CallLogAdapter.onBindViewHolder(CallLogAdapter.java:90)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:4805)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4106)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:3999)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1892)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1338)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1301)
at android.support.v7.widget.LinearLayoutManager.scrollBy(LinearLayoutManager.java:1128)
at android.support.v7.widget.LinearLayoutManager.scrollVerticallyBy(LinearLayoutManager.java:985)
at android.support.v7.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:3458)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:799)
at android.view.Choreographer.doCallbacks(Choreographer.java:599)
at android.view.Choreographer.doFrame(Choreographer.java:558)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:784)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5872)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:674)
at dalvik.system.NativeStart.main(Native Method)
Invalid index 30, size is 30??????!!!!!!!!
where is disableLoadMore?
i want stop loadMore
Because when calling disableLoadmore method, customLoadMoreView will still be set an empty view(empty_progressbar.xml). But if recycle view need show load more view you use the following clauses:
if (mAdapter.getAdapterItemCount() >= showLoadMoreItemNum && mAdapter.getCustomLoadMoreView() != null
&& mAdapter.getCustomLoadMoreView().getVisibility() == View.GONE) {
mAdapter.getCustomLoadMoreView().setVisibility(View.VISIBLE);
}
if (mAdapter.getAdapterItemCount() < showLoadMoreItemNum && mAdapter.getCustomLoadMoreView() != null) {
mAdapter.getCustomLoadMoreView().setVisibility(View.GONE);
}
You can see the if clause can still be true, is that right?
Can support grid layout manager?
I have a very important question. If i want to integrate admob or DFP into the list view.
As from the image. How does it make the adapter to support typed view binding to support this kind of inserting ad into the listview? I have also seen from the previous discussion about this support as mentioned on #35.
I have also came across another android library from the typed listview.
Will anyone to take a good look of how to integrate that?
<android.support.v7.widget.RecyclerView
android:id="@+id/ultimate_list"
android:background="#ffffff"
android:layout_width="match_parent"
android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>
This part of the code. I am not able to override it in gradle. Please remove the #ffffff I do not want my recyclerview to be white at all times.
The swapAdapter
method is just a proxy to RecyclerView's method. But I think this method should do more stuff just like the addAdapter
method. For example show/hide loading progress, attach observers and update an empty view, etc.
For now if I update data with the swapAdapter
a loader indicator is not hiding.
hi cymcsg, its a great library and very helpfull.
I just try pulltorefresh when adapter is empty, and it seems does'nt work anyway.
maybe you can change pulltorefresh with MultiSwipeRefreshLayout
here is the link : MultiSwipeRefreshLayout.java
and you can add layout_empty.xml with scrollview as parent view to make it enable to pulltorefresh.
thanks cymcsg 👍
Just try to integrate QuickReturn library with this library.
https://github.com/lawloretienne/QuickReturn
I found that Custom OnScrollListener and Load More OnScrollListener cannot use at the same time.
Process: com.marshalchen.ultimaterecyclerview.demo, PID: 19937
java.lang.StringIndexOutOfBoundsException: length=0; index=0
at com.marshalchen.ultimaterecyclerview.demo.SimpleAdapter.getHeaderId(SimpleAdapter.java:87)
at com.timehop.stickyheadersrecyclerview.HeaderPositionCalculator.hasNewHeader(HeaderPositionCalculator.java:43)
at com.timehop.stickyheadersrecyclerview.StickyRecyclerHeadersDecoration.getItemOffsets(StickyRecyclerHeadersDecoration.java:60)
at android.support.v7.widget.RecyclerView.getItemDecorInsetsForChild(RecyclerView.java:2744)
at android.support.v7.widget.RecyclerView$LayoutManager.measureChildWithMargins(RecyclerView.java:5543)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1332)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1269)
at android.support.v7.widget.LinearLayoutManager.scrollBy(LinearLayoutManager.java:1097)
at android.support.v7.widget.LinearLayoutManager.scrollVerticallyBy(LinearLayoutManager.java:957)
at android.support.v7.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:2797)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at android.view.Choreographer.doCallbacks(Choreographer.java:574)
at android.view.Choreographer.doFrame(Choreographer.java:543)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5050)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:806)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
at dalvik.system.NativeStart.main(Native Method)
I find your code about showing or hiding empty view as follows:
if (mRecyclerView.getAdapter().getItemCount() == 0 && mEmptyId != 0) {
mEmpty.setVisibility(View.VISIBLE);
} else if (mEmptyId != 0) {
mEmpty.setVisibility(View.GONE);
}
There is a bug if you add load more view. You can see mRecyclerView.getAdapter().getItemCount() will never be ==0 because the return result of getItemCount method will be ==1.
Now I have to use the following method to fix this problem:
@OverRide
public int getAdapterItemCount() {
int fixHeaderFooterBug = 0;
if(mItems.size() == 0 && getCustomLoadMoreView() != null)fixHeaderFooterBug--;
if(mItems.size() == 0 && getCustomHeaderView() != null)fixHeaderFooterBug--;
return mItems.size() + fixHeaderFooterBug;
}
Can you fix this bug ASAP. Thank you very much
我的recyclerview上方有toolbar遮挡了一部分,这样刷新圆圈出现的位置就被toolbar挡住了,我没找到类似setDistanceToTriggerSync (int distance)的方法。
is there a way to add separator line between the items in the list view?
The current implementation only works for toolbar, would be awesome to also support any kind of view instead of only Toolbar. In my case i have a LinearLayout that contains the toolbar and tabs and i would like to hide only a portion of that LinearLayout
setCustomLoadMoreView 接口为什么一定要在adapter设置, 这应该是RecyclerView职责啊, 而不该在adapter中.
Hi, I was using UltimateRecyclerView on my application, but it works well on my Nexys 5 (5.1) but now in my Galaxy Nexus (4.3), Am I doing something wrong?
Thanks
When I ran build task, it's got a error:
ERROR: In FloatActionButton, unable to find attribute icon, how can I fix it ?
Hi, I am trying to integrate UltimateRecyclerView into my project, and I am not able to extend my custom ViewHolder from UltimateRecyclerviewViewHolder
as it is protected class in UltimateViewHolder
.
It would be good also if adapter could be based on generics, to that I could use it in same way as RecyclerView.Adapter
and specify my custom ViewHolder class there.
i use it like this,but it doen't work
rv_mycre.setOnLoadMoreListener(new UltimateRecyclerView.OnLoadMoreListener() {
@Override
public void loadMore(int i, int i2) {
// fg_recommend_presenter.getRcdPost(lasId);
}
});
I want know how to use it
can I use it directly on eclipse, i cant see any activity being loaded in manifest ?
Is it usable directly ?
Could you remove the background color or recyclerview (ultimate_recycler_view_layout.xml, android:background="#ffffff" ) and make it optional with styles or something?
Because it doesn't seem good with white background.
Also another suggestion is could you add some attributes to VerticalSwipeRefreshLayout for changing refreshing colors? like; app:recyclerviewRefreshingColors="@color\refreshing_colors" which uses array of 4 colors.
Thank you so much again @cymcsg
I am using the OnScrollListener to hide the Toolbar when scrolling.. This functions correctly with the stock RecyclerView, however when using UltimateRecyclerView component, the RecyclerView doesn't translate upwards with the Toolbar, instead it just crops the content.
Any ideas as to how to resolve this? TIA.
hello,cymcsg,工具集成的很不错,赞一个,不过里面自带的UltimateAdapter并没有做精简,还是和原生一样需要码很多句,我发现一个不错的adapter,https://github.com/StanKocken/EfficientAdapter
Thank you for amazing lib!
I'd like to use it in one of my project, could you host it in maven please?
I am facing a strange behaviour. I have an adapter extending UltimateViewAdapter. It is showing one row less that it must show in actual. If I setView count to 1, it shows no rows.
Would you consider adding "Loading" state into the RecyclerView?, empty view will trigger when there isn't any item and loading will trigger the first time the recycler view is retrieving the items.
HI, Im trying to use enabledMore feature, but when I scroll down, progress bar not showing, can you explain me how this works, and if there is some callback like onRefresh (pull from top) to loadmore... I was thinking in populate recycler from a paginated get service...
Thanks,
apply plugin: 'com.android.application'
android {
compileSdkVersion 18
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "test"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
repositories {
mavenCentral()
//UltimateRecyclerView 用到的
jcenter()
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v4:22.1.1'
//网络请求
compile 'com.loopj.android:android-async-http:1.4.7'
//加载图片类库
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
//阿里fastjson
compile files('libs/fastjson-1.1.43.android.jar')
//recyclerview
compile 'com.android.support:recyclerview-v7:22.1.1'
//viewpager tablayout
compile 'com.ogaclejapan.smarttablayout:library:1.1.3@aar'
//圆形图片
compile 'de.hdodenhof:circleimageview:1.3.0'
//卡片背景
compile 'com.android.support:cardview-v7:22.1.1'
//扇形菜单
compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
//photoview支持图片放大缩小
compile 'com.github.chrisbanes.photoview:library:1.2.3'
//动画库
compile files('libs/nineoldandroids-2.4.0.jar')
//gif显示类库
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.+'
compile 'com.marshalchen.ultimaterecyclerview:library:0.3.4'
}
Can support non-parallax header?
Thanks
I've updated the lib for the latest version and it gives error from proguard;
Warning:com.tonicartos.superslim.LayoutModifierHelper: can't find referenced class com.tonicartos.superslim.Recycler
Warning:there were 4 unresolved references to classes or interfaces.
You may need to add missing library jars or update their versions.
If your code works fine without the missing classes, you can suppress
the warnings with '-dontwarn' options.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
is it a problem or should i add the superslim library with -dontwarn ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.