-
-
Notifications
You must be signed in to change notification settings - Fork 363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migration to ViewPager 2 #159
Conversation
…fecycle to FragmentActivity based adapter constructor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally the code looks good and cleaner, thanks for doing so :)
Other than the comments I left, I noticed two things:
- There are way more leaks reported by leakcanary for
MainActivity
(at least on the emulator). Are you experiencing the same? - There is a flickering of the Option menu when changing tab from Network to Errors for the first time. I can notice that 3 bin icons are shown (rather than 1). Here a Gif to explain this issue:
} | ||
}) | ||
|
||
val tabLayout = findViewById<TabLayout>(R.id.tabLayoutHome) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val tabLayout = findViewById<TabLayout>(R.id.tabLayoutHome) | |
val tabLayout : TabLayout = findViewById(R.id.tabLayoutHome) |
selectedTabPosition = position | ||
populateUI(transaction) | ||
private fun setupViewPager() { | ||
val viewPager = findViewById<ViewPager2>(R.id.viewPagerTransaction) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val viewPager = findViewById<ViewPager2>(R.id.viewPagerTransaction) | |
val viewPager : ViewPager2 = findViewById(R.id.viewPagerTransaction) |
currentItem = selectedTabPosition | ||
} | ||
|
||
val tabLayout = findViewById<TabLayout>(R.id.tabLayoutTransaction) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val tabLayout = findViewById<TabLayout>(R.id.tabLayoutTransaction) | |
val tabLayout : TabLayout = findViewById(R.id.tabLayoutTransaction) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we should drop all these findViewById
usages. But in another PR later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, feel free to drop it for now.
|
Same here, so you can drop this now.
This is definitely a regression. Are you able to have a look at it before we merge this? |
Yes, I definitely want to investigate it. Tried a few things yesterday, but wasn't able to resolve just yet. |
Tried to debug and find the problem, but had no luck so far. |
What do we do here? Do we want to move it to |
I would postpone to 3.2.0 to not compromise on quality. Ideally, we should strive to have stable versions as bugless as possible (even without such minor issues), so users could be confident in library reliability. |
Since no updates to ViewPager2 were presented moving further to versions after |
Yesterday Google released 1.1.0-alpha01 and it has fix for the issue with options menu. Checked it and everything works fine. Going to wait till it gets stable and we will be able to finally merge this PR. |
Great news, let's wait for the stable and we can proceed them. Should we have a label like |
I think |
Another test |
I'm afraid you can't rebase this branch as it has a non linear git history (there are a lot of |
Yeah, I see. |
It's been a year since I opened this PR and it looks like we still can't merge it. Since we have no Sometimes wrong set of option menu items appears in the toolbar. For example here is a screenshot of Due to this issue and the fact that Google hasn't released any updates to ViewPager2 1.0.0 except some alpha (which we can't use to not create potential issues like #469) I am convinced that we are fine with older ViewPager, which has no issues for our usage and needs no workarounds. Closing this PR. Hope that in future we could return to this when |
📄 Context
Google encourages developers to try the new ViewPager 2, since it offers quite a lot optimizations.
More info on changes: https://medium.com/google-developer-experts/exploring-the-view-pager-2-86dbce06ff71
The library is in
release candidate
state, so I am sure that no changes should appear there and we can safely update Chucker to use latest components.Additionally, this migration allowed to make the code cleaner and more concise.
📝 Changes
Added dependency to corresponding library.
Updated ViewPager adapters in
MainActivity
andTransactionActivity
to be able to work with ViewPager2 as well as changed layouts to useViewPager2
.