Skip to content

Commit

Permalink
Activate Library
Browse files Browse the repository at this point in the history
  • Loading branch information
Your NameerliteHq committed Jan 21, 2021
1 parent 533ba63 commit 2a4cfd9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions themelite/src/main/java/com/erlite/themelite/ThemeLite.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class ThemeLite {

SharedPreferences sharedPreferences;
SharedPreferences.Editor editor;
public int setTheme;
public int getTheme, dark, light;


public ThemeLite(Context context){
Expand All @@ -18,26 +18,28 @@ public ThemeLite(Context context){


//fetch theme for shared prefs
setTheme = sharedPreferences.getInt("ThemeValue", 1);
getTheme = sharedPreferences.getInt("ThemeValue", 1);

dark = AppCompatDelegate.MODE_NIGHT_YES;
light = AppCompatDelegate.MODE_NIGHT_NO;

}

//save the theme state
public void saveTheme(Context context){

setTheme = AppCompatDelegate.getDefaultNightMode();
getTheme = AppCompatDelegate.getDefaultNightMode();

sharedPreferences = context.getSharedPreferences("darkLite", Context.MODE_PRIVATE);
editor = sharedPreferences.edit();

editor.putInt("ThemeValue", setTheme);
editor.putInt("ThemeValue", getTheme);
editor.apply();

}

public void setTheme(){
AppCompatDelegate.setDefaultNightMode(setTheme);
AppCompatDelegate.setDefaultNightMode(getTheme);
}

public void light(){
Expand Down

0 comments on commit 2a4cfd9

Please sign in to comment.