org.telegram.ui.Components.AnimatedFileDrawable Java Examples

The following examples show how to use org.telegram.ui.Components.AnimatedFileDrawable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImageLoader.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void onPostExecute(final BitmapDrawable bitmapDrawable) {
    AndroidUtilities.runOnUIThread(() -> {
        BitmapDrawable toSet = null;
        if (bitmapDrawable instanceof AnimatedFileDrawable) {
            toSet = bitmapDrawable;
        } else if (bitmapDrawable != null) {
            toSet = memCache.get(cacheImage.key);
            if (toSet == null) {
                memCache.put(cacheImage.key, bitmapDrawable);
                toSet = bitmapDrawable;
            } else {
                Bitmap image = bitmapDrawable.getBitmap();
                image.recycle();
            }
        }
        final BitmapDrawable toSetFinal = toSet;
        imageLoadQueue.postRunnable(() -> cacheImage.setImageAndClear(toSetFinal));
    });
}
 
Example #2
Source File: ImageReceiver.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public Bitmap getBitmap() {
    AnimatedFileDrawable animation = getAnimation();
    RLottieDrawable lottieDrawable = getLottieAnimation();
    if (lottieDrawable != null && lottieDrawable.hasBitmap()) {
        return lottieDrawable.getAnimatedBitmap();
    } else if (animation != null && animation.hasBitmap()) {
        return animation.getAnimatedBitmap();
    } else if (currentMediaDrawable instanceof BitmapDrawable && !(currentMediaDrawable instanceof AnimatedFileDrawable) && !(currentMediaDrawable instanceof RLottieDrawable)) {
        return ((BitmapDrawable) currentMediaDrawable).getBitmap();
    } else if (currentImageDrawable instanceof BitmapDrawable && !(currentImageDrawable instanceof AnimatedFileDrawable) && !(currentMediaDrawable instanceof RLottieDrawable)) {
        return ((BitmapDrawable) currentImageDrawable).getBitmap();
    } else if (currentThumbDrawable instanceof BitmapDrawable && !(currentThumbDrawable instanceof AnimatedFileDrawable) && !(currentMediaDrawable instanceof RLottieDrawable)) {
        return ((BitmapDrawable) currentThumbDrawable).getBitmap();
    } else if (staticThumbDrawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) staticThumbDrawable).getBitmap();
    }
    return null;
}
 
Example #3
Source File: ImageReceiver.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public BitmapHolder getBitmapSafe() {
    Bitmap bitmap = null;
    String key = null;
    if (currentImage instanceof AnimatedFileDrawable) {
        bitmap = ((AnimatedFileDrawable) currentImage).getAnimatedBitmap();
    } else if (staticThumb instanceof AnimatedFileDrawable) {
        bitmap = ((AnimatedFileDrawable) staticThumb).getAnimatedBitmap();
    } else if (currentImage instanceof BitmapDrawable) {
        bitmap = ((BitmapDrawable) currentImage).getBitmap();
        key = currentKey;
    } else if (currentThumb instanceof BitmapDrawable) {
        bitmap = ((BitmapDrawable) currentThumb).getBitmap();
        key = currentThumbKey;
    } else if (staticThumb instanceof BitmapDrawable) {
        bitmap = ((BitmapDrawable) staticThumb).getBitmap();
    }
    if (bitmap != null) {
        return new BitmapHolder(bitmap, key);
    }
    return null;
}
 
