mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Fix the issue of not reloading the cursor after the setting changed
This commit is contained in:
parent
7050efc996
commit
d1fc670b19
4 changed files with 23 additions and 12 deletions
|
|
@ -42,8 +42,7 @@ public class ContributionsActivity
|
|||
AdapterView.OnItemClickListener,
|
||||
MediaDetailPagerFragment.MediaDetailProvider,
|
||||
FragmentManager.OnBackStackChangedListener,
|
||||
ContributionsListFragment.SourceRefresher
|
||||
{
|
||||
ContributionsListFragment.SourceRefresher {
|
||||
|
||||
private Cursor allContributions;
|
||||
private ContributionsListFragment contributionsList;
|
||||
|
|
@ -92,6 +91,15 @@ public class ContributionsActivity
|
|||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
boolean isSettingsChanged =
|
||||
sharedPreferences.getBoolean(Prefs.IS_CONTRIBUTION_COUNT_CHANGED,false);
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putBoolean(Prefs.IS_CONTRIBUTION_COUNT_CHANGED,false);
|
||||
editor.apply();
|
||||
if(isSettingsChanged){
|
||||
refreshSource();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ public class Prefs {
|
|||
public static String TRACKING_ENABLED = "eventLogging";
|
||||
public static final String DEFAULT_LICENSE = "defaultLicense";
|
||||
public static final String UPLOADS_SHOWING = "uploadsshowing";
|
||||
public static final String IS_CONTRIBUTION_COUNT_CHANGED = "ccontributionCountChanged";
|
||||
|
||||
public static class Licenses {
|
||||
public static final String CC_BY_SA_3 = "CC BY-SA 3.0";
|
||||
|
|
|
|||
|
|
@ -41,7 +41,8 @@ public class SettingsFragment extends PreferenceFragment {
|
|||
});
|
||||
|
||||
licensePreference.setSummary(getString(Utils.licenseNameFor(licensePreference.getValue())));
|
||||
licensePreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener(){
|
||||
licensePreference
|
||||
.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener(){
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
preference.setSummary(getString(Utils.licenseNameFor((String) newValue)));
|
||||
|
|
@ -59,17 +60,16 @@ public class SettingsFragment extends PreferenceFragment {
|
|||
});
|
||||
|
||||
final EditTextPreference uploadLimit = (EditTextPreference) findPreference("uploads");
|
||||
SharedPreferences sharedPref = PreferenceManager
|
||||
final SharedPreferences sharedPref = PreferenceManager
|
||||
.getDefaultSharedPreferences(getActivity().getApplicationContext());
|
||||
int uploads = sharedPref.getInt(Prefs.UPLOADS_SHOWING, 100);
|
||||
uploadLimit.setText(uploads + "");
|
||||
uploadLimit.setSummary(uploads + "");
|
||||
uploadLimit.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
int value = Integer.parseInt(newValue.toString());
|
||||
final SharedPreferences sharedPref = PreferenceManager
|
||||
.getDefaultSharedPreferences(getActivity().getApplicationContext());
|
||||
final SharedPreferences.Editor editor = sharedPref.edit();
|
||||
if (value > 500) {
|
||||
new AlertDialog.Builder(getActivity())
|
||||
|
|
@ -83,10 +83,12 @@ public class SettingsFragment extends PreferenceFragment {
|
|||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.show();
|
||||
editor.putInt(Prefs.UPLOADS_SHOWING, 500);
|
||||
editor.putBoolean(Prefs.IS_CONTRIBUTION_COUNT_CHANGED,true);
|
||||
uploadLimit.setSummary(500 + "");
|
||||
uploadLimit.setText(500 + "");
|
||||
} else {
|
||||
editor.putInt(Prefs.UPLOADS_SHOWING, Integer.parseInt(newValue.toString()));
|
||||
editor.putBoolean(Prefs.IS_CONTRIBUTION_COUNT_CHANGED,true);
|
||||
uploadLimit.setSummary(newValue.toString());
|
||||
}
|
||||
editor.apply();
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ Tap this message (or hit back) to skip this step.</string>
|
|||
<string name="mapbox_commons_app_token">pk.eyJ1IjoibWFza2FyYXZpdmVrIiwiYSI6ImNqMmxvdzFjMTAwMHYzM283ZWM3eW5tcDAifQ.ib5SZ9EVjwJe6GSKve0bcg</string>
|
||||
<string name="number_of_uploads">My Recent Upload Limit</string>
|
||||
<string name="maximum_limit">Maximum Limit</string>
|
||||
<string name="maximum_limit_alert">Maximum limit should be 500</string>
|
||||
<string name="maximum_limit_alert">Unable to display more than 500</string>
|
||||
<string name="set_limit">Set Recent Upload Limit</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue