setupTabs() if ageRestrictedContent pref changed
This commit is contained in:
parent
430d4e1ccd
commit
9ede7a3c42
|
@ -2,6 +2,7 @@ package org.schabi.newpipe.fragments;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
|
@ -45,6 +46,9 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
|
||||||
|
|
||||||
private boolean hasTabsChanged = false;
|
private boolean hasTabsChanged = false;
|
||||||
|
|
||||||
|
private boolean previousShowAgeRestrictedContent;
|
||||||
|
private String showAgeRestrictedContentKey;
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
// Fragment's LifeCycle
|
// Fragment's LifeCycle
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
@ -53,7 +57,6 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
|
||||||
public void onCreate(final Bundle savedInstanceState) {
|
public void onCreate(final Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
tabsManager = TabsManager.getManager(activity);
|
tabsManager = TabsManager.getManager(activity);
|
||||||
tabsManager.setSavedTabsListener(() -> {
|
tabsManager.setSavedTabsListener(() -> {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
|
@ -66,6 +69,9 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
|
||||||
hasTabsChanged = true;
|
hasTabsChanged = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
showAgeRestrictedContentKey = getString(R.string.show_age_restricted_content);
|
||||||
|
previousShowAgeRestrictedContent = PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean(showAgeRestrictedContentKey, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -92,7 +98,11 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
if (hasTabsChanged) {
|
boolean showAgeRestrictedContent = PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean(showAgeRestrictedContentKey, false);
|
||||||
|
if (previousShowAgeRestrictedContent != showAgeRestrictedContent) {
|
||||||
|
previousShowAgeRestrictedContent = showAgeRestrictedContent;
|
||||||
|
setupTabs();
|
||||||
|
} else if (hasTabsChanged) {
|
||||||
setupTabs();
|
setupTabs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue