Skip to content

Commit 9e353f1

Browse files
authored
Merge pull request #10394 from TeamNewPipe/fix/memory-leaks
Fix memory leaks and add documentation
2 parents 0eae9e7 + 8f83e39 commit 9e353f1

4 files changed

Lines changed: 33 additions & 0 deletions

File tree

app/src/main/java/org/schabi/newpipe/BaseFragment.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,29 @@ protected void onRestoreInstanceState(@NonNull final Bundle savedInstanceState)
8080
// Init
8181
//////////////////////////////////////////////////////////////////////////*/
8282

83+
/**
84+
* This method is called in {@link #onViewCreated(View, Bundle)} to initialize the views.
85+
*
86+
* <p>
87+
* {@link #initListeners()} is called after this method to initialize the corresponding
88+
* listeners.
89+
* </p>
90+
* @param rootView The inflated view for this fragment
91+
* (provided by {@link #onViewCreated(View, Bundle)})
92+
* @param savedInstanceState The saved state of this fragment
93+
* (provided by {@link #onViewCreated(View, Bundle)})
94+
*/
8395
protected void initViews(final View rootView, final Bundle savedInstanceState) {
8496
}
8597

98+
/**
99+
* Initialize the listeners for this fragment.
100+
*
101+
* <p>
102+
* This method is called after {@link #initViews(View, Bundle)}
103+
* in {@link #onViewCreated(View, Bundle)}.
104+
* </p>
105+
*/
86106
protected void initListeners() {
87107
}
88108

app/src/main/java/org/schabi/newpipe/fragments/BaseStateFragment.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ public void onDestroyView() {
8080
if (errorPanelHelper != null) {
8181
errorPanelHelper.dispose();
8282
}
83+
emptyStateView = null;
84+
emptyStateMessageView = null;
8385
}
8486

8587
protected void onRetryButtonClicked() {

app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ public void onDestroy() {
139139
}
140140
}
141141

142+
@Override
143+
public void onDestroyView() {
144+
super.onDestroyView();
145+
binding = null;
146+
}
147+
142148
/*//////////////////////////////////////////////////////////////////////////
143149
// Menu
144150
//////////////////////////////////////////////////////////////////////////*/

app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
115115
feedGroupsCarouselState = feedGroupsCarousel.onSaveInstanceState()
116116
}
117117

118+
override fun onDestroyView() {
119+
super.onDestroyView()
120+
_binding = null
121+
}
122+
118123
override fun onDestroy() {
119124
super.onDestroy()
120125
disposables.dispose()

0 commit comments

Comments
 (0)