This repository has been archived by the owner on Oct 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
day night theme setup + removing memory leaks + use vector drawables
- Loading branch information
Laith Nurie
committed
May 2, 2016
1 parent
3f27cb8
commit 9fb90ba
Showing
54 changed files
with
223 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
mobile/src/main/java/com/laithlab/rhythm/activity/RhythmActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.laithlab.rhythm.activity; | ||
|
||
import android.content.res.Configuration; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.app.AppCompatDelegate; | ||
|
||
import com.laithlab.rhythm.RhythmApp; | ||
|
||
public abstract class RhythmActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onResume() { | ||
super.onResume(); | ||
updateTheme(); | ||
int currentNightMode = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; | ||
if (currentNightMode != ((RhythmApp) getApplication()).getCurrentNighMode()) { | ||
((RhythmApp) getApplication()).setCurrentNightMode(currentNightMode); | ||
recreate(); | ||
} | ||
} | ||
|
||
private void updateTheme() { | ||
String theme = ((RhythmApp) getApplication()).getSelectedTheme(); | ||
int nightMode = AppCompatDelegate.MODE_NIGHT_NO; | ||
if (theme.equals("dark")) { | ||
nightMode = AppCompatDelegate.MODE_NIGHT_YES; | ||
} | ||
if (theme.equals("auto")) { | ||
nightMode = AppCompatDelegate.MODE_NIGHT_AUTO; | ||
} | ||
AppCompatDelegate.setDefaultNightMode(nightMode); | ||
getDelegate().applyDayNight(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.