BaseActivity: invalidate icon cache on Android P
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
e5f6c24174
commit
8aab35a70d
@ -121,21 +121,20 @@ public abstract class BaseActivity extends AppCompatActivity implements Topic.Su
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTopicPublished(Topic topic) {
|
public void onTopicPublished(Topic topic) {
|
||||||
try {
|
if (topic == Application.getComponent().getThemeChangeTopic()) {
|
||||||
Field f = getResources().getClass().getDeclaredField("mResourcesImpl");
|
try {
|
||||||
f.setAccessible(true);
|
Field f = getResources().getClass().getDeclaredField("mResourcesImpl");
|
||||||
Object o = f.get(getResources());
|
f.setAccessible(true);
|
||||||
f = o.getClass().getDeclaredField("mDrawableCache");
|
Object o = f.get(getResources());
|
||||||
f.setAccessible(true);
|
f = o.getClass().getDeclaredField("mDrawableCache");
|
||||||
o = f.get(o);
|
f.setAccessible(true);
|
||||||
f = o.getClass().getSuperclass().getDeclaredField("mThemedEntries");
|
o = f.get(o);
|
||||||
f.setAccessible(true);
|
o.getClass().getMethod("onConfigurationChange", int.class).invoke(o, -1);
|
||||||
o = f.get(o);
|
} catch (Exception e) {
|
||||||
o.getClass().getMethod("clear").invoke(o);
|
Log.e(TAG, "Failed to flush icon cache", e);
|
||||||
} catch (Exception e) {
|
}
|
||||||
Log.e(TAG, "Failed to flush icon cache", e);
|
recreate();
|
||||||
}
|
}
|
||||||
recreate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -101,7 +101,8 @@ public class SettingsActivity extends AppCompatActivity implements Topic.Subscri
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTopicPublished(final Topic topic) {
|
public void onTopicPublished(final Topic topic) {
|
||||||
recreate();
|
if (topic == Application.getComponent().getThemeChangeTopic())
|
||||||
|
recreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user