SwipeRefreshLayout and ListView action detection - android

So I'm currently working on a bit not-ideal legacy Android project and I'm trying to solve this inconsistency regarding SwipeRefreshLayout and ListView. Both of these views are added programmatically as follows:
// lv is ListView initiated elsewhere.
mSwipeRefreshLayout = new SwipeRefreshLayout(this);
mSwipeRefreshLayout.addView(lv);
Pull-to-refresh and anything related to SwipeRefreshLayout and ListView actions are working as expected. But, if I'm scrolling with intention to trigger pull-to-refresh mechanism:
On portrait, my ListView fires up onScroll but NOT through onScrollStateChanged whereas if I'm scrolling up (moving ListView contents up) I get the expected event sequence from ListView.
On landscape, I didn't receive any scroll event on the ListView unless I'm scrolling up (moving ListView contents up) which is what I wanted.
Does anyone have an idea or a pointer for me to start looking for the solution? I figured that somewhere, some code part triggered a scroll but I've been at it for almost a day now and cannot find it and started to think that I might be barking on a wrong tree.
Thank you.

Related

How to set a final scroll's position in listView?

Maybe someone faced such a problem: I have adapter class, customView class. Everything works normal. But: When I scroll listView, It's possible to stop the scroll anywhere in the middle.
But I expected: a final scroll's position (when soon as user's finger is up and inertia-movement is completed) should always be like on my screenshot(image1) and never like this(image2).
I hope I understood your question right.
To achieve this in ListView Android ListView - stop scrolling at 'whole' row position
For RecyclerView You can achieve this by using SnapHelper
LinearSnapHelper().attachToRecyclerView(recyclerView)

Underscroll in RecyclerView android

I am creating a custom scroll inside RecyclerView and I did most of the work already but now I came to hopefully one of the last problems.
On scrolling, I am expanding/collapsing rows as they move up or down. It works fine until I reach the bottom of the list. Two items remain in their normal state because I can no longer scroll down and therefore they will not expand.
My question is, how can I scroll under the recyclerView when I reach the bottom? Do I need to implement onTouch listener and do the work from there? Or is there something in RecyclerView that can help me create the underscroll?
You should be able to expand them in onOverScrolled, as that will be called at the correct time to trigger their expansion.

Stop user scroll to set position on RecyclerView

So I've got a problem, i'm quite new to android programming, it's been only 6-8 weeks since i've started programming android apps so i may be blind and not see the easy answer but here's my problem:
I'm making a school project and i'm trying to develop a similar calendar to the one in Today's Calendar split view (The one below here)
So i've made a RecyclerView with a GridLayoutManager that looks like this:
And up until here everything's fine, but i'm trying to implement the button that sets the calendar on today's date, the thing is that when i'm scrolling with a fling and then set the RecyclerView position with scrollToPositionWithOffset(position, 0); the view keeps the momentum gained from the first fling, sets the position and then keeps on scrolling until the momentum is gone
I've searched a lot to find a solution, when i was using gridView instead of RecyclerView i used smoothScrollToPositionFromTop() which stopped the scrolling and then the setSelection() to position it, but the gridView skipped frames and i had to change, here with RecyclerView there is no smoothScrollToPositionFromTop and smoothScrollToPosition doesn't stop the scroll, neither does scrollToPosition or scrollToPositionWithOffset.
found this but doesn't help Scroll RecyclerView to show selected item on top
and many others that didn't help.
I considered implementing my own scrolling logic but when i looked into it my head exploded and i wouldn't know where to begin.
Does anyone know how to solve this?
Did you know that RecyclerView has a stopScroll() method to stop a scroll in progress?

ListView with ViewPagers

Im having trouble with my UI.
It contains a ListView , with ViewPagers as List Items.
The problem is that the horizontal scrolls seem to get interrupted by the ListView (catching vertical scrolls).
What i want to achieve is that no matter what happens, the horizontal scrolls finish all the time. Right now they stop half way sometime.
this is probably a common problem, but i havent found a solution yet.
I've tried to intercept horizontal scrolls on the the listview, but although I can intercept, it still causes the swipe to stop.
can anyone point me in the right direction ?
ViewPagers are not compatible with ListViews.
Sorry.
ViewPager inside ListView

Android Scroll ListViewfrom code

I'm trying to have a piece of code cause a ListViewto scroll. This is happening as another view is being scrolled. Currently I'm calling scrollBy(x,y) on this ListView to cause it to scroll. This causes the items in the list to scroll but does not cause new items to be loaded. I've tried calling invalidate on the list but this does not seem to work. The problem appears to be that what the list understands as visible items are only updated by touch events.
Does anyone know a way to get around this?
I think the problem is that ScrollBy and ScrollTo are methods of the base View, and thus seems to be scrolling the whole 'viewport' of the list.
If you want to scroll the items use smoothScrollBy or smoothScrollToPosition.
That should work

Categories

Resources