nikhilpanju / recyclerviewenhanced Goto Github PK
View Code? Open in Web Editor NEWAndroid Library to provide swipe, click and other functionality to RecyclerView
Android Library to provide swipe, click and other functionality to RecyclerView
log belows:
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getHeight()' on a null object reference
at com.nikhilpanju.recyclerviewenhanced.RecyclerTouchListener.handleTouchEvent(RecyclerTouchListener.java:474)
at com.nikhilpanju.recyclerviewenhanced.RecyclerTouchListener.onInterceptTouchEvent(RecyclerTouchListener.java:127)
at android.support.v7.widget.RecyclerView.dispatchOnItemTouchIntercept(RecyclerView.java:2231)
at android.support.v7.widget.RecyclerView.onInterceptTouchEvent(RecyclerView.java:2277)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1977)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2435)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2066)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2435)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2066)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2435)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2066)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2435)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2066)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2435)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2066)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2435)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2066)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2485)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1783)
at android.app.Activity.dispatchTouchEvent(Activity.java:2835)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2444)
at android.view.View.dispatchPointerEvent(View.java:8712)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4236)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4090)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3618)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3684)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3644)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3773)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3652)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3830)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3618)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3684)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3644)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3652)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3618)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5962)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5936)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5896)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6059)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:193)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:143)
at android.os.Looper.loop(Looper.java:122)
at android.app.ActivityThread.main(ActivityThread.java:5400)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1037)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
It's possible Disable the autoclose of the foreground view when click in itens from OptionView?
Or need help to implement this feature?
hi
when i swap the item to see the buttons (Add,Remove,Edit) and i touch one of this buttons to see the next item(touch it is mean i do not want to apply the function like edit ) but just i want to move the list item up or down,, in this case the function apply
in short : touch the button for moving list item it will apply the function
any help
The height of the recyclerview you get by rView.getHeight()
is inaccurate,when the recyclerview is wrap_content
,or its parent is scrollview of some kind. It caused the error of heightOutsideRView
then the result of closeVisibleBG()
.
Please, how Implement OnSwipeListener?
Thanks!
I use your swipe on activity or fragment it runs but when running on dialogFragment it can't swipe, have you ever had the same situation as me.
thanks
how to use dispatchTouchEvent in fragment?
it is not work what you have tall implement either i am not clickable of my view.
public class BookingDetailActivity extends AppCompatActivity implements RecyclerTouchListener.RecyclerTouchListenerHelper,AddPackageContract.View {
onTouchListener = new RecyclerTouchListener(this, recyclerViewAddItem);
onTouchListener.setClickable(new RecyclerTouchListener.OnRowClickListener() {
@OverRide
public void onRowClicked(int position) {
// ShowLogToast.ShowToast(getApplicationContext(), "Row " + (position + 1) + " clicked!", 1);
}
@Override
public void onIndependentViewClicked(int independentViewID, int position) {
// main view is cliecked (linear forgound view)
// ShowLogToast.ShowToast(getApplicationContext(), "Button in row " + (position + 1) + " clicked!", 1);
}
}).setSwipeOptionViews(R.id.linearEdit, R.id.linearDelete)
.setSwipeable(R.id.linearForeground, R.id.relativeBackground, new RecyclerTouchListener.OnSwipeOptionsClickListener() {
@Override
public void onSwipeOptionClicked(int viewID, int position) {
String message = "";
if (viewID == R.id.linearEdit) {
message += "Edit";
setEditItem(position);
} else if (viewID == R.id.linearDelete) {
showAlertDeleteItem(position);
message += "Delete";
}
message += " clicked for row " + (position + 1);
ShowLogToast.ShowLog(TAG,message);
//ShowLogToast.ShowToast(getApplicationContext(), message, 1);
}
});
@OverRide
protected void onResume() {
super.onResume();
if (recyclerViewAddItem != null)
recyclerViewAddItem.addOnItemTouchListener(onTouchListener);
}
@Override
protected void onPause() {
super.onPause();
if (recyclerViewAddItem != null)
recyclerViewAddItem.removeOnItemTouchListener(onTouchListener);
}
// for hide view of recycler when user touch out side of recyclerView.
@Override
public void setOnActivityTouchListener(OnActivityTouchListener listener) {
this.touchListener = listener;
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (touchListener != null) touchListener.getTouchCoordinates(ev);
return super.dispatchTouchEvent(ev);
} }
I am trying to make a recyclerview having multiple(2) viewtypes. The first view is for header and second one is for items inside particular header. I want to make headers unswipable and items are swipables. i used setUnSwipeableRows method for achieve this behaviour but this does not work. It crashes when i swipe/click on my header view. The full logcat of exception is as below.
10-03 09:32:56.358 3979-3979/com.jsonexample E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.jsonexample, PID: 3979
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getHeight()' on a null object reference
at com.nikhilpanju.recyclerviewenhanced.RecyclerTouchListener.handleTouchEvent(RecyclerTouchListener.java:521)
at com.nikhilpanju.recyclerviewenhanced.RecyclerTouchListener.onInterceptTouchEvent(RecyclerTouchListener.java:153)
at android.support.v7.widget.RecyclerView.dispatchOnItemTouchIntercept(RecyclerView.java:2821)
at android.support.v7.widget.RecyclerView.onInterceptTouchEvent(RecyclerView.java:2867)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2059)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2430)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2119)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2430)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2119)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2430)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2119)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2430)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2119)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2430)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2119)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2430)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2119)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2314)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1692)
at android.app.Activity.dispatchTouchEvent(Activity.java:2739)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:68)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2275)
at android.view.View.dispatchPointerEvent(View.java:8578)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4021)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3887)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3449)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3502)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3468)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3578)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3476)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3635)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3449)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3502)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3468)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3476)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3449)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5701)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5675)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5646)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5791)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:143)
at android.os.Looper.loop(Looper.java:122)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)```
I found that when the screen turns off when the swiped becomes ineffective and Viewholder multiplexing effect occurs.
test environment:
Millet 3 system: 6.0.1
Сonflict with ViewPager
If RecyclerView with SwipeRefreshLayout then swipes conflicts
Hi. I have been using your library for half a year. But recently I switched to api 28 and I began to receive crashes with an error: "Attempt to invoke interface method 'boolean androidx.recyclerview.widget.RecyclerView$OnItemTouchListener.onInterceptTouchEvent(androidx.recyclerview.widget.RecyclerView, android.view.MotionEvent)' on a null object reference
android.view.ViewGroup.dispatchTouchEvent".
Can you help me?
Each item in the recyclerview has its own height. Background-layout's height is auto calculated based on foreground layout.'s height But it is not getting recalculated properly
Hi,
I have a RecyclerView with swipe to delete for each rows. I added a footer to my RecyclerView (footer uses a different layout than items and should not be swipeable nor clickable).
I did try to use setUnSwipeableRows(), but it crashes inside handleTouchEven()'s ACTION_DOWN. Would it be possible to make the footer bypass the touch listener? Is there a way to have a footer with actual code?
When the RecyclerView
is empty and I click somewhere on empty screen, I'm getting the following exception inside onRowClicked(int position)
since callback calls this method although it should not:
09-27 15:16:37.669 24445-24445/cc.chatstop.android E/InputEventReceiver: Exception dispatching input event.
09-27 15:16:37.669 24445-24445/cc.chatstop.android E/MessageQueue-JNI: Exception in MessageQueue callback: handleReceiveCallback
09-27 15:16:37.673 24445-24445/cc.chatstop.android E/MessageQueue-JNI: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
BTW, I'm using setStackFromEnd(true)
for my RecyclerView
. Probably, that causes a mistaken callback for an empty list. Please check it.
i don't no reason that notuse swipe in fragment, but in Activity evething is ok ?
Hello, i have a question, how to prevent close the swipe, when touch an item. when touch an item increase a count in my app, and i need prevent close the swipe.
I hope you can help me
Regaarts,!
hi
how to enable left to right swipe?
setLeftToRightSwipeable does not work...
thanks
Hello,
We are currently using your library in one of our application. Actually we need a favour from your side. According to the Google Play Policy, all apps have to provide support for at least API level 26 which is not satisfied in your case. We are targeting API level 28. So can you please provide us support for API level 28 in your current repository?
Even if the click is disabled on a view, the view and it's children (foregroundView) exhibits the ripple effect giving a bit odd impression on the UI.
Note- we cannot remove the clickable attribute from layout as that would disable the Ripple for all views even those that are clickable.
Is this library live? I want to create pull request.
While loading data from firebase, the view doesn't respond, i.e. I cannot scroll it, and cannot swipe it.
On further inspection, I am getting this kind of error:
E/ViewRootImpl: mView does not exist, so discard the remaining points. java.lang.NullPointerException: Attempt to invoke interface method 'boolean androidx.recyclerview.widget.RecyclerView$OnItemTouchListener.onInterceptTouchEvent(androidx.recyclerview.widget.RecyclerView, android.view.MotionEvent)' on a null object reference
I/Surface: opservice is null false
I even tried to attach onTouchListener, when the list is loaded. But still not working.
很喜欢改控件样式,需要侧滑课以删除和修改的,如何实现,试了下,实现了侧滑删除,但修改那个始终无效了,
I want to have swipable edit button on left side instead of standard right side. I dont find any way or method to do that. Please help me.
Can anyone help me to how to add Left to Right swipe for the recycerview? I need both swipe.. Left to Right and Right to Left..
when I call the onTouchListner.openSwipeOptions() method, it doesn't openSwipeOptions for the correct row if the recycler view has been scrolled past the first few visible items.
here is my code:
onTouchListener.setClickable(new RecyclerTouchListener.OnRowClickListener() {
@Override
public void onRowClicked(int position) {
onTouchListener.openSwipeOptions(position);
}
@Override
public void onIndependentViewClicked(int independentViewID, int position) {
}
});
java.lang.NullPointerException: Attempt to invoke interface method 'void com.nikhilpanju.recyclerviewenhanced.RecyclerTouchListener$OnRowClickListener.onRowClicked(int)' on a null object reference
at com.nikhilpanju.recyclerviewenhanced.RecyclerTouchListener.handleTouchEvent(RecyclerTouchListener.java:732)
at com.nikhilpanju.recyclerviewenhanced.RecyclerTouchListener.onInterceptTouchEvent(RecyclerTouchListener.java:153)
at android.support.v7.widget.RecyclerView.dispatchOnItemTouchIntercept(RecyclerView.java:2504)
at android.support.v7.widget.RecyclerView.onInterceptTouchEvent(RecyclerView.java:2550)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2109)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2554)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2255)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2554)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2255)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2554)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2255)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2554)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2255)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2554)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2255)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2554)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2255)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2554)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2255)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2554)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2255)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2554)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2255)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2554)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2255)
at com.android.internal.policy.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2403)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1737)
at android.app.Activity.dispatchTouchEvent(Activity.java:2820)
at cn.zeke.app.doctor.home.activity.MainActivity.dispatchTouchEvent(MainActivity.java:123)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:67)
at com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2364)
at android.view.View.dispatchPointerEvent(View.java:9526)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4262)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4128)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3669)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3722)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3688)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3814)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3696)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3871)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3669)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3722)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3688)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3696)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3669)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5954)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5928)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5889)
at android.view.ViewRootImpl$WindowInputE
When I swipe and trying to tap an option It doesn't react to click but swiping closes. Just first 3.
尝试去setOnTouch事件没有效果,我想拿到对应的position修改源码,没有办法传进去,求助
I want the unswipeable rows stay still while i swipe left or right, so i comment the No 863 line (fgView.setTranslationX(translateAmount / 5);)in RecyclerTouchListener.java file, will this operation cause some other problems? it works well for me so far,
For Vivo device it doesn't work,
For nexus 5, s6 works fine.
Can't seem to find any logical reason for this
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.