Search in sources :

Example 1 with ImageLoader

use of org.telegram.messenger.ImageLoader in project Telegram-FOSS by Telegram-FOSS-Team.

the class ChatAvatarContainer method openProfile.

private void openProfile(boolean byAvatar) {
    if (byAvatar && (AndroidUtilities.isTablet() || AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y || !avatarImageView.getImageReceiver().hasNotThumb())) {
        byAvatar = false;
    }
    TLRPC.User user = parentFragment.getCurrentUser();
    TLRPC.Chat chat = parentFragment.getCurrentChat();
    ImageReceiver imageReceiver = avatarImageView.getImageReceiver();
    String key = imageReceiver.getImageKey();
    ImageLoader imageLoader = ImageLoader.getInstance();
    if (key != null && !imageLoader.isInMemCache(key, false)) {
        Drawable drawable = imageReceiver.getDrawable();
        if (drawable instanceof BitmapDrawable) {
            imageLoader.putImageToCache((BitmapDrawable) drawable, key, false);
        }
    }
    if (user != null) {
        Bundle args = new Bundle();
        if (UserObject.isUserSelf(user)) {
            args.putLong("dialog_id", parentFragment.getDialogId());
            int[] media = new int[MediaDataController.MEDIA_TYPES_COUNT];
            System.arraycopy(sharedMediaPreloader.getLastMediaCount(), 0, media, 0, media.length);
            MediaActivity fragment = new MediaActivity(args, sharedMediaPreloader);
            fragment.setChatInfo(parentFragment.getCurrentChatInfo());
            parentFragment.presentFragment(fragment);
        } else {
            args.putLong("user_id", user.id);
            args.putBoolean("reportSpam", parentFragment.hasReportSpam());
            if (timeItem != null) {
                args.putLong("dialog_id", parentFragment.getDialogId());
            }
            args.putInt("actionBarColor", getThemedColor(Theme.key_actionBarDefault));
            ProfileActivity fragment = new ProfileActivity(args, sharedMediaPreloader);
            fragment.setUserInfo(parentFragment.getCurrentUserInfo());
            fragment.setPlayProfileAnimation(byAvatar ? 2 : 1);
            parentFragment.presentFragment(fragment);
        }
    } else if (chat != null) {
        Bundle args = new Bundle();
        args.putLong("chat_id", chat.id);
        ProfileActivity fragment = new ProfileActivity(args, sharedMediaPreloader);
        fragment.setChatInfo(parentFragment.getCurrentChatInfo());
        fragment.setPlayProfileAnimation(byAvatar ? 2 : 1);
        parentFragment.presentFragment(fragment);
    }
}
Also used : ImageReceiver(org.telegram.messenger.ImageReceiver) ProfileActivity(org.telegram.ui.ProfileActivity) Bundle(android.os.Bundle) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ImageLoader(org.telegram.messenger.ImageLoader) TLRPC(org.telegram.tgnet.TLRPC)

Aggregations

BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 Drawable (android.graphics.drawable.Drawable)1 Bundle (android.os.Bundle)1 ImageLoader (org.telegram.messenger.ImageLoader)1 ImageReceiver (org.telegram.messenger.ImageReceiver)1 TLRPC (org.telegram.tgnet.TLRPC)1 ProfileActivity (org.telegram.ui.ProfileActivity)1