mirror of
https://gitee.com/replugin/RePlugin.git
synced 2024-12-01 19:28:22 +08:00
raotao:【Replugin】修改BUG
1、解决Android高版本上使用webview时资源文件找不到BUG 2、解决插件startActivityForResult2的反射参数错误 3、解决当已运行的插件发生更新后,在常驻进程存活的情况下,重新启动UI进程,会出现内置插件加载失败的情况 4、解决编译期间解析AndroidManifest.xml时发生的错误 5、使用高版本的javassist,解决activity替换失败的问题 reviewer:yuxueting
This commit is contained in:
parent
824b62814c
commit
dbaaa67142
@ -360,6 +360,9 @@ class PmBase {
|
||||
}
|
||||
}
|
||||
|
||||
// 将插件信息存入Map
|
||||
refreshPluginMap(plugins);
|
||||
|
||||
// 判断是否有需要更新的插件
|
||||
// FIXME 执行此操作前,判断下当前插件的运行进程,具体可以限制仅允许该插件运行在一个进程且为自身进程中
|
||||
List<PluginInfo> updatedPlugins = null;
|
||||
@ -374,10 +377,9 @@ class PmBase {
|
||||
}
|
||||
}
|
||||
|
||||
// 将需要更新的插件更新到Map中
|
||||
if (updatedPlugins != null) {
|
||||
refreshPluginMap(updatedPlugins);
|
||||
} else {
|
||||
refreshPluginMap(plugins);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ dependencies {
|
||||
compile 'org.codehaus.groovy:groovy:2.4.7'
|
||||
compile 'com.squareup:javapoet:1.5.1'
|
||||
compile 'com.android.tools.build:transform-api:1.5.0'
|
||||
compile 'javassist:javassist:3.12.1.GA'
|
||||
compile 'org.javassist:javassist:3.18.2-GA'
|
||||
compile 'commons-io:commons-io:2.5'
|
||||
|
||||
compile gradleApi()
|
||||
|
@ -64,8 +64,20 @@ public class ManifestAPI {
|
||||
manifestOutputFile = processManifestTask.getManifestOutputFile()
|
||||
instantRunManifestOutputFile = processManifestTask.getInstantRunManifestOutputFile()
|
||||
} catch (Exception e) {
|
||||
manifestOutputFile = new File(processManifestTask.getManifestOutputDirectory(), "AndroidManifest.xml")
|
||||
instantRunManifestOutputFile = new File(processManifestTask.getInstantRunManifestOutputDirectory(), "AndroidManifest.xml")
|
||||
// manifestOutputFile = new File(processManifestTask.getManifestOutputDirectory(), "AndroidManifest.xml")
|
||||
// instantRunManifestOutputFile = new File(processManifestTask.getInstantRunManifestOutputDirectory(), "AndroidManifest.xml")
|
||||
def dir = processManifestTask.getManifestOutputDirectory()
|
||||
if (dir instanceof File || dir instanceof String) {
|
||||
manifestOutputFile = new File(dir, "AndroidManifest.xml")
|
||||
} else {
|
||||
manifestOutputFile = new File(dir.getAsFile().get(), "AndroidManifest.xml")
|
||||
}
|
||||
dir = processManifestTask.getInstantRunManifestOutputDirectory()
|
||||
if (dir instanceof File || dir instanceof String) {
|
||||
instantRunManifestOutputFile = new File(dir, "AndroidManifest.xml")
|
||||
} else {
|
||||
instantRunManifestOutputFile = new File(dir.getAsFile().get(), "AndroidManifest.xml")
|
||||
}
|
||||
}
|
||||
|
||||
if (manifestOutputFile == null && instantRunManifestOutputFile == null) {
|
||||
|
@ -1290,7 +1290,7 @@ public class RePlugin {
|
||||
startActivity = new MethodInvoker(classLoader, rePlugin, "startActivity", new Class<?>[]{Context.class, Intent.class});
|
||||
startActivity2 = new MethodInvoker(classLoader, rePlugin, "startActivity", new Class<?>[]{Context.class, Intent.class, String.class, String.class});
|
||||
startActivityForResult = new MethodInvoker(classLoader, rePlugin, "startActivityForResult", new Class<?>[]{Activity.class, Intent.class, int.class});
|
||||
startActivityForResult2 = new MethodInvoker(classLoader, rePlugin, "startActivityForResult", new Class<?>[]{Context.class, Intent.class, int.class, Bundle.class});
|
||||
startActivityForResult2 = new MethodInvoker(classLoader, rePlugin, "startActivityForResult", new Class<?>[]{Activity.class, Intent.class, int.class, Bundle.class});
|
||||
createIntent = new MethodInvoker(classLoader, rePlugin, "createIntent", new Class<?>[]{String.class, String.class});
|
||||
createComponentName = new MethodInvoker(classLoader, rePlugin, "createComponentName", new Class<?>[]{String.class, String.class});
|
||||
isForDev = new MethodInvoker(classLoader, rePlugin, "isForDev", new Class<?>[]{});
|
||||
|
@ -0,0 +1,424 @@
|
||||
package com.qihoo360.replugin.loader;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.res.AssetFileDescriptor;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.content.res.XmlResourceParser;
|
||||
import android.graphics.Movie;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.util.TypedValue;
|
||||
|
||||
import com.qihoo360.replugin.RePlugin;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
public class PluginResource extends Resources {
|
||||
|
||||
private Resources mPluginResource;
|
||||
private Resources mHostResources;
|
||||
|
||||
public PluginResource(Resources resources) {
|
||||
super(resources.getAssets(), resources.getDisplayMetrics(), resources.getConfiguration());
|
||||
this.mPluginResource = resources;
|
||||
if (RePlugin.isHostInitialized()){
|
||||
mHostResources = RePlugin.getHostContext().getResources();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getText(int id) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.getText(id);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.getText(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getQuantityText(int id, int quantity) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.getQuantityText(id, quantity);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.getQuantityText(id, quantity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(int id) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.getString(id);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.getString(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(int id, Object... formatArgs) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.getString(id, formatArgs);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.getString(id, formatArgs);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuantityString(int id, int quantity, Object... formatArgs)
|
||||
throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.getQuantityString(id, quantity, formatArgs);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.getQuantityString(id, quantity, formatArgs);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuantityString(int id, int quantity) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.getQuantityString(id, quantity);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.getQuantityString(id, quantity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getText(int id, CharSequence def) {
|
||||
try {
|
||||
return mPluginResource.getText(id, def);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.getText(id, def);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence[] getTextArray(int id) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.getTextArray(id);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.getTextArray(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getStringArray(int id) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.getStringArray(id);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.getStringArray(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getIntArray(int id) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.getIntArray(id);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.getIntArray(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedArray obtainTypedArray(int id) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.obtainTypedArray(id);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.obtainTypedArray(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDimension(int id) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.getDimension(id);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.getDimension(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDimensionPixelOffset(int id) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.getDimensionPixelOffset(id);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.getDimensionPixelOffset(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDimensionPixelSize(int id) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.getDimensionPixelSize(id);
|
||||
}catch (NotFoundException e){
|
||||
e.printStackTrace();
|
||||
return mHostResources.getDimensionPixelSize(id);
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.CUPCAKE)
|
||||
@Override
|
||||
public float getFraction(int id, int base, int pbase) {
|
||||
try {
|
||||
return mPluginResource.getFraction(id, base, pbase);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.getFraction(id, base, pbase);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable getDrawable(int id) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.getDrawable(id);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.getDrawable(id);
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public Drawable getDrawable(int id, Theme theme) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.getDrawable(id, theme);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.getDrawable(id, theme);
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
|
||||
@Override
|
||||
public Drawable getDrawableForDensity(int id, int density) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.getDrawableForDensity(id, density);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.getDrawableForDensity(id, density);
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
|
||||
@Override
|
||||
public Drawable getDrawableForDensity(int id, int density, Theme theme) {
|
||||
try {
|
||||
return mPluginResource.getDrawableForDensity(id, density);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.getDrawableForDensity(id, density);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Movie getMovie(int id) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.getMovie(id);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.getMovie(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor(int id) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.getColor(id);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.getColor(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ColorStateList getColorStateList(int id) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.getColorStateList(id);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.getColorStateList(id);
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.CUPCAKE)
|
||||
@Override
|
||||
public boolean getBoolean(int id) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.getBoolean(id);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.getBoolean(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInteger(int id) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.getInteger(id);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.getInteger(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlResourceParser getLayout(int id) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.getLayout(id);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.getLayout(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlResourceParser getAnimation(int id) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.getAnimation(id);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.getAnimation(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlResourceParser getXml(int id) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.getXml(id);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.getXml(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream openRawResource(int id) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.openRawResource(id);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.openRawResource(id);
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.CUPCAKE)
|
||||
@Override
|
||||
public InputStream openRawResource(int id, TypedValue value) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.openRawResource(id, value);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.openRawResource(id, value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AssetFileDescriptor openRawResourceFd(int id) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.openRawResourceFd(id);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.openRawResourceFd(id);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getValue(int id, TypedValue outValue, boolean resolveRefs)
|
||||
throws NotFoundException {
|
||||
try {
|
||||
mPluginResource.getValue(id, outValue, resolveRefs);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
mHostResources.getValue(id, outValue, resolveRefs);
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
|
||||
@Override
|
||||
public void getValueForDensity(int id, int density, TypedValue outValue, boolean resolveRefs)
|
||||
throws NotFoundException {
|
||||
try {
|
||||
mPluginResource.getValueForDensity(id, density, outValue, resolveRefs);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
mHostResources.getValueForDensity(id, density, outValue, resolveRefs);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getResourceName(int resid) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.getResourceName(resid);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.getResourceName(resid);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getResourcePackageName(int resid) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.getResourcePackageName(resid);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.getResourcePackageName(resid);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getResourceTypeName(int resid) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.getResourceTypeName(resid);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.getResourceTypeName(resid);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getResourceEntryName(int resid) throws NotFoundException {
|
||||
try {
|
||||
return mPluginResource.getResourceEntryName(resid);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return mHostResources.getResourceEntryName(resid);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdentifier(String name, String defType, String defPackage) {
|
||||
try {
|
||||
return mPluginResource.getIdentifier(name, defType, defPackage);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return mHostResources.getIdentifier(name, defType, defPackage);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Configuration getConfiguration() {
|
||||
try {
|
||||
return mPluginResource.getConfiguration();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return mHostResources.getConfiguration();
|
||||
}
|
||||
}
|
||||
}
|
@ -19,10 +19,12 @@ package com.qihoo360.replugin.loader.a;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.qihoo360.replugin.RePluginInternal;
|
||||
import com.qihoo360.replugin.helper.LogRelease;
|
||||
import com.qihoo360.replugin.loader.PluginResource;
|
||||
|
||||
/**
|
||||
* 插件内的BaseActivity,建议插件内所有的Activity都要继承此类
|
||||
@ -32,12 +34,23 @@ import com.qihoo360.replugin.helper.LogRelease;
|
||||
*/
|
||||
public abstract class PluginActivity extends Activity {
|
||||
|
||||
private PluginResource pluginResource;
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context newBase) {
|
||||
newBase = RePluginInternal.createActivityContext(this, newBase);
|
||||
pluginResource = new PluginResource(newBase.getResources());
|
||||
super.attachBaseContext(newBase);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resources getResources() {
|
||||
if (pluginResource != null){
|
||||
return pluginResource;
|
||||
}
|
||||
return super.getResources();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
//
|
||||
|
@ -19,22 +19,35 @@ package com.qihoo360.replugin.loader.a;
|
||||
import android.app.ActivityGroup;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.qihoo360.replugin.RePluginInternal;
|
||||
import com.qihoo360.replugin.helper.LogRelease;
|
||||
import com.qihoo360.replugin.loader.PluginResource;
|
||||
|
||||
/**
|
||||
* @author RePlugin Team
|
||||
*/
|
||||
public abstract class PluginActivityGroup extends ActivityGroup {
|
||||
|
||||
private PluginResource pluginResource;
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context newBase) {
|
||||
newBase = RePluginInternal.createActivityContext(this, newBase);
|
||||
pluginResource = new PluginResource(newBase.getResources());
|
||||
super.attachBaseContext(newBase);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resources getResources() {
|
||||
if (pluginResource != null){
|
||||
return pluginResource;
|
||||
}
|
||||
return super.getResources();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
//
|
||||
|
@ -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;
|
||||
import android.support.v4.app.Fragment;
|
||||
@ -25,6 +26,7 @@ import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.qihoo360.replugin.RePluginInternal;
|
||||
import com.qihoo360.replugin.helper.LogRelease;
|
||||
import com.qihoo360.replugin.loader.PluginResource;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
@ -33,12 +35,23 @@ import java.lang.reflect.Field;
|
||||
*/
|
||||
public abstract class PluginAppCompatActivity extends AppCompatActivity {
|
||||
|
||||
private PluginResource pluginResource;
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context newBase) {
|
||||
newBase = RePluginInternal.createActivityContext(this, newBase);
|
||||
pluginResource = new PluginResource(newBase.getResources());
|
||||
super.attachBaseContext(newBase);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resources getResources() {
|
||||
if (pluginResource != null){
|
||||
return pluginResource;
|
||||
}
|
||||
return super.getResources();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Context getBaseContext() {
|
||||
|
||||
|
@ -19,22 +19,35 @@ package com.qihoo360.replugin.loader.a;
|
||||
import android.app.ExpandableListActivity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.qihoo360.replugin.RePluginInternal;
|
||||
import com.qihoo360.replugin.helper.LogRelease;
|
||||
import com.qihoo360.replugin.loader.PluginResource;
|
||||
|
||||
/**
|
||||
* @author RePlugin Team
|
||||
*/
|
||||
public abstract class PluginExpandableListActivity extends ExpandableListActivity {
|
||||
|
||||
private PluginResource pluginResource;
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context newBase) {
|
||||
newBase = RePluginInternal.createActivityContext(this, newBase);
|
||||
pluginResource = new PluginResource(newBase.getResources());
|
||||
super.attachBaseContext(newBase);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resources getResources() {
|
||||
if (pluginResource != null){
|
||||
return pluginResource;
|
||||
}
|
||||
return super.getResources();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
//
|
||||
|
@ -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;
|
||||
import android.support.v4.app.Fragment;
|
||||
@ -25,6 +26,7 @@ import android.support.v4.app.FragmentActivity;
|
||||
|
||||
import com.qihoo360.replugin.RePluginInternal;
|
||||
import com.qihoo360.replugin.helper.LogRelease;
|
||||
import com.qihoo360.replugin.loader.PluginResource;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
@ -33,12 +35,23 @@ import java.lang.reflect.Field;
|
||||
*/
|
||||
public abstract class PluginFragmentActivity extends FragmentActivity {
|
||||
|
||||
private PluginResource pluginResource;
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context newBase) {
|
||||
newBase = RePluginInternal.createActivityContext(this, newBase);
|
||||
pluginResource = new PluginResource(newBase.getResources());
|
||||
super.attachBaseContext(newBase);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resources getResources() {
|
||||
if (pluginResource != null){
|
||||
return pluginResource;
|
||||
}
|
||||
return super.getResources();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Context getBaseContext() {
|
||||
|
||||
|
@ -19,22 +19,35 @@ package com.qihoo360.replugin.loader.a;
|
||||
import android.app.ListActivity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.qihoo360.replugin.RePluginInternal;
|
||||
import com.qihoo360.replugin.helper.LogRelease;
|
||||
import com.qihoo360.replugin.loader.PluginResource;
|
||||
|
||||
/**
|
||||
* @author RePlugin Team
|
||||
*/
|
||||
public abstract class PluginListActivity extends ListActivity {
|
||||
|
||||
private PluginResource pluginResource;
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context newBase) {
|
||||
newBase = RePluginInternal.createActivityContext(this, newBase);
|
||||
pluginResource = new PluginResource(newBase.getResources());
|
||||
super.attachBaseContext(newBase);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resources getResources() {
|
||||
if (pluginResource != null){
|
||||
return pluginResource;
|
||||
}
|
||||
return super.getResources();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
//
|
||||
|
@ -18,11 +18,13 @@ package com.qihoo360.replugin.loader.a;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceActivity;
|
||||
|
||||
import com.qihoo360.replugin.RePluginInternal;
|
||||
import com.qihoo360.replugin.helper.LogRelease;
|
||||
import com.qihoo360.replugin.loader.PluginResource;
|
||||
|
||||
/**
|
||||
* @author RePlugin Team
|
||||
@ -30,12 +32,23 @@ import com.qihoo360.replugin.helper.LogRelease;
|
||||
|
||||
public class PluginPreferenceActivity extends PreferenceActivity {
|
||||
|
||||
private PluginResource pluginResource;
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context newBase) {
|
||||
newBase = RePluginInternal.createActivityContext(this, newBase);
|
||||
pluginResource = new PluginResource(newBase.getResources());
|
||||
super.attachBaseContext(newBase);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resources getResources() {
|
||||
if (pluginResource != null){
|
||||
return pluginResource;
|
||||
}
|
||||
return super.getResources();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
//
|
||||
|
@ -19,22 +19,35 @@ package com.qihoo360.replugin.loader.a;
|
||||
import android.app.TabActivity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.qihoo360.replugin.RePluginInternal;
|
||||
import com.qihoo360.replugin.helper.LogRelease;
|
||||
import com.qihoo360.replugin.loader.PluginResource;
|
||||
|
||||
/**
|
||||
* @author RePlugin Team
|
||||
*/
|
||||
public abstract class PluginTabActivity extends TabActivity {
|
||||
|
||||
private PluginResource pluginResource;
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context newBase) {
|
||||
newBase = RePluginInternal.createActivityContext(this, newBase);
|
||||
pluginResource = new PluginResource(newBase.getResources());
|
||||
super.attachBaseContext(newBase);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resources getResources() {
|
||||
if (pluginResource != null){
|
||||
return pluginResource;
|
||||
}
|
||||
return super.getResources();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user