Skip to content

Commit

Permalink
#FIX #plugin-lib 解决自定义PluginResource在Lenovo Z90-7必现崩溃Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
raotao committed Aug 28, 2020
1 parent ee4f8f2 commit 4b6e2f9
Showing 1 changed file with 9 additions and 5 deletions.
Expand Up @@ -24,7 +24,7 @@ public class PluginResource extends Resources {
public PluginResource(Resources resources) {
super(resources.getAssets(), resources.getDisplayMetrics(), resources.getConfiguration());
this.mPluginResource = resources;
if (RePlugin.isHostInitialized()){
if (RePlugin.isHostInitialized()) {
mHostResources = RePlugin.getHostContext().getResources();
}
}
Expand Down Expand Up @@ -164,9 +164,13 @@ public int getDimensionPixelOffset(int id) throws NotFoundException {
public int getDimensionPixelSize(int id) throws NotFoundException {
try {
return mPluginResource.getDimensionPixelSize(id);
}catch (NotFoundException e){
} catch (NotFoundException e) {
e.printStackTrace();
return mHostResources.getDimensionPixelSize(id);
try {
return mHostResources.getDimensionPixelSize(id);
} catch (NotFoundException e1) {
return 0;
}
}
}

Expand Down Expand Up @@ -406,7 +410,7 @@ public String getResourceEntryName(int resid) throws NotFoundException {
public int getIdentifier(String name, String defType, String defPackage) {
try {
return mPluginResource.getIdentifier(name, defType, defPackage);
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
return mHostResources.getIdentifier(name, defType, defPackage);
}
Expand All @@ -416,7 +420,7 @@ public int getIdentifier(String name, String defType, String defPackage) {
public Configuration getConfiguration() {
try {
return mPluginResource.getConfiguration();
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
return mHostResources.getConfiguration();
}
Expand Down

0 comments on commit 4b6e2f9

Please sign in to comment.