use of com.ferg.awfulapp.preferences.fragments.RootSettings in project Awful.apk by Awful.
the class SettingsActivity method onSubmenuSelected.
@Override
public void onSubmenuSelected(@NonNull SettingsFragment sourceFragment, @NonNull String submenuFragmentName) {
try {
SettingsFragment fragment = (SettingsFragment) (Class.forName(submenuFragmentName).newInstance());
boolean fromRootMenu = sourceFragment instanceof RootSettings;
displayFragment(fragment, fromRootMenu);
} catch (IllegalAccessException | ClassNotFoundException | InstantiationException e) {
Timber.e(e, "Unable to create fragment (%s)", submenuFragmentName);
}
}
use of com.ferg.awfulapp.preferences.fragments.RootSettings in project Awful.apk by Awful.
the class SettingsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
prefs = AwfulPreferences.getInstance(this, this);
currentThemeName = prefs.theme;
updateTheme();
// theme needs to be set BEFORE the super call, or it'll be inconsistent
super.onCreate(savedInstanceState);
setContentView(R.layout.settings);
View leftPane = findViewById(R.id.root_fragment_container);
if (leftPane != null && leftPane.getVisibility() == View.VISIBLE) {
isDualPane = true;
}
FragmentManager fm = getFragmentManager();
// we need to start with the root fragment, so it's always under the backstack
if (savedInstanceState == null) {
fm.beginTransaction().replace(R.id.main_fragment_container, new RootSettings(), ROOT_FRAGMENT_TAG).commit();
fm.executePendingTransactions();
}
// hide the root fragment in dual-pane mode (there's a copy visible in the layout),
// but make sure it's shown in single-pane (we might have switched from dual-pane)
SettingsFragment fragment = (SettingsFragment) fm.findFragmentByTag(ROOT_FRAGMENT_TAG);
if (fragment != null) {
if (isDualPane) {
fm.beginTransaction().hide(fragment).commit();
} else {
fm.beginTransaction().show(fragment).commit();
}
}
Toolbar toolbar = (Toolbar) findViewById(R.id.awful_toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
updateTitleBar();
}
Aggregations