Kate Mobile v109.1版本的 MD5 值为:fcd76ded5f363ecbfac46035a4ed2a23

以下内容为反编译后的 AttachmentsHelper.java 源代码,内容仅作参考


package com.perm.kate;

import android.app.Activity;
import android.content.Intent;
import android.media.AudioManager;
import android.os.Build;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.util.Log;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsoluteLayout;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.SeekBar;
import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
import com.airbnb.lottie.LottieComposition;
import com.airbnb.lottie.LottieCompositionFactory;
import com.airbnb.lottie.LottieDrawable;
import com.airbnb.lottie.LottieResult;
import com.perm.kate.AudioClickHelper;
import com.perm.kate.Player;
import com.perm.kate.api.Album;
import com.perm.kate.api.Attachment;
import com.perm.kate.api.Audio;
import com.perm.kate.api.AudioMessage;
import com.perm.kate.api.Document;
import com.perm.kate.api.Geo;
import com.perm.kate.api.Gift;
import com.perm.kate.api.Group;
import com.perm.kate.api.Link;
import com.perm.kate.api.Message;
import com.perm.kate.api.Page;
import com.perm.kate.api.Photo;
import com.perm.kate.api.Sticker;
import com.perm.kate.api.User;
import com.perm.kate.api.Video;
import com.perm.kate.api.VkPoll;
import com.perm.kate.api.WallMessage;
import com.perm.kate.theme.ThemeColorsHelper;
import com.perm.utils.AdEvents;
import com.perm.utils.GroupCache;
import com.perm.utils.LeakDetector;
import com.perm.utils.ProxyManager;
import com.perm.utils.SeekBarHelper;
import com.perm.utils.SmileHelper;
import com.perm.utils.UserAgent;
import com.perm.utils.UserCache;
import com.perm.utils.Utils;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FilterInputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.zip.GZIPInputStream;
public abstract class AttachmentsHelper {
    private static final int hor_margin = Helper.getDIP(1.0d);
    private static final int vert_margin = Helper.getDIP(1.0d);
    private static Audio voice;
    private static Player voicePlayer;
    BaseActivity activity;
    final View.OnClickListener albumClickListener;
    AudioClickHelper audioHelper;
    final LinkedList audioPool;
    final ArrayList audioViews = new ArrayList();
    public int available_width;
    final boolean big_photos;
    final LinkedList docPool;
    final View.OnClickListener documentClickListener;
    final View.OnClickListener documentWithPreviewClickListener;
    private final View.OnLongClickListener documentWithPreviewLongClickListener;
    final View.OnClickListener forwardedMessageClickListener;
    final View.OnClickListener geoClickListener;
    final View.OnClickListener giftClickListener;
    final GroupCache groupCache;
    final Handler handler;
    final int left_pane_offset;
    final View.OnClickListener linkClickListener;
    public boolean linkMargins;
    private final HashMap linkPreviews;
    ArrayList messages_all;
    private boolean mosaic_enabled;
    final View.OnClickListener notesClickListener;
    final View.OnClickListener photoClickListener;
    final LinkedList photoPool;
    final Player.PlayerCallback playerCallback;
    final Player.PlayerCallback playerCallbackVoice;
    final View.OnClickListener pollClickListener;
    private SeekBar.OnSeekBarChangeListener seekBarChangeListener;
    private boolean show_transcript;
    final int source;
    final Runnable task;
    final UserCache userCache;
    private final View.OnClickListener videoPlayClick;
    final LinkedList videoPool;
    final View.OnClickListener wallCommentClickListener;
    final View.OnClickListener wallMessageClickListener;

    public class AnonymousClass2 implements View.OnClickListener {
        final Activity val$activity;
        final ImageView val$imageView;
        final Sticker val$row;

        AnonymousClass2(Sticker sticker, Activity activity, ImageView imageView) {
            this.val$row = sticker;
            this.val$activity = activity;
            this.val$imageView = imageView;
        }

