Skip to content

Commit 1c5de23

Browse files
committed
update loader for 5.x and 2.x
Signed-off-by: Cai Liming <405977146@163.com>
1 parent bf71bcd commit 1c5de23

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

PluginCore/src/com/plugin/core/PluginLoader.java

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,30 @@ public static Context getDefaultPluginContext(@SuppressWarnings("rawtypes") Clas
223223
public static Context getNewPluginContext(@SuppressWarnings("rawtypes") Class clazz) {
224224

225225
Context pluginContext = getDefaultPluginContext(clazz);
226+
//为了使5.0支持主题, 这里做api版本区分
227+
if (Build.VERSION.SDK_INT >= 14 && Build.VERSION.SDK_INT <= 20 ) {
228+
229+
if (pluginContext != null) {
230+
pluginContext = PluginCreator.createPluginApplicationContext(sApplication,
231+
pluginContext.getResources(), (DexClassLoader)pluginContext.getClassLoader());
232+
pluginContext.setTheme(sApplication.getApplicationContext().getApplicationInfo().theme);
233+
}
234+
235+
return pluginContext;
236+
237+
} else {
238+
PluginDescriptor pd = getPluginDescriptorByClassName(clazz.getName());
226239

227-
if (pluginContext != null) {
228-
pluginContext = PluginCreator.createPluginApplicationContext(sApplication,
229-
pluginContext.getResources(), (DexClassLoader)pluginContext.getClassLoader());
230-
pluginContext.setTheme(sApplication.getApplicationContext().getApplicationInfo().theme);
240+
Resources resFor5 = PluginCreator.createPluginResourceFor5(sApplication, pd.getInstalledPath());
241+
242+
if (pluginContext != null) {
243+
pluginContext = PluginCreator.createPluginApplicationContext(sApplication,
244+
resFor5, (DexClassLoader)pluginContext.getClassLoader());
245+
pluginContext.setTheme(sApplication.getApplicationContext().getApplicationInfo().theme);
246+
}
247+
return null;
231248
}
232249

233-
return pluginContext;
234250
}
235251

236252
/**

0 commit comments

Comments
 (0)