ViewPager2 with TabLayout swipes to next position on Tab tapped - android-viewpager2

I prepared on github (https://github.com/SertanAcubens/ViewPagertest) sample app to illustrate problem I encountered while migrating to ViewPager2. Shortly, one of fragments in ViewPager is built from CardViews (with RecyclerView inside) which are added in fragment's onViewCreated method. When Tab Three is tapped ViewPager2 swipes immediately to next position. I would appreciate any help on that issue.
Seems like this bug affects at least devices with Android 9. On some devices with Android 11 works OK.

Related

recyclerview position is back to 0 when navigating to another fragment

So, I have 3 fragments. Explore Fragment, Expanded Version of Explore Fragment, and Detail Fragment.
When I navigate into Detail Fragment from Explore Fragment, everything is fine, the recyclerView position is not back to 0. But when navigating to Detail Fragment from the Expanded Version of Explore Fragment, then returning to it, the position is back to 0. So, how does this happen? Why is this only affecting the Expanded Version of Explore Fragment? And how do I solve this if I want to persist in the scroll position when navigating to Detail Fragment from Expanded Fragment?

How to remove process from processor in android application

I have created one android app. In that i have Main Activity and in Main Activity i have sliding drawer. At first load my Home fragment will show and by click on home fragment's list will added another fragment so that i can see drawer in every screen so basically my whole app is in fragment.
Now issue is when i go to the 15 to 17 screen from Home fragment to sub fragment i got hang issue and i have found in android monitor that my app occupy 50% processor so i want to remove process from that processor what should i do?
thanks in advance

ios7 new pan gesture to go back in navigation stack does not clear tableview selection

I have a Notes-like app: uitableviewcontroller showing up individual notes by pushing them onto navigation stack). And I decided to use an ios7 Back button and a pan gesture recognizer coming with it.
My only modification is removing text from the button by setting navigationItem title of the from-controller to an empty string before pushing the detail-view-controller, as it is advised at https://stackoverflow.com/questions/18870128/ios-7-navigation-bar-custom-back-button-without-title
The button itself works just fine, but when I am going back from my note to the notes table view by means of the pan gesture, tableview selection is not cleaned! The row of the note I've just transitioned from is still shown as a selected one.
Any ideas what could be wrong here?
I've checked the standard Notes app and it works like a charm.
This answer did help me: https://stackoverflow.com/questions/897071/iphone-uitableview-cells-stay-selected
- (void) viewWillAppear:(BOOL)animated {
[self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:animated];
[super viewWillAppear:animated];
}
At least for the cases we were seeing this happen, it seems to be fixed in iOS 7.0.4. (We've actually noticed that a number of glitches with the back gesture have been fixed during the 7.0.x releases.)

Swipe to go back in navigation controller on iOS 7

I've been looking through the iOS 7 / UIKIT framework, and although it looks quite different aesthetically it's really the same SDK underneath from what I can see.
My question, is there any extra code that needs to be included to get the draggable behaviour between pushed tableviews/views?
When you push a view onto a UINavigationController you can now drag back to the previous controller from the side rather than pressing the back button.
This behavior can be seen in mail.
How is this achieved, do I need to add any code to add it to my app?
This has nothing to do with UITableView or UITableViewController, but with UINavigationController. And yes, you get this behavior for free as long as the back button is visible.

replace fragments inside fragment displayed by the viewpager

Please see the wireframe image http://i.imgur.com/dPAMA.png first.
I am using a ViewPager to display fragments inside a FragmentActivity. ViewPager gets fragments from the attached FragmentPagerAdapter
mViewPager = (ViewPager) findViewById(R.id.view_pager);
mAdapter = new HomePagerAdapter(getSupportFragmentManager());
mViewPager.setAdapter(mAdapter);
Suppose viewpager has 3 fragments to display say Fragment1, Fragment2, Fragment3.
In the above image 'displaying fragment1' is the title for the first fragment, "Fragment1". This fragment is a list fragment and displays a list. Fragment2 and Fragment3 have their own content to display. when the user swipes on the screen, ViewPager will display the next fragment, "Fragment2".
What i want is that, when an item from the list(displayed by Fragment1) is clicked, Fragment1 should be completely replaced with some other Fragment, say Fragment4 (this is different fragment and is not returned by the attached adapter). when Fragment4 is displayed, the actionbar should change its content. whenever user works on Fragment4 and onBackPress or an action from the ActionBar, Fragment1 with the list should be displayed again. Meanwhile ViewPager should behave the same i.e on swipe, and the next fragment(in our case Fragment2) will be displayed.
basically, i want to get the same behavior as in example at :
http://developer.android.com/training/basics/fragments/fragment-ui.html#Replace
In this example the ListFragment is displayed directly inside a FragmentActivity. I am displaying the ListFragment with a ViewPager. I want the same functionality from the above example but inside fragments displayed with ViewPager. This was very difficult to achieve before the release of Android 4.2. this version of android supports nested fragments using getChildFragmentManager() so, i see some hope.
I am trying this on my side for many days and also scanned entire stackoverflow for Q & A related to nested fragments but didn't get what i want.
So, is this possible to achieve? if yes, then how to?
This was a big problem before Android 4.2 but it seems to easier now with nested fragments, apart from ensuring the back button works. I posted my solution to your question over here: https://stackoverflow.com/a/13925130/467509
My solution answers everything you asked apart from changing the ActionBar.

Resources