Stop user scroll to set position on RecyclerView - android

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?

Related

Curiosity Down/Up Swipe Animation & Fragments Populating Based On posts date

** in a nutshell: i want the scroll animation as shown in the gif, when the user swipes down/up it goes directly to the item, and its like a fling animation.
For the Date fragments, i guess its a horizontal Recyclerview.
What am looking as an answer is, a code example of the scroll animation, and a way to do the date thing, where i can auto populate the fragments based on the dates.
I've asked before about this and wmy question was not that clear. this app includes a swipe down/up style.
When u swipe down or up, the app doesnt let you swipe like a normal Scrollview, instead from the first touch (up for example) it navigates you to the next post.
Important note is the post/item in full size (item layout match_parent ?).
Also, every post has a date, and the app includes a calendar, when you swipe left or right, you navigates to dates and based on dates you get the posts.
What i want, hints or ways to do something like this. i'd love to provide a code but i've tried to draw the way up in my mind but couldn't think in of a logical way.
For fragments, i guess they're taking the now date, and the oldest date in the post, and based on that they're making (looping) fragments, each fragment has to load a posts based on the date (query to the API which gives date as param?).
Anyway, here's a GIF of the app which explains what im talking about. Im going to setup a bounty for this question, as im eager to achieve such a feature like this in my app.
https://gfycat.com/JadedMenacingAmericanalligator
I have not tried this by myself but I would like to help may be this will do the work
First use this library for the vertical scrolling one at a time
https://github.com/lsjwzh/RecyclerViewPager
or may be this one
https://github.com/castorflex/VerticalViewPager
or may be use the pagersnaphelper of v7 support library like this
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
SnapHelper snapHelper = new PagerSnapHelper();
snapHelper.attachToRecyclerView(recyclerView);
and for the horizontal scrolling you can use these libraries may be if you apply little bit of logic you will achieve it.
https://medium.com/#ali.muzaffar/looping-infinite-viewpager-with-page-indicator-in-android-ce741f25702a
https://github.com/antonyt/InfiniteViewPager
Changing ViewPager to enable infinite page scrolling
let me know if it works.

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.

Animate RecyclerView onLoad

I have been looking for a long time for a Android RecyclerView onLoad animation
but until now I have not found anything really helpful.
What I want is to have an animation when the RecyclerView loads and displays the cells animated.
But I want to have that animation just when the RecyclerView loads and not when the cells are loaded by the ViewHolder.
Because when the cells are loaded by the ViewHolder the RecyclerView animates the cells while scrolling and so on...
So I don't want no animation while scrolling anymore.
And some guys will know that the effect I would like to implement is
a standard animation effect the TableView of iOS supports.
I have found a tutorial where is exactly done what I would like to do.
The last example is what I mean.
So all solutions I have found were similar to that one
Has anyone an idea?
Or is the way I would like to animate the cells "not Android standard like"?
kind regards
Well one way to do this is to make sure that you are animating the entire recyclerview when your activity / fragment is ready and displayed on screen. So instead of animating each individual item in the recyclerview, you set an animation on the recyclerview as a whole to "fly" in for example, by animating the TranslateY element of the recyclerview.

Center aligned selection with animation in ListView (?)

I need a component that works like the picture below but I'm having trouble coming up with some kind of decent solution that works.
I want the list to have a center locked selection but being scrollable with the d-pad. This is for an application running on a TV so no need for touch scroll. So when pressing down on the remote d-pad the list will scroll and a new item will size up and the current selected one will size down and the new selection will still be in the middle.
I've tried doing this using a ListView that I extended and programmatically scrolling when pressing down or up. On scroll finished I called notifyDatasetChanged() on the ListView for re-inflating of the childs and in the ListViews adapters getView() I made the animation of the view located at the current selected position.
This is not optimal since I need to call notifyDatasetChanged(), which re-inflates all visible views, for the animation to apply. The UI becomes laggy when doing this and scrolling fast. It's also not possible to make som kind of compress animation when current selected item goes out of selection. There is also some trouble with the end items (read views) such the first or last in the list when doing animation of them, the may sometimes go out of screen.
I think that his must have been done before and maybe I'm missing it when searching for an answer.
Have anyone done something similar or do you have some suggestions of how this can be achieved? Maybe I'm just starting of with the wrong component here..
Regards,
Kristoffer

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

Categories

Resources