Example #4
Source File: ImageReceiver.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public BitmapHolder getBitmapSafe() {
    Bitmap bitmap = null;
    String key = null;
    AnimatedFileDrawable animation = getAnimation();
    RLottieDrawable lottieDrawable = getLottieAnimation();
    if (lottieDrawable != null && lottieDrawable.hasBitmap()) {
        bitmap = lottieDrawable.getAnimatedBitmap();
    } else if (animation != null && animation.hasBitmap()) {
        bitmap = animation.getAnimatedBitmap();
    } else if (currentMediaDrawable instanceof BitmapDrawable && !(currentMediaDrawable instanceof AnimatedFileDrawable) && !(currentMediaDrawable instanceof RLottieDrawable)) {
        bitmap = ((BitmapDrawable) currentMediaDrawable).getBitmap();
        key = currentMediaKey;
    } else if (currentImageDrawable instanceof BitmapDrawable && !(currentImageDrawable instanceof AnimatedFileDrawable) && !(currentMediaDrawable instanceof RLottieDrawable)) {
        bitmap = ((BitmapDrawable) currentImageDrawable).getBitmap();
        key = currentImageKey;
    } else if (currentThumbDrawable instanceof BitmapDrawable && !(currentThumbDrawable instanceof AnimatedFileDrawable) && !(currentMediaDrawable instanceof RLottieDrawable)) {
        bitmap = ((BitmapDrawable) currentThumbDrawable).getBitmap();
        key = currentThumbKey;
    } else if (staticThumbDrawable instanceof BitmapDrawable) {
        bitmap = ((BitmapDrawable) staticThumbDrawable).getBitmap();
    }
    if (bitmap != null) {
        return new BitmapHolder(bitmap, key);
    }
    return null;
}
 
Example #5
Source File: ImageReceiver.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public int getBitmapHeight() {
    Drawable drawable = getDrawable();
    AnimatedFileDrawable animation = getAnimation();
    if (animation != null) {
        return imageOrientation % 360 == 0 || imageOrientation % 360 == 180 ? animation.getIntrinsicHeight() : animation.getIntrinsicWidth();
    }
    RLottieDrawable lottieDrawable = getLottieAnimation();
    if (lottieDrawable != null) {
        return lottieDrawable.getIntrinsicHeight();
    }
    Bitmap bitmap = getBitmap();
    if (bitmap == null) {
        if (staticThumbDrawable != null) {
            return staticThumbDrawable.getIntrinsicHeight();
        }
        return 1;
    }
    return imageOrientation % 360 == 0 || imageOrientation % 360 == 180 ? bitmap.getHeight() : bitmap.getWidth();
}
 
Example #6
Source File: ImageReceiver.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public int getBitmapWidth() {
    Drawable drawable = getDrawable();
    AnimatedFileDrawable animation = getAnimation();
    if (animation != null) {
        return imageOrientation % 360 == 0 || imageOrientation % 360 == 180 ? animation.getIntrinsicWidth() : animation.getIntrinsicHeight();
    }
    RLottieDrawable lottieDrawable = getLottieAnimation();
    if (lottieDrawable != null) {
        return lottieDrawable.getIntrinsicWidth();
    }
    Bitmap bitmap = getBitmap();
    if (bitmap == null) {
        if (staticThumbDrawable != null) {
            return staticThumbDrawable.getIntrinsicWidth();
        }
        return 1;
    }
    return imageOrientation % 360 == 0 || imageOrientation % 360 == 180 ? bitmap.getWidth() : bitmap.getHeight();
}
 
Example #7
Source File: ImageReceiver.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public BitmapHolder getBitmapSafe() {
    Bitmap bitmap = null;
    String key = null;
    AnimatedFileDrawable animation = getAnimation();
    RLottieDrawable lottieDrawable = getLottieAnimation();
    if (lottieDrawable != null && lottieDrawable.hasBitmap()) {
        bitmap = lottieDrawable.getAnimatedBitmap();
    } else if (animation != null && animation.hasBitmap()) {
        bitmap = animation.getAnimatedBitmap();
    } else if (currentMediaDrawable instanceof BitmapDrawable && !(currentMediaDrawable instanceof AnimatedFileDrawable) && !(currentMediaDrawable instanceof RLottieDrawable)) {
        bitmap = ((BitmapDrawable) currentMediaDrawable).getBitmap();
        key = currentMediaKey;
    } else if (currentImageDrawable instanceof BitmapDrawable && !(currentImageDrawable instanceof AnimatedFileDrawable) && !(currentMediaDrawable instanceof RLottieDrawable)) {
        bitmap = ((BitmapDrawable) currentImageDrawable).getBitmap();
        key = currentImageKey;
    } else if (currentThumbDrawable instanceof BitmapDrawable && !(currentThumbDrawable instanceof AnimatedFileDrawable) && !(currentMediaDrawable instanceof RLottieDrawable)) {
        bitmap = ((BitmapDrawable) currentThumbDrawable).getBitmap();
        key = currentThumbKey;
    } else if (staticThumbDrawable instanceof BitmapDrawable) {
        bitmap = ((BitmapDrawable) staticThumbDrawable).getBitmap();
    }
    if (bitmap != null) {
        return new BitmapHolder(bitmap, key);
    }
    return null;
}
 
