org.solovyev.android.prefs
Class LocalePreference

java.lang.Object
  extended by org.solovyev.android.prefs.LocalePreference
All Implemented Interfaces:
Preference<Locale>

public class LocalePreference
extends Object
implements Preference<Locale>

User: serso Date: 4/15/12 Time: 7:09 PM


Method Summary
 Locale getDefaultValue()
           
 String getKey()
          Method returns key of preference used in android: the key with which current preference is saved in persistence
 Locale getPreference(android.content.SharedPreferences preferences)
          NOTE: this method can throw runtime exceptions if errors occurred while extracting preferences values
 Locale getPreferenceNoError(android.content.SharedPreferences preferences)
          NOTE: this method SHOULD not throw any runtime exceptions BUT return default value if any error occurred
 boolean isSameKey(String key)
           
 boolean isSet(android.content.SharedPreferences preferences)
           
static LocalePreference of(String id, Locale defaultValue)
           
static LocalePreference of(String id, Locale defaultValue, org.solovyev.common.text.Mapper<Locale> localeMapper)
           
 void putDefault(android.content.SharedPreferences preferences)
          Method saves default value in preferences container.
 void putPreference(android.content.SharedPreferences preferences, Locale value)
          Method puts (saves) preference represented by value in preferences container
 boolean tryPutDefault(android.content.SharedPreferences preferences)
          Method applies default value to preference only if explicit value is not set
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

of

@Nonnull
public static LocalePreference of(@Nonnull
                                          String id,
                                          @Nullable
                                          Locale defaultValue,
                                          @Nonnull
                                          org.solovyev.common.text.Mapper<Locale> localeMapper)

of

@Nonnull
public static LocalePreference of(@Nonnull
                                          String id,
                                          @Nullable
                                          Locale defaultValue)

getKey

@Nonnull
public String getKey()
Description copied from interface: Preference
Method returns key of preference used in android: the key with which current preference is saved in persistence

Specified by:
getKey in interface Preference<Locale>
Returns:
android preference key

getDefaultValue

public Locale getDefaultValue()
Specified by:
getDefaultValue in interface Preference<Locale>
Returns:
default preference value, may be null

getPreference

public Locale getPreference(@Nonnull
                            android.content.SharedPreferences preferences)
Description copied from interface: Preference
NOTE: this method can throw runtime exceptions if errors occurred while extracting preferences values

Specified by:
getPreference in interface Preference<Locale>
Parameters:
preferences - application preferences
Returns:
value from preference, default value if no value in preference was found

getPreferenceNoError

public Locale getPreferenceNoError(@Nonnull
                                   android.content.SharedPreferences preferences)
Description copied from interface: Preference
NOTE: this method SHOULD not throw any runtime exceptions BUT return default value if any error occurred

Specified by:
getPreferenceNoError in interface Preference<Locale>
Parameters:
preferences - application preferences
Returns:
value from preference, default value if no value in preference was found or error occurred

putDefault

public void putDefault(@Nonnull
                       android.content.SharedPreferences preferences)
Description copied from interface: Preference
Method saves default value in preferences container. Should behave exactly as p.putPreference(preferences, p.getDefaultValue())

Specified by:
putDefault in interface Preference<Locale>
Parameters:
preferences - preferences container

putPreference

public void putPreference(@Nonnull
                          android.content.SharedPreferences preferences,
                          @Nullable
                          Locale value)
Description copied from interface: Preference
Method puts (saves) preference represented by value in preferences container

Specified by:
putPreference in interface Preference<Locale>
Parameters:
preferences - preferences container
value - value to be saved

isSet

public boolean isSet(@Nonnull
                     android.content.SharedPreferences preferences)
Specified by:
isSet in interface Preference<Locale>
Parameters:
preferences - preferences container
Returns:
true if any value is saved in preferences container, false - otherwise

tryPutDefault

public boolean tryPutDefault(@Nonnull
                             android.content.SharedPreferences preferences)
Description copied from interface: Preference
Method applies default value to preference only if explicit value is not set

Specified by:
tryPutDefault in interface Preference<Locale>
Parameters:
preferences - preferences container
Returns:
true if default values have been applied, false otherwise

isSameKey

public boolean isSameKey(@Nonnull
                         String key)
Specified by:
isSameKey in interface Preference<Locale>
Parameters:
key - preference key
Returns:
true if current preferences has the same key


Copyright © 2014 se.solovyev. All Rights Reserved.