[Android] Disable DayNight mode if app context is not ready

Geoffrey Métais git at videolan.org
Wed Oct 11 17:15:40 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Oct 11 17:14:46 2017 +0200| [e6f98d3b4723821851cd17f432096b8efcbf19de] | committer: Geoffrey Métais

Disable DayNight mode if app context is not ready

This is to avoid NPE

> https://code.videolan.org/videolan/vlc-android/commit/e6f98d3b4723821851cd17f432096b8efcbf19de
---

 vlc-android/src/org/videolan/vlc/gui/BaseActivity.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/BaseActivity.java b/vlc-android/src/org/videolan/vlc/gui/BaseActivity.java
index a73e12a36..7856e2077 100644
--- a/vlc-android/src/org/videolan/vlc/gui/BaseActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/BaseActivity.java
@@ -14,7 +14,7 @@ import org.videolan.vlc.VLCApplication;
 public class BaseActivity extends AppCompatActivity {
 
     static {
-        AppCompatDelegate.setDefaultNightMode(PreferenceManager.getDefaultSharedPreferences(VLCApplication.getAppContext()).getBoolean("daynight", false) ? AppCompatDelegate.MODE_NIGHT_AUTO : AppCompatDelegate.MODE_NIGHT_NO);
+        AppCompatDelegate.setDefaultNightMode(VLCApplication.getAppContext() != null && PreferenceManager.getDefaultSharedPreferences(VLCApplication.getAppContext()).getBoolean("daynight", false) ? AppCompatDelegate.MODE_NIGHT_AUTO : AppCompatDelegate.MODE_NIGHT_NO);
     }
 
     protected SharedPreferences mSettings;



More information about the Android mailing list