forked from mapzen/prefs-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ru26kif
committed
Sep 6, 2020
1 parent
254282c
commit ed7102c
Showing
8 changed files
with
28 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 7 additions & 14 deletions
21
prefs-plusx/src/main/java/com/mapzen/prefsplusx/DefaultPreferenceFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,22 @@ | ||
package com.mapzen.prefsplusx; | ||
|
||
import android.content.SharedPreferences; | ||
import android.os.Bundle; | ||
|
||
import androidx.annotation.XmlRes; | ||
import androidx.preference.PreferenceFragmentCompat; | ||
import androidx.preference.PreferenceManager; | ||
import androidx.preference.PreferenceScreen; | ||
|
||
import static android.content.Context.MODE_PRIVATE; | ||
|
||
// Takes the resource file in the constructor | ||
// Does nothing special,you can use this one whenever you don't want to declare a new fragment just for an xml preference screen | ||
public class DefaultPreferenceFragment extends PreferenceFragmentCompat { | ||
private final String sharedPreferencesName; | ||
private final PreferenceScreen preferenceScreen; | ||
private final @XmlRes int resourceFile; | ||
|
||
DefaultPreferenceFragment(PreferenceScreen preferenceScreen, String sharedPreferencesName) { | ||
this.preferenceScreen = preferenceScreen; | ||
this.sharedPreferencesName=sharedPreferencesName; | ||
public DefaultPreferenceFragment(@XmlRes int resourceFile) { | ||
this.resourceFile=resourceFile; | ||
} | ||
|
||
@Override | ||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { | ||
PreferenceManager prefMgr = getPreferenceManager(); | ||
prefMgr.setSharedPreferencesName(sharedPreferencesName); | ||
prefMgr.setSharedPreferencesMode(MODE_PRIVATE); | ||
setPreferenceScreen(preferenceScreen); | ||
setPreferencesFromResource(resourceFile, rootKey); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters