Package com.cheetahdigital.uikit.helper
Class ThemeSelector
- java.lang.Object
-
- com.cheetahdigital.uikit.helper.ThemeSelector
-
public class ThemeSelector extends java.lang.ObjectClass used by theThemedActivityto change the theme of the activity based on the values passed to it. It can also be used to change the theme of anotherActivityThe passed theme is saved on a privateSharedPreferencesGuidelines in creating your own Theme
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_THEME
-
Constructor Summary
Constructors Constructor Description ThemeSelector()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidchangeToTheme(android.app.Activity activity, int theme)Called to change the theme of theActivityIf this will be called on theActivity.onResume()or other lifecycle methods, make sure to check that this method will only be called once because this method will 'restart' the activity by callingActivity.finish()thenActivity.startActivity(Intent)static voidclearBaseBackground(android.content.Context context)Clears the base background from shared preferencesstatic voidclearBaseTitle(android.content.Context context)Clear the stored preference for base titlestatic voidclearTheme(android.content.Context context)Clears theme from shared preferences.static intgetBackIcon(android.app.Activity activity)Gets the back icon from shared preferences.static java.lang.StringgetBaseBackground(android.content.Context context)Gets the base background from shared preferencesstatic java.lang.StringgetBaseTitle(android.content.Context context)Gets the base title from shared preferencesstatic java.lang.StringgetBaseTitleImageFilePath(android.content.Context context)static intgetTheme(android.content.Context context)Gets the them from theSharedPreferencesattached to this Theme Selector classstatic java.lang.StringgetThemeName(android.content.Context context)Gets the theme name from shared preferences.static booleanisStringNumeric(java.lang.String value)static voidonActivityCreateSetTheme(android.app.Activity activity)CallsActivity.setTheme(int)applying the Theme that was saved in theSharedPreferencesattached to this classstatic voidsetBackIcon(android.app.Activity activity, int drawable)Sets the back icon.static voidsetBackIcon(android.content.Context context, int drawable)Sets the back iconstatic voidsetBaseBackground(android.content.Context context, java.lang.String filePath)Sets the background into shared preferences.static voidsetBaseTitle(android.content.Context context, java.lang.String title)Sets the base title into shared preferences.static voidsetBaseTitleImageFilePath(android.content.Context context, java.lang.String filePath)Sets the base title image file path into shared preferences.static voidsetTheme(android.app.Activity activity, java.lang.String theme)Saves the send theme to theSharedPreferencesattached to this Theme Selector classstatic voidsetTheme(android.content.Context context, java.lang.String theme)Saves the send theme to theSharedPreferencesattached to this Theme Selector class
-
-
-
Field Detail
-
DEFAULT_THEME
public static final java.lang.String DEFAULT_THEME
- See Also:
- Constant Field Values
-
-
Method Detail
-
changeToTheme
public static void changeToTheme(android.app.Activity activity, int theme)Called to change the theme of theActivityIf this will be called on theActivity.onResume()or other lifecycle methods, make sure to check that this method will only be called once because this method will 'restart' the activity by callingActivity.finish()thenActivity.startActivity(Intent)- Parameters:
activity- CallingActivityclasstheme- int Resource ID of the Style/Theme to be applied to the callingActivity
-
onActivityCreateSetTheme
public static void onActivityCreateSetTheme(android.app.Activity activity)
CallsActivity.setTheme(int)applying the Theme that was saved in theSharedPreferencesattached to this class- Parameters:
activity- the callingActivityclass
-
setTheme
public static void setTheme(android.app.Activity activity, java.lang.String theme)Saves the send theme to theSharedPreferencesattached to this Theme Selector class- Parameters:
activity- Activity who sets the Themetheme- int value of the style resource, example: R.style.Theme_Original
-
setTheme
public static void setTheme(android.content.Context context, java.lang.String theme)Saves the send theme to theSharedPreferencesattached to this Theme Selector class- Parameters:
context- context of the applicationtheme- int value of the style resource, example: R.style.Theme_Original
-
isStringNumeric
public static boolean isStringNumeric(java.lang.String value)
-
getTheme
public static int getTheme(android.content.Context context)
Gets the them from theSharedPreferencesattached to this Theme Selector class- Parameters:
context- calling Context- Returns:
- returns the saved value from the
SharedPreferences
-
getThemeName
public static java.lang.String getThemeName(android.content.Context context)
Gets the theme name from shared preferences.- Parameters:
context- used to get resources- Returns:
- theme name saved in preference
-
setBackIcon
public static void setBackIcon(android.app.Activity activity, @DrawableRes int drawable)Sets the back icon.- Parameters:
activity- used to get resourcesdrawable- resource id of the icon
-
setBackIcon
public static void setBackIcon(android.content.Context context, @DrawableRes int drawable)Sets the back icon- Parameters:
context- used to get resourcesdrawable- resource id of the icon
-
getBackIcon
public static int getBackIcon(android.app.Activity activity)
Gets the back icon from shared preferences.- Parameters:
activity- used to get resources- Returns:
- resource id of back icon saved in preference
-
clearTheme
public static void clearTheme(android.content.Context context)
Clears theme from shared preferences.- Parameters:
context- used to get resources
-
setBaseBackground
public static void setBaseBackground(android.content.Context context, java.lang.String filePath)Sets the background into shared preferences.- Parameters:
context- used to get resourcesfilePath- path of file
-
getBaseBackground
public static java.lang.String getBaseBackground(android.content.Context context)
Gets the base background from shared preferences- Parameters:
context- used to get resources- Returns:
- file path of background saved in preference
-
clearBaseBackground
public static void clearBaseBackground(android.content.Context context)
Clears the base background from shared preferences- Parameters:
context- used to get resources
-
setBaseTitle
public static void setBaseTitle(android.content.Context context, java.lang.String title)Sets the base title into shared preferences.- Parameters:
context- used to get resourcestitle- value of homepage header title
-
getBaseTitle
public static java.lang.String getBaseTitle(android.content.Context context)
Gets the base title from shared preferences- Parameters:
context- used to get resources- Returns:
- homepage header title saved in preference
-
setBaseTitleImageFilePath
public static void setBaseTitleImageFilePath(android.content.Context context, java.lang.String filePath)Sets the base title image file path into shared preferences.- Parameters:
context- used to get resourcesfilePath- path of file
-
getBaseTitleImageFilePath
public static java.lang.String getBaseTitleImageFilePath(android.content.Context context)
- Parameters:
context- used to get resources- Returns:
- file path of base title image
-
clearBaseTitle
public static void clearBaseTitle(android.content.Context context)
Clear the stored preference for base title- Parameters:
context- used to get resources
-
-