1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 16:40:32 +00:00

-Fixed preferences fetching.

This commit is contained in:
John Zhen Mo 2018-02-11 11:40:08 -08:00
parent e7d148336b
commit 263a816c3b

View File

@ -27,6 +27,7 @@ import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView; import android.support.design.widget.NavigationView;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.view.GravityCompat; import android.support.v4.view.GravityCompat;
@ -217,7 +218,8 @@ public class MainActivity extends AppCompatActivity {
private void onHeapDumpToggled(@NonNull MenuItem item) { private void onHeapDumpToggled(@NonNull MenuItem item) {
final boolean isHeapDumpEnabled = !item.isChecked(); final boolean isHeapDumpEnabled = !item.isChecked();
sharedPreferences.edit().putBoolean(getString(R.string.allow_heap_dumping_key), isHeapDumpEnabled).apply(); PreferenceManager.getDefaultSharedPreferences(this).edit()
.putBoolean(getString(R.string.allow_heap_dumping_key), isHeapDumpEnabled).apply();
item.setChecked(isHeapDumpEnabled); item.setChecked(isHeapDumpEnabled);
final String heapDumpNotice; final String heapDumpNotice;
@ -267,8 +269,8 @@ public class MainActivity extends AppCompatActivity {
public boolean onPrepareOptionsMenu(Menu menu) { public boolean onPrepareOptionsMenu(Menu menu) {
MenuItem heapDumpToggle = menu.findItem(R.id.action_toggle_heap_dump); MenuItem heapDumpToggle = menu.findItem(R.id.action_toggle_heap_dump);
if (heapDumpToggle != null) { if (heapDumpToggle != null) {
final boolean isToggled = sharedPreferences.getBoolean( final boolean isToggled = PreferenceManager.getDefaultSharedPreferences(this)
getString(R.string.allow_heap_dumping_key), false); .getBoolean(getString(R.string.allow_heap_dumping_key), false);
heapDumpToggle.setChecked(isToggled); heapDumpToggle.setChecked(isToggled);
} }
return super.onPrepareOptionsMenu(menu); return super.onPrepareOptionsMenu(menu);