diff options
Diffstat (limited to 'androvdr/src/de/bjusystems/androvdr/data/EpgSearchTimeValues.java')
-rw-r--r-- | androvdr/src/de/bjusystems/androvdr/data/EpgSearchTimeValues.java | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/androvdr/src/de/bjusystems/androvdr/data/EpgSearchTimeValues.java b/androvdr/src/de/bjusystems/androvdr/data/EpgSearchTimeValues.java new file mode 100644 index 0000000..7300e8e --- /dev/null +++ b/androvdr/src/de/bjusystems/androvdr/data/EpgSearchTimeValues.java @@ -0,0 +1,62 @@ +package de.bjusystems.androvdr.data; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import android.content.Context; +import de.bjusystems.androvdr.R; + +public class EpgSearchTimeValues { + + private final List<EpgSearchTimeValue> values = new ArrayList<EpgSearchTimeValue>(); + private final Context context; + + public EpgSearchTimeValues(final Context context) { + + this.context = context; + } + + public List<EpgSearchTimeValue> getValues() { + + final Preferences prefs = Preferences.getPreferences(); + + // fixed values for now and next + values.add(new EpgSearchTimeValue(0, context.getString(R.string.epg_list_time_now))); + values.add(new EpgSearchTimeValue(1, context.getString(R.string.epg_list_time_next))); + + // get user defined values + final String userValueString = prefs.getEpgSearchTimes(); + + final String[] userValues = userValueString.split(","); + + Arrays.sort(userValues); + + for(final String userValue : userValues) { + if (userValue.contains(":")) { + values.add(new EpgSearchTimeValue(values.size(), userValue)); + } + } + + return values; + } + + public void saveValues(final List<EpgSearchTimeValue> values) { + + // get old values + final Preferences prefs = Preferences.getPreferences(); + + // add value + String newValues = ""; + for(int i = 2; i < values.size(); i++) { + final EpgSearchTimeValue value = values.get(i); + if (newValues.length() > 0) { + newValues += ","; + } + newValues += value.toString(); + } + + // save new values + prefs.setEpgSearchTimes(context, newValues); + } +} |