Open terribleness opened 6 years ago
i resolve this issue by change the getImage function as follow,support android code-push plugin:
private Drawable getImage(String name, String altPath, double altDensity) throws IOException { Drawable result = null; Resources activityRes = cordova.getActivity().getResources();
if (name != null) {
int id = activityRes.getIdentifier(name, "drawable",
cordova.getActivity().getPackageName());
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
result = activityRes.getDrawable(id);
} else {
result = activityRes.getDrawable(id, cordova.getActivity().getTheme());
}
} else if (altPath != null) {
File file = new File("www", altPath);
InputStream is = null;
try {
Bitmap bitmap = null;
try{
is = cordova.getActivity().getAssets().open(file.getPath());
}
catch(Exception e){
File f = cordova.getActivity().getFilesDir();
File codepush = new File(f.getPath()+"/codepush/deploy/versions");
File[] list = codepush.listFiles();
String codepushName = list[0].getName();
file = new File(codepush.getPath()+"/"+codepushName+"/"+"www",altPath);
is = new FileInputStream(file);
}
finally {
bitmap = BitmapFactory.decodeStream(is);
bitmap.setDensity((int) (DisplayMetrics.DENSITY_MEDIUM * altDensity));
result = new BitmapDrawable(activityRes, bitmap);
}
} finally {
// Make sure we close this input stream to prevent resource leak.
try {
is.close();
} catch (Exception e) {}
}
}
return result;
}
i saw your source code in Themeablebrowser.java getImage function,as follow code: is = cordova.getActivity().getAssets().open(file.getPath());
but with cordova-plugin-code-push,the wwwImage path change like "/data/data/com.dj/files/codepush/deploy/versions/319858b6658fef2c3feef68a9575dcceba9d6a6ae04c07dbfbc4b89e017447bb/www"
so, I mean your code can not get the real image by cordova.getActivity().getAssets(), so , please tell me how to get the close button wwwImage?