mirror of
https://github.com/nextcloud/android.git
synced 2024-11-28 02:17:43 +03:00
ui:preview Refactored image rendering. Show checkerboard with svg's as well.
This commit is contained in:
parent
2b1cff9172
commit
a26f3b6b44
1 changed files with 19 additions and 13 deletions
|
@ -651,22 +651,14 @@ public class PreviewImageFragment extends FileFragment {
|
|||
bitmap.getHeight());
|
||||
}
|
||||
|
||||
if (result.ocFile.getMimetype().equalsIgnoreCase("image/png")) {
|
||||
if (result.ocFile.getMimetype().equalsIgnoreCase("image/png") ||
|
||||
result.ocFile.getMimetype().equalsIgnoreCase("image/svg+xml") ||
|
||||
result.ocFile.getMimetype().equalsIgnoreCase("image/gif")) {
|
||||
if (getResources() != null) {
|
||||
imageView.setImageDrawable(generateCheckerboardLayeredDrawable(result, bitmap));
|
||||
} else {
|
||||
imageView.setImageBitmap(bitmap);
|
||||
}
|
||||
} else if (result.ocFile.getMimetype().equalsIgnoreCase("image/svg+xml")) {
|
||||
imageView.setImageDrawable(result.drawable);
|
||||
} else if (result.ocFile.getMimetype().equalsIgnoreCase("image/gif")) {
|
||||
GifDrawable gif;
|
||||
try {
|
||||
gif = new GifDrawable(result.ocFile.getStoragePath());
|
||||
imageView.setImageDrawable(gif);
|
||||
} catch (IOException ex) {
|
||||
imageView.setImageDrawable(result.drawable);
|
||||
}
|
||||
} else {
|
||||
imageView.setImageBitmap(bitmap);
|
||||
}
|
||||
|
@ -684,12 +676,26 @@ public class PreviewImageFragment extends FileFragment {
|
|||
}
|
||||
}
|
||||
|
||||
private LayerDrawable generateCheckerboardLayeredDrawable (LoadImage result, Bitmap bitmap) {
|
||||
private LayerDrawable generateCheckerboardLayeredDrawable(LoadImage result, Bitmap bitmap) {
|
||||
Resources r = getResources();
|
||||
Drawable[] layers = new Drawable[2];
|
||||
layers[0] = r.getDrawable(R.color.white);
|
||||
Drawable bitmapDrawable;
|
||||
bitmapDrawable = new BitmapDrawable(getResources(), bitmap);
|
||||
|
||||
if (result.ocFile.getMimetype().equalsIgnoreCase("image/png")) {
|
||||
bitmapDrawable = new BitmapDrawable(getResources(), bitmap);
|
||||
} else if (result.ocFile.getMimetype().equalsIgnoreCase("image/svg+xml")) {
|
||||
bitmapDrawable = result.drawable;
|
||||
} else if (result.ocFile.getMimetype().equalsIgnoreCase("image/gif")) {
|
||||
try {
|
||||
bitmapDrawable = new GifDrawable(result.ocFile.getStoragePath());
|
||||
} catch (IOException exception) {
|
||||
bitmapDrawable = result.drawable;
|
||||
}
|
||||
} else {
|
||||
bitmapDrawable = new BitmapDrawable(getResources(), bitmap);
|
||||
}
|
||||
|
||||
layers[1] = bitmapDrawable;
|
||||
LayerDrawable layerDrawable = new LayerDrawable(layers);
|
||||
|
||||
|
|
Loading…
Reference in a new issue