FragmentUtils: Directly cast context as SettingsActivity

ContextThemeWrapper#getContext seems to be an instance of ContextImpl now which
is not public API and also not what we want. Directly cast context as SettingsActivity
which seems to work exactly how we need this to.

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
Harsh Shandilya 2019-09-27 17:26:56 +05:30
parent 992b6486a1
commit c545b5e65f

View File

@ -18,8 +18,8 @@ public final class FragmentUtils {
public static SettingsActivity getPrefActivity(final Preference preference) { public static SettingsActivity getPrefActivity(final Preference preference) {
final Context context = preference.getContext(); final Context context = preference.getContext();
if (context instanceof ContextThemeWrapper) { if (context instanceof ContextThemeWrapper) {
if (((ContextThemeWrapper) context).getBaseContext() instanceof SettingsActivity) { if (context instanceof SettingsActivity) {
return ((SettingsActivity) ((ContextThemeWrapper) context).getBaseContext()); return ((SettingsActivity) context);
} }
} }
return null; return null;