Implement some features, for example, in the Instagram app android

There are two things that I like about Instagram for Android, and I would like to implement them in my application.

1. Infinite return to the history of fragments

If you click on a user, you can see his data, and writing to followers will return a list of followers, clicking on another user will show his data ... and so on. Basically, you can do this many times, BUT, when you return, everything is instantaneous, without load. How can this be implemented? My initial thought was to have only one action with the top action bar, and for the rest - fragments (one fragment for user details, one fragment for a list of users) and so on. The problem is that I cannot come up with a good way to let me go back in history. The only way I can see is to cache all the data (user data / list adapters) is an ArrayList, so when the user clicks back, removes the last item from the list and creates an instance of the fragment. Is there a better way to do this? I think that I can start a new activity for each user interaction, and when the user clicks back, just end the current one. My only concern in this case will be exhausted. Is there a way to cache fragments with their state?

2.GridView inside ScrollView

There are two main layouts in user details: a layout with custom details and gridview images. When the user scrolls, at the end of the scroll, the gridview receives a new set of elements (loading while scrolling). Although I know how to implement loading while scrolling a gridview, I don't know how to add gridview inside a scroll and continue to listen to scroll events

enter image description here

+4
source share
1 answer

Did not get a quick answer for number 2, but for the first question, why not just add fragments to the backstack using FragmentTransaction.addToBackStack

This way you get a natural reverse action with fragments without having to start new actions for each action.

0
source

Source: https://habr.com/ru/post/1500139/


All Articles