Example #8
Source File: ImageReceiver.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public Bitmap getBitmap() {
    AnimatedFileDrawable animation = getAnimation();
    RLottieDrawable lottieDrawable = getLottieAnimation();
    if (lottieDrawable != null && lottieDrawable.hasBitmap()) {
        return lottieDrawable.getAnimatedBitmap();
    } else if (animation != null && animation.hasBitmap()) {
        return animation.getAnimatedBitmap();
    } else if (currentMediaDrawable instanceof BitmapDrawable && !(currentMediaDrawable instanceof AnimatedFileDrawable) && !(currentMediaDrawable instanceof RLottieDrawable)) {
        return ((BitmapDrawable) currentMediaDrawable).getBitmap();
    } else if (currentImageDrawable instanceof BitmapDrawable && !(currentImageDrawable instanceof AnimatedFileDrawable) && !(currentMediaDrawable instanceof RLottieDrawable)) {
        return ((BitmapDrawable) currentImageDrawable).getBitmap();
    } else if (currentThumbDrawable instanceof BitmapDrawable && !(currentThumbDrawable instanceof AnimatedFileDrawable) && !(currentMediaDrawable instanceof RLottieDrawable)) {
        return ((BitmapDrawable) currentThumbDrawable).getBitmap();
    } else if (staticThumbDrawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) staticThumbDrawable).getBitmap();
    }
    return null;
}
 
Example #9
Source File: ImageReceiver.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public int getBitmapWidth() {
    Drawable drawable = getDrawable();
    AnimatedFileDrawable animation = getAnimation();
    if (animation != null) {
        return imageOrientation % 360 == 0 || imageOrientation % 360 == 180 ? animation.getIntrinsicWidth() : animation.getIntrinsicHeight();
    }
    RLottieDrawable lottieDrawable = getLottieAnimation();
    if (lottieDrawable != null) {
        return lottieDrawable.getIntrinsicWidth();
    }
    Bitmap bitmap = getBitmap();
    if (bitmap == null) {
        if (staticThumbDrawable != null) {
            return staticThumbDrawable.getIntrinsicWidth();
        }
        return 1;
    }
    return imageOrientation % 360 == 0 || imageOrientation % 360 == 180 ? bitmap.getWidth() : bitmap.getHeight();
}
 
Example #10
Source File: ImageReceiver.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public int getBitmapHeight() {
    Drawable drawable = getDrawable();
    AnimatedFileDrawable animation = getAnimation();
    if (animation != null) {
        return imageOrientation % 360 == 0 || imageOrientation % 360 == 180 ? animation.getIntrinsicHeight() : animation.getIntrinsicWidth();
    }
    RLottieDrawable lottieDrawable = getLottieAnimation();
    if (lottieDrawable != null) {
        return lottieDrawable.getIntrinsicHeight();
    }
    Bitmap bitmap = getBitmap();
    if (bitmap == null) {
        if (staticThumbDrawable != null) {
            return staticThumbDrawable.getIntrinsicHeight();
        }
        return 1;
    }
    return imageOrientation % 360 == 0 || imageOrientation % 360 == 180 ? bitmap.getHeight() : bitmap.getWidth();
}
 
Example #11
Source File: ImageLoader.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void onPostExecute(final BitmapDrawable bitmapDrawable) {
    AndroidUtilities.runOnUIThread(() -> {
        BitmapDrawable toSet = null;
        if (bitmapDrawable instanceof AnimatedFileDrawable) {
            toSet = bitmapDrawable;
        } else if (bitmapDrawable != null) {
            toSet = memCache.get(cacheImage.key);
            if (toSet == null) {
                memCache.put(cacheImage.key, bitmapDrawable);
                toSet = bitmapDrawable;
            } else {
                Bitmap image = bitmapDrawable.getBitmap();
                image.recycle();
            }
        }
        final BitmapDrawable toSetFinal = toSet;
        imageLoadQueue.postRunnable(() -> cacheImage.setImageAndClear(toSetFinal));
    });
}
 
