Inline methods in PreferencesUtils.

Donot want to have a pair of getter and setting for each preference.
This commit is contained in:
Jimmy Shih
2012-05-02 12:23:32 -07:00
parent 81281e560e
commit 234f1f4a0a
25 changed files with 84 additions and 231 deletions
@@ -46,7 +46,7 @@ public class CheckUnitsDialogFragment extends DialogFragment {
public Dialog onCreateDialog(Bundle savedInstanceState) {
Locale defaultLocale = Locale.getDefault();
boolean defaultMetric = !defaultLocale.equals(Locale.US) && !defaultLocale.equals(Locale.UK);
PreferencesUtils.setMetricUnits(getActivity(), defaultMetric);
PreferencesUtils.setBoolean(getActivity(), R.string.metric_units_key, defaultMetric);
final String metric = getString(R.string.preferred_units_metric);
final String imperial = getString(R.string.preferred_units_imperial);
final CharSequence[] items = defaultMetric ? new CharSequence[] { metric, imperial }
@@ -56,7 +56,7 @@ public class CheckUnitsDialogFragment extends DialogFragment {
@Override
public void onClick(DialogInterface dialog, int which) {
int position = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
PreferencesUtils.setMetricUnits(getActivity(), items[position].equals(metric));
PreferencesUtils.setBoolean(getActivity(), R.string.metric_units_key, items[position].equals(metric));
onDone();
}
})
@@ -68,7 +68,7 @@ public class CheckUnitsDialogFragment extends DialogFragment {
* Tasks to perform when done.
*/
private void onDone() {
PreferencesUtils.setShowCheckUnitsDialog(getActivity());
PreferencesUtils.setBoolean(getActivity(), R.string.show_check_units_dialog_key, false);
TrackListActivity trackListActivity = (TrackListActivity) getActivity();
trackListActivity.showStartupDialogs();
}
@@ -74,7 +74,7 @@ public class StatsFragment extends Fragment implements TrackDataListener {
@Override
public void run() {
Log.d(TAG, "UI update thread started");
while (PreferencesUtils.getRecordingTrackId(getActivity()) != -1L) {
while (PreferencesUtils.getLong(getActivity(), R.string.recording_track_id_key) != -1L) {
getActivity().runOnUiThread(updateTotalTime);
try {
Thread.sleep(1000L);
@@ -55,7 +55,7 @@ public class WelcomeDialogFragment extends DialogFragment {
}
private void onDone() {
PreferencesUtils.setShowWelcome(getActivity());
PreferencesUtils.setBoolean(getActivity(), R.string.show_welcome_dialog_key, false);
TrackListActivity trackListActivity = (TrackListActivity) getActivity();
trackListActivity.showStartupDialogs();
}