Skip to content

Commit

Permalink
Fix three memory leaks
Browse files Browse the repository at this point in the history
Add documentation to BaseFragment.initViews(View, Bundle) and BaseFragment.initListeners()
  • Loading branch information
TobiGr committed Sep 18, 2023
1 parent 0eae9e7 commit 8f83e39
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
20 changes: 20 additions & 0 deletions app/src/main/java/org/schabi/newpipe/BaseFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,29 @@ protected void onRestoreInstanceState(@NonNull final Bundle savedInstanceState)
// Init
//////////////////////////////////////////////////////////////////////////*/

/**
* This method is called in {@link #onViewCreated(View, Bundle)} to initialize the views.
*
* <p>
* {@link #initListeners()} is called after this method to initialize the corresponding
* listeners.
* </p>
* @param rootView The inflated view for this fragment
* (provided by {@link #onViewCreated(View, Bundle)})
* @param savedInstanceState The saved state of this fragment
* (provided by {@link #onViewCreated(View, Bundle)})
*/
protected void initViews(final View rootView, final Bundle savedInstanceState) {
}

/**
* Initialize the listeners for this fragment.
*
* <p>
* This method is called after {@link #initViews(View, Bundle)}
* in {@link #onViewCreated(View, Bundle)}.
* </p>
*/
protected void initListeners() {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public void onDestroyView() {
if (errorPanelHelper != null) {
errorPanelHelper.dispose();
}
emptyStateView = null;
emptyStateMessageView = null;
}

protected void onRetryButtonClicked() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ public void onDestroy() {
}
}

@Override
public void onDestroyView() {
super.onDestroyView();
binding = null;
}

/*//////////////////////////////////////////////////////////////////////////
// Menu
//////////////////////////////////////////////////////////////////////////*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
feedGroupsCarouselState = feedGroupsCarousel.onSaveInstanceState()
}

override fun onDestroyView() {
super.onDestroyView()
_binding = null
}

override fun onDestroy() {
super.onDestroy()
disposables.dispose()
Expand Down

0 comments on commit 8f83e39

Please sign in to comment.