-Added listener unregistration to local item adapters to release dependency and avoid memory leak.
-Added listener unregistration on all listeners using contexts in local item related fragments.
This commit is contained in:
parent
c0a75f5b98
commit
7ab41e0c3a
|
@ -71,6 +71,10 @@ public class LocalItemListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
localItemBuilder.setOnItemSelectedListener(listener);
|
||||
}
|
||||
|
||||
public void unsetSelectedListener() {
|
||||
localItemBuilder.setOnItemSelectedListener(null);
|
||||
}
|
||||
|
||||
public void addItems(List<? extends LocalItem> data) {
|
||||
if (data != null) {
|
||||
if (DEBUG) {
|
||||
|
|
|
@ -230,6 +230,11 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
|
|||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
|
||||
if (itemListAdapter != null) itemListAdapter.unsetSelectedListener();
|
||||
if (headerBackgroundButton != null) headerBackgroundButton.setOnClickListener(null);
|
||||
if (headerPlayAllButton != null) headerPlayAllButton.setOnClickListener(null);
|
||||
if (headerPopupButton != null) headerPopupButton.setOnClickListener(null);
|
||||
|
||||
if (databaseSubscription != null) databaseSubscription.cancel();
|
||||
if (debouncedSaver != null) debouncedSaver.dispose();
|
||||
|
||||
|
|
|
@ -112,6 +112,7 @@ public final class PlaylistAppendDialog extends PlaylistDialog {
|
|||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
if (playlistReactor != null) playlistReactor.dispose();
|
||||
if (playlistAdapter != null) playlistAdapter.unsetSelectedListener();
|
||||
|
||||
playlistReactor = null;
|
||||
playlistRecyclerView = null;
|
||||
|
|
|
@ -178,6 +178,9 @@ public final class BookmarkFragment
|
|||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
if (mostWatchedButton != null) mostWatchedButton.setOnClickListener(null);
|
||||
if (watchHistoryButton != null) watchHistoryButton.setOnClickListener(null);
|
||||
|
||||
if (disposables != null) disposables.clear();
|
||||
if (databaseSubscription != null) databaseSubscription.cancel();
|
||||
|
||||
|
|
|
@ -140,6 +140,12 @@ public abstract class StatisticsPlaylistFragment
|
|||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
|
||||
if (itemListAdapter != null) itemListAdapter.unsetSelectedListener();
|
||||
if (headerBackgroundButton != null) headerBackgroundButton.setOnClickListener(null);
|
||||
if (headerPlayAllButton != null) headerPlayAllButton.setOnClickListener(null);
|
||||
if (headerPopupButton != null) headerPopupButton.setOnClickListener(null);
|
||||
|
||||
if (databaseSubscription != null) databaseSubscription.cancel();
|
||||
databaseSubscription = null;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ public class LocalPlaylistStreamItemHolder extends LocalItemHolder {
|
|||
private View.OnTouchListener getOnTouchListener(final PlaylistStreamEntry item) {
|
||||
return (view, motionEvent) -> {
|
||||
view.performClick();
|
||||
if (itemBuilder != null &&
|
||||
if (itemBuilder != null && itemBuilder.getOnItemSelectedListener() != null &&
|
||||
motionEvent.getActionMasked() == MotionEvent.ACTION_DOWN) {
|
||||
itemBuilder.getOnItemSelectedListener().drag(item,
|
||||
LocalPlaylistStreamItemHolder.this);
|
||||
|
|
Loading…
Reference in New Issue