From dcb8bdec24aa6282eb7c8994ed1e5dcbe7887029 Mon Sep 17 00:00:00 2001 From: raotao Date: Fri, 25 Mar 2022 17:47:24 +0800 Subject: [PATCH] =?UTF-8?q?Plugin=20lib:=20AndroidX=E7=9A=84Activity?= =?UTF-8?q?=E4=BD=BF=E7=94=A8PluginResource?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../loader/a/PluginAppCompatXActivity.java | 14 +++++++++++++- .../replugin/loader/a/PluginFragmentXActivity.java | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/replugin-plugin-library/replugin-plugin-lib/src/main/java/com/qihoo360/replugin/loader/a/PluginAppCompatXActivity.java b/replugin-plugin-library/replugin-plugin-lib/src/main/java/com/qihoo360/replugin/loader/a/PluginAppCompatXActivity.java index e86121c3..7131ab85 100644 --- a/replugin-plugin-library/replugin-plugin-lib/src/main/java/com/qihoo360/replugin/loader/a/PluginAppCompatXActivity.java +++ b/replugin-plugin-library/replugin-plugin-lib/src/main/java/com/qihoo360/replugin/loader/a/PluginAppCompatXActivity.java @@ -18,6 +18,7 @@ import android.content.Context; import android.content.Intent; +import android.content.res.Resources; import android.os.Build; import android.os.Bundle; @@ -26,6 +27,7 @@ import com.qihoo360.replugin.RePluginInternal; import com.qihoo360.replugin.helper.LogRelease; +import com.qihoo360.replugin.loader.PluginResource; import java.lang.reflect.Field; @@ -34,15 +36,25 @@ */ public abstract class PluginAppCompatXActivity extends AppCompatActivity { + private PluginResource pluginResource; + @Override protected void attachBaseContext(Context newBase) { newBase = RePluginInternal.createActivityContext(this, newBase); + pluginResource = new PluginResource(newBase); super.attachBaseContext(newBase); } @Override - public Context getBaseContext() { + public Resources getResources() { + if (pluginResource != null){ + return pluginResource; + } + return super.getResources(); + } + @Override + public Context getBaseContext() { return super.getBaseContext(); } diff --git a/replugin-plugin-library/replugin-plugin-lib/src/main/java/com/qihoo360/replugin/loader/a/PluginFragmentXActivity.java b/replugin-plugin-library/replugin-plugin-lib/src/main/java/com/qihoo360/replugin/loader/a/PluginFragmentXActivity.java index 95c86530..62f2120d 100644 --- a/replugin-plugin-library/replugin-plugin-lib/src/main/java/com/qihoo360/replugin/loader/a/PluginFragmentXActivity.java +++ b/replugin-plugin-library/replugin-plugin-lib/src/main/java/com/qihoo360/replugin/loader/a/PluginFragmentXActivity.java @@ -18,6 +18,7 @@ import android.content.Context; import android.content.Intent; +import android.content.res.Resources; import android.os.Build; import android.os.Bundle; @@ -26,6 +27,7 @@ import com.qihoo360.replugin.RePluginInternal; import com.qihoo360.replugin.helper.LogRelease; +import com.qihoo360.replugin.loader.PluginResource; import java.lang.reflect.Field; @@ -34,15 +36,25 @@ */ public abstract class PluginFragmentXActivity extends FragmentActivity { + private PluginResource pluginResource; + @Override protected void attachBaseContext(Context newBase) { newBase = RePluginInternal.createActivityContext(this, newBase); + pluginResource = new PluginResource(newBase); super.attachBaseContext(newBase); } @Override - public Context getBaseContext() { + public Resources getResources() { + if (pluginResource != null){ + return pluginResource; + } + return super.getResources(); + } + @Override + public Context getBaseContext() { return super.getBaseContext(); }