fixed settings title change on frag transaction
This commit is contained in:
@@ -2,7 +2,6 @@ package net.headlezz.notificationlogger;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
public class BlacklistFragment extends Fragment {
|
||||
|
||||
@@ -10,6 +9,5 @@ public class BlacklistFragment extends Fragment {
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
((AppCompatActivity) activity).getSupportActionBar().setTitle("Blacklist");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,10 +26,7 @@ public class PreferenceActivity extends AppCompatActivity implements PreferenceF
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
if(getSupportFragmentManager().findFragmentById(R.id.fragment_holder) == null) {
|
||||
PreferenceFragment pf = new PreferenceFragment();
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.add(R.id.fragment_holder, pf)
|
||||
.commit();
|
||||
showSettingsScreen();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,5 +51,20 @@ public class PreferenceActivity extends AppCompatActivity implements PreferenceF
|
||||
.replace(R.id.fragment_holder, new BlacklistFragment())
|
||||
.addToBackStack("blacklist")
|
||||
.commit();
|
||||
getSupportActionBar().setTitle(getString(R.string.title_blacklist));
|
||||
}
|
||||
|
||||
public void showSettingsScreen() {
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.fragment_holder, new PreferenceFragment())
|
||||
.commit();
|
||||
getSupportActionBar().setTitle(getString(R.string.title_settings));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if(getSupportFragmentManager().getBackStackEntryCount() > 0)
|
||||
getSupportActionBar().setTitle(getString(R.string.title_settings));
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,6 @@ public class PreferenceFragment extends PreferenceFragmentCompat implements Pref
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
mCallbacks = (PreferenceCallbacks) activity;
|
||||
((AppCompatActivity) activity).getSupportActionBar().setTitle("Settings");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,4 +15,5 @@
|
||||
<string name="pref_about_title">About</string>
|
||||
<string name="fab_cd_create_notification">FAB: Create notification</string>
|
||||
<string name="title_create_notification">Create notification</string>
|
||||
<string name="title_blacklist">Blacklist</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user