Example #12
Source File: ImageReceiver.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public BitmapHolder getBitmapSafe() {
    Bitmap bitmap = null;
    String key = null;
    if (currentImage instanceof AnimatedFileDrawable) {
        bitmap = ((AnimatedFileDrawable) currentImage).getAnimatedBitmap();
    } else if (staticThumb instanceof AnimatedFileDrawable) {
        bitmap = ((AnimatedFileDrawable) staticThumb).getAnimatedBitmap();
    } else if (currentImage instanceof BitmapDrawable) {
        bitmap = ((BitmapDrawable) currentImage).getBitmap();
        key = currentKey;
    } else if (currentThumb instanceof BitmapDrawable) {
        bitmap = ((BitmapDrawable) currentThumb).getBitmap();
        key = currentThumbKey;
    } else if (staticThumb instanceof BitmapDrawable) {
        bitmap = ((BitmapDrawable) staticThumb).getBitmap();
    }
    if (bitmap != null) {
        return new BitmapHolder(bitmap, key);
    }
    return null;
}
 
Example #13
Source File: ImageLoader.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void onPostExecute(final Drawable drawable) {
    AndroidUtilities.runOnUIThread(() -> {
        Drawable toSet = null;
        String decrementKey = null;
        if (drawable instanceof RLottieDrawable) {
            RLottieDrawable lottieDrawable = (RLottieDrawable) drawable;
            toSet = lottieMemCache.get(cacheImage.key);
            if (toSet == null) {
                lottieMemCache.put(cacheImage.key, lottieDrawable);
                toSet = lottieDrawable;
            } else {
                lottieDrawable.recycle();
            }
            if (toSet != null) {
                incrementUseCount(cacheImage.key);
                decrementKey = cacheImage.key;
            }
        } else if (drawable instanceof AnimatedFileDrawable) {
            toSet = drawable;
        } else if (drawable instanceof BitmapDrawable) {
            BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
            toSet = memCache.get(cacheImage.key);
            if (toSet == null) {
                memCache.put(cacheImage.key, bitmapDrawable);
                toSet = bitmapDrawable;
            } else {
                Bitmap image = bitmapDrawable.getBitmap();
                image.recycle();
            }
            if (toSet != null) {
                incrementUseCount(cacheImage.key);
                decrementKey = cacheImage.key;
            }
        }
        final Drawable toSetFinal = toSet;
        final String decrementKetFinal = decrementKey;
        imageLoadQueue.postRunnable(() -> cacheImage.setImageAndClear(toSetFinal, decrementKetFinal));
    });
}
 
