diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-01-15 12:39:59 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-01-15 12:39:59 +0100 |
commit | 4d4d8f98e9824f31eae2ce00af2b2b618243d87f (patch) | |
tree | c4c7459780b2d9a06953768caad684a66cb957f1 /src | |
parent | ef114b76c1fd420339ec9f84c9538507d5fb7fbf (diff) |
play gif files in fullscreen view
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ShowFullscreenMessageActivity.java | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ShowFullscreenMessageActivity.java b/src/main/java/de/pixart/messenger/ui/ShowFullscreenMessageActivity.java index 5f1fdc3c7..1c7d41232 100644 --- a/src/main/java/de/pixart/messenger/ui/ShowFullscreenMessageActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ShowFullscreenMessageActivity.java @@ -33,6 +33,7 @@ import de.pixart.messenger.R; import de.pixart.messenger.persistance.FileBackend; import de.pixart.messenger.services.XmppConnectionService; import de.pixart.messenger.utils.ExifHelper; +import pl.droidsonroids.gif.GifDrawable; import uk.co.senab.photoview.PhotoView; import uk.co.senab.photoview.PhotoViewAttacher; @@ -142,6 +143,7 @@ public class ShowFullscreenMessageActivity extends Activity { width = options.outWidth; rotation = getRotation(Uri.parse("file://" + file.getAbsolutePath())); Log.d(Config.LOGTAG, "Image height: " + height + ", width: " + width + ", rotation: " + rotation); + mImage.setVisibility(View.VISIBLE); if (width > height) { if (rotation == 0 || rotation == 180) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { @@ -171,21 +173,29 @@ public class ShowFullscreenMessageActivity extends Activity { } } } - final PhotoViewAttacher mAttacher = new PhotoViewAttacher(mImage); - mImage.setVisibility(View.VISIBLE); - try { - Glide.with(this) - .load(file) - .asBitmap() - .into(new BitmapImageViewTarget(mImage) { - @Override - public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { - super.onResourceReady(resource, glideAnimation); - mAttacher.update(); - } - }); - } catch (Exception e) { - e.printStackTrace(); + if (getMimeType(file.toString()) != null && getMimeType(file.toString()).endsWith("/gif")) { + try { + GifDrawable gifDrawable = new GifDrawable(file); + mImage.setImageDrawable(gifDrawable); + } catch (IOException e) { + e.printStackTrace(); + } + } else { + final PhotoViewAttacher mAttacher = new PhotoViewAttacher(mImage); + try { + Glide.with(this) + .load(file) + .asBitmap() + .into(new BitmapImageViewTarget(mImage) { + @Override + public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { + super.onResourceReady(resource, glideAnimation); + mAttacher.update(); + } + }); + } catch (Exception e) { + e.printStackTrace(); + } } } |