Skip to content
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

Closed
wants to merge 18 commits into from

Conversation

vbuberen
Copy link
Collaborator

📄 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 and TransactionActivity to be able to work with ViewPager2 as well as changed layouts to use ViewPager2.

@cortinico cortinico self-requested a review January 2, 2020 00:29
@cortinico cortinico added the enhancement New feature or improvement to the library label Jan 2, 2020
Copy link
Member

@cortinico cortinico left a 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:

  1. There are way more leaks reported by leakcanary for MainActivity (at least on the emulator). Are you experiencing the same?
  2. 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:
    flickering

}
})

val tabLayout = findViewById<TabLayout>(R.id.tabLayoutHome)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
val viewPager = findViewById<ViewPager2>(R.id.viewPagerTransaction)
val viewPager : ViewPager2 = findViewById(R.id.viewPagerTransaction)

currentItem = selectedTabPosition
}

val tabLayout = findViewById<TabLayout>(R.id.tabLayoutTransaction)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
val tabLayout = findViewById<TabLayout>(R.id.tabLayoutTransaction)
val tabLayout : TabLayout = findViewById(R.id.tabLayoutTransaction)

Copy link
Collaborator Author

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.

Copy link
Member

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.

@cortinico cortinico added this to the 3.1.0 milestone Jan 2, 2020
@vbuberen
Copy link
Collaborator Author

vbuberen commented Jan 3, 2020

  1. Don't see leaks. After merging latest develop changes with ViewModel see no leaks too.
  2. Yeah, strange order of menu creations in fragments. Interesting.

@cortinico
Copy link
Member

  • Don't see leaks. After merging latest develop changes with ViewModel see no leaks too.

Same here, so you can drop this now.

  • Yeah, strange order of menu creations in fragments. Interesting.

This is definitely a regression. Are you able to have a look at it before we merge this?

@vbuberen
Copy link
Collaborator Author

vbuberen commented Jan 4, 2020

Yes, I definitely want to investigate it. Tried a few things yesterday, but wasn't able to resolve just yet.
It is something with transactions list menu invalidation before errors list menu starts its initialization.
Also, it happens only during first switch between views.

@vbuberen
Copy link
Collaborator Author

Tried to debug and find the problem, but had no luck so far.
Somehow onCreateOptionsMenu() is called in TransactionListFragment again before calling onCreateOptionsMenu() in ErrorListFragment
Opened an issue on Google's issue tracker: https://issuetracker.google.com/issues/147550812

@cortinico
Copy link
Member

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 3.2.0 or we include it as it is? @vbuberen

@vbuberen
Copy link
Collaborator Author

vbuberen commented Jan 16, 2020

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.

@vbuberen vbuberen modified the milestones: 3.1.0, 3.2.0 Jan 18, 2020
@vbuberen vbuberen mentioned this pull request Jan 23, 2020
@vbuberen
Copy link
Collaborator Author

Since no updates to ViewPager2 were presented moving further to versions after 3.2.0

@vbuberen vbuberen removed this from the 3.2.0 milestone Mar 30, 2020
@vbuberen
Copy link
Collaborator Author

vbuberen commented Apr 2, 2020

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.

@cortinico
Copy link
Member

Yesterday Google released 1.1.0-alpha01 and it has fix for the issue with options menu

Great news, let's wait for the stable and we can proceed them. Should we have a label like on hold for PRs like this one?

@vbuberen
Copy link
Collaborator Author

vbuberen commented Apr 3, 2020

I think do not merge works fine here. Don't want to make things too complicated.

@vbuberen vbuberen added the ⛔️ do not merge A PR that should not be merged label Apr 3, 2020
@vbuberen
Copy link
Collaborator Author

Another test
/rebase

@cortinico
Copy link
Member

Another test
/rebase

I'm afraid you can't rebase this branch as it has a non linear git history (there are a lot of Merge latest develop changes). It works fine if there are no merge commits in the branch to rebase.

@vbuberen
Copy link
Collaborator Author

Yeah, I see.

@vbuberen
Copy link
Collaborator Author

vbuberen commented Nov 15, 2020

It's been a year since I opened this PR and it looks like we still can't merge it.
Today I tried to update the PR with latest changes from develop branch, which I believed would unblock us from merging.

Since we have no ViewPager in the MainActivity anymore, we should have no issues with options menu items there, which were one of the reasons why the PR is still unmerged. However, while testing things again I noticed another issue:

Sometimes wrong set of option menu items appears in the toolbar. For example here is a screenshot of Overview tab, where search and save should be hidden:

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 ViewPager2 gets more love from Google.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⛔️ do not merge A PR that should not be merged enhancement New feature or improvement to the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants