Commit e7cd90f1 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf
Browse files

Avoid crash in Preferences

More checks and exception catching...
parent 270a40cc
...@@ -32,6 +32,7 @@ import org.videolan.vlc.util.BitmapCache; ...@@ -32,6 +32,7 @@ import org.videolan.vlc.util.BitmapCache;
import org.videolan.vlc.util.Util; import org.videolan.vlc.util.Util;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
...@@ -49,6 +50,7 @@ import android.preference.PreferenceActivity; ...@@ -49,6 +50,7 @@ import android.preference.PreferenceActivity;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.preference.PreferenceScreen; import android.preference.PreferenceScreen;
import android.text.format.DateFormat; import android.text.format.DateFormat;
import android.view.Window;
import android.widget.Toast; import android.widget.Toast;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
...@@ -296,12 +298,18 @@ public class PreferencesActivity extends PreferenceActivity implements OnSharedP ...@@ -296,12 +298,18 @@ public class PreferencesActivity extends PreferenceActivity implements OnSharedP
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference)
{ {
super.onPreferenceTreeClick(preferenceScreen, preference); super.onPreferenceTreeClick(preferenceScreen, preference);
if (preference!=null) try {
if (preference instanceof PreferenceScreen) if (preference!=null && preference instanceof PreferenceScreen) {
if (((PreferenceScreen)preference).getDialog()!=null) Dialog dialog = ((PreferenceScreen)preference).getDialog();
((PreferenceScreen)preference).getDialog().getWindow().getDecorView() if (dialog!=null) {
.setBackgroundDrawable(this.getWindow().getDecorView().getBackground() Window window = dialog.getWindow();
.getConstantState().newDrawable()); if(window != null)
window.getDecorView().setBackgroundDrawable(
this.getWindow().getDecorView().getBackground()
.getConstantState().newDrawable());
}
}
} catch(Exception e){}
return false; return false;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment