Exoplayer inside RecyclerView overlaps with other views of the list - android-recyclerview

I have a recyclerview with hybrid list, i.e with different types itemViews. 1 of the viewholder is based on exoplayer. But sometimes, while scrolling my exoplayer viewholder overlaps with other itemViews or moves in a delayed manner. Exact steps to reproduce it is as follows:-
Scroll to a video viewholder -> push the app to background -> pull back app to foreground -> scroll up/down the recyclerview to video viewholder
Video viewholder delays the scrolls and sometimes leaves space between the just above view and itself, or soemtimes overlaps with the view just below it.

Related

Scroll through the contents of a RecyclerView using an outer ScrollView

I have a RecyclerView located at the bottom of the inside of a vertical ScrollView. Now each RecyclerView item has an OnClickListener which "expands" the item's layout so that more details are shown. Now i noticed that when i have multiple item layouts expanded and i try to scroll up and down, logically the scroll is happening inside of the RecyclerView first thus :
Scrolling at a lower speed than it would be if it was scrolling outside of the RecyclerView and inside of the ScrollView
When you scroll upwards , the scrolling comes at a stop as you reach the top of the RecyclerView and then you need to scroll again to scroll through the rest of the ScrollView layout.
Furthermore, since the bottom part of the whole layout is occupied by the RecyclerView, in order to scroll upwards within the parent scrollview, you need to scroll to the top of the RecyclerView first, hit the top (where the indicator lights up) and then scroll upwards again.
Is there any way that i can use the outer ScrollView to scroll through the RecyclerView items and their expanded layouts? Can i scroll through the main layout when i'm scrolling from within the recyclerview?
A NestedScrollView should be used instead of ScrollView, that is if you want to stick with scroll views in general.
This approach is also explained here.
Or you can replace the entire scroll view with a large RecyclerView. It can be vanilla or with Epoxy.

RecyclerView with GridLayoutManager inside of ViewPager2

I found a bug when using ViewPager2 (horizontal orientation), which the fragment contains a RecyclerView with GridLayoutManager (vertical orientation),
The RecyclerView with GridLayoutManager always jump-scrolls to top (1st item) when I scroll it vertically,
this issue does not exist when I change it to LinearLayoutManager
I suspect that this has something to do with bubbling onTouch event from nested recycler view, (AFAIK viewpager2 use RecyclerView)
Need help
Update: after doing research, it is may be caused by SwipeRefreshLayout wrapping my RecycleView, seems I need to extend it to something like "NestedScroll Swipe Refresh Layout"

Using TouchImageView in RecyclerView attached with PageSnapHelper?

My app is doing a gallery which uses TouchImageView on RecyclerView.
I was trying to use this class to display multiple fullscreen images in a RecyclerView attached with PageSnapHelper
This works fine, but the zooming is very awkward to use .If I try to pinch zoom , the image moving left and right but not zooming. Only double Tap works.
I think there is a conflict with the swiping and scrolling of the RecyclerView attached with PageSnapHelper .
How can I make the TouchImageView touch events override the PageSnapHelper events when pinch zoomed byt swiping also works when swiped?
To be simple , I want the same behavior of Chat Apps(Whatsapp and telegram) Image Slider which supports both swiping and pinch zooming
Note , I searched the stackoverflow but there are only solutions for ViewPagers but no recyclerview
Im not exactly sure what you are asking here, but if I got it right, the problem is you can't pinch zoom because the RecyclerView is recognising your pinch action as a swipe.
If you wanted, you could always disallow the RecyclerView from intercepting the touch event (and handle the event yourself) by calling:
view.parent.requestDisallowInterceptTouchEvent(true)
inside the onTouch method of the PrivateOnTouchListener.
If you want a simpler solution, you could also check if the current view is zoomed or if at least 2 fingers are touching the view. If yes, disallow the parent to intercept the touch event. The inside the PrivateOnTouchListener code would then look like this:
if (isZoomed || event.pointerCount >= 2) {
v.parent.requestDisallowInterceptTouchEvent(true)
}
The parent will now only be allowed to intercept the touch event if the view isn't zoomed and if only one finger is touching the view.

Scrolled to the bottom when ads (admob) loaded in recyclerview in android

I have a recyclerview with 7 items in it. In the bottom of the list, I insert a banner of admob. I have inserted successfully.However, when the ads (in the bottom of the list) loaded, it automatically scrolled my view to the bottom.
I have used "ScrollToPosition(0)" but it doesn't have any effects.
I want my list always in the top when the ads loaded. What should I do?
Many Thanks.

Android recycler view item position

In my app I am showing a list of cards in a recycler view. The card view consists of two textviews and one imageview. Whenever the user clicks on the imageView of a cardview I need the position of the cardview. Any help would be appreciated.
You can set an OnClickListener for your ImageView inside your Adapter , from there you can get the position of current Item by using getAdapterPosition() method.
also you can see :
Get position of clicked item in recycler view
How do I get the position selected in a RecyclerView?