Skip to content

Commit

Permalink
Merge pull request #10394 from TeamNewPipe/fix/memory-leaks
Browse files Browse the repository at this point in the history
Fix memory leaks and add documentation
  • Loading branch information
Stypox authored Sep 19, 2023
2 parents 0eae9e7 + 8f83e39 commit 9e353f1
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 9e353f1

Please sign in to comment.