Example #14
Source File: ImageReceiver.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void updateDrawableRadius(Drawable drawable) {
    if (hasRoundRadius() && drawable instanceof BitmapDrawable) {
        if (drawable instanceof RLottieDrawable) {

        } else if (drawable instanceof AnimatedFileDrawable) {
            AnimatedFileDrawable animatedFileDrawable = (AnimatedFileDrawable) drawable;
            animatedFileDrawable.setRoundRadius(roundRadius);
        } else {
            setDrawableShader(drawable, new BitmapShader(((BitmapDrawable) drawable).getBitmap(), Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
        }
    } else {
        setDrawableShader(drawable, null);
    }
}
 
Example #15
Source File: ImageReceiver.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void setParentView(View view) {
    parentView = view;
    AnimatedFileDrawable animation = getAnimation();
    if (animation != null) {
        animation.setParentView(parentView);
    }
}
 
Example #16
Source File: ImageReceiver.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void startAnimation() {
    AnimatedFileDrawable animation = getAnimation();
    if (animation != null) {
        animation.setUseSharedQueue(useSharedAnimationQueue);
        animation.start();
    }
}
 
Example #17
Source File: ImageReceiver.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public AnimatedFileDrawable getAnimation() {
    AnimatedFileDrawable animatedFileDrawable;
    if (currentMediaDrawable instanceof AnimatedFileDrawable) {
        return (AnimatedFileDrawable) currentMediaDrawable;
    } else if (currentImageDrawable instanceof AnimatedFileDrawable) {
        return (AnimatedFileDrawable) currentImageDrawable;
    } else if (currentThumbDrawable instanceof AnimatedFileDrawable) {
        return (AnimatedFileDrawable) currentThumbDrawable;
    } else if (staticThumbDrawable instanceof AnimatedFileDrawable) {
        return (AnimatedFileDrawable) staticThumbDrawable;
    }
    return null;
}
 
Example #18
Source File: ImageReceiver.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void setMediaStartEndTime(long startTime, long endTime) {
    this.startTime = startTime;
    this.endTime = endTime;

    if (currentMediaDrawable instanceof AnimatedFileDrawable) {
        ((AnimatedFileDrawable) currentMediaDrawable).setStartEndTime(startTime, endTime);
    }
}
 
Example #19
Source File: ImageLoader.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void onPostExecute(final Drawable drawable) {
    AndroidUtilities.runOnUIThread(() -> {
        Drawable toSet = null;
        String decrementKey = null;
        if (drawable instanceof RLottieDrawable) {
            RLottieDrawable lottieDrawable = (RLottieDrawable) drawable;
            toSet = lottieMemCache.get(cacheImage.key);
            if (toSet == null) {
                lottieMemCache.put(cacheImage.key, lottieDrawable);
                toSet = lottieDrawable;
            } else {
                lottieDrawable.recycle();
            }
            if (toSet != null) {
                incrementUseCount(cacheImage.key);
                decrementKey = cacheImage.key;
            }
        } else if (drawable instanceof AnimatedFileDrawable) {
            toSet = drawable;
        } else if (drawable instanceof BitmapDrawable) {
            BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
            toSet = memCache.get(cacheImage.key);
            if (toSet == null) {
                memCache.put(cacheImage.key, bitmapDrawable);
                toSet = bitmapDrawable;
            } else {
                Bitmap image = bitmapDrawable.getBitmap();
                image.recycle();
            }
            if (toSet != null) {
                incrementUseCount(cacheImage.key);
                decrementKey = cacheImage.key;
            }
        }
        final Drawable toSetFinal = toSet;
        final String decrementKetFinal = decrementKey;
        imageLoadQueue.postRunnable(() -> cacheImage.setImageAndClear(toSetFinal, decrementKetFinal));
    });
}
 
Example #20
Source File: ImageReceiver.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void updateDrawableRadius(Drawable drawable) {
    if (hasRoundRadius() && drawable instanceof BitmapDrawable) {
        if (drawable instanceof RLottieDrawable) {

        } else if (drawable instanceof AnimatedFileDrawable) {
            AnimatedFileDrawable animatedFileDrawable = (AnimatedFileDrawable) drawable;
            animatedFileDrawable.setRoundRadius(roundRadius);
        } else {
            setDrawableShader(drawable, new BitmapShader(((BitmapDrawable) drawable).getBitmap(), Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
        }
    } else {
        setDrawableShader(drawable, null);
    }
}
 
Example #21
Source File: ImageReceiver.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void setParentView(View view) {
    parentView = view;
    AnimatedFileDrawable animation = getAnimation();
    if (animation != null) {
        animation.setParentView(parentView);
    }
}
 
Example #22
Source File: ImageReceiver.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void startAnimation() {
    AnimatedFileDrawable animation = getAnimation();
    if (animation != null) {
        animation.setUseSharedQueue(useSharedAnimationQueue);
        animation.start();
    }
}
 
Example #23
Source File: ImageReceiver.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public AnimatedFileDrawable getAnimation() {
    AnimatedFileDrawable animatedFileDrawable;
    if (currentMediaDrawable instanceof AnimatedFileDrawable) {
        return (AnimatedFileDrawable) currentMediaDrawable;
    } else if (currentImageDrawable instanceof AnimatedFileDrawable) {
        return (AnimatedFileDrawable) currentImageDrawable;
    } else if (currentThumbDrawable instanceof AnimatedFileDrawable) {
        return (AnimatedFileDrawable) currentThumbDrawable;
    } else if (staticThumbDrawable instanceof AnimatedFileDrawable) {
        return (AnimatedFileDrawable) staticThumbDrawable;
    }
    return null;
}
 
Example #24
Source File: ImageReceiver.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void setMediaStartEndTime(long startTime, long endTime) {
    this.startTime = startTime;
    this.endTime = endTime;

    if (currentMediaDrawable instanceof AnimatedFileDrawable) {
        ((AnimatedFileDrawable) currentMediaDrawable).setStartEndTime(startTime, endTime);
    }
}
 
Example #25
Source File: ImageReceiver.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public int getAnimatedOrientation() {
    if (currentImage instanceof AnimatedFileDrawable) {
        return ((AnimatedFileDrawable) currentImage).getOrientation();
    } else if (staticThumb instanceof AnimatedFileDrawable) {
        return ((AnimatedFileDrawable) staticThumb).getOrientation();
    }
    return 0;
}
 
Example #26
Source File: ImageReceiver.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public int getAnimatedOrientation() {
    if (currentImage instanceof AnimatedFileDrawable) {
        return ((AnimatedFileDrawable) currentImage).getOrientation();
    } else if (staticThumb instanceof AnimatedFileDrawable) {
        return ((AnimatedFileDrawable) staticThumb).getOrientation();
    }
    return 0;
}
 
Example #27
Source File: ImageReceiver.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public void setParentView(View view) {
    parentView = view;
    if (currentImage instanceof AnimatedFileDrawable) {
        AnimatedFileDrawable fileDrawable = (AnimatedFileDrawable) currentImage;
        fileDrawable.setParentView(parentView);
    }
}
 
Example #28
Source File: ImageReceiver.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public int getBitmapHeight() {
    if (currentImage instanceof AnimatedFileDrawable) {
        return orientation % 360 == 0 || orientation % 360 == 180 ? currentImage.getIntrinsicHeight() : currentImage.getIntrinsicWidth();
    } else if (staticThumb instanceof AnimatedFileDrawable) {
        return orientation % 360 == 0 || orientation % 360 == 180 ? staticThumb.getIntrinsicHeight() : staticThumb.getIntrinsicWidth();
    }
    Bitmap bitmap = getBitmap();
    if (bitmap == null) {
        if (staticThumb != null) {
            return staticThumb.getIntrinsicHeight();
        }
        return 1;
    }
    return orientation % 360 == 0 || orientation % 360 == 180 ? bitmap.getHeight() : bitmap.getWidth();
}
 
Example #29
Source File: ImageReceiver.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public int getBitmapWidth() {
    if (currentImage instanceof AnimatedFileDrawable) {
        return orientation % 360 == 0 || orientation % 360 == 180 ? currentImage.getIntrinsicWidth() : currentImage.getIntrinsicHeight();
    } else if (staticThumb instanceof AnimatedFileDrawable) {
        return orientation % 360 == 0 || orientation % 360 == 180 ? staticThumb.getIntrinsicWidth() : staticThumb.getIntrinsicHeight();
    }
    Bitmap bitmap = getBitmap();
    if (bitmap == null) {
        if (staticThumb != null) {
            return staticThumb.getIntrinsicWidth();
        }
        return 1;
    }
    return orientation % 360 == 0 || orientation % 360 == 180 ? bitmap.getWidth() : bitmap.getHeight();
}
 
Example #30
Source File: ImageReceiver.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public Bitmap getBitmap() {
    if (currentImage instanceof AnimatedFileDrawable) {
        return ((AnimatedFileDrawable) currentImage).getAnimatedBitmap();
    } else if (staticThumb instanceof AnimatedFileDrawable) {
        return ((AnimatedFileDrawable) staticThumb).getAnimatedBitmap();
    } else if (currentImage instanceof BitmapDrawable) {
        return ((BitmapDrawable) currentImage).getBitmap();
    } else if (currentThumb instanceof BitmapDrawable) {
        return ((BitmapDrawable) currentThumb).getBitmap();
    } else if (staticThumb instanceof BitmapDrawable) {
        return ((BitmapDrawable) staticThumb).getBitmap();
    }
    return null;
}