mirror of
https://gitee.com/replugin/RePlugin.git
synced 2024-11-29 18:28:33 +08:00
Plugin lib: AndroidX的Activity使用PluginResource
This commit is contained in:
parent
e44e8b0524
commit
dcb8bdec24
@ -18,6 +18,7 @@ package com.qihoo360.replugin.loader.a;
|
||||
|
||||
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 androidx.fragment.app.Fragment;
|
||||
|
||||
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 @@ import java.lang.reflect.Field;
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ package com.qihoo360.replugin.loader.a;
|
||||
|
||||
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 androidx.fragment.app.FragmentActivity;
|
||||
|
||||
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 @@ import java.lang.reflect.Field;
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user