summaryrefslogtreecommitdiffhomepage
path: root/app
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-06-04 18:35:18 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-06-04 18:35:18 +0200
commitb88acf3406e6390a247ea0b8ea2c01a4305c5198 (patch)
tree2e5a62793db7b51d9562690f3684998743510eac /app
parent2efae1ac68619e82997e7988bf7f9210322a0844 (diff)
BaseActivity: support android 5 and 6 when clearing drawable cache
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/com/wireguard/android/activity/BaseActivity.java22
1 files changed, 15 insertions, 7 deletions
diff --git a/app/src/main/java/com/wireguard/android/activity/BaseActivity.java b/app/src/main/java/com/wireguard/android/activity/BaseActivity.java
index 3cce412d..2ebb6e90 100644
--- a/app/src/main/java/com/wireguard/android/activity/BaseActivity.java
+++ b/app/src/main/java/com/wireguard/android/activity/BaseActivity.java
@@ -120,18 +120,26 @@ public abstract class BaseActivity extends AppCompatActivity implements Topic.Su
}
@Override
- public void onTopicPublished(Topic topic) {
+ public void onTopicPublished(final Topic topic) {
if (topic == Application.getComponent().getThemeChangeTopic()) {
try {
- Field f = getResources().getClass().getDeclaredField("mResourcesImpl");
- f.setAccessible(true);
- Object o = f.get(getResources());
+ Field f;
+ Object o = getResources();
+ try {
+ f = o.getClass().getDeclaredField("mResourcesImpl");
+ f.setAccessible(true);
+ o = f.get(o);
+ } catch (final Exception ignored) { }
f = o.getClass().getDeclaredField("mDrawableCache");
f.setAccessible(true);
o = f.get(o);
- o.getClass().getMethod("onConfigurationChange", int.class).invoke(o, -1);
- } catch (Exception e) {
- Log.e(TAG, "Failed to flush icon cache", e);
+ try {
+ o.getClass().getMethod("onConfigurationChange", int.class).invoke(o, -1);
+ } catch (final Exception ignored) {
+ o.getClass().getMethod("clear").invoke(o);
+ }
+ } catch (final Exception e) {
+ Log.e(TAG, "Failed to flush drawable cache", e);
}
recreate();
}