        @Override
        public void onClick(View view) {
            new Thread() {
                @Override
                public void run() {
                    try {
                        String str = AnonymousClass2.this.val$row.animation_url;
                        if (TextUtils.isEmpty(str)) {
                            str = "https://vk.com/sticker/3-" + AnonymousClass2.this.val$row.id + ".json";
                        }
                        if (!ThemeColorsHelper.isLightTheme()) {
                            str = str.replace(".json", "b.json");
                        }
                        ((BaseActivity) AnonymousClass2.this.val$activity).showProgressBar(true);
                        String serverResponse = AttachmentsHelper.getServerResponse(str);
                        ((BaseActivity) AnonymousClass2.this.val$activity).showProgressBar(false);
                        if (TextUtils.isEmpty(serverResponse)) {
                            return;
                        }
                        LottieResult fromJsonStringSync = LottieCompositionFactory.fromJsonStringSync(serverResponse, str);
                        Throwable exception = fromJsonStringSync.getException();
                        if (exception != null) {
                            Helper.reportError(exception, str);
                            exception.printStackTrace();
                        }
                        final LottieComposition lottieComposition = (LottieComposition) fromJsonStringSync.getValue();
                        if (lottieComposition == null) {
                            return;
                        }
                        AnonymousClass2.this.val$activity.runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                try {
                                    LottieDrawable lottieDrawable = new LottieDrawable();
                                    lottieDrawable.setComposition(lottieComposition);
                                    AnonymousClass2.this.val$imageView.setImageDrawable(lottieDrawable);
                                    lottieDrawable.setRepeatCount(3);
                                    lottieDrawable.playAnimation();
                                } catch (Throwable th) {
                                    th.printStackTrace();
                                    Helper.reportError(th);
                                }
                            }
                        });
                    } catch (Throwable th) {
                        th.printStackTrace();
                        Helper.reportError(th);
                    }
                }
            }.start();
        }
    }

    public static class AudioClickHelper extends com.perm.kate.AudioClickHelper {
        public AudioClickHelper(BaseActivity baseActivity, AudioClickHelper.AudioClickHelperCallback audioClickHelperCallback) {
            super(baseActivity, audioClickHelperCallback);
        }
    }

    public class AudioClickListener implements View.OnClickListener {
        final String ad_data;
        final ArrayList audios;
        final String post_ids;
        final String track_code;

        public AudioClickListener(ArrayList arrayList, String str, String str2, String str3) {
            this.audios = arrayList;
            this.post_ids = str;
            this.ad_data = str2;
            this.track_code = str3;
        }

        @Override
        public void onClick(View view) {
            Audio audio = (Audio) view.getTag();
            AttachmentsHelper attachmentsHelper = AttachmentsHelper.this;
            attachmentsHelper.audioHelper.click(audio, this.audios, attachmentsHelper.source, this.post_ids, this.ad_data, this.track_code);
        }
    }

    public class AudioPlayClickListener implements View.OnClickListener {
        final String ad_data;
        final Audio audio;
        ArrayList audios;
        final String post_ids;
        final String track_code;
        final Long wall_owner_id;

        public AudioPlayClickListener(ArrayList arrayList, Audio audio, Long l, String str, String str2, String str3) {
            this.audios = arrayList;
            this.audio = audio;
            this.wall_owner_id = l;
            this.post_ids = str;
            this.ad_data = str2;
            this.track_code = str3;
        }

        @Override
        public void onClick(View view) {
            long j;
            long j2;
            Audio audio = PlaybackService.episode;
            if (audio != null) {
                j = audio.aid;
                j2 = audio.owner_id;
            } else {
                j = 0;
                j2 = 0;
            }
            Player player = PlaybackService.player;
            if (player != null && player.state == 0) {
                Audio audio2 = this.audio;
                if (j == audio2.aid && j2 == audio2.owner_id) {
                    AttachmentsHelper.this.pauseAudio();
                    return;
                }
            }
            MiniPlayer miniPlayer = (MiniPlayer) AttachmentsHelper.this.activity.findViewById(R.id.mini_player);
            if (miniPlayer != null) {
                miniPlayer.setActive(true);
            }
            Long l = this.wall_owner_id;
            if (l != null) {
                try {
                    ArrayList fetchAudiosFromWall = KApplication.db.fetchAudiosFromWall(l.longValue());
                    if (fetchAudiosFromWall.size() > 0) {
                        this.audios = fetchAudiosFromWall;
                    }
                } catch (Throwable th) {
                    th.printStackTrace();
                    Helper.reportError(th);
                }
            }
            AttachmentsHelper attachmentsHelper = AttachmentsHelper.this;
            attachmentsHelper.audioHelper.fetchAndPlayAudio(this.audio, attachmentsHelper.activity, this.audios, attachmentsHelper.source);
            if (TextUtils.isEmpty(this.ad_data)) {
                return;
            }
            AdEvents.reportAudioStart(this.post_ids, this.ad_data, this.track_code);
        }
    }

    public class VoicePlayClickListener implements View.OnClickListener {
        final Audio audio;

        public VoicePlayClickListener(Audio audio) {
            this.audio = audio;
        }

        @Override
        public void onClick(View view) {
            long j;
            long j2;
            if (AttachmentsHelper.voice != null) {
                j = AttachmentsHelper.voice.aid;
                j2 = AttachmentsHelper.voice.owner_id;
            } else {
                j = 0;
                j2 = 0;
            }
            if (AttachmentsHelper.voicePlayer != null && AttachmentsHelper.voicePlayer.state == 0) {
                Audio audio = this.audio;
                if (j == audio.aid && j2 == audio.owner_id) {
                    AttachmentsHelper.this.getVoicePlayer().pause();
                    AttachmentsHelper attachmentsHelper = AttachmentsHelper.this;
                    attachmentsHelper.handler.removeCallbacks(attachmentsHelper.task);
                    return;
                }
            }
            Player player = PlaybackService.player;
            if (player != null && player.state == 0) {
                AttachmentsHelper.this.pauseAudio();
            }
            Audio unused = AttachmentsHelper.voice = this.audio;
            if (ProxyManager.getEnabled() || AttachmentsHelper.downloadVoiceEnabled()) {
                final String str = this.audio.url;
                if (TextUtils.isEmpty(str)) {
                    return;
                }
                final File cacheFile = KApplication.getImageLoader().getCacheFile(str);
                if (cacheFile.exists()) {
                    AttachmentsHelper.this.getVoicePlayer().play(cacheFile.getAbsolutePath());
                    if (AttachmentsHelper.voiceOverSpeakerphoneEnabled()) {
                        AttachmentsHelper.this.activity.setVolumeControlStream(0);
                    }
                } else {
                    new Thread(new Runnable() {
                        @Override
                        public void run() {
                            try {
                                AttachmentsHelper.this.activity.showProgressBar(true);
                                KApplication.getImageLoader().downloadImage(str, cacheFile, null);
                                BaseActivity baseActivity = AttachmentsHelper.this.activity;
                                if (baseActivity == null) {
                                    return;
                                }
                                baseActivity.showProgressBar(false);
                                AttachmentsHelper.this.activity.runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        AttachmentsHelper.this.getVoicePlayer().play(cacheFile.getAbsolutePath());
                                        if (AttachmentsHelper.voiceOverSpeakerphoneEnabled()) {
                                            AttachmentsHelper.this.activity.setVolumeControlStream(0);
                                        }
                                    }
                                });
                            } catch (Throwable th) {
                                th.printStackTrace();
                                if (!Helper.isNoiseException(th)) {
                                    Helper.reportError(th);
                                }
                                BaseActivity baseActivity2 = AttachmentsHelper.this.activity;
                                if (baseActivity2 != null) {
                                    baseActivity2.showProgressBar(false);
                                }
                            }
                        }
                    }).start();
                }
            } else {
                AttachmentsHelper.this.getVoicePlayer().play(this.audio.url);
                if (AttachmentsHelper.voiceOverSpeakerphoneEnabled()) {
                    AttachmentsHelper.this.activity.setVolumeControlStream(0);
                }
            }
            AttachmentsHelper attachmentsHelper2 = AttachmentsHelper.this;
            attachmentsHelper2.handler.removeCallbacks(attachmentsHelper2.task);
            AttachmentsHelper attachmentsHelper3 = AttachmentsHelper.this;
            attachmentsHelper3.handler.postDelayed(attachmentsHelper3.task, 1000L);
        }
    }

    public AttachmentsHelper(BaseActivity baseActivity, boolean z, int i, boolean z2, int i2, int i3, int i4) {
        Handler handler = new Handler();
        this.handler = handler;
        this.userCache = new UserCache();
        this.groupCache = new GroupCache();
        this.mosaic_enabled = true;
        this.show_transcript = true;
        this.linkMargins = true;
        this.linkPreviews = new HashMap();
        this.videoPool = new LinkedList();
        this.docPool = new LinkedList();
        this.photoPool = new LinkedList();
        this.videoPlayClick = new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Video video = (Video) view.getTag();
                VideoLogic.fetchAndPlay(video.vid, video.owner_id, video.access_key, AttachmentsHelper.this.activity);
                String str = (String) view.getTag(R.id.accounts);
                String str2 = (String) view.getTag(R.id.action_audio);
                String str3 = (String) view.getTag(R.id.action_faves);
                if (TextUtils.isEmpty(str2)) {
                    return;
                }
                AdEvents.reportVideoStart(str, str2, str3);
            }
        };
        this.pollClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                boolean booleanValue = ((Boolean) view.getTag(R.id.action_all)).booleanValue();
                Intent intent = new Intent();
                intent.setClass(AttachmentsHelper.this.activity, PollActivity.class);
                intent.putExtra("com.perm.kate.poll_id", (Long) view.getTag(R.id.albums));
                intent.putExtra("com.perm.kate.owner_id", (Long) view.getTag(R.id.accounts));
                intent.putExtra("com.perm.kate.is_board", booleanValue);
                AttachmentsHelper.this.activity.startActivity(intent);
            }
        };
        this.linkClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String str = (String) view.getTag();
                Helper.openUrl(str, AttachmentsHelper.this.activity);
                String str2 = (String) view.getTag(R.id.accounts);
                String str3 = (String) view.getTag(R.id.action_audio);
                String str4 = (String) view.getTag(R.id.action_faves);
                if (TextUtils.isEmpty(str3)) {
                    return;
                }
                if (AttachmentsHelper.this.isSnippet(str)) {
                    AdEvents.reportSnippetClick(str2, str3, str4, str);
                } else {
                    AdEvents.reportAttachedLinkClick(str2, str3, str4, str);
                }
            }
        };
        this.geoClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                try {
                    Geo geo = (Geo) view.getTag();
                    Helper.openMap(geo.lat, geo.lon, AttachmentsHelper.this.activity);
                } catch (Throwable th) {
                    th.printStackTrace();
                    Helper.reportError(th, null);
                }
            }
        };
        this.albumClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Album album = (Album) view.getTag();
                Helper.ShowAlbum(Long.toString(album.owner_id), album.aid, AttachmentsHelper.this.activity);
            }
        };
        this.documentClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                try {
                    Document document = (Document) view.getTag();
                    new DocClickHelper(AttachmentsHelper.this.activity, null).createContextMenu(document.id, document.owner_id, document.url, document.title, document.ext, false, document.access_key, document.thumb);
                } catch (Throwable th) {
                    th.printStackTrace();
                    Helper.reportError(th, null);
                }
            }
        };
        this.documentWithPreviewClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                try {
                    Document document = (Document) view.getTag();
                    new DocClickHelper(AttachmentsHelper.this.activity, null).click(document.url, document.title, document.ext, document.id, document.owner_id, document.access_key, document.thumb);
                } catch (Throwable th) {
                    th.printStackTrace();
                    Helper.reportError(th, null);
                }
            }
        };
        this.documentWithPreviewLongClickListener = new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                try {
                    Document document = (Document) view.getTag();
                    new DocClickHelper(AttachmentsHelper.this.activity, null).createContextMenu(document.id, document.owner_id, document.url, document.title, document.ext, false, document.access_key, document.thumb);
                    return true;
                } catch (Throwable th) {
                    th.printStackTrace();
                    Helper.reportError(th, null);
                    return true;
                }
            }
        };
        this.giftClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                try {
                    String str = ((Gift) view.getTag()).thumb_256;
                    Helper.openPhoto(str, AttachmentsHelper.this.activity, str);
                } catch (Throwable th) {
                    th.printStackTrace();
                    Helper.reportError(th, null);
                }
            }
        };
        this.wallMessageClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                try {
                    Intent intent = new Intent(AttachmentsHelper.this.activity, WallMessageActivity.class);
                    WallMessage wallMessage = ((Attachment) view.getTag()).wallMessage;
                    if (wallMessage != null) {
                        intent.putExtra("post", wallMessage);
                        intent.putExtra("cache_post", false);
                    }
                    AttachmentsHelper.this.activity.startActivity(intent);
                } catch (Throwable th) {
                    th.printStackTrace();
                    Helper.reportError(th, null);
                }
            }
        };
        this.wallCommentClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                try {
                    Attachment attachment = (Attachment) view.getTag();
                    Intent intent = new Intent(AttachmentsHelper.this.activity, WebActivity.class);
                    intent.putExtra("com.perm.kate.title", AttachmentsHelper.this.activity.getString(R.string.text_comment));
                    intent.putExtra("com.perm.kate.url", "http://vk.com/wall" + attachment.comment.post.to_id + "_" + attachment.comment.post.id + "?reply=" + attachment.comment.cid);
                    AttachmentsHelper.this.activity.startActivity(intent);
                } catch (Throwable th) {
                    th.printStackTrace();
                    Helper.reportError(th, null);
                }
            }
        };
        this.forwardedMessageClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                try {
                    Intent intent = new Intent(AttachmentsHelper.this.activity, ForwardedMessagesActivity.class);
                    intent.putExtra("messages", AttachmentsHelper.this.attachmenttsToMessages((ArrayList) view.getTag()));
                    AttachmentsHelper.this.activity.startActivity(intent);
                } catch (Throwable th) {
                    th.printStackTrace();
                    Helper.reportError(th, null);
                }
            }
        };
        this.notesClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                AttachmentsHelper.noteClick(view, AttachmentsHelper.this.activity);
            }
        };
        this.photoClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                AttachmentsHelper.photoClick(view, AttachmentsHelper.this.activity);
            }
        };
        this.audioPool = new LinkedList();
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                try {
                    AttachmentsHelper.this.displayAudioPlayersStates();
                } finally {
                    AttachmentsHelper attachmentsHelper = AttachmentsHelper.this;
                    attachmentsHelper.handler.postDelayed(attachmentsHelper.task, 1000L);
                }
            }
        };
        this.task = runnable;
        Player.PlayerCallback playerCallback = new Player.PlayerCallback() {
            @Override
            public void onCompletion() {
                AttachmentsHelper.this.displayAudioPlayersStates();
                Log.i("Kate.AttachmentsHelper", "onCompletion");
            }

            @Override
            public void onError() {
                AttachmentsHelper.this.displayAudioPlayersStates();
                Log.i("Kate.AttachmentsHelper", "onError");
            }

            @Override
            public void onNextEpisode() {
                AttachmentsHelper.this.displayAudioPlayersStates();
            }

            @Override
            public void onPrepared() {
                AttachmentsHelper.this.displayAudioPlayersStates();
                Log.i("Kate.AttachmentsHelper", "onPrepared");
            }

            @Override
            public void onStartBuffering() {
                AttachmentsHelper.this.displayAudioPlayersStates();
            }

            @Override
            public void onStateChanged() {
                AttachmentsHelper.this.displayAudioPlayersStates();
            }
        };
        this.playerCallback = playerCallback;
        Player.PlayerCallback playerCallback2 = new Player.PlayerCallback() {
            @Override
            public void onCompletion() {
                AttachmentsHelper.this.displayAudioPlayersStates();
                Log.i("Kate.AttachmentsHelper", "onCompletion");
                AttachmentsHelper attachmentsHelper = AttachmentsHelper.this;
                if (attachmentsHelper.activity == null) {
                    return;
                }
                AttachmentsHelper.this.playVoice(attachmentsHelper.getNextVoice());
            }

            @Override
            public void onError() {
                AttachmentsHelper.this.displayAudioPlayersStates();
                Log.i("Kate.AttachmentsHelper", "onError");
            }

            @Override
            public void onNextEpisode() {
                AttachmentsHelper.this.displayAudioPlayersStates();
            }

            @Override
            public void onPrepared() {
                AttachmentsHelper.this.displayAudioPlayersStates();
                Log.i("Kate.AttachmentsHelper", "onPrepared");
            }

            @Override
            public void onStartBuffering() {
                AttachmentsHelper.this.displayAudioPlayersStates();
            }

            @Override
            public void onStateChanged() {
                AttachmentsHelper.this.displayAudioPlayersStates();
            }
        };
        this.playerCallbackVoice = playerCallback2;
        this.seekBarChangeListener = new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int i5, boolean z3) {
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                long j;
                long j2;
                if (!AttachmentsHelper.downloadVoiceEnabled() && !AttachmentsHelper.useExoForVoice()) {
                    new AlertDialog.Builder(AttachmentsHelper.this.activity).setMessage(R.string.scroll_voice_message).create().show();
                    return;
                }
                Audio audio = (Audio) seekBar.getTag();
                int progress = seekBar.getProgress();
                if (AttachmentsHelper.voice != null) {
                    j = AttachmentsHelper.voice.aid;
                    j2 = AttachmentsHelper.voice.owner_id;
                } else {
                    j = 0;
                    j2 = 0;
                }
                if (AttachmentsHelper.voicePlayer != null && AttachmentsHelper.voicePlayer.state == 0 && j == audio.aid && j2 == audio.owner_id) {
                    AttachmentsHelper.voicePlayer.seek(progress);
                }
            }
        };
        this.activity = baseActivity;
        LeakDetector.getInstance().monitorObject(this);
        this.audioHelper = new AudioClickHelper(this.activity, null);
        PlaybackService.addCallback(playerCallback);
        this.big_photos = z;
        this.left_pane_offset = i;
        this.mosaic_enabled = isMosaicEnabled();
        this.show_transcript = isTranscriptEnabled();
        calculateBigPhotoSize(baseActivity, z2, i2, i3);
        this.source = i4;
        Player player = voicePlayer;
        if (player != null) {
            player.callbacks.add(playerCallback2);
            if (voicePlayer.state == 0) {
                handler.postDelayed(runnable, 1000L);
            }
        }
    }

    public static void ShowNoteActivity(String str, String str2, Activity activity) {
        Intent intent = new Intent();
        intent.setClass(activity, NoteActivity.class);
        intent.putExtra("com.perm.kate.uid", str);
        intent.putExtra("com.perm.kate.nid", str2);
        activity.startActivity(intent);
    }

    public ArrayList attachmenttsToMessages(ArrayList arrayList) {
        ArrayList arrayList2 = new ArrayList();
        Iterator it = arrayList.iterator();
        while (it.hasNext()) {
            Attachment attachment = (Attachment) it.next();
            Message message = attachment.message;
            if (message == null) {
                NullPointerException nullPointerException = new NullPointerException();
                Helper.reportError(nullPointerException, "size=" + arrayList.size() + ",type=" + attachment.type);
            } else {
                arrayList2.add(message);
                attachment.message.read_state = true;
            }
        }
        return arrayList2;
    }

    private void calculateBigPhotoSize(BaseActivity baseActivity, boolean z, int i, int i2) {
        Display defaultDisplay = baseActivity.getWindowManager().getDefaultDisplay();
        Log.i("Kate.AttachmentsHelper", "width=" + defaultDisplay.getWidth() + " height=" + defaultDisplay.getHeight());
        int min = Math.min(defaultDisplay.getWidth(), defaultDisplay.getHeight());
        this.available_width = min;
        int dip = min - Helper.getDIP((double) i2);
        this.available_width = dip;
        if (z) {
            if (KApplication.isTablet) {
                this.available_width = dip - Helper.getDIP(70.0d);
            } else {
                this.available_width = dip - Helper.getDIP(45.0d);
            }
        }
        int dip2 = this.available_width - Helper.getDIP(this.left_pane_offset);
        this.available_width = dip2;
        this.available_width = dip2 - Helper.getDIP(i);
    }

    public static ArrayList calculateMosaic(ArrayList arrayList, boolean z, int i, boolean z2, float f) {
        int[] iArr;
        float maxPhotoScale = getMaxPhotoScale(f);
        ArrayList arrayList2 = new ArrayList();
        arrayList2.add(new PhotoRow());
        int i2 = 0;
        while (true) {
            if (i2 >= arrayList.size()) {
                break;
            }
            PhotoPlace photoPlace = (PhotoPlace) arrayList.get(i2);
            PhotoRow photoRow = (PhotoRow) arrayList2.get(arrayList2.size() - 1);
            int i3 = arrayList2.size() == 1 ? 2 : 3;
            if (arrayList.size() == 3 && arrayList2.size() == 1 && (photoPlace.type != 0 || !isVertical(photoPlace.photo))) {
                i3 = 1;
            }
            if (photoRow.photos.size() == 2 && photoPlace.type == 1) {
                i3 = 2;
            }
            int i4 = photoPlace.type;
            if (i4 == 0) {
                Photo photo = photoPlace.photo;
                int i5 = photo.width;
                int i6 = photo.height;
                float ratio = getRatio(i5, i6);
                photoPlace.ratio = ratio;
                iArr = getPreviewSize(z, ratio, i5, i6);
            } else {
                iArr = i4 == 1 ? new int[]{320, 240} : PhotoViewerActrivity.isGraffiti(photoPlace.doc.title) ? new int[]{130, 130} : new int[]{400, 300};
            }
            photoPlace.width = iArr[0];
            photoPlace.height = iArr[1];
            if (z2 ? photoRow.photos.size() >= i3 && ((float) photoRow.getWidth()) * maxPhotoScale >= ((float) i) && i2 != arrayList.size() - 1 : true) {
                photoRow = new PhotoRow();
                arrayList2.add(photoRow);
            }
            photoRow.photos.add(photoPlace);
            i2++;
        }
        int i7 = 0;
        int i8 = 0;
        for (int i9 = 0; i9 < arrayList2.size(); i9++) {
            PhotoRow photoRow2 = (PhotoRow) arrayList2.get(i9);
            Iterator it = photoRow2.photos.iterator();
            int i10 = 700;
            while (it.hasNext()) {
                int i11 = ((PhotoPlace) it.next()).height;
                if (i11 < i10) {
                    i10 = i11;
                }
            }
            Iterator it2 = photoRow2.photos.iterator();
            while (it2.hasNext()) {
                PhotoPlace photoPlace2 = (PhotoPlace) it2.next();
                float f2 = photoPlace2.height / i10;
                photoPlace2.height = i10;
                photoPlace2.width = Math.round(photoPlace2.width / f2);
            }
            Iterator it3 = photoRow2.photos.iterator();
            int i12 = 0;
            while (it3.hasNext()) {
                i12 += ((PhotoPlace) it3.next()).width;
            }
            float size = (i - (hor_margin * (photoRow2.photos.size() - 1))) / i12;
            if (size >= maxPhotoScale) {
                size = maxPhotoScale;
            }
            Iterator it4 = photoRow2.photos.iterator();
            while (it4.hasNext()) {
                PhotoPlace photoPlace3 = (PhotoPlace) it4.next();
                photoPlace3.width = (int) Math.ceil(photoPlace3.width * size);
                photoPlace3.height = (int) Math.ceil(photoPlace3.height * size);
            }
            int i13 = 0;
            int i14 = 0;
            for (int i15 = 0; i15 < photoRow2.photos.size(); i15++) {
                PhotoPlace photoPlace4 = (PhotoPlace) photoRow2.photos.get(i15);
                int i16 = i13 + i14;
                photoPlace4.x = i16;
                if (i15 != 0) {
                    photoPlace4.x = i16 + hor_margin;
                }
                i13 = photoPlace4.x;
                i14 = photoPlace4.width;
                int i17 = i7 + i8;
                photoPlace4.y = i17;
                if (i9 != 0) {
                    photoPlace4.y = i17 + vert_margin;
                }
            }
            if (photoRow2.photos.size() > 0) {
                i7 = ((PhotoPlace) photoRow2.photos.get(0)).y;
                i8 = ((PhotoPlace) photoRow2.photos.get(0)).height;
            }
        }
        return arrayList2;
    }

    private boolean cantExpand(ArrayList arrayList) {
        try {
            if (arrayList.size() > 10) {
                return true;
            }
            Iterator it = arrayList.iterator();
            while (it.hasNext()) {
                if (((Attachment) it.next()).message == null) {
                    return true;
                }
            }
            return false;
        } catch (Throwable unused) {
            return true;
        }
    }

    public void displayAudioPlayersStates() {
        long j;
        long j2;
        BaseActivity baseActivity = this.activity;
        if (baseActivity == null || baseActivity.isFinishing()) {
            return;
        }
        Audio audio = PlaybackService.episode;
        if (audio != null) {
            j = audio.aid;
            j2 = audio.owner_id;
        } else {
            j = 0;
            j2 = 0;
        }
        Iterator it = this.audioViews.iterator();
        while (it.hasNext()) {
            displayAudioStatus((ViewGroup) it.next(), j, j2);
        }
    }

    public static boolean downloadVoiceEnabled() {
        return PreferenceManager.getDefaultSharedPreferences(KApplication.current).getBoolean("download_voice", false);
    }

    public static int[] getImageViewSizeGift(int i, float f) {
        double maxPhotoScale = getMaxPhotoScale(f);
        double d = i;
        double d2 = 256;
        Double.isNaN(d);
        Double.isNaN(d2);
        double d3 = d / d2;
        if (d3 < maxPhotoScale) {
            maxPhotoScale = d3;
        }
        Double.isNaN(d2);
        int i2 = (int) (d2 * maxPhotoScale);
        return new int[]{i2, i2};
    }

    private static float getMaxPhotoScale(float f) {
        if (f >= 3.0f) {
            return f * 1.15f;
        }
        if (f >= 2.0f) {
            return 2.3f;
        }
        return ((double) f) >= 1.3d ? 1.5f : 1.0f;
    }

    public Audio getNextVoice() {
        ArrayList arrayList = this.messages_all;
        if (arrayList == null) {
            return null;
        }
        Iterator it = arrayList.iterator();
        boolean z = false;
        while (true) {
            if (!it.hasNext()) {
                break;
            }
            Message message = (Message) it.next();
            if (z) {
                Iterator<Attachment> it2 = message.attachments.iterator();
                while (it2.hasNext()) {
                    Attachment next = it2.next();
                    if (next.type.equals("audio")) {
                        Audio audio = next.audio;
                        if (audio.aid < 0) {
                            return audio;
                        }
                    }
                }
            } else {
                Iterator<Attachment> it3 = message.attachments.iterator();
                while (it3.hasNext()) {
                    Audio audio2 = it3.next().audio;
                    if (audio2 != null && audio2.aid == voice.aid) {
                        z = true;
                    }
                }
            }
        }
        return null;
    }

    static int[] getPreviewSize(boolean z, float f, int i, int i2) {
        int i3 = z ? 604 : 130;
        int i4 = (int) (z ? 604.0f / f : 130.0f / f);
        if (i2 > i) {
            int i5 = z ? 604 : 130;
            i3 = (int) (z ? f * 604.0f : f * 130.0f);
            i4 = i5;
        }
        if (i == 0 || i2 == 0 || i >= i3 || i2 >= i4) {
            i = i3;
            i2 = i4;
        }
        return new int[]{i, i2};
    }

    private static float getRatio(int i, int i2) {
        if (i == 0 || i2 == 0) {
            return 1.5f;
        }
        return i / i2;
    }

    public static int getResIdForNoPhoto4() {
        switch (BaseActivity.Theme) {
            case R.style.KateCoffee:
                return R.drawable.d_no_photo4_coffee;
            case R.style.KateDark:
                return R.drawable.d_no_photo4_dark;
            case R.style.KateGreen:
                return R.drawable.d_no_photo4_green;
            case R.style.KateHolo:
                return R.drawable.d_no_photo4_holo;
            case R.style.KateLightGreen:
                return R.drawable.d_no_photo4_green;
            case R.style.KateMaterialDark:
                return R.drawable.d_no_photo4_material_dark;
            case R.style.KateMetal:
                return R.drawable.d_no_photo4_metal;
            case R.style.KateOrange:
                return R.drawable.d_no_photo4_orange;
            case R.style.KatePink:
                return R.drawable.d_no_photo4_pink;
            case R.style.KateTransparent:
                return R.drawable.item_transparent_bg;
            default:
                return R.drawable.d_no_photo4;
        }
    }

    public static String getServerResponse(String str) {
        HttpURLConnection httpURLConnection;
        try {
            httpURLConnection = ProxyManager.getConnection(new URL(str));
            try {
                httpURLConnection.setConnectTimeout(5000);
                httpURLConnection.setReadTimeout(5000);
                httpURLConnection.setRequestProperty("Accept-Encoding", "gzip");
                UserAgent.set(httpURLConnection);
                if (httpURLConnection.getResponseCode() == -1) {
                    httpURLConnection.disconnect();
                    return null;
                }
                FilterInputStream bufferedInputStream = new BufferedInputStream(httpURLConnection.getInputStream());
                if ("gzip".equalsIgnoreCase(httpURLConnection.getHeaderField("Content-Encoding"))) {
                    bufferedInputStream = new GZIPInputStream(bufferedInputStream);
                }
                String convertStreamToString = Utils.convertStreamToString(bufferedInputStream);
                httpURLConnection.disconnect();
                return convertStreamToString;
            } catch (Throwable th) {
                th = th;
                try {
                    th.printStackTrace();
                    return null;
                } finally {
                    if (httpURLConnection != null) {
                        httpURLConnection.disconnect();
                    }
                }
            }
        } catch (Throwable th2) {
            th = th2;
            httpURLConnection = null;
        }
    }

    public Player getVoicePlayer() {
        if (voicePlayer == null) {
            Player playerExo = useExoForVoice() ? new PlayerExo(this.playerCallbackVoice) : new Player(this.playerCallbackVoice);
            voicePlayer = playerExo;
            playerExo.setVoiceSpeed(getVoiceSpeed());
            voicePlayer.isVoice = true;
            if (voiceOverSpeakerphoneEnabled()) {
                AudioManager audioManager = (AudioManager) this.activity.getSystemService("audio");
                if (!audioManager.isWiredHeadsetOn() && !audioManager.isBluetoothA2dpOn()) {
                    voicePlayer.setAudioStreamType(0);
                }
            }
        }
        return voicePlayer;
    }

    public static float getVoiceSpeed() {
        return PreferenceManager.getDefaultSharedPreferences(KApplication.current).getFloat("voice_speed", 1.0f);
    }

    public boolean isSnippet(String str) {
        for (Map.Entry entry : this.linkPreviews.entrySet()) {
            if (str.equals(((Link) entry.getValue()).url)) {
                return true;
            }
        }
        return false;
    }

    private static boolean isVertical(Photo photo) {
        return photo.height > photo.width;
    }

    public static void noteClick(View view, Activity activity) {
        String str = (String) view.getTag();
        if (str != null) {
            String[] split = str.split(",");
            if (split.length == 2) {
                ShowNoteActivity(split[1], split[0], activity);
            }
        }
    }

    public void pauseAudio() {
        Intent intent = new Intent(this.activity, PlaybackService.class);
        intent.setAction("pause");
        this.activity.startService(intent);
        Log.i("Kate.AttachmentsHelper", "pauseAudio");
    }

    public static void photoClick(View view, Activity activity) {
        ArrayList arrayList = (ArrayList) view.getTag(R.id.action_comments);
        long parseLong = Long.parseLong(KApplication.session.getMid());
        for (int i = 0; i < arrayList.size(); i++) {
            Photo fetchPhoto = KApplication.db.fetchPhoto(((Photo) arrayList.get(i)).pid, Long.parseLong(((Photo) arrayList.get(i)).owner_id), parseLong);
            if (fetchPhoto != null) {
                fetchPhoto.access_key = ((Photo) arrayList.get(i)).access_key;
                arrayList.set(i, fetchPhoto);
            }
        }
        int intValue = ((Integer) view.getTag(R.id.action_all)).intValue();
        Intent intent = new Intent();
        intent.setClass(activity, PhotoViewerActrivity.class);
        intent.putExtra("com.perm.kate.position", intValue);
        intent.putExtra("com.perm.kate.photos", arrayList);
        activity.startActivity(intent);
        String str = (String) view.getTag(R.id.accounts);
        String str2 = (String) view.getTag(R.id.action_audio);
        String str3 = (String) view.getTag(R.id.action_faves);
        if (TextUtils.isEmpty(str2)) {
            return;
        }
        AdEvents.reportPhotoOpen(str, str2, str3);
    }

    public void playVoice(Audio audio) {
        if (audio == null) {
            return;
        }
        voice = audio;
        getVoicePlayer().play(audio.url);
    }

    private static void saveVoiceSpeed(float f) {
        PreferenceManager.getDefaultSharedPreferences(KApplication.current).edit().putFloat("voice_speed", f).apply();
    }

    static boolean useExoForVoice() {
        return Build.VERSION.SDK_INT <= 28 && AudioMessage.isOggSupported();
    }

    public static boolean voiceOverSpeakerphoneEnabled() {
        return PreferenceManager.getDefaultSharedPreferences(KApplication.current).getBoolean("voice_speakerphone", false) && !useExoForVoice();
    }

    public void destroy() {
        PlaybackService.removeCallback(this.playerCallback);
        this.activity = null;
        this.audioHelper.destroy();
        this.audioHelper = null;
        Player player = voicePlayer;
        if (player != null) {
            player.callbacks.remove(this.playerCallbackVoice);
        }
        this.handler.removeCallbacks(this.task);
        this.videoPool.clear();
        this.docPool.clear();
        this.photoPool.clear();
        this.audioPool.clear();
        this.seekBarChangeListener = null;
    }

    public void displayAlbum(TextView textView, Album album, Activity activity) {
        textView.setText(((Object) activity.getText(R.string.label_menu_photoalbum)) + ": " + album.title);
        textView.setTag(album);
        textView.setOnClickListener(this.albumClickListener);
        textView.setVisibility(0);
    }

    public void displayAttachments(ArrayList arrayList, NewsItemTag newsItemTag, ViewHolder viewHolder, String str, String str2, ArrayList arrayList2, Activity activity, ViewGroup viewGroup, ViewGroup viewGroup2, ViewGroup viewGroup3, ViewGroup viewGroup4, ViewGroup viewGroup5) {
        displayAttachments(arrayList, newsItemTag, viewHolder, str, str2, arrayList2, activity, viewGroup, viewGroup2, viewGroup3, viewGroup4, viewGroup5, null, null, null, null, null);
    }

    public void displayAttachments(ArrayList arrayList, NewsItemTag newsItemTag, ViewHolder viewHolder, String str, String str2, ArrayList arrayList2, Activity activity, ViewGroup viewGroup, ViewGroup viewGroup2, ViewGroup viewGroup3, ViewGroup viewGroup4, ViewGroup viewGroup5, Long l, String str3, String str4, String str5, ArrayList arrayList3) {
        Object obj;
        Attachment attachment;
        String str6;
        Video video;
        Audio audio;
        this.messages_all = arrayList3;
        ArrayList arrayList4 = new ArrayList();
        if (arrayList != null) {
            arrayList4.addAll(arrayList);
        }
        ArrayList arrayList5 = new ArrayList();
        ArrayList arrayList6 = new ArrayList();
        ArrayList arrayList7 = new ArrayList();
        ArrayList arrayList8 = new ArrayList();
        ArrayList arrayList9 = new ArrayList();
        ArrayList arrayList10 = new ArrayList();
        ArrayList arrayList11 = new ArrayList();
        String str7 = "link";
        if (arrayList2 != null) {
            Iterator it = arrayList2.iterator();
            while (it.hasNext()) {
                Attachment attachment2 = (Attachment) it.next();
                Iterator it2 = it;
                if (attachment2.type.equals("photo") || attachment2.type.equals("posted_photo")) {
                    str6 = str7;
                    arrayList4.add(attachment2.photo);
                } else if (attachment2.type.equals(str7) && attachment2.link.photo != null && arrayList4.isEmpty()) {
                    arrayList4.add(attachment2.link.photo);
                    HashMap hashMap = this.linkPreviews;
                    Link link = attachment2.link;
                    str6 = str7;
                    hashMap.put(link.photo, link);
                    arrayList6.add(attachment2);
                } else {
                    str6 = str7;
                    if (attachment2.type.equals("message")) {
                        arrayList5.add(attachment2);
                    } else if (attachment2.type.equals("audio") && (audio = attachment2.audio) != null) {
                        arrayList7.add(audio);
                    } else if (attachment2.type.equals("video") && (video = attachment2.video) != null) {
                        arrayList8.add(video);
                    } else if (attachment2.type.equals("doc") && !TextUtils.isEmpty(attachment2.document.thumb)) {
                        arrayList9.add(attachment2.document);
                    } else if (attachment2.type.equals("gift")) {
                        arrayList10.add(attachment2.gift);
                    } else if (attachment2.type.equals("sticker")) {
                        arrayList11.add(attachment2.sticker);
                    } else if (!attachment2.type.equals("friend")) {
                        arrayList6.add(attachment2);
                    }
                }
                it = it2;
                str7 = str6;
            }
        }
        String str8 = str7;
        if (viewGroup5 != null) {
            if (cantExpand(arrayList5)) {
                arrayList6.add(arrayList5);
                viewGroup5.setVisibility(8);
            } else {
                displayMessagesExpanded(viewGroup5, arrayList5, activity);
                viewGroup5.setVisibility(0);
            }
        }
        String str9 = str8;
        int i = 0;
        Object obj2 = "doc";
        displayPhotos(viewGroup, arrayList4, arrayList8, arrayList9, activity, str3, str4, str5);
        displayAudios(viewGroup3, arrayList7, activity, l, str3, str4, str5);
        displayGifts(viewGroup4, arrayList10, activity);
        if (arrayList11.size() > 0) {
            displayStickers(viewGroup, arrayList11, activity);
        }
        int size = arrayList6.size() - viewGroup2.getChildCount();
        for (int i2 = 0; i2 < size; i2++) {
            viewGroup2.addView(LayoutInflater.from(activity).inflate(R.layout.link_item, viewGroup2, false));
        }
        int i3 = 0;
        while (i3 < viewGroup2.getChildCount()) {
            TextView textView = (TextView) viewGroup2.getChildAt(i3);
            if (i3 < arrayList6.size()) {
                textView.setVisibility(i);
                Object obj3 = arrayList6.get(i3);
                if (obj3 instanceof Attachment) {
                    Attachment attachment3 = (Attachment) obj3;
                    String str10 = str9;
                    if (attachment3.type.equals(str10)) {
                        Link link2 = attachment3.link;
                        str9 = str10;
                        attachment = attachment3;
                        displayLink(textView, link2.url, link2.title, activity, str3, str4, str5);
                    } else {
                        str9 = str10;
                        attachment = attachment3;
                    }
                    if (attachment.type.equals("note")) {
                        displayNote(textView, Long.valueOf(attachment.note.nid), Long.toString(attachment.note.owner_id), attachment.note.title, activity);
                    }
                    if (attachment.type.equals("poll")) {
                        displayPollAttachment(textView, attachment.poll, activity);
                    }
                    if (attachment.type.equals("geo")) {
                        displayGeo(textView, attachment.geo, activity);
                    }
                    obj = obj2;
                    if (attachment.type.equals(obj)) {
                        displayDocument(textView, attachment.document, activity);
                    }
                    if (attachment.type.equals("wall")) {
                        displayWallMessage(textView, attachment, activity);
                    }
                    if (attachment.type.equals("page")) {
                        displayPage(textView, attachment.page, activity, str3, str4, str5);
                    }
                    if (attachment.type.equals("album")) {
                        displayAlbum(textView, attachment.album, activity);
                    }
                    if (attachment.type.equals("wall_reply")) {
                        displayWallComment(textView, attachment, activity);
                    }
                } else {
                    obj = obj2;
                }
                if (obj3 instanceof ArrayList) {
                    displayForwardMessages(textView, (ArrayList) obj3, activity);
                }
            } else {
                obj = obj2;
                textView.setVisibility(8);
            }
            i3++;
            obj2 = obj;
            i = 0;
        }
        if (this.linkMargins) {
            return;
        }
        ((LinearLayout.LayoutParams) viewGroup2.getLayoutParams()).setMargins(0, 0, 0, 0);
        viewGroup2.requestLayout();
    }

    void displayAudioStatus(ViewGroup viewGroup, long j, long j2) {
        long j3;
        long j4;
        Player player;
        int i;
        Player player2;
        int i2;
        Player player3;
        int i3;
        Audio audio = (Audio) viewGroup.getTag();
        if (audio == null) {
            return;
        }
        ImageView imageView = (ImageView) viewGroup.findViewById(R.id.button);
        Audio audio2 = voice;
        if (audio2 != null) {
            j3 = audio2.aid;
            j4 = audio2.owner_id;
        } else {
            j3 = 0;
            j4 = 0;
        }
        long j5 = audio.aid;
        if ((j5 == j && audio.owner_id == j2 && (player3 = PlaybackService.player) != null && ((i3 = player3.state) == 0 || i3 == 3)) || (j5 == j3 && audio.owner_id == j4 && (player = voicePlayer) != null && ((i = player.state) == 0 || i == 3))) {
            imageView.setImageResource(AudioListAdapter.getAudioIconByTheme(false));
            imageView.setContentDescription(this.activity.getText(R.string.pause));
        } else {
            imageView.setImageResource(AudioListAdapter.getAudioIconByTheme(true));
            imageView.setContentDescription(this.activity.getText(R.string.play_video));
        }
        ProgressBar progressBar = (ProgressBar) viewGroup.findViewById(R.id.SeekBar01);
        if (audio.aid != j3 || audio.owner_id != j4 || (player2 = voicePlayer) == null || ((i2 = player2.state) != 0 && i2 != 3 && i2 != 1)) {
            progressBar.setProgress(0);
            return;
        }
        progressBar.setMax((int) voice.duration);
        progressBar.setProgress(voicePlayer.getCurrentPosition());
    }

    public void displayAudios(ViewGroup viewGroup, ArrayList arrayList, Activity activity, Long l, String str, String str2, String str3) {
        View.OnClickListener onClickListener;
        long j;
        long j2;
        int i;
        long j3;
        View.OnClickListener onClickListener2;
        Audio audio;
        int i2;
        ViewGroup viewGroup2;
        int i3 = 0;
        int i4 = 0;
        while (true) {
            onClickListener = null;
            if (i4 >= viewGroup.getChildCount()) {
                break;
            }
            View childAt = viewGroup.getChildAt(i4);
            this.audioPool.add(childAt);
            childAt.setTag(null);
            i4++;
        }
        viewGroup.removeAllViews();
        int size = arrayList.size() - viewGroup.getChildCount();
        for (int i5 = 0; i5 < size; i5++) {
            View view = (View) this.audioPool.poll();
            if (view == null) {
                view = LayoutInflater.from(activity).inflate(R.layout.audio_attachment_item, viewGroup, false);
                this.audioViews.add((ViewGroup) view);
            }
            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-2, -2);
            int dip = Helper.getDIP(3.0d);
            layoutParams.setMargins(dip, dip, dip, dip);
            viewGroup.addView(view, layoutParams);
        }
        Audio audio2 = PlaybackService.episode;
        long j4 = 0;
        if (audio2 != null) {
            j = audio2.aid;
            j2 = audio2.owner_id;
        } else {
            j = 0;
            j2 = 0;
        }
        int i6 = 0;
        while (i6 < viewGroup.getChildCount()) {
            ViewGroup viewGroup3 = (ViewGroup) viewGroup.getChildAt(i6);
            if (i6 < arrayList.size()) {
                Audio audio3 = (Audio) arrayList.get(i6);
                viewGroup3.setVisibility(i3);
                viewGroup3.setAlpha(TextUtils.isEmpty(audio3.url) ? 0.2f : 1.0f);
                viewGroup3.setTag(audio3);
                if (audio3.aid > j4) {
                    audio = audio3;
                    i2 = 8;
                    viewGroup3.setOnClickListener(new AudioClickListener(arrayList, str, str2, str3));
                } else {
                    audio = audio3;
                    i2 = 8;
                    viewGroup3.setOnClickListener(onClickListener);
                }
                if (audio.aid < 0) {
                    audio.title = activity.getString(R.string.record_audio);
                    audio.artist = activity.getString(R.string.record_audio);
                }
                TextView textView = (TextView) viewGroup3.findViewById(R.id.artist);
                textView.setText(audio.isPodcast() ? activity.getString(R.string.podcast) + ": " + audio.artist : audio.artist);
                textView.setVisibility(audio.aid > 0 ? 0 : 8);
                ((TextView) viewGroup3.findViewById(R.id.title)).setText(audio.title + " (" + Helper.getDurationTextBySeconds(audio.duration) + ")");
                TextView textView2 = (TextView) viewGroup3.findViewById(R.id.text);
                if (TextUtils.isEmpty(audio.transcript) || !this.show_transcript) {
                    textView2.setVisibility(i2);
                } else {
                    textView2.setText(audio.transcript);
                    textView2.setVisibility(0);
                }
                ImageView imageView = (ImageView) viewGroup3.findViewById(R.id.button);
                if (audio.aid > 0) {
                    viewGroup2 = viewGroup3;
                    i = i6;
                    imageView.setOnClickListener(new AudioPlayClickListener(arrayList, audio, l, str, str2, str3));
                } else {
                    viewGroup2 = viewGroup3;
                    i = i6;
                    imageView.setOnClickListener(new VoicePlayClickListener(audio));
                }
                SeekBar seekBar = (SeekBar) viewGroup2.findViewById(R.id.SeekBar01);
                j3 = 0;
                if (audio.aid < 0) {
                    i3 = 0;
                    seekBar.setVisibility(0);
                    seekBar.setOnSeekBarChangeListener(this.seekBarChangeListener);
                    seekBar.setTag(audio);
                    SeekBarHelper.setSeekBarColor(seekBar, BaseActivity.Theme);
                } else {
                    i3 = 0;
                    seekBar.setVisibility(8);
                }
                displayAudioStatus(viewGroup2, j, j2);
                onClickListener2 = null;
            } else {
                i = i6;
                j3 = j4;
                viewGroup3.setVisibility(8);
                onClickListener2 = null;
                viewGroup3.setTag(null);
            }
            onClickListener = onClickListener2;
            j4 = j3;
            i6 = i + 1;
        }
    }

    public void displayDocument(TextView textView, Document document, Activity activity) {
        String documentDisplaySize = Helper.getDocumentDisplaySize(document.size);
        textView.setText(activity.getString(R.string.document) + ": " + document.title + " (" + documentDisplaySize + ")");
        textView.setTag(document);
        textView.setOnClickListener(this.documentClickListener);
        textView.setVisibility(0);
    }

    public void displayForwardMessages(TextView textView, ArrayList arrayList, Activity activity) {
        textView.setText(activity.getString(R.string.forwarded_messages));
        textView.setTag(arrayList);
        textView.setOnClickListener(this.forwardedMessageClickListener);
        textView.setVisibility(0);
    }

    public void displayGeo(TextView textView, Geo geo, Activity activity) {
        textView.setText(activity.getText(R.string.place).toString());
        textView.setTag(geo);
        textView.setOnClickListener(this.geoClickListener);
        textView.setVisibility(0);
    }

    public void displayGifts(ViewGroup viewGroup, ArrayList arrayList, Activity activity) {
        int size = arrayList.size() - viewGroup.getChildCount();
        for (int i = 0; i < size; i++) {
            ImageView imageView = new ImageView(activity);
            imageView.setScaleType(ImageView.ScaleType.FIT_START);
            imageView.setContentDescription("Подарок");
            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(1, 1);
            int dip = Helper.getDIP(3.0d);
            layoutParams.setMargins(0, dip, 0, dip);
            viewGroup.addView(imageView, layoutParams);
        }
        int[] imageViewSizeGift = getImageViewSizeGift(this.available_width, Helper.getScale());
        for (int i2 = 0; i2 < viewGroup.getChildCount(); i2++) {
            ImageView imageView2 = (ImageView) viewGroup.getChildAt(i2);
            if (i2 < arrayList.size()) {
                Gift gift = (Gift) arrayList.get(i2);
                LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) imageView2.getLayoutParams();
                layoutParams2.width = imageViewSizeGift[0];
                layoutParams2.height = imageViewSizeGift[1];
                imageView2.requestLayout();
                imageView2.setVisibility(0);
                imageView2.setOnClickListener(this.giftClickListener);
                imageView2.setTag(gift);
                KApplication.getImageLoader().DisplayImage(gift.thumb_256, imageView2, true, imageViewSizeGift[0], imageViewSizeGift[1], getResIdForNoPhoto4(), true, false, false);
            } else {
                imageView2.setVisibility(8);
                imageView2.setImageBitmap(null);
            }
        }
    }

    public void displayLink(TextView textView, String str, String str2, Activity activity, String str3, String str4, String str5) {
        String str6;
        String charSequence = activity.getText(str.contains("/poll") ? R.string.poll : R.string.link).toString();
        if (str.contains("/story")) {
            charSequence = activity.getString(R.string.stories);
        }
        if (str2 == null || str2.equals("")) {
            str6 = charSequence + ": " + str;
        } else {
            str6 = charSequence + ": " + str2;
        }
        textView.setText(str6);
        textView.setTag(str);
        textView.setTag(R.id.accounts, str3);
        textView.setTag(R.id.action_audio, str4);
        textView.setTag(R.id.action_faves, str5);
        textView.setOnClickListener(this.linkClickListener);
        textView.setVisibility(0);
    }

    public void displayMessagesExpanded(ViewGroup viewGroup, ArrayList arrayList, Activity activity) {
        String str;
        String str2;
        String attachmnetsText;
        String str3;
        long nanoTime = System.nanoTime();
        viewGroup.setTag(arrayList);
        viewGroup.setOnClickListener(this.forwardedMessageClickListener);
        int size = arrayList.size() - viewGroup.getChildCount();
        for (int i = 0; i < size; i++) {
            View inflate = LayoutInflater.from(activity).inflate(R.layout.message_item_fwd, viewGroup, false);
            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-2, -2);
            int dip = Helper.getDIP(3.0d);
            layoutParams.setMargins(dip, 0, dip, 0);
            viewGroup.addView(inflate, layoutParams);
        }
        for (int i2 = 0; i2 < viewGroup.getChildCount(); i2++) {
            ViewGroup viewGroup2 = (ViewGroup) viewGroup.getChildAt(i2);
            if (i2 < arrayList.size()) {
                Message message = ((Attachment) arrayList.get(i2)).message;
                viewGroup2.setVisibility(0);
                long parseLong = message.is_out ? Long.parseLong(KApplication.session.getMid()) : message.uid;
                ImageView imageView = (ImageView) viewGroup2.findViewById(R.id.photo_fwd);
                String str4 = null;
                if (User.isVirtualUser(parseLong)) {
                    Group group = this.groupCache.get(parseLong);
                    if (group != null) {
                        str2 = group.photo_medium;
                        str4 = group.name;
                    } else {
                        str = null;
                        str2 = null;
                        KApplication.getImageLoader().DisplayImage(str2, imageView, true, 90, Helper.getAvaStubId(), true);
                        String ago = Helper.getAgo(activity, message.date);
                        TextView textView = (TextView) viewGroup2.findViewById(R.id.time);
                        if (!TextUtils.isEmpty(str)) {
                            ago = str + ", " + ago;
                        }
                        textView.setText(ago);
                        TextView textView2 = (TextView) viewGroup2.findViewById(R.id.text);
                        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(message.body);
                        SmileHelper.getSmiledText(KApplication.current, spannableStringBuilder);
                        attachmnetsText = DialogsAdapter.getAttachmnetsText(activity, message.attachments);
                        if (attachmnetsText.length() > 0) {
                            if (spannableStringBuilder.length() > 0) {
                                spannableStringBuilder.append((CharSequence) " ");
                            }
                            spannableStringBuilder.append((CharSequence) ("(" + attachmnetsText + ")"));
                        }
                        textView2.setText(spannableStringBuilder);
                    }
                } else {
                    User user = this.userCache.get(parseLong);
                    if (user != null) {
                        str4 = user.first_name + " " + user.last_name;
                        str3 = user.photo_medium_rec;
                    } else {
                        str3 = null;
                    }
                    str2 = str3;
                }
                str = str4;
                KApplication.getImageLoader().DisplayImage(str2, imageView, true, 90, Helper.getAvaStubId(), true);
                String ago2 = Helper.getAgo(activity, message.date);
                TextView textView3 = (TextView) viewGroup2.findViewById(R.id.time);
                if (!TextUtils.isEmpty(str)) {
                }
                textView3.setText(ago2);
                TextView textView22 = (TextView) viewGroup2.findViewById(R.id.text);
                SpannableStringBuilder spannableStringBuilder2 = new SpannableStringBuilder(message.body);
                SmileHelper.getSmiledText(KApplication.current, spannableStringBuilder2);
                attachmnetsText = DialogsAdapter.getAttachmnetsText(activity, message.attachments);
                if (attachmnetsText.length() > 0) {
                }
                textView22.setText(spannableStringBuilder2);
            } else {
                viewGroup2.setVisibility(8);
            }
        }
        long nanoTime2 = System.nanoTime();
        if (arrayList.size() > 0) {
            Log.i("Kate.AttachmentsHelper", "displayMessagesExpanded=" + ((nanoTime2 - nanoTime) / 1000000) + " ms");
        }
    }

    public void displayNote(TextView textView, Long l, String str, String str2, Activity activity) {
        textView.setVisibility(0);
        textView.setText(((Object) activity.getText(R.string.note)) + ": " + str2);
        textView.setTag(l + "," + str);
        textView.setOnClickListener(this.notesClickListener);
    }

    public void displayPage(TextView textView, Page page, Activity activity, String str, String str2, String str3) {
        textView.setText(activity.getString(R.string.page) + ": " + page.title);
        textView.setTag("http://vk.com/page-" + page.group_id + "_" + page.id);
        textView.setTag(R.id.accounts, str);
        textView.setTag(R.id.action_audio, str2);
        textView.setTag(R.id.action_faves, str3);
        textView.setOnClickListener(this.linkClickListener);
        textView.setVisibility(0);
    }

    public void displayPhotos(ViewGroup viewGroup, ArrayList arrayList, ArrayList arrayList2, ArrayList arrayList3, Activity activity, String str, String str2, String str3) {
        int i;
        Iterator it;
        int i2;
        ViewGroup viewGroup2 = viewGroup;
        String str4 = str;
        viewGroup2.setVisibility((arrayList.size() > 0 || arrayList2.size() > 0 || arrayList3.size() > 0) ? 0 : 8);
        int i3 = 0;
        while (true) {
            int childCount = viewGroup.getChildCount();
            i = R.id.iv_ph_tag_border;
            if (i3 >= childCount) {
                break;
            }
            View childAt = viewGroup2.getChildAt(i3);
            KApplication.getImageLoader().photosQueue.Clean(childAt);
            if ("v".equals(childAt.getTag(R.id.iv_ph_tag_border))) {
                this.videoPool.add(childAt);
            }
            if ("d".equals(childAt.getTag(R.id.iv_ph_tag_border))) {
                this.docPool.add(childAt);
            }
            if ("p".equals(childAt.getTag(R.id.iv_ph_tag_border))) {
                this.photoPool.add((ImageView) childAt);
            }
            i3++;
        }
        viewGroup.removeAllViews();
        ArrayList arrayList4 = new ArrayList();
        Iterator it2 = arrayList.iterator();
        while (it2.hasNext()) {
            arrayList4.add(new PhotoPlace((Photo) it2.next()));
        }
        Iterator it3 = arrayList2.iterator();
        while (it3.hasNext()) {
            arrayList4.add(new PhotoPlace((Video) it3.next()));
        }
        Iterator it4 = arrayList3.iterator();
        while (it4.hasNext()) {
            arrayList4.add(new PhotoPlace((Document) it4.next()));
        }
        Iterator it5 = calculateMosaic(arrayList4, this.big_photos, this.available_width, this.mosaic_enabled, Helper.getScale()).iterator();
        int i4 = 0;
        while (it5.hasNext()) {
            Iterator it6 = ((PhotoRow) it5.next()).photos.iterator();
            while (it6.hasNext()) {
                PhotoPlace photoPlace = (PhotoPlace) it6.next();
                if (photoPlace.type == 0) {
                    ImageView imageView = (ImageView) this.photoPool.poll();
                    if (imageView == null) {
                        imageView = new ImageView(activity);
                        imageView.setTag(i, "p");
                    }
                    imageView.setScaleType(ImageView.ScaleType.FIT_START);
                    StringBuilder sb = new StringBuilder();
                    it = it5;
                    sb.append((Object) KApplication.current.getText(R.string.label_photo));
                    sb.append(" ");
                    int i5 = i4 + 1;
                    sb.append(i5);
                    imageView.setContentDescription(sb.toString());
                    AbsoluteLayout.LayoutParams layoutParams = new AbsoluteLayout.LayoutParams(1, 1, 1, 1);
                    layoutParams.width = photoPlace.width;
                    layoutParams.height = photoPlace.height;
                    layoutParams.x = photoPlace.x;
                    layoutParams.y = photoPlace.y;
                    viewGroup2.addView(imageView, layoutParams);
                    imageView.setVisibility(0);
                    imageView.setTag(R.id.accounts, str4);
                    imageView.setTag(R.id.action_audio, str2);
                    imageView.setTag(R.id.action_faves, str3);
                    if (this.linkPreviews.containsKey(photoPlace.photo)) {
                        imageView.setTag(((Link) this.linkPreviews.get(photoPlace.photo)).url);
                        imageView.setOnClickListener(this.linkClickListener);
                    } else {
                        imageView.setTag(R.id.action_all, Integer.valueOf(i4));
                        imageView.setTag(R.id.action_comments, arrayList);
                        imageView.setOnClickListener(this.photoClickListener);
                    }
                    String str5 = this.big_photos ? photoPlace.photo.src_big : photoPlace.photo.src;
                    KApplication.getImageLoader().DisplayImage(str5, imageView, true, photoPlace.width, photoPlace.height, getResIdForNoPhoto4(), true, false, false);
                    i4 = i5;
                } else {
                    it = it5;
                }
                if (photoPlace.type == 1) {
                    View view = (View) this.videoPool.poll();
                    if (view == null) {
                        view = LayoutInflater.from(activity).inflate(R.layout.video_item_attachment, viewGroup2, false);
                        view.setTag(R.id.iv_ph_tag_border, "v");
                    }
                    AbsoluteLayout.LayoutParams layoutParams2 = new AbsoluteLayout.LayoutParams(1, 1, 1, 1);
                    layoutParams2.width = photoPlace.width;
                    layoutParams2.height = photoPlace.height;
                    layoutParams2.x = photoPlace.x;
                    layoutParams2.y = photoPlace.y;
                    viewGroup2.addView(view, layoutParams2);
                    Video video = photoPlace.video;
                    ImageView imageView2 = (ImageView) view.findViewById(R.id.image);
                    TextView textView = (TextView) view.findViewById(R.id.title);
                    FrameLayout.LayoutParams layoutParams3 = (FrameLayout.LayoutParams) imageView2.getLayoutParams();
                    layoutParams3.width = photoPlace.width;
                    layoutParams3.height = photoPlace.height;
                    imageView2.requestLayout();
                    ((FrameLayout.LayoutParams) textView.getLayoutParams()).width = photoPlace.width;
                    textView.requestLayout();
                    String durationTextBySeconds = Helper.getDurationTextBySeconds(video.duration);
                    if (TextUtils.isEmpty(video.platform)) {
                        i2 = i4;
                    } else {
                        StringBuilder sb2 = new StringBuilder();
                        i2 = i4;
                        sb2.append(video.platform);
                        sb2.append(" · ");
                        sb2.append(durationTextBySeconds);
                        durationTextBySeconds = sb2.toString();
                    }
                    ((TextView) view.findViewById(R.id.duration)).setText(durationTextBySeconds);
                    textView.setText(video.title);
                    KApplication.getImageLoader().DisplayImage(video.image_big, imageView2, true, photoPlace.width, photoPlace.height, R.drawable.d_solid_background_dark, true, false, false);
                    view.setTag(R.id.action_comments, str4);
                    view.setTag(R.id.action_audio, str2);
                    view.setTag(R.id.action_faves, str3);
                    view.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public final void onClick(View view2) {
                            AttachmentsHelper.this.videoClick(view2);
                        }
                    });
                    view.setTag(video);
                    view.setTag(R.id.albums, Long.valueOf(video.vid));
                    view.setTag(R.id.accounts, Long.valueOf(video.owner_id));
                    view.setTag(R.id.action_all, video.access_key);
                    View findViewById = view.findViewById(R.id.play);
                    findViewById.setOnClickListener(this.videoPlayClick);
                    findViewById.setTag(video);
                    findViewById.setTag(R.id.accounts, str4);
                    findViewById.setTag(R.id.action_audio, str2);
                    findViewById.setTag(R.id.action_faves, str3);
                } else {
                    i2 = i4;
                }
                if (photoPlace.type == 2) {
                    View view2 = (View) this.docPool.poll();
                    if (view2 == null) {
                        view2 = LayoutInflater.from(activity).inflate(R.layout.doc_preview_attachment, viewGroup2, false);
                        view2.setTag(R.id.iv_ph_tag_border, "d");
                    }
                    AbsoluteLayout.LayoutParams layoutParams4 = new AbsoluteLayout.LayoutParams(1, 1, 1, 1);
                    layoutParams4.width = photoPlace.width;
                    layoutParams4.height = photoPlace.height;
                    layoutParams4.x = photoPlace.x;
                    layoutParams4.y = photoPlace.y;
                    viewGroup2.addView(view2, layoutParams4);
                    Document document = photoPlace.doc;
                    ImageView imageView3 = (ImageView) view2.findViewById(R.id.image);
                    TextView textView2 = (TextView) view2.findViewById(R.id.title);
                    FrameLayout.LayoutParams layoutParams5 = (FrameLayout.LayoutParams) imageView3.getLayoutParams();
                    layoutParams5.width = photoPlace.width;
                    layoutParams5.height = photoPlace.height;
                    imageView3.requestLayout();
                    ((FrameLayout.LayoutParams) textView2.getLayoutParams()).width = photoPlace.width;
                    textView2.requestLayout();
                    String documentDisplaySize = Helper.getDocumentDisplaySize(document.size);
                    textView2.setText(document.title + " (" + documentDisplaySize + ")");
                    if (PhotoViewerActrivity.isGraffiti(document.title)) {
                        textView2.setVisibility(8);
                    }
                    String str6 = TextUtils.isEmpty(document.thumb_o) ? document.thumb : document.thumb_o;
                    if (PhotoViewerActrivity.isGraffiti(document.title)) {
                        str6 = document.url;
                    }
                    KApplication.getImageLoader().DisplayImage(str6, imageView3, true, photoPlace.width, photoPlace.height, getResIdForNoPhoto4(), true, false, false);
                    view2.setOnClickListener(this.documentWithPreviewClickListener);
                    view2.setOnLongClickListener(this.documentWithPreviewLongClickListener);
                    view2.setTag(document);
                }
                viewGroup2 = viewGroup;
                str4 = str;
                i4 = i2;
                it5 = it;
                i = R.id.iv_ph_tag_border;
            }
            viewGroup2 = viewGroup;
            str4 = str;
        }
    }

    public void displayPollAttachment(TextView textView, VkPoll vkPoll, Activity activity) {
        textView.setVisibility(0);
        textView.setText(((Object) activity.getText(R.string.poll)) + ": " + vkPoll.question);
        textView.setOnClickListener(this.pollClickListener);
        textView.setTag(R.id.albums, Long.valueOf(vkPoll.id));
        textView.setTag(R.id.accounts, Long.valueOf(vkPoll.owner_id));
        textView.setTag(R.id.action_all, Boolean.valueOf(vkPoll.is_board));
    }

    public void displayStickers(ViewGroup viewGroup, ArrayList arrayList, Activity activity) {
        Activity activity2 = activity;
        int i = 0;
        viewGroup.setVisibility(0);
        int size = arrayList.size() - viewGroup.getChildCount();
        for (int i2 = 0; i2 < size; i2++) {
            ImageView imageView = new ImageView(activity2);
            imageView.setScaleType(ImageView.ScaleType.FIT_START);
            imageView.setContentDescription(KApplication.current.getText(R.string.sticker));
            viewGroup.addView(imageView, new AbsoluteLayout.LayoutParams(1, 1, 1, 1));
        }
        int dip = Helper.getDIP(128.0d);
        Iterator it = arrayList.iterator();
        int i3 = 0;
        while (it.hasNext()) {
            Sticker sticker = (Sticker) it.next();
            ImageView imageView2 = (ImageView) viewGroup.getChildAt(i3);
            AbsoluteLayout.LayoutParams layoutParams = (AbsoluteLayout.LayoutParams) imageView2.getLayoutParams();
            layoutParams.width = dip;
            layoutParams.height = dip;
            layoutParams.x = i;
            layoutParams.y = i;
            imageView2.requestLayout();
            imageView2.setVisibility(i);
            imageView2.setOnClickListener(new AnonymousClass2(sticker, activity2, imageView2));
            String str = sticker.photo_64;
            int i4 = 64;
            if (dip > 64) {
                str = sticker.photo_128;
                i4 = 128;
            }
            if (dip > 128) {
                if (!TextUtils.isEmpty(sticker.photo_256)) {
                    str = sticker.photo_256;
                }
                i4 = 256;
            }
            if (TextUtils.isEmpty(str)) {
                str = "https://vk.com/sticker/1-" + sticker.id + "-" + i4;
            }
            if (!ThemeColorsHelper.isLightTheme() && str.contains("/sticker/")) {
                str = str + "b";
            }
            KApplication.getImageLoader().DisplayImage(str, imageView2, true, dip, dip, getResIdForNoPhoto4(), true, false, false);
            if (SmileHelper.isBlind()) {
                imageView2.setContentDescription(StickerHints.getStickerDescription(sticker.id));
            }
            i3++;
            activity2 = activity;
            i = 0;
        }
        while (i3 < viewGroup.getChildCount()) {
            ImageView imageView3 = (ImageView) viewGroup.getChildAt(i3);
            imageView3.setVisibility(8);
            imageView3.setImageBitmap(null);
            i3++;
        }
    }

    public void displayWallComment(TextView textView, Attachment attachment, Activity activity) {
        String replace = attachment.comment.message.replace('\n', ' ');
        if (replace.length() > 70) {
            replace = replace.substring(0, 70) + "...";
        }
        textView.setText(activity.getString(R.string.text_comment) + ": " + replace);
        textView.setTag(attachment);
        textView.setOnClickListener(this.wallCommentClickListener);
        textView.setVisibility(0);
    }

    public void displayWallMessage(TextView textView, Attachment attachment, Activity activity) {
        String str;
        ArrayList<Attachment> arrayList;
        WallMessage wallMessage = attachment.wallMessage;
        if (wallMessage != null) {
            str = Helper.removeBrokenChar(wallMessage.text).replace('\n', ' ');
            if (str.length() < 70 && (arrayList = attachment.wallMessage.attachments) != null && arrayList.size() > 0) {
                str = str + " (" + DialogsAdapter.getAttachmnetsText(activity, attachment.wallMessage.attachments) + ")";
            }
        } else {
            str = "";
        }
        if (str.length() > 70) {
            str = str.substring(0, 70) + "...";
        }
        textView.setText(activity.getString(R.string.wall_post) + ": " + str);
        textView.setTag(attachment);
        textView.setOnClickListener(this.wallMessageClickListener);
        textView.setVisibility(0);
    }

    boolean isMosaicEnabled() {
        return PreferenceManager.getDefaultSharedPreferences(KApplication.current).getBoolean("key_mosaic", true);
    }

    boolean isTranscriptEnabled() {
        return PreferenceManager.getDefaultSharedPreferences(KApplication.current).getBoolean("transcript", true);
    }

    public void setVoiceSpeed(float f) {
        saveVoiceSpeed(f);
        Player player = voicePlayer;
        if (player != null) {
            player.setVoiceSpeed(f);
        }
    }

    public void videoClick(View view) {
        VideoMenu videoMenu = new VideoMenu(this.activity, null, null);
        long longValue = ((Long) view.getTag(R.id.albums)).longValue();
        long longValue2 = ((Long) view.getTag(R.id.accounts)).longValue();
        Boolean bool = Boolean.FALSE;
        videoMenu.display(null, longValue, longValue2, (String) view.getTag(R.id.action_all), false, bool, false, bool, (Video) view.getTag(), (String) view.getTag(R.id.action_comments), (String) view.getTag(R.id.action_audio), (String) view.getTag(R.id.action_faves));
    }
}