[Android] Preferences: prevent potential NullDereference
Jean-Baptiste Kempf
git at videolan.org
Fri Jul 18 20:46:03 CEST 2014
vlc-ports/android | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Fri Jul 18 20:45:30 2014 +0200| [6568a7118160294159b134b8775c9635c3caf5b5] | committer: Jean-Baptiste Kempf
Preferences: prevent potential NullDereference
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=6568a7118160294159b134b8775c9635c3caf5b5
---
.../src/org/videolan/vlc/gui/PreferencesActivity.java | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java b/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
index d2f631b..4c9539f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
@@ -39,6 +39,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
+import android.graphics.drawable.Drawable.ConstantState;
import android.os.Bundle;
import android.os.Environment;
import android.preference.CheckBoxPreference;
@@ -303,10 +304,11 @@ public class PreferencesActivity extends PreferenceActivity implements OnSharedP
Dialog dialog = ((PreferenceScreen)preference).getDialog();
if (dialog!=null) {
Window window = dialog.getWindow();
- if(window != null)
- window.getDecorView().setBackgroundDrawable(
- this.getWindow().getDecorView().getBackground()
- .getConstantState().newDrawable());
+ if (window != null) {
+ ConstantState state = this.getWindow().getDecorView().getBackground().getConstantState();
+ if (state != null)
+ window.getDecorView().setBackgroundDrawable(state.newDrawable());
+ }
}
}
} catch(Exception e){}
More information about the Android
mailing list