Closed
Conversation
5 tasks
2 tasks
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is it?
Description of the changes in your PR
Use Android's view binding instead of
findViewById().I'd appreciate anyone's help. Btw I still need to figure out how to port things using a
ViewPagerover, so don't work on those yet.Why?
This results in cleaner code imho. This also gives us the opportunity to easily fix all memory leaks of the first category in #3517.
How could I port a fragment to use view binding?
onCreateView()withbinding = Binding.inflate(inflater, container, false);, whereBindingshould be e.g.FragmentChannelBindingwhen the layout is calledfragment_channel.xml. Of course also addbindingas a class member, Thenreturn binding.getRoot();inonCreateView().onViewCreated(). Change all accesses to that class member tobinding.whatever, wherewhateveris the camel case version of the ID in the layout.bindingtonullinonDestroyView()(notonDestroy(), you'll probably see a lot of cases in our app where things are done inonDestroy()while they should be inonDestroyView()), otherwise you'll cause a memory leak.How could I port an activity to use view binding?
onCreate()withbinding = Binding.inflate(inflater);, whereBindingshould be e.g.FragmentChannelBindingwhen the layout is calledfragment_channel.xml. Of course also addbindingas a class member, Then callsetContentView(binding.getRoot());inonCreate().binding.whatever, wherewhateveris the camel case version of the ID in the layout.How could I verify that it works correctly?
In Android's settings, enable Developer settings -> Don't keep activities. Then open the fragment/activity in NewPipe, switch to another app, switch back to NewPipe and verify that it doesn't crash or cause weird behavior. Don't forget to turn off that setting once you're finished with working on this PR, as it's pretty annoying to have that enabled in everyday use.
In case of a fragment, you should also verify that going to another fragment in NewPipe from there and then going back works correctly.
To do
Here should be a list of all fragments/activities that we need to port to use view binding. When you start working on one, please add your name behind the fragment/activity. When you've finished, please check the checkmark.
ChannelFragment@wb9688SearchFragment@StypoxMainActivity@wb9688AboutActivity.javaLicenseFragment.javaDownloadActivity.javaDownloadDialog.javaVideoDetailFragment.javaPlaylistFragment.javaSuggestionListAdapter.javaRelatedVideosFragment.javaBaseListFragment.javaBaseStateFragment.javaMainFragment.javaChannelMiniInfoItemHolder.javaCommentsInfoItemHolder.javaPlaylistMiniInfoItemHolder.javaCommentsMiniInfoItemHolder.javaStreamInfoItemHolder.javaStreamMiniInfoItemHolder.javaChannelInfoItemHolder.javaInfoItemDialog.javaBookmarkFragment.javaPlaylistAppendDialog.javaPlaylistCreationDialog.javaStatisticsPlaylistFragment.javaPlaylistItemHolder.javaLocalPlaylistStreamItemHolder.javaLocalStatisticStreamItemHolder.javaLocalPlaylistFragment.javaSubscriptionsImportFragment.javaFeedImportExportItem.ktBaseLocalListFragment.javaCustomBottomSheetBehavior.javaPlaybackParameterDialog.javaPlayQueueItemHolder.javaServicePlayerActivity.javaVideoPlayer.javaVideoPlayerImpl.javaErrorActivity.javaAddTabDialog.javaChooseTabsFragment.javaSelectKioskFragment.javaSettingsActivity.javaNotificationSettingsFragment.javaSelectChannelFragment.javaSelectPlaylistFragment.javaPeertubeInstanceListFragment.javaPermissionHelper.javaFilePickerActivityHelper.javaStreamItemAdapter.javaFocusAwareCoordinator.javaReCaptchaActivity.javaRouterActivity.javaAgreement