导航菜单

页面标题

页面副标题

Telegram v11.13.0 - ChatActivity.java 源代码

正在查看: Telegram v11.13.0 应用的 ChatActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package org.telegram.ui;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.LinearGradient;
import android.graphics.Matrix;
import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.media.AudioManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcelable;
import android.os.SystemClock;
import android.telephony.TelephonyManager;
import android.text.Editable;
import android.text.Layout;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.style.CharacterStyle;
import android.text.style.ForegroundColorSpan;
import android.text.style.ImageSpan;
import android.text.style.URLSpan;
import android.util.Pair;
import android.util.Property;
import android.util.SparseArray;
import android.util.SparseIntArray;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.TextureView;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewOutlineProvider;
import android.view.ViewParent;
import android.view.ViewPropertyAnimator;
import android.view.ViewTreeObserver;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.animation.DecelerateInterpolator;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
import androidx.collection.LongSparseArray;
import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider;
import androidx.core.content.pm.ShortcutManagerCompat$;
import androidx.core.graphics.ColorUtils;
import androidx.core.view.inputmethod.InputContentInfoCompat;
import androidx.dynamicanimation.animation.DynamicAnimation;
import androidx.dynamicanimation.animation.FloatValueHolder;
import androidx.dynamicanimation.animation.SpringAnimation;
import androidx.dynamicanimation.animation.SpringForce;
import androidx.recyclerview.widget.ChatListItemAnimator;
import androidx.recyclerview.widget.GridLayoutManagerFixed;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.LinearSmoothScrollerCustom;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
import com.google.android.exoplayer2.util.Consumer;
import j$.util.Collection;
import j$.util.function.Predicate;
import j$.util.function.Supplier;
import j$.util.stream.Collectors;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.messenger.AccountInstance;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.BotInlineKeyboard;
import org.telegram.messenger.BotWebViewVibrationEffect;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.ChannelBoostsController;
import org.telegram.messenger.ChatMessageSharedResources;
import org.telegram.messenger.ChatMessagesMetadataController;
import org.telegram.messenger.ChatObject;
import org.telegram.messenger.ChatThemeController;
import org.telegram.messenger.CodeHighlighting;
import org.telegram.messenger.ContactsController;
import org.telegram.messenger.DialogObject;
import org.telegram.messenger.DocumentObject;
import org.telegram.messenger.Emoji;
import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.FilesMigrationService$FilesMigrationBottomSheet$;
import org.telegram.messenger.FlagSecureReason;
import org.telegram.messenger.HashtagSearchController;
import org.telegram.messenger.ImageLocation;
import org.telegram.messenger.ImageReceiver;
import org.telegram.messenger.LanguageDetector;
import org.telegram.messenger.LiteMode;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MediaController;
import org.telegram.messenger.MediaDataController;
import org.telegram.messenger.MessageObject;
import org.telegram.messenger.MessagePreviewParams;
import org.telegram.messenger.MessageSuggestionParams;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.MessagesStorage;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R;
import org.telegram.messenger.SendMessagesHelper;
import org.telegram.messenger.SharedConfig;
import org.telegram.messenger.SvgHelper;
import org.telegram.messenger.Timer;
import org.telegram.messenger.TopicsController;
import org.telegram.messenger.TranslateController;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.UserObject;
import org.telegram.messenger.Utilities;
import org.telegram.messenger.VideoEditedInfo;
import org.telegram.messenger.browser.Browser;
import org.telegram.messenger.support.LongSparseIntArray;
import org.telegram.messenger.utils.PhotoUtilities;
import org.telegram.messenger.utils.tlutils.AmountUtils;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.QuickAckDelegate;
import org.telegram.tgnet.RequestDelegate;
import org.telegram.tgnet.ResultCallback;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.tgnet.WriteToSocketDelegate;
import org.telegram.tgnet.tl.TL_account;
import org.telegram.tgnet.tl.TL_bots;
import org.telegram.tgnet.tl.TL_phone;
import org.telegram.tgnet.tl.TL_stories;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.ActionBarMenuItem;
import org.telegram.ui.ActionBar.ActionBarMenuSubItem;
import org.telegram.ui.ActionBar.ActionBarPopupWindow;
import org.telegram.ui.ActionBar.AdjustPanLayoutHelper;
import org.telegram.ui.ActionBar.AlertDialog;
import org.telegram.ui.ActionBar.BackDrawable;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.ActionBar.BottomSheet;
import org.telegram.ui.ActionBar.EmojiThemes;
import org.telegram.ui.ActionBar.INavigationLayout;
import org.telegram.ui.ActionBar.SimpleTextView;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.ActionBar.ThemeDescription;
import org.telegram.ui.Adapters.FiltersView;
import org.telegram.ui.Adapters.MessagesSearchAdapter;
import org.telegram.ui.AvatarPreviewer;
import org.telegram.ui.Business.BusinessBotButton;
import org.telegram.ui.Business.BusinessLinksActivity;
import org.telegram.ui.Business.BusinessLinksEmptyView;
import org.telegram.ui.Business.QuickRepliesActivity;
import org.telegram.ui.Business.QuickRepliesController;
import org.telegram.ui.Business.QuickRepliesEmptyView;
import org.telegram.ui.Cells.BaseCell;
import org.telegram.ui.Cells.BotHelpCell;
import org.telegram.ui.Cells.BotSwitchCell;
import org.telegram.ui.Cells.ChatActionCell;
import org.telegram.ui.Cells.ChatLoadingCell;
import org.telegram.ui.Cells.ChatMessageCell;
import org.telegram.ui.Cells.ChatUnreadCell;
import org.telegram.ui.Cells.CheckBoxCell;
import org.telegram.ui.Cells.ContextLinkCell;
import org.telegram.ui.Cells.DialogCell;
import org.telegram.ui.Cells.MentionCell;
import org.telegram.ui.Cells.ProfileChannelCell;
import org.telegram.ui.Cells.ShareDialogCell;
import org.telegram.ui.Cells.StickerCell;
import org.telegram.ui.Cells.TextCell;
import org.telegram.ui.Cells.TextSelectionHelper;
import org.telegram.ui.Cells.UserInfoCell;
import org.telegram.ui.ChatActivity;
import org.telegram.ui.Components.AlertsCreator;
import org.telegram.ui.Components.AnimatedEmojiDrawable;
import org.telegram.ui.Components.AnimatedEmojiSpan;
import org.telegram.ui.Components.AnimatedFileDrawable;
import org.telegram.ui.Components.AnimatedTextView;
import org.telegram.ui.Components.AnimationProperties;
import org.telegram.ui.Components.AttachBotIntroTopView;
import org.telegram.ui.Components.BackButtonMenu;
import org.telegram.ui.Components.BackupImageView;
import org.telegram.ui.Components.BluredView;
import org.telegram.ui.Components.BlurredFrameLayout;
import org.telegram.ui.Components.BottomSheetWithRecyclerListView;
import org.telegram.ui.Components.Bulletin;
import org.telegram.ui.Components.BulletinFactory;
import org.telegram.ui.Components.ChatActivityEnterTopView;
import org.telegram.ui.Components.ChatActivityEnterView;
import org.telegram.ui.Components.ChatActivityInterface;
import org.telegram.ui.Components.ChatAttachAlert;
import org.telegram.ui.Components.ChatAttachAlertDocumentLayout;
import org.telegram.ui.Components.ChatAvatarContainer;
import org.telegram.ui.Components.ChatBigEmptyView;
import org.telegram.ui.Components.ChatGreetingsView;
import org.telegram.ui.Components.ChatNotificationsPopupWrapper;
import org.telegram.ui.Components.ChatSearchTabs;
import org.telegram.ui.Components.ChatThemeBottomSheet;
import org.telegram.ui.Components.ChecksHintView;
import org.telegram.ui.Components.CircularProgressDrawable;
import org.telegram.ui.Components.ClippingImageView;
import org.telegram.ui.Components.CounterView;
import org.telegram.ui.Components.CrossfadeDrawable;
import org.telegram.ui.Components.CubicBezierInterpolator;
import org.telegram.ui.Components.EditTextCaption;
import org.telegram.ui.Components.EmbedBottomSheet;
import org.telegram.ui.Components.EmojiPacksAlert;
import org.telegram.ui.Components.EmojiView;
import org.telegram.ui.Components.FireworksOverlay;
import org.telegram.ui.Components.FlickerLoadingView;
import org.telegram.ui.Components.FloatingDebug.FloatingDebugController;
import org.telegram.ui.Components.FloatingDebug.FloatingDebugProvider;
import org.telegram.ui.Components.Forum.ForumUtilities;
import org.telegram.ui.Components.FragmentContextView;
import org.telegram.ui.Components.GigagroupConvertAlert;
import org.telegram.ui.Components.HashtagActivity;
import org.telegram.ui.Components.HashtagHistoryView;
import org.telegram.ui.Components.HideViewAfterAnimation;
import org.telegram.ui.Components.HintView;
import org.telegram.ui.Components.ImageUpdater;
import org.telegram.ui.Components.ImportingAlert;
import org.telegram.ui.Components.InstantCameraView;
import org.telegram.ui.Components.InviteMembersBottomSheet;
import org.telegram.ui.Components.ItemOptions;
import org.telegram.ui.Components.JoinGroupAlert;
import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.LinkSpanDrawable;
import org.telegram.ui.Components.MediaActivity;
import org.telegram.ui.Components.MentionsContainerView;
import org.telegram.ui.Components.MessageBackgroundDrawable;
import org.telegram.ui.Components.MessagePreviewView;
import org.telegram.ui.Components.MotionBackgroundDrawable;
import org.telegram.ui.Components.NumberTextView;
import org.telegram.ui.Components.PhonebookShareAlert;
import org.telegram.ui.Components.PinnedLineView;
import org.telegram.ui.Components.PipRoundVideoView;
import org.telegram.ui.Components.PollVotesAlert;
import org.telegram.ui.Components.Premium.GiftPremiumBottomSheet$GiftTier;
import org.telegram.ui.Components.Premium.LimitReachedBottomSheet;
import org.telegram.ui.Components.Premium.PremiumFeatureBottomSheet;
import org.telegram.ui.Components.Premium.PremiumPreviewBottomSheet;
import org.telegram.ui.Components.Premium.boosts.BoostDialogs;
import org.telegram.ui.Components.Premium.boosts.GiftInfoBottomSheet;
import org.telegram.ui.Components.Premium.boosts.PremiumPreviewGiftLinkBottomSheet;
import org.telegram.ui.Components.QuoteSpan;
import org.telegram.ui.Components.RLottieDrawable;
import org.telegram.ui.Components.RLottieImageView;
import org.telegram.ui.Components.RadialProgressView;
import org.telegram.ui.Components.ReactedHeaderView;
import org.telegram.ui.Components.ReactedUsersListView;
import org.telegram.ui.Components.ReactionTabHolderView;
import org.telegram.ui.Components.Reactions.ChatSelectionReactionMenuOverlay;
import org.telegram.ui.Components.Reactions.ReactionsEffectOverlay;
import org.telegram.ui.Components.Reactions.ReactionsLayoutInBubble;
import org.telegram.ui.Components.ReactionsContainerLayout;
import org.telegram.ui.Components.RecyclerAnimationScrollHelper;
import org.telegram.ui.Components.RecyclerListView;
import org.telegram.ui.Components.ScaleStateListAnimator;
import org.telegram.ui.Components.ScrimOptions;
import org.telegram.ui.Components.SearchTagsList;
import org.telegram.ui.Components.ShareAlert;
import org.telegram.ui.Components.SharedMediaLayout;
import org.telegram.ui.Components.SizeNotifierFrameLayout;
import org.telegram.ui.Components.StickerEmptyView;
import org.telegram.ui.Components.StickersAlert;
import org.telegram.ui.Components.SuggestEmojiView;
import org.telegram.ui.Components.TextSelectionHint;
import org.telegram.ui.Components.TextStyleSpan;
import org.telegram.ui.Components.ThanosEffect;
import org.telegram.ui.Components.ThemeEditorView;
import org.telegram.ui.Components.TopicSeparator;
import org.telegram.ui.Components.TopicsTabsView;
import org.telegram.ui.Components.TranscribeButton;
import org.telegram.ui.Components.TranslateAlert2;
import org.telegram.ui.Components.TranslateButton;
import org.telegram.ui.Components.TrendingStickersAlert;
import org.telegram.ui.Components.TypefaceSpan;
import org.telegram.ui.Components.URLSpanBotCommand;
import org.telegram.ui.Components.URLSpanReplacement;
import org.telegram.ui.Components.URLSpanUserMention;
import org.telegram.ui.Components.UndoView;
import org.telegram.ui.Components.UnreadCounterTextView;
import org.telegram.ui.Components.VideoPlayer;
import org.telegram.ui.Components.ViewPagerFixed;
import org.telegram.ui.Components.quickforward.QuickShareSelectorOverlayLayout;
import org.telegram.ui.Components.voip.VoIPHelper;
import org.telegram.ui.ContactAddActivity;
import org.telegram.ui.ContentPreviewViewer;
import org.telegram.ui.CountrySelectActivity;
import org.telegram.ui.Delegates.ChatActivityMemberRequestsDelegate;
import org.telegram.ui.DialogsActivity;
import org.telegram.ui.Gifts.GiftSheet;
import org.telegram.ui.GroupCreateActivity;
import org.telegram.ui.LocationActivity;
import org.telegram.ui.PhotoAlbumPickerActivity;
import org.telegram.ui.PhotoViewer;
import org.telegram.ui.PollCreateActivity;
import org.telegram.ui.ProfileActivity;
import org.telegram.ui.ProfileBirthdayEffect;
import org.telegram.ui.Stars.MessageSuggestionOfferSheet;
import org.telegram.ui.Stars.StarReactionsOverlay;
import org.telegram.ui.Stars.StarsController;
import org.telegram.ui.Stars.StarsIntroActivity;
import org.telegram.ui.Stories.StoriesListPlaceProvider;
import org.telegram.ui.Stories.StoryViewer;
import org.telegram.ui.Stories.recorder.HintView2;
import org.telegram.ui.Stories.recorder.PreviewView;
import org.telegram.ui.Stories.recorder.StoryEntry;
import org.telegram.ui.Stories.recorder.StoryRecorder;
import org.telegram.ui.TON.TONIntroActivity;
import org.telegram.ui.bots.AffiliateProgramFragment;
import org.telegram.ui.bots.BotAdView;
import org.telegram.ui.bots.BotCommandsMenuContainer;
import org.telegram.ui.bots.BotCommandsMenuView;
import org.telegram.ui.bots.BotWebViewSheet;
import org.telegram.ui.bots.WebViewRequestProps;

public class ChatActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, DialogsActivity.DialogsActivityDelegate, LocationActivity.LocationActivityDelegate, ChatAttachAlertDocumentLayout.DocumentSelectActivityDelegate, ChatActivityInterface, FloatingDebugProvider, InstantCameraView.Delegate {
    private static int SKELETON_LIGHT_OVERLAY_ALPHA = 22;
    private static float SKELETON_SATURATION = 1.4f;
    public static Pattern privateMsgUrlPattern;
    public static Pattern publicMsgUrlPattern;
    public static boolean scrolling;
    private static ArrayList textSelectionHelpersCache;
    public static Pattern voiceChatUrlPattern;
    private Paint actionBarBackgroundPaint;
    public SearchTagsList actionBarSearchTags;
    private ArrayList actionModeViews;
    private long activityResumeTime;
    private ActionBarMenuItem.Item addContactItem;
    private TextView addToContactsButton;
    private boolean addToContactsButtonArchive;
    private TextView alertNameTextView;
    private TextView alertTextView;
    private FrameLayout alertView;
    private AnimatorSet alertViewAnimator;
    private float alertViewEnterProgress;
    private boolean allowContextBotPanel;
    private boolean allowContextBotPanelSecond;
    public boolean allowExpandPreviewByClick;
    private boolean allowStickersPanel;
    private HashMap alreadyPlayedStickers;
    boolean animateProgressViewTo;
    private ArrayList animateSendingViews;
    private final HashMap animatingDocuments;
    private ClippingImageView animatingImageView;
    public ArrayList animatingMessageObjects;
    private int appliedDraftDate;
    private boolean approved;
    private Paint aspectPaint;
    private Path aspectPath;
    private AspectRatioFrameLayout aspectRatioFrameLayout;
    private ActionBarMenu.LazyItem attachItem;
    private String attachMenuBotStartCommand;
    private String attachMenuBotToOpen;
    private ActionBarMenu.LazyItem audioCallIconItem;
    public ChatAvatarContainer avatarContainer;
    private ChatActivity backToPreviousFragment;
    private ChatBigEmptyView bigEmptyView;
    public ProfileBirthdayEffect.BirthdayEffectFetcher birthdayAssetsFetcher;
    private BusinessBotButton bizBotButton;
    private boolean bizbothint;
    private BluredView blurredView;
    public int blurredViewBottomOffset;
    public int blurredViewTopOffset;
    private TL_stories.TL_premium_boostsStatus boostsStatus;
    private BotAdView botAdView;
    private MessageObject botButtons;
    private PhotoViewer.PhotoViewerProvider botContextProvider;
    private ArrayList botContextResults;
    private LongSparseArray botInfo;
    private HintView2 botMessageHint;
    private MessageObject botReplyButtons;
    private MessageObject botSponsoredMessage;
    private String botUser;
    private int botsCount;
    private ImageView bottomGiftButton;
    private HintView2 bottomGiftHintView;
    private BlurredFrameLayout bottomMessagesActionContainer;
    private FrameLayout bottomOverlay;
    private AnimatorSet bottomOverlayAnimation;
    private BlurredFrameLayout bottomOverlayChat;
    private UnreadCounterTextView bottomOverlayChatText;
    private boolean bottomOverlayChatWaitsReply;
    private ImageView bottomOverlayImage;
    private boolean bottomOverlayLinks;
    private LinkSpanDrawable.LinksTextView bottomOverlayLinksText;
    private RadialProgressView bottomOverlayProgress;
    private TextView bottomOverlayStartButton;
    private TextView bottomOverlayText;
    private float bottomPanelTranslationY;
    private float bottomPanelTranslationYReverse;
    private ImageView bottomSuggestButton;
    private HintView2 bottomSuggestHintView;
    Bulletin.Delegate bulletinDelegate;
    public TL_account.TL_businessChatLink businessLink;
    private BusinessLinksEmptyView businessLinksEmptyView;
    private boolean[] cacheEndReached;
    private ChannelBoostsController.CanApplyBoost canApplyBoosts;
    private int canEditMessagesCount;
    private int canForwardMessagesCount;
    private int canSaveDocumentsCount;
    private int canSaveMusicCount;
    private boolean canShowPagedownButton;
    private Runnable cancelFixedPositionRunnable;
    private int cantDeleteMessagesCount;
    private int cantForwardMessagesCount;
    private int cantSaveMessagesCount;
    private ValueAnimator changeBoundAnimator;
    private ChatActivityDelegate chatActivityDelegate;
    private ChatActivityEnterTopView chatActivityEnterTopView;
    protected ChatActivityEnterView chatActivityEnterView;
    private boolean chatActivityEnterViewAnimateBeforeSending;
    private int chatActivityEnterViewAnimateFromTop;
    private ChatActivityAdapter chatAdapter;
    public ChatAttachAlert chatAttachAlert;
    private int chatEmojiViewPadding;
    private long chatEnterTime;
    protected TLRPC.ChatFull chatInfo;
    private TLRPC.ChatInvite chatInvite;
    private Runnable chatInviteRunnable;
    private long chatInviterId;
    private GridLayoutManagerFixed chatLayoutManager;
    private long chatLeaveTime;
    private ChatListItemAnimator chatListItemAnimator;
    private ThanosEffect chatListThanosEffect;
    private RecyclerListView chatListView;
    private boolean chatListViewAttached;
    public float chatListViewPaddingTop;
    public int chatListViewPaddingVisibleOffset;
    private final ChatMessagesMetadataController chatMessagesMetadataController;
    private int chatMode;
    private ChatNotificationsPopupWrapper chatNotificationsPopupWrapper;
    private RecyclerAnimationScrollHelper chatScrollHelper;
    private final ChatScrollCallback chatScrollHelperCallback;
    private ChatThemeBottomSheet chatThemeBottomSheet;
    private boolean chatWasReset;
    private TextView chatWithAdminTextView;
    private Runnable checkPaddingsRunnable;
    private boolean checkTextureViewPosition;
    private Runnable checkTranslationRunnable;
    private boolean checkedSavedMessagesHint;
    private ChecksHintView checksHintView;
    private ActionBarMenuItem.Item clearHistoryItem;
    private boolean clearOnLoad;
    private int clearOnLoadAndScrollMessageId;
    private int clearOnLoadAndScrollOffset;
    private LongSparseIntArray clearingHistoryArr;
    private Dialog closeChatDialog;
    private Runnable closeInstantCameraAnimation;
    private ImageView closePinned;
    private ImageView closeReportSpam;
    private ActionBarMenuItem.Item closeTopicItem;
    private int commentLoadingGuid;
    private int commentLoadingMessageId;
    private long commentLoadingStartedAt;
    private int commentMessagesLoadingGuid;
    private int commentMessagesRequestId;
    private int commentRequestId;
    private int contentPaddingTop;
    private float contentPanTranslation;
    private float contentPanTranslationT;
    ContentPreviewViewer.ContentPreviewViewerDelegate contentPreviewViewerDelegate;
    public ChatActivityFragmentView contentView;
    private LongSparseArray conversionMessages;
    SparseIntArray conversionObjectsStableIds;
    private boolean convertingToast;
    private int convertingToastMessageId;
    private boolean convertingToastShown;
    private boolean createGroupCall;
    private int createUnreadMessageAfterId;
    private boolean createUnreadMessageAfterIdLoading;
    protected TLRPC.Chat currentChat;
    protected TLRPC.EncryptedChat currentEncryptedChat;
    private boolean currentFloatingDateOnScreen;
    private boolean currentFloatingTopIsNotMessage;
    private boolean currentFloatingTopicOnScreen;
    private String currentPicturePath;
    private int currentPinnedMessageId;
    private int[] currentPinnedMessageIndex;
    protected TLRPC.User currentUser;
    SparseIntArray dateObjectsStableIds;
    private int defaultSearchPage;
    private Runnable delayedReadRunnable;
    private Runnable destroyTextureViewRunnable;
    int dialogFilterId;
    int dialogFolderId;
    private long dialog_id;
    private Long dialog_id_Long;
    private ChatMessageCell drawLaterRoundProgressCell;
    public float drawingChatListViewYoffset;
    private ChatMessageCell dummyMessageCell;
    private AnimatorSet editButtonAnimation;
    private int editTextEnd;
    private ActionBarMenu.LazyItem editTextItem;
    private int editTextStart;
    public MessageObject editingMessageObject;
    private int editingMessageObjectReqId;
    public EmojiAnimationsOverlay emojiAnimationsOverlay;
    private View emojiButtonRed;
    private HintView emojiHintTextView;
    private LinkSpanDrawable.LinksTextView emojiStatusSpamHint;
    private TextView emptyView;
    private FrameLayout emptyViewContainer;
    private LinearLayout emptyViewContent;
    private boolean[] endReached;
    private HintView2 factCheckHint;
    private boolean fakePostponedScroll;
    private ActionBarMenuItem.Item feeItemGap;
    private ActionBarMenuItem.Item feeItemText;
    private int fieldPanelShown;
    private boolean filledEditTextItemMenu;
    private LongSparseArray filteredMessagesByDays;
    private LongSparseArray filteredMessagesDict;
    protected FireworksOverlay fireworksOverlay;
    private boolean first;
    private boolean firstLoading;
    private boolean firstMessagesLoaded;
    boolean firstOpen;
    private boolean firstUnreadSent;
    private int first_unread_id;
    private boolean fixPaddingsInLayout;
    private int fixedKeyboardHeight;
    private FlagSecureReason flagSecure;
    private AnimatorSet floatingDateAnimation;
    private ChatActionCell floatingDateView;
    private float floatingDateViewOffset;
    private ValueAnimator floatingTopicAnimation;
    private TopicSeparator.Cell floatingTopicSeparator;
    private float floatingTopicViewAlpha;
    private float floatingTopicViewOffset;
    private boolean forbidForwardingWithDismiss;
    public boolean forceDisallowApplyWallpeper;
    public boolean forceDisallowRedrawThemeDescriptions;
    private boolean forceHistoryEmpty;
    private int forceNextPinnedMessageId;
    private boolean forceScrollToFirst;
    private boolean forceScrollToTop;
    private CharSequence formwardingNameText;
    private TLRPC.TL_forumTopic forumTopic;
    private TextView forwardButton;
    private AnimatorSet forwardButtonAnimation;
    private boolean[] forwardEndReached;
    private HintView forwardHintView;
    private MessageObject forwardingMessage;
    private MessageObject.GroupedMessages forwardingMessageGroup;
    MessagePreviewView forwardingPreviewView;
    private ArrayList foundUrls;
    public TLRPC.WebPage foundWebPage;
    private FragmentContextView fragmentContextView;
    private FragmentContextView fragmentLocationContextView;
    public boolean fragmentOpened;
    private AnimatorSet fragmentTransition;
    private Runnable fragmentTransitionRunnable;
    private boolean fromPullingDownTransition;
    private HintView fwdRestrictedBottomHint;
    private HintView fwdRestrictedTopHint;
    private HintView gifHintTextView;
    private boolean globalIgnoreLayout;
    private ChatActionCell greetingsInfo;
    private ChatGreetingsView greetingsViewContainer;
    private ChatObject.Call groupCall;
    private HintView2 groupEmojiPackHint;
    private LongSparseArray groupedMessagesMap;
    private boolean hasAllMentionsLocal;
    private boolean hasBotWebView;
    private boolean hasBotsCommands;
    private boolean hasQuickReplies;
    private boolean hasUnfavedSelected;
    private HashtagHistoryView hashtagHistoryView;
    private FlickerLoadingView hashtagLoadingView;
    private StickerEmptyView hashtagSearchEmptyView;
    private int hashtagSearchSelectedIndex;
    public ChatSearchTabs hashtagSearchTabs;
    private ActionBarMenuItem headerItem;
    private Runnable hideAlertViewRunnable;
    private boolean hideCommentLoading;
    private int hideDateDelay;
    private boolean hideForwardEndReached;
    public int highlightMessageId;
    public String highlightMessageQuote;
    public boolean highlightMessageQuoteFirst;
    private long highlightMessageQuoteFirstTime;
    public int highlightMessageQuoteOffset;
    public Integer highlightTaskId;
    private MessageObject hint2MessageObject;
    private MessageObject hintMessageObject;
    private int hintMessageType;
    private boolean historyPreloaded;
    private boolean ignoreAttachOnPause;
    private boolean ignoreDraft;
    private ChatActionCell infoTopView;
    private Animator infoTopViewAnimator;
    private int initialMessagesSize;
    private long inlineReturn;
    public InstantCameraView instantCameraView;
    private boolean invalidateChatListViewTopPadding;
    private boolean invalidateMessagesVisiblePart;
    public boolean isComments;
    public boolean isFullyVisible;
    public boolean isInsideContainer;
    private boolean isPauseOnThemePreview;
    public boolean isSubscriberSuggestions;
    public boolean isTopic;
    public boolean justCreatedChat;
    public boolean justCreatedTopic;
    private boolean keyboardWasVisible;
    private boolean lastCallCheckFromServer;
    private HashMap lastLinkPreviewResults;
    private int lastLoadIndex;
    private long lastScrollTime;
    private int lastSkeletonCount;
    private int lastSkeletonMessageCount;
    private float lastTouchY;
    private long lastTranslationCheck;
    private int last_message_id;
    private int linkSearchRequestId;
    private Boolean liteModeChat;
    private boolean livestream;
    private boolean loadInfo;
    private int loadedPinnedMessagesCount;
    private boolean loading;
    private boolean loadingForward;
    private boolean loadingFromOldPosition;
    private SparseArray loadingPinnedMessages;
    public boolean loadingPinnedMessagesList;
    private int loadsCount;
    private boolean locationAlertShown;
    private int[] maxDate;
    private int[] maxMessageId;
    private int maxPinnedMessageId;
    private boolean maybeStartTrackingSlidingView;
    private HintView mediaBanTooltip;
    public MentionsContainerView mentionContainer;
    private AnimatorSet mentionListAnimation;
    private FrameLayout mentiondownButton;
    private ValueAnimator mentiondownButtonAnimation;
    private SimpleTextView mentiondownButtonCounter;
    private ImageView mentiondownButtonImage;
    private float mentionsButtonEnterProgress;
    private RecyclerListView.OnItemClickListener mentionsOnItemClickListener;
    private ActionBarMenuSubItem menuDeleteItem;
    private long mergeDialogId;
    private Animator messageEditTextAnimator;
    public MessageEnterTransitionContainer messageEnterTransitionContainer;
    public MessagePreviewParams messagePreviewParams;
    public Bulletin messageSeenPrivacyBulletin;
    private List messageSkeletons;
    public MessageSuggestionParams messageSuggestionParams;
    public ArrayList messages;
    private HashMap messagesByDays;
    private SparseArray messagesByDaysSorted;
    private SparseArray[] messagesDict;
    private MessagesSearchAdapter messagesSearchAdapter;
    private FrameLayout messagesSearchListContainer;
    public RecyclerListView messagesSearchListView;
    private AnimatorSet messagesSearchListViewAnimation;
    private int migrated_to;
    private int[] minDate;
    private int[] minMessageId;
    private ActionBarMenuItem.Item muteItem;
    private ActionBarMenuItem.Item muteItemGap;
    private MessageObject needAnimateToMessage;
    private boolean needRemovePreviousSameChatActivity;
    private boolean needSelectFromMessageId;
    private int newMentionsCount;
    private int newUnreadMessageCount;
    private ArrayList nextChannels;
    private boolean nextScrollForce;
    private int nextScrollForcePinnedMessageId;
    private int nextScrollFromMessageId;
    private int nextScrollLoadIndex;
    private boolean nextScrollSelect;
    private int nextScrollToMessageId;
    private HintView noSoundHintView;
    private ArrayList notPushedSponsoredMessages;
    private Runnable onChatMessagesLoaded;
    private Runnable onHideFieldPanelRunnable;
    RecyclerListView.OnItemClickListenerExtended onItemClickListener;
    RecyclerListView.OnItemLongClickListenerExtended onItemLongClickListener;
    public Runnable onThemeChange;
    public boolean openAnimationEnded;
    private long openAnimationStartTime;
    private ActionBarMenuItem.Item openForumItem;
    private boolean openImport;
    protected boolean openKeyboardOnAttachMenuClose;
    private boolean openSearchKeyboard;
    private boolean openVideoChat;
    private View overlayView;
    public float paddingTopHeight;
    private ValueAnimator pagedownAnimator;
    private FrameLayout pagedownButton;
    private ValueAnimator pagedownButtonAnimation;
    private ImageView pagedownButtonArrow;
    private CounterView pagedownButtonCounter;
    private float pagedownButtonEnterProgress;
    private ImageView pagedownButtonImage;
    private ImageView pagedownButtonLoading;
    private CircularProgressDrawable pagedownButtonLoadingDrawable;
    private boolean pagedownButtonShowedByScroll;
    private float pagedownLoadingT;
    private ChatActivity parentChatActivity;
    private ThemeDelegate parentThemeDelegate;
    private boolean paused;
    private boolean pausedOnLastMessage;
    private String pendingLinkSearchString;
    private ChatActivityMemberRequestsDelegate pendingRequestsDelegate;
    private final ArrayList pendingSendMessages;
    private final SparseArray pendingSendMessagesDict;
    private PhotoViewer.PhotoViewerProvider photoViewerPaidMediaProvider;
    private PhotoViewer.PhotoViewerProvider photoViewerProvider;
    private int pinBullerinTag;
    private Bulletin pinBulletin;
    private PinchToZoomHelper pinchToZoomHelper;
    private NumberTextView pinnedCounterTextView;
    private int pinnedCounterTextViewX;
    private boolean pinnedEndReached;
    private int pinnedImageCacheType;
    private boolean pinnedImageHasBlur;
    private TLRPC.PhotoSize pinnedImageLocation;
    private TLObject pinnedImageLocationObject;
    private int pinnedImageSize;
    private TLRPC.PhotoSize pinnedImageThumbLocation;
    private PinnedLineView pinnedLineView;
    private AnimatorSet pinnedListAnimator;
    private ImageView pinnedListButton;
    private PinnedMessageButton[] pinnedMessageButton;
    private boolean pinnedMessageButtonShown;
    private float pinnedMessageEnterOffset;
    private ArrayList pinnedMessageIds;
    private BackupImageView[] pinnedMessageImageView;
    private HashMap pinnedMessageObjects;
    private SimpleTextView[] pinnedMessageTextView;
    private BlurredFrameLayout pinnedMessageView;
    private AnimatorSet pinnedMessageViewAnimator;
    private TrackingWidthSimpleTextView[] pinnedNameTextView;
    private AnimatorSet[] pinnedNextAnimation;
    private RadialProgressView pinnedProgress;
    private boolean pinnedProgressIsShowing;
    private ChatMessageCell pollHintCell;
    private HintView pollHintView;
    private int pollHintX;
    private int pollHintY;
    private LongSparseArray polls;
    private final ArrayList pollsToCheck;
    private int popupAnimationIndex;
    private NotificationCenter.PostponeNotificationCallback postponeNotificationsWhileLoadingCallback;
    private final DialogInterface.OnCancelListener postponedScrollCancelListener;
    private boolean postponedScrollIsCanceled;
    private int postponedScrollMessageId;
    private int postponedScrollMinMessageId;
    private int postponedScrollToLastMessageQueryIndex;
    private TLRPC.Document preloadedGreetingsSticker;
    private boolean premiumInvoiceBot;
    private int prevSetUnreadCount;
    boolean preventReopenSearchWithText;
    public ProfileChannelCell.ChannelMessageFetcher profileChannelMessageFetcher;
    private RadialProgressView progressBar;
    private AlertDialog progressDialog;
    private int progressDialogAtMessageId;
    private int progressDialogAtMessageType;
    private String progressDialogBotButtonUrl;
    private Browser.Progress progressDialogCurrent;
    private CharacterStyle progressDialogLinkSpan;
    private FrameLayout progressView;
    private View progressView2;
    boolean pulled;
    private float pullingBottomOffset;
    private float pullingDownAnimateProgress;
    private ChatActivity pullingDownAnimateToActivity;
    private Animator pullingDownBackAnimator;
    private ChatPullingDownDrawable pullingDownDrawable;
    private float pullingDownOffset;
    private QuickRepliesEmptyView quickRepliesEmptyView;
    private MessageObject quickReplyMessage;
    public String quickReplyShortcut;
    private QuickShareSelectorOverlayLayout quickShareSelectorOverlay;
    private AlertDialog quoteMessageUpdateAlert;
    private ValueAnimator reactionsMentionButtonAnimation;
    private float reactionsMentionButtonEnterProgress;
    private int reactionsMentionCount;
    private FrameLayout reactionsMentiondownButton;
    private CounterView reactionsMentiondownButtonCounter;
    private ImageView reactionsMentiondownButtonImage;
    private boolean removingFromParent;
    private SparseArray repliesMessagesDict;
    private TextView replyButton;
    private AnimatorSet replyButtonAnimation;
    private ImageView replyCloseImageView;
    private ImageView replyIconImageView;
    private int replyImageCacheType;
    private boolean replyImageHasMediaSpoiler;
    private TLRPC.PhotoSize replyImageLocation;
    private TLObject replyImageLocationObject;
    private int replyImageSize;
    private TLRPC.PhotoSize replyImageThumbLocation;
    private BackupImageView replyImageView;
    private View replyLineView;
    private int replyMaxReadId;
    private MessageObject replyMessageHeaderObject;
    private SparseArray replyMessageOwners;
    private SimpleTextView replyNameTextView;
    private SimpleTextView replyObjectHintTextView;
    private SimpleTextView replyObjectTextView;
    public TLRPC.Chat replyOriginalChat;
    private int replyOriginalMessageId;
    private MessageObject replyingMessageObject;
    private ReplyQuote replyingQuote;
    private MessageObject.GroupedMessages replyingQuoteGroup;
    public MessageObject replyingTopMessage;
    private String reportMessage;
    private byte[] reportOption;
    private TextView reportSpamButton;
    private AnimatorSet reportSpamViewAnimator;
    private String reportTitle;
    private boolean requestClearSearchPages;
    private TL_account.resolvedBusinessChatLinks resolvedChatLink;
    private TextView restartTopicButton;
    private int returnToLoadIndex;
    private int returnToMessageId;
    public boolean reversed;
    private int runningAnimationIndex;
    private ActionBarMenuItem.Item savedChatsGap;
    private ActionBarMenuItem.Item savedChatsItem;
    private TLRPC.TL_messages_discussionMessage savedDiscussionMessage;
    private TLRPC.messages_Messages savedHistory;
    private HintView2 savedMessagesHint;
    private boolean savedMessagesHintShown;
    private HintView2 savedMessagesSearchHint;
    private HintView2 savedMessagesTagHint;
    private boolean savedMessagesTagHintShown;
    private boolean savedNoDiscussion;
    private boolean savedNoHistory;
    private AlertDialog scheduleNowDialog;
    private HintView scheduledHint;
    private boolean scheduledHintShown;
    private int scheduledMessagesCount;
    private HintView scheduledOrNoSoundHint;
    private boolean scheduledOrNoSoundHintShown;
    private AnimatorSet scrimAnimatorSet;
    private Bitmap scrimBlurBitmap;
    private Paint scrimBlurBitmapPaint;
    private BitmapShader scrimBlurBitmapShader;
    private Matrix scrimBlurMatrix;
    private Paint scrimPaint;
    private float scrimPaintAlpha;
    public ActionBarPopupWindow scrimPopupWindow;
    private boolean scrimPopupWindowHideDimOnDismiss;
    private ActionBarMenuSubItem[] scrimPopupWindowItems;
    private int scrimPopupX;
    private int scrimPopupY;
    private boolean scrimProgressDirection;
    private View scrimView;
    private float scrimViewAlpha;
    private ValueAnimator scrimViewAlphaAnimator;
    private float scrimViewProgress;
    private Integer scrimViewReaction;
    private boolean scrimViewReactionAnimated;
    private int scrimViewReactionOffset;
    private Integer scrimViewTask;
    private int scrollAnimationIndex;
    private boolean scrollByTouch;
    private int scrollCallbackAnimationIndex;
    private MessageObject scrollToMessage;
    private int scrollToMessagePosition;
    private int scrollToOffsetOnRecreate;
    private int scrollToPositionOnRecreate;
    private boolean scrollToThreadMessage;
    private boolean scrollToTopOnResume;
    private boolean scrollToTopUnReadOnResume;
    private boolean scrollToVideo;
    private boolean scrollingChatListView;
    private boolean scrollingFloatingDate;
    private boolean scrollingFloatingTopic;
    private ImageView searchCalendarButton;
    private BlurredFrameLayout searchContainer;
    private final int searchContainerHeight;
    private AnimatedTextView searchCountText;
    private FrameLayout searchDownButton;
    private ImageView searchDownButtonArrow;
    private ValueAnimator searchExpandAnimator;
    private AnimatedTextView searchExpandList;
    private float searchExpandProgress;
    private ActionBarMenuItem searchIconItem;
    protected ActionBarMenuItem searchItem;
    private SearchItemListener searchItemListener;
    private boolean searchItemVisible;
    private int searchLastCount;
    private int searchLastIndex;
    private AnimatedTextView searchOtherButton;
    private int searchType;
    private FrameLayout searchUpButton;
    private ValueAnimator searchUpButtonAnimation;
    private ImageView searchUpButtonArrow;
    private float searchUpDownEnterProgress;
    private ImageView searchUserButton;
    private ViewPagerFixed searchViewPager;
    boolean searchWas;
    private boolean searching;
    private TLRPC.Chat searchingChatMessages;
    private boolean searchingFiltered;
    private boolean searchingForUser;
    private String searchingHashtag;
    private String searchingQuery;
    public ReactionsLayoutInBubble.VisibleReaction searchingReaction;
    private TLRPC.User searchingUserMessages;
    private SecretVoicePlayer secretVoicePlayer;
    private SparseArray[] selectedMessagesCanCopyIds;
    private SparseArray[] selectedMessagesCanStarIds;
    private NumberTextView selectedMessagesCountTextView;
    private SparseArray[] selectedMessagesIds;
    private MessageObject selectedObject;
    private MessageObject.GroupedMessages selectedObjectGroup;
    private MessageObject selectedObjectToEditCaption;
    private ChatSelectionReactionMenuOverlay selectionReactionsOverlay;
    private TLRPC.TL_channels_sendAsPeers sendAsPeersObj;
    private boolean sentBotStart;
    private boolean setPinnedTextTranslationX;
    public int shareAlertDebugMode;
    public boolean shareAlertDebugTopicsSlowMotion;
    public ChatMessageSharedResources sharedResources;
    private boolean showAudioCallAsIcon;
    private boolean showCloseChatDialogLater;
    public boolean showNoQuoteAlert;
    private boolean showPinBulletin;
    private final Runnable showScheduledHintRunnable;
    private final Runnable showScheduledOrNoSoundRunnable;
    private boolean showScrollToMessageError;
    private boolean showSearchAsIcon;
    private boolean showTapForForwardingOptionsHit;
    private boolean shownBotVerification;
    private boolean shownConversionDateTimeToast;
    private boolean shownRestartTopic;
    private boolean shownTranslateTopic;
    private Theme.MessageDrawable.PathDrawParams skeletonBackgroundCacheParams;
    private Theme.MessageDrawable skeletonBackgroundDrawable;
    private int skeletonColor0;
    private int skeletonColor1;
    private ColorMatrix skeletonColorMatrix;
    private LinearGradient skeletonGradient;
    private int skeletonGradientWidth;
    private long skeletonLastUpdateTime;
    private Matrix skeletonMatrix;
    private LinearGradient skeletonOutlineGradient;
    private Matrix skeletonOutlineMatrix;
    private Paint skeletonOutlinePaint;
    private Paint skeletonPaint;
    private Paint skeletonServicePaint;
    private int skeletonTotalTranslation;
    private ChatMessageCell slidingView;
    private HintView slowModeHint;
    private boolean sponsoredMessagesAdded;
    private int sponsoredMessagesPostsBetween;
    private Pattern sponsoredUrlPattern;
    private StarReactionsOverlay starReactionsOverlay;
    private int startFromVideoMessageId;
    private int startFromVideoTimestamp;
    private int startLoadFromDate;
    private int startLoadFromMessageId;
    private int startLoadFromMessageIdSaved;
    private int startLoadFromMessageOffset;
    private long startMessageAppearTransitionMs;
    long startMs;
    private int startReplyTo;
    private String startVideoEdit;
    private boolean startedTrackingSlidingView;
    private SuggestEmojiView suggestEmojiPanel;
    private boolean swipeBackEnabled;
    private boolean switchFromTopics;
    private boolean switchingFromTopics;
    private float switchingFromTopicsProgress;
    private ReactionsContainerLayout tagSelector;
    private Runnable tapForForwardingOptionsHitRunnable;
    private ChatActivityTextSelectionHelper textSelectionHelper;
    private TextSelectionHint textSelectionHint;
    private boolean textSelectionHintWasShowed;
    private String textToSet;
    public ThemeDelegate themeDelegate;
    private int threadMaxInboxReadId;
    private int threadMaxOutboxReadId;
    private boolean threadMessageAdded;
    private long threadMessageId;
    private MessageObject threadMessageObject;
    private ArrayList threadMessageObjects;
    private boolean threadMessageVisible;
    private int threadUnreadMessagesCount;
    private ActionBarMenuItem.Item timeItem2;
    private HintView timerHintView;
    private boolean toPullingDownTransition;
    private BlurredFrameLayout topChatPanelView;
    private BlurredFrameLayout topChatPanelView2;
    private AnimatorSet topChatPanelView2Animator;
    private float topChatPanelView2Offset;
    private float topChatPanelViewOffset;
    private UndoView topUndoView;
    private float topViewOffset;
    private View topViewSeparator1;
    private View topViewSeparator2;
    private View topViewSeparator3;
    private int topViewWasVisible;
    private boolean topicChangedFromMessage;
    private MessageObject topicStarterMessageObject;
    public TopicsTabsView topicsTabs;
    private int totalPinnedMessagesCount;
    private int transitionAnimationGlobalIndex;
    private int transitionAnimationIndex;
    private TranslateButton translateButton;
    private ActionBarMenuItem.Item translateItem;
    private UndoView undoView;
    private MessageObject unreadMessageObject;
    private Runnable unselectRunnable;
    private final Runnable updateDeleteItemRunnable;
    Runnable updatePinnedProgressRunnable;
    Runnable updateReactionRunnable;
    private boolean userBlocked;
    protected TLRPC.UserFull userInfo;
    private HintView2 videoConversionTimeHint;
    private float videoConversionTimeHintY;
    private FrameLayout videoPlayerContainer;
    private TextureView videoTextureView;
    private ActionBarMenuItem.Item viewAsTopics;
    private String voiceChatHash;
    private HintView voiceHintTextView;
    private Runnable waitingForCharaterEnterRunnable;
    private boolean waitingForGetDifference;
    private ArrayList waitingForLoad;
    private SparseArray waitingForReplies;
    private boolean waitingForReplyMessageLoad;
    private boolean waitingForSendingMessageLoad;
    int waitingForWebpageId;
    private boolean wasManualScroll;
    private boolean wasPaused;
    TextView webBotTitle;
    private static final LongSparseArray chatMessageCellsCache = new LongSparseArray();
    public static int lastStableId = 10;
    private static final int[] allowedNotificationsDuringChatListAnimations = {NotificationCenter.messagesRead, NotificationCenter.threadMessagesRead, NotificationCenter.monoForumMessagesRead, NotificationCenter.commentsRead, NotificationCenter.messagesReadEncrypted, NotificationCenter.messagesReadContent, NotificationCenter.didLoadPinnedMessages, NotificationCenter.newDraftReceived, NotificationCenter.updateMentionsCount, NotificationCenter.didUpdateConnectionState, NotificationCenter.updateDefaultSendAsPeer, NotificationCenter.closeChats, NotificationCenter.chatInfoCantLoad, NotificationCenter.userInfoDidLoad, NotificationCenter.pinnedInfoDidLoad, NotificationCenter.didSetNewWallpapper, NotificationCenter.savedMessagesDialogsUpdate, NotificationCenter.didApplyNewTheme};
    private static boolean replacingChatActivity = false;

    class AnonymousClass108 extends GigagroupConvertAlert {
        AnonymousClass108(Context context, BaseFragment baseFragment) {
            super(context, baseFragment);
        }

        public void lambda$onCovert$0(boolean z) {
            if (z) {
                ChatActivity.this.createUndoView();
                if (ChatActivity.this.undoView == null) {
                    return;
                }
                ChatActivity.this.undoView.showWithAction(0L, 76, (Runnable) null);
            }
        }

        protected void onCancel() {
            ChatActivity.this.createUndoView();
            if (ChatActivity.this.undoView == null) {
                return;
            }
            ChatActivity.this.undoView.showWithAction(0L, 75, (Runnable) null);
            ChatActivity.this.getMessagesController().removeSuggestion(ChatActivity.this.dialog_id, "CONVERT_GIGAGROUP");
        }

        protected void onCovert() {
            MessagesController messagesController = ChatActivity.this.getMessagesController();
            Activity parentActivity = ChatActivity.this.getParentActivity();
            ChatActivity chatActivity = ChatActivity.this;
            messagesController.convertToGigaGroup(parentActivity, chatActivity.currentChat, chatActivity, new MessagesStorage.BooleanCallback() {
                public final void run(boolean z) {
                    ChatActivity.AnonymousClass108.this.lambda$onCovert$0(z);
                }
            });
        }
    }

    class AnonymousClass114 implements Runnable {
        AnonymousClass114() {
        }

        public void lambda$run$0(ValueAnimator valueAnimator) {
            ChatActivity.this.alertViewEnterProgress = ((Float) valueAnimator.getAnimatedValue()).floatValue();
            ChatActivity.this.invalidateChatListViewTopPadding();
        }

        @Override
        public void run() {
            if (ChatActivity.this.hideAlertViewRunnable == this && ChatActivity.this.alertView.getTag() == null) {
                ChatActivity.this.alertView.setTag(1);
                if (ChatActivity.this.alertViewAnimator != null) {
                    ChatActivity.this.alertViewAnimator.cancel();
                    ChatActivity.this.alertViewAnimator = null;
                }
                ChatActivity.this.alertViewAnimator = new AnimatorSet();
                ValueAnimator ofFloat = ValueAnimator.ofFloat(ChatActivity.this.alertViewEnterProgress, 0.0f);
                ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                    @Override
                    public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                        ChatActivity.AnonymousClass114.this.lambda$run$0(valueAnimator);
                    }
                });
                ChatActivity.this.alertViewAnimator.playTogether(ofFloat);
                ChatActivity.this.alertViewAnimator.setDuration(200L);
                ChatActivity.this.alertViewAnimator.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationCancel(Animator animator) {
                        if (ChatActivity.this.alertViewAnimator == null || !ChatActivity.this.alertViewAnimator.equals(animator)) {
                            return;
                        }
                        ChatActivity.this.alertViewAnimator = null;
                    }

                    @Override
                    public void onAnimationEnd(Animator animator) {
                        if (ChatActivity.this.alertViewAnimator == null || !ChatActivity.this.alertViewAnimator.equals(animator)) {
                            return;
                        }
                        ChatActivity.this.alertView.setVisibility(8);
                        ChatActivity.this.alertViewEnterProgress = 0.0f;
                        ChatActivity.this.invalidateChatListViewTopPadding();
                        ChatActivity.this.alertViewAnimator = null;
                    }
                });
                ChatActivity.this.alertViewAnimator.start();
            }
        }
    }

    class AnonymousClass12 implements RecyclerListView.OnItemClickListenerExtended {
        AnonymousClass12() {
        }

        public void lambda$onItemClick$0(int i) {
            ChatActivity.this.scrollToMessageId(i, 0, true, 0, true, 0);
        }

        public boolean hasDoubleTap(View view, int i) {
            MessageObject messageObject;
            TLRPC.ChatFull chatFull;
            if (ChatActivity.this.chatMode == 5) {
                return false;
            }
            String doubleTapReaction = ChatActivity.this.getMediaDataController().getDoubleTapReaction();
            TLRPC.TL_availableReaction tL_availableReaction = (TLRPC.TL_availableReaction) ChatActivity.this.getMediaDataController().getReactionsMap().get(doubleTapReaction);
            if (tL_availableReaction == null && (doubleTapReaction == null || !doubleTapReaction.startsWith("animated_"))) {
                return false;
            }
            boolean z = ChatActivity.this.dialog_id >= 0;
            if (!z && (chatFull = ChatActivity.this.chatInfo) != null) {
                if (tL_availableReaction != null) {
                    doubleTapReaction = tL_availableReaction.reaction;
                }
                z = ChatObject.reactionIsAvailable(chatFull, doubleTapReaction);
            }
            if (!z) {
                return false;
            }
            if (view instanceof ChatMessageCell) {
                messageObject = ((ChatMessageCell) view).getPrimaryMessageObject();
            } else {
                if (!(view instanceof ChatActionCell)) {
                    return false;
                }
                messageObject = ((ChatActionCell) view).getMessageObject();
            }
            return (messageObject == null || messageObject.isDateObject || messageObject.isSending() || !messageObject.canSetReaction() || messageObject.isEditing() || ((BaseFragment) ChatActivity.this).actionBar.isActionModeShowed() || ChatActivity.this.isSecretChat() || ChatActivity.this.isInScheduleMode() || messageObject.isSponsored()) ? false : true;
        }

        public void onDoubleTap(View view, int i, float f, float f2) {
            MessageObject messageObject;
            boolean z;
            ChatActivity chatActivity;
            ReactionsLayoutInBubble.VisibleReaction fromEmojicon;
            TLRPC.ChatFull chatFull;
            TLRPC.ChatFull chatFull2;
            if (ChatActivity.this.getParentActivity() == null || ChatActivity.this.isSecretChat() || ChatActivity.this.isInScheduleMode() || ChatActivity.this.isInPreviewMode() || ChatActivity.this.chatMode == 5) {
                return;
            }
            if (view instanceof ChatMessageCell) {
                messageObject = ((ChatMessageCell) view).getPrimaryMessageObject();
            } else {
                if (!(view instanceof ChatActionCell)) {
                    return;
                }
                messageObject = ((ChatActionCell) view).getMessageObject();
                if (messageObject.isDateObject) {
                    return;
                }
            }
            MessageObject messageObject2 = messageObject;
            if (messageObject2.isSecret() || !messageObject2.canSetReaction() || messageObject2.isExpiredStory() || messageObject2.type == 27) {
                return;
            }
            ReactionsEffectOverlay.removeCurrent(false);
            String doubleTapReaction = ChatActivity.this.getMediaDataController().getDoubleTapReaction();
            if (doubleTapReaction.startsWith("animated_")) {
                z = ChatActivity.this.dialog_id >= 0;
                if (!z && (chatFull2 = ChatActivity.this.chatInfo) != null) {
                    z = ChatObject.reactionIsAvailable(chatFull2, doubleTapReaction);
                }
                if (!z) {
                    return;
                }
                chatActivity = ChatActivity.this;
                fromEmojicon = ReactionsLayoutInBubble.VisibleReaction.fromEmojicon(doubleTapReaction);
            } else {
                TLRPC.TL_availableReaction tL_availableReaction = (TLRPC.TL_availableReaction) ChatActivity.this.getMediaDataController().getReactionsMap().get(doubleTapReaction);
                if (tL_availableReaction == null || messageObject2.isSponsored()) {
                    return;
                }
                z = ChatActivity.this.dialog_id >= 0;
                if (!z && (chatFull = ChatActivity.this.chatInfo) != null) {
                    z = ChatObject.reactionIsAvailable(chatFull, tL_availableReaction.reaction);
                }
                if (!z) {
                    return;
                }
                chatActivity = ChatActivity.this;
                fromEmojicon = ReactionsLayoutInBubble.VisibleReaction.fromEmojicon(tL_availableReaction);
            }
            chatActivity.selectReaction(view, messageObject2, null, null, f, f2, fromEmojicon, true, false, false, false);
        }

        public void onItemClick(View view, int i, float f, float f2) {
            ChatMessageCell chatMessageCell;
            MessageObject messageObject;
            boolean z = false;
            if (((BaseFragment) ChatActivity.this).inPreviewMode) {
                return;
            }
            ChatActivity.this.wasManualScroll = true;
            boolean z2 = view instanceof ChatActionCell;
            if (z2) {
                ChatActionCell chatActionCell = (ChatActionCell) view;
                if (chatActionCell.getMessageObject().isDateObject) {
                    if (ChatActivity.this.isInsideContainer) {
                        return;
                    }
                    Bundle bundle = new Bundle();
                    int i2 = chatActionCell.getMessageObject().messageOwner.date;
                    bundle.putLong("dialog_id", ChatActivity.this.dialog_id);
                    bundle.putLong("topic_id", ChatActivity.this.getTopicId());
                    bundle.putInt("type", 0);
                    CalendarActivity calendarActivity = new CalendarActivity(bundle, 0, i2);
                    calendarActivity.setChatActivity(ChatActivity.this);
                    ChatActivity.this.presentFragment(calendarActivity);
                    return;
                }
            }
            if (z2) {
                ChatActionCell chatActionCell2 = (ChatActionCell) view;
                if (chatActionCell2.getMessageObject() != null && (chatActionCell2.getMessageObject().messageOwner.action instanceof TLRPC.TL_messageActionBoostApply)) {
                    ChatActivity.this.getNotificationCenter().postNotificationName(NotificationCenter.openBoostForUsersDialog, new Object[]{Long.valueOf(ChatActivity.this.dialog_id)});
                    return;
                }
            }
            if (z2) {
                ChatActionCell chatActionCell3 = (ChatActionCell) view;
                if (chatActionCell3.getMessageObject() != null && (chatActionCell3.getMessageObject().messageOwner.action instanceof TLRPC.TL_messageActionSetSameChatWallPaper)) {
                    final int replyMsgId = chatActionCell3.getMessageObject().getReplyMsgId();
                    AndroidUtilities.runOnUIThread(new Runnable() {
                        @Override
                        public final void run() {
                            ChatActivity.AnonymousClass12.this.lambda$onItemClick$0(replyMsgId);
                        }
                    }, 16L);
                    return;
                }
            }
            if (((BaseFragment) ChatActivity.this).actionBar.isActionModeShowed() || ChatActivity.this.isReport()) {
                if (view instanceof ChatMessageCell) {
                    ChatMessageCell chatMessageCell2 = (ChatMessageCell) view;
                    if (ChatActivity.this.textSelectionHelper.isSelected(chatMessageCell2.getMessageObject())) {
                        return;
                    } else {
                        z = !chatMessageCell2.isInsideBackground(f, f2);
                    }
                }
                ChatActivity.this.processRowSelect(view, z, f, f2);
                return;
            }
            if (!(view instanceof ChatMessageCell) || (messageObject = (chatMessageCell = (ChatMessageCell) view).getMessageObject()) == null || messageObject.type != 27) {
                ChatActivity.this.createMenu(view, true, false, f, f2, false);
                return;
            }
            messageObject.toggleChannelRecommendations();
            messageObject.forceUpdate = true;
            chatMessageCell.forceResetMessageObject();
            view.requestLayout();
            if (i >= 0) {
                ChatActivity.this.chatAdapter.notifyItemChanged(i);
            }
        }
    }

    class AnonymousClass13 extends ActionBar.ActionBarMenuOnItemClick {
        final Context val$context;

        class AnonymousClass1 implements MessagesStorage.BooleanCallback {
            final boolean val$canDeleteHistory;

            AnonymousClass1(boolean z) {
                this.val$canDeleteHistory = z;
            }

            public void lambda$run$0(boolean z, boolean z2) {
                ChatActivity.this.performHistoryClear(true, z);
            }

            public void lambda$run$1(final boolean z, int i) {
                if (i < 50) {
                    ChatActivity.this.performHistoryClear(true, z);
                } else {
                    ChatActivity chatActivity = ChatActivity.this;
                    AlertsCreator.createClearOrDeleteDialogAlert(chatActivity, true, false, true, chatActivity.currentChat, chatActivity.currentUser, false, false, z, new MessagesStorage.BooleanCallback() {
                        public final void run(boolean z2) {
                            ChatActivity.AnonymousClass13.AnonymousClass1.this.lambda$run$0(z, z2);
                        }
                    }, ChatActivity.this.themeDelegate);
                }
            }

            public void run(boolean z) {
                if (z) {
                    ChatActivity chatActivity = ChatActivity.this;
                    if (chatActivity.currentUser != null || this.val$canDeleteHistory) {
                        MessagesStorage messagesStorage = chatActivity.getMessagesStorage();
                        long j = ChatActivity.this.dialog_id;
                        final boolean z2 = this.val$canDeleteHistory;
                        messagesStorage.getMessagesCount(j, new MessagesStorage.IntCallback() {
                            public final void run(int i) {
                                ChatActivity.AnonymousClass13.AnonymousClass1.this.lambda$run$1(z2, i);
                            }
                        });
                        return;
                    }
                }
                ChatActivity.this.performHistoryClear(z, this.val$canDeleteHistory);
            }
        }

        AnonymousClass13(Context context) {
            this.val$context = context;
        }

        public void lambda$onItemClick$0() {
            ChatActivity.this.lambda$onBackPressed$354();
        }

        public void lambda$onItemClick$1(long j, long j2, Long l, Boolean bool) {
            StarsController.getInstance(((BaseFragment) ChatActivity.this).currentAccount).stopPaidMessages(j, j2, l.longValue() > 0 && bool.booleanValue(), true);
        }

        public void lambda$onItemClick$2(final long j, final long j2, final Long l) {
            if (ChatActivity.this.getContext() == null) {
                return;
            }
            AlertsCreator.showAlertWithCheckbox(ChatActivity.this.getContext(), LocaleController.getString(R.string.RemoveMessageFeeTitle), AndroidUtilities.replaceTags(LocaleController.formatString(ChatObject.isMonoForum(ChatActivity.this.currentChat) ? R.string.RemoveMessageFeeMessageChannel : R.string.RemoveMessageFeeMessage, new Object[]{DialogObject.getShortName(j)})), l.longValue() > 0 ? LocaleController.formatPluralStringComma("RemoveMessageFeeRefund", (int) l.longValue()) : null, LocaleController.getString(R.string.Confirm), new Utilities.Callback() {
                public final void run(Object obj) {
                    ChatActivity.AnonymousClass13.this.lambda$onItemClick$1(j, j2, l, (Boolean) obj);
                }
            }, ((BaseFragment) ChatActivity.this).resourceProvider);
        }

        public void lambda$onItemClick$3(boolean z, int i) {
            if (i <= 0 || ChatActivity.this.getParentActivity() == null) {
                return;
            }
            BulletinFactory.of(ChatActivity.this).createDownloadBulletin(z ? BulletinFactory.FileType.AUDIOS : BulletinFactory.FileType.UNKNOWNS, i, ChatActivity.this.themeDelegate).show();
        }

        public void lambda$onItemClick$4(TLRPC.User user, boolean z) {
            if (user.id != ChatActivity.this.getThreadId()) {
                return;
            }
            ChatActivity.this.performHistoryClear(false, true);
        }

        public void lambda$onItemClick$5(int i, boolean z, boolean z2) {
            if (i == 15 && ChatObject.isChannel(ChatActivity.this.currentChat)) {
                TLRPC.Chat chat = ChatActivity.this.currentChat;
                if (!chat.megagroup || ChatObject.isPublic(chat)) {
                    ChatActivity.this.getMessagesController().deleteDialog(ChatActivity.this.dialog_id, 2, z2);
                    return;
                }
            }
            if (i == 15) {
                ChatActivity.this.performHistoryClear(z2, z);
                return;
            }
            NotificationCenter notificationCenter = ChatActivity.this.getNotificationCenter();
            ChatActivity chatActivity = ChatActivity.this;
            int i2 = NotificationCenter.closeChats;
            notificationCenter.removeObserver(chatActivity, i2);
            ChatActivity.this.getNotificationCenter().postNotificationName(i2, new Object[0]);
            ChatActivity.this.lambda$onBackPressed$354();
            NotificationCenter notificationCenter2 = ChatActivity.this.getNotificationCenter();
            int i3 = NotificationCenter.needDeleteDialog;
            Long valueOf = Long.valueOf(ChatActivity.this.dialog_id);
            ChatActivity chatActivity2 = ChatActivity.this;
            notificationCenter2.postNotificationName(i3, new Object[]{valueOf, chatActivity2.currentUser, chatActivity2.currentChat, Boolean.valueOf(z2)});
        }

        public void lambda$onItemClick$6(QuickRepliesController.QuickReply quickReply, String str) {
            if (quickReply != null) {
                QuickRepliesController.getInstance(((BaseFragment) ChatActivity.this).currentAccount).renameReply(quickReply.id, str);
            }
            ChatActivity chatActivity = ChatActivity.this;
            chatActivity.quickReplyShortcut = str;
            chatActivity.avatarContainer.setTitle(str);
        }

        public void lambda$onItemClick$7(View view) {
            ChatActivity.this.headerItem.closeSubMenu();
            ChatAttachAlert chatAttachAlert = ChatActivity.this.chatAttachAlert;
            if (chatAttachAlert != null) {
                chatAttachAlert.setEditingMessageObject(0, (MessageObject) null);
            }
            ChatActivity.this.openAttachMenu();
        }

        public void lambda$onItemClick$8() {
            Intent intent = new Intent(ChatActivity.this.getContext(), (Class<?>) LaunchActivity.class);
            intent.setAction("android.intent.action.SEND");
            intent.setType("text/plain");
            intent.putExtra("android.intent.extra.TEXT", ChatActivity.this.businessLink.link);
            ChatActivity.this.startActivityForResult(intent, 500);
        }

        public void lambda$onItemClick$9(AlertDialog alertDialog, int i) {
            ChatActivity.this.lambda$onBackPressed$354();
            ChatActivity.this.getNotificationCenter().postNotificationName(NotificationCenter.needDeleteBusinessLink, new Object[]{ChatActivity.this.businessLink});
        }

        @Override
        public void onItemClick(final int i) {
            TLRPC.User user;
            TLRPC.ChatFull chatFull;
            final TLRPC.User user2;
            SendMessagesHelper sendMessagesHelper;
            long j;
            MessageObject.SendAnimationData sendAnimationData;
            boolean z;
            String str;
            TLRPC.User user3;
            long j2 = 0;
            if (i != -1) {
                if (i != 59) {
                    if (i == 10) {
                        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
                        long j3 = 0;
                        for (int i2 = 1; i2 >= 0; i2--) {
                            ArrayList arrayList = new ArrayList();
                            for (int i3 = 0; i3 < ChatActivity.this.selectedMessagesCanCopyIds[i2].size(); i3++) {
                                arrayList.add(Integer.valueOf(ChatActivity.this.selectedMessagesCanCopyIds[i2].keyAt(i3)));
                            }
                            if (ChatActivity.this.currentEncryptedChat == null) {
                                Collections.sort(arrayList);
                            } else {
                                Collections.sort(arrayList, Collections.reverseOrder());
                            }
                            for (int i4 = 0; i4 < arrayList.size(); i4++) {
                                MessageObject messageObject = (MessageObject) ChatActivity.this.selectedMessagesCanCopyIds[i2].get(((Integer) arrayList.get(i4)).intValue());
                                if (spannableStringBuilder.length() != 0) {
                                    spannableStringBuilder.append((CharSequence) "\n\n");
                                }
                                spannableStringBuilder.append(ChatActivity.getMessageContent(messageObject, j3, arrayList.size() != 1 && ((user3 = ChatActivity.this.currentUser) == null || !user3.self)));
                                j3 = messageObject.getFromChatId();
                            }
                        }
                        if (spannableStringBuilder.length() != 0) {
                            AndroidUtilities.addToClipboard(spannableStringBuilder);
                            ChatActivity.this.createUndoView();
                            ChatActivity.this.undoView.showWithAction(0L, 58, (Runnable) null);
                        }
                    } else {
                        if (i == 12) {
                            if (ChatActivity.this.getParentActivity() == null) {
                                return;
                            }
                            ChatActivity.this.createDeleteMessagesAlert(null, null);
                            return;
                        }
                        if (i == 11) {
                            ChatActivity.this.openForward(true);
                            return;
                        }
                        if (i == 69) {
                            ChatActivity.this.share();
                            return;
                        }
                        if (i == 70) {
                            ChatActivity chatActivity = ChatActivity.this;
                            TLRPC.Chat chat = chatActivity.currentChat;
                            if (chat == null) {
                                return;
                            }
                            chatActivity.presentFragment(ChatActivity.of(-chat.linked_monoforum_id));
                            return;
                        }
                        if (i == 72) {
                            long j4 = ChatActivity.this.dialog_id;
                            if (ChatObject.isMonoForum(ChatActivity.this.currentChat) && ChatObject.canManageMonoForum(((BaseFragment) ChatActivity.this).currentAccount, ChatActivity.this.currentChat)) {
                                j4 = ChatActivity.this.getThreadId();
                                j2 = ChatActivity.this.dialog_id;
                            }
                            StarsController.getInstance(((BaseFragment) ChatActivity.this).currentAccount).stopPaidMessages(j4, j2, false, false);
                            return;
                        }
                        if (i == 71) {
                            long j5 = ChatActivity.this.dialog_id;
                            if (ChatObject.isMonoForum(ChatActivity.this.currentChat) && ChatObject.canManageMonoForum(((BaseFragment) ChatActivity.this).currentAccount, ChatActivity.this.currentChat)) {
                                j5 = ChatActivity.this.getThreadId();
                                j2 = ChatActivity.this.dialog_id;
                            }
                            final long j6 = j5;
                            final long j7 = j2;
                            StarsController.getInstance(((BaseFragment) ChatActivity.this).currentAccount).getPaidRevenue(j6, j7, new Utilities.Callback() {
                                public final void run(Object obj) {
                                    ChatActivity.AnonymousClass13.this.lambda$onItemClick$2(j6, j7, (Long) obj);
                                }
                            });
                            return;
                        }
                        if (i == 28) {
                            if (ChatActivity.this.tagSelector == null) {
                                ChatActivity.this.showTagSelector();
                                return;
                            } else {
                                ChatActivity.this.hideTagSelector();
                                return;
                            }
                        }
                        if (i == 25) {
                            ArrayList arrayList2 = new ArrayList();
                            for (int i5 = 1; i5 >= 0; i5--) {
                                for (int i6 = 0; i6 < ChatActivity.this.selectedMessagesIds[i5].size(); i6++) {
                                    arrayList2.add((MessageObject) ChatActivity.this.selectedMessagesIds[i5].valueAt(i6));
                                }
                                ChatActivity.this.selectedMessagesIds[i5].clear();
                                ChatActivity.this.selectedMessagesCanCopyIds[i5].clear();
                                ChatActivity.this.selectedMessagesCanStarIds[i5].clear();
                            }
                            final boolean z2 = ChatActivity.this.canSaveMusicCount > 0;
                            ChatActivity.this.hideActionMode();
                            ChatActivity.this.updatePinnedMessageView(true);
                            ChatActivity.this.updateVisibleRows();
                            MediaController.saveFilesFromMessages(ChatActivity.this.getParentActivity(), ChatActivity.this.getAccountInstance(), arrayList2, new MessagesStorage.IntCallback() {
                                public final void run(int i7) {
                                    ChatActivity.AnonymousClass13.this.lambda$onItemClick$3(z2, i7);
                                }
                            });
                            return;
                        }
                        if (i == 13) {
                            if (ChatActivity.this.getParentActivity() == null) {
                                return;
                            }
                            ChatActivity chatActivity2 = ChatActivity.this;
                            Activity parentActivity = chatActivity2.getParentActivity();
                            ChatActivity chatActivity3 = ChatActivity.this;
                            chatActivity2.showDialog(AlertsCreator.createTTLAlert(parentActivity, chatActivity3.currentEncryptedChat, chatActivity3.themeDelegate).create());
                            return;
                        }
                        if (i == 15 || i == 16 || i == 26) {
                            if (ChatActivity.this.getParentActivity() == null) {
                                return;
                            }
                            if (i == 15 && ChatObject.isMonoForum(ChatActivity.this.currentChat)) {
                                if (ChatActivity.this.getThreadId() == 0 || (user2 = ChatActivity.this.getMessagesController().getUser(Long.valueOf(ChatActivity.this.getThreadId()))) == null) {
                                    return;
                                }
                                ChatActivity chatActivity4 = ChatActivity.this;
                                AlertsCreator.createClearDaysDialogAlert(chatActivity4, -1, user2, chatActivity4.currentChat, true, new MessagesStorage.BooleanCallback() {
                                    public final void run(boolean z3) {
                                        ChatActivity.AnonymousClass13.this.lambda$onItemClick$4(user2, z3);
                                    }
                                }, ChatActivity.this.getResourceProvider());
                                return;
                            }
                            ChatActivity chatActivity5 = ChatActivity.this;
                            TLRPC.ChatFull chatFull2 = chatActivity5.chatInfo;
                            final boolean z3 = chatFull2 != null && chatFull2.can_delete_channel;
                            if (i == 26 || (i == 15 && chatActivity5.currentEncryptedChat == null && (!((user = chatActivity5.currentUser) == null || UserObject.isUserSelf(user) || UserObject.isDeleted(ChatActivity.this.currentUser)) || ((chatFull = ChatActivity.this.chatInfo) != null && chatFull.can_delete_channel)))) {
                                ChatActivity chatActivity6 = ChatActivity.this;
                                AlertsCreator.createClearDaysDialogAlert(chatActivity6, -1, chatActivity6.currentUser, chatActivity6.currentChat, z3, new AnonymousClass1(z3), ChatActivity.this.getResourceProvider());
                                return;
                            } else {
                                ChatActivity chatActivity7 = ChatActivity.this;
                                AlertsCreator.createClearOrDeleteDialogAlert(chatActivity7, i == 15, chatActivity7.currentChat, chatActivity7.currentUser, chatActivity7.currentEncryptedChat != null, true, z3, new MessagesStorage.BooleanCallback() {
                                    public final void run(boolean z4) {
                                        ChatActivity.AnonymousClass13.this.lambda$onItemClick$5(i, z3, z4);
                                    }
                                }, ChatActivity.this.themeDelegate);
                                return;
                            }
                        }
                        if (i == 17) {
                            ChatActivity chatActivity8 = ChatActivity.this;
                            if (chatActivity8.currentUser == null || chatActivity8.getParentActivity() == null) {
                                return;
                            }
                            if (ChatActivity.this.addToContactsButton != null && ChatActivity.this.addToContactsButton.getTag() != null) {
                                ChatActivity chatActivity9 = ChatActivity.this;
                                chatActivity9.shareMyContact(((Integer) chatActivity9.addToContactsButton.getTag()).intValue(), null);
                                return;
                            } else {
                                Bundle bundle = new Bundle();
                                bundle.putLong("user_id", ChatActivity.this.currentUser.id);
                                bundle.putBoolean("addContact", true);
                                ChatActivity.this.presentFragment(new ContactAddActivity(bundle));
                                return;
                            }
                        }
                        if (i == 18) {
                            ChatActivity.this.toggleMute(false);
                            return;
                        }
                        if (i == 24) {
                            try {
                                ChatActivity.this.getMediaDataController().installShortcut(ChatActivity.this.currentUser.id, MediaDataController.SHORTCUT_TYPE_USER_OR_CHAT);
                                return;
                            } catch (Exception e) {
                                FileLog.e(e);
                                return;
                            }
                        }
                        if (i == 29) {
                            if (!ChatObject.hasAdminRights(ChatActivity.this.currentChat)) {
                                ChatActivity.this.getNotificationCenter().postNotificationName(NotificationCenter.openBoostForUsersDialog, new Object[]{Long.valueOf(ChatActivity.this.dialog_id)});
                                return;
                            }
                            BoostsActivity boostsActivity = new BoostsActivity(ChatActivity.this.dialog_id);
                            boostsActivity.setBoostsStatus(ChatActivity.this.boostsStatus);
                            ChatActivity.this.presentFragment(boostsActivity);
                            return;
                        }
                        if (i == 21) {
                            ReportBottomSheet.openChat(ChatActivity.this);
                            return;
                        }
                        if (i != 22) {
                            if (i == 23) {
                                for (int i7 = 1; i7 >= 0; i7--) {
                                    if (r9 == null && ChatActivity.this.selectedMessagesIds[i7].size() == 1) {
                                        ArrayList arrayList3 = new ArrayList();
                                        for (int i8 = 0; i8 < ChatActivity.this.selectedMessagesIds[i7].size(); i8++) {
                                            arrayList3.add(Integer.valueOf(ChatActivity.this.selectedMessagesIds[i7].keyAt(i8)));
                                        }
                                        r9 = (MessageObject) ChatActivity.this.messagesDict[i7].get(((Integer) arrayList3.get(0)).intValue());
                                    }
                                    ChatActivity.this.selectedMessagesIds[i7].clear();
                                    ChatActivity.this.selectedMessagesCanCopyIds[i7].clear();
                                    ChatActivity.this.selectedMessagesCanStarIds[i7].clear();
                                }
                                if (r9 == null || !r9.isTodo()) {
                                    ChatActivity.this.startEditingMessageObject(r9);
                                } else {
                                    ChatActivity.this.selectedObject = r9;
                                    ChatActivity.this.processSelectedOption(109);
                                }
                                ChatActivity.this.hideActionMode();
                                ChatActivity.this.updatePinnedMessageView(true);
                                ChatActivity.this.updateVisibleRows();
                                return;
                            }
                            if (i == 64) {
                                final QuickRepliesController.QuickReply findReply = QuickRepliesController.getInstance(((BaseFragment) ChatActivity.this).currentAccount).findReply(ChatActivity.this.getQuickReplyId());
                                Context context = ChatActivity.this.getContext();
                                int i9 = ((BaseFragment) ChatActivity.this).currentAccount;
                                ChatActivity chatActivity10 = ChatActivity.this;
                                QuickRepliesActivity.openRenameReplyAlert(context, i9, chatActivity10.quickReplyShortcut, findReply, chatActivity10.getResourceProvider(), false, new Utilities.Callback() {
                                    public final void run(Object obj) {
                                        ChatActivity.AnonymousClass13.this.lambda$onItemClick$6(findReply, (String) obj);
                                    }
                                });
                                return;
                            }
                            if (i == 14) {
                                ActionBarMenuSubItem actionBarMenuSubItem = new ActionBarMenuSubItem(this.val$context, false, true, true, ChatActivity.this.getResourceProvider());
                                actionBarMenuSubItem.setTextAndIcon(LocaleController.getString(R.string.AttachMenu), R.drawable.input_attach);
                                actionBarMenuSubItem.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public final void onClick(View view) {
                                        ChatActivity.AnonymousClass13.this.lambda$onItemClick$7(view);
                                    }
                                });
                                ChatActivity.this.headerItem.toggleSubMenu(actionBarMenuSubItem, ChatActivity.this.attachItem.createView());
                                return;
                            }
                            if (i == 30) {
                                sendMessagesHelper = ChatActivity.this.getSendMessagesHelper();
                                j = ChatActivity.this.dialog_id;
                                sendAnimationData = null;
                                z = false;
                                str = "/help";
                            } else {
                                if (i != 31) {
                                    if (i == 40) {
                                        ChatActivity chatActivity11 = ChatActivity.this;
                                        chatActivity11.lambda$openSearchWithText$357(chatActivity11.isSupportedTags() ? "" : null);
                                        return;
                                    }
                                    if (i == 62) {
                                        ChatActivity.this.getMessagesController().getTranslateController().setHideTranslateDialog(ChatActivity.this.getDialogId(), false, true);
                                        if (ChatActivity.this.getMessagesController().getTranslateController().toggleTranslatingDialog(ChatActivity.this.getDialogId(), true)) {
                                            return;
                                        }
                                    } else {
                                        if (i == 32 || i == 33) {
                                            ChatActivity chatActivity12 = ChatActivity.this;
                                            if (chatActivity12.currentUser == null || chatActivity12.getParentActivity() == null) {
                                                return;
                                            }
                                            ChatActivity chatActivity13 = ChatActivity.this;
                                            TLRPC.User user4 = chatActivity13.currentUser;
                                            boolean z4 = i == 33;
                                            TLRPC.UserFull userFull = chatActivity13.userInfo;
                                            VoIPHelper.startCall(user4, z4, userFull != null && userFull.video_calls_available, chatActivity13.getParentActivity(), ChatActivity.this.getMessagesController().getUserFull(ChatActivity.this.currentUser.id), ChatActivity.this.getAccountInstance());
                                            return;
                                        }
                                        if (i == 50) {
                                            ChatActivityEnterView chatActivityEnterView = ChatActivity.this.chatActivityEnterView;
                                            if (chatActivityEnterView == null || chatActivityEnterView.getEditField() == null) {
                                                return;
                                            }
                                            ChatActivity.this.chatActivityEnterView.getEditField().setSelectionOverride(ChatActivity.this.editTextStart, ChatActivity.this.editTextEnd);
                                            ChatActivity.this.chatActivityEnterView.getEditField().makeSelectedBold();
                                            return;
                                        }
                                        if (i == 51) {
                                            ChatActivityEnterView chatActivityEnterView2 = ChatActivity.this.chatActivityEnterView;
                                            if (chatActivityEnterView2 == null || chatActivityEnterView2.getEditField() == null) {
                                                return;
                                            }
                                            ChatActivity.this.chatActivityEnterView.getEditField().setSelectionOverride(ChatActivity.this.editTextStart, ChatActivity.this.editTextEnd);
                                            ChatActivity.this.chatActivityEnterView.getEditField().makeSelectedItalic();
                                            return;
                                        }
                                        if (i == 57) {
                                            ChatActivityEnterView chatActivityEnterView3 = ChatActivity.this.chatActivityEnterView;
                                            if (chatActivityEnterView3 == null || chatActivityEnterView3.getEditField() == null) {
                                                return;
                                            }
                                            ChatActivity.this.chatActivityEnterView.getEditField().setSelectionOverride(ChatActivity.this.editTextStart, ChatActivity.this.editTextEnd);
                                            ChatActivity.this.chatActivityEnterView.getEditField().makeSelectedSpoiler();
                                            return;
                                        }
                                        if (i == 58) {
                                            ChatActivityEnterView chatActivityEnterView4 = ChatActivity.this.chatActivityEnterView;
                                            if (chatActivityEnterView4 == null || chatActivityEnterView4.getEditField() == null) {
                                                return;
                                            }
                                            ChatActivity.this.chatActivityEnterView.getEditField().setSelectionOverride(ChatActivity.this.editTextStart, ChatActivity.this.editTextEnd);
                                            ChatActivity.this.chatActivityEnterView.getEditField().makeSelectedQuote();
                                            return;
                                        }
                                        if (i == 52) {
                                            ChatActivityEnterView chatActivityEnterView5 = ChatActivity.this.chatActivityEnterView;
                                            if (chatActivityEnterView5 == null || chatActivityEnterView5.getEditField() == null) {
                                                return;
                                            }
                                            ChatActivity.this.chatActivityEnterView.getEditField().setSelectionOverride(ChatActivity.this.editTextStart, ChatActivity.this.editTextEnd);
                                            ChatActivity.this.chatActivityEnterView.getEditField().makeSelectedMono();
                                            return;
                                        }
                                        if (i == 55) {
                                            ChatActivityEnterView chatActivityEnterView6 = ChatActivity.this.chatActivityEnterView;
                                            if (chatActivityEnterView6 == null || chatActivityEnterView6.getEditField() == null) {
                                                return;
                                            }
                                            ChatActivity.this.chatActivityEnterView.getEditField().setSelectionOverride(ChatActivity.this.editTextStart, ChatActivity.this.editTextEnd);
                                            ChatActivity.this.chatActivityEnterView.getEditField().makeSelectedStrike();
                                            return;
                                        }
                                        if (i == 56) {
                                            ChatActivityEnterView chatActivityEnterView7 = ChatActivity.this.chatActivityEnterView;
                                            if (chatActivityEnterView7 == null || chatActivityEnterView7.getEditField() == null) {
                                                return;
                                            }
                                            ChatActivity.this.chatActivityEnterView.getEditField().setSelectionOverride(ChatActivity.this.editTextStart, ChatActivity.this.editTextEnd);
                                            ChatActivity.this.chatActivityEnterView.getEditField().makeSelectedUnderline();
                                            return;
                                        }
                                        if (i == 53) {
                                            ChatActivityEnterView chatActivityEnterView8 = ChatActivity.this.chatActivityEnterView;
                                            if (chatActivityEnterView8 == null || chatActivityEnterView8.getEditField() == null) {
                                                return;
                                            }
                                            ChatActivity.this.chatActivityEnterView.getEditField().setSelectionOverride(ChatActivity.this.editTextStart, ChatActivity.this.editTextEnd);
                                            ChatActivity.this.chatActivityEnterView.getEditField().makeSelectedUrl();
                                            return;
                                        }
                                        if (i == 54) {
                                            ChatActivityEnterView chatActivityEnterView9 = ChatActivity.this.chatActivityEnterView;
                                            if (chatActivityEnterView9 == null || chatActivityEnterView9.getEditField() == null) {
                                                return;
                                            }
                                            ChatActivity.this.chatActivityEnterView.getEditField().setSelectionOverride(ChatActivity.this.editTextStart, ChatActivity.this.editTextEnd);
                                            ChatActivity.this.chatActivityEnterView.getEditField().makeSelectedRegular();
                                            return;
                                        }
                                        if (i == 27) {
                                            ChatActivity.this.showChatThemeBottomSheet();
                                            return;
                                        }
                                        if (i == 60) {
                                            TopicsController topicsController = ChatActivity.this.getMessagesController().getTopicsController();
                                            ChatActivity chatActivity14 = ChatActivity.this;
                                            long j8 = chatActivity14.currentChat.id;
                                            int i10 = chatActivity14.forumTopic.id;
                                            ChatActivity.this.forumTopic.closed = true;
                                            topicsController.toggleCloseTopic(j8, i10, true);
                                            ChatActivity.this.updateTopicButtons();
                                            ChatActivity.this.updateBottomOverlay();
                                        } else if (i != 61) {
                                            if (i == 65) {
                                                AndroidUtilities.addToClipboard(ChatActivity.this.businessLink.link);
                                                BulletinFactory.of(LaunchActivity.getLastFragment()).createCopyLinkBulletin().show();
                                                return;
                                            }
                                            if (i == 66) {
                                                Runnable runnable = new Runnable() {
                                                    @Override
                                                    public final void run() {
                                                        ChatActivity.AnonymousClass13.this.lambda$onItemClick$8();
                                                    }
                                                };
                                                if (ChatActivity.this.chatActivityEnterView.businessLinkHasChanges()) {
                                                    ChatActivity.this.showBusinessLinksDiscardAlert(runnable);
                                                    return;
                                                } else {
                                                    runnable.run();
                                                    return;
                                                }
                                            }
                                            if (i == 67) {
                                                Context context2 = ChatActivity.this.getContext();
                                                int i11 = ((BaseFragment) ChatActivity.this).currentAccount;
                                                ChatActivity chatActivity15 = ChatActivity.this;
                                                BusinessLinksActivity.openRenameAlert(context2, i11, chatActivity15.businessLink, ((BaseFragment) chatActivity15).resourceProvider, false);
                                                return;
                                            }
                                            if (i == 68) {
                                                AlertDialog create = new AlertDialog.Builder(ChatActivity.this.getContext(), ChatActivity.this.getResourceProvider()).setTitle(LocaleController.getString(R.string.BusinessLinksDeleteTitle)).setMessage(LocaleController.getString(R.string.BusinessLinksDeleteMessage)).setPositiveButton(LocaleController.getString(R.string.Remove), new AlertDialog.OnButtonClickListener() {
                                                    @Override
                                                    public final void onClick(AlertDialog alertDialog, int i12) {
                                                        ChatActivity.AnonymousClass13.this.lambda$onItemClick$9(alertDialog, i12);
                                                    }
                                                }).setNegativeButton(LocaleController.getString(R.string.Cancel), null).create();
                                                ChatActivity.this.showDialog(create);
                                                TextView textView = (TextView) create.getButton(-1);
                                                if (textView != null) {
                                                    textView.setTextColor(ChatActivity.this.getThemedColor(Theme.key_text_RedBold));
                                                    return;
                                                }
                                                return;
                                            }
                                            return;
                                        }
                                    }
                                    ChatActivity.this.updateTopPanel(true);
                                    return;
                                }
                                sendMessagesHelper = ChatActivity.this.getSendMessagesHelper();
                                j = ChatActivity.this.dialog_id;
                                sendAnimationData = null;
                                z = false;
                                str = "/settings";
                            }
                            sendMessagesHelper.sendMessage(SendMessagesHelper.SendMessageParams.of(str, j, (MessageObject) null, (MessageObject) null, (TLRPC.WebPage) null, false, (ArrayList) null, (TLRPC.ReplyMarkup) null, (HashMap) null, true, 0, sendAnimationData, z));
                            return;
                        }
                        for (int i12 = 0; i12 < 2; i12++) {
                            for (int i13 = 0; i13 < ChatActivity.this.selectedMessagesCanStarIds[i12].size(); i13++) {
                                MessageObject messageObject2 = (MessageObject) ChatActivity.this.selectedMessagesCanStarIds[i12].valueAt(i13);
                                ChatActivity.this.getMediaDataController().addRecentSticker(2, messageObject2, messageObject2.getDocument(), (int) (System.currentTimeMillis() / 1000), !ChatActivity.this.hasUnfavedSelected);
                            }
                        }
                    }
                } else {
                    if (ChatActivity.this.getUserConfig().getClientUserId() == ChatActivity.this.dialog_id) {
                        ChatActivity.this.getMessagesController().setSavedViewAs(true);
                        ChatActivity.this.avatarContainer.openProfile(false, true, true);
                        return;
                    }
                    ChatActivity.this.getMessagesController().getTopicsController().toggleViewForumAsMessages(-ChatActivity.this.dialog_id, false);
                }
                TopicsFragment.prepareToSwitchAnimation(ChatActivity.this);
                return;
            }
            if (!((BaseFragment) ChatActivity.this).actionBar.isActionModeShowed()) {
                if (ChatActivity.this.chatMode == 5 && (ChatActivity.this.messages.isEmpty() || ChatActivity.this.threadMessageId == 0)) {
                    ChatActivity.this.showQuickRepliesRemoveAlert();
                    return;
                }
                if (ChatActivity.this.chatMode == 6 && ChatActivity.this.chatActivityEnterView.businessLinkHasChanges()) {
                    ChatActivity.this.showBusinessLinksDiscardAlert(new Runnable() {
                        @Override
                        public final void run() {
                            ChatActivity.AnonymousClass13.this.lambda$onItemClick$0();
                        }
                    });
                    return;
                } else {
                    if (ChatActivity.this.checkRecordLocked(true)) {
                        return;
                    }
                    ChatActivity.this.lambda$onBackPressed$354();
                    return;
                }
            }
            ChatActivity.this.clearSelectionMode();
        }
    }

    class AnonymousClass131 extends PagerAdapter {
        final SparseIntArray val$cachedHeights;
        final SparseArray val$cachedViews;
        final List val$counters;
        final int val$finalCount;
        final int[] val$foregroundIndex;
        final int val$head;
        final MessageObject val$message;
        final ViewPager val$pager;
        final ActionBarPopupWindow.ActionBarPopupWindowLayout val$popupLayout;
        final MessageObject val$primaryMessage;
        final ReactedHeaderView val$reactedView;
        final boolean val$showAllReactionsTab;
        final int val$size;

        AnonymousClass131(int i, SparseArray sparseArray, boolean z, List list, MessageObject messageObject, ReactedHeaderView reactedHeaderView, MessageObject messageObject2, SparseIntArray sparseIntArray, int i2, ViewPager viewPager, ActionBarPopupWindow.ActionBarPopupWindowLayout actionBarPopupWindowLayout, int[] iArr, int i3) {
            this.val$size = i;
            this.val$cachedViews = sparseArray;
            this.val$showAllReactionsTab = z;
            this.val$counters = list;
            this.val$message = messageObject;
            this.val$reactedView = reactedHeaderView;
            this.val$primaryMessage = messageObject2;
            this.val$cachedHeights = sparseIntArray;
            this.val$head = i2;
            this.val$pager = viewPager;
            this.val$popupLayout = actionBarPopupWindowLayout;
            this.val$foregroundIndex = iArr;
            this.val$finalCount = i3;
        }

        public void lambda$instantiateItem$0(ReactedUsersListView reactedUsersListView, ArrayList arrayList) {
            ChatActivity chatActivity = ChatActivity.this;
            EmojiPacksAlert emojiPacksAlert = new EmojiPacksAlert(chatActivity, chatActivity.getParentActivity(), ChatActivity.this.themeDelegate, arrayList) {
                public void dismiss() {
                    super.dismiss();
                    ChatActivity.this.dimBehindView(false);
                }
            };
            emojiPacksAlert.setCalcMandatoryInsets(ChatActivity.this.isKeyboardVisible());
            emojiPacksAlert.setDimBehind(false);
            ChatActivity.this.closeMenu(false);
            ChatActivity.this.showDialog(emojiPacksAlert);
        }

        public void lambda$instantiateItem$1(MessageObject messageObject, ReactedUsersListView reactedUsersListView, long j, TLRPC.MessagePeerReaction messagePeerReaction) {
            String str;
            Bundle bundle = new Bundle();
            if (j > 0) {
                str = "user_id";
            } else {
                j = -j;
                str = "chat_id";
            }
            bundle.putLong(str, j);
            bundle.putInt("report_reaction_message_id", messageObject.getId());
            bundle.putLong("report_reaction_from_dialog_id", ChatActivity.this.dialog_id);
            ChatActivity.this.presentFragment(new ProfileActivity(bundle));
            ChatActivity.this.closeMenu();
        }

        public static void lambda$instantiateItem$2(SparseIntArray sparseIntArray, int i, int i2, ViewPager viewPager, ActionBarPopupWindow.ActionBarPopupWindowLayout actionBarPopupWindowLayout, int[] iArr, ReactedUsersListView reactedUsersListView, int i3) {
            int i4 = i2 + i3;
            sparseIntArray.put(i, i4);
            if (viewPager.getCurrentItem() == i) {
                actionBarPopupWindowLayout.getSwipeBack().setNewForegroundHeight(iArr[0], i4, true);
            }
        }

        public void destroyItem(ViewGroup viewGroup, int i, Object obj) {
            viewGroup.removeView((View) obj);
        }

        public int getCount() {
            return this.val$size;
        }

        public Object instantiateItem(ViewGroup viewGroup, final int i) {
            View view = (View) this.val$cachedViews.get(i);
            if (view != null) {
                viewGroup.addView(view);
                return view;
            }
            int i2 = this.val$showAllReactionsTab ? i - 1 : i;
            TLRPC.ReactionCount reactionCount = i2 >= 0 ? (TLRPC.ReactionCount) this.val$counters.get(i2) : null;
            Context context = viewGroup.getContext();
            ChatActivity chatActivity = ChatActivity.this;
            ReactedUsersListView onCustomEmojiSelectedListener = new ReactedUsersListView(context, chatActivity.themeDelegate, ((BaseFragment) chatActivity).currentAccount, this.val$message, reactionCount, false, true).setSeenUsers(this.val$reactedView.getSeenUsers()).setOnCustomEmojiSelectedListener(new ReactedUsersListView.OnCustomEmojiSelectedListener() {
                public final void showCustomEmojiAlert(ReactedUsersListView reactedUsersListView, ArrayList arrayList) {
                    ChatActivity.AnonymousClass131.this.lambda$instantiateItem$0(reactedUsersListView, arrayList);
                }
            });
            final MessageObject messageObject = this.val$primaryMessage;
            ReactedUsersListView onProfileSelectedListener = onCustomEmojiSelectedListener.setOnProfileSelectedListener(new ReactedUsersListView.OnProfileSelectedListener() {
                public final void onProfileSelected(ReactedUsersListView reactedUsersListView, long j, TLRPC.MessagePeerReaction messagePeerReaction) {
                    ChatActivity.AnonymousClass131.this.lambda$instantiateItem$1(messageObject, reactedUsersListView, j, messagePeerReaction);
                }
            });
            final SparseIntArray sparseIntArray = this.val$cachedHeights;
            final int i3 = this.val$head;
            final ViewPager viewPager = this.val$pager;
            final ActionBarPopupWindow.ActionBarPopupWindowLayout actionBarPopupWindowLayout = this.val$popupLayout;
            final int[] iArr = this.val$foregroundIndex;
            ReactedUsersListView onHeightChangedListener = onProfileSelectedListener.setOnHeightChangedListener(new ReactedUsersListView.OnHeightChangedListener() {
                public final void onHeightChanged(ReactedUsersListView reactedUsersListView, int i4) {
                    ChatActivity.AnonymousClass131.lambda$instantiateItem$2(sparseIntArray, i, i3, viewPager, actionBarPopupWindowLayout, iArr, reactedUsersListView, i4);
                }
            });
            if (i2 < 0) {
                onHeightChangedListener.setPredictiveCount(this.val$finalCount);
                this.val$reactedView.setSeenCallback(new ChatActivity$$ExternalSyntheticLambda226(onHeightChangedListener));
            }
            viewGroup.addView(onHeightChangedListener);
            this.val$cachedViews.put(i, onHeightChangedListener);
            return onHeightChangedListener;
        }

        public boolean isViewFromObject(View view, Object obj) {
            return view == obj;
        }
    }

    class AnonymousClass14 extends LongPressListenerWithMovingGesture {
        final View val$backButton;

        AnonymousClass14(View view) {
            this.val$backButton = view;
        }

        public void lambda$onLongPress$0() {
            setSubmenu(null);
            ChatActivity chatActivity = ChatActivity.this;
            chatActivity.scrimPopupWindow = null;
            chatActivity.menuDeleteItem = null;
            ChatActivity.this.scrimPopupWindowItems = null;
            ChatActivity.this.chatLayoutManager.setCanScrollVertically(true);
            if (ChatActivity.this.scrimPopupWindowHideDimOnDismiss) {
                ChatActivity.this.dimBehindView(false);
            } else {
                ChatActivity.this.scrimPopupWindowHideDimOnDismiss = true;
            }
            ChatActivityEnterView chatActivityEnterView = ChatActivity.this.chatActivityEnterView;
            if (chatActivityEnterView == null || chatActivityEnterView.getEditField() == null) {
                return;
            }
            ChatActivity.this.chatActivityEnterView.getEditField().setAllowDrawCursor(true);
        }

        @Override
        public void onLongPress() {
            ChatActivity chatActivity = ChatActivity.this;
            chatActivity.scrimPopupWindow = BackButtonMenu.show(chatActivity, this.val$backButton, chatActivity.dialog_id, ChatActivity.this.getTopicId(), ChatActivity.this.themeDelegate);
            ActionBarPopupWindow actionBarPopupWindow = ChatActivity.this.scrimPopupWindow;
            if (actionBarPopupWindow != null) {
                setSubmenu(actionBarPopupWindow);
                ChatActivity.this.scrimPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
                    @Override
                    public final void onDismiss() {
                        ChatActivity.AnonymousClass14.this.lambda$onLongPress$0();
                    }
                });
                ChatActivity.this.chatListView.stopScroll();
                ChatActivity.this.chatLayoutManager.setCanScrollVertically(false);
                ChatActivity.this.dimBehindView(this.val$backButton, 0.3f);
                ChatActivity.this.hideHints(false);
                if (ChatActivity.this.topUndoView != null) {
                    ChatActivity.this.topUndoView.hide(true, 1);
                }
                if (ChatActivity.this.undoView != null) {
                    ChatActivity.this.undoView.hide(true, 1);
                }
                ChatActivityEnterView chatActivityEnterView = ChatActivity.this.chatActivityEnterView;
                if (chatActivityEnterView == null || chatActivityEnterView.getEditField() == null) {
                    return;
                }
                ChatActivity.this.chatActivityEnterView.getEditField().setAllowDrawCursor(false);
            }
        }
    }

    class AnonymousClass151 implements Runnable {
        final boolean val$added;
        final int val$finalMessageIdForCell;
        final boolean val$fromDoubleTap;
        final MessageObject val$primaryMessage;
        final ReactionsContainerLayout val$reactionsLayout;
        final ReactionsLayoutInBubble.VisibleReaction val$visibleReaction;
        final boolean val$withoutAnimation;
        final float val$x;
        final float val$y;

        AnonymousClass151(boolean z, boolean z2, int i, boolean z3, ReactionsContainerLayout reactionsContainerLayout, float f, float f2, ReactionsLayoutInBubble.VisibleReaction visibleReaction, MessageObject messageObject) {
            this.val$withoutAnimation = z;
            this.val$fromDoubleTap = z2;
            this.val$finalMessageIdForCell = i;
            this.val$added = z3;
            this.val$reactionsLayout = reactionsContainerLayout;
            this.val$x = f;
            this.val$y = f2;
            this.val$visibleReaction = visibleReaction;
            this.val$primaryMessage = messageObject;
        }

        public void lambda$run$0(int i, boolean z, ReactionsContainerLayout reactionsContainerLayout, float f, float f2, ReactionsLayoutInBubble.VisibleReaction visibleReaction) {
            BaseCell findMessageCell = ChatActivity.this.findMessageCell(i, true);
            if (z) {
                ChatActivity chatActivity = ChatActivity.this;
                ReactionsEffectOverlay.show(chatActivity, reactionsContainerLayout, findMessageCell, null, f, f2, visibleReaction, ((BaseFragment) chatActivity).currentAccount, 1);
                ReactionsEffectOverlay.startAnimation();
            }
        }

        public void lambda$run$1(final int i, final boolean z, final ReactionsContainerLayout reactionsContainerLayout, final float f, final float f2, final ReactionsLayoutInBubble.VisibleReaction visibleReaction) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.AnonymousClass151.this.lambda$run$0(i, z, reactionsContainerLayout, f, f2, visibleReaction);
                }
            }, 50L);
        }

        public void lambda$run$2(MessageObject messageObject) {
            MessageObject messageObject2 = (MessageObject) ChatActivity.this.messagesDict[0].get(messageObject.getId());
            if (messageObject2 != null && messageObject2 != messageObject) {
                MessageObject messageObject3 = (MessageObject) ChatActivity.this.messagesDict[0].get(messageObject.getId());
                messageObject3.messageOwner.reactions = messageObject.messageOwner.reactions;
                messageObject = messageObject3;
            }
            ChatActivity.this.updateMessageAnimated(messageObject, true);
            ReactionsEffectOverlay.startAnimation();
        }

        @Override
        public void run() {
            if (this.val$withoutAnimation) {
                return;
            }
            ChatActivity chatActivity = ChatActivity.this;
            if (chatActivity.updateReactionRunnable != null) {
                chatActivity.updateReactionRunnable = null;
                if (this.val$fromDoubleTap) {
                    final int i = this.val$finalMessageIdForCell;
                    final boolean z = this.val$added;
                    final ReactionsContainerLayout reactionsContainerLayout = this.val$reactionsLayout;
                    final float f = this.val$x;
                    final float f2 = this.val$y;
                    final ReactionsLayoutInBubble.VisibleReaction visibleReaction = this.val$visibleReaction;
                    chatActivity.lambda$openDiscussionMessageChat$372(new Runnable() {
                        @Override
                        public final void run() {
                            ChatActivity.AnonymousClass151.this.lambda$run$1(i, z, reactionsContainerLayout, f, f2, visibleReaction);
                        }
                    });
                } else {
                    final MessageObject messageObject = this.val$primaryMessage;
                    chatActivity.lambda$openDiscussionMessageChat$372(new Runnable() {
                        @Override
                        public final void run() {
                            ChatActivity.AnonymousClass151.this.lambda$run$2(messageObject);
                        }
                    });
                }
                ChatActivity.this.closeMenu();
            }
        }
    }

    class AnonymousClass153 implements NotificationCenter.NotificationCenterDelegate {
        final ChatActivity val$chatActivity;
        final int val$commentsClassGuid;
        final Runnable val$openCommentsChat;

        AnonymousClass153(int i, Runnable runnable, ChatActivity chatActivity) {
            this.val$commentsClassGuid = i;
            this.val$openCommentsChat = runnable;
            this.val$chatActivity = chatActivity;
        }

        public void didReceivedNotification(final int i, final int i2, final Object... objArr) {
            int i3 = NotificationCenter.messagesDidLoad;
            if (i == i3 && ((Integer) objArr[10]).intValue() == this.val$commentsClassGuid) {
                this.val$openCommentsChat.run();
                final ChatActivity chatActivity = this.val$chatActivity;
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.this.didReceivedNotification(i, i2, objArr);
                    }
                }, 50L);
                NotificationCenter.getInstance(((BaseFragment) ChatActivity.this).currentAccount).removeObserver(this, i3);
            }
        }
    }

    class AnonymousClass154 extends Browser.Progress {
        final ChatMessageCell val$cell;
        final int val$id;
        final CharacterStyle val$span;

        AnonymousClass154(int i, CharacterStyle characterStyle, ChatMessageCell chatMessageCell) {
            this.val$id = i;
            this.val$span = characterStyle;
            this.val$cell = chatMessageCell;
        }

        public void lambda$end$0(int i) {
            if (ChatActivity.this.progressDialogAtMessageId == i) {
                ChatActivity.this.resetProgressDialogLoading();
            }
        }

        public void end(boolean z) {
            if (z) {
                return;
            }
            final int i = this.val$id;
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.AnonymousClass154.this.lambda$end$0(i);
                }
            }, 240L);
        }

        public void init() {
            ChatActivity.this.progressDialogAtMessageId = this.val$id;
            ChatActivity.this.progressDialogAtMessageType = 1;
            ChatActivity.this.progressDialogLinkSpan = this.val$span;
            this.val$cell.invalidate();
        }
    }

    class AnonymousClass155 extends Browser.Progress {
        final ChatMessageCell val$cell;
        final int val$id;

        AnonymousClass155(int i, ChatMessageCell chatMessageCell) {
            this.val$id = i;
            this.val$cell = chatMessageCell;
        }

        public void lambda$end$0(int i) {
            if (ChatActivity.this.progressDialogAtMessageId == i) {
                ChatActivity.this.resetProgressDialogLoading();
            }
        }

        public void end(boolean z) {
            if (z) {
                return;
            }
            final int i = this.val$id;
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.AnonymousClass155.this.lambda$end$0(i);
                }
            }, 240L);
        }

        public void init() {
            ChatActivity.this.progressDialogAtMessageId = this.val$id;
            ChatActivity.this.progressDialogAtMessageType = 6;
            this.val$cell.invalidate();
        }
    }

    class AnonymousClass156 extends Browser.Progress {
        final ChatMessageCell val$cell;
        final int val$id;
        final String val$url;

        AnonymousClass156(int i, String str, ChatMessageCell chatMessageCell) {
            this.val$id = i;
            this.val$url = str;
            this.val$cell = chatMessageCell;
        }

        public void lambda$end$0(int i) {
            if (ChatActivity.this.progressDialogAtMessageId == i) {
                ChatActivity.this.resetProgressDialogLoading();
            }
        }

        public void end(boolean z) {
            if (z) {
                return;
            }
            final int i = this.val$id;
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.AnonymousClass156.this.lambda$end$0(i);
                }
            }, 240L);
        }

        public void init() {
            ChatActivity.this.progressDialogAtMessageId = this.val$id;
            ChatActivity.this.progressDialogAtMessageType = 3;
            ChatActivity.this.progressDialogBotButtonUrl = this.val$url;
            this.val$cell.invalidate();
        }
    }

    class AnonymousClass157 extends Browser.Progress {
        final ChatMessageCell val$cell;
        final int val$id;

        AnonymousClass157(int i, ChatMessageCell chatMessageCell) {
            this.val$id = i;
            this.val$cell = chatMessageCell;
        }

        public void lambda$end$0(int i) {
            if (ChatActivity.this.progressDialogAtMessageId == i) {
                ChatActivity.this.resetProgressDialogLoading();
            }
        }

        public void end(boolean z) {
            if (z) {
                return;
            }
            final int i = this.val$id;
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.AnonymousClass157.this.lambda$end$0(i);
                }
            }, 240L);
        }

        public void init() {
            ChatActivity.this.progressDialogAtMessageId = this.val$id;
            ChatActivity.this.progressDialogAtMessageType = 5;
            ChatActivity.this.progressDialogBotButtonUrl = null;
            this.val$cell.invalidate();
        }
    }

    class AnonymousClass158 extends AnimatorListenerAdapter {
        int index;
        final Runnable val$callback;
        final ChatActivity val$previousChat;

        AnonymousClass158(ChatActivity chatActivity, Runnable runnable) {
            this.val$previousChat = chatActivity;
            this.val$callback = runnable;
        }

        public void lambda$onAnimationEnd$0() {
            NotificationCenter.getInstance(((BaseFragment) ChatActivity.this).currentAccount).onAnimationFinish(this.index);
        }

        @Override
        public void onAnimationEnd(Animator animator) {
            ChatActivity chatActivity = ChatActivity.this;
            chatActivity.fragmentOpened = true;
            ((BaseFragment) chatActivity).fragmentBeginToShow = true;
            ChatActivity.this.fragmentTransition = null;
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.AnonymousClass158.this.lambda$onAnimationEnd$0();
                }
            }, 32L);
            super.onAnimationEnd(animator);
            ChatActivity.this.contentView.invalidate();
            ChatActivity.this.contentView.setSkipBackgroundDrawing(false);
            ChatActivity.this.toPullingDownTransition = false;
            this.val$previousChat.setTransitionToChatProgress(0.0f);
            this.val$previousChat.setTransitionToChatActivity(null);
            ((BaseFragment) ChatActivity.this).fragmentView.setAlpha(1.0f);
            this.val$callback.run();
            ChatActivity.this.avatarContainer.setTranslationY(0.0f);
            this.val$previousChat.avatarContainer.setTranslationY(0.0f);
            this.val$previousChat.avatarContainer.getAvatarImageView().setTranslationY(0.0f);
            ChatActivity.this.avatarContainer.getAvatarImageView().setScaleX(1.0f);
            ChatActivity.this.avatarContainer.getAvatarImageView().setScaleY(1.0f);
            ChatActivity.this.avatarContainer.getAvatarImageView().setAlpha(1.0f);
            this.val$previousChat.avatarContainer.getAvatarImageView().setScaleX(1.0f);
            this.val$previousChat.avatarContainer.getAvatarImageView().setScaleY(1.0f);
            this.val$previousChat.avatarContainer.getAvatarImageView().setAlpha(1.0f);
            if (this.val$previousChat.pinnedMessageView != null) {
                this.val$previousChat.pinnedMessageView.setAlpha(1.0f);
            }
            if (this.val$previousChat.topChatPanelView != null) {
                this.val$previousChat.topChatPanelView.setAlpha(1.0f);
            }
            if (this.val$previousChat.topChatPanelView2 != null) {
                this.val$previousChat.topChatPanelView2.setAlpha(1.0f);
            }
        }

        @Override
        public void onAnimationStart(Animator animator) {
            super.onAnimationStart(animator);
            this.index = NotificationCenter.getInstance(((BaseFragment) ChatActivity.this).currentAccount).setAnimationInProgress(this.index, (int[]) null);
        }
    }

    class AnonymousClass160 extends AnimatorListenerAdapter {
        int index;
        final Runnable val$callback;
        final boolean val$isOpen;

        AnonymousClass160(boolean z, Runnable runnable) {
            this.val$isOpen = z;
            this.val$callback = runnable;
        }

        public void lambda$onAnimationEnd$0() {
            NotificationCenter.getInstance(((BaseFragment) ChatActivity.this).currentAccount).onAnimationFinish(this.index);
        }

        @Override
        public void onAnimationEnd(Animator animator) {
            ChatActivity chatActivity = ChatActivity.this;
            chatActivity.fragmentOpened = true;
            ((BaseFragment) chatActivity).fragmentBeginToShow = true;
            ChatActivity.this.fragmentTransition = null;
            if (this.val$isOpen) {
                ChatActivity.this.switchingFromTopics = false;
            }
            ((BaseFragment) ChatActivity.this).actionBar.invalidate();
            ChatActivity.this.contentView.invalidate();
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.AnonymousClass160.this.lambda$onAnimationEnd$0();
                }
            }, 32L);
            this.val$callback.run();
        }

        @Override
        public void onAnimationStart(Animator animator) {
            super.onAnimationStart(animator);
            this.index = NotificationCenter.getInstance(((BaseFragment) ChatActivity.this).currentAccount).setAnimationInProgress(this.index, (int[]) null);
        }
    }

    static class AnonymousClass165 {
        static final int[] $SwitchMap$org$telegram$ui$AvatarPreviewer$MenuItem;

        static {
            int[] iArr = new int[AvatarPreviewer.MenuItem.values().length];
            $SwitchMap$org$telegram$ui$AvatarPreviewer$MenuItem = iArr;
            try {
                iArr[AvatarPreviewer.MenuItem.OPEN_PROFILE.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                $SwitchMap$org$telegram$ui$AvatarPreviewer$MenuItem[AvatarPreviewer.MenuItem.MENTION.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                $SwitchMap$org$telegram$ui$AvatarPreviewer$MenuItem[AvatarPreviewer.MenuItem.SEARCH_MESSAGES.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                $SwitchMap$org$telegram$ui$AvatarPreviewer$MenuItem[AvatarPreviewer.MenuItem.OPEN_GROUP.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            try {
                $SwitchMap$org$telegram$ui$AvatarPreviewer$MenuItem[AvatarPreviewer.MenuItem.OPEN_CHANNEL.ordinal()] = 5;
            } catch (NoSuchFieldError unused5) {
            }
            try {
                $SwitchMap$org$telegram$ui$AvatarPreviewer$MenuItem[AvatarPreviewer.MenuItem.SEND_MESSAGE.ordinal()] = 6;
            } catch (NoSuchFieldError unused6) {
            }
        }
    }

    class AnonymousClass17 extends RecyclerListViewInternal {
        private final ArrayList drawCaptionAfter;
        private final ArrayList drawNamesAfter;
        private final ArrayList drawReactionsAfter;
        private final ArrayList drawTimeAfter;
        private final ArrayList drawingGroups;
        private float endTrackingX;
        private boolean ignoreLayout;
        private boolean invalidated;
        int lastH;
        private long lastTrackingAnimationTime;
        private int lastWidth;
        private Paint outlineActionBackgroundDarkenPaint;
        private Paint outlineActionBackgroundPaint;
        private Path path;
        private boolean slidingBeyondMax;
        private FloatValueHolder slidingDrawableVisibilityProgress;
        private SpringAnimation slidingDrawableVisibilitySpring;
        private FloatValueHolder slidingFillProgress;
        private SpringAnimation slidingFillProgressSpring;
        private FloatValueHolder slidingOuterRingProgress;
        private SpringAnimation slidingOuterRingSpring;
        private float springMultiplier;
        private int startedTrackingPointerId;
        private int startedTrackingX;
        private int startedTrackingY;
        private float trackAnimationProgress;
        private boolean wasTrackingVibrate;

        AnonymousClass17(Context context, ThemeDelegate themeDelegate) {
            super(context, themeDelegate);
            this.drawTimeAfter = new ArrayList();
            this.drawNamesAfter = new ArrayList();
            this.drawCaptionAfter = new ArrayList();
            this.drawReactionsAfter = new ArrayList();
            this.drawingGroups = new ArrayList(10);
            this.springMultiplier = 2000.0f;
            this.outlineActionBackgroundPaint = new Paint(1);
            this.outlineActionBackgroundDarkenPaint = new Paint(1);
            this.slidingDrawableVisibilityProgress = new FloatValueHolder(0.0f);
            this.slidingDrawableVisibilitySpring = new SpringAnimation(this.slidingDrawableVisibilityProgress).setMinValue(0.0f).setMaxValue(this.springMultiplier).setSpring(new SpringForce(0.0f).setStiffness(1500.0f).setDampingRatio(1.0f)).addUpdateListener(new DynamicAnimation.OnAnimationUpdateListener() {
                public final void onAnimationUpdate(DynamicAnimation dynamicAnimation, float f, float f2) {
                    ChatActivity.AnonymousClass17.this.lambda$$0(dynamicAnimation, f, f2);
                }
            });
            this.slidingFillProgress = new FloatValueHolder(0.0f);
            this.slidingFillProgressSpring = new SpringAnimation(this.slidingFillProgress).setMinValue(0.0f).setSpring(new SpringForce(0.0f).setStiffness(400.0f).setDampingRatio(0.5f)).addUpdateListener(new DynamicAnimation.OnAnimationUpdateListener() {
                public final void onAnimationUpdate(DynamicAnimation dynamicAnimation, float f, float f2) {
                    ChatActivity.AnonymousClass17.this.lambda$$1(dynamicAnimation, f, f2);
                }
            });
            this.slidingOuterRingProgress = new FloatValueHolder(0.0f);
            this.slidingOuterRingSpring = new SpringAnimation(this.slidingOuterRingProgress).setMinValue(0.0f).setSpring(new SpringForce(0.0f).setStiffness(200.0f).setDampingRatio(1.0f)).addUpdateListener(new DynamicAnimation.OnAnimationUpdateListener() {
                public final void onAnimationUpdate(DynamicAnimation dynamicAnimation, float f, float f2) {
                    ChatActivity.AnonymousClass17.this.lambda$$2(dynamicAnimation, f, f2);
                }
            });
            this.path = new Path();
            this.lastH = 0;
            Paint paint = this.outlineActionBackgroundPaint;
            Paint.Style style = Paint.Style.STROKE;
            paint.setStyle(style);
            Paint paint2 = this.outlineActionBackgroundPaint;
            Paint.Cap cap = Paint.Cap.ROUND;
            paint2.setStrokeCap(cap);
            this.outlineActionBackgroundPaint.setStrokeWidth(AndroidUtilities.dp(2.0f));
            this.outlineActionBackgroundDarkenPaint.setStyle(style);
            this.outlineActionBackgroundDarkenPaint.setStrokeCap(cap);
            this.outlineActionBackgroundDarkenPaint.setStrokeWidth(AndroidUtilities.dp(2.0f));
        }

        private void drawChatBackgroundElements(Canvas canvas) {
            int i;
            int i2;
            int i3;
            float f;
            boolean z;
            int i4;
            int i5;
            MessageObject.GroupedMessages currentMessagesGroup;
            boolean z2;
            int i6;
            ?? r13;
            int childCount = getChildCount();
            MessageObject.GroupedMessages groupedMessages = null;
            int i7 = 0;
            while (true) {
                i = 4;
                i2 = 8;
                i3 = 2;
                f = 0.0f;
                if (i7 >= childCount) {
                    break;
                }
                View childAt = getChildAt(i7);
                if (childAt.getVisibility() != 4 && childAt.getVisibility() != 8) {
                    if (ChatActivity.this.chatAdapter.isBot && (childAt instanceof BotHelpCell)) {
                        float measuredHeight = ((((getMeasuredHeight() - ChatActivity.this.chatListViewPaddingTop) - r4.blurredViewBottomOffset) / 2.0f) - (childAt.getMeasuredHeight() / 2)) + ChatActivity.this.chatListViewPaddingTop;
                        if (!((BotHelpCell) childAt).animating() && !ChatActivity.this.chatListView.fastScrollAnimationRunning) {
                            if (childAt.getTop() > measuredHeight) {
                                childAt.setTranslationY(measuredHeight - childAt.getTop());
                            } else {
                                childAt.setTranslationY(0.0f);
                            }
                        }
                    } else if (childAt instanceof UserInfoCell) {
                        float measuredHeight2 = ((((getMeasuredHeight() - ChatActivity.this.chatListViewPaddingTop) - r5.blurredViewBottomOffset) / 2.0f) - (childAt.getMeasuredHeight() / 2)) + ChatActivity.this.chatListViewPaddingTop;
                        if (!((UserInfoCell) childAt).animating() && !ChatActivity.this.chatListView.fastScrollAnimationRunning) {
                            if (childAt.getTop() > measuredHeight2) {
                                childAt.setTranslationY(measuredHeight2 - childAt.getTop());
                            } else {
                                childAt.setTranslationY(0.0f);
                            }
                        }
                    } else if (childAt instanceof ChatMessageCell) {
                        ChatMessageCell chatMessageCell = (ChatMessageCell) childAt;
                        MessageObject.GroupedMessages currentMessagesGroup2 = chatMessageCell.getCurrentMessagesGroup();
                        if (currentMessagesGroup2 == null || currentMessagesGroup2 != groupedMessages) {
                            MessageObject.GroupedMessagePosition currentPosition = chatMessageCell.getCurrentPosition();
                            MessageBackgroundDrawable backgroundDrawable = chatMessageCell.getBackgroundDrawable();
                            if ((backgroundDrawable.isAnimationInProgress() || chatMessageCell.isDrawingSelectionBackground()) && (currentPosition == null || (currentPosition.flags & 2) != 0)) {
                                if (!chatMessageCell.isHighlighted() && !chatMessageCell.isHighlightedAnimated()) {
                                    int y = (int) chatMessageCell.getY();
                                    canvas.save();
                                    if (currentPosition == null) {
                                        i6 = chatMessageCell.getMeasuredHeight();
                                    } else {
                                        int measuredHeight3 = chatMessageCell.getMeasuredHeight() + y;
                                        long j = 0;
                                        float f2 = 0.0f;
                                        for (int i8 = 0; i8 < childCount; i8++) {
                                            View childAt2 = getChildAt(i8);
                                            if (childAt2 instanceof ChatMessageCell) {
                                                ChatMessageCell chatMessageCell2 = (ChatMessageCell) childAt2;
                                                if (chatMessageCell2.getCurrentMessagesGroup() == currentMessagesGroup2) {
                                                    MessageBackgroundDrawable backgroundDrawable2 = chatMessageCell2.getBackgroundDrawable();
                                                    y = Math.min(y, (int) chatMessageCell2.getY());
                                                    measuredHeight3 = Math.max(measuredHeight3, ((int) chatMessageCell2.getY()) + chatMessageCell2.getMeasuredHeight());
                                                    long lastTouchTime = backgroundDrawable2.getLastTouchTime();
                                                    if (lastTouchTime > j) {
                                                        j = lastTouchTime;
                                                        f = backgroundDrawable2.getTouchX() + chatMessageCell2.getX();
                                                        f2 = backgroundDrawable2.getTouchY() + chatMessageCell2.getY();
                                                    }
                                                }
                                            }
                                        }
                                        backgroundDrawable.setTouchCoordsOverride(f, f2 - y);
                                        i6 = measuredHeight3 - y;
                                    }
                                    int i9 = i6 + y;
                                    canvas.clipRect(0, y, getMeasuredWidth(), i9);
                                    Paint themedPaint = getThemedPaint("paintChatMessageBackgroundSelected");
                                    ThemeDelegate themeDelegate = ChatActivity.this.themeDelegate;
                                    if (themeDelegate == null || themeDelegate.isDark || themedPaint == null) {
                                        backgroundDrawable.setCustomPaint((Paint) null);
                                        backgroundDrawable.setColor(getThemedColor(Theme.key_chat_selectedBackground));
                                    } else {
                                        backgroundDrawable.setCustomPaint(themedPaint);
                                        float top = (ChatActivity.this.isKeyboardVisible() ? ChatActivity.this.chatListView.getTop() : ((BaseFragment) ChatActivity.this).actionBar.getMeasuredHeight()) - ChatActivity.this.contentView.getBackgroundTranslationY();
                                        int backgroundSizeY = ChatActivity.this.contentView.getBackgroundSizeY();
                                        ThemeDelegate themeDelegate2 = ChatActivity.this.themeDelegate;
                                        if (themeDelegate2 != null) {
                                            themeDelegate2.applyServiceShaderMatrix(getMeasuredWidth(), backgroundSizeY, chatMessageCell.getX(), top);
                                        } else {
                                            Theme.applyServiceShaderMatrix(getMeasuredWidth(), backgroundSizeY, chatMessageCell.getX(), top);
                                        }
                                    }
                                    backgroundDrawable.setBounds(0, y, getMeasuredWidth(), i9);
                                    backgroundDrawable.draw(canvas);
                                    canvas.restore();
                                } else if (currentPosition == null) {
                                    Paint themedPaint2 = getThemedPaint("paintChatMessageBackgroundSelected");
                                    ThemeDelegate themeDelegate3 = ChatActivity.this.themeDelegate;
                                    if ((themeDelegate3 == null || !themeDelegate3.isDark) && themedPaint2 != null) {
                                        float top2 = (ChatActivity.this.isKeyboardVisible() ? ChatActivity.this.chatListView.getTop() : ((BaseFragment) ChatActivity.this).actionBar.getMeasuredHeight()) - ChatActivity.this.contentView.getBackgroundTranslationY();
                                        int backgroundSizeY2 = ChatActivity.this.contentView.getBackgroundSizeY();
                                        ThemeDelegate themeDelegate4 = ChatActivity.this.themeDelegate;
                                        if (themeDelegate4 != null) {
                                            themeDelegate4.applyServiceShaderMatrix(getMeasuredWidth(), backgroundSizeY2, chatMessageCell.getX(), top2);
                                        } else {
                                            Theme.applyServiceShaderMatrix(getMeasuredWidth(), backgroundSizeY2, chatMessageCell.getX(), top2);
                                        }
                                    } else {
                                        themedPaint2 = Theme.chat_replyLinePaint;
                                        themedPaint2.setColor(getThemedColor(Theme.key_chat_selectedBackground));
                                    }
                                    Paint paint = themedPaint2;
                                    canvas.save();
                                    canvas.translate(0.0f, chatMessageCell.getTranslationY());
                                    int alpha = paint.getAlpha();
                                    paint.setAlpha((int) (alpha * chatMessageCell.getHighlightAlpha() * chatMessageCell.getAlpha()));
                                    z2 = true;
                                    canvas.drawRect(0.0f, chatMessageCell.getTop(), getMeasuredWidth(), chatMessageCell.getBottom(), paint);
                                    paint.setAlpha(alpha);
                                    canvas.restore();
                                    groupedMessages = currentMessagesGroup2;
                                    r13 = z2;
                                }
                            }
                            z2 = true;
                            groupedMessages = currentMessagesGroup2;
                            r13 = z2;
                        } else {
                            r13 = 1;
                        }
                        if ((ChatActivity.this.scrimView != chatMessageCell || ChatActivity.this.scrimViewTask != null) && currentMessagesGroup2 == null && chatMessageCell.drawBackgroundInParent()) {
                            canvas.save();
                            canvas.translate(chatMessageCell.getX(), chatMessageCell.getY() + chatMessageCell.getPaddingTop());
                            if (chatMessageCell.getScaleX() != 1.0f) {
                                canvas.scale(chatMessageCell.getScaleX(), chatMessageCell.getScaleY(), chatMessageCell.getPivotX(), chatMessageCell.getHeight() >> r13);
                            }
                            chatMessageCell.drawBackgroundInternal(canvas, r13);
                            canvas.restore();
                        }
                    } else if (childAt instanceof ChatActionCell) {
                        ChatActionCell chatActionCell = (ChatActionCell) childAt;
                        if (chatActionCell.hasGradientService()) {
                            canvas.save();
                            canvas.translate(chatActionCell.getX(), chatActionCell.getY() + chatActionCell.getPaddingTop());
                            canvas.scale(chatActionCell.getScaleX(), chatActionCell.getScaleY(), chatActionCell.getMeasuredWidth() / 2.0f, chatActionCell.getMeasuredHeight() / 2.0f);
                            canvas.translate(ChatActivity.this.getSideMenuWidth() / 2.0f, 0.0f);
                            chatActionCell.drawBackground(canvas, true);
                            chatActionCell.drawReactions(canvas, true, null);
                            canvas.restore();
                        }
                    }
                }
                i7++;
            }
            boolean z3 = true;
            MessageObject.GroupedMessages currentMessagesGroup3 = ChatActivity.this.scrimView instanceof ChatMessageCell ? ((ChatMessageCell) ChatActivity.this.scrimView).getCurrentMessagesGroup() : null;
            int i10 = 0;
            while (i10 < 3) {
                this.drawingGroups.clear();
                if (i10 != i3 || ChatActivity.this.chatListView.isFastScrollAnimationRunning()) {
                    int i11 = 0;
                    while (i11 < childCount) {
                        View childAt3 = ChatActivity.this.chatListView.getChildAt(i11);
                        if (childAt3 instanceof ChatMessageCell) {
                            ChatMessageCell chatMessageCell3 = (ChatMessageCell) childAt3;
                            if (childAt3.getY() <= ChatActivity.this.chatListView.getHeight() && childAt3.getY() + childAt3.getHeight() >= f && chatMessageCell3.getVisibility() != i2 && (currentMessagesGroup = chatMessageCell3.getCurrentMessagesGroup()) != null && ((i10 != 0 || currentMessagesGroup.messages.size() != z3) && ((i10 != z3 || currentMessagesGroup.transitionParams.drawBackgroundForDeletedItems) && ((i10 != 0 || !chatMessageCell3.getMessageObject().deleted) && ((i10 != z3 || chatMessageCell3.getMessageObject().deleted) && ((i10 != i3 || chatMessageCell3.willRemovedAfterAnimation()) && (i10 == i3 || !chatMessageCell3.willRemovedAfterAnimation()))))))) {
                                if (!this.drawingGroups.contains(currentMessagesGroup)) {
                                    MessageObject.GroupedMessages.TransitionParams transitionParams = currentMessagesGroup.transitionParams;
                                    transitionParams.left = 0;
                                    transitionParams.top = 0;
                                    transitionParams.right = 0;
                                    transitionParams.bottom = 0;
                                    transitionParams.pinnedBotton = false;
                                    transitionParams.pinnedTop = false;
                                    transitionParams.cell = chatMessageCell3;
                                    this.drawingGroups.add(currentMessagesGroup);
                                }
                                currentMessagesGroup.transitionParams.pinnedTop = chatMessageCell3.isPinnedTop();
                                currentMessagesGroup.transitionParams.pinnedBotton = chatMessageCell3.isPinnedBottom();
                                int left = chatMessageCell3.getLeft() + chatMessageCell3.getBackgroundDrawableLeft();
                                int left2 = chatMessageCell3.getLeft() + chatMessageCell3.getBackgroundDrawableRight();
                                int top3 = chatMessageCell3.getTop() + chatMessageCell3.getPaddingTop() + chatMessageCell3.getBackgroundDrawableTop();
                                int top4 = chatMessageCell3.getTop() + chatMessageCell3.getPaddingTop() + chatMessageCell3.getBackgroundDrawableBottom();
                                if ((chatMessageCell3.getCurrentPosition().flags & i) == 0) {
                                    top3 -= AndroidUtilities.dp(10.0f);
                                }
                                int i12 = top3;
                                if ((chatMessageCell3.getCurrentPosition().flags & i2) == 0) {
                                    top4 += AndroidUtilities.dp(10.0f);
                                }
                                int i13 = top4;
                                if (chatMessageCell3.willRemovedAfterAnimation()) {
                                    currentMessagesGroup.transitionParams.cell = chatMessageCell3;
                                }
                                MessageObject.GroupedMessages.TransitionParams transitionParams2 = currentMessagesGroup.transitionParams;
                                int i14 = transitionParams2.top;
                                if (i14 == 0 || i12 < i14) {
                                    transitionParams2.top = i12;
                                }
                                int i15 = transitionParams2.bottom;
                                if (i15 == 0 || i13 > i15) {
                                    transitionParams2.bottom = i13;
                                }
                                int i16 = transitionParams2.left;
                                if (i16 == 0 || left < i16) {
                                    transitionParams2.left = left;
                                }
                                int i17 = transitionParams2.right;
                                if (i17 == 0 || left2 > i17) {
                                    transitionParams2.right = left2;
                                }
                            }
                        }
                        i11++;
                        f = 0.0f;
                        i3 = 2;
                    }
                    int i18 = 0;
                    while (i18 < this.drawingGroups.size()) {
                        MessageObject.GroupedMessages groupedMessages2 = (MessageObject.GroupedMessages) this.drawingGroups.get(i18);
                        if (groupedMessages2 == currentMessagesGroup3) {
                            i4 = i10;
                            i5 = i18;
                        } else {
                            float nonAnimationTranslationX = groupedMessages2.transitionParams.cell.getNonAnimationTranslationX(z3);
                            MessageObject.GroupedMessages.TransitionParams transitionParams3 = groupedMessages2.transitionParams;
                            float f3 = transitionParams3.left + nonAnimationTranslationX + transitionParams3.offsetLeft;
                            float f4 = transitionParams3.top + transitionParams3.offsetTop;
                            float f5 = transitionParams3.right + nonAnimationTranslationX + transitionParams3.offsetRight;
                            float f6 = transitionParams3.bottom + transitionParams3.offsetBottom;
                            if (!transitionParams3.backgroundChangeBounds) {
                                f4 += transitionParams3.cell.getTranslationY();
                                f6 += groupedMessages2.transitionParams.cell.getTranslationY();
                            }
                            if (f4 < (ChatActivity.this.chatListViewPaddingTop - r2.chatListViewPaddingVisibleOffset) - AndroidUtilities.dp(20.0f)) {
                                f4 = (ChatActivity.this.chatListViewPaddingTop - r3.chatListViewPaddingVisibleOffset) - AndroidUtilities.dp(20.0f);
                            }
                            float f7 = f4;
                            if (f6 > ChatActivity.this.chatListView.getMeasuredHeight() + AndroidUtilities.dp(20.0f)) {
                                f6 = ChatActivity.this.chatListView.getMeasuredHeight() + AndroidUtilities.dp(20.0f);
                            }
                            float f8 = f6;
                            boolean z4 = (groupedMessages2.transitionParams.cell.getScaleX() == 1.0f && groupedMessages2.transitionParams.cell.getScaleY() == 1.0f) ? false : true;
                            if (z4) {
                                canvas.save();
                                canvas.scale(groupedMessages2.transitionParams.cell.getScaleX(), groupedMessages2.transitionParams.cell.getScaleY(), ((f5 - f3) / 2.0f) + f3, f7 + ((f8 - f7) / 2.0f));
                            }
                            int size = groupedMessages2.messages.size();
                            int i19 = 0;
                            while (true) {
                                if (i19 >= size) {
                                    z = true;
                                    break;
                                }
                                MessageObject messageObject = (MessageObject) groupedMessages2.messages.get(i19);
                                if (ChatActivity.this.selectedMessagesIds[messageObject.getDialogId() == ChatActivity.this.dialog_id ? (char) 0 : (char) 1].indexOfKey(messageObject.getId()) < 0) {
                                    z = false;
                                    break;
                                }
                                i19++;
                            }
                            MessageObject.GroupedMessages.TransitionParams transitionParams4 = groupedMessages2.transitionParams;
                            i4 = i10;
                            i5 = i18;
                            transitionParams4.cell.drawBackground(canvas, (int) f3, (int) f7, (int) f5, (int) f8, transitionParams4.pinnedTop, transitionParams4.pinnedBotton, z, ChatActivity.this.contentView.getKeyboardHeight());
                            MessageObject.GroupedMessages.TransitionParams transitionParams5 = groupedMessages2.transitionParams;
                            transitionParams5.cell = null;
                            transitionParams5.drawCaptionLayout = groupedMessages2.hasCaption;
                            if (z4) {
                                canvas.restore();
                                for (int i20 = 0; i20 < childCount; i20++) {
                                    View childAt4 = ChatActivity.this.chatListView.getChildAt(i20);
                                    if (childAt4 instanceof ChatMessageCell) {
                                        ChatMessageCell chatMessageCell4 = (ChatMessageCell) childAt4;
                                        if (chatMessageCell4.getCurrentMessagesGroup() == groupedMessages2) {
                                            int left3 = chatMessageCell4.getLeft();
                                            int top5 = chatMessageCell4.getTop();
                                            childAt4.setPivotX((f3 - left3) + ((f5 - f3) / 2.0f));
                                            childAt4.setPivotY((f7 - top5) + ((f8 - f7) / 2.0f));
                                        }
                                    }
                                }
                            }
                        }
                        i18 = i5 + 1;
                        i10 = i4;
                        z3 = true;
                    }
                }
                i10++;
                f = 0.0f;
                i3 = 2;
                i2 = 8;
                z3 = true;
                i = 4;
            }
        }

        private void drawChatForegroundElements(Canvas canvas) {
            int size = this.drawTimeAfter.size();
            boolean z = 1;
            boolean z2 = false;
            if (size > 0) {
                for (int i = 0; i < size; i++) {
                    ChatMessageCell chatMessageCell = (ChatMessageCell) this.drawTimeAfter.get(i);
                    canvas.save();
                    canvas.translate(chatMessageCell.getLeft() + chatMessageCell.getNonAnimationTranslationX(false), chatMessageCell.getY() + chatMessageCell.getPaddingTop());
                    chatMessageCell.drawTime(canvas, chatMessageCell.shouldDrawAlphaLayer() ? chatMessageCell.getAlpha() : 1.0f, true);
                    canvas.restore();
                }
                this.drawTimeAfter.clear();
            }
            int size2 = this.drawNamesAfter.size();
            if (size2 > 0) {
                for (int i2 = 0; i2 < size2; i2++) {
                    ChatMessageCell chatMessageCell2 = (ChatMessageCell) this.drawNamesAfter.get(i2);
                    float left = chatMessageCell2.getLeft() + chatMessageCell2.getNonAnimationTranslationX(false);
                    float y = chatMessageCell2.getY() + chatMessageCell2.getPaddingTop();
                    float alpha = chatMessageCell2.shouldDrawAlphaLayer() ? chatMessageCell2.getAlpha() : 1.0f;
                    canvas.save();
                    canvas.translate(left, y);
                    chatMessageCell2.setInvalidatesParent(true);
                    chatMessageCell2.drawNamesLayout(canvas, alpha);
                    chatMessageCell2.setInvalidatesParent(false);
                    canvas.restore();
                }
                this.drawNamesAfter.clear();
            }
            int size3 = this.drawCaptionAfter.size();
            if (size3 > 0) {
                int i3 = 0;
                while (i3 < size3) {
                    ChatMessageCell chatMessageCell3 = (ChatMessageCell) this.drawCaptionAfter.get(i3);
                    boolean z3 = chatMessageCell3.getCurrentPosition() != null && (chatMessageCell3.getCurrentPosition().flags & z) == 0;
                    float alpha2 = chatMessageCell3.shouldDrawAlphaLayer() ? chatMessageCell3.getAlpha() : 1.0f;
                    float left2 = chatMessageCell3.getLeft() + chatMessageCell3.getNonAnimationTranslationX(z2);
                    float y2 = chatMessageCell3.getY() + chatMessageCell3.getPaddingTop();
                    canvas.save();
                    MessageObject.GroupedMessages currentMessagesGroup = chatMessageCell3.getCurrentMessagesGroup();
                    if (currentMessagesGroup != null && currentMessagesGroup.transitionParams.backgroundChangeBounds) {
                        float nonAnimationTranslationX = chatMessageCell3.getNonAnimationTranslationX(z);
                        MessageObject.GroupedMessages.TransitionParams transitionParams = currentMessagesGroup.transitionParams;
                        float f = transitionParams.left + nonAnimationTranslationX + transitionParams.offsetLeft;
                        float f2 = transitionParams.top + transitionParams.offsetTop;
                        float f3 = transitionParams.right + nonAnimationTranslationX + transitionParams.offsetRight;
                        float f4 = transitionParams.bottom + transitionParams.offsetBottom;
                        if (!transitionParams.backgroundChangeBounds) {
                            f2 += chatMessageCell3.getTranslationY();
                            f4 += chatMessageCell3.getTranslationY();
                        }
                        canvas.clipRect(f + AndroidUtilities.dp(8.0f), f2 + AndroidUtilities.dp(8.0f), f3 - AndroidUtilities.dp(8.0f), f4 - AndroidUtilities.dp(8.0f));
                    }
                    if (chatMessageCell3.getTransitionParams().wasDraw) {
                        canvas.translate(left2, y2);
                        chatMessageCell3.setInvalidatesParent(true);
                        chatMessageCell3.drawCaptionLayout(canvas, z3, alpha2);
                        chatMessageCell3.setInvalidatesParent(false);
                    }
                    canvas.restore();
                    i3++;
                    z = 1;
                    z2 = false;
                }
                this.drawCaptionAfter.clear();
            }
            int size4 = this.drawReactionsAfter.size();
            if (size4 > 0) {
                for (int i4 = 0; i4 < size4; i4++) {
                    ChatMessageCell chatMessageCell4 = (ChatMessageCell) this.drawReactionsAfter.get(i4);
                    boolean z4 = chatMessageCell4.getCurrentPosition() != null && (chatMessageCell4.getCurrentPosition().flags & 1) == 0;
                    float alpha3 = chatMessageCell4.shouldDrawAlphaLayer() ? chatMessageCell4.getAlpha() : 1.0f;
                    float left3 = chatMessageCell4.getLeft() + chatMessageCell4.getNonAnimationTranslationX(false);
                    float y3 = chatMessageCell4.getY() + chatMessageCell4.getPaddingTop();
                    canvas.save();
                    MessageObject.GroupedMessages currentMessagesGroup2 = chatMessageCell4.getCurrentMessagesGroup();
                    if (currentMessagesGroup2 != null && currentMessagesGroup2.transitionParams.backgroundChangeBounds) {
                        float nonAnimationTranslationX2 = chatMessageCell4.getNonAnimationTranslationX(true);
                        MessageObject.GroupedMessages.TransitionParams transitionParams2 = currentMessagesGroup2.transitionParams;
                        float f5 = transitionParams2.left + nonAnimationTranslationX2 + transitionParams2.offsetLeft;
                        float f6 = transitionParams2.top + transitionParams2.offsetTop;
                        float f7 = transitionParams2.right + nonAnimationTranslationX2 + transitionParams2.offsetRight;
                        float f8 = transitionParams2.bottom + transitionParams2.offsetBottom;
                        if (!transitionParams2.backgroundChangeBounds) {
                            f6 += chatMessageCell4.getTranslationY();
                            f8 += chatMessageCell4.getTranslationY();
                        }
                        canvas.clipRect(f5 + AndroidUtilities.dp(8.0f), f6 + AndroidUtilities.dp(8.0f), f7 - AndroidUtilities.dp(8.0f), f8 - AndroidUtilities.dp(8.0f));
                    }
                    if (!z4 && chatMessageCell4.getTransitionParams().wasDraw) {
                        canvas.translate(left3, y3);
                        chatMessageCell4.setInvalidatesParent(true);
                        chatMessageCell4.drawReactionsLayout(canvas, alpha3, null);
                        chatMessageCell4.drawCommentLayout(canvas, alpha3);
                        chatMessageCell4.setInvalidatesParent(false);
                    }
                    canvas.restore();
                }
                this.drawReactionsAfter.clear();
            }
        }

        private void drawReplyButton(android.graphics.Canvas r25) {
            throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.AnonymousClass17.drawReplyButton(android.graphics.Canvas):void");
        }

        public void lambda$$0(DynamicAnimation dynamicAnimation, float f, float f2) {
            invalidate();
        }

        public void lambda$$1(DynamicAnimation dynamicAnimation, float f, float f2) {
            invalidate();
        }

        public void lambda$$2(DynamicAnimation dynamicAnimation, float f, float f2) {
            invalidate();
        }

        public void lambda$onTouchEvent$3(ValueAnimator valueAnimator) {
            ChatActivity.this.pullingDownOffset = ((Float) valueAnimator.getAnimatedValue()).floatValue();
            ChatActivity.this.chatListView.invalidate();
        }

        public void lambda$onTouchEvent$4() {
            ChatActivity.this.animateToNextChat();
        }

        public void lambda$onTouchEvent$5(ValueAnimator valueAnimator) {
            ChatActivity.this.pullingDownOffset = ((Float) valueAnimator.getAnimatedValue()).floatValue();
            ChatActivity.this.chatListView.invalidate();
        }

        public void lambda$onTouchEvent$6(ValueAnimator valueAnimator) {
            ChatActivity.this.pullingDownOffset = ((Float) valueAnimator.getAnimatedValue()).floatValue();
            ChatActivity.this.chatListView.invalidate();
        }

        public void lambda$onTouchEvent$7(ValueAnimator valueAnimator) {
            ChatActivity.this.pullingDownOffset = ((Float) valueAnimator.getAnimatedValue()).floatValue();
            ChatActivity.this.chatListView.invalidate();
        }

        private void processTouchEvent(MotionEvent motionEvent) {
            TLRPC.Chat chat;
            if (motionEvent != null) {
                ChatActivity.this.wasManualScroll = true;
            }
            if (motionEvent != null && motionEvent.getAction() == 0 && !ChatActivity.this.startedTrackingSlidingView && !ChatActivity.this.maybeStartTrackingSlidingView && ChatActivity.this.slidingView == null && !((BaseFragment) ChatActivity.this).inPreviewMode) {
                View pressedChildView = getPressedChildView();
                if (pressedChildView instanceof ChatMessageCell) {
                    if (ChatActivity.this.slidingView != null) {
                        ChatActivity.this.slidingView.setSlidingOffset(0.0f);
                    }
                    ChatActivity.this.slidingView = (ChatMessageCell) pressedChildView;
                    MessageObject messageObject = ChatActivity.this.slidingView.getMessageObject();
                    boolean canSendMessageToTopic = ChatActivity.this.canSendMessageToTopic(messageObject);
                    if ((ChatActivity.this.chatMode != 0 && ChatActivity.this.chatMode != 5 && ChatActivity.this.chatMode != 8 && (ChatActivity.this.chatMode != 3 || ChatActivity.this.threadMessageId != ChatActivity.this.getUserConfig().getClientUserId())) || ((ChatActivity.this.threadMessageObjects != null && ChatActivity.this.threadMessageObjects.contains(messageObject)) || ((ChatActivity.this.getMessageType(messageObject) == 1 && (messageObject.getDialogId() == ChatActivity.this.mergeDialogId || messageObject.needDrawBluredPreview())) || ((ChatActivity.this.currentEncryptedChat == null && messageObject.getId() < 0) || ((ChatActivity.this.bottomOverlayChat != null && ChatActivity.this.bottomOverlayChat.getVisibility() == 0 && ((!ChatActivity.this.bottomOverlayChatWaitsReply || !canSendMessageToTopic) && !messageObject.wasJustSent)) || (((chat = ChatActivity.this.currentChat) != null && ((ChatObject.isNotInChat(chat) && !ChatActivity.this.isThreadChat()) || ((ChatObject.isChannel(ChatActivity.this.currentChat) && !ChatObject.canPost(ChatActivity.this.currentChat) && !ChatActivity.this.currentChat.megagroup) || !ChatObject.canSendMessages(ChatActivity.this.currentChat) || (ChatObject.isForum(ChatActivity.this.currentChat) && !canSendMessageToTopic)))) || ChatActivity.this.textSelectionHelper.isInSelectionMode())))))) {
                        ChatActivity.this.slidingView.setSlidingOffset(0.0f);
                        ChatActivity.this.slidingView = null;
                        return;
                    } else {
                        this.startedTrackingPointerId = motionEvent.getPointerId(0);
                        ChatActivity.this.maybeStartTrackingSlidingView = true;
                        this.startedTrackingX = (int) motionEvent.getX();
                        this.startedTrackingY = (int) motionEvent.getY();
                        return;
                    }
                }
                return;
            }
            if (ChatActivity.this.slidingView == null || motionEvent == null || motionEvent.getAction() != 2 || motionEvent.getPointerId(0) != this.startedTrackingPointerId) {
                if (ChatActivity.this.slidingView != null) {
                    if (motionEvent != null) {
                        if (motionEvent.getPointerId(0) != this.startedTrackingPointerId) {
                            return;
                        }
                        if (motionEvent.getAction() != 3 && motionEvent.getAction() != 1 && motionEvent.getAction() != 6) {
                            return;
                        }
                    }
                    if (motionEvent != null && motionEvent.getAction() != 3 && Math.abs(ChatActivity.this.slidingView.getNonAnimationTranslationX(false)) >= AndroidUtilities.dp(50.0f)) {
                        ChatActivity chatActivity = ChatActivity.this;
                        chatActivity.showFieldPanelForReply(chatActivity.slidingView.getMessageObject());
                    }
                    float slidingOffsetX = ChatActivity.this.slidingView.getSlidingOffsetX();
                    this.endTrackingX = slidingOffsetX;
                    if (slidingOffsetX == 0.0f) {
                        ChatActivity.this.slidingView = null;
                    }
                    this.lastTrackingAnimationTime = System.currentTimeMillis();
                    this.trackAnimationProgress = 0.0f;
                    invalidate();
                    ChatActivity.this.maybeStartTrackingSlidingView = false;
                    ChatActivity.this.startedTrackingSlidingView = false;
                    ChatActivity.this.chatLayoutManager.setCanScrollVertically(true);
                    return;
                }
                return;
            }
            int max = Math.max(AndroidUtilities.dp(-80.0f), Math.min(0, (int) (motionEvent.getX() - this.startedTrackingX)));
            int abs = Math.abs(((int) motionEvent.getY()) - this.startedTrackingY);
            if (getScrollState() == 0 && ChatActivity.this.maybeStartTrackingSlidingView && !ChatActivity.this.startedTrackingSlidingView && max <= (-AndroidUtilities.getPixelsInCM(0.4f, true)) && Math.abs(max) / 3 > abs) {
                MotionEvent obtain = MotionEvent.obtain(0L, 0L, 3, 0.0f, 0.0f, 0);
                ChatActivity.this.slidingView.onTouchEvent(obtain);
                super.onInterceptTouchEvent(obtain);
                obtain.recycle();
                ChatActivity.this.chatLayoutManager.setCanScrollVertically(false);
                ChatActivity.this.maybeStartTrackingSlidingView = false;
                ChatActivity.this.startedTrackingSlidingView = true;
                this.startedTrackingX = (int) motionEvent.getX();
                if (getParent() != null) {
                    getParent().requestDisallowInterceptTouchEvent(true);
                    return;
                }
                return;
            }
            if (ChatActivity.this.startedTrackingSlidingView) {
                if (Math.abs(max) < AndroidUtilities.dp(50.0f)) {
                    this.wasTrackingVibrate = false;
                } else if (!this.wasTrackingVibrate) {
                    try {
                        performHapticFeedback(3, 2);
                    } catch (Exception unused) {
                    }
                    this.wasTrackingVibrate = true;
                }
                float f = max;
                ChatActivity.this.slidingView.setSlidingOffset(f);
                MessageObject messageObject2 = ChatActivity.this.slidingView.getMessageObject();
                if (messageObject2.isRoundVideo() || messageObject2.isVideo()) {
                    ChatActivity.this.updateTextureViewPosition(false, false);
                }
                setGroupTranslationX(ChatActivity.this.slidingView, f);
                invalidate();
            }
        }

        private void setGroupTranslationX(ChatMessageCell chatMessageCell, float f) {
            MessageObject.GroupedMessages currentMessagesGroup = chatMessageCell.getCurrentMessagesGroup();
            if (currentMessagesGroup == null) {
                return;
            }
            int childCount = getChildCount();
            for (int i = 0; i < childCount; i++) {
                View childAt = getChildAt(i);
                if (childAt != chatMessageCell && (childAt instanceof ChatMessageCell)) {
                    ChatMessageCell chatMessageCell2 = (ChatMessageCell) childAt;
                    if (chatMessageCell2.getCurrentMessagesGroup() == currentMessagesGroup) {
                        chatMessageCell2.setSlidingOffset(f);
                        chatMessageCell2.invalidate();
                    }
                }
            }
            invalidate();
        }

        private void updateSkeletonColors() {
            boolean z = ColorUtils.calculateLuminance(getThemedColor(Theme.key_windowBackgroundWhite)) <= 0.699999988079071d;
            int i = Theme.key_listSelector;
            int blendARGB = ColorUtils.blendARGB(getThemedColor(i), Color.argb(z ? 33 : 3, 255, 255, 255), z ? 0.9f : 0.5f);
            int alphaComponent = ColorUtils.setAlphaComponent(getThemedColor(i), z ? 24 : ChatActivity.SKELETON_LIGHT_OVERLAY_ALPHA);
            if (ChatActivity.this.skeletonColor1 == alphaComponent && ChatActivity.this.skeletonColor0 == blendARGB) {
                return;
            }
            ChatActivity.this.skeletonColor0 = blendARGB;
            ChatActivity.this.skeletonColor1 = alphaComponent;
            ChatActivity chatActivity = ChatActivity.this;
            ChatActivity chatActivity2 = ChatActivity.this;
            Shader.TileMode tileMode = Shader.TileMode.CLAMP;
            chatActivity.skeletonGradient = new LinearGradient(0.0f, 0.0f, chatActivity2.skeletonGradientWidth = AndroidUtilities.dp(200.0f), 0.0f, new int[]{alphaComponent, blendARGB, blendARGB, alphaComponent}, new float[]{0.0f, 0.4f, 0.6f, 1.0f}, tileMode);
            ChatActivity chatActivity3 = ChatActivity.this;
            chatActivity3.skeletonTotalTranslation = (-chatActivity3.skeletonGradientWidth) * 2;
            ChatActivity.this.skeletonPaint.setShader(ChatActivity.this.skeletonGradient);
            int argb = Color.argb(z ? 43 : 96, 255, 255, 255);
            ChatActivity.this.skeletonOutlineGradient = new LinearGradient(0.0f, 0.0f, ChatActivity.this.skeletonGradientWidth, 0.0f, new int[]{0, argb, argb, 0}, new float[]{0.0f, 0.4f, 0.6f, 1.0f}, tileMode);
            ChatActivity.this.skeletonOutlinePaint.setShader(ChatActivity.this.skeletonOutlineGradient);
        }

        private void updateSkeletonGradient() {
            long elapsedRealtime = SystemClock.elapsedRealtime();
            long abs = Math.abs(ChatActivity.this.skeletonLastUpdateTime - elapsedRealtime);
            if (abs > 17) {
                abs = 16;
            }
            if (abs < 4) {
                abs = 0;
            }
            int width = getWidth();
            ChatActivity.this.skeletonLastUpdateTime = elapsedRealtime;
            ChatActivity.access$18316(ChatActivity.this, (abs * width) / 400.0f);
            if (ChatActivity.this.skeletonTotalTranslation >= width * 2) {
                ChatActivity chatActivity = ChatActivity.this;
                chatActivity.skeletonTotalTranslation = (-chatActivity.skeletonGradientWidth) * 2;
            }
            ChatActivity.this.skeletonMatrix.setTranslate(ChatActivity.this.skeletonTotalTranslation, 0.0f);
            if (ChatActivity.this.skeletonGradient != null) {
                ChatActivity.this.skeletonGradient.setLocalMatrix(ChatActivity.this.skeletonMatrix);
            }
            ChatActivity.this.skeletonOutlineMatrix.setTranslate(ChatActivity.this.skeletonTotalTranslation, 0.0f);
            if (ChatActivity.this.skeletonOutlineGradient != null) {
                ChatActivity.this.skeletonOutlineGradient.setLocalMatrix(ChatActivity.this.skeletonOutlineMatrix);
            }
        }

        protected boolean allowSelectChildAtPosition(View view) {
            if (view == null || !(view.getVisibility() == 4 || view.getVisibility() == 8)) {
                return super.allowSelectChildAtPosition(view);
            }
            return false;
        }

        public AccessibilityNodeInfo createAccessibilityNodeInfo() {
            if (ChatActivity.this.currentEncryptedChat != null) {
                return null;
            }
            return super/*android.view.ViewGroup*/.createAccessibilityNodeInfo();
        }

        protected void dispatchDraw(Canvas canvas) {
            ChatActivity.this.drawLaterRoundProgressCell = null;
            this.invalidated = false;
            canvas.save();
            if (ChatActivity.this.fragmentTransition == null || (ChatActivity.this.fromPullingDownTransition && !ChatActivity.this.toPullingDownTransition)) {
                ChatActivity chatActivity = ChatActivity.this;
                if (!chatActivity.isInsideContainer) {
                    canvas.clipRect(0.0f, (chatActivity.chatListViewPaddingTop - chatActivity.chatListViewPaddingVisibleOffset) - AndroidUtilities.dp(4.0f), getMeasuredWidth(), getMeasuredHeight() - ChatActivity.this.blurredViewBottomOffset);
                }
            }
            ((RecyclerListView) this).selectorRect.setEmpty();
            if (ChatActivity.this.pullingDownOffset != 0.0f) {
                int save = canvas.save();
                float measuredHeight = ChatActivity.this.pullingDownAnimateProgress != 0.0f ? (ChatActivity.this.chatListView.getMeasuredHeight() - ChatActivity.this.pullingDownOffset) * ChatActivity.this.pullingDownAnimateProgress : 0.0f;
                ChatActivity chatActivity2 = ChatActivity.this;
                float f = (-chatActivity2.pullingDownOffset) - measuredHeight;
                chatActivity2.drawingChatListViewYoffset = f;
                canvas.translate(0.0f, f);
                drawChatBackgroundElements(canvas);
                super.dispatchDraw(canvas);
                drawChatForegroundElements(canvas);
                canvas.restoreToCount(save);
            } else {
                drawChatBackgroundElements(canvas);
                super.dispatchDraw(canvas);
                drawChatForegroundElements(canvas);
            }
            canvas.restore();
        }

        public void draw(android.graphics.Canvas r21) {
            throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.AnonymousClass17.draw(android.graphics.Canvas):void");
        }

        public boolean drawChild(android.graphics.Canvas r22, android.view.View r23, long r24) {
            throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.AnonymousClass17.drawChild(android.graphics.Canvas, android.view.View, long):boolean");
        }

        protected void onAttachedToWindow() {
            super.onAttachedToWindow();
            ChatActivity.this.chatListViewAttached = true;
        }

        protected void onChildPressed(View view, float f, float f2, boolean z) {
            MessageObject.GroupedMessages currentMessagesGroup;
            super.onChildPressed(view, f, f2, z);
            if (view instanceof ChatMessageCell) {
                ChatMessageCell chatMessageCell = (ChatMessageCell) view;
                MessageObject messageObject = chatMessageCell.getMessageObject();
                if (messageObject.isMusic() || messageObject.isDocument() || (currentMessagesGroup = chatMessageCell.getCurrentMessagesGroup()) == null) {
                    return;
                }
                int childCount = getChildCount();
                for (int i = 0; i < childCount; i++) {
                    View childAt = getChildAt(i);
                    if (childAt != view && (childAt instanceof ChatMessageCell)) {
                        ChatMessageCell chatMessageCell2 = (ChatMessageCell) childAt;
                        if (chatMessageCell2.getCurrentMessagesGroup() == currentMessagesGroup) {
                            chatMessageCell2.setPressed(z);
                        }
                    }
                }
            }
        }

        protected void onDetachedFromWindow() {
            super.onDetachedFromWindow();
            ChatActivity.this.chatListViewAttached = false;
        }

        public void onDraw(Canvas canvas) {
            float f;
            super/*androidx.recyclerview.widget.RecyclerView*/.onDraw(canvas);
            if (ChatActivity.this.slidingView != null) {
                float slidingOffsetX = ChatActivity.this.slidingView.getSlidingOffsetX();
                if (!ChatActivity.this.maybeStartTrackingSlidingView && !ChatActivity.this.startedTrackingSlidingView && this.endTrackingX != 0.0f && slidingOffsetX != 0.0f) {
                    long currentTimeMillis = System.currentTimeMillis();
                    float f2 = this.trackAnimationProgress + ((currentTimeMillis - this.lastTrackingAnimationTime) / 180.0f);
                    this.trackAnimationProgress = f2;
                    if (f2 > 1.0f) {
                        this.trackAnimationProgress = 1.0f;
                    }
                    this.lastTrackingAnimationTime = currentTimeMillis;
                    float interpolation = this.endTrackingX * (1.0f - AndroidUtilities.decelerateInterpolator.getInterpolation(this.trackAnimationProgress));
                    if (interpolation == 0.0f) {
                        this.endTrackingX = 0.0f;
                    }
                    setGroupTranslationX(ChatActivity.this.slidingView, interpolation);
                    ChatActivity.this.slidingView.setSlidingOffset(interpolation);
                    MessageObject messageObject = ChatActivity.this.slidingView.getMessageObject();
                    if (messageObject.isRoundVideo() || messageObject.isVideo()) {
                        ChatActivity.this.updateTextureViewPosition(false, false);
                    }
                    float f3 = this.trackAnimationProgress;
                    if (f3 == 1.0f || f3 == 0.0f) {
                        ChatActivity.this.slidingView.setSlidingOffset(0.0f);
                        ChatActivity.this.slidingView = null;
                    }
                    invalidate();
                }
                drawReplyButton(canvas);
            }
            if (ChatActivity.this.pullingDownOffset != 0.0f && !ChatActivity.this.isInPreviewMode()) {
                ChatActivity chatActivity = ChatActivity.this;
                if (!chatActivity.isInsideContainer && chatActivity.chatMode != 3 && ChatActivity.this.chatMode != 1) {
                    canvas.save();
                    if (ChatActivity.this.pullingDownAnimateProgress != 0.0f) {
                        f = ((ChatActivity.this.chatListView.getMeasuredHeight() - ChatActivity.this.pullingDownOffset) + (ChatActivity.this.pullingDownAnimateToActivity == null ? 0.0f : ChatActivity.this.pullingDownAnimateToActivity.pullingBottomOffset)) * ChatActivity.this.pullingDownAnimateProgress;
                    } else {
                        f = 0.0f;
                    }
                    canvas.translate(0.0f, (getMeasuredHeight() - ChatActivity.this.blurredViewBottomOffset) - f);
                    if (ChatActivity.this.pullingDownDrawable == null) {
                        ChatActivity chatActivity2 = ChatActivity.this;
                        int i = ((BaseFragment) chatActivity2).currentAccount;
                        ChatActivity chatActivity3 = ChatActivity.this;
                        View view = ((BaseFragment) chatActivity3).fragmentView;
                        long j = chatActivity3.dialog_id;
                        ChatActivity chatActivity4 = ChatActivity.this;
                        chatActivity2.pullingDownDrawable = new ChatPullingDownDrawable(i, view, j, chatActivity4.dialogFolderId, chatActivity4.dialogFilterId, chatActivity4.getTopicId(), ChatActivity.this.themeDelegate);
                        if (ChatActivity.this.nextChannels == null || ChatActivity.this.nextChannels.isEmpty()) {
                            ChatActivity chatActivity5 = ChatActivity.this;
                            boolean z = chatActivity5.isTopic;
                            ChatPullingDownDrawable chatPullingDownDrawable = chatActivity5.pullingDownDrawable;
                            if (z) {
                                chatPullingDownDrawable.updateTopic();
                            } else {
                                chatPullingDownDrawable.updateDialog();
                            }
                        } else {
                            ChatActivity.this.pullingDownDrawable.updateDialog((TLRPC.Chat) ChatActivity.this.nextChannels.get(0));
                        }
                        ChatActivity.this.pullingDownDrawable.onAttach();
                    }
                    ChatActivity.this.pullingDownDrawable.setWidth(getMeasuredWidth() - (ChatActivity.this.isSideMenued() ? AndroidUtilities.dp(64.0f) : 0));
                    float min = Math.min(1.0f, ChatActivity.this.pullingDownOffset / AndroidUtilities.dp(110.0f));
                    canvas.translate(ChatActivity.this.isSideMenued() ? AndroidUtilities.lerp(AndroidUtilities.dp(32.0f), AndroidUtilities.dp(64.0f), ChatActivity.this.getSideMenuAlpha()) : 0.0f, 0.0f);
                    ChatActivity.this.pullingDownDrawable.draw(canvas, ChatActivity.this.chatListView, min, 1.0f - ChatActivity.this.pullingDownAnimateProgress);
                    canvas.restore();
                    if (ChatActivity.this.pullingDownAnimateToActivity != null) {
                        canvas.saveLayerAlpha(0.0f, 0.0f, ChatActivity.this.pullingDownAnimateToActivity.chatListView.getMeasuredWidth(), ChatActivity.this.pullingDownAnimateToActivity.chatListView.getMeasuredHeight(), (int) (ChatActivity.this.pullingDownAnimateProgress * 255.0f), 31);
                        canvas.translate(0.0f, (getMeasuredHeight() - ChatActivity.this.pullingDownOffset) - f);
                        ChatActivity.this.pullingDownAnimateToActivity.chatListView.draw(canvas);
                        canvas.restore();
                        return;
                    }
                    return;
                }
            }
            if (ChatActivity.this.pullingDownDrawable != null) {
                ChatActivity.this.pullingDownDrawable.reset();
            }
        }

        public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
            if (ChatActivity.this.currentEncryptedChat != null) {
                return;
            }
            super/*android.view.ViewGroup*/.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
            AccessibilityNodeInfo.CollectionInfo collectionInfo = accessibilityNodeInfo.getCollectionInfo();
            if (collectionInfo != null) {
                accessibilityNodeInfo.setCollectionInfo(AccessibilityNodeInfo.CollectionInfo.obtain(collectionInfo.getRowCount(), 1, false));
            }
        }

        public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
            ChatActivity.this.textSelectionHelper.checkSelectionCancel(motionEvent);
            if (isFastScrollAnimationRunning()) {
                return false;
            }
            if (ChatActivity.this.quickShareSelectorOverlay != null && ChatActivity.this.quickShareSelectorOverlay.isActive()) {
                return false;
            }
            boolean onInterceptTouchEvent = super.onInterceptTouchEvent(motionEvent);
            if (!((BaseFragment) ChatActivity.this).actionBar.isActionModeShowed() && !ChatActivity.this.isReport()) {
                processTouchEvent(motionEvent);
            }
            return onInterceptTouchEvent;
        }

        protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
            super.onLayout(z, i, i2, i3, i4);
            int i5 = this.lastWidth;
            int i6 = i3 - i;
            if (i5 != i6) {
                if (i5 != 0) {
                    ChatActivity.this.hideHints(false);
                }
                this.lastWidth = i6;
            }
            int measuredHeight = getMeasuredHeight();
            if (this.lastH != measuredHeight) {
                this.ignoreLayout = true;
                if (ChatActivity.this.chatListItemAnimator != null) {
                    ChatActivity.this.chatListItemAnimator.endAnimations();
                }
                ChatActivity.this.chatScrollHelper.cancel();
                this.ignoreLayout = false;
                this.lastH = measuredHeight;
            }
            ChatActivity.this.forceScrollToTop = false;
            if (ChatActivity.this.textSelectionHelper != null && ChatActivity.this.textSelectionHelper.isInSelectionMode()) {
                ChatActivity.this.textSelectionHelper.invalidate();
            }
            ChatActivity.this.isSkeletonVisible();
        }

        protected void onMeasure(int i, int i2) {
            super.onMeasure(i, i2);
        }

        public boolean onTouchEvent(MotionEvent motionEvent) {
            ChatActivity.this.textSelectionHelper.checkSelectionCancel(motionEvent);
            if (motionEvent.getAction() == 0) {
                ChatActivity.this.scrollByTouch = true;
            }
            if (ChatActivity.this.pullingDownOffset != 0.0f && (motionEvent.getAction() == 1 || motionEvent.getAction() == 3)) {
                float min = Math.min(1.0f, ChatActivity.this.pullingDownOffset / AndroidUtilities.dp(110.0f));
                if (motionEvent.getAction() != 1 || min != 1.0f || ChatActivity.this.pullingDownDrawable == null || ChatActivity.this.pullingDownDrawable.emptyStub) {
                    if (ChatActivity.this.pullingDownDrawable == null || !ChatActivity.this.pullingDownDrawable.emptyStub || System.currentTimeMillis() - ChatActivity.this.pullingDownDrawable.lastShowingReleaseTime >= 500 || !ChatActivity.this.pullingDownDrawable.animateSwipeToRelease) {
                        ValueAnimator ofFloat = ValueAnimator.ofFloat(ChatActivity.this.pullingDownOffset, 0.0f);
                        ChatActivity.this.pullingDownBackAnimator = ofFloat;
                        if (ChatActivity.this.pullingDownDrawable != null) {
                            ChatActivity.this.pullingDownDrawable.showBottomPanel(false);
                        }
                        ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                            @Override
                            public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                                ChatActivity.AnonymousClass17.this.lambda$onTouchEvent$7(valueAnimator);
                            }
                        });
                        ofFloat.setDuration(250L);
                        ofFloat.setInterpolator(ChatListItemAnimator.DEFAULT_INTERPOLATOR);
                        ofFloat.start();
                    } else {
                        AnimatorSet animatorSet = new AnimatorSet();
                        ChatActivity.this.pullingDownBackAnimator = animatorSet;
                        if (ChatActivity.this.pullingDownDrawable != null) {
                            ChatActivity.this.pullingDownDrawable.showBottomPanel(false);
                        }
                        ValueAnimator ofFloat2 = ValueAnimator.ofFloat(ChatActivity.this.pullingDownOffset, AndroidUtilities.dp(111.0f));
                        ofFloat2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                            @Override
                            public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                                ChatActivity.AnonymousClass17.this.lambda$onTouchEvent$5(valueAnimator);
                            }
                        });
                        ofFloat2.setDuration(400L);
                        ofFloat2.setInterpolator(CubicBezierInterpolator.DEFAULT);
                        ValueAnimator ofFloat3 = ValueAnimator.ofFloat(AndroidUtilities.dp(111.0f), 0.0f);
                        ofFloat3.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                            @Override
                            public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                                ChatActivity.AnonymousClass17.this.lambda$onTouchEvent$6(valueAnimator);
                            }
                        });
                        ofFloat3.setStartDelay(600L);
                        ofFloat3.setDuration(250L);
                        ofFloat3.setInterpolator(ChatListItemAnimator.DEFAULT_INTERPOLATOR);
                        animatorSet.playSequentially(ofFloat2, ofFloat3);
                        animatorSet.start();
                    }
                } else if (ChatActivity.this.pullingDownDrawable.animationIsRunning()) {
                    ValueAnimator ofFloat4 = ValueAnimator.ofFloat(ChatActivity.this.pullingDownOffset, ChatActivity.this.pullingDownOffset + AndroidUtilities.dp(8.0f));
                    ChatActivity.this.pullingDownBackAnimator = ofFloat4;
                    ofFloat4.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                        @Override
                        public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                            ChatActivity.AnonymousClass17.this.lambda$onTouchEvent$3(valueAnimator);
                        }
                    });
                    ofFloat4.setDuration(200L);
                    ofFloat4.setInterpolator(CubicBezierInterpolator.DEFAULT);
                    ofFloat4.start();
                    ChatActivity.this.pullingDownDrawable.runOnAnimationFinish(new Runnable() {
                        @Override
                        public final void run() {
                            ChatActivity.AnonymousClass17.this.lambda$onTouchEvent$4();
                        }
                    });
                } else {
                    ChatActivity.this.animateToNextChat();
                }
            }
            if (isFastScrollAnimationRunning()) {
                return false;
            }
            boolean onTouchEvent = super.onTouchEvent(motionEvent);
            if (((BaseFragment) ChatActivity.this).actionBar.isActionModeShowed() || ChatActivity.this.isReport()) {
                return onTouchEvent;
            }
            processTouchEvent(motionEvent);
            return ChatActivity.this.startedTrackingSlidingView || onTouchEvent;
        }

        public boolean requestChildRectangleOnScreen(View view, Rect rect, boolean z) {
            if (ChatActivity.this.scrimPopupWindow != null) {
                return false;
            }
            return super/*androidx.recyclerview.widget.RecyclerView*/.requestChildRectangleOnScreen(view, rect, z);
        }

        public void requestDisallowInterceptTouchEvent(boolean z) {
            super/*androidx.recyclerview.widget.RecyclerView*/.requestDisallowInterceptTouchEvent(z);
            if (ChatActivity.this.slidingView != null) {
                processTouchEvent(null);
            }
        }

        public void requestLayout() {
            if (this.ignoreLayout) {
                return;
            }
            super.requestLayout();
        }

        public void setItemAnimator(RecyclerView.ItemAnimator itemAnimator) {
            if (isFastScrollAnimationRunning()) {
                return;
            }
            super/*androidx.recyclerview.widget.RecyclerView*/.setItemAnimator(itemAnimator);
        }

        public void setTranslationY(float f) {
            BotCommandsMenuContainer botCommandsMenuContainer;
            FrameLayout frameLayout;
            float f2;
            if (f != getTranslationY()) {
                super.setTranslationY(f);
                if (ChatActivity.this.emptyViewContainer != null) {
                    ChatActivityEnterView chatActivityEnterView = ChatActivity.this.chatActivityEnterView;
                    if (chatActivityEnterView == null || !(chatActivityEnterView.panelAnimationInProgress() || ChatObject.isMonoForum(ChatActivity.this.currentChat))) {
                        frameLayout = ChatActivity.this.emptyViewContainer;
                        f2 = 1.7f;
                    } else {
                        frameLayout = ChatActivity.this.emptyViewContainer;
                        f2 = 2.0f;
                    }
                    frameLayout.setTranslationY(f / f2);
                }
                ChatActivityEnterView chatActivityEnterView2 = ChatActivity.this.chatActivityEnterView;
                if (chatActivityEnterView2 != null && (botCommandsMenuContainer = chatActivityEnterView2.botCommandsMenuContainer) != null) {
                    botCommandsMenuContainer.setTranslationY(f);
                }
                ChatActivity.this.invalidateChatListViewTopPadding();
                ChatActivity.this.invalidateMessagesVisiblePart();
            }
        }
    }

    class AnonymousClass18 extends ChatListItemAnimator {
        Runnable finishRunnable;

        AnonymousClass18(ChatActivity chatActivity, RecyclerListView recyclerListView, Theme.ResourcesProvider resourcesProvider) {
            super(chatActivity, recyclerListView, resourcesProvider);
        }

        public void lambda$endAnimations$1() {
            this.finishRunnable = null;
            if (ChatActivity.this.scrollAnimationIndex != -1) {
                ChatActivity.this.getNotificationCenter().onAnimationFinish(ChatActivity.this.scrollAnimationIndex);
                ChatActivity.this.scrollAnimationIndex = -1;
            }
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("chatItemAnimator enable notifications");
            }
        }

        public void lambda$onAllAnimationsDone$0() {
            this.finishRunnable = null;
            if (ChatActivity.this.scrollAnimationIndex != -1) {
                ChatActivity.this.getNotificationCenter().onAnimationFinish(ChatActivity.this.scrollAnimationIndex);
                ChatActivity.this.scrollAnimationIndex = -1;
            }
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("chatItemAnimator enable notifications");
            }
        }

        public void checkIsRunning() {
            if (ChatActivity.this.scrollAnimationIndex == -1) {
                ChatActivity chatActivity = ChatActivity.this;
                chatActivity.scrollAnimationIndex = chatActivity.getNotificationCenter().setAnimationInProgress(ChatActivity.this.scrollAnimationIndex, ChatActivity.allowedNotificationsDuringChatListAnimations, false);
            }
        }

        public void endAnimations() {
            super.endAnimations();
            Runnable runnable = this.finishRunnable;
            if (runnable != null) {
                AndroidUtilities.cancelRunOnUIThread(runnable);
            }
            Runnable runnable2 = new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.AnonymousClass18.this.lambda$endAnimations$1();
                }
            };
            this.finishRunnable = runnable2;
            AndroidUtilities.runOnUIThread(runnable2);
        }

        protected void onAllAnimationsDone() {
            super.onAllAnimationsDone();
            Runnable runnable = this.finishRunnable;
            if (runnable != null) {
                AndroidUtilities.cancelRunOnUIThread(runnable);
                this.finishRunnable = null;
            }
            Runnable runnable2 = new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.AnonymousClass18.this.lambda$onAllAnimationsDone$0();
                }
            };
            this.finishRunnable = runnable2;
            AndroidUtilities.runOnUIThread(runnable2);
        }

        public void onAnimationStart() {
            ChatActivity chatActivity = ChatActivity.this;
            chatActivity.scrollAnimationIndex = chatActivity.getNotificationCenter().setAnimationInProgress(ChatActivity.this.scrollAnimationIndex, ChatActivity.allowedNotificationsDuringChatListAnimations, false);
            Runnable runnable = this.finishRunnable;
            if (runnable != null) {
                AndroidUtilities.cancelRunOnUIThread(runnable);
                this.finishRunnable = null;
            }
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("chatItemAnimator disable notifications");
            }
            ChatActivity.this.chatActivityEnterView.getAdjustPanLayoutHelper().runDelayedAnimation();
            ChatActivity.this.chatActivityEnterView.runEmojiPanelAnimation();
        }
    }

    class AnonymousClass19 extends GridLayoutManagerFixed {
        boolean computingScroll;

        AnonymousClass19(Context context, int i, int i2, boolean z) {
            super(context, i, i2, z);
        }

        public void lambda$onLayoutChildren$0() {
            ChatActivity.this.chatAdapter.notifyDataSetChanged(false);
        }

        public int computeVerticalScrollExtent(RecyclerView.State state) {
            this.computingScroll = true;
            int computeVerticalScrollExtent = super/*androidx.recyclerview.widget.LinearLayoutManager*/.computeVerticalScrollExtent(state);
            this.computingScroll = false;
            return computeVerticalScrollExtent;
        }

        public int computeVerticalScrollOffset(RecyclerView.State state) {
            this.computingScroll = true;
            int computeVerticalScrollOffset = super/*androidx.recyclerview.widget.GridLayoutManager*/.computeVerticalScrollOffset(state);
            this.computingScroll = false;
            return computeVerticalScrollOffset;
        }

        public int computeVerticalScrollRange(RecyclerView.State state) {
            this.computingScroll = true;
            int computeVerticalScrollRange = super/*androidx.recyclerview.widget.GridLayoutManager*/.computeVerticalScrollRange(state);
            this.computingScroll = false;
            return computeVerticalScrollRange;
        }

        protected int getParentStart() {
            if (this.computingScroll) {
                return (int) ChatActivity.this.chatListViewPaddingTop;
            }
            return 0;
        }

        public int getStartAfterPadding() {
            return this.computingScroll ? (int) ChatActivity.this.chatListViewPaddingTop : super/*androidx.recyclerview.widget.RecyclerView.LayoutManager*/.getStartAfterPadding();
        }

        public int getStartForFixGap() {
            return (int) ChatActivity.this.chatListViewPaddingTop;
        }

        public int getTotalSpace() {
            return this.computingScroll ? (int) ((getHeight() - ChatActivity.this.chatListViewPaddingTop) - getPaddingBottom()) : super/*androidx.recyclerview.widget.RecyclerView.LayoutManager*/.getTotalSpace();
        }

        protected boolean hasSiblingChild(int i) {
            int i2;
            MessageObject messageObject;
            MessageObject.GroupedMessages validGroupedMessage;
            byte b;
            if (i >= ChatActivity.this.chatAdapter.messagesStartRow && i < ChatActivity.this.chatAdapter.messagesEndRow && (i2 = i - ChatActivity.this.chatAdapter.messagesStartRow) >= 0 && i2 < ChatActivity.this.chatAdapter.getMessages().size() && (validGroupedMessage = ChatActivity.this.getValidGroupedMessage((messageObject = (MessageObject) ChatActivity.this.chatAdapter.getMessages().get(i2)))) != null) {
                MessageObject.GroupedMessagePosition position = validGroupedMessage.getPosition(messageObject);
                if (position.minX != position.maxX && (b = position.minY) == position.maxY && b != 0) {
                    int size = validGroupedMessage.posArray.size();
                    for (int i3 = 0; i3 < size; i3++) {
                        MessageObject.GroupedMessagePosition groupedMessagePosition = (MessageObject.GroupedMessagePosition) validGroupedMessage.posArray.get(i3);
                        if (groupedMessagePosition != position) {
                            byte b2 = groupedMessagePosition.minY;
                            byte b3 = position.minY;
                            if (b2 <= b3 && groupedMessagePosition.maxY >= b3) {
                                return true;
                            }
                        }
                    }
                }
            }
            return false;
        }

        public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
            if (BuildVars.DEBUG_PRIVATE_VERSION) {
                super/*androidx.recyclerview.widget.GridLayoutManager*/.onLayoutChildren(recycler, state);
                return;
            }
            try {
                super/*androidx.recyclerview.widget.GridLayoutManager*/.onLayoutChildren(recycler, state);
            } catch (Exception e) {
                FileLog.e(e);
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.AnonymousClass19.this.lambda$onLayoutChildren$0();
                    }
                });
            }
        }

        public void scrollToPositionWithOffset(int i, int i2, boolean z) {
            if (!z) {
                i2 = (int) ((i2 - getPaddingTop()) + ChatActivity.this.chatListViewPaddingTop);
            }
            super/*androidx.recyclerview.widget.LinearLayoutManager*/.scrollToPositionWithOffset(i, i2, z);
        }

        public int scrollVerticallyBy(int i, RecyclerView.Recycler recycler, RecyclerView.State state) {
            int i2;
            boolean z;
            float f;
            float f2;
            float f3;
            boolean z2 = false;
            if (i < 0 && ChatActivity.this.pullingDownOffset != 0.0f) {
                ChatActivity.access$15416(ChatActivity.this, i);
                if (ChatActivity.this.pullingDownOffset < 0.0f) {
                    i = (int) ChatActivity.this.pullingDownOffset;
                    ChatActivity.this.pullingDownOffset = 0.0f;
                    ChatActivity.this.chatListView.invalidate();
                } else {
                    i = 0;
                }
            }
            int childCount = ChatActivity.this.chatListView.getChildCount();
            int i3 = 0;
            while (true) {
                if (i3 >= childCount) {
                    i2 = 0;
                    z = false;
                    break;
                }
                View childAt = ChatActivity.this.chatListView.getChildAt(i3);
                ChatActivity chatActivity = ChatActivity.this;
                float f4 = chatActivity.chatListViewPaddingTop;
                int childAdapterPosition = chatActivity.chatListView.getChildAdapterPosition(childAt);
                ChatActivity chatActivity2 = ChatActivity.this;
                if (childAdapterPosition == (chatActivity2.reversed ? 0 : chatActivity2.chatAdapter.getItemCount() - 1)) {
                    i2 = super/*androidx.recyclerview.widget.GridLayoutManager*/.scrollVerticallyBy(((float) (childAt.getTop() - i)) > f4 ? (int) (childAt.getTop() - f4) : i, recycler, state);
                    z = true;
                } else {
                    i3++;
                }
            }
            if (!z) {
                i2 = super/*androidx.recyclerview.widget.GridLayoutManager*/.scrollVerticallyBy(i, recycler, state);
            }
            if (i > 0 && i2 == 0 && (((ChatObject.isChannel(ChatActivity.this.currentChat) && !ChatActivity.this.currentChat.megagroup) || ChatActivity.this.isTopic) && ChatActivity.this.chatMode != 3 && ChatActivity.this.chatMode != 1 && ChatActivity.this.chatListView.getScrollState() == 1 && !ChatActivity.this.chatListView.isFastScrollAnimationRunning() && !ChatActivity.this.chatListView.isMultiselect() && !ChatActivity.this.isReport())) {
                if (ChatActivity.this.pullingDownOffset == 0.0f && ChatActivity.this.pullingDownDrawable != null) {
                    if (ChatActivity.this.nextChannels == null || ChatActivity.this.nextChannels.isEmpty()) {
                        ChatActivity chatActivity3 = ChatActivity.this;
                        boolean z3 = chatActivity3.isTopic;
                        ChatPullingDownDrawable chatPullingDownDrawable = chatActivity3.pullingDownDrawable;
                        if (z3) {
                            chatPullingDownDrawable.updateTopic();
                        } else {
                            chatPullingDownDrawable.updateDialog();
                        }
                    } else {
                        ChatActivity.this.pullingDownDrawable.updateDialog((TLRPC.Chat) ChatActivity.this.nextChannels.get(0));
                    }
                }
                if (ChatActivity.this.pullingDownBackAnimator != null) {
                    ChatActivity.this.pullingDownBackAnimator.removeAllListeners();
                    ChatActivity.this.pullingDownBackAnimator.cancel();
                }
                if (ChatActivity.this.pullingDownOffset < AndroidUtilities.dp(110.0f)) {
                    float dp = ChatActivity.this.pullingDownOffset / AndroidUtilities.dp(110.0f);
                    f2 = (1.0f - dp) * 0.65f;
                    f3 = dp * 0.45f;
                } else if (ChatActivity.this.pullingDownOffset < AndroidUtilities.dp(160.0f)) {
                    float dp2 = (ChatActivity.this.pullingDownOffset - AndroidUtilities.dp(110.0f)) / AndroidUtilities.dp(50.0f);
                    f2 = (1.0f - dp2) * 0.45f;
                    f3 = dp2 * 0.05f;
                } else {
                    f = 0.05f;
                    float f5 = i * f;
                    ChatActivity.access$15416(ChatActivity.this, f5);
                    ReactionsEffectOverlay.onScrolled((int) f5);
                    ChatActivity.this.chatListView.invalidate();
                }
                f = f2 + f3;
                float f52 = i * f;
                ChatActivity.access$15416(ChatActivity.this, f52);
                ReactionsEffectOverlay.onScrolled((int) f52);
                ChatActivity.this.chatListView.invalidate();
            }
            if (ChatActivity.this.pullingDownOffset == 0.0f) {
                ChatActivity.this.chatListView.setOverScrollMode(0);
            } else {
                ChatActivity.this.chatListView.setOverScrollMode(2);
            }
            if (ChatActivity.this.pullingDownDrawable != null) {
                ChatPullingDownDrawable chatPullingDownDrawable2 = ChatActivity.this.pullingDownDrawable;
                if (ChatActivity.this.pullingDownOffset > 0.0f && ChatActivity.this.chatListView.getScrollState() == 1) {
                    z2 = true;
                }
                chatPullingDownDrawable2.showBottomPanel(z2);
            }
            return i2;
        }

        public boolean shouldLayoutChildFromOpositeSide(View view) {
            if (view instanceof ChatMessageCell) {
                return !((ChatMessageCell) view).getMessageObject().isOutOwner();
            }
            return false;
        }

        public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int i) {
            ChatActivity.this.scrollByTouch = false;
            LinearSmoothScrollerCustom linearSmoothScrollerCustom = new LinearSmoothScrollerCustom(recyclerView.getContext(), 0);
            linearSmoothScrollerCustom.setTargetPosition(i);
            startSmoothScroll(linearSmoothScrollerCustom);
        }

        public boolean supportsPredictiveItemAnimations() {
            return true;
        }
    }

    class AnonymousClass22 extends RecyclerView.OnScrollListener {
        private boolean scrollUp;
        private float totalDy = 0.0f;
        private final int scrollValue = AndroidUtilities.dp(100.0f);

        AnonymousClass22() {
        }

        public void onScrollStateChanged(androidx.recyclerview.widget.RecyclerView r10, int r11) {
            throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.AnonymousClass22.onScrollStateChanged(androidx.recyclerview.widget.RecyclerView, int):void");
        }

        public void onScrolled(androidx.recyclerview.widget.RecyclerView r8, int r9, int r10) {
            throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.AnonymousClass22.onScrolled(androidx.recyclerview.widget.RecyclerView, int, int):void");
        }
    }

    class AnonymousClass28 implements View.OnClickListener {
        AnonymousClass28() {
        }

        public void lambda$loadLastUnreadMention$0(int i) {
            if (i != 0) {
                ChatActivity.this.scrollToMessageId(i, 0, false, 0, true, 0);
            } else {
                ChatActivity.this.hasAllMentionsLocal = false;
                loadLastUnreadMention();
            }
        }

        public void lambda$loadLastUnreadMention$1(TLObject tLObject, TLRPC.TL_error tL_error, MessagesStorage messagesStorage) {
            TLRPC.messages_Messages messages_messages = (TLRPC.messages_Messages) tLObject;
            if (tL_error == null && !messages_messages.messages.isEmpty()) {
                int i = ((TLRPC.Message) messages_messages.messages.get(0)).id;
                MessageObject messageObject = (MessageObject) ChatActivity.this.messagesDict[0].get(i);
                messagesStorage.markMessageAsMention(ChatActivity.this.dialog_id, i);
                if (messageObject != null) {
                    TLRPC.Message message = messageObject.messageOwner;
                    message.media_unread = true;
                    message.mentioned = true;
                }
                ChatActivity.this.scrollToMessageId(i, 0, false, 0, true, 0);
                return;
            }
            if (messages_messages != null) {
                ChatActivity.this.newMentionsCount = messages_messages.count;
            } else {
                ChatActivity.this.newMentionsCount = 0;
            }
            messagesStorage.resetMentionsCount(ChatActivity.this.dialog_id, ChatActivity.this.getTopicId(), ChatActivity.this.newMentionsCount);
            if (ChatActivity.this.newMentionsCount == 0) {
                ChatActivity.this.hasAllMentionsLocal = true;
                ChatActivity.this.showMentionDownButton(false, true);
            } else {
                ChatActivity.this.mentiondownButtonCounter.setText(String.format("%d", Integer.valueOf(ChatActivity.this.newMentionsCount)));
                loadLastUnreadMention();
            }
        }

        public void lambda$loadLastUnreadMention$2(final MessagesStorage messagesStorage, final TLObject tLObject, final TLRPC.TL_error tL_error) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.AnonymousClass28.this.lambda$loadLastUnreadMention$1(tLObject, tL_error, messagesStorage);
                }
            });
        }

        private void loadLastUnreadMention() {
            ChatActivity.this.wasManualScroll = true;
            if (ChatActivity.this.hasAllMentionsLocal) {
                ChatActivity.this.getMessagesStorage().getUnreadMention(ChatActivity.this.dialog_id, ChatActivity.this.getTopicId(), new MessagesStorage.IntCallback() {
                    public final void run(int i) {
                        ChatActivity.AnonymousClass28.this.lambda$loadLastUnreadMention$0(i);
                    }
                });
                return;
            }
            final MessagesStorage messagesStorage = ChatActivity.this.getMessagesStorage();
            TLRPC.TL_messages_getUnreadMentions tL_messages_getUnreadMentions = new TLRPC.TL_messages_getUnreadMentions();
            tL_messages_getUnreadMentions.peer = ChatActivity.this.getMessagesController().getInputPeer(ChatActivity.this.dialog_id);
            tL_messages_getUnreadMentions.limit = 1;
            ChatActivity chatActivity = ChatActivity.this;
            if (chatActivity.isTopic) {
                tL_messages_getUnreadMentions.top_msg_id = (int) chatActivity.threadMessageId;
                tL_messages_getUnreadMentions.flags |= 1;
            }
            tL_messages_getUnreadMentions.add_offset = ChatActivity.this.newMentionsCount - 1;
            ChatActivity.this.getConnectionsManager().sendRequest(tL_messages_getUnreadMentions, new RequestDelegate() {
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    ChatActivity.AnonymousClass28.this.lambda$loadLastUnreadMention$2(messagesStorage, tLObject, tL_error);
                }
            });
        }

        @Override
        public void onClick(View view) {
            loadLastUnreadMention();
        }
    }

    class AnonymousClass41 extends ChatActivityEnterView {
        int lastContentViewHeight;
        int messageEditTextPredrawHeigth;
        int messageEditTextPredrawScrollY;

        AnonymousClass41(Activity activity, SizeNotifierFrameLayout sizeNotifierFrameLayout, ChatActivity chatActivity, boolean z, Theme.ResourcesProvider resourcesProvider) {
            super(activity, sizeNotifierFrameLayout, chatActivity, z, resourcesProvider);
        }

        public void lambda$checkAnimation$0(ValueAnimator valueAnimator) {
            float floatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
            ((ChatActivityEnterView) this).animatedTop = (int) floatValue;
            View view = ((ChatActivityEnterView) this).topView;
            if (view == null || view.getVisibility() != 0) {
                MentionsContainerView mentionsContainerView = ChatActivity.this.mentionContainer;
                if (mentionsContainerView != null) {
                    mentionsContainerView.setTranslationY(floatValue);
                }
                ChatActivity.this.chatListView.setTranslationY(floatValue);
                ChatActivity.this.invalidateChatListViewTopPadding();
                ChatActivity.this.invalidateMessagesVisiblePart();
            } else {
                ((ChatActivityEnterView) this).topView.setTranslationY(((1.0f - ((ChatActivityEnterView) this).topViewEnterProgress) * r0.getLayoutParams().height) + floatValue);
                View view2 = ((ChatActivityEnterView) this).topLineView;
                if (view2 != null) {
                    view2.setTranslationY(floatValue);
                }
            }
            ((ChatActivityEnterView) this).messageEditTextContainer.invalidate();
            invalidate();
        }

        public void lambda$checkAnimation$1(ValueAnimator valueAnimator) {
            ((ChatActivityEnterView) this).messageEditText.setOffsetY(((Float) valueAnimator.getAnimatedValue()).floatValue());
        }

        public void checkAnimation() {
            throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.AnonymousClass41.checkAnimation():void");
        }

        public boolean dispatchTouchEvent(MotionEvent motionEvent) {
            if (getAlpha() != 1.0f) {
                return false;
            }
            return super/*android.widget.FrameLayout*/.dispatchTouchEvent(motionEvent);
        }

        public void hideTopView(boolean z) {
            super.hideTopView(z);
            if (ChatActivity.this.onHideFieldPanelRunnable != null) {
                AndroidUtilities.runOnUIThread(ChatActivity.this.onHideFieldPanelRunnable);
                ChatActivity.this.onHideFieldPanelRunnable = null;
            }
        }

        public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
            if (getAlpha() != 1.0f) {
                return false;
            }
            return super.onInterceptTouchEvent(motionEvent);
        }

        protected void onLineCountChanged(int i, int i2) {
            ChatActivity chatActivity = ChatActivity.this;
            if (chatActivity.chatActivityEnterView != null) {
                if (chatActivity.chatListView != null) {
                    if (ChatActivity.this.searchExpandProgress > 0.0f) {
                        return;
                    }
                    if (((BaseFragment) ChatActivity.this).actionBar != null && ((BaseFragment) ChatActivity.this).actionBar.isActionModeShowed()) {
                        return;
                    }
                }
                ((ChatActivityEnterView) this).shouldAnimateEditTextWithBounds = true;
                this.messageEditTextPredrawHeigth = ((ChatActivityEnterView) this).messageEditText.getMeasuredHeight();
                this.messageEditTextPredrawScrollY = ((ChatActivityEnterView) this).messageEditText.getScrollY();
                ChatActivity.this.contentView.invalidate();
                ChatActivity chatActivity2 = ChatActivity.this;
                chatActivity2.chatActivityEnterViewAnimateFromTop = chatActivity2.chatActivityEnterView.getBackgroundTop();
                ChatActivity chatActivity3 = ChatActivity.this;
                TopicsTabsView topicsTabsView = chatActivity3.topicsTabs;
                if (topicsTabsView != null) {
                    topicsTabsView.setBottomMargin(chatActivity3.chatActivityEnterView.getHeightWithTopView());
                }
            }
        }

        protected void onMeasure(int i, int i2) {
            super.onMeasure(i, i2);
            if (ChatActivity.this.chatListView != null && ((BaseFragment) ChatActivity.this).actionBar != null && ((BaseFragment) ChatActivity.this).actionBar.isActionModeShowed()) {
                ChatActivity.this.chatListView.setTranslationY(ChatActivity.this.chatActivityEnterView.getMeasuredHeight() - AndroidUtilities.dp(51.0f));
            } else {
                if (ChatActivity.this.chatListView == null || ChatActivity.this.searchExpandProgress <= 0.0f) {
                    return;
                }
                ChatActivity.this.chatListView.setTranslationY(ChatActivity.this.searchExpandProgress * (ChatActivity.this.chatActivityEnterView.getMeasuredHeight() - AndroidUtilities.dp(51.0f)));
            }
        }

        public boolean onTouchEvent(MotionEvent motionEvent) {
            if (getAlpha() != 1.0f) {
                return false;
            }
            return super/*android.widget.FrameLayout*/.onTouchEvent(motionEvent);
        }

        public void openKeyboard() {
            if (ChatActivity.this.forwardingPreviewView != null) {
                return;
            }
            super.openKeyboard();
        }

        protected boolean pannelAnimationEnabled() {
            return ChatActivity.this.openAnimationEnded;
        }
    }

    class AnonymousClass59 extends TopicsTabsView {
        AnonymousClass59(Context context, BaseFragment baseFragment, SizeNotifierFrameLayout sizeNotifierFrameLayout, int i, long j, Theme.ResourcesProvider resourcesProvider) {
            super(context, baseFragment, sizeNotifierFrameLayout, i, j, resourcesProvider);
        }

        public void lambda$updateSidemenuPosition$0(View view) {
            if (!(view instanceof ChatMessageCell)) {
                if (!(view instanceof ChatActionCell)) {
                    if (view instanceof ChatUnreadCell) {
                        ((ChatUnreadCell) view).getTextView().setTranslationX(ChatActivity.this.getSideMenuWidth() / 2.0f);
                        return;
                    }
                    return;
                }
                ChatActionCell chatActionCell = (ChatActionCell) view;
                chatActionCell.isAllChats = ChatActivity.this.isAllChats();
                chatActionCell.isSideMenued = ChatActivity.this.isSideMenued();
                chatActionCell.isSideMenuEnabled = ChatActivity.this.isSideMenuEnabled();
                chatActionCell.sideMenuAlpha = ChatActivity.this.getSideMenuAlpha();
                int sideMenuWidth = ChatActivity.this.getSideMenuWidth();
                if (chatActionCell.sideMenuWidth != sideMenuWidth) {
                    chatActionCell.sideMenuWidth = sideMenuWidth;
                    chatActionCell.invalidate();
                    return;
                }
                return;
            }
            ChatMessageCell chatMessageCell = (ChatMessageCell) view;
            chatMessageCell.isAllChats = ChatActivity.this.isAllChats();
            chatMessageCell.isSideMenued = ChatActivity.this.isSideMenued();
            boolean isSideMenuEnabled = ChatActivity.this.isSideMenuEnabled();
            if (chatMessageCell.isSideMenuEnabled != isSideMenuEnabled) {
                chatMessageCell.isSideMenuEnabled = isSideMenuEnabled;
                int childAdapterPosition = ChatActivity.this.chatListView.getChildAdapterPosition(view);
                chatMessageCell.relayout();
                if (childAdapterPosition >= 0) {
                    ChatActivity.this.chatAdapter.notifyItemChanged(childAdapterPosition);
                }
            }
            chatMessageCell.sideMenuAlpha = ChatActivity.this.getSideMenuAlpha();
            int sideMenuWidth2 = ChatActivity.this.getSideMenuWidth();
            if (chatMessageCell.sideMenuWidth != sideMenuWidth2) {
                chatMessageCell.sideMenuWidth = sideMenuWidth2;
                chatMessageCell.updateTranslation();
                chatMessageCell.invalidate();
            }
        }

        public void updateSidemenuPosition() {
            super.updateSidemenuPosition();
            ChatActivity.this.invalidateChatListViewTopPadding();
            AndroidUtilities.forEachViews(ChatActivity.this.chatListView, new Consumer() {
                public final void accept(Object obj) {
                    ChatActivity.AnonymousClass59.this.lambda$updateSidemenuPosition$0((View) obj);
                }
            });
            if (ChatActivity.this.floatingDateView != null) {
                ChatActivity.this.floatingDateView.setTranslationX(ChatActivity.this.getSideMenuWidth() / 2.0f);
            }
            if (ChatActivity.this.floatingTopicSeparator != null) {
                ChatActivity.this.floatingTopicSeparator.setTranslationX(ChatActivity.this.getSideMenuWidth() / 2.0f);
            }
            if (ChatActivity.this.emptyViewContainer != null) {
                ChatActivity.this.emptyViewContainer.setTranslationX(ChatActivity.this.getSideMenuWidth() / 2.0f);
            }
            if (ChatActivity.this.pendingRequestsDelegate != null) {
                ChatActivity.this.pendingRequestsDelegate.setLeftMargin(ChatActivity.this.getSideMenuWidth());
            }
            if (ChatActivity.this.bizBotButton != null) {
                ChatActivity.this.bizBotButton.setLeftMargin(ChatActivity.this.getSideMenuWidth());
            }
            if (ChatActivity.this.translateButton != null) {
                ChatActivity.this.translateButton.setLeftMargin(ChatActivity.this.getSideMenuWidth());
            }
            if (ChatActivity.this.reportSpamButton != null) {
                ChatActivity.this.reportSpamButton.setTranslationX(ChatActivity.this.getSideMenuWidth() / 2.0f);
            }
            if (ChatActivity.this.addToContactsButton != null) {
                ChatActivity.this.addToContactsButton.setTranslationX(ChatActivity.this.getSideMenuWidth() / 2.0f);
            }
            if (ChatActivity.this.restartTopicButton != null) {
                ChatActivity.this.restartTopicButton.setTranslationX(ChatActivity.this.getSideMenuWidth() / 2.0f);
            }
            if (ChatActivity.this.fragmentContextView != null) {
                ChatActivity.this.fragmentContextView.setLeftMargin(ChatActivity.this.getSideMenuWidth());
            }
            if (ChatActivity.this.fragmentLocationContextView != null) {
                ChatActivity.this.fragmentLocationContextView.setLeftMargin(ChatActivity.this.getSideMenuWidth());
            }
            if (ChatActivity.this.emojiStatusSpamHint != null) {
                ChatActivity.this.emojiStatusSpamHint.setTranslationX(ChatActivity.this.getSideMenuWidth() / 2.0f);
            }
            ChatActivity.this.updateTopPanelSidemenuTranslation();
        }
    }

    class AnonymousClass60 extends ReactionsContainerLayout {
        private boolean firstLayout;
        private int[] loc;
        private ValueAnimator va;

        AnonymousClass60(int i, BaseFragment baseFragment, Context context, int i2, Theme.ResourcesProvider resourcesProvider) {
            super(i, baseFragment, context, i2, resourcesProvider);
            this.loc = new int[2];
            this.firstLayout = true;
        }

        public void lambda$updateBubbleOffset$0(ValueAnimator valueAnimator) {
            setBubbleOffset(((Float) valueAnimator.getAnimatedValue()).floatValue());
            invalidate();
        }

        private void updateBubbleOffset(float f, boolean z) {
            ValueAnimator valueAnimator = this.va;
            if (valueAnimator != null) {
                valueAnimator.cancel();
                this.va = null;
            }
            if (!z) {
                setBubbleOffset(f);
                return;
            }
            ValueAnimator ofFloat = ValueAnimator.ofFloat(((ReactionsContainerLayout) this).bubblesOffset, f);
            this.va = ofFloat;
            ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public final void onAnimationUpdate(ValueAnimator valueAnimator2) {
                    ChatActivity.AnonymousClass60.this.lambda$updateBubbleOffset$0(valueAnimator2);
                }
            });
            this.va.setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT);
            this.va.setDuration(420L);
            this.va.start();
        }

        protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
            super/*android.widget.FrameLayout*/.onLayout(z, i, i2, i3, i4);
            ActionBarMenuItem item = ((BaseFragment) ChatActivity.this).actionBar.createActionMode().getItem(28);
            if (item != null) {
                getLocationInWindow(this.loc);
                float x = getX();
                float width = getWidth() + x;
                item.getLocationInWindow(this.loc);
                float width2 = this.loc[0] + (item.getWidth() / 2.0f);
                int dp = AndroidUtilities.dp(20.0f);
                boolean z2 = LocaleController.isRTL;
                float f = width2 + (dp * (z2 ? -1 : 1));
                updateBubbleOffset(z2 ? f - x : f - width, !this.firstLayout);
                this.firstLayout = false;
            }
        }
    }

    class AnonymousClass68 extends MessagePreviewView {
        AnonymousClass68(Context context, ChatActivity chatActivity, MessagePreviewParams messagePreviewParams, TLRPC.User user, TLRPC.Chat chat, int i, MessagePreviewView.ResourcesDelegate resourcesDelegate, int i2, boolean z) {
            super(context, chatActivity, messagePreviewParams, user, chat, i, resourcesDelegate, i2, z);
        }

        public void lambda$onDismiss$1() {
            ChatActivityEnterView chatActivityEnterView = ChatActivity.this.chatActivityEnterView;
            if (chatActivityEnterView != null) {
                chatActivityEnterView.openKeyboard();
            }
        }

        public void lambda$onFullDismiss$0() {
            ChatActivityEnterView chatActivityEnterView = ChatActivity.this.chatActivityEnterView;
            if (chatActivityEnterView != null) {
                chatActivityEnterView.freezeEmojiView(false);
            }
        }

        protected void onDismiss(boolean z) {
            ChatActivity chatActivity = ChatActivity.this;
            chatActivity.forwardingPreviewView = null;
            chatActivity.checkShowBlur(true);
            ChatActivity chatActivity2 = ChatActivity.this;
            if (chatActivity2.messagePreviewParams != null) {
                if (chatActivity2.replyingQuote == null) {
                    ChatActivity chatActivity3 = ChatActivity.this;
                    chatActivity3.replyingQuote = chatActivity3.messagePreviewParams.quote;
                }
                ChatActivity chatActivity4 = ChatActivity.this;
                if (chatActivity4.messagePreviewParams.quote == null) {
                    chatActivity4.replyingQuote = null;
                }
                if (ChatActivity.this.replyingQuote != null) {
                    ChatActivity.this.replyingQuote.outdated = false;
                    ReplyQuote replyQuote = ChatActivity.this.replyingQuote;
                    ChatActivity chatActivity5 = ChatActivity.this;
                    replyQuote.start = chatActivity5.messagePreviewParams.quoteStart;
                    ReplyQuote replyQuote2 = chatActivity5.replyingQuote;
                    ChatActivity chatActivity6 = ChatActivity.this;
                    replyQuote2.end = chatActivity6.messagePreviewParams.quoteEnd;
                    chatActivity6.replyingQuote.update();
                    if (ChatActivity.this.fieldPanelShown == 2) {
                        ChatActivity chatActivity7 = ChatActivity.this;
                        chatActivity7.showFieldPanelForReplyQuote(chatActivity7.replyingMessageObject, ChatActivity.this.replyingQuote);
                    }
                } else {
                    ArrayList arrayList = new ArrayList();
                    MessagePreviewParams.Messages messages = ChatActivity.this.messagePreviewParams.forwardMessages;
                    if (messages != null) {
                        messages.getSelectedMessages(arrayList);
                    }
                    ChatActivity.this.fallbackFieldPanel();
                }
            }
            ChatActivity.this.forbidForwardingWithDismiss = false;
            if (ChatActivity.this.keyboardWasVisible && z) {
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.AnonymousClass68.this.lambda$onDismiss$1();
                    }
                }, 50L);
                ChatActivity.this.keyboardWasVisible = false;
            }
            AndroidUtilities.requestAdjustResize(ChatActivity.this.getParentActivity(), ((BaseFragment) ChatActivity.this).classGuid);
        }

        protected void onFullDismiss(boolean z) {
            MessagePreviewParams messagePreviewParams = ChatActivity.this.messagePreviewParams;
            if (messagePreviewParams != null) {
                messagePreviewParams.attach((MessagePreviewView) null);
            }
            if (z) {
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.AnonymousClass68.this.lambda$onFullDismiss$0();
                    }
                }, 15L);
            }
        }

        protected void onQuoteSelectedPart() {
            if (ChatActivity.this.replyingQuote != null && ChatActivity.this.replyingQuote.message != null) {
                ChatActivity chatActivity = ChatActivity.this;
                ReplyQuote replyQuote = chatActivity.messagePreviewParams.quote;
                if (replyQuote == null || replyQuote.message == null || chatActivity.replyingQuote.message.getId() == ChatActivity.this.messagePreviewParams.quote.message.getId()) {
                    return;
                }
            }
            ChatActivity chatActivity2 = ChatActivity.this;
            chatActivity2.replyingQuote = chatActivity2.messagePreviewParams.quote;
        }

        protected void removeForward() {
            super.removeForward();
            dismiss(true);
            ChatActivity chatActivity = ChatActivity.this;
            chatActivity.messagePreviewParams.updateForward((ArrayList) null, chatActivity.dialog_id);
            ChatActivity.this.fallbackFieldPanel();
        }

        protected void removeLink() {
            dismiss(true);
            ChatActivity chatActivity = ChatActivity.this;
            chatActivity.foundWebPage = null;
            ChatActivityEnterView chatActivityEnterView = chatActivity.chatActivityEnterView;
            if (chatActivityEnterView != null) {
                chatActivityEnterView.setWebPage((TLRPC.WebPage) null, false);
            }
            ChatActivity chatActivity2 = ChatActivity.this;
            MessagePreviewParams messagePreviewParams = chatActivity2.messagePreviewParams;
            if (messagePreviewParams != null) {
                messagePreviewParams.updateLink(((BaseFragment) chatActivity2).currentAccount, (TLRPC.WebPage) null, (CharSequence) null, ChatActivity.this.replyingMessageObject != ChatActivity.this.threadMessageObject ? ChatActivity.this.replyingMessageObject : null, ChatActivity.this.replyingQuote, ChatActivity.this.editingMessageObject);
            }
            ChatActivity.this.fallbackFieldPanel();
        }

        protected void removeQuote() {
            dismiss(true);
            ChatActivity.this.replyingQuote = null;
            ChatActivity chatActivity = ChatActivity.this;
            chatActivity.showFieldPanelForReply(chatActivity.replyingMessageObject);
        }

        protected void removeReply() {
            dismiss(true);
            ChatActivity.this.replyingMessageObject = null;
            ChatActivity.this.replyingQuote = null;
            ChatActivity chatActivity = ChatActivity.this;
            chatActivity.messagePreviewParams.updateReply((MessageObject) null, (MessageObject.GroupedMessages) null, chatActivity.dialog_id, (ReplyQuote) null);
            ChatActivity.this.fallbackFieldPanel();
        }

        protected void selectAnotherChat(boolean z) {
            int i;
            boolean z2;
            MessagePreviewParams.Messages messages;
            dismiss(false);
            ChatActivity chatActivity = ChatActivity.this;
            if (chatActivity.messagePreviewParams != null) {
                if (!z) {
                    chatActivity.ignoreDraft = true;
                }
                MessagePreviewParams.Messages messages2 = ChatActivity.this.messagePreviewParams.forwardMessages;
                if (messages2 != null) {
                    int size = messages2.messages.size();
                    i = 0;
                    z2 = false;
                    for (int i2 = 0; i2 < size; i2++) {
                        MessageObject messageObject = (MessageObject) ChatActivity.this.messagePreviewParams.forwardMessages.messages.get(i2);
                        if (messageObject.isTodo()) {
                            i = 3;
                        } else if (messageObject.isPoll()) {
                            if (i != 2) {
                                i = messageObject.isPublicPoll() ? 2 : 1;
                            }
                        } else if (messageObject.isInvoice()) {
                            z2 = true;
                        }
                        ChatActivity.this.selectedMessagesIds[0].put(messageObject.getId(), messageObject);
                    }
                } else {
                    i = 0;
                    z2 = false;
                }
                Bundle bundle = new Bundle();
                bundle.putBoolean("onlySelect", true);
                bundle.putInt("dialogsType", 3);
                bundle.putBoolean("quote", !z);
                boolean z3 = (z || (messages = ChatActivity.this.messagePreviewParams.replyMessage) == null || messages.messages.isEmpty() || ChatActivity.this.messagePreviewParams.quote != null) ? false : true;
                bundle.putBoolean("reply_to", z3);
                if (z3) {
                    long peerDialogId = DialogObject.getPeerDialogId(((MessageObject) ChatActivity.this.messagePreviewParams.replyMessage.messages.get(0)).getFromPeer());
                    if (peerDialogId != 0 && peerDialogId != ChatActivity.this.getDialogId() && peerDialogId != ChatActivity.this.getUserConfig().getClientUserId() && peerDialogId > 0) {
                        bundle.putLong("reply_to_author", peerDialogId);
                    }
                }
                bundle.putInt("hasPoll", i);
                bundle.putBoolean("hasInvoice", z2);
                MessagePreviewParams.Messages messages3 = ChatActivity.this.messagePreviewParams.forwardMessages;
                bundle.putInt("messagesCount", messages3 != null ? messages3.messages.size() : 0);
                bundle.putBoolean("canSelectTopics", true);
                DialogsActivity dialogsActivity = new DialogsActivity(bundle);
                dialogsActivity.setDelegate(ChatActivity.this);
                ChatActivity.this.presentFragment(dialogsActivity);
            }
        }
    }

    class AnonymousClass71 extends BlurredFrameLayout {
        float lastY;
        float startY;

        AnonymousClass71(Context context, SizeNotifierFrameLayout sizeNotifierFrameLayout) {
            super(context, sizeNotifierFrameLayout);
            setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public final boolean onLongClick(View view) {
                    boolean lambda$new$0;
                    lambda$new$0 = ChatActivity.AnonymousClass71.this.lambda$new$0(view);
                    return lambda$new$0;
                }
            });
        }

        public boolean lambda$new$0(View view) {
            if (AndroidUtilities.isTablet() || ChatActivity.this.isThreadChat()) {
                return false;
            }
            this.startY = this.lastY;
            ChatActivity.this.openPinnedMessagesList(true);
            return true;
        }

        protected boolean drawChild(android.graphics.Canvas r4, android.view.View r5, long r6) {
            throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.AnonymousClass71.drawChild(android.graphics.Canvas, android.view.View, long):boolean");
        }

        protected void onMeasure(int i, int i2) {
            super/*android.widget.FrameLayout*/.onMeasure(i, i2);
            if (ChatActivity.this.setPinnedTextTranslationX) {
                for (int i3 = 0; i3 < ChatActivity.this.pinnedNextAnimation.length; i3++) {
                    if (ChatActivity.this.pinnedNextAnimation[i3] != null) {
                        ChatActivity.this.pinnedNextAnimation[i3].start();
                    }
                }
                ChatActivity.this.setPinnedTextTranslationX = false;
            }
        }

        public boolean onTouchEvent(MotionEvent motionEvent) {
            this.lastY = motionEvent.getY();
            if (motionEvent.getAction() == 1) {
                ChatActivity.this.finishPreviewFragment();
            } else if (motionEvent.getAction() == 2) {
                float f = this.startY - this.lastY;
                ChatActivity.this.movePreviewFragment(f);
                if (f < 0.0f) {
                    this.startY = this.lastY;
                }
            }
            return super/*android.widget.FrameLayout*/.onTouchEvent(motionEvent);
        }
    }

    class AnonymousClass74 implements ChatActivityDelegate {
        AnonymousClass74() {
        }

        public void lambda$onUnpin$0(boolean z, ArrayList arrayList, ArrayList arrayList2, int i, int i2) {
            if (z) {
                MessagesController.getNotificationsSettings(((BaseFragment) ChatActivity.this).currentAccount).edit().remove("pin_" + ChatActivity.this.dialog_id).commit();
                ChatActivity.this.updatePinnedMessageView(true);
            } else {
                ChatActivity.this.getNotificationCenter().postNotificationName(NotificationCenter.didLoadPinnedMessages, new Object[]{Long.valueOf(ChatActivity.this.dialog_id), arrayList, Boolean.TRUE, arrayList2, null, 0, Integer.valueOf(i), Boolean.valueOf(ChatActivity.this.pinnedEndReached)});
            }
            if (i2 == ChatActivity.this.pinBullerinTag) {
                ChatActivity.this.pinBulletin = null;
            }
        }

        public void lambda$onUnpin$1(boolean z, int i) {
            if (!z) {
                ChatActivity chatActivity = ChatActivity.this;
                if (chatActivity.isTopic) {
                    for (int i2 = 0; i2 < ChatActivity.this.pinnedMessageIds.size(); i2++) {
                        MessagesController messagesController = ChatActivity.this.getMessagesController();
                        ChatActivity chatActivity2 = ChatActivity.this;
                        messagesController.pinMessage(chatActivity2.currentChat, chatActivity2.currentUser, ((Integer) chatActivity2.pinnedMessageIds.get(i2)).intValue(), true, false, false);
                    }
                } else {
                    MessagesController messagesController2 = chatActivity.getMessagesController();
                    ChatActivity chatActivity3 = ChatActivity.this;
                    messagesController2.unpinAllMessages(chatActivity3.currentChat, chatActivity3.currentUser);
                }
            }
            if (i == ChatActivity.this.pinBullerinTag) {
                ChatActivity.this.pinBulletin = null;
            }
        }

        @Override
        public void onUnpin(boolean z, final boolean z2) {
            SharedPreferences.Editor putInt;
            if (!z) {
                MessageObject messageObject = (MessageObject) ChatActivity.this.pinnedMessageObjects.get(Integer.valueOf(ChatActivity.this.currentPinnedMessageId));
                if (messageObject == null) {
                    messageObject = (MessageObject) ChatActivity.this.messagesDict[0].get(ChatActivity.this.currentPinnedMessageId);
                }
                ChatActivity.this.unpinMessage(messageObject);
                return;
            }
            final ArrayList arrayList = new ArrayList(ChatActivity.this.pinnedMessageIds);
            final ArrayList arrayList2 = new ArrayList(ChatActivity.this.pinnedMessageObjects.values());
            ChatActivity chatActivity = ChatActivity.this;
            if (z2) {
                SharedPreferences notificationsSettings = MessagesController.getNotificationsSettings(((BaseFragment) chatActivity).currentAccount);
                boolean isEmpty = ChatActivity.this.pinnedMessageIds.isEmpty();
                SharedPreferences.Editor edit = notificationsSettings.edit();
                if (isEmpty) {
                    putInt = edit.remove("pin_" + ChatActivity.this.dialog_id);
                } else {
                    putInt = edit.putInt("pin_" + ChatActivity.this.dialog_id, ((Integer) ChatActivity.this.pinnedMessageIds.get(0)).intValue());
                }
                putInt.commit();
                ChatActivity.this.updatePinnedMessageView(true);
            } else {
                chatActivity.getNotificationCenter().postNotificationName(NotificationCenter.didLoadPinnedMessages, new Object[]{Long.valueOf(ChatActivity.this.dialog_id), arrayList, Boolean.FALSE, null, null, 0, 0, Boolean.TRUE});
            }
            if (ChatActivity.this.pinBulletin != null) {
                ChatActivity.this.pinBulletin.hide();
            }
            ChatActivity.this.showPinBulletin = true;
            final int access$35804 = ChatActivity.access$35804(ChatActivity.this);
            final int pinnedMessagesCount = ChatActivity.this.getPinnedMessagesCount();
            ChatActivity chatActivity2 = ChatActivity.this;
            chatActivity2.pinBulletin = BulletinFactory.createUnpinAllMessagesBulletin(chatActivity2, pinnedMessagesCount, z2, new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.AnonymousClass74.this.lambda$onUnpin$0(z2, arrayList, arrayList2, pinnedMessagesCount, access$35804);
                }
            }, new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.AnonymousClass74.this.lambda$onUnpin$1(z2, access$35804);
                }
            }, ChatActivity.this.themeDelegate);
        }

        @Override
        public void openHashtagSearch(String str) {
            ChatActivity.this.lambda$openHashtagSearch$358(str);
        }

        @Override
        public void openReplyMessage(int i) {
            ChatActivity.this.scrollToMessageId(i, 0, true, 0, true, 0);
        }
    }

    class AnonymousClass90 extends AnimatorListenerAdapter {
        AnonymousClass90() {
        }

        public void lambda$onAnimationEnd$0() {
            if (ChatActivity.this.gifHintTextView == null) {
                return;
            }
            AnimatorSet animatorSet = new AnimatorSet();
            animatorSet.playTogether(ObjectAnimator.ofFloat(ChatActivity.this.gifHintTextView, (Property<HintView, Float>) View.ALPHA, 0.0f));
            animatorSet.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animator) {
                    if (ChatActivity.this.gifHintTextView != null) {
                        ChatActivity.this.gifHintTextView.setVisibility(8);
                    }
                }
            });
            animatorSet.setDuration(300L);
            animatorSet.start();
        }

        @Override
        public void onAnimationEnd(Animator animator) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.AnonymousClass90.this.lambda$onAnimationEnd$0();
                }
            }, 2000L);
        }
    }

    public class ChatActivityAdapter extends RecyclerAnimationScrollHelper.AnimatableAdapter {
        public boolean filteredEndReached;
        private boolean isBot;
        public boolean isFiltered;
        public boolean isFrozen;
        private Context mContext;
        private int messagesEndRow;
        public int messagesStartRow;
        private int rowCount;
        private int hintRow = -5;
        private int botInfoRow = -5;
        private int botInfoEmptyRow = -5;
        private int userInfoRow = -5;
        private int loadingUpRow = -5;
        private int loadingDownRow = -5;
        private int userPhotoTimeRow = -5;
        private int userNameTimeRow = -5;
        public ArrayList frozenMessages = new ArrayList();
        public ArrayList filteredMessages = new ArrayList();

        class AnonymousClass2 implements ChatActionCell.ChatActionCellDelegate {

            class AnonymousClass1 extends Browser.Progress {
                final ChatActionCell val$cell;

                AnonymousClass1(ChatActionCell chatActionCell) {
                    this.val$cell = chatActionCell;
                }

                public void lambda$end$0(ChatActionCell chatActionCell) {
                    ChatActivity.this.resetProgressDialogLoading();
                    chatActionCell.getMessageObject().flickerLoading = false;
                    chatActionCell.invalidate();
                }

                public void end(boolean z) {
                    if (z) {
                        return;
                    }
                    final ChatActionCell chatActionCell = this.val$cell;
                    AndroidUtilities.runOnUIThread(new Runnable() {
                        @Override
                        public final void run() {
                            ChatActivity.ChatActivityAdapter.AnonymousClass2.AnonymousClass1.this.lambda$end$0(chatActionCell);
                        }
                    }, 250L);
                }

                public void init() {
                    ChatActivity.this.progressDialogAtMessageId = this.val$cell.getMessageObject().getId();
                    ChatActivity.this.progressDialogAtMessageType = 4;
                    ChatActivity.this.progressDialogLinkSpan = null;
                    this.val$cell.getMessageObject().flickerLoading = true;
                    this.val$cell.invalidate();
                }
            }

            class C00112 extends PhotoViewer.EmptyPhotoViewerProvider {
                final MediaController.PhotoEntry val$entry;
                final MessageObject val$message;

                C00112(MessageObject messageObject, MediaController.PhotoEntry photoEntry) {
                    this.val$message = messageObject;
                    this.val$entry = photoEntry;
                }

                public void lambda$sendButtonPressed$1() {
                    Bundle bundle = new Bundle();
                    bundle.putLong("user_id", UserConfig.getInstance(((BaseFragment) ChatActivity.this).currentAccount).clientUserId);
                    ChatActivity.this.presentFragment(new ProfileActivity(bundle));
                }

                public void lambda$sendButtonPressed$2(TLObject tLObject, MessageObject messageObject) {
                    if (tLObject instanceof TLRPC.TL_photos_photo) {
                        TLRPC.TL_photos_photo tL_photos_photo = (TLRPC.TL_photos_photo) tLObject;
                        ChatActivity.this.getMessagesController().putUsers(tL_photos_photo.users, false);
                        TLRPC.User user = ChatActivity.this.getMessagesController().getUser(Long.valueOf(ChatActivity.this.getUserConfig().clientUserId));
                        if ((tL_photos_photo.photo instanceof TLRPC.TL_photo) && user != null) {
                            PhotoUtilities.applyPhotoToUser(messageObject.messageOwner.action.photo, user, false);
                            ChatActivity.this.getUserConfig().setCurrentUser(user);
                            ChatActivity.this.getUserConfig().saveConfig(true);
                            BulletinFactory.of(ChatActivity.this).createUsersBulletin(Collections.singletonList(user), AndroidUtilities.replaceTags(LocaleController.getString(R.string.ApplyAvatarHintTitle)), AndroidUtilities.replaceSingleTag(LocaleController.getString(R.string.ApplyAvatarHint), new Runnable() {
                                @Override
                                public final void run() {
                                    ChatActivity.ChatActivityAdapter.AnonymousClass2.C00112.this.lambda$sendButtonPressed$1();
                                }
                            }), (BulletinFactory.UndoObject) null).show();
                        }
                    }
                    messageObject.settingAvatar = false;
                }

                public void lambda$sendButtonPressed$3(final MessageObject messageObject, final TLObject tLObject, TLRPC.TL_error tL_error) {
                    AndroidUtilities.runOnUIThread(new Runnable() {
                        @Override
                        public final void run() {
                            ChatActivity.ChatActivityAdapter.AnonymousClass2.C00112.this.lambda$sendButtonPressed$2(tLObject, messageObject);
                        }
                    });
                }

                @Override
                public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int i, boolean z, boolean z2) {
                    return ChatActivity.this.photoViewerProvider.getPlaceForPhoto(this.val$message, fileLocation, i, z, false);
                }

                @Override
                public void sendButtonPressed(int i, VideoEditedInfo videoEditedInfo, boolean z, int i2, boolean z2) {
                    final MessageObject messageObject = this.val$message;
                    messageObject.settingAvatar = true;
                    MediaController.PhotoEntry photoEntry = this.val$entry;
                    if (((MediaController.MediaEditState) photoEntry).imagePath != null || photoEntry.isVideo) {
                        PhotoUtilities.setImageAsAvatar(photoEntry, ChatActivity.this, new Runnable() {
                            @Override
                            public final void run() {
                                messageObject.settingAvatar = false;
                            }
                        });
                        return;
                    }
                    TLRPC.TL_photos_updateProfilePhoto tL_photos_updateProfilePhoto = new TLRPC.TL_photos_updateProfilePhoto();
                    TLRPC.TL_inputPhoto tL_inputPhoto = new TLRPC.TL_inputPhoto();
                    tL_photos_updateProfilePhoto.id = tL_inputPhoto;
                    TLRPC.Photo photo = this.val$message.messageOwner.action.photo;
                    ((TLRPC.InputPhoto) tL_inputPhoto).id = photo.id;
                    ((TLRPC.InputPhoto) tL_inputPhoto).access_hash = photo.access_hash;
                    ((TLRPC.InputPhoto) tL_inputPhoto).file_reference = photo.file_reference;
                    ConnectionsManager connectionsManager = ChatActivity.this.getConnectionsManager();
                    final MessageObject messageObject2 = this.val$message;
                    connectionsManager.sendRequest(tL_photos_updateProfilePhoto, new RequestDelegate() {
                        public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                            ChatActivity.ChatActivityAdapter.AnonymousClass2.C00112.this.lambda$sendButtonPressed$3(messageObject2, tLObject, tL_error);
                        }
                    });
                }
            }

            AnonymousClass2() {
            }

            private void initGiftProgressDialog(ChatActionCell chatActionCell) {
                if (ChatActivity.this.progressDialogCurrent != null) {
                    ChatActivity.this.progressDialogCurrent.cancel(true);
                }
                ChatActivity.this.progressDialogCurrent = (chatActionCell == null || chatActionCell.getMessageObject() == null) ? null : new AnonymousClass1(chatActionCell);
            }

            public void lambda$didClickButton$0(AlertDialog alertDialog, int i) {
                ChatThemeController.getInstance(((BaseFragment) ChatActivity.this).currentAccount).clearWallpaper(ChatActivity.this.dialog_id, true, true);
            }

            public void lambda$didPressReplyMessage$1(ChatActionCell chatActionCell, int i) {
                MessageObject messageObject = chatActionCell.getMessageObject();
                ChatActivity.this.scrollToMessageId(i, messageObject.getId(), true, messageObject.getDialogId() == ChatActivity.this.mergeDialogId ? 1 : 0, true, 0);
            }

            public void lambda$didPressTaskLink$2(ChatActionCell chatActionCell, int i, int i2) {
                MessageObject messageObject = chatActionCell.getMessageObject();
                ChatActivity.this.highlightTaskId = Integer.valueOf(i);
                ChatActivity.this.scrollToMessageId(i2, messageObject.getId(), true, messageObject.getDialogId() == ChatActivity.this.mergeDialogId ? 1 : 0, true, 0);
            }

            @Override
            public boolean canDrawOutboundsContent() {
                return false;
            }

            @Override
            public void didClickButton(ChatActionCell chatActionCell) {
                MessageObject messageObject;
                if (chatActionCell != null && (messageObject = chatActionCell.getMessageObject()) != null && messageObject.type == 22 && !chatActionCell.getMessageObject().isOutOwner() && chatActionCell.getMessageObject().isWallpaperForBoth() && chatActionCell.getMessageObject().isCurrentWallpaper()) {
                    AlertDialog create = new AlertDialog.Builder(ChatActivity.this.getContext(), ChatActivity.this.getResourceProvider()).setTitle(LocaleController.getString(R.string.RemoveWallpaperTitle)).setMessage(LocaleController.getString(R.string.RemoveWallpaperMessage)).setPositiveButton(LocaleController.getString(R.string.Remove), new AlertDialog.OnButtonClickListener() {
                        @Override
                        public final void onClick(AlertDialog alertDialog, int i) {
                            ChatActivity.ChatActivityAdapter.AnonymousClass2.this.lambda$didClickButton$0(alertDialog, i);
                        }
                    }).setNegativeButton(LocaleController.getString(R.string.Cancel), null).create();
                    ChatActivity.this.showDialog(create);
                    TextView textView = (TextView) create.getButton(-1);
                    if (textView != null) {
                        textView.setTextColor(ChatActivity.this.getThemedColor(Theme.key_text_RedBold));
                    }
                }
            }

            @Override
            public void didClickImage(ChatActionCell chatActionCell) {
                TLRPC.VideoSize videoSize;
                TLRPC.VideoSize videoSize2;
                PhotoViewer photoViewer;
                int i;
                PhotoViewer photoViewer2;
                int i2;
                String str;
                MessageObject messageObject = chatActionCell.getMessageObject();
                PhotoViewer photoViewer3 = PhotoViewer.getInstance();
                ChatActivity chatActivity = ChatActivity.this;
                photoViewer3.setParentActivity(chatActivity, chatActivity.themeDelegate);
                TLRPC.PhotoSize closestPhotoSizeWithSize = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 640);
                if (chatActionCell.getMessageObject().type == 24) {
                    StoryViewer orCreateStoryViewer = ChatActivity.this.getOrCreateStoryViewer();
                    ChatActivity chatActivity2 = ChatActivity.this;
                    orCreateStoryViewer.openFor(chatActivity2, chatActivity2.chatListView, chatActionCell);
                    return;
                }
                if (chatActionCell.getMessageObject().type == 22) {
                    MessagesController messagesController = MessagesController.getInstance(((BaseFragment) ChatActivity.this).currentAccount);
                    if (chatActionCell.showingCancelButton() && messageObject.getId() < 0 && (str = messagesController.uploadingWallpaper) != null && TextUtils.equals(messageObject.messageOwner.action.wallpaper.uploadingImage, str)) {
                        messagesController.cancelUploadWallpaper();
                        ChatActivity.this.removeMessageObject(messageObject);
                        return;
                    } else if (chatActionCell.hasButton()) {
                        ThemePreviewActivity.showFor(ChatActivity.this, messageObject);
                        return;
                    } else {
                        ChatActivity.this.showChatThemeBottomSheet();
                        return;
                    }
                }
                ArrayList arrayList = messageObject.messageOwner.action.photo.video_sizes;
                if (arrayList == null || arrayList.isEmpty()) {
                    videoSize = null;
                    videoSize2 = null;
                } else {
                    videoSize = FileLoader.getClosestVideoSizeWithSize(messageObject.messageOwner.action.photo.video_sizes, 1000);
                    videoSize2 = FileLoader.getEmojiMarkup(messageObject.messageOwner.action.photo.video_sizes);
                }
                if (chatActionCell.getMessageObject().type != 21 || messageObject.isOutOwner()) {
                    if (videoSize != null) {
                        PhotoViewer.getInstance().openPhoto(videoSize.location, ImageLocation.getForPhoto(videoSize, messageObject.messageOwner.action.photo), ChatActivity.this.photoViewerProvider);
                        if (chatActionCell.getMessageObject().type != 21) {
                            return;
                        }
                        photoViewer = PhotoViewer.getInstance();
                        i = R.string.SuggestedVideo;
                    } else {
                        if (closestPhotoSizeWithSize == null) {
                            PhotoViewer.getInstance().openPhoto(messageObject, (ChatActivity) null, 0L, 0L, 0L, ChatActivity.this.photoViewerProvider);
                            return;
                        }
                        PhotoViewer.getInstance().openPhoto(closestPhotoSizeWithSize.location, ImageLocation.getForPhoto(closestPhotoSizeWithSize, messageObject.messageOwner.action.photo), ChatActivity.this.photoViewerProvider);
                        if (chatActionCell.getMessageObject().type != 21) {
                            return;
                        }
                        photoViewer = PhotoViewer.getInstance();
                        i = R.string.SuggestedPhoto;
                    }
                    photoViewer.setTitle(LocaleController.getString(i));
                    return;
                }
                if (messageObject.settingAvatar) {
                    return;
                }
                if (videoSize2 != null) {
                    PhotoUtilities.showAvatartConstructorForUpdateUserPhoto(ChatActivity.this, videoSize2);
                    return;
                }
                ArrayList arrayList2 = new ArrayList();
                ImageLocation.getForPhoto(videoSize, messageObject.messageOwner.action.photo);
                FileLoader fileLoader = ChatActivity.this.getFileLoader();
                File pathToAttach = videoSize == null ? fileLoader.getPathToAttach(messageObject.messageOwner.action.photo) : fileLoader.getPathToAttach(videoSize);
                File file = new File(FileLoader.getDirectory(4), pathToAttach.getName());
                if (!pathToAttach.exists()) {
                    if (!file.exists()) {
                        return;
                    } else {
                        pathToAttach = file;
                    }
                }
                MediaController.PhotoEntry photoEntry = new MediaController.PhotoEntry(0, 0, 0L, pathToAttach.getAbsolutePath(), 0, false, 0, 0, 0L);
                ((MediaController.MediaEditState) photoEntry).caption = ChatActivity.this.chatActivityEnterView.getFieldText();
                photoEntry.isVideo = videoSize != null;
                arrayList2.add(photoEntry);
                PhotoViewer.getInstance().openPhotoForSelect(arrayList2, 0, 1, false, new C00112(messageObject, photoEntry), null);
                if (photoEntry.isVideo) {
                    photoViewer2 = PhotoViewer.getInstance();
                    i2 = R.string.SuggestedVideo;
                } else {
                    photoViewer2 = PhotoViewer.getInstance();
                    i2 = R.string.SuggestedPhoto;
                }
                photoViewer2.setTitle(LocaleController.getString(i2));
                ImageUpdater.AvatarFor avatarFor = new ImageUpdater.AvatarFor(ChatActivity.this.getUserConfig().getCurrentUser(), 1);
                avatarFor.isVideo = videoSize != null;
                avatarFor.fromObject = ChatActivity.this.getMessagesController().getUser(Long.valueOf(ChatActivity.this.dialog_id));
                PhotoViewer.getInstance().setAvatarFor(avatarFor);
            }

            @Override
            public boolean didLongPress(ChatActionCell chatActionCell, float f, float f2) {
                if (((BaseFragment) ChatActivity.this).inPreviewMode) {
                    return false;
                }
                return ChatActivity.this.createMenu(chatActionCell, false, false, f, f2, true);
            }

            @Override
            public void didOpenPremiumGift(ChatActionCell chatActionCell, TLRPC.TL_premiumGiftOption tL_premiumGiftOption, String str, boolean z) {
                if (str != null) {
                    initGiftProgressDialog(chatActionCell);
                    PremiumPreviewGiftLinkBottomSheet.show(str, ChatActivity.this.progressDialogCurrent);
                } else {
                    ChatActivity chatActivity = ChatActivity.this;
                    ChatActivity chatActivity2 = ChatActivity.this;
                    chatActivity.showDialog(new PremiumPreviewBottomSheet(chatActivity2, ((BaseFragment) chatActivity2).currentAccount, ChatActivity.this.getCurrentUser(), new GiftPremiumBottomSheet$GiftTier(tL_premiumGiftOption, (Object) null), ChatActivity.this.themeDelegate).setAnimateConfetti(z).setOutboundGift(chatActionCell.getMessageObject().isOut()));
                }
            }

            @Override
            public void didOpenPremiumGiftChannel(ChatActionCell chatActionCell, String str, boolean z) {
                initGiftProgressDialog(chatActionCell);
                GiftInfoBottomSheet.show(getBaseFragment(), str, ChatActivity.this.progressDialogCurrent);
            }

            @Override
            public void didPressReaction(ChatActionCell chatActionCell, TLRPC.ReactionCount reactionCount, boolean z, float f, float f2) {
                ChatActivity.this.didPressReaction(chatActionCell, reactionCount, z, f, f2);
            }

            @Override
            public void didPressReplyMessage(final ChatActionCell chatActionCell, final int i) {
                Runnable runnable = new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.ChatActivityAdapter.AnonymousClass2.this.lambda$didPressReplyMessage$1(chatActionCell, i);
                    }
                };
                if (!ChatActivity.this.chatAdapter.isFiltered) {
                    runnable.run();
                } else {
                    ChatActivity.this.setFilterMessages(false, true, true);
                    AndroidUtilities.runOnUIThread(runnable, 80L);
                }
            }

            @Override
            public void didPressTaskLink(final ChatActionCell chatActionCell, final int i, final int i2) {
                Runnable runnable = new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.ChatActivityAdapter.AnonymousClass2.this.lambda$didPressTaskLink$2(chatActionCell, i2, i);
                    }
                };
                if (!ChatActivity.this.chatAdapter.isFiltered) {
                    runnable.run();
                } else {
                    ChatActivity.this.setFilterMessages(false, true, true);
                    AndroidUtilities.runOnUIThread(runnable, 80L);
                }
            }

            @Override
            public void forceUpdate(ChatActionCell chatActionCell, boolean z) {
                MessageObject messageObject;
                int i;
                int i2;
                if (chatActionCell == null || (messageObject = chatActionCell.getMessageObject()) == null) {
                    return;
                }
                messageObject.forceUpdate = true;
                if (ChatActivity.this.chatListView != null && ChatActivity.this.chatLayoutManager != null && !ChatActivity.this.chatLayoutManager.hasPendingScrollPosition()) {
                    for (int childCount = ChatActivity.this.chatListView.getChildCount() - 1; childCount >= 0; childCount--) {
                        View childAt = ChatActivity.this.chatListView.getChildAt(childCount);
                        i = ChatActivity.this.chatListView.getChildAdapterPosition(childAt);
                        if (i >= 0) {
                            if (!(childAt instanceof ChatMessageCell)) {
                                if (childAt instanceof ChatActionCell) {
                                    i2 = ChatActivity.this.getScrollingOffsetForView(childAt);
                                    break;
                                }
                            } else {
                                if (((ChatMessageCell) childAt).getCurrentMessagesGroup() == null) {
                                    i2 = ChatActivity.this.getScrollingOffsetForView(childAt);
                                    break;
                                }
                            }
                        }
                    }
                }
                i = -1;
                i2 = 0;
                ChatActivity.this.lambda$updateMessageAnimated$308(messageObject, false);
                if (!z || i < 0) {
                    return;
                }
                ChatActivity.this.chatLayoutManager.scrollToPositionWithOffset(i, i2);
            }

            @Override
            public BaseFragment getBaseFragment() {
                return ChatActivity.this;
            }

            @Override
            public long getDialogId() {
                return ChatActionCell.ChatActionCellDelegate.CC.$default$getDialogId(this);
            }

            @Override
            public long getTopicId() {
                return ChatActivity.this.getTopicId();
            }

            @Override
            public void needOpenInviteLink(TLRPC.TL_chatInviteExported tL_chatInviteExported) {
                ChatActionCell.ChatActionCellDelegate.CC.$default$needOpenInviteLink(this, tL_chatInviteExported);
            }

            @Override
            public void needOpenUserProfile(long j) {
                ChatActivity.this.openUserProfile(j);
            }

            @Override
            public void needShowEffectOverlay(ChatActionCell chatActionCell, TLRPC.Document document, TLRPC.VideoSize videoSize) {
                ChatActivity.this.emojiAnimationsOverlay.showAnimationForActionCell(chatActionCell, document, videoSize);
            }

            @Override
            public void onTopicClick(ChatActionCell chatActionCell) {
                MessageObject messageObject;
                TopicsTabsView topicsTabsView;
                if (chatActionCell == null || (messageObject = chatActionCell.getMessageObject()) == null || (topicsTabsView = ChatActivity.this.topicsTabs) == null) {
                    return;
                }
                topicsTabsView.selectTopic(messageObject.getMonoForumTopicId(), true);
            }
        }

        class AnonymousClass3 implements ViewTreeObserver.OnPreDrawListener {
            final ChatMessageCell val$messageCell;

            AnonymousClass3(ChatMessageCell chatMessageCell) {
                this.val$messageCell = chatMessageCell;
            }

            @Override
            public boolean onPreDraw() {
                PipRoundVideoView pipRoundVideoView = PipRoundVideoView.getInstance();
                if (pipRoundVideoView != null) {
                    pipRoundVideoView.showTemporary(true);
                }
                this.val$messageCell.getViewTreeObserver().removeOnPreDrawListener(this);
                ImageReceiver photoImage = this.val$messageCell.getPhotoImage();
                float imageWidth = photoImage.getImageWidth();
                org.telegram.ui.Components.Rect cameraRect = ChatActivity.this.instantCameraView.getCameraRect();
                float f = imageWidth / cameraRect.width;
                int[] iArr = new int[2];
                this.val$messageCell.getTransitionParams().ignoreAlpha = true;
                this.val$messageCell.setAlpha(0.0f);
                this.val$messageCell.setTimeAlpha(0.0f);
                this.val$messageCell.getLocationOnScreen(iArr);
                iArr[0] = (int) (iArr[0] + (photoImage.getImageX() - this.val$messageCell.getAnimationOffsetX()));
                iArr[1] = (int) (iArr[1] + ((photoImage.getImageY() + this.val$messageCell.getPaddingTop()) - this.val$messageCell.getTranslationY()));
                final InstantCameraView.InstantViewCameraContainer cameraContainer = ChatActivity.this.instantCameraView.getCameraContainer();
                cameraContainer.setPivotX(0.0f);
                cameraContainer.setPivotY(0.0f);
                AnimatorSet animatorSet = new AnimatorSet();
                cameraContainer.setImageReceiver(photoImage);
                ChatActivity.this.instantCameraView.cancelBlur();
                AnimatorSet animatorSet2 = new AnimatorSet();
                ObjectAnimator ofFloat = ObjectAnimator.ofFloat(cameraContainer, (Property<InstantCameraView.InstantViewCameraContainer, Float>) View.SCALE_X, f);
                ObjectAnimator ofFloat2 = ObjectAnimator.ofFloat(cameraContainer, (Property<InstantCameraView.InstantViewCameraContainer, Float>) View.SCALE_Y, f);
                ObjectAnimator ofFloat3 = ObjectAnimator.ofFloat(cameraContainer, (Property<InstantCameraView.InstantViewCameraContainer, Float>) View.TRANSLATION_Y, iArr[1] - cameraRect.y);
                View switchButtonView = ChatActivity.this.instantCameraView.getSwitchButtonView();
                Property property = View.ALPHA;
                animatorSet.playTogether(ofFloat, ofFloat2, ofFloat3, ObjectAnimator.ofFloat(switchButtonView, (Property<View, Float>) property, 0.0f), ObjectAnimator.ofFloat(ChatActivity.this.instantCameraView.getFlashButtonView(), (Property<View, Float>) property, 0.0f), ObjectAnimator.ofInt(ChatActivity.this.instantCameraView.getPaint(), (Property<Paint, Integer>) AnimationProperties.PAINT_ALPHA, 0), ObjectAnimator.ofFloat(ChatActivity.this.instantCameraView.getMuteImageView(), (Property<View, Float>) property, 0.0f));
                animatorSet.setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT);
                ObjectAnimator ofFloat4 = ObjectAnimator.ofFloat(cameraContainer, (Property<InstantCameraView.InstantViewCameraContainer, Float>) View.TRANSLATION_X, iArr[0] - cameraRect.x);
                ofFloat4.setInterpolator(CubicBezierInterpolator.DEFAULT);
                animatorSet2.playTogether(ofFloat4, animatorSet);
                animatorSet2.setDuration(300L);
                InstantCameraView instantCameraView = ChatActivity.this.instantCameraView;
                if (instantCameraView != null) {
                    instantCameraView.setIsMessageTransition(true);
                }
                animatorSet2.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animator) {
                        AnonymousClass3.this.val$messageCell.setAlpha(1.0f);
                        AnonymousClass3.this.val$messageCell.getTransitionParams().ignoreAlpha = false;
                        AnimationProperties.FloatProperty floatProperty = new AnimationProperties.FloatProperty("alpha") {
                            public Float get(ChatMessageCell chatMessageCell) {
                                return Float.valueOf(chatMessageCell.getTimeAlpha());
                            }

                            public void setValue(ChatMessageCell chatMessageCell, float f2) {
                                chatMessageCell.setTimeAlpha(f2);
                            }
                        };
                        AnimatorSet animatorSet3 = new AnimatorSet();
                        animatorSet3.playTogether(ObjectAnimator.ofFloat(cameraContainer, (Property<InstantCameraView.InstantViewCameraContainer, Float>) View.ALPHA, 0.0f), ObjectAnimator.ofFloat(AnonymousClass3.this.val$messageCell, (Property<ChatMessageCell, Float>) floatProperty, 1.0f));
                        animatorSet3.setDuration(100L);
                        animatorSet3.setInterpolator(new DecelerateInterpolator());
                        animatorSet3.addListener(new AnimatorListenerAdapter() {
                            @Override
                            public void onAnimationEnd(Animator animator2) {
                                InstantCameraView instantCameraView2 = ChatActivity.this.instantCameraView;
                                if (instantCameraView2 != null) {
                                    instantCameraView2.setIsMessageTransition(false);
                                    ChatActivity.this.instantCameraView.hideCamera(true);
                                    ChatActivity.this.instantCameraView.setVisibility(4);
                                }
                            }
                        });
                        animatorSet3.start();
                    }
                });
                animatorSet2.start();
                return true;
            }
        }

        public ChatActivityAdapter(Context context) {
            this.mContext = context;
            TLRPC.User user = ChatActivity.this.currentUser;
            this.isBot = user != null && user.bot;
            setHasStableIds(true);
        }

        public void lambda$onCreateViewHolder$0(String str) {
            if (str.startsWith("@")) {
                ChatActivity.this.getMessagesController().openByUserName(str.substring(1), ChatActivity.this, 0);
                return;
            }
            if (str.startsWith("#") || str.startsWith("$")) {
                DialogsActivity dialogsActivity = new DialogsActivity(null);
                dialogsActivity.setSearchString(str);
                ChatActivity.this.presentFragment(dialogsActivity);
            } else {
                if (!str.startsWith("/")) {
                    ChatActivity.this.processExternalUrl(0, str, null, null, false, false);
                    return;
                }
                ChatActivity.this.chatActivityEnterView.setCommand((MessageObject) null, str, false, false);
                if (ChatActivity.this.chatActivityEnterView.getFieldText() == null) {
                    ChatActivity.this.hideFieldPanel(false);
                }
            }
        }

        public void updateRowsInternal() {
            throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.ChatActivityAdapter.updateRowsInternal():void");
        }

        public int getItemCount() {
            this.botInfoEmptyRow = -5;
            if (!ChatActivity.this.isClearingHistory()) {
                return this.rowCount;
            }
            ChatActivity chatActivity = ChatActivity.this;
            TLRPC.User user = chatActivity.currentUser;
            if (user == null || !user.bot || chatActivity.chatMode != 0 || ((ChatActivity.this.botInfo.size() <= 0 || (((TL_bots.BotInfo) ChatActivity.this.botInfo.get(ChatActivity.this.currentUser.id)).description == null && ((TL_bots.BotInfo) ChatActivity.this.botInfo.get(ChatActivity.this.currentUser.id)).description_photo == null && ((TL_bots.BotInfo) ChatActivity.this.botInfo.get(ChatActivity.this.currentUser.id)).description_document == null)) && !UserObject.isReplyUser(ChatActivity.this.currentUser))) {
                return 0;
            }
            this.botInfoEmptyRow = 0;
            return 1;
        }

        public long getItemId(int i) {
            if (ChatActivity.this.isClearingHistory() && i == this.botInfoEmptyRow) {
                return 1L;
            }
            ArrayList arrayList = this.isFrozen ? this.frozenMessages : this.isFiltered ? this.filteredMessages : ChatActivity.this.messages;
            if (i >= this.messagesStartRow && i < this.messagesEndRow) {
                return ((MessageObject) arrayList.get(i - r3)).stableId;
            }
            if (i == this.botInfoRow || i == this.botInfoEmptyRow) {
                return 1L;
            }
            if (i == this.loadingUpRow) {
                return 2L;
            }
            if (i == this.loadingDownRow) {
                return 3L;
            }
            if (i == this.hintRow) {
                return 4L;
            }
            if (i == this.userInfoRow) {
                return 6L;
            }
            if (i == this.userPhotoTimeRow) {
                return 7L;
            }
            return i == this.userNameTimeRow ? 8L : 5L;
        }

        public int getItemViewType(int i) {
            if (ChatActivity.this.isClearingHistory() && i == this.botInfoEmptyRow) {
                return 3;
            }
            if (i == this.hintRow) {
                return 1;
            }
            int i2 = this.messagesStartRow;
            if (i >= i2 && i < this.messagesEndRow) {
                return ((MessageObject) (this.isFrozen ? this.frozenMessages : this.isFiltered ? this.filteredMessages : ChatActivity.this.messages).get(i - i2)).contentType;
            }
            if (i == this.botInfoRow) {
                return 3;
            }
            if (i == this.userInfoRow) {
                return 6;
            }
            return (i == this.userNameTimeRow || i == this.userPhotoTimeRow) ? 7 : 4;
        }

        public ArrayList getMessages() {
            return this.isFrozen ? this.frozenMessages : this.isFiltered ? this.filteredMessages : ChatActivity.this.messages;
        }

        public void invalidateRowWithMessageObject(MessageObject messageObject) {
            int childCount = ChatActivity.this.chatListView.getChildCount();
            for (int i = 0; i < childCount; i++) {
                View childAt = ChatActivity.this.chatListView.getChildAt(i);
                if (childAt instanceof ChatMessageCell) {
                    ChatMessageCell chatMessageCell = (ChatMessageCell) childAt;
                    if (chatMessageCell.getMessageObject() == messageObject) {
                        chatMessageCell.invalidate();
                        return;
                    }
                }
            }
        }

        public boolean isEnabled(RecyclerView.ViewHolder viewHolder) {
            return false;
        }

        public void notifyDataSetChanged() {
            notifyDataSetChanged(false);
        }

        public void notifyDataSetChanged(boolean r7) {
            throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.ChatActivityAdapter.notifyDataSetChanged(boolean):void");
        }

        public void notifyItemChanged(int i) {
            RecyclerListView recyclerListView;
            RecyclerView.ItemAnimator itemAnimator;
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("notify item changed " + i);
            }
            try {
                if (((BaseFragment) ChatActivity.this).fragmentBeginToShow) {
                    if (ChatActivity.this.chatListView.getItemAnimator() != ChatActivity.this.chatListItemAnimator) {
                        recyclerListView = ChatActivity.this.chatListView;
                        itemAnimator = ChatActivity.this.chatListItemAnimator;
                    }
                    updateRowsInternal();
                    super.notifyItemChanged(i);
                    return;
                }
                recyclerListView = ChatActivity.this.chatListView;
                itemAnimator = null;
                super.notifyItemChanged(i);
                return;
            } catch (Exception e) {
                FileLog.e(e);
                return;
            }
            recyclerListView.setItemAnimator(itemAnimator);
            updateRowsInternal();
        }

        public void notifyItemInserted(int i) {
            RecyclerListView recyclerListView;
            RecyclerView.ItemAnimator itemAnimator;
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("notify item inserted " + i);
            }
            try {
                if (((BaseFragment) ChatActivity.this).fragmentBeginToShow) {
                    if (ChatActivity.this.chatListView.getItemAnimator() != ChatActivity.this.chatListItemAnimator) {
                        recyclerListView = ChatActivity.this.chatListView;
                        itemAnimator = ChatActivity.this.chatListItemAnimator;
                    }
                    updateRowsInternal();
                    super.notifyItemInserted(i);
                    return;
                }
                recyclerListView = ChatActivity.this.chatListView;
                itemAnimator = null;
                super.notifyItemInserted(i);
                return;
            } catch (Exception e) {
                FileLog.e(e);
                return;
            }
            recyclerListView.setItemAnimator(itemAnimator);
            updateRowsInternal();
        }

        public void notifyItemMoved(int i, int i2) {
            RecyclerListView recyclerListView;
            RecyclerView.ItemAnimator itemAnimator;
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("notify item moved" + i + ":" + i2);
            }
            try {
                if (((BaseFragment) ChatActivity.this).fragmentBeginToShow) {
                    if (ChatActivity.this.chatListView.getItemAnimator() != ChatActivity.this.chatListItemAnimator) {
                        recyclerListView = ChatActivity.this.chatListView;
                        itemAnimator = ChatActivity.this.chatListItemAnimator;
                    }
                    updateRowsInternal();
                    super/*androidx.recyclerview.widget.RecyclerView.Adapter*/.notifyItemMoved(i, i2);
                    return;
                }
                recyclerListView = ChatActivity.this.chatListView;
                itemAnimator = null;
                super/*androidx.recyclerview.widget.RecyclerView.Adapter*/.notifyItemMoved(i, i2);
                return;
            } catch (Exception e) {
                FileLog.e(e);
                return;
            }
            recyclerListView.setItemAnimator(itemAnimator);
            updateRowsInternal();
        }

        public void notifyItemRangeChanged(int i, int i2) {
            RecyclerListView recyclerListView;
            RecyclerView.ItemAnimator itemAnimator;
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("notify item range changed " + i + ":" + i2);
            }
            try {
                if (((BaseFragment) ChatActivity.this).fragmentBeginToShow) {
                    if (ChatActivity.this.chatListView.getItemAnimator() != ChatActivity.this.chatListItemAnimator) {
                        recyclerListView = ChatActivity.this.chatListView;
                        itemAnimator = ChatActivity.this.chatListItemAnimator;
                    }
                    updateRowsInternal();
                    super.notifyItemRangeChanged(i, i2);
                    return;
                }
                recyclerListView = ChatActivity.this.chatListView;
                itemAnimator = null;
                super.notifyItemRangeChanged(i, i2);
                return;
            } catch (Exception e) {
                FileLog.e(e);
                return;
            }
            recyclerListView.setItemAnimator(itemAnimator);
            updateRowsInternal();
        }

        public void notifyItemRangeInserted(int i, int i2) {
            RecyclerListView recyclerListView;
            RecyclerView.ItemAnimator itemAnimator;
            int i3;
            int i4;
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("notify item range inserted " + i + ":" + i2);
            }
            try {
                if (((BaseFragment) ChatActivity.this).fragmentBeginToShow) {
                    if (ChatActivity.this.chatListView.getItemAnimator() != ChatActivity.this.chatListItemAnimator) {
                        recyclerListView = ChatActivity.this.chatListView;
                        itemAnimator = ChatActivity.this.chatListItemAnimator;
                    }
                    updateRowsInternal();
                    if (i == 1 && i2 > 0 && (i3 = i + i2) >= (i4 = this.messagesStartRow) && i3 < this.messagesEndRow) {
                        MessageObject messageObject = (MessageObject) ChatActivity.this.messages.get(i3 - i4);
                        MessageObject messageObject2 = (MessageObject) ChatActivity.this.messages.get((i3 - this.messagesStartRow) - 1);
                        if ((ChatActivity.this.currentChat != null && messageObject.getFromChatId() == messageObject2.getFromChatId()) || (ChatActivity.this.currentUser != null && messageObject.isOutOwner() == messageObject2.isOutOwner())) {
                            notifyItemChanged(i);
                        }
                    }
                    super.notifyItemRangeInserted(i, i2);
                    return;
                }
                recyclerListView = ChatActivity.this.chatListView;
                itemAnimator = null;
                super.notifyItemRangeInserted(i, i2);
                return;
            } catch (Exception e) {
                FileLog.e(e);
                return;
            }
            recyclerListView.setItemAnimator(itemAnimator);
            updateRowsInternal();
            if (i == 1) {
                MessageObject messageObject3 = (MessageObject) ChatActivity.this.messages.get(i3 - i4);
                MessageObject messageObject22 = (MessageObject) ChatActivity.this.messages.get((i3 - this.messagesStartRow) - 1);
                if (ChatActivity.this.currentChat != null) {
                    notifyItemChanged(i);
                }
                notifyItemChanged(i);
            }
        }

        public void notifyItemRangeRemoved(int i, int i2) {
            RecyclerListView recyclerListView;
            RecyclerView.ItemAnimator itemAnimator;
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("notify item range removed" + i + ":" + i2);
            }
            try {
                if (((BaseFragment) ChatActivity.this).fragmentBeginToShow) {
                    if (ChatActivity.this.chatListView.getItemAnimator() != ChatActivity.this.chatListItemAnimator) {
                        recyclerListView = ChatActivity.this.chatListView;
                        itemAnimator = ChatActivity.this.chatListItemAnimator;
                    }
                    updateRowsInternal();
                    super.notifyItemRangeRemoved(i, i2);
                    return;
                }
                recyclerListView = ChatActivity.this.chatListView;
                itemAnimator = null;
                super.notifyItemRangeRemoved(i, i2);
                return;
            } catch (Exception e) {
                FileLog.e(e);
                return;
            }
            recyclerListView.setItemAnimator(itemAnimator);
            updateRowsInternal();
        }

        public void notifyItemRemoved(int i) {
            RecyclerListView recyclerListView;
            RecyclerView.ItemAnimator itemAnimator;
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("notify item removed " + i);
            }
            try {
                if (((BaseFragment) ChatActivity.this).fragmentBeginToShow) {
                    if (ChatActivity.this.chatListView.getItemAnimator() != ChatActivity.this.chatListItemAnimator) {
                        recyclerListView = ChatActivity.this.chatListView;
                        itemAnimator = ChatActivity.this.chatListItemAnimator;
                    }
                    updateRowsInternal();
                    super.notifyItemRemoved(i);
                    return;
                }
                recyclerListView = ChatActivity.this.chatListView;
                itemAnimator = null;
                super.notifyItemRemoved(i);
                return;
            } catch (Exception e) {
                FileLog.e(e);
                return;
            }
            recyclerListView.setItemAnimator(itemAnimator);
            updateRowsInternal();
        }

        public void notifyItemRemoved(int i, boolean z) {
            RecyclerListView recyclerListView;
            RecyclerView.ItemAnimator itemAnimator;
            if (BuildVars.LOGS_ENABLED) {
                StringBuilder sb = new StringBuilder();
                sb.append("notify item removed ");
                sb.append(i);
                sb.append(z ? " with thanos effect" : "");
                FileLog.d(sb.toString());
            }
            try {
                if (((BaseFragment) ChatActivity.this).fragmentBeginToShow) {
                    if (ChatActivity.this.chatListView.getItemAnimator() != ChatActivity.this.chatListItemAnimator) {
                        recyclerListView = ChatActivity.this.chatListView;
                        itemAnimator = ChatActivity.this.chatListItemAnimator;
                    }
                    if (z && ChatActivity.this.chatListItemAnimator != null && ChatActivity.this.chatListView.getItemAnimator() == ChatActivity.this.chatListItemAnimator) {
                        ChatActivity.this.chatListItemAnimator.prepareThanos(ChatActivity.this.chatListView.findViewHolderForAdapterPosition(i));
                    }
                    updateRowsInternal();
                    super.notifyItemRemoved(i);
                    return;
                }
                recyclerListView = ChatActivity.this.chatListView;
                itemAnimator = null;
                super.notifyItemRemoved(i);
                return;
            } catch (Exception e) {
                FileLog.e(e);
                return;
            }
            recyclerListView.setItemAnimator(itemAnimator);
            if (z) {
                ChatActivity.this.chatListItemAnimator.prepareThanos(ChatActivity.this.chatListView.findViewHolderForAdapterPosition(i));
            }
            updateRowsInternal();
        }

        public void onBindViewHolder(androidx.recyclerview.widget.RecyclerView.ViewHolder r23, int r24) {
            throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.ChatActivityAdapter.onBindViewHolder(androidx.recyclerview.widget.RecyclerView$ViewHolder, int):void");
        }

        public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
            View view;
            boolean z = true;
            View view2 = null;
            boolean z2 = false;
            if (i == 0) {
                ArrayList arrayList = (ArrayList) ChatActivity.chatMessageCellsCache.get(((BaseFragment) ChatActivity.this).currentAccount);
                if (arrayList == null || arrayList.isEmpty()) {
                    Context context = this.mContext;
                    int i2 = ((BaseFragment) ChatActivity.this).currentAccount;
                    ChatActivity chatActivity = ChatActivity.this;
                    view = new ChatMessageCell(context, i2, true, chatActivity.sharedResources, chatActivity.themeDelegate);
                } else {
                    View view3 = (View) arrayList.get(0);
                    arrayList.remove(0);
                    view = view3;
                }
                ChatMessageCell chatMessageCell = (ChatMessageCell) view;
                chatMessageCell.setResourcesProvider(ChatActivity.this.themeDelegate);
                chatMessageCell.shouldCheckVisibleOnScreen = false;
                chatMessageCell.setDelegate(new ChatMessageCellDelegate());
                if (ChatActivity.this.currentEncryptedChat == null) {
                    chatMessageCell.setAllowAssistant(true);
                }
                view2 = view;
            } else if (i == 1) {
                ChatActionCell chatActionCell = new ChatActionCell(this.mContext, z, ChatActivity.this.themeDelegate) {
                    @Override
                    public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
                        super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
                        accessibilityNodeInfo.setVisibleToUser(true);
                    }
                };
                chatActionCell.setInvalidateColors(true);
                chatActionCell.setDelegate(new AnonymousClass2());
                view2 = chatActionCell;
            } else if (i == 2) {
                view2 = new ChatUnreadCell(this.mContext, ChatActivity.this.themeDelegate);
            } else if (i == 3) {
                BotHelpCell botHelpCell = new BotHelpCell(this.mContext, ChatActivity.this.themeDelegate);
                botHelpCell.setDelegate(new BotHelpCell.BotHelpCellDelegate() {
                    @Override
                    public final void didPressUrl(String str) {
                        ChatActivity.ChatActivityAdapter.this.lambda$onCreateViewHolder$0(str);
                    }
                });
                view2 = botHelpCell;
            } else if (i == 4) {
                Context context2 = this.mContext;
                ChatActivity chatActivity2 = ChatActivity.this;
                view2 = new ChatLoadingCell(context2, chatActivity2.contentView, chatActivity2.themeDelegate);
            } else if (i == 6) {
                view2 = new UserInfoCell(this.mContext, ((BaseFragment) ChatActivity.this).currentAccount, ChatActivity.this.themeDelegate);
            } else if (i == 7) {
                view2 = new ChatActionCell(this.mContext, false, ChatActivity.this.themeDelegate);
            }
            view2.setLayoutParams(new RecyclerView.LayoutParams(-1, -2));
            return new RecyclerListView.Holder(view2);
        }

        public void onViewAttachedToWindow(androidx.recyclerview.widget.RecyclerView.ViewHolder r18) {
            throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.ChatActivityAdapter.onViewAttachedToWindow(androidx.recyclerview.widget.RecyclerView$ViewHolder):void");
        }

        public void updateRowAtPosition(int i) {
            int i2;
            if (ChatActivity.this.chatLayoutManager == null || this.isFrozen || this.isFiltered) {
                return;
            }
            int i3 = 0;
            if (!ChatActivity.this.wasManualScroll && ChatActivity.this.unreadMessageObject != null) {
                int childCount = ChatActivity.this.chatListView.getChildCount();
                int i4 = 0;
                while (true) {
                    if (i4 >= childCount) {
                        break;
                    }
                    View childAt = ChatActivity.this.chatListView.getChildAt(i4);
                    if ((childAt instanceof ChatMessageCell) && ((ChatMessageCell) childAt).getMessageObject() == ChatActivity.this.unreadMessageObject) {
                        ChatActivity chatActivity = ChatActivity.this;
                        if (chatActivity.messages.indexOf(chatActivity.unreadMessageObject) >= 0) {
                            int i5 = this.messagesStartRow;
                            ChatActivity chatActivity2 = ChatActivity.this;
                            i2 = i5 + chatActivity2.messages.indexOf(chatActivity2.unreadMessageObject);
                            i3 = ChatActivity.this.getScrollingOffsetForView(childAt);
                        }
                    } else {
                        i4++;
                    }
                }
            }
            i2 = -1;
            notifyItemChanged(i);
            if (i2 != -1) {
                ChatActivity.this.chatLayoutManager.scrollToPositionWithOffset(i2, i3);
            }
        }

        public View updateRowWithMessageObject(MessageObject messageObject, boolean z, boolean z2) {
            if (z) {
                int childCount = ChatActivity.this.chatListView.getChildCount();
                for (int i = 0; i < childCount; i++) {
                    View childAt = ChatActivity.this.chatListView.getChildAt(i);
                    if (childAt instanceof ChatMessageCell) {
                        ChatMessageCell chatMessageCell = (ChatMessageCell) childAt;
                        if (chatMessageCell.getMessageObject() == messageObject && !chatMessageCell.isAdminLayoutChanged()) {
                            chatMessageCell.setMessageObject(messageObject, chatMessageCell.getCurrentMessagesGroup(), chatMessageCell.isPinnedBottom(), chatMessageCell.isPinnedTop(), chatMessageCell.isFirstInChat());
                            return chatMessageCell;
                        }
                    }
                }
            }
            int indexOf = (this.isFrozen ? this.frozenMessages : this.isFiltered ? this.filteredMessages : ChatActivity.this.messages).indexOf(messageObject);
            if (indexOf == -1) {
                return null;
            }
            if (z2) {
                int i2 = ChatActivity.lastStableId;
                ChatActivity.lastStableId = i2 + 1;
                messageObject.stableId = i2;
                notifyDataSetChanged(true);
            } else {
                updateRowAtPosition(this.messagesStartRow + indexOf);
            }
            return null;
        }

        public void updateRowsSafe() {
            int i = this.rowCount;
            int i2 = this.botInfoRow;
            int i3 = this.userInfoRow;
            int i4 = this.hintRow;
            int i5 = this.loadingUpRow;
            int i6 = this.loadingDownRow;
            int i7 = this.messagesStartRow;
            int i8 = this.messagesEndRow;
            int i9 = this.userPhotoTimeRow;
            int i10 = this.userNameTimeRow;
            updateRowsInternal();
            if (i == this.rowCount && i2 == this.botInfoRow && i5 == this.loadingUpRow && i6 == this.loadingDownRow && i7 == this.messagesStartRow && i8 == this.messagesEndRow && i4 == this.hintRow && i3 == this.userInfoRow && i9 == this.userPhotoTimeRow && i10 == this.userNameTimeRow) {
                return;
            }
            notifyDataSetChanged(false);
        }
    }

    private interface ChatActivityDelegate {

        public abstract class CC {
            public static void $default$onUnpin(ChatActivityDelegate chatActivityDelegate, boolean z, boolean z2) {
            }

            public static void $default$openReplyMessage(ChatActivityDelegate chatActivityDelegate, int i) {
            }
        }

        void onUnpin(boolean z, boolean z2);

        void openHashtagSearch(String str);

        void openReplyMessage(int i);
    }

    class ChatActivityEnterViewDelegate implements ChatActivityEnterView.ChatActivityEnterViewDelegate {
        boolean isEditTextItemVisibilitySuppressed;
        int lastSize;

        private ChatActivityEnterViewDelegate() {
        }

        public void lambda$onMessageEditEnd$2() {
            ChatActivity.this.hideFieldPanel(true);
        }

        public void lambda$onStickersExpandedChange$3() {
            if (ChatActivity.this.suggestEmojiPanel == null || !ChatActivity.this.chatActivityEnterView.isStickersExpanded()) {
                return;
            }
            ChatActivity.this.suggestEmojiPanel.setVisibility(8);
        }

        public static void lambda$onTextSelectionChanged$0(ActionBarMenu actionBarMenu, ValueAnimator valueAnimator) {
            actionBarMenu.translateXItems(((Float) valueAnimator.getAnimatedValue()).floatValue());
        }

        public static void lambda$onTextSelectionChanged$1(ActionBarMenu actionBarMenu, ValueAnimator valueAnimator) {
            actionBarMenu.translateXItems(((Float) valueAnimator.getAnimatedValue()).floatValue());
        }

        public void bottomPanelTranslationYChanged(float f) {
            if (f != 0.0f) {
                ChatActivity.this.wasManualScroll = true;
            }
            ChatActivity chatActivity = ChatActivity.this;
            chatActivity.bottomPanelTranslationY = chatActivity.chatActivityEnterView.panelAnimationInProgress() ? ChatActivity.this.chatActivityEnterView.getEmojiPadding() - f : 0.0f;
            ChatActivity chatActivity2 = ChatActivity.this;
            chatActivity2.bottomPanelTranslationYReverse = chatActivity2.chatActivityEnterView.panelAnimationInProgress() ? f : 0.0f;
            ChatActivity.this.chatActivityEnterView.setTranslationY(f);
            ChatActivity.this.mentionContainer.setTranslationY(f);
            ChatActivity chatActivity3 = ChatActivity.this;
            chatActivity3.contentView.setEmojiOffset(chatActivity3.chatActivityEnterView.panelAnimationInProgress(), ChatActivity.this.bottomPanelTranslationY);
            float topViewTranslation = f + ChatActivity.this.chatActivityEnterView.getTopViewTranslation();
            ChatActivity.this.mentionContainer.setTranslationY(topViewTranslation);
            ChatActivity.this.chatListView.setTranslationY(topViewTranslation);
            ChatActivity.this.invalidateChatListViewTopPadding();
            ChatActivity.this.invalidateMessagesVisiblePart();
            ChatActivity.this.updateTextureViewPosition(false, false);
            ChatActivity.this.contentView.invalidate();
            ChatActivity.this.updateBulletinLayout();
        }

        public boolean checkCanRemoveRestrictionsByBoosts() {
            return ChatActivity.this.checkCanRemoveRestrictionsByBoosts();
        }

        public void didPressAttachButton() {
            ChatAttachAlert chatAttachAlert = ChatActivity.this.chatAttachAlert;
            if (chatAttachAlert != null) {
                chatAttachAlert.setEditingMessageObject(0, (MessageObject) null);
            }
            ChatActivity.this.openAttachMenu();
        }

        public void didPressSuggestionButton() {
            Context context = ChatActivity.this.getContext();
            int i = ((BaseFragment) ChatActivity.this).currentAccount;
            long j = ChatActivity.this.dialog_id;
            MessageSuggestionParams messageSuggestionParams = ChatActivity.this.messageSuggestionParams;
            if (messageSuggestionParams == null) {
                messageSuggestionParams = MessageSuggestionParams.empty();
            }
            MessageSuggestionParams messageSuggestionParams2 = messageSuggestionParams;
            ChatActivity chatActivity = ChatActivity.this;
            new MessageSuggestionOfferSheet(context, i, j, messageSuggestionParams2, chatActivity, chatActivity.getResourceProvider(), 0, new ChatActivity$$ExternalSyntheticLambda115(ChatActivity.this)).show();
        }

        public int getContentViewHeight() {
            return ChatActivity.this.contentView.getHeight();
        }

        public ReplyQuote getReplyQuote() {
            return ChatActivity.this.replyingQuote;
        }

        public TL_stories.StoryItem getReplyToStory() {
            return ChatActivityEnterView.ChatActivityEnterViewDelegate.-CC.$default$getReplyToStory(this);
        }

        public TLRPC.TL_channels_sendAsPeers getSendAsPeers() {
            return ChatActivity.this.sendAsPeersObj;
        }

        public boolean hasForwardingMessages() {
            MessagePreviewParams.Messages messages;
            MessagePreviewParams messagePreviewParams = ChatActivity.this.messagePreviewParams;
            return (messagePreviewParams == null || (messages = messagePreviewParams.forwardMessages) == null || messages.messages.isEmpty()) ? false : true;
        }

        public boolean hasScheduledMessages() {
            if ((!ChatActivity.this.getMessagesController().isForum(ChatActivity.this.getDialogId()) || ChatActivity.this.isTopic) && ChatActivity.this.scheduledMessagesCount > 0) {
                return ChatActivity.this.chatMode == 0 || (ChatActivity.this.chatMode == 3 && ChatActivity.this.getSavedDialogId() == ChatActivity.this.getUserConfig().getClientUserId());
            }
            return false;
        }

        public boolean isVideoRecordingPaused() {
            InstantCameraView instantCameraView = ChatActivity.this.instantCameraView;
            return instantCameraView != null && instantCameraView.isPaused();
        }

        public int measureKeyboardHeight() {
            return ChatActivity.this.contentView.measureKeyboardHeight();
        }

        public void needChangeVideoPreviewState(int i, float f) {
            InstantCameraView instantCameraView = ChatActivity.this.instantCameraView;
            if (instantCameraView != null) {
                instantCameraView.changeVideoPreviewState(i, f);
            }
        }

        public void needSendTyping() {
            if (ChatActivity.this.chatMode == 5 || ChatActivity.this.chatMode == 6 || ChatActivity.this.chatMode == 8) {
                return;
            }
            ChatActivity.this.getMessagesController().sendTyping(ChatActivity.this.dialog_id, ChatActivity.this.threadMessageId, 0, ((BaseFragment) ChatActivity.this).classGuid);
        }

        public void needShowMediaBanHint() {
            ChatActivity.this.showMediaBannedHint();
        }

        public void needStartRecordAudio(int i) {
            int i2 = i == 0 ? 8 : 0;
            if (ChatActivity.this.overlayView.getVisibility() != i2) {
                ChatActivity.this.overlayView.setVisibility(i2);
            }
        }

        public void needStartRecordVideo(int i, boolean z, int i2, int i3, long j, long j2) {
            ChatActivity.this.checkInstantCameraView();
            InstantCameraView instantCameraView = ChatActivity.this.instantCameraView;
            if (instantCameraView != null) {
                if (i == 0) {
                    instantCameraView.showCamera(false);
                    ChatActivity.this.chatListView.stopScroll();
                    ChatActivity.this.chatAdapter.updateRowsSafe();
                } else if (i == 1 || i == 3 || i == 4) {
                    instantCameraView.send(i, z, i2, i3, j, j2);
                } else if (i == 2 || i == 5) {
                    instantCameraView.cancel(i == 2);
                }
            }
        }

        public void onAttachButtonHidden() {
            if (((BaseFragment) ChatActivity.this).actionBar.isSearchFieldVisible()) {
                return;
            }
            if (ChatActivity.this.editTextItem != null && !this.isEditTextItemVisibilitySuppressed) {
                ChatActivity.this.editTextItem.setVisibility(8);
            }
            if (TextUtils.isEmpty(ChatActivity.this.chatActivityEnterView.getSlowModeTimer())) {
                if (ChatActivity.this.headerItem != null) {
                    ChatActivity.this.headerItem.setVisibility(8);
                }
                if (ChatActivity.this.attachItem != null) {
                    ChatActivity.this.attachItem.setVisibility(0);
                }
            }
        }

        public void onAttachButtonShow() {
            if (((BaseFragment) ChatActivity.this).actionBar.isSearchFieldVisible()) {
                return;
            }
            if (ChatActivity.this.headerItem != null) {
                ChatActivity.this.headerItem.setVisibility(0);
            }
            if (ChatActivity.this.editTextItem != null && !this.isEditTextItemVisibilitySuppressed) {
                ChatActivity.this.editTextItem.setVisibility(8);
            }
            if (ChatActivity.this.attachItem != null) {
                ChatActivity.this.attachItem.setVisibility(8);
            }
        }

        public void onAudioVideoInterfaceUpdated() {
            ChatActivity.this.updatePagedownButtonVisibility(true);
        }

        public void onContextMenuClose() {
            if (ChatActivity.this.suggestEmojiPanel != null) {
                ChatActivity.this.suggestEmojiPanel.fireUpdate();
            }
        }

        public void onContextMenuOpen() {
            if (ChatActivity.this.suggestEmojiPanel != null) {
                ChatActivity.this.suggestEmojiPanel.forceClose();
            }
        }

        public void onEditTextScroll() {
            if (ChatActivity.this.suggestEmojiPanel != null) {
                ChatActivity.this.suggestEmojiPanel.forceClose();
            }
        }

        public void onKeyboardRequested() {
            ChatActivity.this.checkAdjustResize();
        }

        public void onMessageEditEnd(boolean z) {
            boolean z2;
            if (ChatActivity.this.chatListItemAnimator != null) {
                ChatActivity chatActivity = ChatActivity.this;
                chatActivity.chatActivityEnterViewAnimateFromTop = chatActivity.chatActivityEnterView.getBackgroundTop();
                if (ChatActivity.this.chatActivityEnterViewAnimateFromTop != 0) {
                    ChatActivity.this.chatActivityEnterViewAnimateBeforeSending = true;
                }
            }
            if (z) {
                return;
            }
            MentionsContainerView mentionsContainerView = ChatActivity.this.mentionContainer;
            if (mentionsContainerView != null) {
                mentionsContainerView.getAdapter().setNeedBotContext(true);
            }
            if (ChatActivity.this.editingMessageObject != null) {
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.ChatActivityEnterViewDelegate.this.lambda$onMessageEditEnd$2();
                    }
                }, 30L);
            }
            if (ChatActivity.this.chatActivityEnterView.isPopupShowing()) {
                ChatActivity.this.chatActivityEnterView.setFieldFocused();
                z2 = true;
            } else {
                z2 = false;
            }
            ChatActivity.this.chatActivityEnterView.setAllowStickersAndGifs(true, true, true, z2);
            if (ChatActivity.this.editingMessageObjectReqId != 0) {
                ChatActivity.this.getConnectionsManager().cancelRequest(ChatActivity.this.editingMessageObjectReqId, true);
                ChatActivity.this.editingMessageObjectReqId = 0;
            }
            ChatActivity.this.updatePinnedMessageView(true);
            ChatActivity.this.updateBottomOverlay();
            ChatActivity.this.updateVisibleRows();
        }

        public void onMessageSend(CharSequence charSequence, boolean z, int i, long j) {
            MessagePreviewParams messagePreviewParams;
            MessagePreviewParams.Messages messages;
            TLRPC.Message message;
            MessagePreviewParams.Messages messages2;
            if (ChatActivity.this.chatListItemAnimator != null) {
                ChatActivity chatActivity = ChatActivity.this;
                chatActivity.chatActivityEnterViewAnimateFromTop = chatActivity.chatActivityEnterView.getBackgroundTop();
                if (ChatActivity.this.chatActivityEnterViewAnimateFromTop != 0) {
                    ChatActivity.this.chatActivityEnterViewAnimateBeforeSending = true;
                }
            }
            MentionsContainerView mentionsContainerView = ChatActivity.this.mentionContainer;
            if (mentionsContainerView != null && mentionsContainerView.getAdapter() != null) {
                ChatActivity.this.mentionContainer.getAdapter().addHashtagsFromMessage(charSequence);
            }
            boolean z2 = false;
            if (i != 0) {
                if (ChatActivity.this.scheduledMessagesCount == -1) {
                    ChatActivity.this.scheduledMessagesCount = 0;
                }
                if (charSequence != null) {
                    ChatActivity.access$3408(ChatActivity.this);
                }
                MessagePreviewParams messagePreviewParams2 = ChatActivity.this.messagePreviewParams;
                if (messagePreviewParams2 != null && (messages2 = messagePreviewParams2.forwardMessages) != null && !messages2.messages.isEmpty()) {
                    ChatActivity chatActivity2 = ChatActivity.this;
                    ChatActivity.access$3412(chatActivity2, chatActivity2.messagePreviewParams.forwardMessages.messages.size());
                }
                ChatActivity.this.updateScheduledInterface(false);
            }
            if (!TextUtils.isEmpty(charSequence) && (messagePreviewParams = ChatActivity.this.messagePreviewParams) != null && (messages = messagePreviewParams.forwardMessages) != null && !messages.messages.isEmpty() && ChatActivity.this.messagePreviewParams.quote == null && j <= 0) {
                ArrayList arrayList = new ArrayList();
                ChatActivity.this.messagePreviewParams.forwardMessages.getSelectedMessages(arrayList);
                boolean z3 = arrayList.size() > 0;
                TLRPC.Peer peer = ChatActivity.this.getMessagesController().getPeer(ChatActivity.this.dialog_id);
                int i2 = 0;
                while (true) {
                    if (i2 >= arrayList.size()) {
                        z2 = z3;
                        break;
                    }
                    MessageObject messageObject = (MessageObject) arrayList.get(i2);
                    if (messageObject != null && (message = messageObject.messageOwner) != null && !MessageObject.peersEqual(message.peer_id, peer)) {
                        break;
                    } else {
                        i2++;
                    }
                }
                if (z2) {
                    Bulletin createSimpleBulletin = BulletinFactory.of(ChatActivity.this).createSimpleBulletin(R.raw.hint_swipe_reply, LocaleController.getString(R.string.SwipeToReplyHint), LocaleController.getString(R.string.SwipeToReplyHintMessage));
                    RLottieImageView rLottieImageView = createSimpleBulletin.getLayout().imageView;
                    rLottieImageView.setScaleX(1.8f);
                    rLottieImageView.setScaleY(1.8f);
                    createSimpleBulletin.show(true);
                }
            }
            if (ChatObject.isForum(ChatActivity.this.currentChat)) {
                ChatActivity chatActivity3 = ChatActivity.this;
                if (!chatActivity3.isTopic && chatActivity3.replyingMessageObject != null) {
                    long topicId = ChatActivity.this.replyingMessageObject.replyToForumTopic != null ? ChatActivity.this.replyingMessageObject.replyToForumTopic.id : MessageObject.getTopicId(((BaseFragment) ChatActivity.this).currentAccount, ChatActivity.this.replyingMessageObject.messageOwner, true);
                    if (topicId != 0) {
                        ChatActivity.this.getMediaDataController().cleanDraft(ChatActivity.this.dialog_id, topicId, false);
                    }
                }
            }
            ChatActivity.this.hideFieldPanel(z, i, j, true);
            ChatActivityEnterView chatActivityEnterView = ChatActivity.this.chatActivityEnterView;
            if (chatActivityEnterView != null && chatActivityEnterView.getEmojiView() != null) {
                ChatActivity.this.chatActivityEnterView.getEmojiView().onMessageSend();
            }
            if (ChatActivity.this.getMessagesController().premiumFeaturesBlocked() || ChatActivity.this.getMessagesController().transcribeAudioTrialWeeklyNumber > 0 || ChatActivity.this.getMessagesController().didPressTranscribeButtonEnough() || ChatActivity.this.getUserConfig().isPremium() || TextUtils.isEmpty(charSequence) || ChatActivity.this.messages == null) {
                return;
            }
            for (int i3 = 1; i3 < Math.min(5, ChatActivity.this.messages.size()); i3++) {
                MessageObject messageObject2 = (MessageObject) ChatActivity.this.messages.get(i3);
                if (messageObject2 != null && !messageObject2.isOutOwner() && ((messageObject2.isVoice() || messageObject2.isRoundVideo()) && messageObject2.isContentUnread())) {
                    TranscribeButton.showOffTranscribe(messageObject2);
                }
            }
        }

        public void onPreAudioVideoRecord() {
            ChatActivity.this.showVoiceHint(true, false);
        }

        public void onSendLongClick() {
            if (ChatActivity.this.scheduledOrNoSoundHint != null) {
                ChatActivity.this.scheduledOrNoSoundHint.hide();
            }
            if (ChatActivity.this.scheduledHint != null) {
                ChatActivity.this.scheduledHint.hide();
            }
        }

        public void onStickersExpandedChange() {
            ChatActivity.this.checkRaiseSensors();
            if (ChatActivity.this.chatActivityEnterView.isStickersExpanded()) {
                AndroidUtilities.setAdjustResizeToNothing(ChatActivity.this.getParentActivity(), ((BaseFragment) ChatActivity.this).classGuid);
                if (Bulletin.getVisibleBulletin() != null && Bulletin.getVisibleBulletin().isShowing()) {
                    Bulletin.getVisibleBulletin().hide();
                }
            } else {
                AndroidUtilities.requestAdjustResize(ChatActivity.this.getParentActivity(), ((BaseFragment) ChatActivity.this).classGuid);
            }
            MentionsContainerView mentionsContainerView = ChatActivity.this.mentionContainer;
            float f = 0.0f;
            if (mentionsContainerView != null) {
                mentionsContainerView.animate().alpha((ChatActivity.this.chatActivityEnterView.isStickersExpanded() || ChatActivity.this.isInPreviewMode()) ? 0.0f : 1.0f).setInterpolator(CubicBezierInterpolator.DEFAULT).start();
            }
            if (ChatActivity.this.suggestEmojiPanel != null) {
                ChatActivity.this.suggestEmojiPanel.setVisibility(0);
                ViewPropertyAnimator animate = ChatActivity.this.suggestEmojiPanel.animate();
                if (!ChatActivity.this.chatActivityEnterView.isStickersExpanded() && !ChatActivity.this.isInPreviewMode()) {
                    f = 1.0f;
                }
                animate.alpha(f).setInterpolator(CubicBezierInterpolator.DEFAULT).withEndAction(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.ChatActivityEnterViewDelegate.this.lambda$onStickersExpandedChange$3();
                    }
                }).start();
            }
        }

        public void onStickersTab(boolean z) {
            if (ChatActivity.this.emojiButtonRed != null) {
                ChatActivity.this.emojiButtonRed.setVisibility(8);
            }
            ChatActivity.this.allowContextBotPanelSecond = !z;
        }

        public void onSwitchRecordMode(boolean z) {
            ChatActivity.this.showVoiceHint(false, z);
        }

        public void onTextChanged(final CharSequence charSequence, boolean z, boolean z2) {
            MediaController.getInstance().setInputFieldHasText(!TextUtils.isEmpty(charSequence) || ChatActivity.this.chatActivityEnterView.isEditingMessage());
            MentionsContainerView mentionsContainerView = ChatActivity.this.mentionContainer;
            if (mentionsContainerView != null && mentionsContainerView.getAdapter() != null) {
                ChatActivity.this.mentionContainer.getAdapter().lambda$searchUsernameOrHashtag$7(charSequence, ChatActivity.this.chatActivityEnterView.getCursorPosition(), ChatActivity.this.messages, false, false);
            }
            if (ChatActivity.this.waitingForCharaterEnterRunnable != null) {
                AndroidUtilities.cancelRunOnUIThread(ChatActivity.this.waitingForCharaterEnterRunnable);
                ChatActivity.this.waitingForCharaterEnterRunnable = null;
            }
            TLRPC.Chat chat = ChatActivity.this.currentChat;
            if ((chat == null || ChatObject.canSendEmbed(chat)) && ChatActivity.this.chatActivityEnterView.isMessageWebPageSearchEnabled() && (!ChatActivity.this.chatActivityEnterView.isEditingMessage() || !ChatActivity.this.chatActivityEnterView.isEditingCaption())) {
                if (z) {
                    ChatActivity.this.searchLinks(charSequence, true);
                } else {
                    ChatActivity.this.checkEditLinkRemoved(charSequence);
                    ChatActivity.this.waitingForCharaterEnterRunnable = new Runnable() {
                        @Override
                        public void run() {
                            if (this == ChatActivity.this.waitingForCharaterEnterRunnable) {
                                ChatActivity.this.searchLinks(charSequence, false);
                                ChatActivity.this.waitingForCharaterEnterRunnable = null;
                            }
                        }
                    };
                    AndroidUtilities.runOnUIThread(ChatActivity.this.waitingForCharaterEnterRunnable, AndroidUtilities.WEB_URL == null ? 3000L : 1000L);
                }
            }
            EmojiAnimationsOverlay emojiAnimationsOverlay = ChatActivity.this.emojiAnimationsOverlay;
            if (emojiAnimationsOverlay != null) {
                emojiAnimationsOverlay.cancelAllAnimations();
            }
            ReactionsEffectOverlay.dismissAll();
            if (z2) {
                return;
            }
            if ((ChatActivity.this.scheduledOrNoSoundHint == null || ChatActivity.this.scheduledOrNoSoundHint.getVisibility() != 0) && (ChatActivity.this.scheduledHint == null || ChatActivity.this.scheduledHint.getVisibility() != 0)) {
                ChatActivity.this.showScheduledHint();
            } else {
                ChatActivity.this.hideSendButtonHints();
            }
        }

        public void onTextSelectionChanged(int i, int i2) {
            if (ChatActivity.this.editTextItem == null) {
                return;
            }
            final ActionBarMenu createMenu = ((BaseFragment) ChatActivity.this).actionBar.createMenu();
            if (ChatActivity.this.suggestEmojiPanel != null) {
                ChatActivity.this.suggestEmojiPanel.onTextSelectionChanged(i, i2);
            }
            if (i2 - i > 0) {
                if (ChatActivity.this.editTextItem.getTag() == null) {
                    ChatActivity.this.editTextItem.setTag(1);
                    if (ChatActivity.this.editTextItem.getVisibility() != 0) {
                        if (!(ChatActivity.this.chatMode == 3 && ChatActivity.this.getSavedDialogId() == ChatActivity.this.getUserConfig().getClientUserId()) && (ChatActivity.this.chatMode != 0 || (!(ChatActivity.this.threadMessageId == 0 || ChatActivity.this.isTopic) || UserObject.isReplyUser(ChatActivity.this.currentUser) || ChatActivity.this.isReport()))) {
                            ValueAnimator ofFloat = ValueAnimator.ofFloat(AndroidUtilities.dp(48.0f), 0.0f);
                            ofFloat.setDuration(220L);
                            ofFloat.setInterpolator(CubicBezierInterpolator.DEFAULT);
                            ofFloat.addListener(new AnimatorListenerAdapter() {
                                @Override
                                public void onAnimationEnd(Animator animator) {
                                    ((BaseFragment) ChatActivity.this).actionBar.setMenuOffsetSuppressed(false);
                                }

                                @Override
                                public void onAnimationStart(Animator animator) {
                                    ((BaseFragment) ChatActivity.this).actionBar.setMenuOffsetSuppressed(true);
                                    ChatActivity.this.checkEditTextItemMenu();
                                    ChatActivity.this.editTextItem.setVisibility(0);
                                    createMenu.translateXItems(AndroidUtilities.dp(48.0f));
                                }
                            });
                            ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                                @Override
                                public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                                    ChatActivity.ChatActivityEnterViewDelegate.lambda$onTextSelectionChanged$0(ActionBarMenu.this, valueAnimator);
                                }
                            });
                            ofFloat.start();
                        } else {
                            ChatActivity.this.editTextItem.setVisibility(0);
                            ChatActivity.this.checkEditTextItemMenu();
                            if (ChatActivity.this.headerItem != null) {
                                ChatActivity.this.headerItem.setVisibility(8);
                            }
                            if (ChatActivity.this.attachItem != null) {
                                ChatActivity.this.attachItem.setVisibility(8);
                            }
                        }
                    }
                }
                ChatActivity.this.editTextStart = i;
                ChatActivity.this.editTextEnd = i2;
                return;
            }
            if (ChatActivity.this.editTextItem.getTag() != null) {
                ChatActivity.this.editTextItem.setTag(null);
                if (ChatActivity.this.editTextItem.getVisibility() != 8) {
                    if (!(ChatActivity.this.chatMode == 3 && ChatActivity.this.getSavedDialogId() == ChatActivity.this.getUserConfig().getClientUserId()) && (ChatActivity.this.chatMode != 0 || (!(ChatActivity.this.threadMessageId == 0 || ChatActivity.this.isTopic) || UserObject.isReplyUser(ChatActivity.this.currentUser) || ChatActivity.this.isReport()))) {
                        ValueAnimator ofFloat2 = ValueAnimator.ofFloat(0.0f, AndroidUtilities.dp(48.0f));
                        ofFloat2.setDuration(220L);
                        ofFloat2.setInterpolator(CubicBezierInterpolator.DEFAULT);
                        ofFloat2.addListener(new AnimatorListenerAdapter() {
                            @Override
                            public void onAnimationEnd(Animator animator) {
                                ChatActivity.this.editTextItem.setVisibility(8);
                                createMenu.translateXItems(0.0f);
                                ((BaseFragment) ChatActivity.this).actionBar.setMenuOffsetSuppressed(false);
                                ChatActivityEnterViewDelegate.this.isEditTextItemVisibilitySuppressed = false;
                            }

                            @Override
                            public void onAnimationStart(Animator animator) {
                                ((BaseFragment) ChatActivity.this).actionBar.setMenuOffsetSuppressed(true);
                                ChatActivityEnterViewDelegate.this.isEditTextItemVisibilitySuppressed = true;
                            }
                        });
                        ofFloat2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                            @Override
                            public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                                ChatActivity.ChatActivityEnterViewDelegate.lambda$onTextSelectionChanged$1(ActionBarMenu.this, valueAnimator);
                            }
                        });
                        ofFloat2.start();
                        return;
                    }
                    ChatActivity.this.editTextItem.setVisibility(8);
                    if (ChatActivity.this.chatActivityEnterView.hasText() && TextUtils.isEmpty(ChatActivity.this.chatActivityEnterView.getSlowModeTimer())) {
                        if (ChatActivity.this.headerItem != null) {
                            ChatActivity.this.headerItem.setVisibility(8);
                        }
                        if (ChatActivity.this.attachItem != null) {
                            ChatActivity.this.attachItem.setVisibility(0);
                            return;
                        }
                        return;
                    }
                    if (ChatActivity.this.headerItem != null) {
                        ChatActivity.this.headerItem.setVisibility(0);
                    }
                    if (ChatActivity.this.attachItem != null) {
                        ChatActivity.this.attachItem.setVisibility(8);
                    }
                }
            }
        }

        public void onTextSpansChanged(CharSequence charSequence) {
            ChatActivity.this.searchLinks(charSequence, true);
        }

        public void onTrendingStickersShowed(boolean z) {
            if (!z) {
                AndroidUtilities.requestAdjustResize(ChatActivity.this.getParentActivity(), ((BaseFragment) ChatActivity.this).classGuid);
            } else {
                AndroidUtilities.setAdjustResizeToNothing(ChatActivity.this.getParentActivity(), ((BaseFragment) ChatActivity.this).classGuid);
                ((BaseFragment) ChatActivity.this).fragmentView.requestLayout();
            }
        }

        public void onUpdateSlowModeButton(View view, boolean z, CharSequence charSequence) {
            ChatActivity.this.showSlowModeHint(view, z, charSequence);
            if (ChatActivity.this.headerItem == null || ChatActivity.this.headerItem.getVisibility() == 0) {
                return;
            }
            ChatActivity.this.headerItem.setVisibility(0);
            if (ChatActivity.this.attachItem != null) {
                ChatActivity.this.attachItem.setVisibility(8);
            }
        }

        public void onWindowSizeChanged(int i) {
            if (i < AndroidUtilities.dp(72.0f) + ActionBar.getCurrentActionBarHeight()) {
                ChatActivity.this.allowStickersPanel = false;
                if (ChatActivity.this.suggestEmojiPanel.getVisibility() == 0) {
                    ChatActivity.this.suggestEmojiPanel.setVisibility(4);
                }
            } else {
                ChatActivity.this.allowStickersPanel = true;
                if (ChatActivity.this.suggestEmojiPanel.getVisibility() == 4 && !ChatActivity.this.isInPreviewMode()) {
                    ChatActivity.this.suggestEmojiPanel.setVisibility(0);
                }
            }
            ChatActivity chatActivity = ChatActivity.this;
            chatActivity.allowContextBotPanel = true ^ chatActivity.chatActivityEnterView.isPopupShowing();
            int i2 = i + (ChatActivity.this.chatActivityEnterView.isPopupShowing() ? 65536 : 0);
            if (this.lastSize != i2) {
                ChatActivity.this.chatActivityEnterViewAnimateFromTop = 0;
                ChatActivity.this.chatActivityEnterViewAnimateBeforeSending = false;
            }
            this.lastSize = i2;
        }

        public boolean onceVoiceAvailable() {
            TLRPC.User user = ChatActivity.this.currentUser;
            if (user != null && !UserObject.isUserSelf(user)) {
                ChatActivity chatActivity = ChatActivity.this;
                if (!chatActivity.currentUser.bot && chatActivity.currentEncryptedChat == null && chatActivity.chatMode == 0) {
                    return true;
                }
            }
            return false;
        }

        public void openScheduledMessages() {
            ChatActivity.this.openScheduledMessages();
        }

        public void prepareMessageSending() {
            ChatActivity.this.waitingForSendingMessageLoad = true;
        }

        public void scrollToSendingMessage() {
            int sendingMessageId = ChatActivity.this.getSendMessagesHelper().getSendingMessageId(ChatActivity.this.dialog_id);
            if (sendingMessageId != 0) {
                ChatActivity.this.scrollToMessageId(sendingMessageId, 0, true, 0, true, 0);
            }
        }

        public void toggleVideoRecordingPause() {
            InstantCameraView instantCameraView = ChatActivity.this.instantCameraView;
            if (instantCameraView != null) {
                instantCameraView.togglePause();
            }
        }
    }

    public class ChatActivityFragmentView extends SizeNotifierFrameLayout {
        int backgroundColor;
        Paint backgroundPaint;
        ArrayList drawCaptionAfter;
        ArrayList drawNamesAfter;
        ArrayList drawReactionsAfter;
        ArrayList drawTimeAfter;
        int inputFieldHeight;
        int lastHeight;
        int lastWidth;
        private boolean pressActionBar;
        private long pressTime;
        private float x;
        private float y;

        public ChatActivityFragmentView(Context context, INavigationLayout iNavigationLayout) {
            super(context, iNavigationLayout);
            this.inputFieldHeight = 0;
            this.drawTimeAfter = new ArrayList();
            this.drawNamesAfter = new ArrayList();
            this.drawCaptionAfter = new ArrayList();
            this.drawReactionsAfter = new ArrayList();
            ((SizeNotifierFrameLayout) this).adjustPanLayoutHelper = new AdjustPanLayoutHelper(this) {
                @Override
                protected boolean heightAnimationEnabled() {
                    ChatAttachAlert chatAttachAlert;
                    INavigationLayout parentLayout = ChatActivity.this.getParentLayout();
                    ChatActivity chatActivity = ChatActivity.this;
                    if (chatActivity.isInsideContainer || ((BaseFragment) chatActivity).inPreviewMode || ((BaseFragment) ChatActivity.this).inBubbleMode || AndroidUtilities.isInMultiwindow || parentLayout == null || ChatActivity.this.fixedKeyboardHeight > 0 || System.currentTimeMillis() - ChatActivity.this.activityResumeTime < 250) {
                        return false;
                    }
                    if ((ChatActivity.this != parentLayout.getLastFragment() || !parentLayout.isTransitionAnimationInProgress()) && !parentLayout.isPreviewOpenAnimationInProgress() && !((BaseFragment) ChatActivity.this).isPaused) {
                        ChatActivity chatActivity2 = ChatActivity.this;
                        if (chatActivity2.openAnimationEnded && ((chatAttachAlert = chatActivity2.chatAttachAlert) == null || !chatAttachAlert.isShowing())) {
                            ChatActivityEnterView chatActivityEnterView = ChatActivity.this.chatActivityEnterView;
                            return chatActivityEnterView == null || chatActivityEnterView.getTrendingStickersAlert() == null || !ChatActivity.this.chatActivityEnterView.getTrendingStickersAlert().isShowing();
                        }
                    }
                    return false;
                }

                @Override
                protected void onPanTranslationUpdate(float f, float f2, boolean z) {
                    if (ChatActivity.this.getParentLayout() == null || !ChatActivity.this.getParentLayout().isPreviewOpenAnimationInProgress()) {
                        ChatActivity.this.contentPanTranslation = f;
                        ChatActivity.this.contentPanTranslationT = f2;
                        ChatActivityFragmentView chatActivityFragmentView = ChatActivity.this.contentView;
                        if (chatActivityFragmentView != null) {
                            chatActivityFragmentView.updateBlurContent();
                        }
                        ChatAttachAlert chatAttachAlert = ChatActivity.this.chatAttachAlert;
                        if (chatAttachAlert == null || !chatAttachAlert.isShowing()) {
                            ((BaseFragment) ChatActivity.this).actionBar.setTranslationY(f);
                            if (ChatActivity.this.tagSelector != null) {
                                ChatActivity.this.tagSelector.setTranslationY(ChatActivity.this.contentPanTranslation + (ChatActivity.this.actionBarSearchTags != null ? r3.getCurrentHeight() : 0));
                            }
                            if (ChatActivity.this.savedMessagesSearchHint != null) {
                                ChatActivity.this.savedMessagesSearchHint.setTranslationY(f);
                            }
                            if (ChatActivity.this.savedMessagesHint != null) {
                                ChatActivity.this.savedMessagesHint.setTranslationY(f);
                            }
                            SearchTagsList searchTagsList = ChatActivity.this.actionBarSearchTags;
                            if (searchTagsList != null) {
                                searchTagsList.setTranslationY(f);
                            }
                            TopicsTabsView topicsTabsView = ChatActivity.this.topicsTabs;
                            if (topicsTabsView != null) {
                                topicsTabsView.setTranslationY(f);
                            }
                            ChatSearchTabs chatSearchTabs = ChatActivity.this.hashtagSearchTabs;
                            if (chatSearchTabs != null) {
                                chatSearchTabs.setTranslationY(f);
                            }
                            if (ChatActivity.this.emptyViewContainer != null) {
                                ChatActivity.this.emptyViewContainer.setTranslationY(f / 2.0f);
                            }
                            if (ChatActivity.this.hashtagHistoryView != null) {
                                ChatActivity.this.hashtagHistoryView.setTranslationY(ChatActivity.this.getHashtagTabsHeight() + f);
                                ChatActivity.this.hashtagHistoryView.emptyView.setTranslationY((-f) / 2.0f);
                            }
                            if (ChatActivity.this.messagesSearchListContainer != null) {
                                ChatActivity.this.messagesSearchListContainer.setTranslationY(ChatActivity.this.getHashtagTabsHeight() + f);
                            }
                            if (ChatActivity.this.hashtagSearchEmptyView != null) {
                                ChatActivity.this.hashtagSearchEmptyView.setTranslationY((-f) / 2.0f);
                            }
                            if (ChatActivity.this.searchViewPager != null) {
                                View currentView = ChatActivity.this.searchViewPager.getCurrentView();
                                if (currentView instanceof ChatActivityContainer) {
                                    ChatActivity chatActivity = ((ChatActivityContainer) currentView).chatActivity;
                                    if (chatActivity.messagesSearchListContainer != null) {
                                        chatActivity.messagesSearchListContainer.setTranslationY(ChatActivity.this.getHashtagTabsHeight() + f);
                                    }
                                    if (chatActivity.hashtagSearchEmptyView != null) {
                                        chatActivity.hashtagSearchEmptyView.setTranslationY((-f) / 2.0f);
                                    }
                                }
                            }
                            ChatActivity.this.progressView.setTranslationY(f / 2.0f);
                            int i = (int) f;
                            ChatActivity.this.contentView.setBackgroundTranslation(i);
                            InstantCameraView instantCameraView = ChatActivity.this.instantCameraView;
                            if (instantCameraView != null) {
                                instantCameraView.onPanTranslationUpdate(f);
                            }
                            if (ChatActivity.this.blurredView != null) {
                                ChatActivity.this.blurredView.drawable.onPanTranslationUpdate(f);
                            }
                            ChatActivity.this.setFragmentPanTranslationOffset(i);
                            ChatActivity.this.invalidateChatListViewTopPadding();
                            ChatActivity.this.invalidateMessagesVisiblePart();
                        } else {
                            ChatActivityFragmentView.this.setNonNoveTranslation(f);
                        }
                        ChatActivity.this.chatListView.invalidate();
                        ChatActivity.this.updateBulletinLayout();
                        ChatActivityEnterView chatActivityEnterView = ChatActivity.this.chatActivityEnterView;
                        if (chatActivityEnterView != null) {
                            chatActivityEnterView.onAdjustPanTransitionUpdate(f, f2, z);
                        }
                        MentionsContainerView mentionsContainerView = ChatActivity.this.mentionContainer;
                        if (mentionsContainerView != null) {
                            mentionsContainerView.onPanTransitionUpdate(f);
                        }
                        if (AndroidUtilities.isTablet() && (ChatActivity.this.getParentActivity() instanceof LaunchActivity)) {
                            BaseFragment lastFragment = ((LaunchActivity) ChatActivity.this.getParentActivity()).getActionBarLayout().getLastFragment();
                            if (lastFragment instanceof DialogsActivity) {
                                ((DialogsActivity) lastFragment).setPanTranslationOffset(f);
                            }
                        }
                        if (ChatActivity.this.voiceHintTextView != null && ChatActivity.this.voiceHintTextView.getVisibility() == 0) {
                            ChatActivity.this.voiceHintTextView.showForView(ChatActivity.this.chatActivityEnterView.getAudioVideoButtonContainer(), false);
                        }
                        if (ChatActivity.this.fragmentContextView != null) {
                            ChatActivity.this.fragmentContextView.onPanTranslationUpdate(f);
                        }
                    }
                }

                @Override
                protected void onTransitionEnd() {
                    ChatActivityEnterView chatActivityEnterView = ChatActivity.this.chatActivityEnterView;
                    if (chatActivityEnterView != null) {
                        chatActivityEnterView.onAdjustPanTransitionEnd();
                    }
                    MentionsContainerView mentionsContainerView = ChatActivity.this.mentionContainer;
                    if (mentionsContainerView != null) {
                        mentionsContainerView.onPanTransitionEnd();
                    }
                    if (ChatActivity.this.voiceHintTextView == null || ChatActivity.this.voiceHintTextView.getVisibility() != 0) {
                        return;
                    }
                    ChatActivity.this.voiceHintTextView.showForView(ChatActivity.this.chatActivityEnterView.getAudioVideoButtonContainer(), false);
                }

                @Override
                protected void onTransitionStart(boolean z, int i) {
                    ChatActivity.this.wasManualScroll = true;
                    ChatActivityEnterView chatActivityEnterView = ChatActivity.this.chatActivityEnterView;
                    if (chatActivityEnterView != null) {
                        chatActivityEnterView.onAdjustPanTransitionStart(z, i);
                    }
                    MentionsContainerView mentionsContainerView = ChatActivity.this.mentionContainer;
                    if (mentionsContainerView != null) {
                        mentionsContainerView.onPanTransitionStart();
                    }
                    if (ChatActivity.this.mediaBanTooltip != null) {
                        ChatActivity.this.mediaBanTooltip.hide(false);
                    }
                    if (ChatActivity.this.factCheckHint != null) {
                        ChatActivity.this.factCheckHint.hide();
                    }
                }

                @Override
                protected int startOffset() {
                    if (ChatActivityFragmentView.this.getKeyboardHeight() > AndroidUtilities.dp(20.0f) || !ChatActivity.this.chatActivityEnterView.isPopupShowing()) {
                        return 0;
                    }
                    return ChatActivity.this.chatActivityEnterView.getEmojiPadding();
                }
            };
        }

        private void drawChildElement(Canvas canvas, float f, ChatMessageCell chatMessageCell, int i) {
            int save = canvas.save();
            float left = ChatActivity.this.chatListView.getLeft() + chatMessageCell.getX();
            float y = ChatActivity.this.chatListView.getY() + chatMessageCell.getY() + chatMessageCell.getPaddingTop();
            float alpha = chatMessageCell.shouldDrawAlphaLayer() ? chatMessageCell.getAlpha() : 1.0f;
            canvas.clipRect(ChatActivity.this.chatListView.getLeft(), f, ChatActivity.this.chatListView.getRight(), (ChatActivity.this.chatListView.getY() + ChatActivity.this.chatListView.getMeasuredHeight()) - ChatActivity.this.blurredViewBottomOffset);
            canvas.translate(left, y);
            chatMessageCell.setInvalidatesParent(true);
            if (i == 0) {
                chatMessageCell.drawTime(canvas, alpha, true);
            } else if (i == 1) {
                chatMessageCell.drawNamesLayout(canvas, alpha);
            } else if (i == 2) {
                chatMessageCell.drawCaptionLayout(canvas, chatMessageCell.getCurrentPosition() != null && (chatMessageCell.getCurrentPosition().flags & 1) == 0, alpha);
            } else if (i == 3) {
                boolean z = chatMessageCell.getCurrentPosition() != null && (chatMessageCell.getCurrentPosition().flags & 1) == 0;
                chatMessageCell.drawCommentLayout(canvas, alpha);
                if (!z) {
                    chatMessageCell.drawReactionsLayout(canvas, alpha, null);
                }
            } else if (i == 4 && ((chatMessageCell.getCurrentPosition() == null || (1 & chatMessageCell.getCurrentPosition().flags) != 0) && ChatActivity.this.scrimViewReaction != null)) {
                float f2 = (ChatActivity.this.scrimPaintAlpha * ChatActivity.this.scrimViewAlpha) / 0.2f;
                canvas.save();
                chatMessageCell.drawScrimReaction(canvas, ChatActivity.this.scrimViewReaction, f2, ChatActivity.this.scrimProgressDirection);
                canvas.restore();
                canvas.restore();
                canvas.save();
                canvas.translate(left, y);
                chatMessageCell.drawScrimReactionPreview(this, canvas, ChatActivity.this.scrimViewReactionOffset, ChatActivity.this.scrimViewReaction, f2);
                canvas.restore();
            }
            chatMessageCell.setInvalidatesParent(false);
            canvas.restoreToCount(save);
        }

        public void lambda$onMeasure$1(int i) {
            ChatActivity.this.chatLayoutManager.scrollToPositionWithOffset(i, ChatActivity.this.scrollToOffsetOnRecreate);
        }

        public void setNonNoveTranslation(float f) {
            ChatActivity.this.contentView.setTranslationY(f);
            ((BaseFragment) ChatActivity.this).actionBar.setTranslationY(0.0f);
            if (ChatActivity.this.tagSelector != null) {
                ChatActivity.this.tagSelector.setTranslationY(ChatActivity.this.actionBarSearchTags != null ? r2.getCurrentHeight() : 0);
            }
            if (ChatActivity.this.savedMessagesSearchHint != null) {
                ChatActivity.this.savedMessagesSearchHint.setTranslationY(0.0f);
            }
            if (ChatActivity.this.savedMessagesHint != null) {
                ChatActivity.this.savedMessagesHint.setTranslationY(0.0f);
            }
            SearchTagsList searchTagsList = ChatActivity.this.actionBarSearchTags;
            if (searchTagsList != null) {
                searchTagsList.setTranslationY(0.0f);
            }
            TopicsTabsView topicsTabsView = ChatActivity.this.topicsTabs;
            if (topicsTabsView != null) {
                topicsTabsView.setTranslationY(0.0f);
            }
            ChatSearchTabs chatSearchTabs = ChatActivity.this.hashtagSearchTabs;
            if (chatSearchTabs != null) {
                chatSearchTabs.setTranslationY(0.0f);
            }
            ChatActivity.this.emptyViewContainer.setTranslationY(0.0f);
            ChatActivity.this.progressView.setTranslationY(0.0f);
            ChatActivity.this.contentPanTranslation = 0.0f;
            ChatActivity.this.contentPanTranslationT = 0.0f;
            ChatActivity.this.contentView.setBackgroundTranslation(0);
            ChatActivityFragmentView chatActivityFragmentView = ChatActivity.this.contentView;
            if (chatActivityFragmentView != null) {
                chatActivityFragmentView.updateBlurContent();
            }
            InstantCameraView instantCameraView = ChatActivity.this.instantCameraView;
            if (instantCameraView != null) {
                instantCameraView.onPanTranslationUpdate(0.0f);
            }
            if (ChatActivity.this.blurredView != null) {
                ChatActivity.this.blurredView.drawable.onPanTranslationUpdate(0.0f);
            }
            ChatActivity.this.setFragmentPanTranslationOffset(0);
            ChatActivity.this.invalidateChatListViewTopPadding();
        }

        protected void dispatchDraw(android.graphics.Canvas r36) {
            throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.ChatActivityFragmentView.dispatchDraw(android.graphics.Canvas):void");
        }

        public boolean dispatchKeyEvent(KeyEvent keyEvent) {
            MessagePreviewView messagePreviewView;
            if (keyEvent.getKeyCode() != 4 || keyEvent.getAction() != 1 || (messagePreviewView = ChatActivity.this.forwardingPreviewView) == null || !messagePreviewView.isShowing()) {
                return super/*android.widget.FrameLayout*/.dispatchKeyEvent(keyEvent);
            }
            ChatActivity.this.forwardingPreviewView.dismiss(true);
            return true;
        }

        public boolean dispatchTouchEvent(android.view.MotionEvent r13) {
            throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.ChatActivityFragmentView.dispatchTouchEvent(android.view.MotionEvent):boolean");
        }

        protected boolean drawChild(android.graphics.Canvas r9, android.view.View r10, long r11) {
            throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.ChatActivityFragmentView.drawChild(android.graphics.Canvas, android.view.View, long):boolean");
        }

        protected void drawList(android.graphics.Canvas r8, boolean r9, java.util.ArrayList r10) {
            throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.ChatActivityFragmentView.drawList(android.graphics.Canvas, boolean, java.util.ArrayList):void");
        }

        protected float getBottomOffset() {
            return ChatActivity.this.chatListView.getBottom();
        }

        public ChatActivity getChatActivity() {
            return ChatActivity.this;
        }

        public int getKeyboardHeight() {
            if (ChatActivity.this.isInsideContainer) {
                return 0;
            }
            return super.getKeyboardHeight();
        }

        protected float getListTranslationY() {
            return ChatActivity.this.chatListView.getTranslationY();
        }

        protected Drawable getNewDrawable() {
            Drawable wallpaperDrawable = ChatActivity.this.themeDelegate.getWallpaperDrawable();
            return wallpaperDrawable != null ? wallpaperDrawable : super.getNewDrawable();
        }

        protected boolean getNewDrawableMotion() {
            return ChatActivity.this.themeDelegate.wallpaper == null ? super.getNewDrawableMotion() : ChatActivity.this.themeDelegate.wallpaper.settings != null && ChatActivity.this.themeDelegate.wallpaper.settings.motion;
        }

        protected int getScrollOffset() {
            return ChatActivity.this.chatListView.computeVerticalScrollOffset();
        }

        public void invalidateBlur() {
            super.invalidateBlur();
            if (ChatActivity.this.parentChatActivity != null) {
                ChatActivity.this.parentChatActivity.contentView.invalidateBlur();
            }
        }

        protected boolean invalidateOptimized() {
            return true;
        }

        protected boolean isActionBarVisible() {
            return ((BaseFragment) ChatActivity.this).actionBar.getVisibility() == 0;
        }

        protected void onAttachedToWindow() {
            super.onAttachedToWindow();
            ChatActivity chatActivity = ChatActivity.this;
            if (chatActivity.isInsideContainer) {
                ((SizeNotifierFrameLayout) this).adjustPanLayoutHelper.setResizableView(chatActivity.contentView);
            } else if (((BaseFragment) chatActivity).parentLayout != null && ((BaseFragment) ChatActivity.this).parentLayout.isSheet()) {
                ((SizeNotifierFrameLayout) this).adjustPanLayoutHelper.setResizableView((FrameLayout) ((BaseFragment) ChatActivity.this).parentLayout.getView().getParent().getParent().getParent().getParent());
            }
            ((SizeNotifierFrameLayout) this).adjustPanLayoutHelper.onAttach();
            ChatActivity.this.chatActivityEnterView.setAdjustPanLayoutHelper(((SizeNotifierFrameLayout) this).adjustPanLayoutHelper);
            MessageObject playingMessageObject = MediaController.getInstance().getPlayingMessageObject();
            if (playingMessageObject != null && ((playingMessageObject.isRoundVideo() || playingMessageObject.isVideo()) && playingMessageObject.eventId == 0 && playingMessageObject.getDialogId() == ChatActivity.this.dialog_id)) {
                MediaController.getInstance().setTextureView(ChatActivity.this.createTextureView(false), ChatActivity.this.aspectRatioFrameLayout, ChatActivity.this.videoPlayerContainer, true);
            }
            if (ChatActivity.this.pullingDownDrawable != null) {
                ChatActivity.this.pullingDownDrawable.onAttach();
            }
            ChatActivity.this.emojiAnimationsOverlay.onAttachedToWindow();
        }

        protected void onDetachedFromWindow() {
            super.onDetachedFromWindow();
            ((SizeNotifierFrameLayout) this).adjustPanLayoutHelper.onDetach();
            if (ChatActivity.this.pullingDownDrawable != null) {
                ChatActivity.this.pullingDownDrawable.onDetach();
                ChatActivity.this.pullingDownDrawable = null;
            }
            ChatActivity.this.emojiAnimationsOverlay.onDetachedFromWindow();
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ReactionsEffectOverlay.removeCurrent(true);
                }
            });
        }

        protected void onDraw(Canvas canvas) {
            if (getTag(67108867) != null) {
                return;
            }
            if (getTag(67108867) == null) {
                InstantCameraView instantCameraView = ChatActivity.this.instantCameraView;
                if (instantCameraView != null && instantCameraView.blurFullyDrawing()) {
                    return;
                }
                if (ChatActivity.this.blurredView != null && ChatActivity.this.blurredView.fullyDrawing() && ChatActivity.this.blurredView.getTag() != null) {
                    return;
                }
            }
            super/*android.widget.FrameLayout*/.onDraw(canvas);
        }

        protected void onLayout(boolean r17, int r18, int r19, int r20, int r21) {
            throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.ChatActivityFragmentView.onLayout(boolean, int, int, int, int):void");
        }

        protected void onMeasure(int r21, int r22) {
            throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.ChatActivityFragmentView.onMeasure(int, int):void");
        }

        public void requestLayout() {
            if (ChatActivity.this.globalIgnoreLayout) {
                return;
            }
            super/*android.widget.FrameLayout*/.requestLayout();
        }

        public void setPadding(int i, int i2, int i3, int i4) {
            ChatActivity.this.contentPaddingTop = i2;
            ChatActivity.this.invalidateChatListViewTopPadding();
            ChatActivity.this.invalidateMessagesVisiblePart();
        }

        public void updateBlurContent() {
            super.updateBlurContent();
            if (ChatActivity.this.parentChatActivity != null) {
                ChatActivity.this.parentChatActivity.contentView.updateBlurContent();
            }
        }
    }

    private static class ChatActivityTextSelectionHelper extends TextSelectionHelper.ChatListTextSelectionHelper {
        ChatActivity chatActivity;

        private ChatActivityTextSelectionHelper() {
        }

        @Override
        protected boolean canCopy() {
            ChatActivity chatActivity;
            TextSelectionHelper.SelectableView selectableView;
            ChatActivity chatActivity2 = this.chatActivity;
            if ((chatActivity2 == null || chatActivity2.getDialogId() != 489000) && (chatActivity = this.chatActivity) != null) {
                return (chatActivity.getDialogId() >= 0 || !this.chatActivity.getMessagesController().isChatNoForwards(-this.chatActivity.getDialogId())) && ((selectableView = this.selectedView) == null || ((ChatMessageCell) selectableView).getMessageObject() == null || ((ChatMessageCell) this.selectedView).getMessageObject().messageOwner == null || !((ChatMessageCell) this.selectedView).getMessageObject().messageOwner.noforwards);
            }
            return true;
        }

        @Override
        protected boolean canShowQuote() {
            TextSelectionHelper.SelectableView selectableView;
            ChatActivity chatActivity;
            ChatActivity chatActivity2 = this.chatActivity;
            if (chatActivity2 != null && chatActivity2.getDialogId() == 489000) {
                return false;
            }
            ChatActivity chatActivity3 = this.chatActivity;
            boolean z = (chatActivity3 != null && chatActivity3.getMessagesController().isChatNoForwards(this.chatActivity.getCurrentChat())) || !((selectableView = this.selectedView) == null || ((ChatMessageCell) selectableView).getMessageObject() == null || ((ChatMessageCell) this.selectedView).getMessageObject().messageOwner == null || !((ChatMessageCell) this.selectedView).getMessageObject().messageOwner.noforwards);
            if (this.isFactCheck || (chatActivity = this.chatActivity) == null || chatActivity.getCurrentEncryptedChat() != null) {
                return false;
            }
            TextSelectionHelper.SelectableView selectableView2 = this.selectedView;
            if ((selectableView2 != null && (((ChatMessageCell) selectableView2).getMessageObject() == null || ((ChatMessageCell) this.selectedView).getMessageObject().type == 23 || ((ChatMessageCell) this.selectedView).getMessageObject().isVoiceTranscriptionOpen() || ((ChatMessageCell) this.selectedView).getMessageObject().isInvoice() || this.chatActivity.textSelectionHelper.isDescription)) || this.chatActivity.getMessagesController().getTranslateController().isTranslatingDialog(this.chatActivity.dialog_id) || UserObject.isService(this.chatActivity.dialog_id)) {
                return false;
            }
            return !z || this.chatActivity.getCurrentChat() == null || ChatObject.canWriteToChat(this.chatActivity.getCurrentChat());
        }

        @Override
        public int getParentBottomPadding() {
            ChatActivity chatActivity = this.chatActivity;
            if (chatActivity == null) {
                return 0;
            }
            return chatActivity.blurredViewBottomOffset;
        }

        @Override
        public int getParentTopPadding() {
            ChatActivity chatActivity = this.chatActivity;
            if (chatActivity == null) {
                return 0;
            }
            return (int) chatActivity.chatListViewPaddingTop;
        }

        @Override
        protected Theme.ResourcesProvider getResourcesProvider() {
            ChatActivity chatActivity = this.chatActivity;
            if (chatActivity != null) {
                return chatActivity.themeDelegate;
            }
            return null;
        }

        @Override
        protected int getThemedColor(int i) {
            return Theme.getColor(i, this.chatActivity.themeDelegate);
        }

        @Override
        protected void onQuoteClick(MessageObject messageObject, int i, int i2, CharSequence charSequence) {
            ChatActivity chatActivity;
            MessageObject.GroupedMessages group;
            if (messageObject == null || (chatActivity = this.chatActivity) == null) {
                return;
            }
            int min = Math.min(i2, chatActivity.getMessagesController().quoteLengthMax + i);
            if (messageObject.getGroupId() != 0 && (group = this.chatActivity.getGroup(messageObject.getGroupId())) != null && !group.isDocuments) {
                messageObject = group.captionMessage;
            }
            if (messageObject == null) {
                return;
            }
            ReplyQuote from = ReplyQuote.from(messageObject, i, min);
            if (from.getText() == null) {
                return;
            }
            ChatActivityEnterView chatActivityEnterView = this.chatActivity.chatActivityEnterView;
            if (chatActivityEnterView != null && chatActivityEnterView.getVisibility() == 0) {
                if (((BaseFragment) this.chatActivity).actionBar != null && ((BaseFragment) this.chatActivity).actionBar.isActionModeShowed()) {
                    this.chatActivity.clearSelectionMode();
                }
                this.chatActivity.showFieldPanelForReplyQuote(messageObject, from);
                ChatActivityEnterView chatActivityEnterView2 = this.chatActivity.chatActivityEnterView;
                if (chatActivityEnterView2 != null) {
                    chatActivityEnterView2.openKeyboard();
                    return;
                }
                return;
            }
            this.chatActivity.replyingQuote = from;
            this.chatActivity.replyingMessageObject = messageObject;
            this.chatActivity.forbidForwardingWithDismiss = false;
            ChatActivity chatActivity2 = this.chatActivity;
            chatActivity2.messagePreviewParams = new MessagePreviewParams(chatActivity2.currentEncryptedChat != null, chatActivity2.getMessagesController().isChatNoForwards(this.chatActivity.currentChat), ChatObject.isMonoForum(this.chatActivity.currentChat));
            ChatActivity chatActivity3 = this.chatActivity;
            chatActivity3.messagePreviewParams.updateReply(chatActivity3.replyingMessageObject, this.chatActivity.getGroup(messageObject.getGroupId()), this.chatActivity.getDialogId(), this.chatActivity.replyingQuote);
            Bundle bundle = new Bundle();
            bundle.putBoolean("onlySelect", true);
            bundle.putInt("dialogsType", 3);
            bundle.putBoolean("quote", true);
            bundle.putInt("messagesCount", 1);
            bundle.putBoolean("canSelectTopics", true);
            DialogsActivity dialogsActivity = new DialogsActivity(bundle);
            dialogsActivity.setDelegate(this.chatActivity);
            this.chatActivity.presentFragment(dialogsActivity);
        }

        public void setChatActivity(ChatActivity chatActivity) {
            cancelAllAnimators();
            clear();
            this.textSelectionOverlay = null;
            this.chatActivity = chatActivity;
        }
    }

    class ChatMessageCellDelegate implements ChatMessageCell.ChatMessageCellDelegate {

        class AnonymousClass1 extends ShareAlert {
            final boolean val$includeStory;
            final MessageObject val$messageObject;

            AnonymousClass1(Context context, ChatActivity chatActivity, ArrayList arrayList, String str, String str2, boolean z, String str3, String str4, boolean z2, boolean z3, boolean z4, Integer num, Theme.ResourcesProvider resourcesProvider, boolean z5, MessageObject messageObject) {
                super(context, chatActivity, arrayList, str, str2, z, str3, str4, z2, z3, z4, num, resourcesProvider);
                this.val$includeStory = z5;
                this.val$messageObject = messageObject;
                ((ShareAlert) this).includeStoryFromMessage = z5;
            }

            public void lambda$onShareStory$0(Long l) {
                TLRPC.Chat chat;
                String str = (l.longValue() >= 0 || (chat = ChatActivity.this.getMessagesController().getChat(Long.valueOf(-l.longValue()))) == null) ? "" : chat.title;
                BulletinFactory.of(ChatActivity.this).createSimpleBulletin(R.raw.contact_check, AndroidUtilities.replaceTags(TextUtils.isEmpty(str) ? LocaleController.getString(R.string.RepostedToProfile) : LocaleController.formatString(R.string.RepostedToChannelProfile, new Object[]{str}))).show();
            }

            public void lambda$onShareStory$1(StoryRecorder storyRecorder, View view, Long l, Runnable runnable, Boolean bool, final Long l2) {
                boolean booleanValue = bool.booleanValue();
                StoryRecorder.SourceView sourceView = null;
                if (booleanValue) {
                    AndroidUtilities.runOnUIThread(new Runnable() {
                        @Override
                        public final void run() {
                            ChatActivity.ChatMessageCellDelegate.AnonymousClass1.this.lambda$onShareStory$0(l2);
                        }
                    });
                    dismiss();
                } else if ((view instanceof ShareDialogCell) && view.isAttachedToWindow()) {
                    sourceView = StoryRecorder.SourceView.fromShareCell((ShareDialogCell) view);
                }
                storyRecorder.replaceSourceView(sourceView);
                AndroidUtilities.runOnUIThread(runnable);
            }

            public void dismissInternal() {
                AndroidUtilities.requestAdjustResize(ChatActivity.this.getParentActivity(), ((BaseFragment) ChatActivity.this).classGuid);
                super.dismissInternal();
                if (ChatActivity.this.chatActivityEnterView.getVisibility() == 0) {
                    ((BaseFragment) ChatActivity.this).fragmentView.requestLayout();
                }
            }

            protected void onSend(LongSparseArray longSparseArray, int i, TLRPC.TL_forumTopic tL_forumTopic, boolean z) {
                ChatActivity.this.createUndoView();
                if (ChatActivity.this.undoView == null || !z) {
                    return;
                }
                if (longSparseArray.size() != 1) {
                    ChatActivity.this.undoView.showWithAction(0L, 53, Integer.valueOf(i), Integer.valueOf(longSparseArray.size()), (Runnable) null, (Runnable) null);
                } else {
                    if (((TLRPC.Dialog) longSparseArray.valueAt(0)).id == ChatActivity.this.getUserConfig().getClientUserId() && BulletinFactory.of(ChatActivity.this).showForwardedBulletinWithTag(((TLRPC.Dialog) longSparseArray.valueAt(0)).id, i)) {
                        return;
                    }
                    ChatActivity.this.undoView.showWithAction(((TLRPC.Dialog) longSparseArray.valueAt(0)).id, 53, Integer.valueOf(i), tL_forumTopic, (Runnable) null, (Runnable) null);
                }
            }

            protected void onShareStory(final View view) {
                StoryRecorder.SourceView fromShareCell = view instanceof ShareDialogCell ? StoryRecorder.SourceView.fromShareCell((ShareDialogCell) view) : null;
                ArrayList arrayList = new ArrayList();
                MessageObject.GroupedMessages groupedMessages = this.val$messageObject.getGroupId() != 0 ? (MessageObject.GroupedMessages) ChatActivity.this.groupedMessagesMap.get(this.val$messageObject.getGroupId()) : null;
                if (groupedMessages != null) {
                    arrayList.addAll(groupedMessages.messages);
                } else {
                    arrayList.add(this.val$messageObject);
                }
                final StoryRecorder storyRecorder = StoryRecorder.getInstance(ChatActivity.this.getParentActivity(), ((BottomSheet) this).currentAccount);
                storyRecorder.setOnPrepareCloseListener(new Utilities.Callback4() {
                    public final void run(Object obj, Object obj2, Object obj3, Object obj4) {
                        ChatActivity.ChatMessageCellDelegate.AnonymousClass1.this.lambda$onShareStory$1(storyRecorder, view, (Long) obj, (Runnable) obj2, (Boolean) obj3, (Long) obj4);
                    }
                });
                storyRecorder.openRepost(fromShareCell, StoryEntry.repostMessage(arrayList));
            }
        }

        class AnonymousClass10 extends Browser.Progress {
            final ChatMessageCell val$cell;

            AnonymousClass10(ChatMessageCell chatMessageCell) {
                this.val$cell = chatMessageCell;
            }

            public void end(boolean z) {
                if (z) {
                    return;
                }
                final ChatActivity chatActivity = ChatActivity.this;
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.access$54900(ChatActivity.this);
                    }
                }, 250L);
            }

            public void init() {
                ChatActivity.this.progressDialogAtMessageId = this.val$cell.getMessageObject().getId();
                ChatActivity.this.progressDialogAtMessageType = 2;
                ChatActivity.this.progressDialogLinkSpan = null;
                this.val$cell.invalidate();
            }
        }

        class AnonymousClass11 extends Browser.Progress {
            final ChatMessageCell val$cell;

            AnonymousClass11(ChatMessageCell chatMessageCell) {
                this.val$cell = chatMessageCell;
            }

            public void end(boolean z) {
                if (z) {
                    return;
                }
                final ChatActivity chatActivity = ChatActivity.this;
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.access$54900(ChatActivity.this);
                    }
                }, 250L);
            }

            public void init() {
                ChatActivity.this.progressDialogAtMessageId = this.val$cell.getMessageObject().getId();
                ChatActivity.this.progressDialogAtMessageType = 2;
                ChatActivity.this.progressDialogLinkSpan = null;
                this.val$cell.invalidate();
            }
        }

        class AnonymousClass12 extends Browser.Progress {
            final ChatMessageCell val$cell;

            AnonymousClass12(ChatMessageCell chatMessageCell) {
                this.val$cell = chatMessageCell;
            }

            public void end(boolean z) {
                if (z) {
                    return;
                }
                final ChatActivity chatActivity = ChatActivity.this;
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.access$54900(ChatActivity.this);
                    }
                }, 250L);
            }

            public void init() {
                ChatActivity.this.progressDialogAtMessageId = this.val$cell.getMessageObject().getId();
                ChatActivity.this.progressDialogAtMessageType = 2;
                ChatActivity.this.progressDialogLinkSpan = null;
                this.val$cell.invalidate();
            }
        }

        class AnonymousClass13 extends Browser.Progress {
            final ChatMessageCell val$cell;

            AnonymousClass13(ChatMessageCell chatMessageCell) {
                this.val$cell = chatMessageCell;
            }

            public void end(boolean z) {
                if (z) {
                    return;
                }
                final ChatActivity chatActivity = ChatActivity.this;
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.access$54900(ChatActivity.this);
                    }
                }, 250L);
            }

            public void init() {
                ChatActivity.this.progressDialogAtMessageId = this.val$cell.getMessageObject().getId();
                ChatActivity.this.progressDialogAtMessageType = 2;
                ChatActivity.this.progressDialogLinkSpan = null;
                this.val$cell.invalidate();
            }
        }

        class AnonymousClass5 extends Browser.Progress {
            final ChatMessageCell val$cell;

            AnonymousClass5(ChatMessageCell chatMessageCell) {
                this.val$cell = chatMessageCell;
            }

            public void end(boolean z) {
                if (z) {
                    return;
                }
                final ChatActivity chatActivity = ChatActivity.this;
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.access$54900(ChatActivity.this);
                    }
                }, 250L);
            }

            public void init() {
                ChatActivity.this.progressDialogAtMessageId = this.val$cell.getMessageObject().getId();
                ChatActivity.this.progressDialogAtMessageType = 2;
                ChatActivity.this.progressDialogLinkSpan = null;
                this.val$cell.invalidate();
            }
        }

        class AnonymousClass6 extends Browser.Progress {
            final ChatMessageCell val$cell;
            final MessageObject val$messageObject;

            AnonymousClass6(MessageObject messageObject, ChatMessageCell chatMessageCell) {
                this.val$messageObject = messageObject;
                this.val$cell = chatMessageCell;
            }

            public void end(boolean z) {
                if (z) {
                    return;
                }
                final ChatActivity chatActivity = ChatActivity.this;
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.access$54900(ChatActivity.this);
                    }
                }, 250L);
            }

            public void init() {
                ChatActivity.this.progressDialogAtMessageId = this.val$messageObject.getId();
                ChatActivity.this.progressDialogAtMessageType = 0;
                ChatActivity.this.progressDialogLinkSpan = null;
                this.val$cell.invalidate();
            }
        }

        class AnonymousClass7 extends Browser.Progress {
            final ChatMessageCell val$cell;

            AnonymousClass7(ChatMessageCell chatMessageCell) {
                this.val$cell = chatMessageCell;
            }

            public void end(boolean z) {
                if (z) {
                    return;
                }
                final ChatActivity chatActivity = ChatActivity.this;
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.access$54900(ChatActivity.this);
                    }
                }, 250L);
            }

            public void init() {
                ChatActivity.this.progressDialogAtMessageId = this.val$cell.getMessageObject().getId();
                ChatActivity.this.progressDialogAtMessageType = 2;
                ChatActivity.this.progressDialogLinkSpan = null;
                this.val$cell.invalidate();
            }
        }

        class AnonymousClass8 extends Browser.Progress {
            final ChatMessageCell val$cell;

            AnonymousClass8(ChatMessageCell chatMessageCell) {
                this.val$cell = chatMessageCell;
            }

            public void end(boolean z) {
                if (z) {
                    return;
                }
                final ChatActivity chatActivity = ChatActivity.this;
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.access$54900(ChatActivity.this);
                    }
                }, 250L);
            }

            public void init() {
                ChatActivity.this.progressDialogAtMessageId = this.val$cell.getMessageObject().getId();
                ChatActivity.this.progressDialogAtMessageType = 2;
                ChatActivity.this.progressDialogLinkSpan = null;
                this.val$cell.invalidate();
            }
        }

        class AnonymousClass9 extends Browser.Progress {
            final ChatMessageCell val$cell;

            AnonymousClass9(ChatMessageCell chatMessageCell) {
                this.val$cell = chatMessageCell;
            }

            public void end(boolean z) {
                if (z) {
                    return;
                }
                final ChatActivity chatActivity = ChatActivity.this;
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.access$54900(ChatActivity.this);
                    }
                }, 250L);
            }

            public void init() {
                ChatActivity.this.progressDialogAtMessageId = this.val$cell.getMessageObject().getId();
                ChatActivity.this.progressDialogAtMessageType = 2;
                ChatActivity.this.progressDialogLinkSpan = null;
                this.val$cell.invalidate();
            }
        }

        private ChatMessageCellDelegate() {
        }

        public void lambda$didLongPressChannelAvatar$16(TLRPC.Chat chat) {
            SpannableStringBuilder spannableStringBuilder;
            ChatActivityEnterView chatActivityEnterView = ChatActivity.this.chatActivityEnterView;
            if (chatActivityEnterView != null) {
                CharSequence fieldText = chatActivityEnterView.getFieldText();
                if (fieldText != null) {
                    spannableStringBuilder = new SpannableStringBuilder(fieldText);
                    if (fieldText.charAt(fieldText.length() - 1) != ' ') {
                        spannableStringBuilder.append((CharSequence) " ");
                    }
                } else {
                    spannableStringBuilder = new SpannableStringBuilder();
                }
                if (spannableStringBuilder.length() > 0 && spannableStringBuilder.charAt(spannableStringBuilder.length() - 1) != ' ') {
                    spannableStringBuilder.append(' ');
                }
                String publicUsername = ChatObject.getPublicUsername(chat);
                if (publicUsername != null) {
                    spannableStringBuilder.append((CharSequence) "@").append((CharSequence) publicUsername).append((CharSequence) " ");
                    ChatActivity.this.chatActivityEnterView.setFieldText(spannableStringBuilder);
                    AndroidUtilities.runOnUIThread(new Runnable() {
                        @Override
                        public final void run() {
                            ChatActivity.ChatMessageCellDelegate.this.lambda$appendMention$11();
                        }
                    }, 200L);
                }
            }
        }

        public void lambda$didLongPressUserAvatar$9(TLRPC.User user) {
            SpannableStringBuilder spannableStringBuilder;
            ChatActivityEnterView chatActivityEnterView = ChatActivity.this.chatActivityEnterView;
            if (chatActivityEnterView != null) {
                CharSequence fieldText = chatActivityEnterView.getFieldText();
                if (fieldText != null) {
                    spannableStringBuilder = new SpannableStringBuilder(fieldText);
                    if (fieldText.charAt(fieldText.length() - 1) != ' ') {
                        spannableStringBuilder.append((CharSequence) " ");
                    }
                } else {
                    spannableStringBuilder = new SpannableStringBuilder();
                }
                if (spannableStringBuilder.length() > 0 && spannableStringBuilder.charAt(spannableStringBuilder.length() - 1) != ' ') {
                    spannableStringBuilder.append(' ');
                }
                String publicUsername = UserObject.getPublicUsername(user);
                if (publicUsername != null) {
                    spannableStringBuilder.append((CharSequence) "@").append((CharSequence) publicUsername).append((CharSequence) " ");
                } else {
                    SpannableString spannableString = new SpannableString(UserObject.getFirstName(user, false) + " ");
                    spannableString.setSpan(new URLSpanUserMention("" + user.id, 3), 0, spannableString.length(), 33);
                    spannableStringBuilder.append((CharSequence) spannableString);
                }
                ChatActivity.this.chatActivityEnterView.setFieldText(spannableStringBuilder);
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.ChatMessageCellDelegate.this.lambda$appendMention$12();
                    }
                }, 200L);
            }
        }

        private boolean isAvatarPreviewerEnabled() {
            TLRPC.Chat chat;
            return UserObject.isUserSelf(ChatActivity.this.currentUser) || ((chat = ChatActivity.this.currentChat) != null && (!ChatObject.isChannel(chat) || ChatActivity.this.currentChat.megagroup));
        }

        public void lambda$appendMention$11() {
            ChatActivity.this.chatActivityEnterView.openKeyboard();
        }

        public void lambda$appendMention$12() {
            ChatActivity.this.chatActivityEnterView.openKeyboard();
        }

        public void lambda$didLongPressChannelAvatar$13(TLRPC.Chat chat, ChatMessageCell chatMessageCell, AvatarPreviewer.MenuItem menuItem) {
            int i = AnonymousClass165.$SwitchMap$org$telegram$ui$AvatarPreviewer$MenuItem[menuItem.ordinal()];
            if (i == 1) {
                lambda$didLongPressChannelAvatar$14(chat);
                return;
            }
            if (i == 2) {
                lambda$didLongPressChannelAvatar$16(chat);
                return;
            }
            if (i == 3) {
                ChatActivity.this.lambda$openSearchWithChat$360(chat);
            } else if (i == 4 || i == 5) {
                openChat(chatMessageCell, chat, 0, false);
            }
        }

        public void lambda$didLongPressChannelAvatar$15(ChatMessageCell chatMessageCell, TLRPC.Chat chat) {
            openChat(chatMessageCell, chat, 0, false);
        }

        public void lambda$didLongPressChannelAvatar$17(TLRPC.Chat chat) {
            ChatActivity.this.lambda$openSearchWithChat$360(chat);
        }

        public void lambda$didLongPressToDoButton$28() {
            ChatActivity.this.selectedObject = null;
            ChatActivity.this.selectedObjectGroup = null;
        }

        public void lambda$didLongPressUserAvatar$10(TLRPC.User user) {
            ChatActivity.this.lambda$openSearchWithUser$359(user);
        }

        public void lambda$didLongPressUserAvatar$6(ChatMessageCell chatMessageCell, TLRPC.User user, AvatarPreviewer.MenuItem menuItem) {
            int i = AnonymousClass165.$SwitchMap$org$telegram$ui$AvatarPreviewer$MenuItem[menuItem.ordinal()];
            if (i == 1) {
                lambda$didLongPressUserAvatar$7(user);
                return;
            }
            if (i == 2) {
                lambda$didLongPressUserAvatar$9(user);
            } else if (i == 3) {
                ChatActivity.this.lambda$openSearchWithUser$359(user);
            } else {
                if (i != 6) {
                    return;
                }
                lambda$didLongPressUserAvatar$8(chatMessageCell, user);
            }
        }

        public void lambda$didPressChannelRecommendation$36(View view) {
            if (((BaseFragment) ChatActivity.this).parentLayout != null) {
                ((BaseFragment) ChatActivity.this).parentLayout.expandPreviewFragment();
            }
        }

        public void lambda$didPressChannelRecommendation$37(TLRPC.Chat chat) {
            BulletinFactory.of(ChatActivity.this).createSimpleBulletin(R.raw.contact_check, LocaleController.formatString(R.string.YouJoinedChannel, new Object[]{chat == null ? "" : chat.title})).show(true);
        }

        public void lambda$didPressChannelRecommendation$38(final TLRPC.Chat chat, ChatMessageCell chatMessageCell, View view) {
            ChatActivity.this.finishPreviewFragment();
            chat.left = false;
            if (chatMessageCell != null && chatMessageCell.channelRecommendationsCell != null) {
                ChatActivity.this.getNotificationCenter().postNotificationName(NotificationCenter.channelRecommendationsLoaded, new Object[]{Long.valueOf(chatMessageCell.channelRecommendationsCell.chatId)});
            }
            ChatActivity.this.getMessagesController().addUserToChat(chat.id, ChatActivity.this.getUserConfig().getCurrentUser(), 0, (String) null, ChatActivity.this, new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.ChatMessageCellDelegate.this.lambda$didPressChannelRecommendation$37(chat);
                }
            });
        }

        public void lambda$didPressCustomBotButton$19(TLRPC.Message message, String str) {
            ChatActivity.this.getMessagesController().rejectSuggestedMessage(DialogObject.getPeerDialogId(message.peer_id), message.id, str);
        }

        public static void lambda$didPressCustomBotButton$20(Bulletin[] bulletinArr, DialogInterface dialogInterface) {
            Bulletin bulletin = bulletinArr[0];
            if (bulletin != null) {
                bulletin.hide();
            }
        }

        public void lambda$didPressCustomBotButton$21(MessageObject messageObject, boolean z, int i) {
            if (z) {
                ChatActivity.this.getMessagesController().approveSuggestedMessage(DialogObject.getPeerDialogId(messageObject.messageOwner.peer_id), messageObject.messageOwner.id, i);
            }
        }

        public void lambda$didPressCustomBotButton$22(TLRPC.Message message, AlertDialog[] alertDialogArr, final MessageObject messageObject, DialogInterface.OnDismissListener onDismissListener) {
            if (message.suggested_post.schedule_date != 0) {
                ChatActivity.this.getMessagesController().approveSuggestedMessage(DialogObject.getPeerDialogId(messageObject.messageOwner.peer_id), messageObject.messageOwner.id, 0);
            } else {
                alertDialogArr[0].setOnDismissListener(null);
                AlertsCreator.createSuggestedMessageDatePickerDialog(ChatActivity.this.getContext(), 0L, new AlertsCreator.ScheduleDatePickerDelegate() {
                    public final void didSelectDate(boolean z, int i) {
                        ChatActivity.ChatMessageCellDelegate.this.lambda$didPressCustomBotButton$21(messageObject, z, i);
                    }
                }, ChatActivity.this.getResourceProvider(), 1).show().setOnDismissListener(onDismissListener);
            }
        }

        public void lambda$didPressCustomBotButton$23(final TLRPC.Message message, boolean z, final MessageObject messageObject) {
            SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
            spannableStringBuilder.append((CharSequence) AndroidUtilities.replaceTags(LocaleController.formatString(R.string.SuggestedMessageAcceptInfo, new Object[]{ChatActivity.this.getMessagesController().getPeerName(DialogObject.getPeerDialogId(message.from_id))})));
            spannableStringBuilder.append((CharSequence) "\n\n");
            AmountUtils.Amount ofSafe = AmountUtils.Amount.ofSafe(message.suggested_post.price);
            int i = (ofSafe.currency == AmountUtils.Currency.TON ? ChatActivity.this.getMessagesController().config.tonSuggestedPostCommissionPermille : ChatActivity.this.getMessagesController().config.starsSuggestedPostCommissionPermille).get();
            if (z) {
                ofSafe = AmountUtils.Amount.fromNano((ofSafe.asNano() / 1000) * i, ofSafe.currency);
            }
            AmountUtils.Amount amount = ofSafe;
            spannableStringBuilder.append((CharSequence) AndroidUtilities.replaceTags(message.suggested_post.schedule_date == 0 ? z ? LocaleController.formatString(R.string.SuggestedMessageAcceptInfoAnytimeAdmin2, new Object[]{amount.formatAsDecimalSpaced(), AffiliateProgramFragment.percents(i)}) : LocaleController.formatString(R.string.SuggestedMessageAcceptInfoAnytimeUser2, new Object[]{amount.formatAsDecimalSpaced()}) : z ? LocaleController.formatString(R.string.SuggestedMessageAcceptInfoAdmin2, new Object[]{amount.formatAsDecimalSpaced(), MessageSuggestionOfferSheet.formatDateTime(message.suggested_post.schedule_date), AffiliateProgramFragment.percents(i)}) : LocaleController.formatString(R.string.SuggestedMessageAcceptInfoUser2, new Object[]{amount.formatAsDecimalSpaced(), MessageSuggestionOfferSheet.formatDateTime(message.suggested_post.schedule_date)})));
            spannableStringBuilder.append(' ');
            spannableStringBuilder.append((CharSequence) AndroidUtilities.replaceTags(LocaleController.formatString(R.string.SuggestedMessageAcceptInfo3, new Object[]{Long.valueOf(MessagesController.getInstance(((BaseFragment) ChatActivity.this).currentAccount).config.starsSuggestedPostAgeMin.get(TimeUnit.HOURS))})));
            final Bulletin[] bulletinArr = new Bulletin[1];
            final DialogInterface.OnDismissListener onDismissListener = new DialogInterface.OnDismissListener() {
                @Override
                public final void onDismiss(DialogInterface dialogInterface) {
                    ChatActivity.ChatMessageCellDelegate.lambda$didPressCustomBotButton$20(bulletinArr, dialogInterface);
                }
            };
            final AlertDialog[] alertDialogArr = new AlertDialog[1];
            AlertDialog showSimpleConfirmAlert = AlertsCreator.showSimpleConfirmAlert(ChatActivity.this, LocaleController.getString(R.string.SuggestedPostAcceptTitle), spannableStringBuilder, LocaleController.getString(message.suggested_post.schedule_date == 0 ? R.string.Next : R.string.SuggestedPostPublish), false, new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.ChatMessageCellDelegate.this.lambda$didPressCustomBotButton$22(message, alertDialogArr, messageObject, onDismissListener);
                }
            });
            alertDialogArr[0] = showSimpleConfirmAlert;
            showSimpleConfirmAlert.setOnDismissListener(onDismissListener);
            if (z && amount.currency == AmountUtils.Currency.STARS) {
                bulletinArr[0] = BulletinFactory.of(Bulletin.BulletinWindow.make(ChatActivity.this.getContext()), ((BaseFragment) ChatActivity.this).resourceProvider).createSimpleBulletin(R.raw.info, LocaleController.getString(R.string.SuggestedMessageAcceptStarsDisclaimer), 10).setDuration(60000).show(true);
            }
        }

        public void lambda$didPressFactCheckWhat$0(HintView2 hintView2) {
            ChatActivity.this.contentView.removeView(hintView2);
            if (hintView2 == ChatActivity.this.factCheckHint) {
                ChatActivity.this.factCheckHint = null;
            }
        }

        public void lambda$didPressFactCheckWhat$1(ChatMessageCell chatMessageCell, int i, int i2) {
            if (ChatActivity.this.factCheckHint == null) {
                return;
            }
            chatMessageCell.getLocationInWindow(new int[2]);
            ChatActivity.this.factCheckHint.setTranslationY(((r0[1] - ChatActivity.this.factCheckHint.getTop()) - AndroidUtilities.dp(520.0f)) + i);
            ChatActivity.this.factCheckHint.setJointPx(0.0f, (-AndroidUtilities.dp(16.0f)) + r0[0] + i2);
            ChatActivity.this.factCheckHint.show();
        }

        public void lambda$didPressImage$41(MessageObject messageObject) {
            if (ChatActivity.this.checkSlowModeAlert()) {
                SendMessagesHelper.SendMessageParams of = SendMessagesHelper.SendMessageParams.of(messageObject.getDiceEmoji(), ChatActivity.this.dialog_id, ChatActivity.this.replyingMessageObject, ChatActivity.this.getThreadMessage(), (TLRPC.WebPage) null, false, (ArrayList) null, (TLRPC.ReplyMarkup) null, (HashMap) null, true, 0, (MessageObject.SendAnimationData) null, false);
                of.quick_reply_shortcut_id = ChatActivity.this.getQuickReplyId();
                ChatActivity chatActivity = ChatActivity.this;
                of.quick_reply_shortcut = chatActivity.quickReplyShortcut;
                chatActivity.getSendMessagesHelper().sendMessage(of);
            }
        }

        public void lambda$didPressInstantButton$42(TLObject tLObject, boolean z) {
            ChatActivity.this.progressDialogCurrent.end();
            if (!(tLObject instanceof TLRPC.TL_messages_stickerSet)) {
                BulletinFactory.of(ChatActivity.this).createSimpleBulletin(R.raw.error, LocaleController.getString(z ? R.string.AddEmojiNotFound : R.string.AddStickersNotFound)).show(true);
                return;
            }
            TLRPC.TL_messages_stickerSet tL_messages_stickerSet = (TLRPC.TL_messages_stickerSet) tLObject;
            MediaDataController.getInstance(((BaseFragment) ChatActivity.this).currentAccount).putStickerSet(tL_messages_stickerSet, false);
            TLRPC.TL_inputStickerSetID tL_inputStickerSetID = new TLRPC.TL_inputStickerSetID();
            TLRPC.StickerSet stickerSet = ((TLRPC.messages_StickerSet) tL_messages_stickerSet).set;
            ((TLRPC.InputStickerSet) tL_inputStickerSetID).access_hash = stickerSet.access_hash;
            ((TLRPC.InputStickerSet) tL_inputStickerSetID).id = stickerSet.id;
            if (!z) {
                Activity parentActivity = ChatActivity.this.getParentActivity();
                ChatActivity chatActivity = ChatActivity.this;
                StickersAlert stickersAlert = new StickersAlert(parentActivity, chatActivity, tL_inputStickerSetID, (TLRPC.TL_messages_stickerSet) null, chatActivity.chatActivityEnterView, chatActivity.themeDelegate, false);
                stickersAlert.setCalcMandatoryInsets(ChatActivity.this.isKeyboardVisible());
                ChatActivity.this.showDialog(stickersAlert);
                return;
            }
            ArrayList arrayList = new ArrayList(1);
            arrayList.add(tL_inputStickerSetID);
            ChatActivity chatActivity2 = ChatActivity.this;
            EmojiPacksAlert emojiPacksAlert = new EmojiPacksAlert(chatActivity2, chatActivity2.getParentActivity(), ChatActivity.this.themeDelegate, arrayList);
            emojiPacksAlert.setCalcMandatoryInsets(ChatActivity.this.isKeyboardVisible());
            ChatActivity.this.showDialog(emojiPacksAlert);
        }

        public void lambda$didPressInstantButton$43(final boolean z, final TLObject tLObject, TLRPC.TL_error tL_error) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.ChatMessageCellDelegate.this.lambda$didPressInstantButton$42(tLObject, z);
                }
            });
        }

        public void lambda$didPressInstantButton$44(int i) {
            ConnectionsManager.getInstance(((BaseFragment) ChatActivity.this).currentAccount).cancelRequest(i, true);
        }

        public void lambda$didPressMoreChannelRecommendations$35() {
            ChatActivity.this.presentFragment(new PremiumPreviewFragment("similar_channels"));
        }

        public void lambda$didPressOther$3(AlertDialog alertDialog, TLObject tLObject, HashSet hashSet, TLRPC.TL_inputGroupCallInviteMessage tL_inputGroupCallInviteMessage, MessageObject messageObject, TLRPC.TL_error tL_error) {
            ChatActivity chatActivity;
            BottomSheetWithRecyclerListView createGroupCallSheet;
            alertDialog.dismiss();
            if (tLObject instanceof TL_phone.groupCall) {
                TL_phone.groupCall groupcall = (TL_phone.groupCall) tLObject;
                ChatActivity.this.getMessagesController().putUsers(groupcall.users, false);
                ChatActivity.this.getMessagesController().putChats(groupcall.chats, false);
                if (!groupcall.participants.isEmpty()) {
                    VoIPHelper.joinConference(ChatActivity.this.getParentActivity(), ((BaseFragment) ChatActivity.this).currentAccount, tL_inputGroupCallInviteMessage, messageObject.messageOwner.action.video, groupcall.call);
                    return;
                } else {
                    chatActivity = ChatActivity.this;
                    createGroupCallSheet = new CreateGroupCallSheet(ChatActivity.this.getContext(), hashSet);
                }
            } else {
                if (tL_error == null || !"GROUPCALL_INVALID".equalsIgnoreCase(tL_error.text)) {
                    if (tL_error != null) {
                        BulletinFactory.of(ChatActivity.this).showForError(tL_error);
                        return;
                    }
                    return;
                }
                chatActivity = ChatActivity.this;
                createGroupCallSheet = new CreateGroupCallSheet(ChatActivity.this.getContext(), hashSet);
            }
            chatActivity.showDialog(createGroupCallSheet);
        }

        public void lambda$didPressOther$4(final AlertDialog alertDialog, final HashSet hashSet, final TLRPC.TL_inputGroupCallInviteMessage tL_inputGroupCallInviteMessage, final MessageObject messageObject, final TLObject tLObject, final TLRPC.TL_error tL_error) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.ChatMessageCellDelegate.this.lambda$didPressOther$3(alertDialog, tLObject, hashSet, tL_inputGroupCallInviteMessage, messageObject, tL_error);
                }
            });
        }

        public void lambda$didPressOther$5(int i, DialogInterface dialogInterface) {
            ChatActivity.this.getConnectionsManager().cancelRequest(i, true);
        }

        public void lambda$didPressReplyMessage$39(MessageObject messageObject) {
            ChatActivity.this.progressDialogAtMessageId = messageObject.getId();
            ChatActivity.this.progressDialogAtMessageType = 0;
        }

        public void lambda$didPressReplyMessage$40(int i, final MessageObject messageObject) {
            ChatActivity.this.scrollToMessageId(i, messageObject.getId(), true, messageObject.getDialogId() == ChatActivity.this.mergeDialogId ? 1 : 0, true, 0, new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.ChatMessageCellDelegate.this.lambda$didPressReplyMessage$39(messageObject);
                }
            });
        }

        public static void lambda$didPressRevealSensitiveContent$45(boolean[] zArr, View view) {
            boolean z = !zArr[0];
            zArr[0] = z;
            ((CheckBoxCell) view).setChecked(z, true);
        }

        public void lambda$didPressRevealSensitiveContent$46() {
            ChatActivity.this.presentFragment(new ThemeActivity(0).highlightSensitiveRow());
        }

        public void lambda$didPressRevealSensitiveContent$47(boolean[] zArr, TL_account.contentSettings contentsettings, ChatMessageCell chatMessageCell, AlertDialog alertDialog, int i) {
            if (!zArr[0]) {
                if (chatMessageCell.getMessageObject() != null) {
                    chatMessageCell.getMessageObject().isSensitiveCached = Boolean.FALSE;
                }
                chatMessageCell.startRevealMedia();
                return;
            }
            if (contentsettings != null && contentsettings.sensitive_can_change) {
                ChatActivity.this.getMessagesController().setContentSettings(true);
                BulletinFactory.of(ChatActivity.this).createSimpleBulletinDetail(R.raw.chats_infotip, AndroidUtilities.replaceArrows(AndroidUtilities.premiumText(LocaleController.getString(R.string.SensitiveContentSettingsToast), new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.ChatMessageCellDelegate.this.lambda$didPressRevealSensitiveContent$46();
                    }
                }), true)).show(true);
            }
            for (int i2 = 0; i2 < ChatActivity.this.chatListView.getChildCount(); i2++) {
                View childAt = ChatActivity.this.chatListView.getChildAt(i2);
                if (childAt instanceof ChatMessageCell) {
                    ChatMessageCell chatMessageCell2 = (ChatMessageCell) childAt;
                    if (chatMessageCell2.getMessageObject() != null && chatMessageCell2.getMessageObject().isSensitive()) {
                        chatMessageCell2.startRevealMedia();
                    }
                }
            }
        }

        public void lambda$didPressRevealSensitiveContent$48(AlertDialog alertDialog, final ChatMessageCell chatMessageCell, final TL_account.contentSettings contentsettings) {
            alertDialog.dismissUnless(200L);
            final boolean[] zArr = new boolean[1];
            FrameLayout frameLayout = new FrameLayout(ChatActivity.this.getContext());
            if (contentsettings != null && contentsettings.sensitive_can_change) {
                CheckBoxCell checkBoxCell = new CheckBoxCell(ChatActivity.this.getContext(), 1, ChatActivity.this.getResourceProvider());
                checkBoxCell.setBackground(Theme.getSelectorDrawable(false));
                checkBoxCell.setText(LocaleController.getString(R.string.MessageShowSensitiveContentAlways), "", zArr[0], false);
                checkBoxCell.setPadding(LocaleController.isRTL ? AndroidUtilities.dp(16.0f) : AndroidUtilities.dp(8.0f), 0, LocaleController.isRTL ? AndroidUtilities.dp(8.0f) : AndroidUtilities.dp(16.0f), 0);
                frameLayout.addView(checkBoxCell, LayoutHelper.createFrame(-1, 48.0f, 51, 0.0f, 0.0f, 0.0f, 0.0f));
                checkBoxCell.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public final void onClick(View view) {
                        ChatActivity.ChatMessageCellDelegate.lambda$didPressRevealSensitiveContent$45(zArr, view);
                    }
                });
            }
            ChatActivity chatActivity = ChatActivity.this;
            chatActivity.showDialog(new AlertDialog.Builder(chatActivity.getContext(), ChatActivity.this.getResourceProvider()).setTitle(LocaleController.getString(R.string.MessageShowSensitiveContentMediaTitle)).setMessage(LocaleController.getString(R.string.MessageShowSensitiveContentMediaText)).setView(frameLayout).setCustomViewOffset(9).setNegativeButton(LocaleController.getString(R.string.Cancel), null).setPositiveButton(LocaleController.getString(R.string.MessageShowSensitiveContentButton), new AlertDialog.OnButtonClickListener() {
                @Override
                public final void onClick(AlertDialog alertDialog2, int i) {
                    ChatActivity.ChatMessageCellDelegate.this.lambda$didPressRevealSensitiveContent$47(zArr, contentsettings, chatMessageCell, alertDialog2, i);
                }
            }).create());
        }

        public void lambda$didPressToDoButton$34() {
            ChatActivity.this.showDialog(new PremiumFeatureBottomSheet(ChatActivity.this, 39, false));
        }

        public void lambda$needShowPremiumBulletin$24() {
            new PremiumFeatureBottomSheet(ChatActivity.this, 8, true).show();
            ChatActivity.this.getMessagesController().pressTranscribeButton();
        }

        public void lambda$needShowPremiumBulletin$25() {
            new PremiumFeatureBottomSheet(ChatActivity.this, 8, true).show();
            ChatActivity.this.getMessagesController().pressTranscribeButton();
        }

        public void lambda$needShowPremiumBulletin$26() {
            new PremiumFeatureBottomSheet(ChatActivity.this, 8, true).show();
            ChatActivity.this.getMessagesController().pressTranscribeButton();
        }

        public void lambda$openChat$18(final Browser.Progress progress, TLRPC.Chat chat, int i, final ChatActivity chatActivity) {
            progress.onCancel(ChatActivity.this.getMessagesController().ensureMessagesLoaded(-chat.id, i, new MessagesController.MessagesLoadedCallback() {
                public void onError() {
                    progress.end();
                    ChatActivity.this.presentFragment(chatActivity);
                }

                public void onMessagesLoaded(boolean z) {
                    progress.end();
                    ChatActivity.this.presentFragment(chatActivity);
                }
            }));
        }

        public void lambda$sendMessageFromQuickShare$2(ArrayList arrayList, long j) {
            AlertsCreator.showSendMediaAlert(SendMessagesHelper.getInstance(((BaseFragment) ChatActivity.this).currentAccount).sendMessage(arrayList, j, false, false, true, 0, (MessageObject) null, -1, 0L, ChatActivity.this.getSendMonoForumPeerId(), ChatActivity.this.getSendMessageSuggestionParams()), ChatActivity.this, (Theme.ResourcesProvider) null);
        }

        private void openChat(ChatMessageCell chatMessageCell, final TLRPC.Chat chat, final int i, boolean z) {
            ChatActivity chatActivity = ChatActivity.this;
            TLRPC.Chat chat2 = chatActivity.currentChat;
            if (chat2 != null && chat.id == chat2.id) {
                ChatAvatarContainer chatAvatarContainer = chatActivity.avatarContainer;
                if (chatAvatarContainer != null && i == 0) {
                    chatAvatarContainer.openProfile(false);
                    return;
                } else {
                    if (chatMessageCell.getMessageObject() != null) {
                        ChatActivity.this.scrollToMessageId(i, chatMessageCell.getMessageObject().getId(), true, 0, false, 0);
                        return;
                    }
                    return;
                }
            }
            if (chat2 == null || chat.id != chat2.id || chatActivity.isThreadChat()) {
                Bundle bundle = new Bundle();
                bundle.putLong("chat_id", chat.id);
                if (i != 0) {
                    bundle.putInt("message_id", i);
                }
                Browser.Progress makeProgressForForward = z ? ChatActivity.this.makeProgressForForward(chatMessageCell) : null;
                if (ChatActivity.this.getMessagesController().checkCanOpenChat(bundle, ChatActivity.this, chatMessageCell.getMessageObject(), makeProgressForForward)) {
                    final ChatActivity chatActivity2 = new ChatActivity(bundle);
                    if (makeProgressForForward == null || i == 0) {
                        ChatActivity.this.presentFragment(chatActivity2);
                        return;
                    }
                    final Browser.Progress progress = makeProgressForForward;
                    AndroidUtilities.runOnUIThread(new Runnable() {
                        @Override
                        public final void run() {
                            ChatActivity.ChatMessageCellDelegate.this.lambda$openChat$18(progress, chat, i, chatActivity2);
                        }
                    }, 5000L);
                    makeProgressForForward.init();
                }
            }
        }

        public void lambda$didLongPressUserAvatar$8(ChatMessageCell chatMessageCell, TLRPC.User user) {
            if (user != null) {
                Bundle bundle = new Bundle();
                bundle.putLong("user_id", user.id);
                if (ChatActivity.this.getMessagesController().checkCanOpenChat(bundle, ChatActivity.this, chatMessageCell.getMessageObject())) {
                    ChatActivity.this.presentFragment(new ChatActivity(bundle));
                }
            }
        }

        public void lambda$didLongPressChannelAvatar$14(TLRPC.Chat chat) {
            openProfile(chat, false);
        }

        private void openProfile(TLRPC.Chat chat, boolean z) {
            if (chat != null) {
                Bundle bundle = new Bundle();
                bundle.putLong("chat_id", chat.id);
                bundle.putBoolean("expandPhoto", z);
                ChatActivity.this.presentFragment(new ProfileActivity(bundle));
            }
        }

        public void lambda$didLongPressUserAvatar$7(TLRPC.User user) {
            openProfile(user, false);
        }

        private void openProfile(TLRPC.User user, boolean z) {
            if (user == null || user.id == 489000) {
                return;
            }
            TLRPC.UserProfilePhoto userProfilePhoto = user.photo;
            int i = 0;
            if (userProfilePhoto == null || (userProfilePhoto instanceof TLRPC.TL_userProfilePhotoEmpty)) {
                z = false;
            }
            Bundle bundle = new Bundle();
            bundle.putLong("user_id", user.id);
            bundle.putBoolean("expandPhoto", z);
            ProfileActivity profileActivity = new ProfileActivity(bundle);
            TLRPC.User user2 = ChatActivity.this.currentUser;
            if (user2 != null && user2.id == user.id) {
                i = 1;
            }
            profileActivity.setPlayProfileAnimation(i);
            AndroidUtilities.setAdjustResizeToNothing(ChatActivity.this.getParentActivity(), ((BaseFragment) ChatActivity.this).classGuid);
            ChatActivity.this.presentFragment(profileActivity);
        }

        private Bulletin sendMessageFromQuickShare(ChatMessageCell chatMessageCell) {
            Runnable runnable;
            MessageObject.GroupedMessages groupedMessages;
            if (ChatActivity.this.quickShareSelectorOverlay == null) {
                return null;
            }
            MessageObject selectedMessageObject = ChatActivity.this.quickShareSelectorOverlay.getSelectedMessageObject(chatMessageCell);
            final long selectedDialogId = ChatActivity.this.quickShareSelectorOverlay.getSelectedDialogId(chatMessageCell);
            if (selectedMessageObject == null || selectedDialogId == 0) {
                return null;
            }
            if (AlertsCreator.checkSlowMode(ChatActivity.this.getContext(), ((BaseFragment) ChatActivity.this).currentAccount, selectedDialogId, false)) {
                return null;
            }
            final ArrayList arrayList = (selectedMessageObject.getGroupId() == 0 || (groupedMessages = (MessageObject.GroupedMessages) ChatActivity.this.groupedMessagesMap.get(selectedMessageObject.getGroupId())) == null) ? null : groupedMessages.messages;
            if (arrayList == null) {
                arrayList = new ArrayList();
                arrayList.add(selectedMessageObject);
            }
            boolean z = selectedDialogId == UserConfig.getInstance(UserConfig.selectedAccount).clientUserId;
            Runnable runnable2 = new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.ChatMessageCellDelegate.this.lambda$sendMessageFromQuickShare$2(arrayList, selectedDialogId);
                }
            };
            if (z) {
                runnable2.run();
                runnable = null;
            } else {
                runnable = runnable2;
            }
            Context context = ChatActivity.this.getContext();
            ChatActivity chatActivity = ChatActivity.this;
            Bulletin createForwardedBulletin = BulletinFactory.createForwardedBulletin(context, chatActivity, (FrameLayout) null, 1, selectedDialogId, 1, chatActivity.getThemedColor(Theme.key_undo_background), ChatActivity.this.getThemedColor(Theme.key_undo_infoColor), 5000, (Runnable) null, runnable);
            return createForwardedBulletin.allowBlur().show(createForwardedBulletin.getLayout() instanceof Bulletin.LottieLayoutWithReactions);
        }

        @Override
        public boolean canDrawOutboundsContent() {
            return false;
        }

        @Override
        public boolean canPerformActions() {
            return (((BaseFragment) ChatActivity.this).actionBar == null || ((BaseFragment) ChatActivity.this).actionBar.isActionModeShowed() || ChatActivity.this.isReport() || ((BaseFragment) ChatActivity.this).inPreviewMode) ? false : true;
        }

        @Override
        public boolean canPerformReply() {
            return (ChatActivity.this.isReport() || ((BaseFragment) ChatActivity.this).inPreviewMode) ? false : true;
        }

        @Override
        public void didLongPress(ChatMessageCell chatMessageCell, float f, float f2) {
            ChatActivity.this.createMenu(chatMessageCell, false, false, f, f2, false);
            ChatActivity chatActivity = ChatActivity.this;
            chatActivity.startMultiselect(chatActivity.chatListView.getChildAdapterPosition(chatMessageCell));
        }

        @Override
        public void didLongPressBotButton(ChatMessageCell chatMessageCell, TLRPC.KeyboardButton keyboardButton) {
            if (ChatActivity.this.chatMode == 5 || ChatActivity.this.getParentActivity() == null) {
                return;
            }
            if (ChatActivity.this.bottomOverlayChat.getVisibility() != 0 || (keyboardButton instanceof TLRPC.TL_keyboardButtonSwitchInline) || (keyboardButton instanceof TLRPC.TL_keyboardButtonCallback) || (keyboardButton instanceof TLRPC.TL_keyboardButtonGame) || (keyboardButton instanceof TLRPC.TL_keyboardButtonUrl) || (keyboardButton instanceof TLRPC.TL_keyboardButtonBuy) || (keyboardButton instanceof TLRPC.TL_keyboardButtonUrlAuth) || (keyboardButton instanceof TLRPC.TL_keyboardButtonUserProfile) || (keyboardButton instanceof TLRPC.TL_keyboardButtonCopy)) {
                if (keyboardButton instanceof TLRPC.TL_keyboardButtonCopy) {
                    ChatActivity.this.didLongPressCopyButton(((TLRPC.TL_keyboardButtonCopy) keyboardButton).copy_text);
                } else if (keyboardButton instanceof TLRPC.TL_keyboardButtonUrl) {
                    ChatActivity.this.openClickableLink(null, keyboardButton.url, true, chatMessageCell, chatMessageCell.getMessageObject(), false);
                    try {
                        chatMessageCell.performHapticFeedback(0, 1);
                    } catch (Exception unused) {
                    }
                }
            }
        }

        @Override
        public boolean didLongPressChannelAvatar(final org.telegram.ui.Cells.ChatMessageCell r8, final org.telegram.tgnet.TLRPC.Chat r9, int r10, float r11, float r12) {
            throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.ChatMessageCellDelegate.didLongPressChannelAvatar(org.telegram.ui.Cells.ChatMessageCell, org.telegram.tgnet.TLRPC$Chat, int, float, float):boolean");
        }

        @Override
        public void didLongPressCustomBotButton(ChatMessageCell chatMessageCell, BotInlineKeyboard.ButtonCustom buttonCustom) {
            ChatMessageCell.ChatMessageCellDelegate.CC.$default$didLongPressCustomBotButton(this, chatMessageCell, buttonCustom);
        }

        @Override
        public boolean didLongPressToDoButton(ChatMessageCell chatMessageCell, TLRPC.TodoItem todoItem) {
            if (ChatActivity.this.getParentActivity() == null || ChatActivity.this.getContext() == null) {
                return false;
            }
            if (ChatActivity.this.savedMessagesTagHint != null && ChatActivity.this.savedMessagesTagHint.shown()) {
                ChatActivity.this.savedMessagesTagHint.hide();
            }
            if (ChatActivity.this.videoConversionTimeHint != null && ChatActivity.this.videoConversionTimeHint.shown()) {
                ChatActivity.this.videoConversionTimeHint.hide();
            }
            MessageObject primaryMessageObject = chatMessageCell.getPrimaryMessageObject();
            TLRPC.MessageMedia media = MessageObject.getMedia(primaryMessageObject);
            if (primaryMessageObject == null || !(media instanceof TLRPC.TL_messageMediaToDo)) {
                return false;
            }
            ChatActivity.this.selectedObject = primaryMessageObject;
            ChatActivity.this.selectedObjectGroup = null;
            TodoItemMenu todoItemMenu = new TodoItemMenu(ChatActivity.this.getContext(), ChatActivity.this.getResourceProvider());
            todoItemMenu.setCell(ChatActivity.this, chatMessageCell, todoItem.id);
            ArrayList arrayList = new ArrayList();
            ArrayList arrayList2 = new ArrayList();
            ArrayList arrayList3 = new ArrayList();
            ChatActivity.this.fillMessageMenu(primaryMessageObject, arrayList, arrayList2, arrayList3);
            final ChatActivity chatActivity = ChatActivity.this;
            todoItemMenu.setupMessageOptions(chatActivity, arrayList, arrayList2, arrayList3, new Utilities.Callback() {
                public final void run(Object obj) {
                    ChatActivity.access$11300(ChatActivity.this, ((Integer) obj).intValue());
                }
            });
            todoItemMenu.setOnDismissListener(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.ChatMessageCellDelegate.this.lambda$didLongPressToDoButton$28();
                }
            });
            todoItemMenu.show();
            return true;
        }

        @Override
        public boolean didLongPressUserAvatar(final org.telegram.ui.Cells.ChatMessageCell r8, final org.telegram.tgnet.TLRPC.User r9, float r10, float r11) {
            throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.ChatMessageCellDelegate.didLongPressUserAvatar(org.telegram.ui.Cells.ChatMessageCell, org.telegram.tgnet.TLRPC$User, float, float):boolean");
        }

        @Override
        public void didPressAboutRevenueSharingAds() {
            ChatActivity chatActivity = ChatActivity.this;
            if (chatActivity.contentView == null || chatActivity.getParentActivity() == null) {
                return;
            }
            Context context = ChatActivity.this.contentView.getContext();
            ChatActivity chatActivity2 = ChatActivity.this;
            RevenueSharingAdsInfoBottomSheet.showAlert(context, chatActivity2, false, ((BaseFragment) chatActivity2).resourceProvider);
        }

        @Override
        public boolean didPressAnimatedEmoji(ChatMessageCell chatMessageCell, AnimatedEmojiSpan animatedEmojiSpan) {
            TLRPC.InputStickerSet inputStickerSet;
            if (ChatActivity.this.getMessagesController().premiumFeaturesBlocked() || animatedEmojiSpan == null || animatedEmojiSpan.standard) {
                return false;
            }
            long documentId = animatedEmojiSpan.getDocumentId();
            TLRPC.Document document = animatedEmojiSpan.document;
            if (document == null) {
                document = AnimatedEmojiDrawable.findDocument(((BaseFragment) ChatActivity.this).currentAccount, documentId);
            }
            if (document == null || (inputStickerSet = MessageObject.getInputStickerSet(document)) == null) {
                return false;
            }
            MediaDataController.getInstance(UserConfig.selectedAccount).getStickerSet(inputStickerSet, true);
            ArrayList arrayList = new ArrayList(1);
            arrayList.add(inputStickerSet);
            ChatActivity chatActivity = ChatActivity.this;
            EmojiPacksAlert emojiPacksAlert = new EmojiPacksAlert(chatActivity, chatActivity.getParentActivity(), ChatActivity.this.themeDelegate, arrayList);
            emojiPacksAlert.setPreviewEmoji(document);
            emojiPacksAlert.setCalcMandatoryInsets(ChatActivity.this.isKeyboardVisible());
            ChatActivity.this.showDialog(emojiPacksAlert);
            return true;
        }

        @Override
        public void didPressBoostCounter(ChatMessageCell chatMessageCell) {
            ChatActivity.this.getNotificationCenter().postNotificationName(NotificationCenter.openBoostForUsersDialog, new Object[]{Long.valueOf(ChatActivity.this.dialog_id), chatMessageCell});
        }

        @Override
        public void didPressBotButton(ChatMessageCell chatMessageCell, TLRPC.KeyboardButton keyboardButton) {
            if (ChatActivity.this.chatMode == 5 || ChatActivity.this.getParentActivity() == null) {
                return;
            }
            if (ChatActivity.this.bottomOverlayChat.getVisibility() != 0 || (keyboardButton instanceof TLRPC.TL_keyboardButtonSwitchInline) || (keyboardButton instanceof TLRPC.TL_keyboardButtonCallback) || (keyboardButton instanceof TLRPC.TL_keyboardButtonGame) || (keyboardButton instanceof TLRPC.TL_keyboardButtonUrl) || (keyboardButton instanceof TLRPC.TL_keyboardButtonBuy) || (keyboardButton instanceof TLRPC.TL_keyboardButtonUrlAuth) || (keyboardButton instanceof TLRPC.TL_keyboardButtonUserProfile) || (keyboardButton instanceof TLRPC.TL_keyboardButtonRequestPeer) || (keyboardButton instanceof TLRPC.TL_keyboardButtonCopy)) {
                ChatActivity.this.chatActivityEnterView.didPressedBotButton(keyboardButton, chatMessageCell.getMessageObject(), chatMessageCell.getMessageObject(), ChatActivity.this.makeProgressForBotButton(chatMessageCell, keyboardButton instanceof TLRPC.TL_keyboardButtonUrl ? keyboardButton.url : null));
            }
        }

        @Override
        public void didPressCancelSendButton(ChatMessageCell chatMessageCell) {
            MessageObject messageObject = chatMessageCell.getMessageObject();
            if (messageObject.messageOwner.send_state != 0) {
                ChatActivity.this.getSendMessagesHelper().cancelSendingMessage(messageObject);
            }
        }

        @Override
        public void didPressChannelAvatar(ChatMessageCell chatMessageCell, TLRPC.Chat chat, int i, float f, float f2, boolean z) {
            MessageObject messageObject;
            if (chat == null) {
                return;
            }
            if (((BaseFragment) ChatActivity.this).actionBar.isActionModeShowed() || ChatActivity.this.isReport()) {
                ChatActivity.this.processRowSelect(chatMessageCell, true, f, f2);
                return;
            }
            if (z || !chat.signature_profiles || (messageObject = chatMessageCell.getMessageObject()) == null || messageObject.getDialogId() == 1271266957) {
                openChat(chatMessageCell, chat, i, z);
            } else {
                ChatActivity.this.openUserProfile(DialogObject.getPeerDialogId(messageObject.messageOwner.from_id));
            }
        }

        @Override
        public void didPressChannelRecommendation(final ChatMessageCell chatMessageCell, TLObject tLObject, boolean z) {
            long j;
            String str;
            if (ChatActivity.this.getContext() == null || tLObject == null) {
                return;
            }
            if (((BaseFragment) ChatActivity.this).parentLayout == null || !((BaseFragment) ChatActivity.this).parentLayout.isInPreviewMode()) {
                Bundle bundle = new Bundle();
                boolean z2 = tLObject instanceof TLRPC.Chat;
                if (z2) {
                    j = ((TLRPC.Chat) tLObject).id;
                    str = "chat_id";
                } else {
                    if (!(tLObject instanceof TLRPC.User)) {
                        return;
                    }
                    j = ((TLRPC.User) tLObject).id;
                    str = "user_id";
                }
                bundle.putLong(str, j);
                if (!z || !z2) {
                    ChatActivity.this.presentFragment(new ChatActivity(bundle));
                    return;
                }
                final TLRPC.Chat chat = (TLRPC.Chat) tLObject;
                ActionBarPopupWindow.ActionBarPopupWindowLayout actionBarPopupWindowLayout = new ActionBarPopupWindow.ActionBarPopupWindowLayout(ChatActivity.this.getContext(), R.drawable.popup_fixed_alert, ChatActivity.this.getResourceProvider(), 2);
                actionBarPopupWindowLayout.setBackgroundColor(ChatActivity.this.getThemedColor(Theme.key_actionBarDefaultSubmenuBackground));
                ActionBarMenuSubItem actionBarMenuSubItem = new ActionBarMenuSubItem(ChatActivity.this.getParentActivity(), false, false);
                actionBarMenuSubItem.setTextAndIcon(LocaleController.getString(R.string.OpenChannel2), R.drawable.msg_channel);
                actionBarMenuSubItem.setMinimumWidth(160);
                actionBarMenuSubItem.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public final void onClick(View view) {
                        ChatActivity.ChatMessageCellDelegate.this.lambda$didPressChannelRecommendation$36(view);
                    }
                });
                actionBarPopupWindowLayout.addView(actionBarMenuSubItem);
                ActionBarMenuSubItem actionBarMenuSubItem2 = new ActionBarMenuSubItem(ChatActivity.this.getParentActivity(), false, false);
                actionBarMenuSubItem2.setTextAndIcon(LocaleController.getString(R.string.ProfileJoinChannel), R.drawable.msg_addbot);
                actionBarMenuSubItem2.setMinimumWidth(160);
                actionBarMenuSubItem2.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public final void onClick(View view) {
                        ChatActivity.ChatMessageCellDelegate.this.lambda$didPressChannelRecommendation$38(chat, chatMessageCell, view);
                    }
                });
                actionBarPopupWindowLayout.addView(actionBarMenuSubItem2);
                ChatActivity chatActivity = new ChatActivity(bundle);
                chatActivity.allowExpandPreviewByClick = true;
                ChatActivity.this.presentFragmentAsPreviewWithMenu(chatActivity, actionBarPopupWindowLayout);
                ChatActivity.this.checkShowBlur(true);
            }
        }

        @Override
        public void didPressChannelRecommendationsClose(ChatMessageCell chatMessageCell) {
            MessageObject messageObject = chatMessageCell.getMessageObject();
            if (messageObject == null || messageObject.type != 27) {
                return;
            }
            messageObject.toggleChannelRecommendations();
            messageObject.forceUpdate = true;
            chatMessageCell.forceResetMessageObject();
            chatMessageCell.requestLayout();
            ChatActivity.this.chatAdapter.updateRowWithMessageObject(messageObject, false, false);
        }

        @Override
        public void didPressCodeCopy(ChatMessageCell chatMessageCell, MessageObject.TextLayoutBlock textLayoutBlock) {
            StaticLayout staticLayout;
            if (textLayoutBlock == null || (staticLayout = textLayoutBlock.textLayout) == null || staticLayout.getText() == null) {
                return;
            }
            String charSequence = textLayoutBlock.textLayout.getText().toString();
            SpannableString spannableString = new SpannableString(charSequence);
            spannableString.setSpan(new CodeHighlighting.Span(false, 0, (TextStyleSpan.TextStyleRun) null, textLayoutBlock.language, charSequence), 0, spannableString.length(), 33);
            AndroidUtilities.addToClipboard(spannableString);
            BulletinFactory.of(ChatActivity.this).createCopyBulletin(LocaleController.getString(R.string.CodeCopied)).show();
        }

        @Override
        public void didPressCommentButton(ChatMessageCell chatMessageCell) {
            long j;
            int i;
            MessageObject.GroupedMessages currentMessagesGroup = chatMessageCell.getCurrentMessagesGroup();
            MessageObject messageObject = (currentMessagesGroup == null || currentMessagesGroup.messages.isEmpty()) ? chatMessageCell.getMessageObject() : (MessageObject) currentMessagesGroup.messages.get(0);
            TLRPC.MessageReplies messageReplies = messageObject.messageOwner.replies;
            if (messageReplies != null) {
                i = messageReplies.read_max_id;
                j = messageReplies.channel_id;
            } else {
                j = 0;
                i = -1;
            }
            ChatActivity chatActivity = ChatActivity.this;
            chatActivity.openDiscussionMessageChat(chatActivity.currentChat.id, messageObject, messageObject.getId(), j, i, 0, null);
        }

        @Override
        public void didPressCustomBotButton(ChatMessageCell chatMessageCell, BotInlineKeyboard.ButtonCustom buttonCustom) {
            final TLRPC.Message message;
            final MessageObject messageObject = chatMessageCell.getMessageObject();
            if (messageObject == null || (message = messageObject.messageOwner) == null) {
                return;
            }
            int i = buttonCustom.id;
            if (i == 1) {
                AlertsCreator.showDeclineSuggestedPostDialog(ChatActivity.this, DialogObject.getPeerDialogId(message.from_id), true, new Utilities.Callback() {
                    public final void run(Object obj) {
                        ChatActivity.ChatMessageCellDelegate.this.lambda$didPressCustomBotButton$19(message, (String) obj);
                    }
                });
                return;
            }
            if (i != 2) {
                if (i == 3) {
                    ChatActivity.this.createMenu(chatMessageCell, true, false, chatMessageCell.getLastTouchX(), chatMessageCell.getLastTouchY(), true, false, true);
                }
            } else if (message.suggested_post != null) {
                final boolean canManageMonoForum = ChatObject.canManageMonoForum(((BaseFragment) ChatActivity.this).currentAccount, ChatActivity.this.currentChat);
                if (canManageMonoForum) {
                    ChatObject.canUserDoChannelDirectAdminAction(((BaseFragment) ChatActivity.this).currentAccount, ChatActivity.this.currentChat, 5);
                }
                Runnable runnable = new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.ChatMessageCellDelegate.this.lambda$didPressCustomBotButton$23(message, canManageMonoForum, messageObject);
                    }
                };
                ChatActivity chatActivity = ChatActivity.this;
                TLRPC.SuggestedPost suggestedPost = message.suggested_post;
                chatActivity.checkStarsNeedSheet(runnable, AmountUtils.Amount.of(suggestedPost != null ? suggestedPost.price : null), !canManageMonoForum);
            }
        }

        @Override
        public void didPressEffect(ChatMessageCell chatMessageCell) {
            ChatActivity chatActivity = ChatActivity.this;
            chatActivity.emojiAnimationsOverlay.onTapItem(chatMessageCell, chatActivity, true);
            ChatActivity.this.chatListView.cancelClickRunnables(false);
        }

        @Override
        public void didPressExtendedMediaPreview(ChatMessageCell chatMessageCell, TLRPC.KeyboardButton keyboardButton) {
            ChatActivity.this.getSendMessagesHelper().sendCallback(true, chatMessageCell.getMessageObject(), keyboardButton, ChatActivity.this);
        }

        @Override
        public void didPressFactCheck(ChatMessageCell chatMessageCell) {
            MessageObject primaryMessageObject;
            int i;
            int i2;
            if (chatMessageCell == null || (primaryMessageObject = chatMessageCell.getPrimaryMessageObject()) == null) {
                return;
            }
            primaryMessageObject.factCheckExpanded = !primaryMessageObject.factCheckExpanded;
            primaryMessageObject.forceUpdate = true;
            if (ChatActivity.this.chatListView != null && ChatActivity.this.chatLayoutManager != null && !ChatActivity.this.chatLayoutManager.hasPendingScrollPosition()) {
                for (int childCount = ChatActivity.this.chatListView.getChildCount() - 1; childCount >= 0; childCount--) {
                    View childAt = ChatActivity.this.chatListView.getChildAt(childCount);
                    i = ChatActivity.this.chatListView.getChildAdapterPosition(childAt);
                    if (i >= 0) {
                        if (!(childAt instanceof ChatMessageCell)) {
                            if (childAt instanceof ChatActionCell) {
                                i2 = ChatActivity.this.getScrollingOffsetForView(childAt);
                                break;
                            }
                        } else {
                            if (((ChatMessageCell) childAt).getCurrentMessagesGroup() == null) {
                                i2 = ChatActivity.this.getScrollingOffsetForView(childAt);
                                break;
                            }
                        }
                    }
                }
            }
            i = -1;
            i2 = 0;
            ChatActivity.this.lambda$updateMessageAnimated$308(primaryMessageObject, false);
            if (ChatActivity.this.factCheckHint != null) {
                ChatActivity.this.factCheckHint.hide();
            }
            if (i < 0 || chatMessageCell.getCurrentMessagesGroup() != null) {
                return;
            }
            ChatActivity.this.chatLayoutManager.scrollToPositionWithOffset(i, i2);
        }

        @Override
        public void didPressFactCheckWhat(final org.telegram.ui.Cells.ChatMessageCell r10, final int r11, final int r12) {
            throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.ChatMessageCellDelegate.didPressFactCheckWhat(org.telegram.ui.Cells.ChatMessageCell, int, int):void");
        }

        @Override
        public void didPressGiveawayChatButton(ChatMessageCell chatMessageCell, int i) {
            if (chatMessageCell.getMessageObject().messageOwner.media instanceof TLRPC.TL_messageMediaGiveaway) {
                long j = -((Long) chatMessageCell.getMessageObject().messageOwner.media.channels.get(i)).longValue();
                if (ChatActivity.this.dialog_id != j) {
                    ChatActivity.this.presentFragment(ChatActivity.of(j));
                } else {
                    ChatActivity.this.avatarContainer.openProfile(false);
                }
            }
            if (chatMessageCell.getMessageObject().messageOwner.media instanceof TLRPC.TL_messageMediaGiveawayResults) {
                ChatActivity.this.presentFragment(ProfileActivity.of(((Long) chatMessageCell.getMessageObject().messageOwner.media.winners.get(i)).longValue()));
            }
        }

        @Override
        public void didPressGroupImage(ChatMessageCell chatMessageCell, ImageReceiver imageReceiver, TLRPC.MessageExtendedMedia messageExtendedMedia, float f, float f2) {
            String str;
            MessageObject messageObject = chatMessageCell.getMessageObject();
            if (messageExtendedMedia instanceof TLRPC.TL_messageExtendedMediaPreview) {
                Browser.Progress makeProgressForPaidMedia = ChatActivity.this.makeProgressForPaidMedia(chatMessageCell);
                StarsController starsController = StarsController.getInstance(((BaseFragment) ChatActivity.this).currentAccount);
                Objects.requireNonNull(makeProgressForPaidMedia);
                Runnable pay = starsController.pay(messageObject, new ChatActivity$ChatMessageCellDelegate$$ExternalSyntheticLambda10(makeProgressForPaidMedia));
                if (pay != null) {
                    makeProgressForPaidMedia.onCancel(pay);
                    makeProgressForPaidMedia.init();
                    return;
                }
                return;
            }
            TLRPC.Message message = messageObject.messageOwner;
            TLRPC.TL_messageMediaPaidMedia tL_messageMediaPaidMedia = message.media;
            if (tL_messageMediaPaidMedia instanceof TLRPC.TL_messageMediaPaidMedia) {
                TLRPC.TL_messageMediaPaidMedia tL_messageMediaPaidMedia2 = tL_messageMediaPaidMedia;
                ArrayList arrayList = new ArrayList();
                int i = -1;
                for (int i2 = 0; i2 < ((TLRPC.MessageMedia) tL_messageMediaPaidMedia2).extended_media.size(); i2++) {
                    TLRPC.TL_messageExtendedMedia tL_messageExtendedMedia = (TLRPC.MessageExtendedMedia) ((TLRPC.MessageMedia) tL_messageMediaPaidMedia2).extended_media.get(i2);
                    if (tL_messageExtendedMedia instanceof TLRPC.TL_messageExtendedMedia) {
                        TLRPC.TL_messageExtendedMedia tL_messageExtendedMedia2 = tL_messageExtendedMedia;
                        if (tL_messageExtendedMedia2 == messageExtendedMedia) {
                            i = arrayList.size();
                        }
                        TLRPC.TL_message tL_message = new TLRPC.TL_message();
                        ((TLRPC.Message) tL_message).id = message.id;
                        ((TLRPC.Message) tL_message).from_id = message.from_id;
                        ((TLRPC.Message) tL_message).from_boosts_applied = message.from_boosts_applied;
                        ((TLRPC.Message) tL_message).peer_id = message.peer_id;
                        ((TLRPC.Message) tL_message).saved_peer_id = message.saved_peer_id;
                        ((TLRPC.Message) tL_message).date = message.date;
                        ((TLRPC.Message) tL_message).expire_date = message.expire_date;
                        ((TLRPC.Message) tL_message).action = message.action;
                        ((TLRPC.Message) tL_message).message = message.message;
                        ((TLRPC.Message) tL_message).flags = message.flags;
                        ((TLRPC.Message) tL_message).flags2 = message.flags2;
                        ((TLRPC.Message) tL_message).mentioned = message.mentioned;
                        ((TLRPC.Message) tL_message).media_unread = message.media_unread;
                        ((TLRPC.Message) tL_message).out = message.out;
                        ((TLRPC.Message) tL_message).unread = message.unread;
                        ((TLRPC.Message) tL_message).entities = message.entities;
                        ((TLRPC.Message) tL_message).via_bot_name = message.via_bot_name;
                        ((TLRPC.Message) tL_message).reply_markup = message.reply_markup;
                        ((TLRPC.Message) tL_message).views = message.views;
                        ((TLRPC.Message) tL_message).forwards = message.forwards;
                        ((TLRPC.Message) tL_message).replies = message.replies;
                        ((TLRPC.Message) tL_message).edit_date = message.edit_date;
                        ((TLRPC.Message) tL_message).silent = message.silent;
                        ((TLRPC.Message) tL_message).post = message.post;
                        ((TLRPC.Message) tL_message).from_scheduled = message.from_scheduled;
                        ((TLRPC.Message) tL_message).legacy = message.legacy;
                        ((TLRPC.Message) tL_message).edit_hide = message.edit_hide;
                        ((TLRPC.Message) tL_message).pinned = message.pinned;
                        ((TLRPC.Message) tL_message).fwd_from = message.fwd_from;
                        ((TLRPC.Message) tL_message).via_bot_id = message.via_bot_id;
                        ((TLRPC.Message) tL_message).via_business_bot_id = message.via_business_bot_id;
                        ((TLRPC.Message) tL_message).reply_to = message.reply_to;
                        ((TLRPC.Message) tL_message).post_author = message.post_author;
                        ((TLRPC.Message) tL_message).grouped_id = message.grouped_id;
                        ((TLRPC.Message) tL_message).reactions = message.reactions;
                        ((TLRPC.Message) tL_message).restriction_reason = message.restriction_reason;
                        ((TLRPC.Message) tL_message).ttl_period = message.ttl_period;
                        ((TLRPC.Message) tL_message).quick_reply_shortcut_id = message.quick_reply_shortcut_id;
                        ((TLRPC.Message) tL_message).effect = message.effect;
                        ((TLRPC.Message) tL_message).noforwards = message.noforwards;
                        ((TLRPC.Message) tL_message).invert_media = message.invert_media;
                        ((TLRPC.Message) tL_message).offline = message.offline;
                        ((TLRPC.Message) tL_message).factcheck = message.factcheck;
                        ((TLRPC.Message) tL_message).send_state = message.send_state;
                        ((TLRPC.Message) tL_message).fwd_msg_id = message.fwd_msg_id;
                        if (TextUtils.isEmpty(((TLRPC.MessageExtendedMedia) tL_messageExtendedMedia2).attachPath)) {
                            if (((TLRPC.MessageMedia) tL_messageMediaPaidMedia2).extended_media.size() == 1) {
                                str = message.attachPath;
                            }
                            ((TLRPC.Message) tL_message).params = message.params;
                            ((TLRPC.Message) tL_message).random_id = message.random_id;
                            ((TLRPC.Message) tL_message).local_id = message.local_id;
                            ((TLRPC.Message) tL_message).dialog_id = message.dialog_id;
                            ((TLRPC.Message) tL_message).ttl = message.ttl;
                            ((TLRPC.Message) tL_message).destroyTime = message.destroyTime;
                            ((TLRPC.Message) tL_message).destroyTimeMillis = message.destroyTimeMillis;
                            ((TLRPC.Message) tL_message).layer = message.layer;
                            ((TLRPC.Message) tL_message).seq_in = message.seq_in;
                            ((TLRPC.Message) tL_message).seq_out = message.seq_out;
                            ((TLRPC.Message) tL_message).with_my_score = message.with_my_score;
                            ((TLRPC.Message) tL_message).replyMessage = message.replyMessage;
                            ((TLRPC.Message) tL_message).reqId = message.reqId;
                            ((TLRPC.Message) tL_message).realId = message.realId;
                            ((TLRPC.Message) tL_message).stickerVerified = message.stickerVerified;
                            ((TLRPC.Message) tL_message).isThreadMessage = message.isThreadMessage;
                            ((TLRPC.Message) tL_message).voiceTranscription = message.voiceTranscription;
                            ((TLRPC.Message) tL_message).voiceTranscriptionOpen = message.voiceTranscriptionOpen;
                            ((TLRPC.Message) tL_message).voiceTranscriptionRated = message.voiceTranscriptionRated;
                            ((TLRPC.Message) tL_message).voiceTranscriptionFinal = message.voiceTranscriptionFinal;
                            ((TLRPC.Message) tL_message).voiceTranscriptionForce = message.voiceTranscriptionForce;
                            ((TLRPC.Message) tL_message).voiceTranscriptionId = message.voiceTranscriptionId;
                            ((TLRPC.Message) tL_message).premiumEffectWasPlayed = message.premiumEffectWasPlayed;
                            ((TLRPC.Message) tL_message).originalLanguage = message.originalLanguage;
                            ((TLRPC.Message) tL_message).translatedToLanguage = message.translatedToLanguage;
                            ((TLRPC.Message) tL_message).translatedText = message.translatedText;
                            ((TLRPC.Message) tL_message).replyStory = message.replyStory;
                            ((TLRPC.Message) tL_message).media = tL_messageExtendedMedia2.media;
                            ((TLRPC.Message) tL_message).quick_reply_shortcut = message.quick_reply_shortcut;
                            ((TLRPC.Message) tL_message).noforwards = true;
                            arrayList.add(new MessageObject(messageObject.currentAccount, tL_message, false, true));
                        } else {
                            str = ((TLRPC.MessageExtendedMedia) tL_messageExtendedMedia2).attachPath;
                        }
                        ((TLRPC.Message) tL_message).attachPath = str;
                        ((TLRPC.Message) tL_message).params = message.params;
                        ((TLRPC.Message) tL_message).random_id = message.random_id;
                        ((TLRPC.Message) tL_message).local_id = message.local_id;
                        ((TLRPC.Message) tL_message).dialog_id = message.dialog_id;
                        ((TLRPC.Message) tL_message).ttl = message.ttl;
                        ((TLRPC.Message) tL_message).destroyTime = message.destroyTime;
                        ((TLRPC.Message) tL_message).destroyTimeMillis = message.destroyTimeMillis;
                        ((TLRPC.Message) tL_message).layer = message.layer;
                        ((TLRPC.Message) tL_message).seq_in = message.seq_in;
                        ((TLRPC.Message) tL_message).seq_out = message.seq_out;
                        ((TLRPC.Message) tL_message).with_my_score = message.with_my_score;
                        ((TLRPC.Message) tL_message).replyMessage = message.replyMessage;
                        ((TLRPC.Message) tL_message).reqId = message.reqId;
                        ((TLRPC.Message) tL_message).realId = message.realId;
                        ((TLRPC.Message) tL_message).stickerVerified = message.stickerVerified;
                        ((TLRPC.Message) tL_message).isThreadMessage = message.isThreadMessage;
                        ((TLRPC.Message) tL_message).voiceTranscription = message.voiceTranscription;
                        ((TLRPC.Message) tL_message).voiceTranscriptionOpen = message.voiceTranscriptionOpen;
                        ((TLRPC.Message) tL_message).voiceTranscriptionRated = message.voiceTranscriptionRated;
                        ((TLRPC.Message) tL_message).voiceTranscriptionFinal = message.voiceTranscriptionFinal;
                        ((TLRPC.Message) tL_message).voiceTranscriptionForce = message.voiceTranscriptionForce;
                        ((TLRPC.Message) tL_message).voiceTranscriptionId = message.voiceTranscriptionId;
                        ((TLRPC.Message) tL_message).premiumEffectWasPlayed = message.premiumEffectWasPlayed;
                        ((TLRPC.Message) tL_message).originalLanguage = message.originalLanguage;
                        ((TLRPC.Message) tL_message).translatedToLanguage = message.translatedToLanguage;
                        ((TLRPC.Message) tL_message).translatedText = message.translatedText;
                        ((TLRPC.Message) tL_message).replyStory = message.replyStory;
                        ((TLRPC.Message) tL_message).media = tL_messageExtendedMedia2.media;
                        ((TLRPC.Message) tL_message).quick_reply_shortcut = message.quick_reply_shortcut;
                        ((TLRPC.Message) tL_message).noforwards = true;
                        arrayList.add(new MessageObject(messageObject.currentAccount, tL_message, false, true));
                    }
                }
                if (i <= -1 || arrayList.isEmpty()) {
                    return;
                }
                PhotoViewer photoViewer = PhotoViewer.getInstance();
                ChatActivity chatActivity = ChatActivity.this;
                photoViewer.setParentActivity(chatActivity, chatActivity.themeDelegate);
                PhotoViewer.getInstance().openPhoto(arrayList, i, ChatActivity.this.getDialogId(), 0L, 0L, ChatActivity.this.photoViewerPaidMediaProvider);
            }
        }

        @Override
        public void didPressHiddenForward(ChatMessageCell chatMessageCell) {
            if (chatMessageCell.getMessageObject().isImportedForward()) {
                didPressTime(chatMessageCell);
            } else {
                ChatActivity.this.showForwardHint(chatMessageCell);
            }
        }

        @Override
        public void didPressHint(ChatMessageCell chatMessageCell, int i) {
            if (i == 0) {
                ChatActivity.this.showPollSolution(chatMessageCell.getMessageObject(), chatMessageCell.getMessageObject().messageOwner.media.results);
            } else if (i == 1) {
                MessageObject messageObject = chatMessageCell.getMessageObject();
                TLRPC.MessageFwdHeader messageFwdHeader = messageObject.messageOwner.fwd_from;
                if (messageFwdHeader == null || TextUtils.isEmpty(messageFwdHeader.psa_type)) {
                    return;
                }
                String string = LocaleController.getString("PsaMessageInfo_" + messageObject.messageOwner.fwd_from.psa_type);
                if (TextUtils.isEmpty(string)) {
                    string = LocaleController.getString(R.string.PsaMessageInfoDefault);
                }
                SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(string);
                MessageObject.addLinks(false, spannableStringBuilder);
                MessageObject.GroupedMessages currentMessagesGroup = chatMessageCell.getCurrentMessagesGroup();
                if (currentMessagesGroup != null) {
                    int size = currentMessagesGroup.posArray.size();
                    int i2 = 0;
                    while (true) {
                        if (i2 >= size) {
                            break;
                        }
                        if ((((MessageObject.GroupedMessagePosition) currentMessagesGroup.posArray.get(i2)).flags & 1) != 0) {
                            MessageObject messageObject2 = (MessageObject) currentMessagesGroup.messages.get(i2);
                            if (messageObject2 != messageObject) {
                                int childCount = ChatActivity.this.chatListView.getChildCount();
                                for (int i3 = 0; i3 < childCount; i3++) {
                                    View childAt = ChatActivity.this.chatListView.getChildAt(i3);
                                    if (childAt instanceof ChatMessageCell) {
                                        ChatMessageCell chatMessageCell2 = (ChatMessageCell) childAt;
                                        if (messageObject2.equals(chatMessageCell2.getMessageObject())) {
                                            chatMessageCell = chatMessageCell2;
                                        }
                                    }
                                }
                                messageObject = messageObject2;
                            }
                        } else {
                            i2++;
                        }
                    }
                }
                ChatActivity.this.showInfoHint(messageObject, spannableStringBuilder, 1);
            }
            chatMessageCell.showHintButton(false, true, i);
        }

        @Override
        public void didPressImage(org.telegram.ui.Cells.ChatMessageCell r22, float r23, float r24, boolean r25) {
            throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.ChatMessageCellDelegate.didPressImage(org.telegram.ui.Cells.ChatMessageCell, float, float, boolean):void");
        }

        @Override
        public void didPressInstantButton(ChatMessageCell chatMessageCell, int i) {
            TLRPC.WebPage webPage;
            TLRPC.MessageMedia messageMedia;
            TLRPC.TL_webPageAttributeStory tL_webPageAttributeStory;
            TL_stories.StoryItem storyItem;
            TLRPC.Message message;
            TLRPC.MessageMedia messageMedia2;
            Browser.Progress user;
            String format;
            TLRPC.WebPage webPage2;
            Context context;
            String str;
            MessageObject messageObject = chatMessageCell.getMessageObject();
            if (i == 19) {
                if (ChatActivity.this.progressDialogCurrent != null) {
                    ChatActivity.this.progressDialogCurrent.cancel(true);
                }
                ChatActivity.this.progressDialogCurrent = chatMessageCell.getMessageObject() != null ? new AnonymousClass9(chatMessageCell) : null;
                BoostDialogs.openGiveAwayStatusDialog(messageObject, ChatActivity.this.progressDialogCurrent, ChatActivity.this.getContext(), ChatActivity.this.getResourceProvider());
                return;
            }
            if (i == 21) {
                if (ApplicationLoader.isStandaloneBuild()) {
                    if (LaunchActivity.instance != null) {
                        if (ChatActivity.this.progressDialogCurrent != null) {
                            ChatActivity.this.progressDialogCurrent.cancel(true);
                        }
                        ChatActivity.this.progressDialogCurrent = chatMessageCell.getMessageObject() != null ? new AnonymousClass10(chatMessageCell) : null;
                        LaunchActivity.instance.checkAppUpdate(true, ChatActivity.this.progressDialogCurrent);
                        return;
                    }
                    return;
                }
                if (BuildVars.isHuaweiStoreApp()) {
                    context = ChatActivity.this.getContext();
                    str = BuildVars.HUAWEI_STORE_URL;
                } else {
                    context = ChatActivity.this.getContext();
                    str = BuildVars.PLAYSTORE_APP_URL;
                }
                Browser.openUrl(context, str);
                return;
            }
            if (i == 8) {
                PollVotesAlert.showForPoll(ChatActivity.this, messageObject);
                return;
            }
            if (i == 0) {
                TLRPC.MessageMedia messageMedia3 = messageObject.messageOwner.media;
                if (messageMedia3 == null || (webPage2 = messageMedia3.webpage) == null || webPage2.cached_page == null) {
                    return;
                }
                LaunchActivity launchActivity = LaunchActivity.instance;
                if (launchActivity == null || launchActivity.getBottomSheetTabs() == null || LaunchActivity.instance.getBottomSheetTabs().tryReopenTab(messageObject) == null) {
                    ChatActivity.this.createArticleViewer(false).open(messageObject);
                    return;
                }
                return;
            }
            if (i == 5) {
                long j = messageObject.messageOwner.media.user_id;
                user = j != 0 ? MessagesController.getInstance(((BaseFragment) ChatActivity.this).currentAccount).getUser(Long.valueOf(j)) : null;
                ChatActivity chatActivity = ChatActivity.this;
                TLRPC.MessageMedia messageMedia4 = messageObject.messageOwner.media;
                chatActivity.openVCard(user, messageMedia4.phone_number, messageMedia4.vcard, messageMedia4.first_name, messageMedia4.last_name);
                return;
            }
            if (i == 30) {
                long j2 = messageObject.messageOwner.media.user_id;
                Bundle bundle = new Bundle();
                bundle.putLong("user_id", j2);
                ChatActivity.this.presentFragment(new ChatActivity(bundle));
                return;
            }
            if (i == 31) {
                long j3 = messageObject.messageOwner.media.user_id;
                user = j3 != 0 ? MessagesController.getInstance(((BaseFragment) ChatActivity.this).currentAccount).getUser(Long.valueOf(j3)) : null;
                if (user != null) {
                    if (!TextUtils.isEmpty(messageObject.vCardData)) {
                        format = messageObject.vCardData.toString();
                    } else if (TextUtils.isEmpty(((TLRPC.User) user).phone)) {
                        String str2 = MessageObject.getMedia(messageObject.messageOwner).phone_number;
                        format = !TextUtils.isEmpty(str2) ? PhoneFormat.getInstance().format(str2) : LocaleController.getString(R.string.NumberUnknown);
                    } else {
                        format = PhoneFormat.getInstance().format("+" + ((TLRPC.User) user).phone);
                    }
                    Bundle bundle2 = new Bundle();
                    bundle2.putLong("user_id", ((TLRPC.User) user).id);
                    bundle2.putString("phone", format);
                    bundle2.putBoolean("addContact", true);
                    ChatActivity.this.presentFragment(new ContactAddActivity(bundle2));
                    return;
                }
                return;
            }
            if (i == 23 || i == 24) {
                final boolean z = i == 24;
                TLRPC.Message message2 = messageObject.messageOwner;
                webPage = (message2 == null || (messageMedia = message2.media) == null) ? null : messageMedia.webpage;
                if (webPage == null || webPage.url == null) {
                    return;
                }
                Matcher matcher = Pattern.compile("^https?\\:\\/\\/t\\.me\\/add(?:emoji|stickers)\\/(.+)$").matcher(webPage.url);
                if (ChatActivity.this.progressDialogCurrent != null) {
                    ChatActivity.this.progressDialogCurrent.cancel(true);
                }
                ChatActivity.this.progressDialogCurrent = chatMessageCell.getMessageObject() != null ? new AnonymousClass11(chatMessageCell) : null;
                if (matcher.matches() && matcher.groupCount() > 1 && matcher.group(1) != null) {
                    String group = matcher.group(1);
                    if (MediaDataController.getInstance(((BaseFragment) ChatActivity.this).currentAccount).getStickerSetByName(group) == null) {
                        ChatActivity.this.progressDialogCurrent.init();
                        TLRPC.TL_messages_getStickerSet tL_messages_getStickerSet = new TLRPC.TL_messages_getStickerSet();
                        TLRPC.TL_inputStickerSetShortName tL_inputStickerSetShortName = new TLRPC.TL_inputStickerSetShortName();
                        ((TLRPC.InputStickerSet) tL_inputStickerSetShortName).short_name = group;
                        tL_messages_getStickerSet.stickerset = tL_inputStickerSetShortName;
                        final int sendRequest = ConnectionsManager.getInstance(((BaseFragment) ChatActivity.this).currentAccount).sendRequest(tL_messages_getStickerSet, new RequestDelegate() {
                            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                                ChatActivity.ChatMessageCellDelegate.this.lambda$didPressInstantButton$43(z, tLObject, tL_error);
                            }
                        });
                        ChatActivity.this.progressDialogCurrent.onCancel(new Runnable() {
                            @Override
                            public final void run() {
                                ChatActivity.ChatMessageCellDelegate.this.lambda$didPressInstantButton$44(sendRequest);
                            }
                        });
                        return;
                    }
                }
            } else {
                if (messageObject.isSponsored()) {
                    ChatActivity.this.logSponsoredClicked(messageObject, false, false);
                    if (messageObject.sponsoredUrl != null) {
                        if (ChatActivity.this.progressDialogCurrent != null) {
                            ChatActivity.this.progressDialogCurrent.cancel(true);
                        }
                        ChatActivity.this.progressDialogCurrent = chatMessageCell.getMessageObject() != null ? new AnonymousClass12(chatMessageCell) : null;
                        Browser.openUrl(ChatActivity.this.getContext(), Uri.parse(messageObject.sponsoredUrl), true, false, false, ChatActivity.this.progressDialogCurrent, (String) null, false, ChatActivity.this.getMessagesController().sponsoredLinksInappAllow, false);
                        return;
                    }
                    return;
                }
                webPage = messageObject.getStoryMentionWebpage();
                if (webPage == null && (message = messageObject.messageOwner) != null && (messageMedia2 = message.media) != null) {
                    webPage = messageMedia2.webpage;
                }
                if (webPage == null) {
                    return;
                }
                if (webPage.attributes != null) {
                    for (int i2 = 0; i2 < webPage.attributes.size(); i2++) {
                        if ((webPage.attributes.get(i2) instanceof TLRPC.TL_webPageAttributeStory) && (storyItem = (tL_webPageAttributeStory = (TLRPC.TL_webPageAttributeStory) webPage.attributes.get(i2)).storyItem) != null) {
                            storyItem.dialogId = DialogObject.getPeerDialogId(tL_webPageAttributeStory.peer);
                            tL_webPageAttributeStory.storyItem.messageId = messageObject.getId();
                            tL_webPageAttributeStory.storyItem.messageType = 1;
                            ChatActivity.this.getOrCreateStoryViewer().open(ChatActivity.this.getContext(), tL_webPageAttributeStory.storyItem, StoriesListPlaceProvider.of(ChatActivity.this.chatListView));
                            return;
                        }
                    }
                }
                if (ChatActivity.this.openLinkInternally(webPage.url, chatMessageCell, null, messageObject.getId(), 2)) {
                    return;
                }
                if (ChatActivity.this.progressDialogCurrent != null) {
                    ChatActivity.this.progressDialogCurrent.cancel(true);
                }
                ChatActivity.this.progressDialogCurrent = chatMessageCell.getMessageObject() != null ? new AnonymousClass13(chatMessageCell) : null;
            }
            Browser.openUrl(ChatActivity.this.getParentActivity(), Uri.parse(webPage.url), true, true, false, ChatActivity.this.progressDialogCurrent, (String) null, false, true, false);
        }

        @Override
        public void didPressMoreChannelRecommendations(ChatMessageCell chatMessageCell) {
            if (!ChatActivity.this.getUserConfig().isPremium()) {
                BulletinFactory.of(ChatActivity.this).createSimpleBulletin(R.raw.star_premium_2, AndroidUtilities.replaceSingleTag(LocaleController.formatPluralStringComma("UnlockSimilarChannelsPremium", ChatActivity.this.getMessagesController().recommendedChannelsLimitPremium), new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.ChatMessageCellDelegate.this.lambda$didPressMoreChannelRecommendations$35();
                    }
                })).show();
                return;
            }
            Bundle bundle = new Bundle();
            bundle.putLong("dialog_id", ChatActivity.this.dialog_id);
            bundle.putInt("start_from", 10);
            ChatActivity chatActivity = ChatActivity.this;
            chatActivity.presentFragment(new MediaActivity(bundle, chatActivity.avatarContainer.getSharedMediaPreloader()));
        }

        @Override
        public void didPressOther(ChatMessageCell chatMessageCell, float f, float f2) {
            final MessageObject messageObject = chatMessageCell.getMessageObject();
            if (messageObject.type != 16) {
                ChatActivity.this.createMenu(chatMessageCell, true, false, f, f2, messageObject.isMusic(), false);
                return;
            }
            TLRPC.TL_messageActionConferenceCall tL_messageActionConferenceCall = messageObject.messageOwner.action;
            if (!(tL_messageActionConferenceCall instanceof TLRPC.TL_messageActionConferenceCall)) {
                TLRPC.User user = ChatActivity.this.currentUser;
                if (user != null) {
                    boolean isVideoCall = messageObject.isVideoCall();
                    ChatActivity chatActivity = ChatActivity.this;
                    TLRPC.UserFull userFull = chatActivity.userInfo;
                    VoIPHelper.startCall(user, isVideoCall, userFull != null && userFull.video_calls_available, chatActivity.getParentActivity(), ChatActivity.this.getMessagesController().getUserFull(ChatActivity.this.currentUser.id), ChatActivity.this.getAccountInstance());
                    return;
                }
                return;
            }
            final HashSet hashSet = new HashSet();
            hashSet.add(Long.valueOf(ChatActivity.this.getDialogId()));
            Iterator it = tL_messageActionConferenceCall.other_participants.iterator();
            while (it.hasNext()) {
                hashSet.add(Long.valueOf(DialogObject.getPeerDialogId((TLRPC.Peer) it.next())));
            }
            final TLRPC.TL_inputGroupCallInviteMessage tL_inputGroupCallInviteMessage = new TLRPC.TL_inputGroupCallInviteMessage();
            ((TLRPC.InputGroupCall) tL_inputGroupCallInviteMessage).msg_id = messageObject.getId();
            final AlertDialog alertDialog = new AlertDialog(ChatActivity.this.getContext(), 3);
            TL_phone.getGroupCall getgroupcall = new TL_phone.getGroupCall();
            getgroupcall.call = tL_inputGroupCallInviteMessage;
            getgroupcall.limit = ChatActivity.this.getMessagesController().conferenceCallSizeLimit;
            final int sendRequest = ChatActivity.this.getConnectionsManager().sendRequest(getgroupcall, new RequestDelegate() {
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    ChatActivity.ChatMessageCellDelegate.this.lambda$didPressOther$4(alertDialog, hashSet, tL_inputGroupCallInviteMessage, messageObject, tLObject, tL_error);
                }
            });
            alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public final void onCancel(DialogInterface dialogInterface) {
                    ChatActivity.ChatMessageCellDelegate.this.lambda$didPressOther$5(sendRequest, dialogInterface);
                }
            });
            alertDialog.showDelayed(600L);
        }

        @Override
        public void didPressReaction(ChatMessageCell chatMessageCell, TLRPC.ReactionCount reactionCount, boolean z, float f, float f2) {
            ChatActivity.this.didPressReaction(chatMessageCell, reactionCount, z, f, f2);
        }

        @Override
        public void didPressReplyMessage(org.telegram.ui.Cells.ChatMessageCell r20, final int r21, float r22, float r23, boolean r24) {
            throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.ChatMessageCellDelegate.didPressReplyMessage(org.telegram.ui.Cells.ChatMessageCell, int, float, float, boolean):void");
        }

        @Override
        public void didPressRevealSensitiveContent(final ChatMessageCell chatMessageCell) {
            if (!ChatActivity.this.getMessagesController().showSensitiveContent()) {
                final AlertDialog alertDialog = new AlertDialog(ChatActivity.this.getContext(), 3);
                alertDialog.showDelayed(200L);
                ChatActivity.this.getMessagesController().getContentSettings(new Utilities.Callback() {
                    public final void run(Object obj) {
                        ChatActivity.ChatMessageCellDelegate.this.lambda$didPressRevealSensitiveContent$48(alertDialog, chatMessageCell, (TL_account.contentSettings) obj);
                    }
                });
            } else {
                if (chatMessageCell.getMessageObject() != null) {
                    chatMessageCell.getMessageObject().isSensitiveCached = Boolean.FALSE;
                }
                chatMessageCell.startRevealMedia();
            }
        }

        @Override
        public void didPressSideButton(ChatMessageCell chatMessageCell) {
            MessageObject messageObject;
            int i;
            TLRPC.MessageFwdHeader messageFwdHeader;
            MessageObject.GroupedMessages groupedMessages;
            if (ChatActivity.this.getParentActivity() == null) {
                return;
            }
            ChatActivity chatActivity = ChatActivity.this;
            if (chatActivity.topicsTabs != null && chatActivity.threadMessageId == 0 && (chatMessageCell.isForum || chatMessageCell.isMonoForum)) {
                ChatActivity.this.topicsTabs.selectTopic(chatMessageCell.getMessageObject().getTopicId(), true);
                return;
            }
            if (ChatActivity.this.getMessagesController().isFrozen()) {
                AccountFrozenAlert.show(((BaseFragment) ChatActivity.this).currentAccount);
                return;
            }
            ChatActivityEnterView chatActivityEnterView = ChatActivity.this.chatActivityEnterView;
            if (chatActivityEnterView != null) {
                chatActivityEnterView.closeKeyboard();
            }
            MessageObject messageObject2 = chatMessageCell.getMessageObject();
            if (ChatActivity.this.chatMode == 2) {
                ChatActivity.this.chatActivityDelegate.openReplyMessage(messageObject2.getId());
                ChatActivity.this.lambda$onBackPressed$354();
                return;
            }
            if (ChatActivity.this.chatMode != 3 && ((ChatActivity.this.chatMode != 7 || ChatActivity.this.searchType != 2) && ((!UserObject.isReplyUser(ChatActivity.this.currentUser) && !UserObject.isUserSelf(ChatActivity.this.currentUser)) || (messageFwdHeader = messageObject2.messageOwner.fwd_from) == null || messageFwdHeader.saved_from_peer == null))) {
                ArrayList arrayList = (messageObject2.getGroupId() == 0 || (groupedMessages = (MessageObject.GroupedMessages) ChatActivity.this.groupedMessagesMap.get(messageObject2.getGroupId())) == null) ? null : groupedMessages.messages;
                if (arrayList == null) {
                    arrayList = new ArrayList();
                    arrayList.add(messageObject2);
                }
                ArrayList arrayList2 = arrayList;
                boolean z = ChatActivity.this.getMessagesController().storiesEnabled() && StoryEntry.canRepostMessage(messageObject2);
                ChatActivity chatActivity2 = ChatActivity.this;
                Context context = ChatActivity.this.getContext();
                ChatActivity chatActivity3 = ChatActivity.this;
                chatActivity2.showDialog(new AnonymousClass1(context, chatActivity3, arrayList2, null, null, ChatObject.isChannel(chatActivity3.currentChat), null, null, false, false, z, null, ChatActivity.this.themeDelegate, z, messageObject2));
                AndroidUtilities.setAdjustResizeToNothing(ChatActivity.this.getParentActivity(), ((BaseFragment) ChatActivity.this).classGuid);
                ((BaseFragment) ChatActivity.this).fragmentView.requestLayout();
                return;
            }
            if (UserObject.isReplyUser(ChatActivity.this.currentUser)) {
                messageObject = messageObject2;
                TLRPC.Message message = messageObject.messageOwner;
                TLRPC.MessageReplyHeader messageReplyHeader = message.reply_to;
                if (messageReplyHeader != null && (i = messageReplyHeader.reply_to_top_id) != 0) {
                    ChatActivity.this.openDiscussionMessageChat(messageReplyHeader.reply_to_peer_id.channel_id, null, i, 0L, -1, message.fwd_from.saved_from_msg_id, messageObject);
                    return;
                }
            } else {
                messageObject = messageObject2;
            }
            if (ChatActivity.this.chatMode == 7 && ChatActivity.this.searchType == 2) {
                ChatActivity.this.openMessageInOriginalDialog(messageObject);
            } else {
                ChatActivity.this.openOriginalReplyChat(messageObject);
            }
        }

        @Override
        public void didPressSponsoredClose(ChatMessageCell chatMessageCell) {
            ChatActivity.this.selectedObject = chatMessageCell.getMessageObject();
            ChatActivity.this.hideAds();
        }

        @Override
        public void didPressSponsoredInfo(ChatMessageCell chatMessageCell, float f, float f2) {
            ChatActivity.this.createMenu(chatMessageCell, true, false, f, f2, false, false);
        }

        @Override
        public void didPressTime(ChatMessageCell chatMessageCell) {
            ChatActivity.this.createUndoView();
            if (ChatActivity.this.undoView == null) {
                return;
            }
            ChatActivity.this.undoView.showWithAction(ChatActivity.this.dialog_id, 47, (Runnable) null);
        }

        @Override
        public boolean didPressToDoButton(ChatMessageCell chatMessageCell, TLRPC.TodoItem todoItem, boolean z) {
            Bulletin createSimpleBulletin;
            BulletinFactory of;
            int i;
            String formatString;
            if (chatMessageCell.getMessageObject().isForwarded()) {
                long peerDialogId = DialogObject.getPeerDialogId(chatMessageCell.getMessageObject().getFromPeer());
                of = BulletinFactory.of(ChatActivity.this);
                i = R.raw.passcode_lock_close;
                formatString = LocaleController.formatString(R.string.TodoCompleteForbiddenForward, new Object[]{DialogObject.getName(((BaseFragment) ChatActivity.this).currentAccount, peerDialogId)});
            } else {
                if (chatMessageCell.getMessageObject().canCompleteTodo()) {
                    if (ChatActivity.this.getUserConfig().isPremium()) {
                        ChatActivity.this.getSendMessagesHelper().toggleTodo(chatMessageCell.getMessageObject(), todoItem, z, (Runnable) null);
                        return true;
                    }
                    createSimpleBulletin = BulletinFactory.of(ChatActivity.this).createSimpleBulletin(R.raw.star_premium_2, AndroidUtilities.premiumText(LocaleController.getString(R.string.TodoPremiumRequired), new Runnable() {
                        @Override
                        public final void run() {
                            ChatActivity.ChatMessageCellDelegate.this.lambda$didPressToDoButton$34();
                        }
                    }));
                    createSimpleBulletin.show(true);
                    return false;
                }
                long peerDialogId2 = DialogObject.getPeerDialogId(chatMessageCell.getMessageObject().getFromPeer());
                of = BulletinFactory.of(ChatActivity.this);
                i = R.raw.passcode_lock_close;
                formatString = LocaleController.formatString(R.string.TodoCompleteForbidden, new Object[]{DialogObject.getName(((BaseFragment) ChatActivity.this).currentAccount, peerDialogId2)});
            }
            createSimpleBulletin = of.createSimpleBulletin(i, AndroidUtilities.replaceTags(formatString));
            createSimpleBulletin.show(true);
            return false;
        }

        @Override
        public void didPressUrl(ChatMessageCell chatMessageCell, CharacterStyle characterStyle, boolean z) {
            ChatActivity.this.didPressMessageUrl(characterStyle, z, chatMessageCell.getMessageObject(), chatMessageCell);
        }

        @Override
        public void didPressUserAvatar(ChatMessageCell chatMessageCell, TLRPC.User user, float f, float f2, boolean z) {
            boolean z2 = true;
            if (((BaseFragment) ChatActivity.this).actionBar.isActionModeShowed() || ChatActivity.this.isReport()) {
                ChatActivity.this.processRowSelect(chatMessageCell, true, f, f2);
                return;
            }
            if (chatMessageCell != null && chatMessageCell.getMessageObject() != null && chatMessageCell.getMessageObject().isSponsored()) {
                didPressInstantButton(chatMessageCell, 10);
                return;
            }
            if (!ChatObject.isForum(ChatActivity.this.currentChat) && !ChatActivity.this.isThreadChat()) {
                z2 = false;
            }
            openProfile(user, z2);
        }

        @Override
        public void didPressUserStatus(ChatMessageCell chatMessageCell, TLRPC.User user, TLRPC.Document document, String str) {
            ImageLocation forDocument;
            if (chatMessageCell == null) {
                return;
            }
            if (!TextUtils.isEmpty(str)) {
                Browser.openUrl(ChatActivity.this.getContext(), "https://" + ChatActivity.this.getMessagesController().linkPrefix + "/nft/" + str);
                return;
            }
            ChatActivity chatActivity = ChatActivity.this;
            ?? premiumPreviewBottomSheet = new PremiumPreviewBottomSheet(chatActivity, ((BaseFragment) chatActivity).currentAccount, user, ChatActivity.this.themeDelegate);
            chatMessageCell.getLocationOnScreen(new int[2]);
            premiumPreviewBottomSheet.startEnterFromX = chatMessageCell.getNameStatusX();
            premiumPreviewBottomSheet.startEnterFromY = chatMessageCell.getNameStatusY();
            premiumPreviewBottomSheet.startEnterFromScale = chatMessageCell.getScaleX();
            premiumPreviewBottomSheet.startEnterFromX1 = chatMessageCell.getLeft();
            premiumPreviewBottomSheet.startEnterFromY1 = chatMessageCell.getTop();
            premiumPreviewBottomSheet.startEnterFromView = chatMessageCell;
            int colorId = UserObject.getColorId(user);
            ChatActivity chatActivity2 = ChatActivity.this;
            if (colorId < 7) {
                premiumPreviewBottomSheet.accentColor = Integer.valueOf(chatActivity2.getThemedColor(Theme.keys_avatar_nameInMessage[colorId]));
            } else {
                MessagesController.PeerColors peerColors = MessagesController.getInstance(((BaseFragment) chatActivity2).currentAccount).peerColors;
                MessagesController.PeerColor color = peerColors != null ? peerColors.getColor(colorId) : null;
                premiumPreviewBottomSheet.accentColor = color != null ? Integer.valueOf(color.getColor1()) : null;
            }
            AnimatedEmojiDrawable.SwapAnimatedEmojiDrawable swapAnimatedEmojiDrawable = chatMessageCell.currentNameStatusDrawable;
            if (swapAnimatedEmojiDrawable != null && (swapAnimatedEmojiDrawable.getDrawable() instanceof AnimatedEmojiDrawable)) {
                premiumPreviewBottomSheet.startEnterFromScale *= 0.95f;
                if (document != null) {
                    BackupImageView backupImageView = new BackupImageView(ChatActivity.this.getContext());
                    SvgHelper.SvgDrawable svgThumb = DocumentObject.getSvgThumb(document.thumbs, Theme.key_windowBackgroundWhiteGrayIcon, 0.2f);
                    TLRPC.PhotoSize closestPhotoSizeWithSize = FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 90);
                    String str2 = "160_160";
                    if ("video/webm".equals(document.mime_type)) {
                        forDocument = ImageLocation.getForDocument(document);
                        str2 = "160_160_g";
                        if (svgThumb != null) {
                            svgThumb.overrideWidthAndHeight(512, 512);
                        }
                    } else {
                        if (svgThumb != null && MessageObject.isAnimatedStickerDocument(document, false)) {
                            svgThumb.overrideWidthAndHeight(512, 512);
                        }
                        forDocument = ImageLocation.getForDocument(document);
                    }
                    ImageLocation imageLocation = forDocument;
                    backupImageView.setLayerNum(7);
                    backupImageView.setRoundRadius(AndroidUtilities.dp(4.0f));
                    backupImageView.setImage(imageLocation, str2, ImageLocation.getForDocument(closestPhotoSizeWithSize, document), "140_140", svgThumb, document);
                    if (MessageObject.isTextColorEmoji(document)) {
                        Integer num = premiumPreviewBottomSheet.accentColor;
                        backupImageView.setColorFilter(new PorterDuffColorFilter(num != null ? num.intValue() : ChatActivity.this.getThemedColor(Theme.key_windowBackgroundWhiteBlueIcon), PorterDuff.Mode.SRC_IN));
                    }
                    premiumPreviewBottomSheet.statusStickerSet = MessageObject.getInputStickerSet(document);
                    premiumPreviewBottomSheet.overrideTitleIcon = backupImageView;
                    premiumPreviewBottomSheet.isEmojiStatus = true;
                }
            }
            ChatActivity.this.showDialog((Dialog) premiumPreviewBottomSheet);
        }

        @Override
        public void didPressViaBot(ChatMessageCell chatMessageCell, String str) {
            if (ChatActivity.this.bottomOverlayChat == null || ChatActivity.this.bottomOverlayChat.getVisibility() != 0) {
                if ((ChatActivity.this.bottomOverlay == null || ChatActivity.this.bottomOverlay.getVisibility() != 0) && ChatActivity.this.chatActivityEnterView != null && str != null && str.length() > 0) {
                    ChatActivity.this.chatActivityEnterView.setFieldText("@" + str + " ");
                    ChatActivity.this.chatActivityEnterView.openKeyboard();
                }
            }
        }

        @Override
        public void didPressViaBotNotInline(ChatMessageCell chatMessageCell, long j) {
            Bundle bundle = new Bundle();
            bundle.putLong("user_id", j);
            if (ChatActivity.this.getMessagesController().checkCanOpenChat(bundle, ChatActivity.this, chatMessageCell.getMessageObject())) {
                ChatActivity.this.presentFragment(new ChatActivity(bundle));
            }
        }

        @Override
        public void didPressVoteButtons(ChatMessageCell chatMessageCell, ArrayList arrayList, int i, int i2, int i3) {
            int i4;
            int i5;
            int i6;
            int i7;
            if (i < 0 && !arrayList.isEmpty()) {
                ChatActivity.this.getSendMessagesHelper().sendVote(chatMessageCell.getMessageObject(), arrayList, (Runnable) null);
                return;
            }
            if (ChatActivity.this.getParentActivity() == null) {
                return;
            }
            if (ChatActivity.this.pollHintView == null) {
                ChatActivity.this.pollHintView = new HintView(ChatActivity.this.getParentActivity(), 5, ChatActivity.this.themeDelegate);
                ChatActivity.this.pollHintView.setAlpha(0.0f);
                ChatActivity.this.pollHintView.setVisibility(4);
                ChatActivity chatActivity = ChatActivity.this;
                int indexOfChild = chatActivity.contentView.indexOfChild(chatActivity.chatActivityEnterView);
                if (indexOfChild == -1) {
                    return;
                }
                ChatActivity chatActivity2 = ChatActivity.this;
                chatActivity2.contentView.addView(chatActivity2.pollHintView, indexOfChild + 1, LayoutHelper.createFrame(-2, -2.0f, 51, 19.0f, 0.0f, 19.0f, 0.0f));
            }
            if (!arrayList.isEmpty() || i >= 0) {
                i4 = i2;
                i5 = i3;
            } else {
                ArrayList<ChatMessageCell.PollButton> pollButtons = chatMessageCell.getPollButtons();
                int size = pollButtons.size();
                int i8 = 0;
                float f = 0.0f;
                while (true) {
                    if (i8 >= size) {
                        i6 = i2;
                        i7 = i3;
                        break;
                    }
                    ChatMessageCell.PollButton pollButton = pollButtons.get(i8);
                    float y = (chatMessageCell.getY() + pollButton.y) - AndroidUtilities.dp(4.0f);
                    ChatActivity chatActivity3 = ChatActivity.this;
                    float f2 = y - chatActivity3.chatListViewPaddingTop;
                    chatActivity3.pollHintX = pollButton.x + AndroidUtilities.dp(13.3f);
                    ChatActivity.this.pollHintY = (pollButton.y - AndroidUtilities.dp(6.0f)) + i3;
                    if (f2 > 0.0f) {
                        i6 = ChatActivity.this.pollHintX;
                        i7 = ChatActivity.this.pollHintY;
                        f = 0.0f;
                        break;
                    }
                    i8++;
                    f = f2;
                }
                if (f != 0.0f) {
                    ChatActivity.this.chatListView.smoothScrollBy(0, (int) f);
                    ChatActivity.this.pollHintCell = chatMessageCell;
                    return;
                } else {
                    i4 = i6;
                    i5 = i7;
                }
            }
            ChatActivity.this.pollHintView.showForMessageCell(chatMessageCell, Integer.valueOf(i), i4, i5, true);
        }

        @Override
        public void didPressWebPage(ChatMessageCell chatMessageCell, TLRPC.WebPage webPage, String str, boolean z) {
            Uri parse;
            if (str == null || (parse = Uri.parse(str)) == null) {
                return;
            }
            if (!z && Browser.isTelegraphUrl(str, false)) {
                z = true;
            }
            if (ChatActivity.this.progressDialogCurrent != null) {
                ChatActivity.this.progressDialogCurrent.cancel(true);
            }
            ChatActivity.this.progressDialogCurrent = (chatMessageCell == null || chatMessageCell.getMessageObject() == null) ? null : new AnonymousClass5(chatMessageCell);
            if (z || Browser.isInternalUri(parse, (boolean[]) null)) {
                Browser.openUrl(ChatActivity.this.getContext(), parse, true, true, false, ChatActivity.this.progressDialogCurrent, (String) null, false, true, false);
            } else {
                ChatActivity chatActivity = ChatActivity.this;
                AlertsCreator.showOpenUrlAlert(chatActivity, str, true, true, true, !z, chatActivity.progressDialogCurrent, ChatActivity.this.themeDelegate);
            }
        }

        @Override
        public void didQuickShareEnd(ChatMessageCell chatMessageCell, float f, float f2) {
            if (ChatActivity.this.quickShareSelectorOverlay == null) {
                return;
            }
            ChatActivity.this.quickShareSelectorOverlay.close(chatMessageCell, sendMessageFromQuickShare(chatMessageCell));
        }

        @Override
        public void didQuickShareMove(ChatMessageCell chatMessageCell, float f, float f2) {
            if (ChatActivity.this.quickShareSelectorOverlay != null) {
                ChatActivity.this.quickShareSelectorOverlay.onTouchMoveEvent(chatMessageCell, f, f2);
            }
        }

        @Override
        public void didQuickShareStart(ChatMessageCell chatMessageCell, float f, float f2) {
            if (ChatActivity.this.getParentActivity() == null) {
                return;
            }
            if (ChatActivity.this.quickShareSelectorOverlay == null) {
                ChatActivity.this.quickShareSelectorOverlay = new QuickShareSelectorOverlayLayout(ChatActivity.this.getContext());
                ChatActivity chatActivity = ChatActivity.this;
                chatActivity.contentView.addView(chatActivity.quickShareSelectorOverlay, LayoutHelper.createFrame(-1, -1, 48));
            }
            ChatActivity.this.quickShareSelectorOverlay.open(chatMessageCell);
        }

        @Override
        public void didStartVideoStream(MessageObject messageObject) {
            if (messageObject.isVideo()) {
                ChatActivity.this.sendSecretMessageRead(messageObject, true);
            }
        }

        @Override
        public boolean doNotShowLoadingReply(MessageObject messageObject) {
            return ((messageObject != null && messageObject.getDialogId() == 1271266957) || (ChatActivity.this.chatAdapter != null && ChatActivity.this.chatAdapter.isFiltered)) && ChatActivity.this.chatMode != 7;
        }

        @Override
        public void forceUpdate(ChatMessageCell chatMessageCell, boolean z) {
            MessageObject primaryMessageObject;
            int i;
            int i2;
            if (chatMessageCell == null || (primaryMessageObject = chatMessageCell.getPrimaryMessageObject()) == null) {
                return;
            }
            primaryMessageObject.forceUpdate = true;
            if (ChatActivity.this.chatListView != null && ChatActivity.this.chatLayoutManager != null && !ChatActivity.this.chatLayoutManager.hasPendingScrollPosition()) {
                for (int childCount = ChatActivity.this.chatListView.getChildCount() - 1; childCount >= 0; childCount--) {
                    View childAt = ChatActivity.this.chatListView.getChildAt(childCount);
                    i = ChatActivity.this.chatListView.getChildAdapterPosition(childAt);
                    if (i >= 0) {
                        if (!(childAt instanceof ChatMessageCell)) {
                            if (childAt instanceof ChatActionCell) {
                                i2 = ChatActivity.this.getScrollingOffsetForView(childAt);
                                break;
                            }
                        } else {
                            if (((ChatMessageCell) childAt).getCurrentMessagesGroup() == null) {
                                i2 = ChatActivity.this.getScrollingOffsetForView(childAt);
                                break;
                            }
                        }
                    }
                }
            }
            i = -1;
            i2 = 0;
            ChatActivity.this.lambda$updateMessageAnimated$308(primaryMessageObject, false);
            if (z && i >= 0 && chatMessageCell.getCurrentMessagesGroup() == null) {
                ChatActivity.this.chatLayoutManager.scrollToPositionWithOffset(i, i2);
            }
        }

        @Override
        public String getAdminRank(long j) {
            String adminRank;
            if (ChatObject.isChannel(ChatActivity.this.currentChat)) {
                ChatActivity chatActivity = ChatActivity.this;
                if (chatActivity.currentChat.megagroup && (adminRank = chatActivity.getMessagesController().getAdminRank(ChatActivity.this.currentChat.id, j)) != null) {
                    return adminRank;
                }
            }
            if (ChatActivity.this.forumTopic == null || ChatActivity.this.forumTopic.from_id == null) {
                return null;
            }
            if (ChatActivity.this.forumTopic.from_id.user_id == j || ChatActivity.this.forumTopic.from_id.channel_id == j || ChatActivity.this.forumTopic.from_id.chat_id == j) {
                return LocaleController.getString(R.string.TopicCreator);
            }
            return null;
        }

        @Override
        public PinchToZoomHelper getPinchToZoomHelper() {
            return ChatActivity.this.pinchToZoomHelper;
        }

        @Override
        public String getProgressLoadingBotButtonUrl(ChatMessageCell chatMessageCell) {
            if (chatMessageCell.getMessageObject() == null || ChatActivity.this.progressDialogAtMessageId == 0 || ChatActivity.this.progressDialogAtMessageId != chatMessageCell.getMessageObject().getId() || ChatActivity.this.progressDialogAtMessageType != 3) {
                return null;
            }
            return ChatActivity.this.progressDialogBotButtonUrl;
        }

        @Override
        public CharacterStyle getProgressLoadingLink(ChatMessageCell chatMessageCell) {
            if (chatMessageCell.getMessageObject() == null || ChatActivity.this.progressDialogAtMessageId == 0 || ChatActivity.this.progressDialogAtMessageId != chatMessageCell.getMessageObject().getId() || ChatActivity.this.progressDialogAtMessageType != 1) {
                return null;
            }
            return ChatActivity.this.progressDialogLinkSpan;
        }

        @Override
        public TextSelectionHelper.ChatListTextSelectionHelper getTextSelectionHelper() {
            return ChatActivity.this.textSelectionHelper;
        }

        @Override
        public boolean hasSelectedMessages() {
            return ChatActivity.this.selectedMessagesIds[0].size() + ChatActivity.this.selectedMessagesIds[1].size() > 0;
        }

        @Override
        public void invalidateBlur() {
            ChatActivity.this.contentView.invalidateBlur();
        }

        @Override
        public boolean isLandscape() {
            return ChatActivity.this.contentView.getMeasuredWidth() > ChatActivity.this.contentView.getMeasuredHeight();
        }

        @Override
        public boolean isProgressLoading(ChatMessageCell chatMessageCell, int i) {
            return ChatActivity.this.progressDialogAtMessageId != 0 && chatMessageCell.getMessageObject() != null && ChatActivity.this.progressDialogAtMessageId == chatMessageCell.getMessageObject().getId() && ChatActivity.this.progressDialogAtMessageType == i;
        }

        @Override
        public boolean isReplyOrSelf() {
            return UserObject.isReplyUser(ChatActivity.this.currentUser) || UserObject.isUserSelf(ChatActivity.this.currentUser);
        }

        @Override
        public boolean keyboardIsOpened() {
            return ChatActivity.this.contentView.getKeyboardHeight() + ChatActivity.this.chatEmojiViewPadding >= AndroidUtilities.dp(20.0f);
        }

        @Override
        public void needOpenWebView(MessageObject messageObject, String str, String str2, String str3, String str4, int i, int i2) {
            try {
                ChatActivity chatActivity = ChatActivity.this;
                EmbedBottomSheet.show(chatActivity, messageObject, chatActivity.photoViewerProvider, str2, str3, str4, str, i, i2, ChatActivity.this.isKeyboardVisible());
            } catch (Throwable th) {
                FileLog.e(th);
            }
        }

        @Override
        public boolean needPlayMessage(ChatMessageCell chatMessageCell, MessageObject messageObject, boolean z) {
            if (!messageObject.isVoiceOnce() && !messageObject.isRoundOnce()) {
                if (messageObject.isVoice() || messageObject.isRoundVideo()) {
                    boolean playMessage = MediaController.getInstance().playMessage(messageObject, z);
                    MediaController.getInstance().setVoiceMessagesPlaylist(playMessage ? ChatActivity.this.createVoiceMessagesPlaylist(messageObject, false) : null, false);
                    return playMessage;
                }
                if (messageObject.isMusic()) {
                    return MediaController.getInstance().setPlaylist(ChatActivity.this.chatAdapter.getMessages(), messageObject, ChatActivity.this.mergeDialogId, !ChatActivity.this.chatAdapter.isFiltered, (MediaController.PlaylistGlobalSearchParams) null);
                }
                return false;
            }
            if (ChatActivity.this.secretVoicePlayer != null && ChatActivity.this.secretVoicePlayer.isShown()) {
                return false;
            }
            try {
                AudioManager audioManager = (AudioManager) ApplicationLoader.applicationContext.getSystemService("audio");
                int streamVolume = audioManager.getStreamVolume(3);
                if (streamVolume == 0) {
                    audioManager.adjustStreamVolume(3, streamVolume, 1);
                    if (!messageObject.isOutOwner()) {
                        BulletinFactory.of(ChatActivity.this).createImageBulletin(R.drawable.tooltip_sound, LocaleController.getString(R.string.VoiceOnceTurnOnSound)).show(true);
                        return false;
                    }
                }
            } catch (Exception unused) {
            }
            ChatActivity.this.secretVoicePlayer = new SecretVoicePlayer(ChatActivity.this.getContext());
            ChatActivity.this.secretVoicePlayer.setCell(chatMessageCell, !messageObject.isOutOwner() ? ChatActivity.this.sendSecretMessageRead(messageObject, true) : null, messageObject.isOutOwner() ? null : ChatActivity.this.sendSecretMediaDelete(messageObject));
            ChatActivity chatActivity = ChatActivity.this;
            chatActivity.showDialog(chatActivity.secretVoicePlayer);
            return false;
        }

        @Override
        public void needReloadPolls() {
            ChatActivity.this.invalidateMessagesVisiblePart();
        }

        @Override
        public void needShowPremiumBulletin(int i) {
            String formatString;
            Runnable runnable;
            CharSequence charSequence;
            UndoView undoView;
            try {
                if (i == 0) {
                    ChatActivity.this.checkTopUndoView();
                    if (ChatActivity.this.topUndoView == null) {
                        return;
                    }
                    ChatActivity.this.topUndoView.showWithAction(0L, 84, (Runnable) null, new Runnable() {
                        @Override
                        public final void run() {
                            ChatActivity.ChatMessageCellDelegate.this.lambda$needShowPremiumBulletin$24();
                        }
                    });
                    undoView = ChatActivity.this.topUndoView;
                } else {
                    if (i != 1) {
                        if (i == 2 || i == 3) {
                            String formatDateTime = LocaleController.formatDateTime(ChatActivity.this.getMessagesController().transcribeAudioTrialCooldownUntil, true);
                            BulletinFactory of = BulletinFactory.of(ChatActivity.this);
                            int i2 = R.raw.transcribe;
                            SpannableStringBuilder append = new SpannableStringBuilder().append((CharSequence) AndroidUtilities.replaceTags(LocaleController.formatPluralString("TranscriptionTrialEnd", ChatActivity.this.getMessagesController().transcribeAudioTrialWeeklyNumber, new Object[0]))).append((CharSequence) " ");
                            if (i == 2) {
                                formatString = LocaleController.getString(R.string.TranscriptionTrialEndBuy);
                                runnable = new Runnable() {
                                    @Override
                                    public final void run() {
                                        ChatActivity.ChatMessageCellDelegate.this.lambda$needShowPremiumBulletin$25();
                                    }
                                };
                            } else {
                                if (ChatActivity.this.getMessagesController().transcribeAudioTrialCooldownUntil <= 0) {
                                    charSequence = "";
                                    of.createSimpleBulletin(i2, append.append(charSequence), 6, 7000).show(true);
                                    BotWebViewVibrationEffect.APP_ERROR.vibrate();
                                    return;
                                }
                                formatString = LocaleController.formatString(R.string.TranscriptionTrialEndWaitOrBuy, new Object[]{formatDateTime});
                                runnable = new Runnable() {
                                    @Override
                                    public final void run() {
                                        ChatActivity.ChatMessageCellDelegate.this.lambda$needShowPremiumBulletin$26();
                                    }
                                };
                            }
                            charSequence = AndroidUtilities.replaceSingleTag(formatString, runnable);
                            of.createSimpleBulletin(i2, append.append(charSequence), 6, 7000).show(true);
                            BotWebViewVibrationEffect.APP_ERROR.vibrate();
                            return;
                        }
                        return;
                    }
                    BulletinFactory.of(ChatActivity.this).createSimpleBulletin(R.raw.transcribe, AndroidUtilities.replaceTags(ChatActivity.this.getMessagesController().transcribeAudioTrialCooldownUntil > 0 ? LocaleController.formatPluralString("TranscriptionTrialLeftUntil", TranscribeButton.getTranscribeTrialCount(((BaseFragment) ChatActivity.this).currentAccount), new Object[]{LocaleController.formatDateTime(ChatActivity.this.getMessagesController().transcribeAudioTrialCooldownUntil, true)}) : LocaleController.formatPluralString("TranscriptionTrialLeft", TranscribeButton.getTranscribeTrialCount(((BaseFragment) ChatActivity.this).currentAccount), new Object[0])), 6).show(true);
                    undoView = ((BaseFragment) ChatActivity.this).fragmentView;
                }
                undoView.performHapticFeedback(3, 2);
            } catch (Exception unused) {
            }
        }

        @Override
        public boolean onAccessibilityAction(int i, Bundle bundle) {
            if (i != 16 && i != R.id.acc_action_small_button && i != R.id.acc_action_msg_options) {
                return false;
            }
            if (((BaseFragment) ChatActivity.this).inPreviewMode) {
                ChatActivity chatActivity = ChatActivity.this;
                if (chatActivity.allowExpandPreviewByClick) {
                    if (((BaseFragment) chatActivity).parentLayout != null) {
                        ((BaseFragment) ChatActivity.this).parentLayout.expandPreviewFragment();
                    }
                    return true;
                }
            }
            return !canPerformActions();
        }

        @Override
        public void onDiceFinished() {
            if (ChatActivity.this.fireworksOverlay.isStarted()) {
                return;
            }
            ChatActivity.this.fireworksOverlay.start();
            try {
                ChatActivity.this.fireworksOverlay.performHapticFeedback(3, 2);
            } catch (Exception unused) {
            }
        }

        @Override
        public void setShouldNotRepeatSticker(MessageObject messageObject) {
            ChatActivity.this.alreadyPlayedStickers.put(messageObject, Boolean.TRUE);
        }

        @Override
        public boolean shouldDrawThreadProgress(ChatMessageCell chatMessageCell, boolean z) {
            MessageObject.GroupedMessages currentMessagesGroup = chatMessageCell.getCurrentMessagesGroup();
            MessageObject messageObject = (currentMessagesGroup == null || currentMessagesGroup.messages.isEmpty()) ? chatMessageCell.getMessageObject() : (MessageObject) currentMessagesGroup.messages.get(0);
            if (messageObject == null) {
                return false;
            }
            boolean z2 = !ChatActivity.this.hideCommentLoading && messageObject.getId() == ChatActivity.this.commentLoadingMessageId;
            return z ? z2 && System.currentTimeMillis() - ChatActivity.this.commentLoadingStartedAt > 1000 : z2;
        }

        @Override
        public boolean shouldRepeatSticker(MessageObject messageObject) {
            return !ChatActivity.this.alreadyPlayedStickers.containsKey(messageObject);
        }

        @Override
        public void videoTimerReached() {
            ChatActivity.this.showNoSoundHint();
        }
    }

    public class ChatScrollCallback extends RecyclerAnimationScrollHelper.AnimationCallback {
        private boolean lastBottom;
        private int lastItemOffset;
        private int lastPadding;
        private MessageObject scrollTo;
        private int position = 0;
        private boolean bottom = true;
        private int offset = 0;

        public ChatScrollCallback() {
        }

        public void lambda$onEndAnimation$0() {
            ChatActivity.this.getNotificationCenter().onAnimationFinish(ChatActivity.this.scrollCallbackAnimationIndex);
        }

        public void onEndAnimation() {
            if (this.scrollTo != null) {
                ChatActivity.this.chatAdapter.updateRowsSafe();
                int indexOf = ChatActivity.this.chatAdapter.messagesStartRow + ChatActivity.this.messages.indexOf(this.scrollTo);
                if (indexOf >= 0) {
                    ChatActivity.this.chatLayoutManager.scrollToPositionWithOffset(indexOf, (int) ((this.lastItemOffset + this.lastPadding) - ChatActivity.this.chatListViewPaddingTop), this.lastBottom);
                }
            } else {
                ChatActivity.this.chatAdapter.updateRowsSafe();
                ChatActivity.this.chatLayoutManager.scrollToPositionWithOffset(this.position, this.offset, this.bottom);
            }
            this.scrollTo = null;
            ChatActivity.this.checkTextureViewPosition = true;
            ChatActivity.this.updateVisibleRows();
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.ChatScrollCallback.this.lambda$onEndAnimation$0();
                }
            });
        }

        public void onStartAnimation() {
            super.onStartAnimation();
            ChatActivity chatActivity = ChatActivity.this;
            chatActivity.scrollCallbackAnimationIndex = chatActivity.getNotificationCenter().setAnimationInProgress(ChatActivity.this.scrollCallbackAnimationIndex, ChatActivity.allowedNotificationsDuringChatListAnimations);
            if (ChatActivity.this.pinchToZoomHelper.isInOverlayMode()) {
                ChatActivity.this.pinchToZoomHelper.finishZoom();
            }
        }

        public void recycleView(View view) {
            if (view instanceof ChatMessageCell) {
                ChatMessageCell chatMessageCell = (ChatMessageCell) view;
                chatMessageCell.setDelegate(null);
                ArrayList arrayList = (ArrayList) ChatActivity.chatMessageCellsCache.get(((BaseFragment) ChatActivity.this).currentAccount);
                if (arrayList == null) {
                    LongSparseArray longSparseArray = ChatActivity.chatMessageCellsCache;
                    long j = ((BaseFragment) ChatActivity.this).currentAccount;
                    ArrayList arrayList2 = new ArrayList();
                    longSparseArray.put(j, arrayList2);
                    arrayList = arrayList2;
                }
                arrayList.add(chatMessageCell);
            }
        }
    }

    public class FirstViewPage extends View {
        private final ArrayList views;
        private final ArrayList viewsToMakeVisible;

        public FirstViewPage(Context context) {
            super(context);
            this.views = new ArrayList();
            this.viewsToMakeVisible = new ArrayList();
        }

        private void updateViews() {
            this.views.clear();
            this.views.add(ChatActivity.this.pagedownButton);
            this.views.add(ChatActivity.this.searchUpButton);
            this.views.add(ChatActivity.this.searchDownButton);
            this.views.add(ChatActivity.this.searchContainer);
            this.views.add(ChatActivity.this.topChatPanelView);
            this.views.add(ChatActivity.this.topChatPanelView2);
            this.views.add(ChatActivity.this.chatListView);
            this.views.add(ChatActivity.this.messagesSearchListContainer);
            this.views.add(ChatActivity.this.mentionContainer);
            this.views.add(ChatActivity.this.floatingDateView);
            this.views.add(ChatActivity.this.chatActivityEnterView);
            this.views.removeAll(Collections.singleton(null));
        }

        @Override
        public boolean dispatchTouchEvent(MotionEvent motionEvent) {
            return false;
        }

        @Override
        protected void onAttachedToWindow() {
            super.onAttachedToWindow();
            Iterator it = this.viewsToMakeVisible.iterator();
            while (it.hasNext()) {
                ((View) it.next()).setVisibility(0);
            }
            this.viewsToMakeVisible.clear();
        }

        @Override
        protected void onDetachedFromWindow() {
            super.onDetachedFromWindow();
            updateViews();
            Iterator it = this.views.iterator();
            while (it.hasNext()) {
                View view = (View) it.next();
                if (view.getVisibility() == 0) {
                    view.setVisibility(8);
                    this.viewsToMakeVisible.add(view);
                }
            }
        }

        @Override
        public void setTranslationX(float f) {
            super.setTranslationX(f);
            updateViews();
            Iterator it = this.views.iterator();
            while (it.hasNext()) {
                View view = (View) it.next();
                if (view != null) {
                    view.setTranslationX(f);
                }
            }
        }
    }

    private static final class MessageSkeleton {
        int height;
        int lastBottom;
        int width;

        private MessageSkeleton() {
        }
    }

    class PinnedMessageButton extends TextView {
        public PinnedMessageButton(Context context) {
            super(context);
            setSingleLine(true);
            setLines(1);
            setMaxLines(1);
            setEllipsize(TextUtils.TruncateAt.END);
            setTextColor(ChatActivity.this.getThemedColor(Theme.key_featuredStickers_buttonText));
            setBackground(Theme.AdaptiveRipple.filledRect(ChatActivity.this.getThemedColor(Theme.key_featuredStickers_addButton), 16.0f));
            setTextSize(1, 14.0f);
            setTypeface(AndroidUtilities.bold());
            setGravity(17);
            setPadding(AndroidUtilities.dp(14.0f), 0, AndroidUtilities.dp(14.0f), 0);
        }

        @Override
        protected void onMeasure(int i, int i2) {
            super.onMeasure(View.MeasureSpec.makeMeasureSpec(Math.min(View.MeasureSpec.getSize(i), (int) (AndroidUtilities.displaySize.x * 0.45f)), Integer.MIN_VALUE), i2);
        }
    }

    private class RecyclerListViewInternal extends RecyclerListView implements StoriesListPlaceProvider.ClippedView {
        public RecyclerListViewInternal(Context context, ThemeDelegate themeDelegate) {
            super(context, themeDelegate);
        }

        public void updateClip(int[] iArr) {
            iArr[0] = ((int) ChatActivity.this.chatListViewPaddingTop) - AndroidUtilities.dp(4.0f);
            iArr[1] = ChatActivity.this.chatListView.getMeasuredHeight() - (ChatActivity.this.chatListView.getPaddingBottom() - AndroidUtilities.dp(3.0f));
        }
    }

    public static class ReplyQuote {
        public int end;
        public ArrayList entities;
        public int length;
        public MessageObject message;
        public int offset;
        public boolean outdated;
        public final long peerId;
        public int start;
        public String text;

        private ReplyQuote(long j, MessageObject messageObject, int i, int i2) {
            this.peerId = j;
            this.message = messageObject;
            this.start = i;
            this.end = i2;
            update();
        }

        public static ReplyQuote from(MessageObject messageObject) {
            TLRPC.Message message;
            if (messageObject == null || (message = messageObject.messageOwner) == null || message.message == null) {
                return null;
            }
            return from(messageObject, 0, Math.min(MessagesController.getInstance(messageObject.currentAccount).quoteLengthMax, messageObject.messageOwner.message.length()));
        }

        public static ReplyQuote from(MessageObject messageObject, int i, int i2) {
            if (messageObject == null) {
                return null;
            }
            return new ReplyQuote(messageObject.getDialogId(), messageObject, i, i2);
        }

        public static ReplyQuote from(MessageObject messageObject, String str, int i) {
            TLRPC.Message message;
            String str2;
            int findQuoteStart;
            if (messageObject == null || (message = messageObject.messageOwner) == null || (str2 = message.message) == null || str == null || (findQuoteStart = MessageObject.findQuoteStart(str2, str, i)) < 0) {
                return null;
            }
            return new ReplyQuote(messageObject.getDialogId(), messageObject, findQuoteStart, findQuoteStart + str.length());
        }

        public boolean update() {
            String str;
            TLRPC.Message message;
            String str2;
            int i;
            TLRPC.TL_messageEntityBold tL_messageEntityCustomEmoji;
            MessageObject messageObject = this.message;
            if (messageObject == null || (message = messageObject.messageOwner) == null || (str2 = message.message) == null) {
                str = "ReplyQuote: message is null";
            } else {
                int i2 = this.end;
                if (i2 < this.start || i2 > str2.length() || this.start > this.message.messageOwner.message.length() || (i = this.start) < 0 || this.end < 0) {
                    str = "ReplyQuote: start/end are invalid (" + this.start + ", " + this.end + ", len=" + this.message.messageOwner.message.length() + ")";
                } else {
                    String str3 = this.message.messageOwner.message;
                    int max = Math.max(0, i);
                    while (max < this.end && Character.isWhitespace(str3.charAt(max))) {
                        max++;
                    }
                    int min = Math.min(this.end, str3.length());
                    while (min > max && Character.isWhitespace(str3.charAt(min - 1))) {
                        min--;
                    }
                    if (max != min) {
                        this.text = this.message.messageOwner.message.substring(max, min);
                        ArrayList arrayList = this.entities;
                        if (arrayList != null) {
                            arrayList.clear();
                        }
                        ArrayList arrayList2 = this.message.messageOwner.entities;
                        if (arrayList2 != null && !arrayList2.isEmpty()) {
                            for (int i3 = 0; i3 < this.message.messageOwner.entities.size(); i3++) {
                                TLRPC.TL_messageEntityCustomEmoji tL_messageEntityCustomEmoji2 = (TLRPC.MessageEntity) this.message.messageOwner.entities.get(i3);
                                int i4 = ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji2).offset;
                                if (AndroidUtilities.intersect1dInclusive(max, min, i4, ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji2).length + i4)) {
                                    if (tL_messageEntityCustomEmoji2 instanceof TLRPC.TL_messageEntityBold) {
                                        tL_messageEntityCustomEmoji = new TLRPC.TL_messageEntityBold();
                                    } else if (tL_messageEntityCustomEmoji2 instanceof TLRPC.TL_messageEntityItalic) {
                                        tL_messageEntityCustomEmoji = new TLRPC.TL_messageEntityItalic();
                                    } else if (tL_messageEntityCustomEmoji2 instanceof TLRPC.TL_messageEntityUnderline) {
                                        tL_messageEntityCustomEmoji = new TLRPC.TL_messageEntityUnderline();
                                    } else if (tL_messageEntityCustomEmoji2 instanceof TLRPC.TL_messageEntityStrike) {
                                        tL_messageEntityCustomEmoji = new TLRPC.TL_messageEntityStrike();
                                    } else if (tL_messageEntityCustomEmoji2 instanceof TLRPC.TL_messageEntitySpoiler) {
                                        tL_messageEntityCustomEmoji = new TLRPC.TL_messageEntitySpoiler();
                                    } else if (tL_messageEntityCustomEmoji2 instanceof TLRPC.TL_messageEntityCustomEmoji) {
                                        tL_messageEntityCustomEmoji = new TLRPC.TL_messageEntityCustomEmoji();
                                        TLRPC.TL_messageEntityCustomEmoji tL_messageEntityCustomEmoji3 = tL_messageEntityCustomEmoji2;
                                        ((TLRPC.TL_messageEntityCustomEmoji) tL_messageEntityCustomEmoji).document_id = tL_messageEntityCustomEmoji3.document_id;
                                        ((TLRPC.TL_messageEntityCustomEmoji) tL_messageEntityCustomEmoji).document = tL_messageEntityCustomEmoji3.document;
                                    }
                                    int i5 = ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji2).offset;
                                    int i6 = i5 - max;
                                    int i7 = (i5 + ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji2).length) - max;
                                    if ((i6 >= 0 || i7 >= 0) && (i6 <= min || i7 <= min)) {
                                        ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).offset = Math.max(0, i6);
                                        ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).length = Math.min(i7, min - max) - ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).offset;
                                        if (this.entities == null) {
                                            this.entities = new ArrayList();
                                        }
                                        this.entities.add(tL_messageEntityCustomEmoji);
                                    }
                                }
                            }
                        }
                        this.offset = max;
                        this.length = min - max;
                        return true;
                    }
                    str = "ReplyQuote: message is full of whitespace";
                }
            }
            FileLog.e(str);
            return false;
        }

        public boolean checkEdit(MessageObject messageObject) {
            String str;
            TLRPC.Message message;
            String str2;
            int i;
            int i2;
            if (messageObject == null || (message = messageObject.messageOwner) == null || (str2 = message.message) == null) {
                str = "ReplyQuote.checkEdit: message is null";
            } else {
                int i3 = this.end;
                if (i3 >= this.start && i3 <= str2.length() && this.start <= messageObject.messageOwner.message.length() && (i = this.start) >= 0 && (i2 = this.end) >= 0) {
                    if (TextUtils.equals(this.text, messageObject.messageOwner.message.substring(i, i2))) {
                        this.message = messageObject;
                    } else {
                        int indexOf = messageObject.messageOwner.message.indexOf(this.text);
                        this.message = messageObject;
                        if (indexOf < 0) {
                            this.start = 0;
                            this.end = messageObject.messageOwner.message.length();
                            update();
                            this.outdated = true;
                            return true;
                        }
                        this.end = (this.end - this.start) + indexOf;
                        this.start = indexOf;
                    }
                    update();
                    this.outdated = false;
                    return false;
                }
                str = "ReplyQuote.checkEdit: start/end are invalid (" + this.start + ", " + this.end + ", len=" + messageObject.messageOwner.message.length() + ")";
            }
            FileLog.e(str);
            this.outdated = false;
            return false;
        }

        public ArrayList getEntities() {
            return this.entities;
        }

        public String getText() {
            return this.text;
        }
    }

    class SearchItemListener extends ActionBarMenuItem.ActionBarMenuItemSearchListener {
        private float searchAnimationProgress;
        private boolean whiteActionBar;

        private SearchItemListener() {
        }

        public void lambda$onSearchCollapse$0(ValueAnimator valueAnimator) {
            setSearchAnimationProgress(((Float) valueAnimator.getAnimatedValue()).floatValue());
        }

        public void lambda$onSearchExpand$1() {
            ChatActivity chatActivity = ChatActivity.this;
            chatActivity.searchWas = false;
            chatActivity.searchItem.getSearchField().requestFocus();
            AndroidUtilities.showKeyboard(ChatActivity.this.searchItem.getSearchField());
            ChatActivity.this.removeKeyboardPositionBeforeTransition();
        }

        public void lambda$onSearchExpand$2(ValueAnimator valueAnimator) {
            setSearchAnimationProgress(((Float) valueAnimator.getAnimatedValue()).floatValue());
        }

        public void lambda$onSearchPressed$3(ValueAnimator valueAnimator) {
            setSearchAnimationProgress(((Float) valueAnimator.getAnimatedValue()).floatValue());
        }

        @Override
        public boolean canClearCaption() {
            return ChatActivity.this.searchingHashtag == null;
        }

        @Override
        public boolean canCollapseSearch() {
            if (ChatActivity.this.hashtagHistoryView.isShowing()) {
                return true;
            }
            if (ChatActivity.this.searchingHashtag != null) {
                ChatActivity chatActivity = ChatActivity.this;
                if (chatActivity.hashtagSearchTabs != null) {
                    View currentView = chatActivity.searchViewPager.getCurrentView();
                    if (currentView instanceof ChatActivityContainer) {
                        chatActivity = ((ChatActivityContainer) currentView).chatActivity;
                    }
                    if (chatActivity.messagesSearchListContainer.getTag() == null) {
                        chatActivity.showMessagesSearchListView(true);
                        return false;
                    }
                    if (ChatActivity.this.hashtagSearchTabs.tabs.getCurrentPosition() != ChatActivity.this.defaultSearchPage) {
                        ChatActivity chatActivity2 = ChatActivity.this;
                        chatActivity2.hashtagSearchTabs.tabs.scrollToTab(chatActivity2.defaultSearchPage, ChatActivity.this.defaultSearchPage);
                        return false;
                    }
                    return true;
                }
            }
            if (ChatActivity.this.messagesSearchListContainer.getTag() != null) {
                ChatActivity.this.showMessagesSearchListView(false);
                return false;
            }
            return true;
        }

        @Override
        public boolean forceShowClear() {
            return ChatActivity.this.searchingForUser;
        }

        @Override
        public void onCaptionCleared() {
            ChatActivity.this.createSearchContainer();
            if (ChatActivity.this.searchingUserMessages != null || ChatActivity.this.searchingChatMessages != null) {
                if (ChatActivity.this.searchUserButton != null) {
                    ChatActivity.this.searchUserButton.callOnClick();
                    return;
                }
                return;
            }
            if (ChatActivity.this.searchingForUser) {
                ChatActivity.this.mentionContainer.getAdapter().lambda$searchUsernameOrHashtag$7(null, 0, null, false, true);
                ChatActivity.this.searchingForUser = false;
                ChatActivity.this.searchItem.setSearchFieldText("", true);
            }
            ChatActivity chatActivity = ChatActivity.this;
            chatActivity.searchItem.setSearchFieldHint(LocaleController.getString(chatActivity.isSupportedTags() ? R.string.SavedTagSearchHint : R.string.Search));
            ChatActivity.this.searchCalendarButton.setVisibility(0);
            if (ChatActivity.this.searchUserButton != null) {
                ChatActivity.this.searchUserButton.setVisibility(0);
            }
            ChatActivity.this.searchingUserMessages = null;
            ChatActivity.this.searchingChatMessages = null;
        }

        @Override
        public void onSearchCollapse() {
            throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.SearchItemListener.onSearchCollapse():void");
        }

        @Override
        public void onSearchExpand() {
            ChatSearchTabs chatSearchTabs;
            boolean z = false;
            ChatActivity.this.searching = true;
            ChatActivity.this.updatePagedownButtonVisibility(true);
            ChatActivity.this.updateSearchUpDownButtonVisibility(true);
            if ((ChatActivity.this.threadMessageId != 0 && ChatActivity.this.chatMode != 3) || UserObject.isReplyUser(ChatActivity.this.currentUser)) {
                ChatActivity chatActivity = ChatActivity.this;
                if (!chatActivity.preventReopenSearchWithText) {
                    chatActivity.lambda$openSearchWithText$357(null);
                }
            }
            if (ChatActivity.this.openSearchKeyboard) {
                ChatActivity.this.saveKeyboardPositionBeforeTransition();
                ChatActivity chatActivity2 = ChatActivity.this;
                if (!chatActivity2.isInsideContainer) {
                    AndroidUtilities.requestAdjustResize(chatActivity2.getParentActivity(), ((BaseFragment) ChatActivity.this).classGuid);
                }
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.SearchItemListener.this.lambda$onSearchExpand$1();
                    }
                }, 500L);
                ChatActivity.this.hideSendButtonHints();
            }
            this.whiteActionBar = ChatActivity.this.searchingHashtag != null || ChatActivity.this.getDialogId() == ChatActivity.this.getUserConfig().getClientUserId();
            ValueAnimator ofFloat = ValueAnimator.ofFloat(this.searchAnimationProgress, 1.0f);
            ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                    ChatActivity.SearchItemListener.this.lambda$onSearchExpand$2(valueAnimator);
                }
            });
            ofFloat.setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT);
            ofFloat.setDuration(320L);
            ofFloat.start();
            ChatActivity chatActivity3 = ChatActivity.this;
            SearchTagsList searchTagsList = chatActivity3.actionBarSearchTags;
            if (searchTagsList != null) {
                if (!chatActivity3.isInsideContainer && searchTagsList.hasFilters() && ChatActivity.this.searchingHashtag == null) {
                    z = true;
                }
                searchTagsList.show(z);
            }
            if (ChatActivity.this.searchingHashtag == null || (chatSearchTabs = ChatActivity.this.hashtagSearchTabs) == null || chatSearchTabs.tabs.getCurrentPosition() == ChatActivity.this.defaultSearchPage) {
                return;
            }
            ChatActivity chatActivity4 = ChatActivity.this;
            chatActivity4.hashtagSearchTabs.tabs.scrollToTab(chatActivity4.defaultSearchPage, ChatActivity.this.defaultSearchPage);
        }

        @Override
        public void onSearchFilterCleared(FiltersView.MediaFilterData mediaFilterData) {
            super.onSearchFilterCleared(mediaFilterData);
            SearchTagsList searchTagsList = ChatActivity.this.actionBarSearchTags;
            if (searchTagsList != null) {
                searchTagsList.clear();
            }
            ChatActivity chatActivity = ChatActivity.this;
            chatActivity.searchingReaction = null;
            chatActivity.updateSearchUpDownButtonVisibility(true);
            ChatActivity.this.updatePagedownButtonVisibility(true);
            ChatActivity.this.setFilterMessages(false);
        }

        @Override
        public void onSearchPressed(EditText editText) {
            ChatActivity chatActivity = ChatActivity.this;
            boolean z = true;
            chatActivity.searchWas = true;
            boolean z2 = false;
            chatActivity.updateSearchButtons(0, 0, -1);
            ChatActivity chatActivity2 = ChatActivity.this;
            chatActivity2.searchingQuery = editText != null ? editText.getText().toString() : chatActivity2.searchingQuery;
            if (TextUtils.isEmpty(ChatActivity.this.searchingQuery) || !(ChatActivity.this.searchingQuery.startsWith("$") || ChatActivity.this.searchingQuery.startsWith("#"))) {
                ChatActivity.this.searchingHashtag = null;
                ChatSearchTabs chatSearchTabs = ChatActivity.this.hashtagSearchTabs;
                if (chatSearchTabs != null) {
                    chatSearchTabs.show(false);
                    ChatActivity.this.messagesSearchListContainer.setPadding(0, 0, 0, ChatActivity.this.getHashtagTabsHeight());
                    ChatActivity.this.updateSearchListEmptyView();
                }
                ChatSearchTabs chatSearchTabs2 = ChatActivity.this.hashtagSearchTabs;
                if (chatSearchTabs2 != null && chatSearchTabs2.tabs.getCurrentPosition() != 0) {
                    ChatActivity.this.hashtagSearchTabs.tabs.scrollToTab(0, 0);
                }
                z = false;
            } else {
                if (ChatActivity.this.searchingQuery.contains("@")) {
                    ChatActivity chatActivity3 = ChatActivity.this;
                    chatActivity3.presentFragment(new HashtagActivity(chatActivity3.searchingQuery, ((BaseFragment) ChatActivity.this).resourceProvider));
                    return;
                }
                if (ChatActivity.this.searchingHashtag == null) {
                    ChatActivity chatActivity4 = ChatActivity.this;
                    chatActivity4.searchingHashtag = chatActivity4.searchingQuery;
                    this.whiteActionBar = true;
                    ValueAnimator ofFloat = ValueAnimator.ofFloat(this.searchAnimationProgress, 1.0f);
                    ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                        @Override
                        public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                            ChatActivity.SearchItemListener.this.lambda$onSearchPressed$3(valueAnimator);
                        }
                    });
                    ofFloat.setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT);
                    ofFloat.setDuration(320L);
                    ofFloat.start();
                    ChatActivity chatActivity5 = ChatActivity.this;
                    SearchTagsList searchTagsList = chatActivity5.actionBarSearchTags;
                    if (searchTagsList != null) {
                        if (!chatActivity5.isInsideContainer && searchTagsList.hasFilters() && ChatActivity.this.searchingHashtag == null) {
                            z2 = true;
                        }
                        searchTagsList.show(z2);
                    }
                }
                ChatActivity chatActivity6 = ChatActivity.this;
                chatActivity6.searchingHashtag = chatActivity6.searchingQuery;
                ChatActivity.this.checkHashtagStories(true);
                HashtagSearchController.getInstance(((BaseFragment) ChatActivity.this).currentAccount).putToHistory(ChatActivity.this.searchingHashtag);
                ChatActivity.this.hashtagHistoryView.update();
                View currentView = ChatActivity.this.searchViewPager.getCurrentView();
                if (ChatActivity.this.searchType == 3) {
                    HashtagSearchController.getInstance(((BaseFragment) ChatActivity.this).currentAccount).clearSearchResults(3);
                } else {
                    HashtagSearchController.getInstance(((BaseFragment) ChatActivity.this).currentAccount).clearSearchResults();
                }
                if (currentView instanceof ChatActivityContainer) {
                    ((ChatActivityContainer) currentView).chatActivity.updateSearchingHashtag(ChatActivity.this.searchingHashtag);
                }
                ChatActivity.this.updateSearchListEmptyView();
                ChatActivity.this.hashtagSearchEmptyView.showProgress(true);
                ChatActivity.this.showMessagesSearchListView(true);
            }
            ChatSearchTabs chatSearchTabs3 = ChatActivity.this.hashtagSearchTabs;
            if (chatSearchTabs3 != null) {
                chatSearchTabs3.show(z);
            }
            ChatActivity.this.getMediaDataController().searchMessagesInChat(ChatActivity.this.searchingQuery, ChatActivity.this.dialog_id, ChatActivity.this.mergeDialogId, ((BaseFragment) ChatActivity.this).classGuid, 0, ChatActivity.this.threadMessageId, ChatActivity.this.searchingUserMessages, ChatActivity.this.searchingChatMessages, ChatActivity.this.searchingReaction);
        }

        @Override
        public void onTextChanged(EditText editText) {
            if (ChatActivity.this.searchingHashtag == null) {
                ChatActivity.this.showMessagesSearchListView(false);
            }
            ChatActivity.this.createSearchContainer();
            if (ChatActivity.this.searchingForUser) {
                ChatActivity.this.mentionContainer.getAdapter().lambda$searchUsernameOrHashtag$7("@" + editText.getText().toString(), 0, ChatActivity.this.messages, true, true);
            } else if (ChatActivity.this.searchingUserMessages == null && ChatActivity.this.searchingChatMessages == null && ChatActivity.this.searchUserButton != null && TextUtils.equals(editText.getText(), LocaleController.getString(R.string.SearchFrom))) {
                ChatActivity.this.searchUserButton.callOnClick();
            }
            if (ChatActivity.this.searchingHashtag != null) {
                boolean z = editText.length() == 0;
                if (z != ChatActivity.this.hashtagHistoryView.isShowing()) {
                    ChatActivity.this.hashtagHistoryView.show(z);
                    ChatActivity.this.updateBottomOverlay();
                }
            }
        }

        public void setSearchAnimationProgress(float f) {
            this.searchAnimationProgress = f;
            if (this.whiteActionBar) {
                int themedColor = ChatActivity.this.getThemedColor(Theme.key_actionBarDefaultIcon);
                ActionBar actionBar = ((BaseFragment) ChatActivity.this).actionBar;
                ChatActivity chatActivity = ChatActivity.this;
                int i = Theme.key_actionBarActionModeDefaultIcon;
                actionBar.setItemsColor(ColorUtils.blendARGB(themedColor, chatActivity.getThemedColor(i), this.searchAnimationProgress), false);
                ((BaseFragment) ChatActivity.this).actionBar.setItemsColor(ChatActivity.this.getThemedColor(i), true);
                ((BaseFragment) ChatActivity.this).actionBar.setItemsBackgroundColor(ColorUtils.blendARGB(ChatActivity.this.getThemedColor(Theme.key_actionBarDefaultSelector), ChatActivity.this.getThemedColor(Theme.key_actionBarActionModeDefaultSelector), this.searchAnimationProgress), false);
                ((BaseFragment) ChatActivity.this).actionBar.setBackgroundColor(ColorUtils.blendARGB(ChatActivity.this.getThemedColor(Theme.key_actionBarDefault), ChatActivity.this.getThemedColor(Theme.key_actionBarActionModeDefault), this.searchAnimationProgress));
                ActionBar actionBar2 = ((BaseFragment) ChatActivity.this).actionBar;
                int i2 = Theme.key_actionBarDefaultSearch;
                actionBar2.setSearchTextColor(ColorUtils.blendARGB(Theme.getColor(i2), ChatActivity.this.getThemedColor(Theme.key_windowBackgroundWhiteBlackText), this.searchAnimationProgress), false);
                ((BaseFragment) ChatActivity.this).actionBar.setSearchTextColor(ColorUtils.blendARGB(Theme.getColor(Theme.key_actionBarDefaultSearchPlaceholder), ChatActivity.this.getThemedColor(Theme.key_windowBackgroundWhiteGrayText), this.searchAnimationProgress), true);
                ((BaseFragment) ChatActivity.this).actionBar.setSearchCursorColor(ColorUtils.blendARGB(Theme.getColor(i2), ChatActivity.this.getThemedColor(Theme.key_windowBackgroundWhiteBlueText), this.searchAnimationProgress));
                ChatActivity chatActivity2 = ChatActivity.this;
                if (!chatActivity2.isInsideContainer && chatActivity2.getParentActivity() != null) {
                    AndroidUtilities.setLightStatusBar(ChatActivity.this.getParentActivity().getWindow(), ChatActivity.this.isLightStatusBar());
                }
            }
            View view = ((BaseFragment) ChatActivity.this).fragmentView;
            if (view != null) {
                view.invalidate();
            }
        }

        @Override
        public boolean showClearForCaption() {
            return ChatActivity.this.searchingHashtag == null;
        }
    }

    public class ThemeDelegate implements Theme.ResourcesProvider, ChatActionCell.ThemeDelegate, MessagePreviewView.ResourcesDelegate {
        private SparseIntArray animatingColors;
        Theme.MessageDrawable animatingMessageDrawable;
        Theme.MessageDrawable animatingMessageMediaDrawable;
        private Drawable backgroundDrawable;
        private List cachedThemes;
        private EmojiThemes chatTheme;
        private int currentColor;
        int currentServiceColor;
        boolean drawSelectedGradient;
        boolean drawServiceGradient;
        private AnimatorSet patternAlphaAnimator;
        private ValueAnimator patternIntensityAnimator;
        private Bitmap serviceBitmap;
        private Bitmap serviceBitmapSource;
        private Canvas serviceCanvas;
        private BitmapShader serviceShader;
        private BitmapShader serviceShaderSource;
        Bitmap startServiceBitmap;
        int startServiceButtonColor;
        int startServiceColor;
        int startServiceIconColor;
        int startServiceLinkColor;
        int startServiceTextColor;
        private boolean useSourceShader;
        private TLRPC.WallPaper wallpaper;
        private final HashMap currentDrawables = new HashMap();
        private final HashMap currentPaints = new HashMap();
        private final Matrix actionMatrix = new Matrix();
        private SparseIntArray currentColors = new SparseIntArray();
        private Paint paint = new Paint();
        final Rect src = new Rect();
        final Rect dst = new Rect();
        private boolean isDark = Theme.getActiveTheme().isDark();

        ThemeDelegate() {
            if (isThemeChangeAvailable(false)) {
                this.chatTheme = ChatThemeController.getInstance(((BaseFragment) ChatActivity.this).currentAccount).getDialogTheme(ChatActivity.this.dialog_id);
                TLRPC.WallPaper dialogWallpaper = ChatThemeController.getInstance(((BaseFragment) ChatActivity.this).currentAccount).getDialogWallpaper(ChatActivity.this.dialog_id);
                this.wallpaper = dialogWallpaper;
                EmojiThemes emojiThemes = this.chatTheme;
                if (emojiThemes != null || dialogWallpaper != null) {
                    setupChatTheme(emojiThemes, dialogWallpaper, false, true);
                    AndroidUtilities.runOnUIThread(new Runnable() {
                        @Override
                        public final void run() {
                            ChatActivity.ThemeDelegate.lambda$new$0();
                        }
                    });
                }
            }
            if (ThemeEditorView.getInstance() == null) {
                Theme.refreshThemeColors(true, true);
                return;
            }
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.ThemeDelegate.lambda$new$0();
                }
            });
        }

        private Drawable getBackgroundDrawableFromTheme(final EmojiThemes emojiThemes, int i) {
            if (emojiThemes.showAsDefaultStub) {
                Drawable drawable = Theme.createBackgroundDrawable(EmojiThemes.getDefaultThemeInfo(this.isDark), emojiThemes.getPreviewColors(((BaseFragment) ChatActivity.this).currentAccount, this.isDark ? 1 : 0), emojiThemes.getWallpaperLink(this.isDark ? 1 : 0), i, false).wallpaper;
                return new ColorDrawable(-16777216);
            }
            int color = getColor(Theme.key_chat_wallpaper);
            int color2 = getColor(Theme.key_chat_wallpaper_gradient_to1);
            int color3 = getColor(Theme.key_chat_wallpaper_gradient_to2);
            int color4 = getColor(Theme.key_chat_wallpaper_gradient_to3);
            final MotionBackgroundDrawable motionBackgroundDrawable = new MotionBackgroundDrawable();
            motionBackgroundDrawable.setPatternBitmap(emojiThemes.getWallpaper(this.isDark ? 1 : 0).settings.intensity);
            motionBackgroundDrawable.setColors(color, color2, color3, color4, 0, true);
            motionBackgroundDrawable.setPhase(i);
            final int patternColor = motionBackgroundDrawable.getPatternColor();
            final boolean z = this.isDark;
            emojiThemes.loadWallpaper(z ? 1 : 0, new ResultCallback() {
                public final void onComplete(Object obj) {
                    ChatActivity.ThemeDelegate.this.lambda$getBackgroundDrawableFromTheme$7(emojiThemes, z, motionBackgroundDrawable, patternColor, (Pair) obj);
                }

                public void onError(TLRPC.TL_error tL_error) {
                    ResultCallback.-CC.$default$onError(this, tL_error);
                }
            });
            return motionBackgroundDrawable;
        }

        private void initDrawables() {
            Drawable messageDrawable;
            int themeDrawableColorKey;
            for (Map.Entry entry : Theme.getThemeDrawablesMap().entrySet()) {
                String str = (String) entry.getKey();
                str.hashCode();
                switch (str) {
                    case "drawableMsgIn":
                        messageDrawable = new Theme.MessageDrawable(0, false, false, this);
                        break;
                    case "drawableMsgInMedia":
                        messageDrawable = new Theme.MessageDrawable(1, false, false, this);
                        break;
                    case "drawableMsgInMediaSelected":
                        messageDrawable = new Theme.MessageDrawable(1, false, true, this);
                        break;
                    case "drawableMsgOutMedia":
                        messageDrawable = new Theme.MessageDrawable(1, true, false, this);
                        break;
                    case "drawableMsgOutSelected":
                        messageDrawable = new Theme.MessageDrawable(0, true, true, this);
                        break;
                    case "drawableMsgOutMediaSelected":
                        messageDrawable = new Theme.MessageDrawable(1, true, true, this);
                        break;
                    case "drawableMsgInSelected":
                        messageDrawable = new Theme.MessageDrawable(0, false, true, this);
                        break;
                    case "drawableMsgOut":
                        messageDrawable = new Theme.MessageDrawable(0, true, false, this);
                        break;
                    default:
                        Drawable.ConstantState constantState = ((Drawable) entry.getValue()).getConstantState();
                        messageDrawable = constantState != null ? constantState.newDrawable().mutate() : null;
                        if (messageDrawable != null && (themeDrawableColorKey = Theme.getThemeDrawableColorKey((String) entry.getKey())) >= 0) {
                            Theme.setDrawableColor(messageDrawable, getColor(themeDrawableColorKey));
                            break;
                        }
                        break;
                }
                if (messageDrawable != null) {
                    this.currentDrawables.put((String) entry.getKey(), messageDrawable);
                }
            }
        }

        private void initPaints() {
            Paint paint;
            for (Map.Entry entry : Theme.getThemePaintsMap().entrySet()) {
                Paint paint2 = (Paint) entry.getValue();
                if (paint2 instanceof TextPaint) {
                    paint = new TextPaint();
                    paint.setTextSize(paint2.getTextSize());
                    paint.setTypeface(paint2.getTypeface());
                } else {
                    paint = new Paint();
                }
                if ((paint2.getFlags() & 1) != 0) {
                    paint.setFlags(1);
                }
                int themePaintColorKey = Theme.getThemePaintColorKey((String) entry.getKey());
                if (themePaintColorKey >= 0 && !"paintChatActionBackgroundDarken".equals(entry.getKey())) {
                    paint.setColor(getColor(themePaintColorKey));
                }
                this.currentPaints.put((String) entry.getKey(), paint);
            }
        }

        private void initServiceMessageColors(android.graphics.drawable.Drawable r23) {
            throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.ThemeDelegate.initServiceMessageColors(android.graphics.drawable.Drawable):void");
        }

        public static void lambda$getBackgroundDrawableFromTheme$6(MotionBackgroundDrawable motionBackgroundDrawable, ValueAnimator valueAnimator) {
            motionBackgroundDrawable.setPatternAlpha(((Float) valueAnimator.getAnimatedValue()).floatValue());
        }

        public void lambda$getBackgroundDrawableFromTheme$7(EmojiThemes emojiThemes, boolean z, final MotionBackgroundDrawable motionBackgroundDrawable, int i, Pair pair) {
            if (pair == null) {
                return;
            }
            long longValue = ((Long) pair.first).longValue();
            Bitmap bitmap = (Bitmap) pair.second;
            EmojiThemes emojiThemes2 = this.chatTheme;
            if (emojiThemes2 == null || longValue != emojiThemes2.getTlTheme(this.isDark ? 1 : 0).id || bitmap == null) {
                return;
            }
            ValueAnimator valueAnimator = this.patternIntensityAnimator;
            if (valueAnimator != null) {
                valueAnimator.cancel();
            }
            motionBackgroundDrawable.setPatternBitmap(emojiThemes.getWallpaper(z ? 1 : 0).settings.intensity, bitmap);
            motionBackgroundDrawable.setPatternColorFilter(i);
            ValueAnimator ofFloat = ValueAnimator.ofFloat(0.0f, 1.0f);
            this.patternIntensityAnimator = ofFloat;
            ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public final void onAnimationUpdate(ValueAnimator valueAnimator2) {
                    ChatActivity.ThemeDelegate.lambda$getBackgroundDrawableFromTheme$6(motionBackgroundDrawable, valueAnimator2);
                }
            });
            this.patternIntensityAnimator.setDuration(250L);
            this.patternIntensityAnimator.start();
        }

        public static void lambda$new$0() {
            NotificationCenter globalInstance = NotificationCenter.getGlobalInstance();
            int i = NotificationCenter.didSetNewTheme;
            Boolean bool = Boolean.TRUE;
            globalInstance.postNotificationName(i, new Object[]{Boolean.FALSE, bool, bool});
        }

        public void lambda$setCurrentTheme$1(EmojiThemes emojiThemes, TLRPC.WallPaper wallPaper, boolean z) {
            setupChatTheme(emojiThemes, wallPaper, z, true);
            initServiceMessageColors(this.backgroundDrawable);
            ChatActivityFragmentView chatActivityFragmentView = ChatActivity.this.contentView;
            if (chatActivityFragmentView != null) {
                chatActivityFragmentView.invalidateBackground();
            }
        }

        public void lambda$setCurrentTheme$2() {
            this.animatingColors = new SparseIntArray();
            Theme.MessageDrawable messageDrawable = (Theme.MessageDrawable) ChatActivity.this.getThemedDrawable("drawableMsgOut");
            this.animatingMessageDrawable = messageDrawable;
            messageDrawable.crossfadeFromDrawable = ((BaseFragment) ChatActivity.this).parentLayout.getMessageDrawableOutStart();
            Theme.MessageDrawable messageDrawable2 = (Theme.MessageDrawable) ChatActivity.this.getThemedDrawable("drawableMsgOutMedia");
            this.animatingMessageMediaDrawable = messageDrawable2;
            messageDrawable2.crossfadeFromDrawable = ((BaseFragment) ChatActivity.this).parentLayout.getMessageDrawableOutMediaStart();
            this.animatingMessageDrawable.crossfadeProgress = 0.0f;
            this.animatingMessageMediaDrawable.crossfadeProgress = 0.0f;
            ChatActivity.this.updateMessagesVisiblePart(false);
            updateServiceMessageColor(0.0f);
        }

        public void lambda$setCurrentTheme$3() {
            this.animatingMessageDrawable.crossfadeFromDrawable = null;
            this.animatingMessageMediaDrawable.crossfadeFromDrawable = null;
            this.animatingColors = null;
            updateServiceMessageColor(1.0f);
        }

        public static void lambda$setupChatTheme$4(MotionBackgroundDrawable motionBackgroundDrawable, ValueAnimator valueAnimator) {
            motionBackgroundDrawable.setPatternAlpha(((Float) valueAnimator.getAnimatedValue()).floatValue());
        }

        public static void lambda$setupChatTheme$5(MotionBackgroundDrawable motionBackgroundDrawable, ValueAnimator valueAnimator) {
            motionBackgroundDrawable.setPatternAlpha(((Float) valueAnimator.getAnimatedValue()).floatValue());
        }

        private void setupChatTheme(EmojiThemes emojiThemes, TLRPC.WallPaper wallPaper, boolean z, boolean z2) {
            Theme.ThemeInfo theme;
            Theme.ThemeInfo theme2;
            if (ChatActivity.this.parentThemeDelegate != null) {
                return;
            }
            this.chatTheme = emojiThemes;
            this.wallpaper = wallPaper;
            SizeNotifierFrameLayout sizeNotifierFrameLayout = ((BaseFragment) ChatActivity.this).fragmentView;
            Drawable backgroundImage = sizeNotifierFrameLayout != null ? sizeNotifierFrameLayout.getBackgroundImage() : null;
            final MotionBackgroundDrawable motionBackgroundDrawable = backgroundImage instanceof MotionBackgroundDrawable ? (MotionBackgroundDrawable) backgroundImage : null;
            int phase = motionBackgroundDrawable != null ? motionBackgroundDrawable.getPhase() : 0;
            if ((emojiThemes == null || emojiThemes.showAsDefaultStub) && wallPaper == null) {
                this.currentColor = Theme.getServiceMessageColor();
            }
            String str = "Dark Blue";
            String str2 = "Blue";
            if (emojiThemes == null && wallPaper == null) {
                this.currentColors = new SparseIntArray();
                this.currentPaints.clear();
                this.currentDrawables.clear();
                MotionBackgroundDrawable cachedWallpaperNonBlocking = Theme.getCachedWallpaperNonBlocking();
                if (cachedWallpaperNonBlocking instanceof MotionBackgroundDrawable) {
                    cachedWallpaperNonBlocking.setPhase(phase);
                }
                this.backgroundDrawable = null;
                if (Theme.getActiveTheme().isDark() == this.isDark) {
                    theme2 = Theme.getActiveTheme();
                } else {
                    SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("themeconfig", 0);
                    String string = sharedPreferences.getString("lastDayTheme", "Blue");
                    if (Theme.getTheme(string) != null && !Theme.getTheme(string).isDark()) {
                        str2 = string;
                    }
                    String string2 = sharedPreferences.getString("lastDarkTheme", "Dark Blue");
                    if (Theme.getTheme(string2) != null && Theme.getTheme(string2).isDark()) {
                        str = string2;
                    }
                    theme2 = this.isDark ? Theme.getTheme(str) : Theme.getTheme(str2);
                }
                Theme.applyTheme(theme2, false, this.isDark);
                initServiceMessageColors(this.backgroundDrawable);
                return;
            }
            if (ApplicationLoader.applicationContext != null) {
                Theme.createChatResources(ApplicationLoader.applicationContext, false);
            }
            this.currentColors = emojiThemes == null ? new SparseIntArray() : emojiThemes.createColors(((BaseFragment) ChatActivity.this).currentAccount, this.isDark ? 1 : 0);
            this.backgroundDrawable = !TextUtils.isEmpty(ChatThemeController.getWallpaperEmoticon(this.wallpaper)) ? PreviewView.getBackgroundDrawable(this.backgroundDrawable, ((BaseFragment) ChatActivity.this).currentAccount, this.wallpaper, this.isDark) : wallPaper != null ? ChatBackgroundDrawable.getOrCreate(this.backgroundDrawable, wallPaper, this.isDark) : getBackgroundDrawableFromTheme(emojiThemes, phase);
            AnimatorSet animatorSet = this.patternAlphaAnimator;
            if (animatorSet != null) {
                animatorSet.cancel();
            }
            if (z) {
                this.patternAlphaAnimator = new AnimatorSet();
                if (motionBackgroundDrawable != null) {
                    ValueAnimator ofFloat = ValueAnimator.ofFloat(1.0f, 0.0f);
                    ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                        @Override
                        public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                            ChatActivity.ThemeDelegate.lambda$setupChatTheme$4(motionBackgroundDrawable, valueAnimator);
                        }
                    });
                    ofFloat.addListener(new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationEnd(Animator animator) {
                            super.onAnimationEnd(animator);
                            motionBackgroundDrawable.setPatternAlpha(1.0f);
                        }
                    });
                    ofFloat.setDuration(200L);
                    this.patternAlphaAnimator.playTogether(ofFloat);
                }
                MotionBackgroundDrawable motionBackgroundDrawable2 = this.backgroundDrawable;
                if (motionBackgroundDrawable2 instanceof MotionBackgroundDrawable) {
                    final MotionBackgroundDrawable motionBackgroundDrawable3 = motionBackgroundDrawable2;
                    motionBackgroundDrawable3.setPatternAlpha(0.0f);
                    ValueAnimator ofFloat2 = ValueAnimator.ofFloat(0.0f, 1.0f);
                    ofFloat2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                        @Override
                        public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                            ChatActivity.ThemeDelegate.lambda$setupChatTheme$5(motionBackgroundDrawable3, valueAnimator);
                        }
                    });
                    ofFloat2.addListener(new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationEnd(Animator animator) {
                            super.onAnimationEnd(animator);
                            motionBackgroundDrawable3.setPatternAlpha(1.0f);
                        }
                    });
                    ofFloat2.setDuration(250L);
                    this.patternAlphaAnimator.playTogether(ofFloat2);
                }
                this.patternAlphaAnimator.start();
            }
            if (emojiThemes == null && ChatActivity.this.dialog_id >= 0) {
                if (Theme.getActiveTheme().isDark() == this.isDark) {
                    theme = Theme.getActiveTheme();
                } else {
                    SharedPreferences sharedPreferences2 = ApplicationLoader.applicationContext.getSharedPreferences("themeconfig", 0);
                    String string3 = sharedPreferences2.getString("lastDayTheme", "Blue");
                    if (Theme.getTheme(string3) != null && !Theme.getTheme(string3).isDark()) {
                        str2 = string3;
                    }
                    String string4 = sharedPreferences2.getString("lastDarkTheme", "Dark Blue");
                    if (Theme.getTheme(string4) != null && Theme.getTheme(string4).isDark()) {
                        str = string4;
                    }
                    theme = this.isDark ? Theme.getTheme(str) : Theme.getTheme(str2);
                }
                Theme.applyTheme(theme, false, this.isDark);
            }
            if (z2) {
                this.currentColor = AndroidUtilities.calcDrawableColor(this.backgroundDrawable)[0];
                initDrawables();
                initPaints();
                initServiceMessageColors(this.backgroundDrawable);
                updateServiceMessageColor(1.0f);
            }
        }

        public void updateServiceMessageColor(float f) {
            Bitmap bitmap;
            BitmapShader bitmapShader;
            Bitmap bitmap2;
            if (this.currentPaints.isEmpty()) {
                return;
            }
            Paint paint = getPaint("paintChatActionBackground");
            Paint paint2 = getPaint("paintChatActionBackgroundSelected");
            Paint paint3 = getPaint("paintChatMessageBackgroundSelected");
            int i = this.currentServiceColor;
            int currentColor = this.drawServiceGradient ? -1 : getCurrentColor(Theme.key_chat_serviceText, true);
            int currentColor2 = this.drawServiceGradient ? -1 : getCurrentColor(Theme.key_chat_serviceLink, true);
            int currentColor3 = this.drawServiceGradient ? -1 : getCurrentColor(Theme.key_chat_serviceLink, true);
            int currentColor4 = this.drawServiceGradient ? -1 : getCurrentColor(Theme.key_chat_serviceIcon, true);
            if (f != 1.0f) {
                i = ColorUtils.blendARGB(this.startServiceColor, i, f);
                currentColor = ColorUtils.blendARGB(this.startServiceTextColor, currentColor, f);
                currentColor2 = ColorUtils.blendARGB(this.startServiceLinkColor, currentColor2, f);
                currentColor3 = ColorUtils.blendARGB(this.startServiceButtonColor, currentColor3, f);
                currentColor4 = ColorUtils.blendARGB(this.startServiceIconColor, currentColor4, f);
            }
            if (paint != null && !this.drawServiceGradient) {
                paint.setColor(i);
                paint2.setColor(i);
            }
            this.currentColor = i;
            Paint paint4 = getPaint("paintChatActionText");
            if (paint4 != null) {
                ((TextPaint) paint4).linkColor = currentColor2;
                getPaint("paintChatActionText").setColor(currentColor);
                getPaint("paintChatBotButton").setColor(currentColor3);
            }
            Theme.setDrawableColor(getDrawable("drawableMsgStickerCheck"), currentColor);
            Theme.setDrawableColor(getDrawable("drawableMsgStickerClock"), currentColor);
            Theme.setDrawableColor(getDrawable("drawableMsgStickerHalfCheck"), currentColor);
            Theme.setDrawableColor(getDrawable("drawableMsgStickerPinned"), currentColor);
            Theme.setDrawableColor(getDrawable("drawableMsgStickerReplies"), currentColor);
            Theme.setDrawableColor(getDrawable("drawableMsgStickerViews"), currentColor);
            Theme.setDrawableColor(getDrawable("drawableBotInline"), currentColor4);
            Theme.setDrawableColor(getDrawable("drawableBotLink"), currentColor4);
            Theme.setDrawableColor(getDrawable("drawableBotLock"), currentColor4);
            Theme.setDrawableColor(getDrawable("drawable_botInvite"), currentColor4);
            Theme.setDrawableColor(getDrawable("drawableCommentSticker"), currentColor4);
            Theme.setDrawableColor(getDrawable("drawableGoIcon"), currentColor4);
            Theme.setDrawableColor(getDrawable("drawableReplyIcon"), currentColor4);
            Theme.setDrawableColor(getDrawable("drawableShareIcon"), currentColor4);
            if (this.serviceCanvas == null || (bitmap = this.serviceBitmapSource) == null) {
                return;
            }
            if (f == 1.0f || (bitmap2 = this.startServiceBitmap) == null) {
                this.useSourceShader = true;
                this.src.set(0, 0, bitmap.getWidth(), this.serviceBitmapSource.getHeight());
                this.dst.set(0, 0, this.serviceBitmap.getWidth(), this.serviceBitmap.getHeight());
                this.serviceCanvas.drawBitmap(this.serviceBitmapSource, this.src, this.dst, (Paint) null);
                if (paint != null) {
                    paint.setShader(this.serviceShaderSource);
                    paint2.setShader(this.serviceShaderSource);
                }
                if (paint3 == null) {
                    return;
                } else {
                    bitmapShader = this.serviceShaderSource;
                }
            } else {
                this.useSourceShader = false;
                this.src.set(0, 0, bitmap2.getWidth(), this.startServiceBitmap.getHeight());
                this.dst.set(0, 0, this.serviceBitmap.getWidth(), this.serviceBitmap.getHeight());
                this.serviceCanvas.drawBitmap(this.startServiceBitmap, this.src, this.dst, (Paint) null);
                this.paint.setAlpha((int) (f * 255.0f));
                this.src.set(0, 0, this.serviceBitmapSource.getWidth(), this.serviceBitmapSource.getHeight());
                this.dst.set(0, 0, this.serviceBitmap.getWidth(), this.serviceBitmap.getHeight());
                this.serviceCanvas.drawBitmap(this.serviceBitmapSource, this.src, this.dst, this.paint);
                if (paint != null) {
                    paint.setShader(this.serviceShader);
                    paint2.setShader(this.serviceShader);
                }
                if (paint3 == null) {
                    return;
                } else {
                    bitmapShader = this.serviceShader;
                }
            }
            paint3.setShader(bitmapShader);
        }

        @Override
        public void applyServiceShaderMatrix(int i, int i2, float f, float f2) {
            Bitmap bitmap;
            BitmapShader bitmapShader;
            if (this.backgroundDrawable == null || (bitmap = this.serviceBitmap) == null || (bitmapShader = this.serviceShader) == null) {
                Theme.applyServiceShaderMatrix(i, i2, f, f2);
            } else if (this.useSourceShader) {
                Theme.applyServiceShaderMatrix(this.serviceBitmapSource, this.serviceShaderSource, this.actionMatrix, i, i2, f, f2);
            } else {
                Theme.applyServiceShaderMatrix(bitmap, bitmapShader, this.actionMatrix, i, i2, f, f2);
            }
        }

        @Override
        public ColorFilter getAnimatedEmojiColorFilter() {
            return Theme.ResourcesProvider.CC.$default$getAnimatedEmojiColorFilter(this);
        }

        public List getCachedThemes() {
            return this.cachedThemes;
        }

        @Override
        public int getColor(int i) {
            int indexOfKey;
            int fallbackKey;
            SparseIntArray sparseIntArray;
            SparseIntArray sparseIntArray2 = this.animatingColors;
            if (sparseIntArray2 != null && (indexOfKey = sparseIntArray2.indexOfKey(i)) >= 0) {
                sparseIntArray = this.animatingColors;
            } else {
                if (this.chatTheme == null) {
                    return Theme.getColor(i);
                }
                indexOfKey = this.currentColors.indexOfKey(i);
                if (indexOfKey < 0 && ((fallbackKey = Theme.getFallbackKey(i)) < 0 || (indexOfKey = this.currentColors.indexOfKey(fallbackKey)) < 0)) {
                    return Theme.getColor(i);
                }
                sparseIntArray = this.currentColors;
            }
            return sparseIntArray.valueAt(indexOfKey);
        }

        @Override
        public int getColorOrDefault(int i) {
            return getColor(i);
        }

        @Override
        public int getCurrentColor(int i) {
            return getCurrentColor(i, false);
        }

        public int getCurrentColor(int i, boolean z) {
            int indexOfKey;
            SparseIntArray sparseIntArray;
            SparseIntArray sparseIntArray2;
            if (this.chatTheme == null && this.backgroundDrawable == null) {
                return Theme.getColor(i);
            }
            if (z || (sparseIntArray2 = this.animatingColors) == null || (indexOfKey = sparseIntArray2.indexOfKey(i)) < 0) {
                SparseIntArray sparseIntArray3 = this.currentColors;
                if (sparseIntArray3 == null || (indexOfKey = sparseIntArray3.indexOfKey(i)) < 0) {
                    return Theme.getColor(i);
                }
                sparseIntArray = this.currentColors;
            } else {
                sparseIntArray = this.animatingColors;
            }
            return sparseIntArray.valueAt(indexOfKey);
        }

        public EmojiThemes getCurrentTheme() {
            return this.chatTheme;
        }

        public TLRPC.WallPaper getCurrentWallpaper() {
            return this.wallpaper;
        }

        @Override
        public Drawable getDrawable(String str) {
            if (this.currentDrawables.isEmpty()) {
                return null;
            }
            return (Drawable) this.currentDrawables.get(str);
        }

        @Override
        public Paint getPaint(String str) {
            if (this.chatTheme == null && this.backgroundDrawable == null) {
                return null;
            }
            return (Paint) this.currentPaints.get(str);
        }

        public Drawable getWallpaperDrawable() {
            Drawable drawable = this.backgroundDrawable;
            return drawable != null ? drawable : Theme.getCachedWallpaperNonBlocking();
        }

        @Override
        public boolean hasGradientService() {
            return this.backgroundDrawable != null ? this.serviceShader != null : Theme.hasGradientService();
        }

        @Override
        public boolean isDark() {
            return Theme.ResourcesProvider.CC.$default$isDark(this);
        }

        public boolean isThemeChangeAvailable(boolean z) {
            TLRPC.User user;
            ChatActivity chatActivity = ChatActivity.this;
            return chatActivity.currentEncryptedChat == null && !(z && (chatActivity.currentChat != null || (user = chatActivity.currentUser) == null || user.bot));
        }

        public boolean isWallpaperMotion() {
            if (this.chatTheme != null) {
                return false;
            }
            return Theme.isWallpaperMotion();
        }

        @Override
        public void setAnimatedColor(int i, int i2) {
            SparseIntArray sparseIntArray = this.animatingColors;
            if (sparseIntArray != null) {
                sparseIntArray.put(i, i2);
            }
        }

        public void setCachedThemes(List list) {
            this.cachedThemes = list;
        }

        public void setCurrentTheme(EmojiThemes emojiThemes, TLRPC.WallPaper wallPaper, boolean z, Boolean bool) {
            setCurrentTheme(emojiThemes, wallPaper, z, bool, false);
        }

        public void setCurrentTheme(final EmojiThemes emojiThemes, final TLRPC.WallPaper wallPaper, final boolean z, Boolean bool, boolean z2) {
            if (((BaseFragment) ChatActivity.this).parentLayout == null || ChatActivity.this.parentThemeDelegate != null) {
                return;
            }
            boolean booleanValue = bool != null ? bool.booleanValue() : this.isDark;
            String emoticon = emojiThemes != null ? emojiThemes.getEmoticon() : null;
            EmojiThemes emojiThemes2 = this.chatTheme;
            String emoticon2 = emojiThemes2 != null ? emojiThemes2.getEmoticon() : null;
            TLRPC.WallPaper wallPaper2 = this.wallpaper;
            if (!z2) {
                if (!isThemeChangeAvailable(false)) {
                    return;
                }
                if (TextUtils.equals(emoticon2, emoticon) && this.isDark == booleanValue && ChatThemeController.equals(wallPaper, wallPaper2)) {
                    return;
                }
            }
            this.isDark = booleanValue;
            Theme.ThemeInfo currentNightTheme = booleanValue ? Theme.getCurrentNightTheme() : Theme.getCurrentTheme();
            INavigationLayout.ThemeAnimationSettings themeAnimationSettings = new INavigationLayout.ThemeAnimationSettings(currentNightTheme, currentNightTheme.currentAccentId, currentNightTheme.isDark(), !z);
            if (this.chatTheme == null && this.wallpaper == null) {
                Drawable cachedWallpaperNonBlocking = Theme.getCachedWallpaperNonBlocking();
                this.drawServiceGradient = cachedWallpaperNonBlocking instanceof MotionBackgroundDrawable;
                initServiceMessageColors(cachedWallpaperNonBlocking);
                this.startServiceTextColor = this.drawServiceGradient ? -1 : Theme.getColor(Theme.key_chat_serviceText);
                this.startServiceLinkColor = this.drawServiceGradient ? -1 : Theme.getColor(Theme.key_chat_serviceLink);
                this.startServiceButtonColor = this.drawServiceGradient ? -1 : Theme.getColor(Theme.key_chat_serviceLink);
                this.startServiceIconColor = this.drawServiceGradient ? -1 : Theme.getColor(Theme.key_chat_serviceIcon);
            } else {
                if (this.drawServiceGradient) {
                    MotionBackgroundDrawable motionBackgroundDrawable = this.backgroundDrawable;
                    if (motionBackgroundDrawable instanceof MotionBackgroundDrawable) {
                        this.startServiceBitmap = motionBackgroundDrawable.getBitmap();
                    }
                }
                Drawable drawable = this.backgroundDrawable;
                if (drawable != null) {
                    initServiceMessageColors(drawable);
                }
            }
            this.startServiceColor = this.currentServiceColor;
            this.startServiceTextColor = this.drawServiceGradient ? -1 : getCurrentColor(Theme.key_chat_serviceText, true);
            this.startServiceLinkColor = this.drawServiceGradient ? -1 : getCurrentColor(Theme.key_chat_serviceLink, true);
            this.startServiceButtonColor = this.drawServiceGradient ? -1 : getCurrentColor(Theme.key_chat_serviceLink, true);
            this.startServiceIconColor = this.drawServiceGradient ? -1 : getCurrentColor(Theme.key_chat_serviceIcon, true);
            if (emojiThemes != null || wallPaper != null) {
                this.currentColor = AndroidUtilities.calcDrawableColor(this.backgroundDrawable)[0];
                initDrawables();
                initPaints();
            }
            themeAnimationSettings.applyTheme = false;
            if (ChatActivity.this.dialog_id < 0) {
                themeAnimationSettings.applyTrulyTheme = false;
            }
            themeAnimationSettings.afterStartDescriptionsAddedRunnable = new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.ThemeDelegate.this.lambda$setCurrentTheme$1(emojiThemes, wallPaper, z);
                }
            };
            if (z) {
                themeAnimationSettings.animationProgress = new INavigationLayout.ThemeAnimationSettings.onAnimationProgress() {
                    @Override
                    public void setProgress(float f) {
                        ChatActivity.this.chatListView.invalidate();
                        ThemeDelegate themeDelegate = ThemeDelegate.this;
                        themeDelegate.animatingMessageDrawable.crossfadeProgress = f;
                        themeDelegate.animatingMessageMediaDrawable.crossfadeProgress = f;
                        themeDelegate.updateServiceMessageColor(f);
                    }
                };
                themeAnimationSettings.beforeAnimationRunnable = new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.ThemeDelegate.this.lambda$setCurrentTheme$2();
                    }
                };
                themeAnimationSettings.afterAnimationRunnable = new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.ThemeDelegate.this.lambda$setCurrentTheme$3();
                    }
                };
            } else {
                ChatActivity chatActivity = ChatActivity.this;
                if (chatActivity.contentView != null) {
                    chatActivity.updateBackground();
                }
                themeAnimationSettings.afterStartDescriptionsAddedRunnable.run();
            }
            themeAnimationSettings.onlyTopFragment = true;
            themeAnimationSettings.resourcesProvider = this;
            themeAnimationSettings.duration = 250L;
            ((BaseFragment) ChatActivity.this).parentLayout.animateThemedValues(themeAnimationSettings, null);
            Runnable runnable = ChatActivity.this.onThemeChange;
            if (runnable != null) {
                runnable.run();
            }
        }
    }

    private class TrackingWidthSimpleTextView extends SimpleTextView {
        private boolean trackWidth;

        public TrackingWidthSimpleTextView(Context context) {
            super(context);
            this.trackWidth = true;
        }

        @Override
        protected boolean createLayout(int i) {
            boolean createLayout = super.createLayout(i);
            if (this.trackWidth && getVisibility() == 0) {
                ChatActivity.this.pinnedCounterTextViewX = getTextWidth() + AndroidUtilities.dp(4.0f);
                if (ChatActivity.this.pinnedCounterTextView != null) {
                    ChatActivity.this.pinnedCounterTextView.setTranslationX(ChatActivity.this.getSideMenuWidth() + ChatActivity.this.pinnedCounterTextViewX);
                }
            }
            return createLayout;
        }

        public boolean getTrackWidth() {
            return this.trackWidth;
        }

        public void setTrackWidth(boolean z) {
            this.trackWidth = z;
        }
    }

    public ChatActivity(Bundle bundle) {
        super(bundle);
        this.shareAlertDebugMode = 0;
        this.justCreatedTopic = false;
        this.justCreatedChat = false;
        this.alreadyPlayedStickers = new HashMap();
        this.actionModeViews = new ArrayList();
        this.pinnedMessageImageView = new BackupImageView[2];
        this.pinnedNameTextView = new TrackingWidthSimpleTextView[2];
        this.pinnedMessageTextView = new SimpleTextView[2];
        this.pinnedMessageButton = new PinnedMessageButton[2];
        this.pinnedNextAnimation = new AnimatorSet[2];
        this.pinnedMessageButtonShown = false;
        this.searchContainerHeight = 51;
        this.hideDateDelay = 500;
        this.businessLink = null;
        this.scheduledMessagesCount = -1;
        this.threadMessageVisible = true;
        this.pendingSendMessagesDict = new SparseArray();
        this.pendingSendMessages = new ArrayList();
        this.animatingMessageObjects = new ArrayList();
        this.animatingDocuments = new HashMap();
        this.scrollToPositionOnRecreate = -1;
        this.scrollToOffsetOnRecreate = 0;
        this.pollsToCheck = new ArrayList(10);
        this.pinnedMessageIds = new ArrayList();
        this.pinnedMessageObjects = new HashMap();
        this.loadingPinnedMessages = new SparseArray();
        this.currentPinnedMessageIndex = new int[1];
        this.dateObjectsStableIds = new SparseIntArray();
        this.conversionObjectsStableIds = new SparseIntArray();
        this.allowStickersPanel = true;
        this.allowContextBotPanelSecond = true;
        this.runningAnimationIndex = -1;
        this.paused = true;
        this.firstOpen = true;
        this.clearingHistoryArr = new LongSparseIntArray();
        this.lastLoadIndex = 1;
        this.selectedMessagesIds = new SparseArray[]{new SparseArray(), new SparseArray()};
        this.selectedMessagesCanCopyIds = new SparseArray[]{new SparseArray(), new SparseArray()};
        this.selectedMessagesCanStarIds = new SparseArray[]{new SparseArray(), new SparseArray()};
        this.waitingForLoad = new ArrayList();
        this.needRemovePreviousSameChatActivity = true;
        this.prevSetUnreadCount = Integer.MIN_VALUE;
        this.animateSendingViews = new ArrayList();
        this.messagesDict = new SparseArray[]{new SparseArray(), new SparseArray()};
        this.repliesMessagesDict = new SparseArray();
        this.replyMessageOwners = new SparseArray();
        this.messagesByDays = new HashMap();
        this.messagesByDaysSorted = new SparseArray();
        this.conversionMessages = new LongSparseArray();
        this.messages = new ArrayList();
        this.waitingForReplies = new SparseArray();
        this.polls = new LongSparseArray();
        this.groupedMessagesMap = new LongSparseArray();
        this.maxMessageId = new int[]{Integer.MAX_VALUE, Integer.MAX_VALUE};
        this.minMessageId = new int[]{Integer.MIN_VALUE, Integer.MIN_VALUE};
        this.maxDate = new int[]{Integer.MIN_VALUE, Integer.MIN_VALUE};
        this.minDate = new int[2];
        this.endReached = new boolean[2];
        this.cacheEndReached = new boolean[2];
        this.forwardEndReached = new boolean[]{true, true};
        this.loading = true;
        this.firstLoading = true;
        this.last_message_id = 0;
        this.messageSkeletons = new ArrayList();
        this.skeletonPaint = new Paint(1);
        this.skeletonServicePaint = new Paint(1);
        this.skeletonColorMatrix = new ColorMatrix();
        this.skeletonBackgroundCacheParams = new Theme.MessageDrawable.PathDrawParams();
        this.skeletonBackgroundDrawable = new Theme.MessageDrawable(0, false, false, new Theme.ResourcesProvider() {
            @Override
            public void applyServiceShaderMatrix(int i, int i2, float f, float f2) {
                Theme.applyServiceShaderMatrix(i, i2, f, f2);
            }

            @Override
            public ColorFilter getAnimatedEmojiColorFilter() {
                return Theme.ResourcesProvider.CC.$default$getAnimatedEmojiColorFilter(this);
            }

            @Override
            public int getColor(int i) {
                return ChatActivity.this.getThemedColor(i);
            }

            @Override
            public int getColorOrDefault(int i) {
                return getColor(i);
            }

            @Override
            public int getCurrentColor(int i) {
                int color;
                color = getColor(i);
                return color;
            }

            @Override
            public Drawable getDrawable(String str) {
                return Theme.ResourcesProvider.CC.$default$getDrawable(this, str);
            }

            @Override
            public Paint getPaint(String str) {
                return Theme.ResourcesProvider.CC.$default$getPaint(this, str);
            }

            @Override
            public boolean hasGradientService() {
                return Theme.ResourcesProvider.CC.$default$hasGradientService(this);
            }

            @Override
            public boolean isDark() {
                return Theme.ResourcesProvider.CC.$default$isDark(this);
            }

            @Override
            public void setAnimatedColor(int i, int i2) {
                Theme.ResourcesProvider.CC.$default$setAnimatedColor(this, i, i2);
            }
        });
        this.skeletonMatrix = new Matrix();
        this.skeletonOutlinePaint = new Paint(1);
        this.skeletonOutlineMatrix = new Matrix();
        this.clearOnLoadAndScrollMessageId = -1;
        this.skeletonOutlinePaint.setStyle(Paint.Style.STROKE);
        this.skeletonOutlinePaint.setStrokeWidth(AndroidUtilities.dp(1.0f));
        this.startLoadFromMessageOffset = Integer.MAX_VALUE;
        this.startFromVideoTimestamp = -1;
        this.first = true;
        this.highlightMessageId = Integer.MAX_VALUE;
        this.highlightMessageQuoteOffset = -1;
        this.scrollToMessagePosition = -10000;
        this.botInfo = new LongSparseArray();
        this.destroyTextureViewRunnable = new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$new$0();
            }
        };
        this.actionBarBackgroundPaint = new Paint(1);
        this.scrimPaintAlpha = 0.0f;
        this.scrimViewAlpha = 1.0f;
        this.scrimViewProgress = 0.0f;
        this.popupAnimationIndex = -1;
        this.scrimPopupWindowHideDimOnDismiss = true;
        this.updateDeleteItemRunnable = new Runnable() {
            @Override
            public void run() {
                if (ChatActivity.this.selectedObject == null || ChatActivity.this.menuDeleteItem == null) {
                    return;
                }
                int max = Math.max(0, ChatActivity.this.selectedObject.messageOwner.ttl_period - (ChatActivity.this.getConnectionsManager().getCurrentTime() - ChatActivity.this.selectedObject.messageOwner.date));
                ChatActivity.this.menuDeleteItem.setSubtext(LocaleController.formatString(R.string.AutoDeleteIn, new Object[]{max < 86400 ? AndroidUtilities.formatDuration(max, false, true) : LocaleController.formatPluralString("Days", Math.round(max / 86400.0f), new Object[0])}));
                AndroidUtilities.runOnUIThread(ChatActivity.this.updateDeleteItemRunnable, 1000L);
            }
        };
        this.swipeBackEnabled = true;
        this.fragmentTransitionRunnable = new Runnable() {
            @Override
            public void run() {
                if (ChatActivity.this.fragmentTransition == null || ChatActivity.this.fragmentTransition.isRunning()) {
                    return;
                }
                ChatActivity.this.fragmentTransition.start();
            }
        };
        this.chatMessagesMetadataController = new ChatMessagesMetadataController(this);
        this.postponedScrollCancelListener = new DialogInterface.OnCancelListener() {
            @Override
            public final void onCancel(DialogInterface dialogInterface) {
                ChatActivity.this.lambda$new$1(dialogInterface);
            }
        };
        this.postponeNotificationsWhileLoadingCallback = new NotificationCenter.PostponeNotificationCallback() {
            public boolean needPostpone(int i, int i2, Object[] objArr) {
                if (i == NotificationCenter.didReceiveNewMessages) {
                    long longValue = ((Long) objArr[0]).longValue();
                    if (ChatActivity.this.firstLoading && longValue == ChatActivity.this.dialog_id) {
                        return true;
                    }
                }
                return false;
            }
        };
        this.fixedKeyboardHeight = -1;
        this.pulled = false;
        this.photoViewerProvider = new PhotoViewer.EmptyPhotoViewerProvider() {
            @Override
            public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int i, boolean z, boolean z2) {
                return ChatActivity.this.getPlaceForPhoto(messageObject, fileLocation, i, z, false);
            }
        };
        this.photoViewerPaidMediaProvider = new PhotoViewer.EmptyPhotoViewerProvider() {
            @Override
            public boolean forceAllInGroup() {
                return true;
            }

            @Override
            public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int i, boolean z, boolean z2) {
                return ChatActivity.this.getPlaceForPhoto(messageObject, fileLocation, i, z, false);
            }
        };
        this.botContextProvider = new PhotoViewer.EmptyPhotoViewerProvider() {
            @Override
            public org.telegram.ui.PhotoViewer.PlaceProviderObject getPlaceForPhoto(org.telegram.messenger.MessageObject r4, org.telegram.tgnet.TLRPC.FileLocation r5, int r6, boolean r7, boolean r8) {
                throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.AnonymousClass9.getPlaceForPhoto(org.telegram.messenger.MessageObject, org.telegram.tgnet.TLRPC$FileLocation, int, boolean, boolean):org.telegram.ui.PhotoViewer$PlaceProviderObject");
            }

            @Override
            public void sendButtonPressed(int i, VideoEditedInfo videoEditedInfo, boolean z, int i2, boolean z2) {
                if (i < 0 || i >= ChatActivity.this.botContextResults.size()) {
                    return;
                }
                ChatActivity chatActivity = ChatActivity.this;
                chatActivity.sendBotInlineResult((TLRPC.BotInlineResult) chatActivity.botContextResults.get(i), z, i2, 0L);
            }
        };
        this.onItemLongClickListener = new RecyclerListView.OnItemLongClickListenerExtended() {
            public boolean onItemClick(android.view.View r12, int r13, float r14, float r15) {
                throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.AnonymousClass10.onItemClick(android.view.View, int, float, float):boolean");
            }

            public void onLongClickRelease() {
                RecyclerListView.OnItemLongClickListenerExtended.-CC.$default$onLongClickRelease(this);
            }

            public void onMove(float f, float f2) {
                RecyclerListView.OnItemLongClickListenerExtended.-CC.$default$onMove(this, f, f2);
            }
        };
        this.onItemClickListener = new AnonymousClass12();
        this.chatScrollHelperCallback = new ChatScrollCallback();
        this.showScheduledOrNoSoundRunnable = new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$new$7();
            }
        };
        this.showScheduledHintRunnable = new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$new$8();
            }
        };
        this.filledEditTextItemMenu = false;
        this.checkTranslationRunnable = new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$new$194();
            }
        };
        this.preventReopenSearchWithText = false;
    }

    public static void access$11300(ChatActivity chatActivity, int i) {
        chatActivity.processSelectedOption(i);
    }

    static float access$15416(ChatActivity chatActivity, float f) {
        float f2 = chatActivity.pullingDownOffset + f;
        chatActivity.pullingDownOffset = f2;
        return f2;
    }

    static int access$18316(ChatActivity chatActivity, float f) {
        int i = (int) (chatActivity.skeletonTotalTranslation + f);
        chatActivity.skeletonTotalTranslation = i;
        return i;
    }

    public static void access$23700(ChatActivity chatActivity) {
        chatActivity.checkBotMessageHint();
    }

    public static void access$23800(ChatActivity chatActivity) {
        chatActivity.checkSavedMessagesTagHint();
    }

    static int access$24510(ChatActivity chatActivity) {
        int i = chatActivity.newMentionsCount;
        chatActivity.newMentionsCount = i - 1;
        return i;
    }

    static int access$25608(ChatActivity chatActivity) {
        int i = chatActivity.lastLoadIndex;
        chatActivity.lastLoadIndex = i + 1;
        return i;
    }

    static int access$3408(ChatActivity chatActivity) {
        int i = chatActivity.scheduledMessagesCount;
        chatActivity.scheduledMessagesCount = i + 1;
        return i;
    }

    static int access$3412(ChatActivity chatActivity, int i) {
        int i2 = chatActivity.scheduledMessagesCount + i;
        chatActivity.scheduledMessagesCount = i2;
        return i2;
    }

    static int access$35804(ChatActivity chatActivity) {
        int i = chatActivity.pinBullerinTag + 1;
        chatActivity.pinBullerinTag = i;
        return i;
    }

    public static void access$54900(ChatActivity chatActivity) {
        chatActivity.resetProgressDialogLoading();
    }

    private void addReplyMessageOwner(MessageObject messageObject, Integer num) {
        MessageObject messageObject2 = messageObject.replyMessageObject;
        if (messageObject2 == null) {
            return;
        }
        int id = messageObject2.getId();
        ArrayList arrayList = (ArrayList) this.replyMessageOwners.get(id);
        if (arrayList == null) {
            arrayList = new ArrayList();
            this.replyMessageOwners.put(id, arrayList);
        }
        int id2 = messageObject.getId();
        if (!arrayList.contains(Integer.valueOf(id2))) {
            arrayList.add(Integer.valueOf(id2));
        }
        if (num.intValue() != 0) {
            arrayList.remove(num);
        }
    }

    private void addSponsoredMessages(boolean r8) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.addSponsoredMessages(boolean):void");
    }

    private void addToPolls(MessageObject messageObject, MessageObject messageObject2) {
        long pollId = messageObject.getPollId();
        if (pollId != 0) {
            ArrayList arrayList = (ArrayList) this.polls.get(pollId);
            if (arrayList == null) {
                arrayList = new ArrayList();
                this.polls.put(pollId, arrayList);
            }
            arrayList.add(messageObject);
            if (messageObject2 != null) {
                arrayList.remove(messageObject2);
            }
        }
    }

    private void addToPulledDialogs(TLRPC.Chat chat, TLRPC.TL_forumTopic tL_forumTopic, long j, int i, int i2) {
        if (getParentLayout() == null) {
            return;
        }
        BackButtonMenu.addToPulledDialogs(this, getParentLayout().getFragmentStack().indexOf(this), chat, (TLRPC.User) null, tL_forumTopic, j, i, i2);
    }

    private void addToPulledDialogsMyself() {
        if (getParentLayout() == null) {
            return;
        }
        BackButtonMenu.addToPulledDialogs(this, getParentLayout().getFragmentStack().indexOf(this), this.currentChat, this.currentUser, (TLRPC.TL_forumTopic) null, this.dialog_id, this.dialogFilterId, this.dialogFolderId);
    }

    private void addToPulledTopicsMyself() {
        if (getParentLayout() == null) {
            return;
        }
        BackButtonMenu.addToPulledDialogs(this, getParentLayout().getFragmentStack().indexOf(this), this.currentChat, this.currentUser, this.forumTopic, this.dialog_id, this.dialogFilterId, this.dialogFolderId);
    }

    public void addToSelectedMessages(MessageObject messageObject, boolean z) {
        addToSelectedMessages(messageObject, z, true);
    }

    private void addToSelectedMessages(org.telegram.messenger.MessageObject r30, boolean r31, boolean r32) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.addToSelectedMessages(org.telegram.messenger.MessageObject, boolean, boolean):void");
    }

    public void afterMessageSend() {
        this.messageSuggestionParams = null;
        if (this.threadMessageId == 0 || this.isTopic) {
            if (this.isTopic) {
                this.replyingMessageObject = this.threadMessageObject;
            } else {
                this.replyingMessageObject = null;
            }
            this.replyingQuote = null;
            this.chatActivityEnterView.setReplyingMessageObject((MessageObject) null, (ReplyQuote) null);
        }
        hideFieldPanel(false);
        if (this.chatMode == 0) {
            getMediaDataController().cleanDraft(this.dialog_id, this.threadMessageId, true);
        }
    }

    public void alertUserOpenError(MessageObject messageObject) {
        if (getParentActivity() == null) {
            return;
        }
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity(), this.themeDelegate);
        builder.setTitle(LocaleController.getString(R.string.AppName));
        builder.setPositiveButton(LocaleController.getString(R.string.OK), null);
        builder.setMessage(messageObject.type == 3 ? LocaleController.getString(R.string.NoPlayerInstalled) : LocaleController.formatString("NoHandleAppInstalled", R.string.NoHandleAppInstalled, new Object[]{messageObject.getDocument().mime_type}));
        showDialog(builder.create());
    }

    public void animateToNextChat() {
        ChatPullingDownDrawable chatPullingDownDrawable = this.pullingDownDrawable;
        if (chatPullingDownDrawable == null) {
            return;
        }
        if (this.isTopic) {
            if (chatPullingDownDrawable.getTopic() != null) {
                addToPulledTopicsMyself();
                addToPulledDialogs(this.currentChat, this.pullingDownDrawable.nextTopic, this.dialog_id, this.dialogFolderId, this.dialogFilterId);
                Bundle bundle = new Bundle();
                bundle.putInt("dialog_folder_id", this.pullingDownDrawable.dialogFolderId);
                bundle.putInt("dialog_filter_id", this.pullingDownDrawable.dialogFilterId);
                bundle.putBoolean("pulled", true);
                ChatActivity chatActivityForTopic = ForumUtilities.getChatActivityForTopic(this, -this.dialog_id, this.pullingDownDrawable.getTopic(), 0, bundle);
                chatActivityForTopic.setPullingDownTransition(true);
                replacingChatActivity = true;
                presentFragment(chatActivityForTopic, true);
                return;
            }
            return;
        }
        if (chatPullingDownDrawable.getChatId() != 0) {
            addToPulledDialogsMyself();
            ChatPullingDownDrawable chatPullingDownDrawable2 = this.pullingDownDrawable;
            addToPulledDialogs(chatPullingDownDrawable2.nextChat, null, chatPullingDownDrawable2.nextDialogId, chatPullingDownDrawable2.dialogFolderId, chatPullingDownDrawable2.dialogFilterId);
            Bundle bundle2 = new Bundle();
            bundle2.putLong("chat_id", this.pullingDownDrawable.getChatId());
            bundle2.putInt("dialog_folder_id", this.pullingDownDrawable.dialogFolderId);
            bundle2.putInt("dialog_filter_id", this.pullingDownDrawable.dialogFilterId);
            bundle2.putBoolean("pulled", true);
            MessagesController.getNotificationsSettings(((BaseFragment) this).currentAccount).edit().remove("diditem" + this.pullingDownDrawable.nextDialogId).apply();
            ChatActivity chatActivity = new ChatActivity(bundle2);
            ArrayList arrayList = this.nextChannels;
            if (arrayList != null && arrayList.size() > 1) {
                ArrayList arrayList2 = this.nextChannels;
                chatActivity.setNextChannels(new ArrayList(arrayList2.subList(1, arrayList2.size())));
            }
            chatActivity.setPullingDownTransition(true);
            replacingChatActivity = true;
            presentFragment(chatActivity, true);
        }
    }

    private String callLink(MessageObject messageObject) {
        TLRPC.Message message;
        TLRPC.MessageMedia messageMedia;
        TLRPC.WebPage webPage;
        if (messageObject == null || (message = messageObject.messageOwner) == null || (messageMedia = message.media) == null || (webPage = messageMedia.webpage) == null || !"telegram_call".equalsIgnoreCase(webPage.type)) {
            return null;
        }
        return messageObject.messageOwner.media.webpage.display_url;
    }

    private boolean canSendMessageToGeneralTopic() {
        if (this.chatMode == 8 || !isForumInViewAsMessagesMode() || this.currentChat == null) {
            return false;
        }
        return canSendMessageToTopic(getMessagesController().getTopicsController().findTopic(this.currentChat.id, 1L));
    }

    public boolean canSendMessageToTopic(MessageObject messageObject) {
        if (this.chatMode == 8) {
            return true;
        }
        if (messageObject == null || !ChatObject.isForum(this.currentChat)) {
            return false;
        }
        return canSendMessageToTopic(getMessagesController().getTopicsController().findTopic(this.currentChat.id, MessageObject.getTopicId(((BaseFragment) this).currentAccount, messageObject.messageOwner, true)));
    }

    private boolean canSendMessageToTopic(TLRPC.TL_forumTopic tL_forumTopic) {
        if (this.chatMode == 8) {
            return true;
        }
        return tL_forumTopic != null && (!tL_forumTopic.closed || ChatObject.canManageTopic(((BaseFragment) this).currentAccount, this.currentChat, tL_forumTopic));
    }

    private void cancelSearchLinks() {
        if (this.linkSearchRequestId != 0) {
            getConnectionsManager().cancelRequest(this.linkSearchRequestId, true);
        }
    }

    private void checkActionBarMenu(boolean z) {
        TLRPC.User user;
        TLRPC.UserFull userFull;
        TLRPC.ChatFull chatFull;
        TLRPC.ChatFull chatFull2;
        ChatAvatarContainer chatAvatarContainer;
        int i;
        TLRPC.EncryptedChat encryptedChat = this.currentEncryptedChat;
        if ((encryptedChat == null || (encryptedChat instanceof TLRPC.TL_encryptedChat)) && ((this.currentChat == null || (this.chatMode == 0 && this.threadMessageId == 0 && (chatFull = this.chatInfo) != null && chatFull.ttl_period != 0)) && ((user = this.currentUser) == null || !(UserObject.isDeleted(user) || (this.currentEncryptedChat == null && ((userFull = this.userInfo) == null || userFull.ttl_period == 0)))))) {
            ActionBarMenuItem.Item item = this.timeItem2;
            if (item != null) {
                item.setVisibility(0);
            }
            ChatAvatarContainer chatAvatarContainer2 = this.avatarContainer;
            if (chatAvatarContainer2 != null) {
                chatAvatarContainer2.showTimeItem(z);
            }
        } else {
            ActionBarMenuItem.Item item2 = this.timeItem2;
            if (item2 != null) {
                item2.setVisibility(8);
            }
            ChatAvatarContainer chatAvatarContainer3 = this.avatarContainer;
            if (chatAvatarContainer3 != null) {
                chatAvatarContainer3.hideTimeItem(z);
            }
        }
        ActionBarMenuItem.Item item3 = this.viewAsTopics;
        if (item3 != null) {
            TLRPC.Chat chat = this.currentChat;
            item3.setVisibility((chat == null || !chat.forum) ? 8 : 0);
        }
        ChatAvatarContainer chatAvatarContainer4 = this.avatarContainer;
        boolean z2 = true;
        if (chatAvatarContainer4 != null) {
            TLRPC.Chat chat2 = this.currentChat;
            chatAvatarContainer4.setStars((chat2 == null || (chat2.flags2 & 2048) == 0) ? false : true, z);
            TLRPC.EncryptedChat encryptedChat2 = this.currentEncryptedChat;
            if (encryptedChat2 != null) {
                chatAvatarContainer = this.avatarContainer;
                i = encryptedChat2.ttl;
            } else {
                TLRPC.UserFull userFull2 = this.userInfo;
                if (userFull2 != null) {
                    chatAvatarContainer = this.avatarContainer;
                    i = userFull2.ttl_period;
                } else {
                    TLRPC.ChatFull chatFull3 = this.chatInfo;
                    if (chatFull3 != null) {
                        chatAvatarContainer = this.avatarContainer;
                        i = chatFull3.ttl_period;
                    }
                }
            }
            chatAvatarContainer.setTime(i, z);
        }
        if (this.clearHistoryItem != null && (chatFull2 = this.chatInfo) != null) {
            if (!chatFull2.can_delete_channel && ChatObject.isChannel(this.currentChat)) {
                TLRPC.Chat chat3 = this.currentChat;
                if (!chat3.megagroup || ChatObject.isPublic(chat3)) {
                    z2 = false;
                }
            }
            this.clearHistoryItem.setVisibility(z2 ? 0 : 8);
        }
        checkAndUpdateAvatar();
    }

    private void checkBotCommands() {
        TLRPC.Chat chat;
        r0 = false;
        r0 = false;
        boolean z = false;
        URLSpanBotCommand.enabled = false;
        TLRPC.User user = this.currentUser;
        if (user == null || !user.bot) {
            TLRPC.ChatFull chatFull = this.chatInfo;
            if (chatFull instanceof TLRPC.TL_chatFull) {
                for (int i = 0; i < this.chatInfo.participants.participants.size(); i++) {
                    TLRPC.User user2 = getMessagesController().getUser(Long.valueOf(((TLRPC.ChatParticipant) this.chatInfo.participants.participants.get(i)).user_id));
                    if (user2 != null && user2.bot) {
                        URLSpanBotCommand.enabled = true;
                        return;
                    }
                }
                return;
            }
            if (!(chatFull instanceof TLRPC.TL_channelFull)) {
                return;
            }
            if (!chatFull.bot_info.isEmpty() && (chat = this.currentChat) != null && chat.megagroup) {
                z = true;
            }
        } else {
            z = !UserObject.isReplyUser(user);
        }
        URLSpanBotCommand.enabled = z;
    }

    private void checkBotKeyboard() {
        MessageObject messageObject;
        StringBuilder sb;
        long j;
        if (this.chatActivityEnterView == null || (messageObject = this.botButtons) == null || this.userBlocked) {
            return;
        }
        if (!(messageObject.messageOwner.reply_markup instanceof TLRPC.TL_replyKeyboardForceReply)) {
            MessageObject messageObject2 = this.replyingMessageObject;
            if (messageObject2 != null && this.botReplyButtons == messageObject2) {
                this.botReplyButtons = null;
                hideFieldPanel(true);
            }
            this.chatActivityEnterView.setButtons(this.botButtons);
            return;
        }
        SharedPreferences mainSettings = MessagesController.getMainSettings(((BaseFragment) this).currentAccount);
        if (this.isTopic) {
            sb = new StringBuilder();
            sb.append(this.dialog_id);
            sb.append("_");
            j = getTopicId();
        } else {
            sb = new StringBuilder();
            sb.append("");
            j = this.dialog_id;
        }
        sb.append(j);
        if (mainSettings.getInt("answered_" + sb.toString(), 0) != this.botButtons.getId()) {
            if (this.replyingMessageObject == null || this.chatActivityEnterView.getFieldText() == null) {
                MessageObject messageObject3 = this.botButtons;
                this.botReplyButtons = messageObject3;
                this.chatActivityEnterView.setButtons(messageObject3);
                showFieldPanelForReply(this.botButtons);
            }
        }
    }

    public void checkBotMessageHint() {
        ChatMessageCell chatMessageCell;
        MessageObject primaryMessageObject;
        TLRPC.Message message;
        if (this.botMessageHint != null) {
            return;
        }
        ChatMessageCell chatMessageCell2 = null;
        for (int childCount = this.chatListView.getChildCount() - 1; childCount >= 0; childCount--) {
            View childAt = this.chatListView.getChildAt(childCount);
            if ((childAt instanceof ChatMessageCell) && (primaryMessageObject = (chatMessageCell = (ChatMessageCell) childAt).getPrimaryMessageObject()) != null && (message = primaryMessageObject.messageOwner) != null && message.via_business_bot_id != 0) {
                chatMessageCell2 = chatMessageCell;
            }
        }
        showBotMessageHint(chatMessageCell2, false);
    }

    private void checkChecksHint() {
        if (getMessagesController().pendingSuggestions.contains("NEWCOMER_TICKS")) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.showChecksHint();
                }
            }, 1000L);
        }
    }

    public void checkConversionDateTimeToast() {
        ChatMessageCell chatMessageCell;
        if (!this.shownConversionDateTimeToast && this.isFullyVisible && this.chatListView.isAttachedToWindow()) {
            int[] iArr = new int[2];
            int childCount = this.chatListView.getChildCount() - 1;
            while (true) {
                if (childCount < 0) {
                    chatMessageCell = null;
                    break;
                }
                View childAt = this.chatListView.getChildAt(childCount);
                if (childAt instanceof ChatMessageCell) {
                    chatMessageCell = (ChatMessageCell) childAt;
                    if (chatMessageCell.getMessageObject() != null && chatMessageCell.getMessageObject().messageOwner != null && chatMessageCell.getMessageObject().messageOwner.video_processing_pending) {
                        if (chatMessageCell.getCurrentPosition() != null) {
                            if (chatMessageCell.getMessageObject() != null && (chatMessageCell.getCurrentPosition().flags & 8) != 0) {
                                if ((chatMessageCell.getCurrentPosition().flags & (chatMessageCell.getMessageObject().isOutOwner() ? 1 : 2)) == 0) {
                                    continue;
                                }
                            }
                        }
                        chatMessageCell.getLocationInWindow(iArr);
                        float timeY = iArr[1] + chatMessageCell.getTimeY();
                        if (timeY >= AndroidUtilities.dp(240.0f) && timeY <= (AndroidUtilities.displaySize.y - AndroidUtilities.dp(25.0f)) - AndroidUtilities.navigationBarHeight) {
                            break;
                        }
                    }
                }
                childCount--;
            }
            if (chatMessageCell == null) {
                AndroidUtilities.cancelRunOnUIThread(new ChatActivity$$ExternalSyntheticLambda96(this));
                AndroidUtilities.runOnUIThread(new ChatActivity$$ExternalSyntheticLambda96(this), 2000L);
                return;
            }
            this.shownConversionDateTimeToast = true;
            HintView2 rounding = new HintView2(getContext(), 3) {
                protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
                    super/*android.view.View*/.onLayout(z, i, i2, i3, i4);
                    setTranslationY(((-getTop()) - AndroidUtilities.dp(120.0f)) + ChatActivity.this.videoConversionTimeHintY);
                }
            }.setMultilineText(true).setTextAlign(Layout.Alignment.ALIGN_CENTER).setDuration(3500L).setHideByTouch(true).useScale(true).setMaxWidth(150.0f).setRounding(8.0f);
            this.videoConversionTimeHint = rounding;
            rounding.setText(LocaleController.getString(R.string.VideoConversionTimeInfo));
            this.contentView.addView(this.videoConversionTimeHint, LayoutHelper.createFrame(-1, 120.0f, 55, 16.0f, 0.0f, 16.0f, 0.0f));
            chatMessageCell.getLocationInWindow(iArr);
            this.videoConversionTimeHintY = iArr[1] + chatMessageCell.getTimeY();
            this.videoConversionTimeHint.setTranslationY(((-r0.getTop()) - AndroidUtilities.dp(120.0f)) + this.videoConversionTimeHintY);
            this.videoConversionTimeHint.setJointPx(0.0f, (-AndroidUtilities.dp(16.0f)) + iArr[0] + chatMessageCell.timeX + (chatMessageCell.timeWidth / 2.0f));
            this.videoConversionTimeHint.show();
        }
    }

    public void checkDispatchHideSkeletons(boolean z) {
        if (this.startMessageAppearTransitionMs == 0) {
            this.startMessageAppearTransitionMs = (!z || this.messageSkeletons.isEmpty()) ? 1L : System.currentTimeMillis();
            isSkeletonVisible();
            RecyclerListView recyclerListView = this.chatListView;
            if (recyclerListView != null) {
                recyclerListView.invalidate();
            }
        }
    }

    public void checkEditTextItemMenu() {
        ActionBarMenu.LazyItem lazyItem;
        if (this.filledEditTextItemMenu || (lazyItem = this.editTextItem) == null) {
            return;
        }
        ActionBarMenuItem createView = lazyItem.createView();
        createView.addSubItem(57, LocaleController.getString(R.string.Spoiler));
        if (this.chatMode == 0) {
            createView.addSubItem(58, LocaleController.getString(R.string.Quote));
        }
        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(LocaleController.getString(R.string.Bold));
        spannableStringBuilder.setSpan(new TypefaceSpan(AndroidUtilities.bold()), 0, spannableStringBuilder.length(), 33);
        createView.addSubItem(50, spannableStringBuilder);
        SpannableStringBuilder spannableStringBuilder2 = new SpannableStringBuilder(LocaleController.getString(R.string.Italic));
        spannableStringBuilder2.setSpan(new TypefaceSpan(AndroidUtilities.getTypeface("fonts/ritalic.ttf")), 0, spannableStringBuilder2.length(), 33);
        createView.addSubItem(51, spannableStringBuilder2);
        SpannableStringBuilder spannableStringBuilder3 = new SpannableStringBuilder(LocaleController.getString(R.string.Mono));
        spannableStringBuilder3.setSpan(new TypefaceSpan(Typeface.MONOSPACE), 0, spannableStringBuilder3.length(), 33);
        createView.addSubItem(52, spannableStringBuilder3);
        TLRPC.EncryptedChat encryptedChat = this.currentEncryptedChat;
        if (encryptedChat == null || AndroidUtilities.getPeerLayerVersion(encryptedChat.layer) >= 101) {
            SpannableStringBuilder spannableStringBuilder4 = new SpannableStringBuilder(LocaleController.getString(R.string.Strike));
            TextStyleSpan.TextStyleRun textStyleRun = new TextStyleSpan.TextStyleRun();
            textStyleRun.flags |= 8;
            spannableStringBuilder4.setSpan(new TextStyleSpan(textStyleRun), 0, spannableStringBuilder4.length(), 33);
            createView.addSubItem(55, spannableStringBuilder4);
            SpannableStringBuilder spannableStringBuilder5 = new SpannableStringBuilder(LocaleController.getString(R.string.Underline));
            TextStyleSpan.TextStyleRun textStyleRun2 = new TextStyleSpan.TextStyleRun();
            textStyleRun2.flags |= 16;
            spannableStringBuilder5.setSpan(new TextStyleSpan(textStyleRun2), 0, spannableStringBuilder5.length(), 33);
            createView.addSubItem(56, spannableStringBuilder5);
        }
        createView.addSubItem(53, LocaleController.getString(R.string.CreateLink));
        createView.addSubItem(54, LocaleController.getString(R.string.Regular));
        this.filledEditTextItemMenu = true;
    }

    public void checkEditTimer() {
        MessageObject editingMessageObject;
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView == null || (editingMessageObject = chatActivityEnterView.getEditingMessageObject()) == null || editingMessageObject.scheduled) {
            return;
        }
        TLRPC.User user = this.currentUser;
        if (user == null || !user.self) {
            int abs = editingMessageObject.canEditMessageAnytime(this.currentChat) ? 360 : (getMessagesController().maxEditTime + 300) - Math.abs(getConnectionsManager().getCurrentTime() - editingMessageObject.messageOwner.date);
            if (abs <= 0) {
                this.chatActivityEnterView.onEditTimeExpired();
                this.replyObjectTextView.setText(LocaleController.formatString("TimeToEditExpired", R.string.TimeToEditExpired, new Object[0]));
            } else {
                if (abs <= 300) {
                    this.replyObjectTextView.setText(LocaleController.formatString("TimeToEdit", R.string.TimeToEdit, new Object[]{AndroidUtilities.formatShortDuration(abs)}));
                }
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.this.checkEditTimer();
                    }
                }, 1000L);
            }
        }
    }

    private void checkGroupCallJoin(boolean z) {
        TLRPC.ChatFull chatFull;
        String str;
        if (this.groupCall != null && (((str = this.voiceChatHash) != null || this.openVideoChat) && this.openAnimationEnded)) {
            VoIPHelper.startCall(this.currentChat, null, str, this.createGroupCall, Boolean.valueOf(!r0.call.rtmp_stream), getParentActivity(), this, getAccountInstance());
            this.voiceChatHash = null;
            this.openVideoChat = false;
            return;
        }
        if (this.voiceChatHash != null && z && (chatFull = this.chatInfo) != null && chatFull.call == null && ((BaseFragment) this).fragmentView != null && getParentActivity() != null) {
            BulletinFactory.of(this).createSimpleBulletin(R.raw.linkbroken, LocaleController.getString(R.string.LinkHashExpired)).show();
            this.voiceChatHash = null;
        }
        this.lastCallCheckFromServer = !this.openAnimationEnded;
    }

    private void checkGroupEmojiPackHint() {
        TLRPC.ChatFull chatFull;
        TLRPC.TL_messages_stickerSet groupStickerSetById;
        if (this.groupEmojiPackHint != null || !ChatObject.isMegagroup(this.currentChat) || (chatFull = getMessagesController().getChatFull(this.currentChat.id)) == null || chatFull.emojiset == null || this.chatActivityEnterView == null || getContext() == null) {
            return;
        }
        BlurredFrameLayout blurredFrameLayout = this.bottomOverlayChat;
        if ((blurredFrameLayout == null || blurredFrameLayout.getVisibility() != 0) && !MessagesController.getGlobalMainSettings().getBoolean("groupEmojiPackHintShown", false)) {
            TLRPC.StickerSet stickerSet = chatFull.emojiset;
            long j = stickerSet.thumb_document_id;
            if (j == 0 && (groupStickerSetById = getMediaDataController().getGroupStickerSetById(stickerSet)) != null && !((TLRPC.messages_StickerSet) groupStickerSetById).documents.isEmpty()) {
                j = ((TLRPC.Document) ((TLRPC.messages_StickerSet) groupStickerSetById).documents.get(0)).id;
            }
            if (j == 0) {
                return;
            }
            MessagesController.getGlobalMainSettings().edit().putBoolean("groupEmojiPackHintShown", true).apply();
            HintView2 hintView2 = new HintView2(getContext(), 3);
            this.groupEmojiPackHint = hintView2;
            hintView2.setCloseButton(true);
            this.groupEmojiPackHint.setMultilineText(true);
            this.groupEmojiPackHint.setTextAlign(Layout.Alignment.ALIGN_CENTER);
            this.groupEmojiPackHint.setRounding(12.0f);
            SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder("d");
            spannableStringBuilder.setSpan(new AnimatedEmojiSpan(j, this.groupEmojiPackHint.getTextPaint().getFontMetricsInt()), 0, spannableStringBuilder.length(), 33);
            SpannableStringBuilder spannableStringBuilder2 = new SpannableStringBuilder(chatFull.emojiset.title);
            spannableStringBuilder2.setSpan(new TypefaceSpan(AndroidUtilities.bold()), 0, spannableStringBuilder2.length(), 34);
            spannableStringBuilder.append((CharSequence) " ");
            spannableStringBuilder.append((CharSequence) spannableStringBuilder2);
            this.groupEmojiPackHint.setText(AndroidUtilities.replaceCharSequence("%s", LocaleController.getString(R.string.GroupEmojiPackHint), spannableStringBuilder));
            HintView2 hintView22 = this.groupEmojiPackHint;
            hintView22.setMaxWidthPx(HintView2.cutInFancyHalf(hintView22.getText(), this.groupEmojiPackHint.getTextPaint()));
            this.groupEmojiPackHint.setDuration(-1L);
            this.groupEmojiPackHint.setPadding(AndroidUtilities.dp(6.0f), 0, AndroidUtilities.dp(6.0f), 0);
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$checkGroupEmojiPackHint$204();
                }
            }, 300L);
        }
    }

    private void checkGroupMessagesOrder() {
        int i;
        if (this.reversed) {
            int i2 = -1;
            long j = 0;
            for (int i3 = 0; i3 < this.messages.size(); i3++) {
                long groupIdForUse = ((MessageObject) this.messages.get(i3)).getGroupIdForUse();
                if (j != groupIdForUse) {
                    if (i2 >= 0 && j != 0 && (i = i3 - i2) > 1) {
                        ArrayList arrayList = new ArrayList();
                        for (int i4 = 0; i4 < i; i4++) {
                            arrayList.add((MessageObject) this.messages.remove(i2));
                        }
                        Collections.sort(arrayList, new Comparator() {
                            @Override
                            public final int compare(Object obj, Object obj2) {
                                int lambda$checkGroupMessagesOrder$395;
                                lambda$checkGroupMessagesOrder$395 = ChatActivity.lambda$checkGroupMessagesOrder$395((MessageObject) obj, (MessageObject) obj2);
                                return lambda$checkGroupMessagesOrder$395;
                            }
                        });
                        this.messages.addAll(i2, arrayList);
                    }
                    i2 = i3;
                    j = groupIdForUse;
                }
            }
            if (i2 < 0 || j == 0 || this.messages.size() - i2 <= 1) {
                return;
            }
            int size = this.messages.size() - i2;
            ArrayList arrayList2 = new ArrayList();
            for (int i5 = 0; i5 < size; i5++) {
                arrayList2.add((MessageObject) this.messages.remove(i2));
            }
            this.messages.addAll(i2, arrayList2);
        }
    }

    public void checkHashtagStories(boolean z) {
        MessagesSearchAdapter messagesSearchAdapter;
        if (this.searchType == 2 && (messagesSearchAdapter = this.messagesSearchAdapter) != null) {
            messagesSearchAdapter.searchStories(this.searchingHashtag, z);
        }
    }

    public void checkInstantCameraView() {
        if (this.instantCameraView != null || getContext() == null) {
            return;
        }
        View view = new InstantCameraView(getContext(), this, this.themeDelegate) {
            protected void clipBlur(Canvas canvas) {
                canvas.clipRect(0, 0, getWidth(), getHeight() - AndroidUtilities.dp(1.5f));
            }
        };
        this.instantCameraView = view;
        this.contentView.addView(view, 21, LayoutHelper.createFrame(-1, -1, 51));
    }

    private void checkInstantSearch() {
        TLRPC.Chat chat;
        long j = getArguments().getInt("search_from_user_id", 0);
        if (j != 0) {
            TLRPC.User user = getMessagesController().getUser(Long.valueOf(j));
            if (user != null) {
                lambda$openSearchWithText$357("");
                ImageView imageView = this.searchUserButton;
                if (imageView != null) {
                    imageView.callOnClick();
                }
                searchUserMessages(user, null);
                return;
            }
            return;
        }
        long j2 = getArguments().getInt("search_from_chat_id", 0);
        if (j2 == 0 || (chat = getMessagesController().getChat(Long.valueOf(j2))) == null) {
            return;
        }
        lambda$openSearchWithText$357("");
        ImageView imageView2 = this.searchUserButton;
        if (imageView2 != null) {
            imageView2.callOnClick();
        }
        searchUserMessages(null, chat);
    }

    private void checkLeaveChannelButton() {
        ActionBarMenuItem actionBarMenuItem;
        int i;
        int i2;
        ActionBarMenuItem actionBarMenuItem2 = this.headerItem;
        if (actionBarMenuItem2 == null || this.chatMode == 3 || actionBarMenuItem2.hasSubItem(16) || this.isTopic) {
            return;
        }
        if (ChatObject.isChannel(this.currentChat)) {
            TLRPC.Chat chat = this.currentChat;
            if (!chat.creator) {
                if (ChatObject.isNotInChat(chat)) {
                    return;
                }
                if (this.currentChat.megagroup) {
                    actionBarMenuItem = this.headerItem;
                    i = R.drawable.msg_leave;
                    i2 = R.string.LeaveMegaMenu;
                } else {
                    actionBarMenuItem = this.headerItem;
                    i = R.drawable.msg_leave;
                    i2 = R.string.LeaveChannelMenu;
                }
                actionBarMenuItem.lazilyAddSubItem(16, i, LocaleController.getString(i2));
            }
        }
        if (ChatObject.isChannel(this.currentChat)) {
            return;
        }
        if (this.currentChat != null) {
            actionBarMenuItem = this.headerItem;
            i = R.drawable.msg_leave;
            i2 = R.string.DeleteAndExit;
        } else {
            TLRPC.User user = this.currentUser;
            if (user != null && user.bot) {
                ActionBarMenuItem.Item lazilyAddSubItem = this.headerItem.lazilyAddSubItem(16, R.drawable.msg_block2, LocaleController.getString(R.string.DeleteAndBlock));
                int i3 = Theme.key_text_RedRegular;
                lazilyAddSubItem.setColors(getThemedColor(i3), getThemedColor(i3));
                return;
            } else {
                actionBarMenuItem = this.headerItem;
                i = R.drawable.msg_delete;
                i2 = R.string.DeleteChatUser;
            }
        }
        actionBarMenuItem.lazilyAddSubItem(16, i, LocaleController.getString(i2));
    }

    private void checkListViewPaddings() {
        MessageObject messageObject;
        if (this.wasManualScroll || (messageObject = this.unreadMessageObject) == null) {
            if (this.checkPaddingsRunnable != null) {
                return;
            }
            Runnable runnable = new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$checkListViewPaddings$248();
                }
            };
            this.checkPaddingsRunnable = runnable;
            AndroidUtilities.runOnUIThread(runnable);
            return;
        }
        if (this.messages.indexOf(messageObject) >= 0) {
            this.fixPaddingsInLayout = true;
            View view = ((BaseFragment) this).fragmentView;
            if (view != null) {
                view.requestLayout();
            }
        }
    }

    private void checkNewMessagesOnQuoteEdit(boolean z) {
        if (this.replyingMessageObject == null) {
            return;
        }
        for (int i = 0; i < this.messages.size(); i++) {
            MessageObject messageObject = (MessageObject) this.messages.get(i);
            if (messageObject != null && messageObject.getId() == this.replyingMessageObject.getId() && messageObject.getDialogId() == this.replyingMessageObject.getDialogId()) {
                this.replyingMessageObject = messageObject;
                ReplyQuote replyQuote = this.replyingQuote;
                if (replyQuote != null) {
                    replyQuote.checkEdit(messageObject);
                }
                if (z) {
                    MessagePreviewParams messagePreviewParams = this.messagePreviewParams;
                    if (messagePreviewParams != null) {
                        MessageObject messageObject2 = this.replyingMessageObject;
                        MessageObject.GroupedMessages groupedMessages = this.replyingQuoteGroup;
                        if (groupedMessages == null) {
                            groupedMessages = getGroup(messageObject2.getGroupId());
                        }
                        messagePreviewParams.updateReply(messageObject2, groupedMessages, this.dialog_id, this.replyingQuote);
                    }
                    fallbackFieldPanel();
                    return;
                }
                return;
            }
        }
    }

    public void checkRaiseSensors() {
        TLRPC.Chat chat;
        BlurredFrameLayout blurredFrameLayout;
        FrameLayout frameLayout;
        BlurredFrameLayout blurredFrameLayout2;
        MediaController mediaController;
        boolean z;
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if ((chatActivityEnterView == null || !chatActivityEnterView.isStickersExpanded()) && (((chat = this.currentChat) == null || ChatObject.canSendVoice(chat)) && !ApplicationLoader.mainInterfacePaused && (((blurredFrameLayout = this.bottomOverlayChat) == null || blurredFrameLayout.getVisibility() != 0) && (((frameLayout = this.bottomOverlay) == null || frameLayout.getVisibility() != 0) && ((blurredFrameLayout2 = this.searchContainer) == null || blurredFrameLayout2.getVisibility() != 0))))) {
            mediaController = MediaController.getInstance();
            z = true;
        } else {
            mediaController = MediaController.getInstance();
            z = false;
        }
        mediaController.setAllowStartRecord(z);
    }

    public void checkSavedMessagesHint() {
        SharedPreferences.Editor edit;
        if (this.checkedSavedMessagesHint) {
            return;
        }
        this.checkedSavedMessagesHint = true;
        if (this.savedMessagesHintShown || this.chatMode != 0 || getMessagesController().getSavedMessagesController().unsupported || getMessagesController().getSavedMessagesController().getAllCount() <= 2) {
            return;
        }
        if (this.savedMessagesHint != null && MessagesController.getGlobalMainSettings().getInt("savedhint", 0) < 1) {
            this.savedMessagesHint.show();
            this.savedMessagesHintShown = true;
            edit = MessagesController.getGlobalMainSettings().edit().putInt("savedhint", MessagesController.getGlobalMainSettings().getInt("savedhint", 0) + 1);
        } else if (this.savedMessagesSearchHint == null || MessagesController.getGlobalMainSettings().getInt("savedsearchhint", 0) >= 1) {
            checkSavedMessagesTagHint();
            return;
        } else {
            this.savedMessagesSearchHint.show();
            this.savedMessagesHintShown = true;
            edit = MessagesController.getGlobalMainSettings().edit();
        }
        edit.putInt("savedsearchhint", MessagesController.getGlobalMainSettings().getInt("savedsearchhint", 0) + 1).apply();
    }

    public void checkSavedMessagesTagHint() {
        ChatMessageCell chatMessageCell;
        HintView2 hintView2 = this.savedMessagesTagHint;
        if (hintView2 == null || hintView2.shown() || this.savedMessagesTagHintShown || !this.checkedSavedMessagesHint || this.savedMessagesTagHint == null) {
            return;
        }
        FrameLayout frameLayout = this.messagesSearchListContainer;
        if ((frameLayout == null || frameLayout.getTag() == null) && System.currentTimeMillis() - this.lastScrollTime > 1800 && MessagesController.getGlobalMainSettings().getInt("savedsearchtaghint", 0) < 1) {
            int[] iArr = new int[2];
            int childCount = this.chatListView.getChildCount() - 1;
            while (true) {
                if (childCount < 0) {
                    chatMessageCell = null;
                    break;
                }
                View childAt = this.chatListView.getChildAt(childCount);
                if (childAt instanceof ChatMessageCell) {
                    chatMessageCell = (ChatMessageCell) childAt;
                    if (chatMessageCell.areTags() && !chatMessageCell.reactionsLayoutInBubble.reactionButtons.isEmpty()) {
                        chatMessageCell.getLocationInWindow(iArr);
                        float f = iArr[1] + chatMessageCell.reactionsLayoutInBubble.y;
                        if (f >= AndroidUtilities.dp(240.0f) && f <= (AndroidUtilities.displaySize.y - AndroidUtilities.dp(25.0f)) - AndroidUtilities.navigationBarHeight) {
                            break;
                        }
                    }
                }
                childCount--;
            }
            if (chatMessageCell == null) {
                AndroidUtilities.cancelRunOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.this.checkSavedMessagesTagHint();
                    }
                });
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.this.checkSavedMessagesTagHint();
                    }
                }, 2000L);
                return;
            }
            this.savedMessagesTagHintShown = true;
            ReactionsLayoutInBubble.ReactionButton reactionButton = (ReactionsLayoutInBubble.ReactionButton) chatMessageCell.reactionsLayoutInBubble.reactionButtons.get(0);
            chatMessageCell.getLocationInWindow(iArr);
            this.savedMessagesTagHint.setTranslationY(((iArr[1] - r6.getTop()) - AndroidUtilities.dp(120.0f)) + chatMessageCell.reactionsLayoutInBubble.y);
            this.savedMessagesTagHint.setJointPx(0.0f, (-AndroidUtilities.dp(16.0f)) + iArr[0] + chatMessageCell.reactionsLayoutInBubble.x + (reactionButton.width / 2.0f));
            this.savedMessagesTagHint.show();
            MessagesController.getGlobalMainSettings().edit().putInt("savedsearchtaghint", 1).apply();
        }
    }

    public void checkScrollForLoad(boolean z) {
        if (this.chatLayoutManager == null || this.paused || this.chatAdapter.isFrozen || this.waitingForGetDifference) {
            return;
        }
        int i = -1;
        final int i2 = -1;
        final int i3 = 0;
        for (int i4 = 0; i4 < this.chatListView.getChildCount(); i4++) {
            RecyclerListView recyclerListView = this.chatListView;
            int childAdapterPosition = recyclerListView.getChildAdapterPosition(recyclerListView.getChildAt(i4));
            if (childAdapterPosition != -1) {
                if (i2 == -1 || childAdapterPosition < i2) {
                    i2 = childAdapterPosition;
                }
                if (i == -1 || childAdapterPosition > i) {
                    i = childAdapterPosition;
                }
                i3++;
            }
        }
        ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
        if (chatActivityAdapter.isFiltered) {
            if (chatActivityAdapter.loadingUpRow < 0 || i2 < 0 || this.chatAdapter.loadingUpRow < i2 || this.chatAdapter.loadingUpRow > i) {
                return;
            }
            getMediaDataController().loadMoreSearchMessages(false);
            return;
        }
        final int itemCount = chatActivityAdapter.getItemCount();
        final int i5 = z ? 25 : 5;
        if (this.chatMode != 7) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$checkScrollForLoad$124(itemCount, i2, i3, i5);
                }
            });
            return;
        }
        if ((itemCount - i2) - i3 > i5 || this.loading || this.endReached[0]) {
            return;
        }
        this.loading = true;
        this.waitingForLoad.add(Integer.valueOf(this.lastLoadIndex));
        HashtagSearchController hashtagSearchController = HashtagSearchController.getInstance(((BaseFragment) this).currentAccount);
        String str = this.searchingHashtag;
        int i6 = ((BaseFragment) this).classGuid;
        int i7 = this.searchType;
        int i8 = this.lastLoadIndex;
        this.lastLoadIndex = i8 + 1;
        hashtagSearchController.searchHashtag(str, i6, i7, i8);
    }

    private void checkSecretMessageForLocation(MessageObject messageObject) {
        if (messageObject.type != 4 || this.locationAlertShown || SharedConfig.isSecretMapPreviewSet()) {
            return;
        }
        this.locationAlertShown = true;
        AlertsCreator.showSecretLocationAlert(getParentActivity(), ((BaseFragment) this).currentAccount, new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$checkSecretMessageForLocation$195();
            }
        }, true, this.themeDelegate);
    }

    public void checkShowBlur(boolean z) {
        MessagePreviewView messagePreviewView;
        BluredView bluredView;
        BluredView bluredView2;
        INavigationLayout iNavigationLayout = ((BaseFragment) this).parentLayout;
        boolean z2 = !(iNavigationLayout == null || !iNavigationLayout.isInPreviewMode() || ((BaseFragment) this).parentLayout.hasIntegratedBlurInPreview() || ((BaseFragment) this).inPreviewMode) || ((messagePreviewView = this.forwardingPreviewView) != null && messagePreviewView.isShowing());
        if (!z2 || ((bluredView2 = this.blurredView) != null && bluredView2.getTag() != null)) {
            if (z2 || (bluredView = this.blurredView) == null || bluredView.getTag() == null) {
                return;
            }
            this.blurredView.animate().setListener(null).cancel();
            this.blurredView.animate().setListener(new HideViewAfterAnimation(this.blurredView)).alpha(0.0f).start();
            this.blurredView.setTag(null);
            this.chatListView.invalidate();
            View view = ((BaseFragment) this).fragmentView;
            if (view != null) {
                view.invalidate();
                return;
            }
            return;
        }
        View view2 = this.blurredView;
        if (view2 == null) {
            View view3 = new BluredView(((BaseFragment) this).fragmentView.getContext(), ((BaseFragment) this).fragmentView, this.themeDelegate) {
                public void setAlpha(float f) {
                    super/*android.view.View*/.setAlpha(f);
                    View view4 = ((BaseFragment) ChatActivity.this).fragmentView;
                    if (view4 != null) {
                        view4.invalidate();
                    }
                }

                public void setVisibility(int i) {
                    super/*android.view.View*/.setVisibility(i);
                    View view4 = ((BaseFragment) ChatActivity.this).fragmentView;
                    if (view4 != null) {
                        view4.invalidate();
                    }
                }
            };
            this.blurredView = view3;
            this.contentView.addView(view3, LayoutHelper.createFrame(-1, -1.0f));
        } else {
            if (this.contentView.indexOfChild(view2) != this.contentView.getChildCount() - 1) {
                this.contentView.removeView(this.blurredView);
                this.contentView.addView(this.blurredView);
            }
            this.blurredView.update();
            this.blurredView.setVisibility(0);
        }
        this.blurredView.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view4) {
                ChatActivity.this.lambda$checkShowBlur$112(view4);
            }
        });
        this.blurredView.setAlpha(0.0f);
        this.blurredView.animate().setListener(null).cancel();
        this.blurredView.animate().alpha(1.0f).setListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animator) {
                ChatActivity chatActivity = ChatActivity.this;
                if (((BaseFragment) chatActivity).fragmentView == null || chatActivity.chatListView == null) {
                    return;
                }
                ChatActivity.this.chatListView.invalidate();
                ((BaseFragment) ChatActivity.this).fragmentView.invalidate();
            }
        }).start();
        this.blurredView.setTag(1);
    }

    private void checkThemeEmoticonOrWallpaper() {
        getNotificationCenter().doOnIdle(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$checkThemeEmoticonOrWallpaper$387();
            }
        });
    }

    public void checkTopUndoView() {
        if (this.topUndoView != null) {
            return;
        }
        View view = new UndoView(getContext(), this, true, this.themeDelegate) {
            public void didPressUrl(CharacterStyle characterStyle) {
                ChatActivity.this.didPressMessageUrl(characterStyle, false, null, null);
            }

            public void showWithAction(long j, int i, Object obj, Object obj2, Runnable runnable, Runnable runnable2) {
                setAdditionalTranslationY((ChatActivity.this.fragmentContextView == null || !ChatActivity.this.fragmentContextView.isCallTypeVisible()) ? 0.0f : AndroidUtilities.dp(ChatActivity.this.fragmentContextView.getStyleHeight()));
                super.showWithAction(j, i, obj, obj2, runnable, runnable2);
            }
        };
        this.topUndoView = view;
        this.contentView.addView(view, 17, LayoutHelper.createFrame(-1, -2.0f, 51, 8.0f, 8.0f, 8.0f, 0.0f));
    }

    public void checkTranslation(boolean z) {
        if (System.currentTimeMillis() - this.lastTranslationCheck > 1000) {
            z = true;
        }
        AndroidUtilities.cancelRunOnUIThread(this.checkTranslationRunnable);
        AndroidUtilities.runOnUIThread(this.checkTranslationRunnable, z ? 0L : 150L);
    }

    private void checkWaitingForReplies() {
        TLRPC.MessageFwdHeader messageFwdHeader;
        int i;
        MessageObject messageObject;
        TLRPC.MessageReplies messageReplies;
        int indexOf;
        if (this.waitingForReplies.size() == 0) {
            return;
        }
        int size = this.waitingForReplies.size();
        ArrayList arrayList = null;
        LongSparseArray longSparseArray = null;
        ArrayList arrayList2 = null;
        for (int i2 = 0; i2 < size; i2++) {
            MessageObject messageObject2 = (MessageObject) this.waitingForReplies.valueAt(i2);
            if (messageObject2.replyMessageObject != null) {
                if (arrayList == null) {
                    arrayList = new ArrayList();
                }
                arrayList.add(Integer.valueOf(this.waitingForReplies.keyAt(i2)));
                if (!(messageObject2.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage) && (messageFwdHeader = messageObject2.replyMessageObject.messageOwner.fwd_from) != null && MessageObject.getPeerId(messageFwdHeader.saved_from_peer) == this.dialog_id && (i = messageObject2.replyMessageObject.messageOwner.fwd_from.channel_post) != 0 && (messageObject = (MessageObject) this.messagesDict[0].get(i)) != null && (messageReplies = messageObject.messageOwner.replies) != null) {
                    messageReplies.replies++;
                    messageObject.animateComments = true;
                    TLRPC.Message message = messageObject2.messageOwner;
                    TLRPC.Peer peer = message.from_id;
                    if (peer == null) {
                        peer = message.peer_id;
                    }
                    int size2 = messageReplies.recent_repliers.size();
                    int i3 = 0;
                    while (true) {
                        if (i3 >= size2) {
                            break;
                        }
                        if (MessageObject.getPeerId((TLRPC.Peer) messageObject.messageOwner.replies.recent_repliers.get(i3)) == MessageObject.getPeerId(peer)) {
                            messageObject.messageOwner.replies.recent_repliers.remove(i3);
                            break;
                        }
                        i3++;
                    }
                    messageObject.messageOwner.replies.recent_repliers.add(0, peer);
                    if (!messageObject2.isOut()) {
                        messageObject.messageOwner.replies.max_id = messageObject2.getId();
                    }
                    MessagesStorage messagesStorage = getMessagesStorage();
                    long j = this.currentChat.id;
                    int id = messageObject.getId();
                    TLRPC.MessageReplies messageReplies2 = messageObject.messageOwner.replies;
                    messagesStorage.updateRepliesCount(j, id, messageReplies2.recent_repliers, messageReplies2.max_id, 1);
                    if (messageObject.hasValidGroupId()) {
                        MessageObject.GroupedMessages groupedMessages = (MessageObject.GroupedMessages) this.groupedMessagesMap.get(messageObject.getGroupId());
                        if (groupedMessages != null) {
                            if (longSparseArray == null) {
                                longSparseArray = new LongSparseArray();
                            }
                            longSparseArray.put(groupedMessages.groupId, groupedMessages);
                            int size3 = groupedMessages.messages.size();
                            for (int i4 = 0; i4 < size3; i4++) {
                                ((MessageObject) groupedMessages.messages.get(i4)).animateComments = true;
                            }
                        }
                    } else if (this.chatAdapter != null && (indexOf = this.messages.indexOf(messageObject)) >= 0) {
                        if (arrayList2 == null) {
                            arrayList2 = new ArrayList();
                        }
                        arrayList2.add(Integer.valueOf(indexOf + this.chatAdapter.messagesStartRow));
                    }
                }
            }
        }
        if (arrayList != null) {
            int size4 = arrayList.size();
            for (int i5 = 0; i5 < size4; i5++) {
                this.waitingForReplies.remove(((Integer) arrayList.get(i5)).intValue());
            }
        }
        if (this.chatAdapter != null) {
            if (longSparseArray != null) {
                int size5 = longSparseArray.size();
                for (int i6 = 0; i6 < size5; i6++) {
                    MessageObject.GroupedMessages groupedMessages2 = (MessageObject.GroupedMessages) longSparseArray.valueAt(i6);
                    ArrayList arrayList3 = groupedMessages2.messages;
                    int indexOf2 = this.messages.indexOf((MessageObject) arrayList3.get(arrayList3.size() - 1));
                    if (indexOf2 >= 0) {
                        ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
                        if (!chatActivityAdapter.isFiltered) {
                            chatActivityAdapter.notifyItemRangeChanged(indexOf2 + chatActivityAdapter.messagesStartRow, groupedMessages2.messages.size());
                        }
                    }
                }
            }
            if (arrayList2 == null || this.chatAdapter.isFiltered) {
                return;
            }
            int size6 = arrayList2.size();
            for (int i7 = 0; i7 < size6; i7++) {
                this.chatAdapter.notifyItemChanged(((Integer) arrayList2.get(i7)).intValue());
            }
        }
    }

    private void clearChatData(boolean z) {
        this.messages.clear();
        this.messagesByDays.clear();
        this.messagesByDaysSorted.clear();
        this.waitingForLoad.clear();
        this.groupedMessagesMap.clear();
        this.threadMessageAdded = false;
        ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
        if (chatActivityAdapter != null) {
            showProgressView(chatActivityAdapter.botInfoRow < 0);
        }
        RecyclerListView recyclerListView = this.chatListView;
        if (recyclerListView != null) {
            recyclerListView.setEmptyView((View) null);
        }
        for (int i = 0; i < 2; i++) {
            this.messagesDict[i].clear();
            if (this.currentEncryptedChat == null) {
                this.maxMessageId[i] = Integer.MAX_VALUE;
                this.minMessageId[i] = Integer.MIN_VALUE;
            } else {
                this.maxMessageId[i] = Integer.MIN_VALUE;
                this.minMessageId[i] = Integer.MAX_VALUE;
            }
            this.maxDate[i] = Integer.MIN_VALUE;
            this.minDate[i] = 0;
            this.endReached[i] = false;
            this.cacheEndReached[i] = false;
            this.forwardEndReached[i] = true;
        }
        if (z) {
            this.first = true;
            this.firstLoading = true;
            this.loading = true;
            this.loadingForward = false;
        }
        this.waitingForReplyMessageLoad = false;
        this.startLoadFromMessageId = 0;
        this.showScrollToMessageError = false;
        this.last_message_id = 0;
        this.unreadMessageObject = null;
        this.createUnreadMessageAfterId = 0;
        this.createUnreadMessageAfterIdLoading = false;
        this.needSelectFromMessageId = false;
        ChatActivityAdapter chatActivityAdapter2 = this.chatAdapter;
        if (chatActivityAdapter2 == null || chatActivityAdapter2.isFiltered) {
            return;
        }
        chatActivityAdapter2.notifyDataSetChanged(false);
    }

    private void clearHistory(boolean z, TLRPC.TL_updates_channelDifferenceTooLong tL_updates_channelDifferenceTooLong) {
        TLRPC.User user;
        if (!z) {
            this.messages.clear();
            this.waitingForLoad.clear();
            this.messagesByDays.clear();
            this.messagesByDaysSorted.clear();
            this.groupedMessagesMap.clear();
            this.threadMessageAdded = false;
            for (int i = 1; i >= 0; i--) {
                this.messagesDict[i].clear();
                if (this.currentEncryptedChat == null) {
                    this.maxMessageId[i] = Integer.MAX_VALUE;
                    this.minMessageId[i] = Integer.MIN_VALUE;
                } else {
                    this.maxMessageId[i] = Integer.MIN_VALUE;
                    this.minMessageId[i] = Integer.MAX_VALUE;
                }
                this.maxDate[i] = Integer.MIN_VALUE;
                this.minDate[i] = 0;
                this.selectedMessagesIds[i].clear();
                this.selectedMessagesCanCopyIds[i].clear();
                this.selectedMessagesCanStarIds[i].clear();
            }
            hideActionMode();
            updatePinnedMessageView(true);
            if (this.botButtons != null) {
                this.botButtons = null;
                ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
                if (chatActivityEnterView != null) {
                    chatActivityEnterView.setButtons((MessageObject) null, false);
                }
            }
            if (this.progressView != null) {
                showProgressView(false);
                createEmptyView(false);
                this.chatListView.setEmptyView(this.emptyViewContainer);
            }
            ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
            if (chatActivityAdapter != null) {
                chatActivityAdapter.notifyDataSetChanged(false);
            }
            if (this.currentEncryptedChat == null && (user = this.currentUser) != null && user.bot && this.botUser == null) {
                this.botUser = "";
                updateBottomOverlay();
                return;
            }
            return;
        }
        if (BuildVars.LOGS_ENABLED) {
            FileLog.d("clear history by overwrite firstLoading=" + this.firstLoading + " minMessage=" + this.minMessageId[0] + " topMessage=" + ((TLRPC.updates_ChannelDifference) tL_updates_channelDifferenceTooLong).dialog.top_message);
        }
        TLRPC.Dialog dialog = ((TLRPC.updates_ChannelDifference) tL_updates_channelDifferenceTooLong).dialog;
        int i2 = dialog.top_message;
        int i3 = this.minMessageId[0];
        if (i2 > i3) {
            this.createUnreadMessageAfterId = Math.max(i3 + 1, dialog.read_inbox_max_id);
        }
        this.forwardEndReached[0] = false;
        this.hideForwardEndReached = false;
        ChatActivityAdapter chatActivityAdapter2 = this.chatAdapter;
        if (chatActivityAdapter2 != null && chatActivityAdapter2.loadingDownRow < 0) {
            this.chatAdapter.notifyItemInserted(0);
        }
        TLRPC.Dialog dialog2 = ((TLRPC.updates_ChannelDifference) tL_updates_channelDifferenceTooLong).dialog;
        int i4 = dialog2.unread_count;
        this.newUnreadMessageCount = i4;
        this.newMentionsCount = dialog2.unread_mentions_count;
        if (this.prevSetUnreadCount != i4) {
            CounterView counterView = this.pagedownButtonCounter;
            if (counterView != null) {
                counterView.setCount(i4, this.openAnimationEnded);
            }
            this.prevSetUnreadCount = this.newUnreadMessageCount;
            updatePagedownButtonVisibility(true);
        }
        int i5 = this.newMentionsCount;
        int i6 = ((TLRPC.updates_ChannelDifference) tL_updates_channelDifferenceTooLong).dialog.unread_mentions_count;
        if (i5 != i6) {
            this.newMentionsCount = i6;
            if (i6 <= 0) {
                this.newMentionsCount = 0;
                this.hasAllMentionsLocal = true;
                showMentionDownButton(false, true);
            } else {
                SimpleTextView simpleTextView = this.mentiondownButtonCounter;
                if (simpleTextView != null) {
                    simpleTextView.setText(String.format("%d", Integer.valueOf(i6)));
                }
                showMentionDownButton(true, true);
            }
        }
        checkScrollForLoad(false);
    }

    public void closeMenu(boolean z) {
        this.scrimPopupWindowHideDimOnDismiss = z;
        ActionBarPopupWindow actionBarPopupWindow = this.scrimPopupWindow;
        if (actionBarPopupWindow != null) {
            actionBarPopupWindow.dismiss();
        }
        if (z) {
            return;
        }
        ValueAnimator valueAnimator = this.scrimViewAlphaAnimator;
        if (valueAnimator != null) {
            valueAnimator.removeAllListeners();
            this.scrimViewAlphaAnimator.cancel();
        }
        ValueAnimator ofFloat = ValueAnimator.ofFloat(1.0f, 0.0f);
        this.scrimViewAlphaAnimator = ofFloat;
        ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public final void onAnimationUpdate(ValueAnimator valueAnimator2) {
                ChatActivity.this.lambda$closeMenu$306(valueAnimator2);
            }
        });
        this.scrimViewAlphaAnimator.setDuration(150L);
        this.scrimViewAlphaAnimator.start();
    }

    private void createActionMode() {
        ArrayList arrayList;
        ActionBarMenuItem addItemWithWidth;
        int i;
        if (this.selectedMessagesCountTextView != null || getContext() == null) {
            return;
        }
        ActionBarMenu createActionMode = ((BaseFragment) this).actionBar.createActionMode();
        NumberTextView numberTextView = new NumberTextView(createActionMode.getContext());
        this.selectedMessagesCountTextView = numberTextView;
        numberTextView.setTextSize(18);
        this.selectedMessagesCountTextView.setTypeface(AndroidUtilities.bold());
        this.selectedMessagesCountTextView.setTextColor(getThemedColor(Theme.key_actionBarActionModeDefaultIcon));
        this.selectedMessagesCountTextView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public final boolean onTouch(View view, MotionEvent motionEvent) {
                boolean lambda$createActionMode$92;
                lambda$createActionMode$92 = ChatActivity.lambda$createActionMode$92(view, motionEvent);
                return lambda$createActionMode$92;
            }
        });
        createActionMode.addView((View) this.selectedMessagesCountTextView, (ViewGroup.LayoutParams) LayoutHelper.createLinear(0, -1, 1.0f, 65, 0, 0, 0));
        if (this.currentEncryptedChat == null) {
            boolean z = getDialogId() == getUserConfig().getClientUserId() && ((i = this.chatMode) == 0 || i == 3);
            this.actionModeViews.add(createActionMode.addItemWithWidth(25, R.drawable.msg_download, AndroidUtilities.dp(54.0f), LocaleController.getString(R.string.SaveToMusic)));
            this.actionModeViews.add(createActionMode.addItemWithWidth(23, R.drawable.msg_edit, AndroidUtilities.dp(54.0f), LocaleController.getString(R.string.Edit)));
            if (z) {
                this.actionModeViews.add(createActionMode.addItemWithWidth(28, R.drawable.menu_tag_edit, AndroidUtilities.dp(54.0f), LocaleController.getString(R.string.AccDescrTagMessage)));
            }
            this.actionModeViews.add(createActionMode.addItemWithWidth(22, R.drawable.msg_fave, AndroidUtilities.dp(54.0f), LocaleController.getString(R.string.AddToFavorites)));
            this.actionModeViews.add(createActionMode.addItemWithWidth(10, R.drawable.msg_copy, AndroidUtilities.dp(54.0f), LocaleController.getString(R.string.Copy)));
            if (!z && getDialogId() != 489000) {
                this.actionModeViews.add(createActionMode.addItemWithWidth(11, R.drawable.msg_forward, AndroidUtilities.dp(54.0f), LocaleController.getString(R.string.Forward)));
            }
            arrayList = this.actionModeViews;
            addItemWithWidth = createActionMode.addItemWithWidth(69, R.drawable.msg_shareout, AndroidUtilities.dp(54.0f), LocaleController.getString(R.string.ShareFile));
        } else {
            this.actionModeViews.add(createActionMode.addItemWithWidth(23, R.drawable.msg_edit, AndroidUtilities.dp(54.0f), LocaleController.getString(R.string.Edit)));
            this.actionModeViews.add(createActionMode.addItemWithWidth(22, R.drawable.msg_fave, AndroidUtilities.dp(54.0f), LocaleController.getString(R.string.AddToFavorites)));
            arrayList = this.actionModeViews;
            addItemWithWidth = createActionMode.addItemWithWidth(10, R.drawable.msg_copy, AndroidUtilities.dp(54.0f), LocaleController.getString(R.string.Copy));
        }
        arrayList.add(addItemWithWidth);
        this.actionModeViews.add(createActionMode.addItemWithWidth(12, R.drawable.msg_delete, AndroidUtilities.dp(54.0f), LocaleController.getString(R.string.Delete)));
        createActionMode.setItemVisibility(23, (this.canEditMessagesCount == 1 && this.selectedMessagesIds[0].size() + this.selectedMessagesIds[1].size() == 1) ? 0 : 8);
        createActionMode.setItemVisibility(10, (getMessagesController().isChatNoForwards(this.currentChat) || this.selectedMessagesCanCopyIds[0].size() + this.selectedMessagesCanCopyIds[1].size() == 0) ? 8 : 0);
        createActionMode.setItemVisibility(22, this.selectedMessagesCanStarIds[0].size() + this.selectedMessagesCanStarIds[1].size() != 0 ? 0 : 8);
        createActionMode.setItemVisibility(12, this.cantDeleteMessagesCount == 0 ? 0 : 8);
        createActionMode.setItemVisibility(28, getUserConfig().isPremium() ? 0 : 8);
        createActionMode.setItemVisibility(69, 8);
    }

    private void createAlertView() {
        if (this.alertView != null || getContext() == null) {
            return;
        }
        FrameLayout frameLayout = new FrameLayout(getContext());
        this.alertView = frameLayout;
        frameLayout.setTag(1);
        this.alertView.setVisibility(8);
        this.alertView.setBackgroundResource(R.drawable.blockpanel);
        this.alertView.getBackground().setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_chat_topPanelBackground), PorterDuff.Mode.MULTIPLY));
        BlurredFrameLayout blurredFrameLayout = this.topChatPanelView;
        int i = 9;
        if (blurredFrameLayout != null) {
            SizeNotifierFrameLayout parent = blurredFrameLayout.getParent();
            SizeNotifierFrameLayout sizeNotifierFrameLayout = this.contentView;
            if (parent == sizeNotifierFrameLayout) {
                i = Math.max(9, sizeNotifierFrameLayout.indexOfChild(this.topChatPanelView) + 1);
            }
        }
        BlurredFrameLayout blurredFrameLayout2 = this.pinnedMessageView;
        if (blurredFrameLayout2 != null) {
            SizeNotifierFrameLayout parent2 = blurredFrameLayout2.getParent();
            SizeNotifierFrameLayout sizeNotifierFrameLayout2 = this.contentView;
            if (parent2 == sizeNotifierFrameLayout2) {
                i = Math.max(i, sizeNotifierFrameLayout2.indexOfChild(this.pinnedMessageView) + 1);
            }
        }
        this.contentView.addView(this.alertView, i, LayoutHelper.createFrame(-1, 50, 51));
        TextView textView = new TextView(getContext());
        this.alertNameTextView = textView;
        textView.setTextSize(1, 14.0f);
        this.alertNameTextView.setTextColor(getThemedColor(Theme.key_chat_topPanelTitle));
        this.alertNameTextView.setTypeface(AndroidUtilities.bold());
        this.alertNameTextView.setSingleLine(true);
        TextView textView2 = this.alertNameTextView;
        TextUtils.TruncateAt truncateAt = TextUtils.TruncateAt.END;
        textView2.setEllipsize(truncateAt);
        this.alertNameTextView.setMaxLines(1);
        this.alertView.addView(this.alertNameTextView, LayoutHelper.createFrame(-2, -2.0f, 51, 8.0f, 5.0f, 8.0f, 0.0f));
        TextView textView3 = new TextView(getContext());
        this.alertTextView = textView3;
        textView3.setTextSize(1, 14.0f);
        this.alertTextView.setTextColor(getThemedColor(Theme.key_chat_topPanelMessage));
        this.alertTextView.setSingleLine(true);
        this.alertTextView.setEllipsize(truncateAt);
        this.alertTextView.setMaxLines(1);
        this.alertView.addView(this.alertTextView, LayoutHelper.createFrame(-2, -2.0f, 51, 8.0f, 23.0f, 8.0f, 0.0f));
    }

    private void createBizBotButton() {
        if (this.bizBotButton != null || getContext() == null) {
            return;
        }
        createTopPanel();
        if (this.topChatPanelView == null) {
            return;
        }
        BusinessBotButton businessBotButton = new BusinessBotButton(getContext(), this, this.themeDelegate);
        this.bizBotButton = businessBotButton;
        this.topChatPanelView.addView(businessBotButton, LayoutHelper.createFrame(-1, 48.0f, 83, 0.0f, 0.0f, 0.0f, 2.0f));
        this.bizBotButton.setLeftMargin(getSideMenuWidth());
    }

    private void createBotAdView() {
        if (this.botAdView != null || getContext() == null) {
            return;
        }
        createTopPanel2();
        if (this.topChatPanelView2 == null) {
            return;
        }
        View botAdView = new BotAdView(getContext(), this.themeDelegate);
        this.botAdView = botAdView;
        this.topChatPanelView2.addView(botAdView);
    }

    private void createBottomMessagesActionButtons() {
        if (this.replyButton != null || getContext() == null) {
            return;
        }
        if (!this.isInsideContainer) {
            TextView textView = new TextView(getContext());
            this.replyButton = textView;
            textView.setText(LocaleController.getString(R.string.Reply));
            this.replyButton.setGravity(16);
            this.replyButton.setTextSize(1, 15.0f);
            this.replyButton.setPadding(AndroidUtilities.dp(14.0f), 0, AndroidUtilities.dp(21.0f), 0);
            this.replyButton.setBackgroundDrawable(Theme.createSelectorDrawable(getThemedColor(Theme.key_actionBarActionModeDefaultSelector), 3));
            TextView textView2 = this.replyButton;
            int i = Theme.key_actionBarActionModeDefaultIcon;
            textView2.setTextColor(getThemedColor(i));
            this.replyButton.setCompoundDrawablePadding(AndroidUtilities.dp(7.0f));
            this.replyButton.setTypeface(AndroidUtilities.bold());
            Drawable mutate = getContext().getResources().getDrawable(R.drawable.input_reply).mutate();
            mutate.setColorFilter(new PorterDuffColorFilter(getThemedColor(i), PorterDuff.Mode.MULTIPLY));
            this.replyButton.setCompoundDrawablesWithIntrinsicBounds(mutate, (Drawable) null, (Drawable) null, (Drawable) null);
            this.replyButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    ChatActivity.this.lambda$createBottomMessagesActionButtons$79(view);
                }
            });
            this.bottomMessagesActionContainer.addView(this.replyButton, LayoutHelper.createFrame(-2, -1, 51));
        }
        TextView textView3 = new TextView(getContext());
        this.forwardButton = textView3;
        textView3.setText(LocaleController.getString(R.string.Forward));
        this.forwardButton.setGravity(16);
        this.forwardButton.setTextSize(1, 15.0f);
        this.forwardButton.setPadding(AndroidUtilities.dp(21.0f), 0, AndroidUtilities.dp(21.0f), 0);
        this.forwardButton.setCompoundDrawablePadding(AndroidUtilities.dp(6.0f));
        this.forwardButton.setBackgroundDrawable(Theme.createSelectorDrawable(getThemedColor(Theme.key_actionBarActionModeDefaultSelector), 3));
        TextView textView4 = this.forwardButton;
        int i2 = Theme.key_actionBarActionModeDefaultIcon;
        textView4.setTextColor(getThemedColor(i2));
        this.forwardButton.setTypeface(AndroidUtilities.bold());
        Drawable mutate2 = getContext().getResources().getDrawable(R.drawable.input_forward).mutate();
        mutate2.setColorFilter(new PorterDuffColorFilter(getThemedColor(i2), PorterDuff.Mode.MULTIPLY));
        this.forwardButton.setCompoundDrawablesWithIntrinsicBounds(mutate2, (Drawable) null, (Drawable) null, (Drawable) null);
        this.forwardButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ChatActivity.this.lambda$createBottomMessagesActionButtons$80(view);
            }
        });
        this.bottomMessagesActionContainer.addView(this.forwardButton, LayoutHelper.createFrame(-2, -1, 53));
        if (getDialogId() == 489000) {
            this.forwardButton.setVisibility(8);
        }
    }

    private void createChatAttachView() {
        if (getParentActivity() == null || getContext() == null || this.chatAttachAlert != null) {
            return;
        }
        boolean z = false;
        ChatAttachAlert chatAttachAlert = new ChatAttachAlert(getParentActivity(), this, z, false, true, this.themeDelegate) {
            public void dismissInternal() {
                ChatAttachAlert chatAttachAlert2 = ChatActivity.this.chatAttachAlert;
                if (chatAttachAlert2 != null && chatAttachAlert2.isShowing()) {
                    AndroidUtilities.requestAdjustResize(ChatActivity.this.getParentActivity(), ((BaseFragment) ChatActivity.this).classGuid);
                }
                super.dismissInternal();
                ChatActivity.this.onEditTextDialogClose(false, true);
            }

            public void onDismissAnimationStart() {
                ChatAttachAlert chatAttachAlert2 = ChatActivity.this.chatAttachAlert;
                if (chatAttachAlert2 != null) {
                    chatAttachAlert2.setFocusable(false);
                }
                ChatActivityEnterView chatActivityEnterView = ChatActivity.this.chatActivityEnterView;
                if (chatActivityEnterView != null && chatActivityEnterView.getEditField() != null) {
                    ChatActivity.this.chatActivityEnterView.getEditField().requestFocus();
                }
                ChatAttachAlert chatAttachAlert3 = ChatActivity.this.chatAttachAlert;
                if (chatAttachAlert3 != null && chatAttachAlert3.isShowing()) {
                    AndroidUtilities.requestAdjustResize(ChatActivity.this.getParentActivity(), ((BaseFragment) ChatActivity.this).classGuid);
                }
                ChatActivity.this.onEditTextDialogClose(false, false);
            }
        };
        this.chatAttachAlert = chatAttachAlert;
        chatAttachAlert.setDelegate(new ChatAttachAlert.ChatAttachViewDelegate() {
            public void didPressedButton(int i, boolean z2, boolean z3, int i2, long j, boolean z4, boolean z5, long j2) {
                ChatActivity chatActivity;
                ChatAttachAlert chatAttachAlert2;
                boolean z6;
                int i3;
                int i4;
                String str;
                TLRPC.Message message;
                if (ChatActivity.this.getParentActivity() == null || (chatAttachAlert2 = (chatActivity = ChatActivity.this).chatAttachAlert) == null) {
                    return;
                }
                chatActivity.editingMessageObject = chatAttachAlert2.getEditingMessageObject();
                ChatActivity chatActivity2 = ChatActivity.this;
                MessageObject messageObject = chatActivity2.editingMessageObject;
                if (messageObject != null && (message = messageObject.messageOwner) != null) {
                    message.invert_media = z4;
                }
                int i5 = 4;
                if (i != 8 && i != 7 && (i != 4 || chatActivity2.chatAttachAlert.getPhotoLayout().getSelectedPhotos().isEmpty())) {
                    ChatAttachAlert chatAttachAlert3 = ChatActivity.this.chatAttachAlert;
                    if (chatAttachAlert3 != null) {
                        chatAttachAlert3.dismissWithButtonClick(i);
                    }
                    ChatActivity.this.processSelectedAttach(i);
                    return;
                }
                ChatAttachAlert chatAttachAlert4 = ChatActivity.this.chatAttachAlert;
                if (chatAttachAlert4 != null && i != 8) {
                    chatAttachAlert4.dismiss(true);
                }
                HashMap selectedPhotos = ChatActivity.this.chatAttachAlert.getPhotoLayout().getSelectedPhotos();
                ArrayList selectedPhotosOrder = ChatActivity.this.chatAttachAlert.getPhotoLayout().getSelectedPhotosOrder();
                if (!selectedPhotos.isEmpty()) {
                    int ceil = (int) Math.ceil(selectedPhotos.size() / 10.0f);
                    int i6 = 0;
                    while (i6 < ceil) {
                        int i7 = i6 * 10;
                        int min = Math.min(10, selectedPhotos.size() - i7);
                        ArrayList arrayList = new ArrayList();
                        for (int i8 = 0; i8 < min; i8++) {
                            int i9 = i7 + i8;
                            if (i9 < selectedPhotosOrder.size()) {
                                MediaController.PhotoEntry photoEntry = (MediaController.PhotoEntry) selectedPhotos.get(selectedPhotosOrder.get(i9));
                                SendMessagesHelper.SendingMediaInfo sendingMediaInfo = new SendMessagesHelper.SendingMediaInfo();
                                if (photoEntry.isVideo || (str = ((MediaController.MediaEditState) photoEntry).imagePath) == null) {
                                    String str2 = photoEntry.path;
                                    if (str2 != null) {
                                        sendingMediaInfo.path = str2;
                                    }
                                } else {
                                    sendingMediaInfo.path = str;
                                    if (((MediaController.MediaEditState) photoEntry).highQuality) {
                                        sendingMediaInfo.originalPhotoEntry = photoEntry.clone();
                                    }
                                }
                                sendingMediaInfo.thumbPath = ((MediaController.MediaEditState) photoEntry).thumbPath;
                                sendingMediaInfo.coverPath = ((MediaController.MediaEditState) photoEntry).coverPath;
                                sendingMediaInfo.coverPhoto = ((MediaController.MediaEditState) photoEntry).coverPhoto;
                                sendingMediaInfo.isVideo = photoEntry.isVideo;
                                CharSequence charSequence = ((MediaController.MediaEditState) photoEntry).caption;
                                sendingMediaInfo.caption = charSequence != null ? charSequence.toString() : null;
                                sendingMediaInfo.entities = ((MediaController.MediaEditState) photoEntry).entities;
                                sendingMediaInfo.masks = ((MediaController.MediaEditState) photoEntry).stickers;
                                sendingMediaInfo.ttl = ((MediaController.MediaEditState) photoEntry).ttl;
                                sendingMediaInfo.videoEditedInfo = ((MediaController.MediaEditState) photoEntry).editedInfo;
                                sendingMediaInfo.canDeleteAfter = photoEntry.canDeleteAfter;
                                sendingMediaInfo.updateStickersOrder = SendMessagesHelper.checkUpdateStickersOrder(((MediaController.MediaEditState) photoEntry).caption);
                                sendingMediaInfo.hasMediaSpoilers = photoEntry.hasSpoiler;
                                sendingMediaInfo.stars = photoEntry.starsAmount;
                                sendingMediaInfo.highQuality = ((MediaController.MediaEditState) photoEntry).highQuality;
                                arrayList.add(sendingMediaInfo);
                                photoEntry.reset();
                            }
                        }
                        if (i6 == 0) {
                            ChatActivity.this.fillEditingMediaWithCaption(((SendMessagesHelper.SendingMediaInfo) arrayList.get(0)).caption, ((SendMessagesHelper.SendingMediaInfo) arrayList.get(0)).entities);
                            z6 = ((SendMessagesHelper.SendingMediaInfo) arrayList.get(0)).updateStickersOrder;
                        } else {
                            z6 = false;
                        }
                        MessageObject messageObject2 = ChatActivity.this.editingMessageObject;
                        if (messageObject2 == null || !messageObject2.needResendWhenEdit()) {
                            i3 = i6;
                            i4 = ceil;
                            AccountInstance accountInstance = ChatActivity.this.getAccountInstance();
                            long j3 = ChatActivity.this.dialog_id;
                            MessageObject messageObject3 = ChatActivity.this.replyingMessageObject;
                            MessageObject threadMessage = ChatActivity.this.getThreadMessage();
                            ReplyQuote replyQuote = ChatActivity.this.replyingQuote;
                            boolean z7 = i == 4 || z5;
                            ChatActivity chatActivity3 = ChatActivity.this;
                            MessageObject messageObject4 = chatActivity3.editingMessageObject;
                            int i10 = chatActivity3.chatMode;
                            ChatActivity chatActivity4 = ChatActivity.this;
                            SendMessagesHelper.prepareSendingMedia(accountInstance, arrayList, j3, messageObject3, threadMessage, (TL_stories.StoryItem) null, replyQuote, z7, z2, messageObject4, z3, i2, i10, z6, (InputContentInfoCompat) null, chatActivity4.quickReplyShortcut, chatActivity4.getQuickReplyId(), j, z4, j2, ChatActivity.this.getSendMonoForumPeerId(), ChatActivity.this.messageSuggestionParams);
                        } else {
                            ChatActivity chatActivity5 = ChatActivity.this;
                            MessageSuggestionParams messageSuggestionParams = chatActivity5.messageSuggestionParams;
                            MessageSuggestionParams of = messageSuggestionParams != null ? messageSuggestionParams : MessageSuggestionParams.of(chatActivity5.editingMessageObject.messageOwner.suggested_post);
                            AccountInstance accountInstance2 = ChatActivity.this.getAccountInstance();
                            long j4 = ChatActivity.this.dialog_id;
                            ChatActivity chatActivity6 = ChatActivity.this;
                            MessageObject messageObject5 = chatActivity6.editingMessageObject;
                            MessageObject threadMessage2 = chatActivity6.getThreadMessage();
                            ReplyQuote replyQuote2 = ChatActivity.this.replyingQuote;
                            boolean z8 = i == i5 || z5;
                            int i11 = ChatActivity.this.chatMode;
                            ChatActivity chatActivity7 = ChatActivity.this;
                            i3 = i6;
                            i4 = ceil;
                            SendMessagesHelper.prepareSendingMedia(accountInstance2, arrayList, j4, messageObject5, threadMessage2, (TL_stories.StoryItem) null, replyQuote2, z8, z2, (MessageObject) null, z3, i2, i11, z6, (InputContentInfoCompat) null, chatActivity7.quickReplyShortcut, chatActivity7.getQuickReplyId(), j, z4, j2, ChatActivity.this.getSendMonoForumPeerId(), of);
                        }
                        i6 = i3 + 1;
                        ceil = i4;
                        i5 = 4;
                    }
                    ChatActivity.this.afterMessageSend();
                    ChatActivity.this.chatActivityEnterView.setFieldText("");
                }
                if (i2 != 0) {
                    if (ChatActivity.this.scheduledMessagesCount == -1) {
                        ChatActivity.this.scheduledMessagesCount = 0;
                    }
                    ChatActivity.access$3412(ChatActivity.this, selectedPhotos.size());
                    ChatActivity.this.updateScheduledInterface(true);
                }
            }

            public void didSelectBot(TLRPC.User user) {
                String publicUsername = UserObject.getPublicUsername(user);
                if (ChatActivity.this.chatActivityEnterView == null || user == null || TextUtils.isEmpty(publicUsername)) {
                    return;
                }
                ChatActivity.this.chatActivityEnterView.setFieldText("@" + publicUsername + " ");
                ChatActivity.this.chatActivityEnterView.openKeyboard();
            }

            public void doOnIdle(Runnable runnable) {
                ChatActivity.this.lambda$openDiscussionMessageChat$372(runnable);
            }

            public boolean needEnterComment() {
                return ChatActivity.this.needEnterText();
            }

            public void onCameraOpened() {
                ChatActivity.this.chatActivityEnterView.closeKeyboard();
            }

            public void onWallpaperSelected(Object obj) {
                ChatAttachAlert.ChatAttachViewDelegate.-CC.$default$onWallpaperSelected(this, obj);
            }

            public void openAvatarsSearch() {
                ChatAttachAlert.ChatAttachViewDelegate.-CC.$default$openAvatarsSearch(this);
            }

            public boolean selectItemOnClicking() {
                return ChatAttachAlert.ChatAttachViewDelegate.-CC.$default$selectItemOnClicking(this);
            }

            public void sendAudio(ArrayList arrayList, CharSequence charSequence, boolean z2, int i, long j, boolean z3, long j2) {
                ChatAttachAlert.ChatAttachViewDelegate.-CC.$default$sendAudio(this, arrayList, charSequence, z2, i, j, z3, j2);
            }
        });
    }

    public void createDeleteMessagesAlert(MessageObject messageObject, MessageObject.GroupedMessages groupedMessages) {
        createDeleteMessagesAlert(messageObject, groupedMessages, false);
    }

    private void createDeleteMessagesAlert(MessageObject messageObject, MessageObject.GroupedMessages groupedMessages, boolean z) {
        if (messageObject == null && this.selectedMessagesIds[0].size() + this.selectedMessagesIds[1].size() == 0) {
            return;
        }
        AlertsCreator.createDeleteMessagesAlert(this, this.currentUser, this.currentChat, this.currentEncryptedChat, this.chatInfo, this.mergeDialogId, messageObject, this.selectedMessagesIds, groupedMessages, (int) getTopicId(), this.chatMode, (TLRPC.ChannelParticipant[]) null, new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$createDeleteMessagesAlert$253();
            }
        }, z ? new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$createDeleteMessagesAlert$254();
            }
        } : null, this.themeDelegate);
    }

    private void createEmptyView(boolean r23) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.createEmptyView(boolean):void");
    }

    public void createHint2MessageObject() {
        if (this.hint2MessageObject != null) {
            return;
        }
        TLRPC.TL_message tL_message = new TLRPC.TL_message();
        ((TLRPC.Message) tL_message).message = LocaleController.getString(this.chatMode == 3 ? R.string.SavedMessagesProfileHint : R.string.BusinessRepliesHint);
        ((TLRPC.Message) tL_message).id = 0;
        MessageObject messageObject = new MessageObject(((BaseFragment) this).currentAccount, tL_message, false, false);
        this.hint2MessageObject = messageObject;
        messageObject.type = 10;
        messageObject.contentType = 1;
    }

    public boolean createMenu(View view, boolean z, boolean z2, float f, float f2, boolean z3) {
        return createMenu(view, z, z2, f, f2, true, z3);
    }

    public boolean createMenu(View view, boolean z, boolean z2, float f, float f2, boolean z3, boolean z4) {
        return createMenu(view, z, z2, f, f2, z3, z4, false);
    }

    public boolean createMenu(final android.view.View r90, boolean r91, boolean r92, float r93, float r94, boolean r95, boolean r96, boolean r97) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.createMenu(android.view.View, boolean, boolean, float, float, boolean, boolean, boolean):boolean");
    }

    private void createPinnedMessageView() {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.createPinnedMessageView():void");
    }

    public void createSearchContainer() {
        if (this.searchContainer != null || getContext() == null) {
            return;
        }
        BlurredFrameLayout blurredFrameLayout = new BlurredFrameLayout(getContext(), this.contentView) {
            private Rect blurBounds = new Rect();

            protected void measureChildWithMargins(View view, int i, int i2, int i3, int i4) {
                if (view == ChatActivity.this.searchCountText) {
                    int i5 = (ChatActivity.this.searchCalendarButton == null || ChatActivity.this.searchCalendarButton.getVisibility() == 8) ? 18 : 66;
                    if (ChatActivity.this.searchUserButton != null && ChatActivity.this.searchUserButton.getVisibility() != 8) {
                        i5 += 48;
                    }
                    ((ViewGroup.MarginLayoutParams) view.getLayoutParams()).leftMargin = AndroidUtilities.dp(i5);
                }
                super/*android.widget.FrameLayout*/.measureChildWithMargins(view, i, i2, i3, i4);
            }

            public void onDraw(Canvas canvas) {
                int intrinsicHeight = Theme.chat_composeShadowDrawable.getIntrinsicHeight();
                if (ChatActivity.this.chatActivityEnterView.getVisibility() != 0) {
                    Theme.chat_composeShadowDrawable.setBounds(0, 0, getMeasuredWidth(), intrinsicHeight);
                    Theme.chat_composeShadowDrawable.draw(canvas);
                }
                this.blurBounds.set(0, intrinsicHeight, getMeasuredWidth(), getMeasuredHeight());
                ChatActivity.this.contentView.drawBlurRect(canvas, getY(), this.blurBounds, ChatActivity.this.getThemedPaint("paintChatComposeBackground"), false);
            }

            public void setVisibility(int i) {
                super/*android.widget.FrameLayout*/.setVisibility(i);
                if (ChatActivity.this.chatListView != null) {
                    ChatActivity chatActivity = ChatActivity.this;
                    if (chatActivity.isInsideContainer) {
                        RecyclerListView recyclerListView = chatActivity.chatListView;
                        int paddingLeft = ChatActivity.this.chatListView.getPaddingLeft();
                        int paddingTop = ChatActivity.this.chatListView.getPaddingTop();
                        int paddingRight = ChatActivity.this.chatListView.getPaddingRight();
                        int dp = AndroidUtilities.dp(3.0f);
                        ChatActivity chatActivity2 = ChatActivity.this;
                        recyclerListView.setPadding(paddingLeft, paddingTop, paddingRight, dp + chatActivity2.blurredViewBottomOffset + ((chatActivity2.isInsideContainer && i == 0) ? AndroidUtilities.dp(50.0f) : 0));
                    }
                }
            }
        };
        this.searchContainer = blurredFrameLayout;
        blurredFrameLayout.setClickable(false);
        BlurredFrameLayout blurredFrameLayout2 = this.searchContainer;
        blurredFrameLayout2.drawBlur = false;
        blurredFrameLayout2.isTopView = false;
        blurredFrameLayout2.setWillNotDraw(false);
        this.searchContainer.setVisibility(4);
        this.searchContainer.setPadding(0, AndroidUtilities.dp(3.0f), 0, 0);
        this.searchContainer.setClipToPadding(false);
        AnimatedTextView animatedTextView = new AnimatedTextView(getContext(), true, true, true);
        this.searchCountText = animatedTextView;
        CubicBezierInterpolator cubicBezierInterpolator = CubicBezierInterpolator.EASE_OUT_QUINT;
        animatedTextView.setAnimationProperties(0.25f, 0L, 280L, cubicBezierInterpolator);
        this.searchCountText.setTextSize(AndroidUtilities.dp(15.0f));
        this.searchCountText.setTypeface(AndroidUtilities.bold());
        this.searchCountText.setTextColor(getThemedColor(Theme.key_chat_searchPanelText));
        this.searchCountText.setGravity(3);
        this.searchContainer.addView(this.searchCountText, LayoutHelper.createFrame(-2, 30.0f, 16, 0.0f, -1.0f, 97.33f, 0.0f));
        this.contentView.addView(this.searchContainer, LayoutHelper.createFrame(-1, 51, 80));
        HashtagHistoryView hashtagHistoryView = this.hashtagHistoryView;
        if (hashtagHistoryView != null) {
            hashtagHistoryView.bringToFront();
        }
        AnimatedTextView animatedTextView2 = new AnimatedTextView(getContext(), true, false, true);
        this.searchExpandList = animatedTextView2;
        animatedTextView2.setAnimationProperties(0.0f, 0L, 420L, cubicBezierInterpolator);
        this.searchExpandList.setScaleProperty(0.7f);
        this.searchExpandList.setTextSize(AndroidUtilities.dp(15.0f));
        this.searchExpandList.setGravity(5);
        this.searchExpandList.setTypeface(AndroidUtilities.bold());
        this.searchExpandList.setTextColor(getThemedColor(Theme.key_windowBackgroundWhiteBlueText2));
        AnimatedTextView animatedTextView3 = this.searchExpandList;
        FrameLayout frameLayout = this.messagesSearchListContainer;
        animatedTextView3.setText(LocaleController.getString((frameLayout == null || frameLayout.getTag() == null) ? R.string.SearchAsList : R.string.SearchAsChat));
        AnimatedTextView animatedTextView4 = this.searchExpandList;
        animatedTextView4.adaptWidth = false;
        animatedTextView4.setPadding(AndroidUtilities.dp(15.33f), 0, AndroidUtilities.dp(15.33f), 0);
        this.searchExpandList.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ChatActivity.this.lambda$createSearchContainer$94(view);
            }
        });
        this.searchExpandList.setAlpha(0.5f);
        this.searchExpandList.setClickable(false);
        this.searchContainer.addView(this.searchExpandList, LayoutHelper.createFrame(-2, -1, 117));
        AnimatedTextView animatedTextView5 = new AnimatedTextView(getContext(), true, true, true);
        this.searchOtherButton = animatedTextView5;
        animatedTextView5.setGravity(17);
        this.searchOtherButton.setTypeface(AndroidUtilities.bold());
        this.searchOtherButton.setTextColor(getThemedColor(Theme.key_chat_fieldOverlayText));
        this.searchOtherButton.setTextSize(AndroidUtilities.dp(15.0f));
        AnimatedTextView animatedTextView6 = this.searchOtherButton;
        int i = Theme.key_windowBackgroundWhite;
        animatedTextView6.setBackground(Theme.createSelectorWithBackgroundDrawable(getThemedColor(i), Theme.blendOver(getThemedColor(i), getThemedColor(Theme.key_listSelector))));
        this.searchOtherButton.setText(LocaleController.getString(this.chatAdapter.isFiltered ? R.string.SavedTagHideOtherMessages : R.string.SavedTagShowOtherMessages));
        this.searchOtherButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ChatActivity.this.lambda$createSearchContainer$95(view);
            }
        });
        this.searchOtherButton.setVisibility(8);
        this.searchOtherButton.setAlpha(0.0f);
        this.searchContainer.addView(this.searchOtherButton, LayoutHelper.createFrame(-1, -1, 119));
        TLRPC.Chat chat = this.currentChat;
        if (chat != null && ((!ChatObject.isChannel(chat) || this.currentChat.megagroup) && this.chatMode != 7 && !ChatObject.isMonoForum(this.currentChat))) {
            ImageView imageView = new ImageView(getContext());
            this.searchUserButton = imageView;
            imageView.setScaleType(ImageView.ScaleType.CENTER);
            this.searchUserButton.setImageResource(R.drawable.msg_usersearch);
            this.searchUserButton.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_chat_searchPanelIcons), PorterDuff.Mode.MULTIPLY));
            this.searchUserButton.setBackgroundDrawable(Theme.createSelectorDrawable(getThemedColor(Theme.key_actionBarActionModeDefaultSelector), 1));
            this.searchContainer.addView(this.searchUserButton, LayoutHelper.createFrame(48, 48.0f, 51, 48.0f, 0.0f, 0.0f, 0.0f));
            this.searchUserButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    ChatActivity.this.lambda$createSearchContainer$96(view);
                }
            });
            this.searchUserButton.setContentDescription(LocaleController.getString(R.string.AccDescrSearchByUser));
        }
        if (this.chatMode != 7) {
            ImageView imageView2 = new ImageView(getContext());
            this.searchCalendarButton = imageView2;
            imageView2.setScaleType(ImageView.ScaleType.CENTER);
            this.searchCalendarButton.setImageResource(R.drawable.msg_calendar);
            this.searchCalendarButton.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_chat_searchPanelIcons), PorterDuff.Mode.MULTIPLY));
            this.searchCalendarButton.setBackgroundDrawable(Theme.createSelectorDrawable(getThemedColor(Theme.key_actionBarActionModeDefaultSelector), 1));
            this.searchContainer.addView(this.searchCalendarButton, LayoutHelper.createFrame(48, 48.0f, 51, 2.66f, 0.0f, 0.0f, 0.0f));
            this.searchCalendarButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    ChatActivity.this.lambda$createSearchContainer$97(view);
                }
            });
            this.searchCalendarButton.setContentDescription(LocaleController.getString(R.string.JumpToDate));
        }
    }

    public TextureView createTextureView(boolean z) {
        if (((BaseFragment) this).parentLayout == null) {
            return null;
        }
        AndroidUtilities.cancelRunOnUIThread(this.destroyTextureViewRunnable);
        if (this.videoPlayerContainer == null) {
            if (Build.VERSION.SDK_INT >= 21) {
                FrameLayout frameLayout = new FrameLayout(getParentActivity()) {
                    @Override
                    public void setTranslationY(float f) {
                        super.setTranslationY(f);
                        ChatActivity.this.contentView.invalidate();
                    }
                };
                this.videoPlayerContainer = frameLayout;
                frameLayout.setOutlineProvider(new ViewOutlineProvider() {
                    @Override
                    public void getOutline(View view, Outline outline) {
                        ImageReceiver imageReceiver = (ImageReceiver) view.getTag(R.id.parent_tag);
                        if (imageReceiver == null) {
                            outline.setOval(0, 0, AndroidUtilities.roundPlayingMessageSize(ChatActivity.this.isSideMenued()), AndroidUtilities.roundPlayingMessageSize(ChatActivity.this.isSideMenued()));
                            return;
                        }
                        int[] roundRadius = imageReceiver.getRoundRadius();
                        int i = 0;
                        for (int i2 = 0; i2 < 4; i2++) {
                            i = Math.max(i, roundRadius[i2]);
                        }
                        outline.setRoundRect(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight(), i);
                    }
                });
                this.videoPlayerContainer.setClipToOutline(true);
            } else {
                this.videoPlayerContainer = new FrameLayout(getParentActivity()) {
                    RectF rect = new RectF();

                    @Override
                    protected void dispatchDraw(Canvas canvas) {
                        super.dispatchDraw(canvas);
                        if (getTag() == null) {
                            canvas.drawPath(ChatActivity.this.aspectPath, ChatActivity.this.aspectPaint);
                        }
                    }

                    @Override
                    protected void onSizeChanged(int i, int i2, int i3, int i4) {
                        super.onSizeChanged(i, i2, i3, i4);
                        ChatActivity.this.aspectPath.reset();
                        ImageReceiver imageReceiver = (ImageReceiver) getTag(R.id.parent_tag);
                        if (imageReceiver != null) {
                            int[] roundRadius = imageReceiver.getRoundRadius();
                            int i5 = 0;
                            for (int i6 = 0; i6 < 4; i6++) {
                                i5 = Math.max(i5, roundRadius[i6]);
                            }
                            this.rect.set(0.0f, 0.0f, i, i2);
                            ChatActivity.this.aspectPath.addRoundRect(this.rect, AndroidUtilities.dp(4.0f), AndroidUtilities.dp(4.0f), Path.Direction.CW);
                        } else {
                            float f = i / 2;
                            ChatActivity.this.aspectPath.addCircle(f, i2 / 2, f, Path.Direction.CW);
                        }
                        ChatActivity.this.aspectPath.toggleInverseFillType();
                    }

                    @Override
                    public void setTranslationY(float f) {
                        super.setTranslationY(f);
                        ChatActivity.this.contentView.invalidate();
                    }

                    @Override
                    public void setVisibility(int i) {
                        super.setVisibility(i);
                        if (i == 0) {
                            setLayerType(2, null);
                        }
                    }
                };
                this.aspectPath = new Path();
                Paint paint = new Paint(1);
                this.aspectPaint = paint;
                paint.setColor(-16777216);
                this.aspectPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
            }
            this.videoPlayerContainer.setWillNotDraw(false);
            AspectRatioFrameLayout aspectRatioFrameLayout = new AspectRatioFrameLayout(getParentActivity());
            this.aspectRatioFrameLayout = aspectRatioFrameLayout;
            aspectRatioFrameLayout.setBackgroundColor(0);
            if (z) {
                this.videoPlayerContainer.addView((View) this.aspectRatioFrameLayout, (ViewGroup.LayoutParams) LayoutHelper.createFrame(-1, -1, 17));
            }
            TextureView textureView = new TextureView(getParentActivity());
            this.videoTextureView = textureView;
            textureView.setOpaque(false);
            this.aspectRatioFrameLayout.addView(this.videoTextureView, LayoutHelper.createFrame(-1, -1.0f));
        }
        ViewGroup viewGroup = (ViewGroup) this.videoPlayerContainer.getParent();
        if (viewGroup != null && viewGroup != this.contentView) {
            viewGroup.removeView(this.videoPlayerContainer);
            viewGroup = null;
        }
        if (viewGroup == null) {
            this.contentView.addView(this.videoPlayerContainer, 1, new FrameLayout.LayoutParams(AndroidUtilities.roundPlayingMessageSize(isSideMenued()), AndroidUtilities.roundPlayingMessageSize(isSideMenued())));
        }
        this.videoPlayerContainer.setTag(null);
        this.aspectRatioFrameLayout.setDrawingReady(false);
        return this.videoTextureView;
    }

    private void createTopPanel() {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.createTopPanel():void");
    }

    private void createTopPanel2() {
        if (this.contentView == null || this.topChatPanelView2 != null || getContext() == null) {
            return;
        }
        BlurredFrameLayout blurredFrameLayout = new BlurredFrameLayout(getContext(), this.contentView);
        this.topChatPanelView2 = blurredFrameLayout;
        int i = Theme.key_chat_topPanelBackground;
        blurredFrameLayout.backgroundColor = getThemedColor(i);
        this.topChatPanelView2.backgroundPaddingBottom = AndroidUtilities.dp(2.0f);
        this.topChatPanelView2.setPadding(0, 0, 0, AndroidUtilities.dp(2.0f));
        this.topChatPanelView2.setTag(1);
        this.topChatPanelView2Offset = -AndroidUtilities.dp(50.0f);
        invalidateChatListViewTopPadding();
        this.topChatPanelView2.setClickable(true);
        int i2 = 8;
        this.topChatPanelView2.setVisibility(8);
        this.topChatPanelView2.setBackgroundResource(R.drawable.blockpanel);
        this.topChatPanelView2.getBackground().setColorFilter(new PorterDuffColorFilter(getThemedColor(i), PorterDuff.Mode.MULTIPLY));
        BlurredFrameLayout blurredFrameLayout2 = this.pinnedMessageView;
        if (blurredFrameLayout2 != null) {
            SizeNotifierFrameLayout parent = blurredFrameLayout2.getParent();
            SizeNotifierFrameLayout sizeNotifierFrameLayout = this.contentView;
            if (parent == sizeNotifierFrameLayout) {
                i2 = sizeNotifierFrameLayout.indexOfChild(this.pinnedMessageView) + 1;
            }
        }
        this.contentView.addView(this.topChatPanelView2, i2, LayoutHelper.createFrame(-1, 50, 51));
    }

    private void createTopicsTabs() {
        ChatActivityEnterView chatActivityEnterView;
        if (this.topicsTabs != null || getContext() == null) {
            return;
        }
        if (this.pinnedMessageView == null) {
            createPinnedMessageView();
        }
        this.topicsTabs = new AnonymousClass59(getContext(), this, this.contentView, ((BaseFragment) this).currentAccount, getDialogId(), getResourceProvider());
        BlurredFrameLayout blurredFrameLayout = this.topChatPanelView;
        int i = 8;
        if (blurredFrameLayout != null) {
            SizeNotifierFrameLayout parent = blurredFrameLayout.getParent();
            SizeNotifierFrameLayout sizeNotifierFrameLayout = this.contentView;
            if (parent == sizeNotifierFrameLayout) {
                i = Math.max(8, sizeNotifierFrameLayout.indexOfChild(this.topChatPanelView) + 1);
            }
        }
        BlurredFrameLayout blurredFrameLayout2 = this.topChatPanelView2;
        if (blurredFrameLayout2 != null) {
            SizeNotifierFrameLayout parent2 = blurredFrameLayout2.getParent();
            SizeNotifierFrameLayout sizeNotifierFrameLayout2 = this.contentView;
            if (parent2 == sizeNotifierFrameLayout2) {
                i = Math.max(i, sizeNotifierFrameLayout2.indexOfChild(this.topChatPanelView2) + 1);
            }
        }
        ChatActivityMemberRequestsDelegate chatActivityMemberRequestsDelegate = this.pendingRequestsDelegate;
        View view = chatActivityMemberRequestsDelegate != null ? chatActivityMemberRequestsDelegate.getView() : null;
        if (view != null) {
            SizeNotifierFrameLayout parent3 = view.getParent();
            SizeNotifierFrameLayout sizeNotifierFrameLayout3 = this.contentView;
            if (parent3 == sizeNotifierFrameLayout3) {
                i = Math.max(i, sizeNotifierFrameLayout3.indexOfChild(view) + 1);
            }
        }
        BlurredFrameLayout blurredFrameLayout3 = this.pinnedMessageView;
        if (blurredFrameLayout3 != null) {
            SizeNotifierFrameLayout parent4 = blurredFrameLayout3.getParent();
            SizeNotifierFrameLayout sizeNotifierFrameLayout4 = this.contentView;
            if (parent4 == sizeNotifierFrameLayout4) {
                i = Math.max(i, sizeNotifierFrameLayout4.indexOfChild(this.pinnedMessageView) + 1);
            }
        }
        FragmentContextView fragmentContextView = this.fragmentContextView;
        if (fragmentContextView != null) {
            SizeNotifierFrameLayout parent5 = fragmentContextView.getParent();
            SizeNotifierFrameLayout sizeNotifierFrameLayout5 = this.contentView;
            if (parent5 == sizeNotifierFrameLayout5) {
                i = Math.max(i, sizeNotifierFrameLayout5.indexOfChild(this.fragmentContextView) + 1);
            }
        }
        FragmentContextView fragmentContextView2 = this.fragmentLocationContextView;
        if (fragmentContextView2 != null) {
            SizeNotifierFrameLayout parent6 = fragmentContextView2.getParent();
            SizeNotifierFrameLayout sizeNotifierFrameLayout6 = this.contentView;
            if (parent6 == sizeNotifierFrameLayout6) {
                i = Math.max(i, sizeNotifierFrameLayout6.indexOfChild(this.fragmentLocationContextView) + 1);
            }
        }
        this.topicsTabs.setCurrentTopic(getTopicId());
        this.topicsTabs.setOnNewTopicSelected(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$createTopicsTabs$88();
            }
        });
        this.topicsTabs.setOnTopicSelected(new Utilities.Callback2() {
            public final void run(Object obj, Object obj2) {
                ChatActivity.this.lambda$createTopicsTabs$89((Integer) obj, (Boolean) obj2);
            }
        });
        this.topicsTabs.setOnDialogSelected(new Utilities.Callback2() {
            public final void run(Object obj, Object obj2) {
                ChatActivity.this.lambda$createTopicsTabs$90((Long) obj, (Boolean) obj2);
            }
        });
        this.contentView.addView(this.topicsTabs, i, LayoutHelper.createFrame(-1, -1, 51));
        TopicsTabsView topicsTabsView = this.topicsTabs;
        if (topicsTabsView != null && (chatActivityEnterView = this.chatActivityEnterView) != null) {
            topicsTabsView.setBottomMargin(chatActivityEnterView.getHeightWithTopView());
        }
        this.topicsTabs.updateSidemenuPosition();
        MentionsContainerView mentionsContainerView = this.mentionContainer;
        if (mentionsContainerView != null) {
            mentionsContainerView.bringToFront();
        }
    }

    private void createTranslateButton() {
        if (this.translateButton != null || getContext() == null) {
            return;
        }
        createTopPanel();
        if (this.topChatPanelView == null) {
            return;
        }
        View view = new TranslateButton(getContext(), this, this.themeDelegate) {
            protected void onButtonClick() {
                ChatActivity chatActivity;
                TLRPC.Chat chat;
                if (ChatActivity.this.getUserConfig().isPremium() || ((chat = (chatActivity = ChatActivity.this).currentChat) != null && chat.autotranslation)) {
                    ChatActivity.this.getMessagesController().getTranslateController().toggleTranslatingDialog(ChatActivity.this.getDialogId());
                } else {
                    MessagesController.getNotificationsSettings(((BaseFragment) chatActivity).currentAccount).edit().putInt("dialog_show_translate_count" + ChatActivity.this.getDialogId(), 14).commit();
                    ChatActivity.this.showDialog(new PremiumFeatureBottomSheet(ChatActivity.this, 13, false));
                }
                ChatActivity.this.updateTopPanel(true);
            }

            protected void onCloseClick() {
                MessagesController.getNotificationsSettings(((BaseFragment) ChatActivity.this).currentAccount).edit().putInt("dialog_show_translate_count" + ChatActivity.this.getDialogId(), 140).commit();
                ChatActivity.this.updateTopPanel(true);
            }
        };
        this.translateButton = view;
        this.topChatPanelView.addView(view, LayoutHelper.createFrame(-1, 36.0f, 83, 0.0f, 0.0f, 0.0f, 2.0f));
        this.translateButton.setLeftMargin(getSideMenuWidth());
    }

    public void createUndoView() {
        if (this.undoView != null || getContext() == null) {
            return;
        }
        UndoView undoView = new UndoView(getContext(), this, false, this.themeDelegate);
        this.undoView = undoView;
        undoView.setAdditionalTranslationY(AndroidUtilities.dp(51.0f));
        this.contentView.addView(this.undoView, LayoutHelper.createFrame(-1, -2.0f, 83, 8.0f, 0.0f, 8.0f, 8.0f));
    }

    public ArrayList createVoiceMessagesPlaylist(MessageObject messageObject, boolean z) {
        ArrayList arrayList = new ArrayList();
        arrayList.add(messageObject);
        int id = messageObject.getId();
        messageObject.getDialogId();
        if (id != 0) {
            for (int size = this.messages.size() - 1; size >= 0; size--) {
                MessageObject messageObject2 = (MessageObject) this.messages.get(size);
                if ((messageObject2.getDialogId() != this.mergeDialogId || messageObject.getDialogId() == this.mergeDialogId) && (((this.currentEncryptedChat == null && messageObject2.getId() > id) || (this.currentEncryptedChat != null && messageObject2.getId() < id)) && ((messageObject2.isVoice() || messageObject2.isRoundVideo()) && !messageObject2.isVoiceOnce() && !messageObject2.isRoundOnce() && (!z || (messageObject2.isContentUnread() && !messageObject2.isOut()))))) {
                    arrayList.add(messageObject2);
                }
            }
        }
        return arrayList;
    }

    public void lambda$new$0() {
        FrameLayout frameLayout = this.videoPlayerContainer;
        if (frameLayout == null || frameLayout.getParent() == null) {
            return;
        }
        this.chatListView.invalidateViews();
        this.aspectRatioFrameLayout.setDrawingReady(false);
        this.videoPlayerContainer.setTag(null);
        if (Build.VERSION.SDK_INT < 21) {
            this.videoPlayerContainer.setLayerType(0, null);
        }
        this.contentView.removeView(this.videoPlayerContainer);
    }

    public void didPressMessageUrl(android.text.style.CharacterStyle r15, boolean r16, org.telegram.messenger.MessageObject r17, org.telegram.ui.Cells.ChatMessageCell r18) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.didPressMessageUrl(android.text.style.CharacterStyle, boolean, org.telegram.messenger.MessageObject, org.telegram.ui.Cells.ChatMessageCell):void");
    }

    private void dimBehindView(float f, boolean z, boolean z2) {
        ValueAnimator ofFloat;
        final boolean z3 = f > 0.0f;
        View view = this.scrimView;
        if (view instanceof ChatMessageCell) {
            ChatMessageCell chatMessageCell = (ChatMessageCell) view;
            chatMessageCell.setInvalidatesParent(z3);
            if (z3) {
                restartSticker(chatMessageCell);
            }
        }
        this.contentView.invalidate();
        this.chatListView.invalidate();
        AnimatorSet animatorSet = this.scrimAnimatorSet;
        if (animatorSet != null) {
            animatorSet.removeAllListeners();
            this.scrimAnimatorSet.cancel();
        }
        this.scrimAnimatorSet = new AnimatorSet();
        ArrayList arrayList = new ArrayList();
        final float max = Math.max(this.scrimPaintAlpha, f);
        if (z3) {
            this.scrimViewAlpha = 1.0f;
            this.scrimViewProgress = 0.0f;
            ValueAnimator valueAnimator = this.scrimViewAlphaAnimator;
            if (valueAnimator != null) {
                valueAnimator.cancel();
            }
            this.scrimProgressDirection = true;
            ofFloat = ValueAnimator.ofFloat(0.0f, f);
            arrayList.add(ofFloat);
            if (z) {
                AndroidUtilities.makeGlobalBlurBitmap(new Utilities.Callback() {
                    public final void run(Object obj) {
                        ChatActivity.this.lambda$dimBehindView$100((Bitmap) obj);
                    }
                }, 14.0f);
            }
        } else {
            float f2 = this.scrimPaintAlpha;
            this.scrimViewProgress = f2 / max;
            this.scrimProgressDirection = false;
            ofFloat = ValueAnimator.ofFloat(f2, 0.0f);
            arrayList.add(ofFloat);
        }
        ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public final void onAnimationUpdate(ValueAnimator valueAnimator2) {
                ChatActivity.this.lambda$dimBehindView$101(max, valueAnimator2);
            }
        });
        if (!z3 || z2) {
            FrameLayout frameLayout = this.pagedownButton;
            if (frameLayout != null) {
                arrayList.add(ObjectAnimator.ofFloat(frameLayout, (Property<FrameLayout, Float>) View.ALPHA, z3 ? 0.0f : 1.0f));
            }
            FrameLayout frameLayout2 = this.mentiondownButton;
            if (frameLayout2 != null) {
                arrayList.add(ObjectAnimator.ofFloat(frameLayout2, (Property<FrameLayout, Float>) View.ALPHA, z3 ? 0.0f : 1.0f));
            }
            FrameLayout frameLayout3 = this.reactionsMentiondownButton;
            if (frameLayout3 != null) {
                arrayList.add(ObjectAnimator.ofFloat(frameLayout3, (Property<FrameLayout, Float>) View.ALPHA, z3 ? 0.0f : 1.0f));
            }
        }
        this.scrimAnimatorSet.playTogether(arrayList);
        this.scrimAnimatorSet.setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT);
        this.scrimAnimatorSet.setDuration(320L);
        View view2 = this.scrimView;
        final ChatMessageCell chatMessageCell2 = view2 instanceof ChatMessageCell ? (ChatMessageCell) view2 : null;
        this.scrimAnimatorSet.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animator) {
                if (z3) {
                    return;
                }
                if (ChatActivity.this.scrimBlurBitmap != null) {
                    ChatActivity.this.scrimBlurBitmapShader = null;
                    ChatActivity.this.scrimBlurBitmapPaint = null;
                    ChatActivity.this.scrimBlurBitmap.recycle();
                    ChatActivity.this.scrimBlurBitmap = null;
                }
                ChatMessageCell chatMessageCell3 = chatMessageCell2;
                if (chatMessageCell3 != null) {
                    chatMessageCell3.invalidate();
                }
                ChatActivity.this.setScrimView(null);
                ChatActivity.this.scrimViewTask = null;
                ChatActivity.this.scrimViewReaction = null;
                ChatActivity.this.contentView.invalidate();
                ChatActivity.this.chatListView.invalidate();
            }
        });
        if (this.scrimView != null && this.scrimViewAlpha <= 0.0f) {
            setScrimView(null);
        }
        this.scrimAnimatorSet.start();
    }

    public void dimBehindView(View view, float f) {
        setScrimView(view);
        dimBehindView(f, false, (view == this.reactionsMentiondownButton || view == this.mentiondownButton) ? false : true);
    }

    private void dimBehindView(View view, boolean z) {
        dimBehindView(view, false, z);
    }

    private void dimBehindView(View view, boolean z, boolean z2) {
        setScrimView(view);
        dimBehindView(z2 ? 0.2f : 0.0f, z, (view == this.reactionsMentiondownButton || view == this.mentiondownButton) ? false : true);
    }

    private void editResetMediaManual() {
        TLRPC.Message message;
        TLRPC.MessageMedia messageMedia;
        MessageObject messageObject = this.editingMessageObject;
        if (messageObject == null || (message = messageObject.messageOwner) == null || (messageMedia = message.media) == null) {
            return;
        }
        messageMedia.manual = false;
    }

    public static void fillActionModeMenu(Menu menu, TLRPC.EncryptedChat encryptedChat, boolean z) {
        int i;
        int i2 = R.id.menu_bold;
        if (menu.findItem(i2) != null) {
            return;
        }
        if (Build.VERSION.SDK_INT >= 23) {
            menu.removeItem(android.R.id.shareText);
        }
        if (z) {
            menu.add(R.id.menu_groupbolditalic, R.id.menu_quote, 6, LocaleController.getString(R.string.Quote));
            i = 7;
        } else {
            i = 6;
        }
        int i3 = R.id.menu_groupbolditalic;
        menu.add(i3, R.id.menu_spoiler, i, LocaleController.getString(R.string.Spoiler));
        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(LocaleController.getString(R.string.Bold));
        spannableStringBuilder.setSpan(new TypefaceSpan(AndroidUtilities.bold()), 0, spannableStringBuilder.length(), 33);
        menu.add(i3, i2, i + 1, spannableStringBuilder);
        SpannableStringBuilder spannableStringBuilder2 = new SpannableStringBuilder(LocaleController.getString(R.string.Italic));
        spannableStringBuilder2.setSpan(new TypefaceSpan(AndroidUtilities.getTypeface("fonts/ritalic.ttf")), 0, spannableStringBuilder2.length(), 33);
        menu.add(i3, R.id.menu_italic, i + 2, spannableStringBuilder2);
        SpannableStringBuilder spannableStringBuilder3 = new SpannableStringBuilder(LocaleController.getString(R.string.Mono));
        spannableStringBuilder3.setSpan(new TypefaceSpan(Typeface.MONOSPACE), 0, spannableStringBuilder3.length(), 33);
        int i4 = i + 4;
        menu.add(i3, R.id.menu_mono, i + 3, spannableStringBuilder3);
        if (encryptedChat == null || AndroidUtilities.getPeerLayerVersion(encryptedChat.layer) >= 101) {
            SpannableStringBuilder spannableStringBuilder4 = new SpannableStringBuilder(LocaleController.getString(R.string.Strike));
            TextStyleSpan.TextStyleRun textStyleRun = new TextStyleSpan.TextStyleRun();
            textStyleRun.flags |= 8;
            spannableStringBuilder4.setSpan(new TextStyleSpan(textStyleRun), 0, spannableStringBuilder4.length(), 33);
            menu.add(i3, R.id.menu_strike, i4, spannableStringBuilder4);
            SpannableStringBuilder spannableStringBuilder5 = new SpannableStringBuilder(LocaleController.getString(R.string.Underline));
            TextStyleSpan.TextStyleRun textStyleRun2 = new TextStyleSpan.TextStyleRun();
            textStyleRun2.flags |= 16;
            spannableStringBuilder5.setSpan(new TextStyleSpan(textStyleRun2), 0, spannableStringBuilder5.length(), 33);
            i4 = i + 6;
            menu.add(i3, R.id.menu_underline, i + 5, spannableStringBuilder5);
        }
        menu.add(i3, R.id.menu_link, i4, LocaleController.getString(R.string.CreateLink));
        menu.add(i3, R.id.menu_regular, i4 + 1, LocaleController.getString(R.string.Regular));
    }

    public void fillEditingMediaWithCaption(CharSequence charSequence, ArrayList arrayList) {
        if (this.editingMessageObject == null) {
            return;
        }
        if (!TextUtils.isEmpty(charSequence)) {
            MessageObject messageObject = this.editingMessageObject;
            messageObject.editingMessage = charSequence;
            messageObject.editingMessageEntities = arrayList;
            return;
        }
        if (this.editingMessageObject.isMediaEmpty()) {
            MessageObject messageObject2 = this.editingMessageObject;
            messageObject2.editingMessage = "";
            messageObject2.editingMessageEntities = new ArrayList();
            return;
        }
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView != null) {
            this.editingMessageObject.editingMessage = chatActivityEnterView.getFieldText();
            MessageObject messageObject3 = this.editingMessageObject;
            if (messageObject3.editingMessage != null || TextUtils.isEmpty(messageObject3.messageOwner.message)) {
                return;
            }
            this.editingMessageObject.editingMessage = "";
        }
    }

    private void fillInviterId(boolean z) {
        long j;
        TLRPC.Chat chat = this.currentChat;
        if (chat == null || this.chatInfo == null || ChatObject.isNotInChat(chat) || this.currentChat.creator) {
            return;
        }
        TLRPC.ChatFull chatFull = this.chatInfo;
        long j2 = chatFull.inviterId;
        if (j2 != 0) {
            this.chatInviterId = j2;
            return;
        }
        TLRPC.ChatParticipants chatParticipants = chatFull.participants;
        if (chatParticipants != null) {
            TLRPC.ChatParticipant chatParticipant = chatParticipants.self_participant;
            if (chatParticipant != null) {
                j = chatParticipant.inviter_id;
            } else {
                long clientUserId = getUserConfig().getClientUserId();
                int size = this.chatInfo.participants.participants.size();
                for (int i = 0; i < size; i++) {
                    TLRPC.ChatParticipant chatParticipant2 = (TLRPC.ChatParticipant) this.chatInfo.participants.participants.get(i);
                    if (chatParticipant2.user_id == clientUserId) {
                        j = chatParticipant2.inviter_id;
                    }
                }
            }
            this.chatInviterId = j;
            return;
        }
        if (z && this.chatInviterId == 0) {
            getMessagesController().checkChatInviter(this.currentChat.id, false);
        }
    }

    private int findAdPlace() {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.findAdPlace():int");
    }

    private Integer findClosest(ArrayList arrayList, int i, int[] iArr) {
        if (arrayList.isEmpty()) {
            return 0;
        }
        Integer num = (Integer) arrayList.get(0);
        if (i >= num.intValue()) {
            iArr[0] = 0;
            return num;
        }
        int size = arrayList.size();
        int i2 = size - 1;
        Integer num2 = (Integer) arrayList.get(i2);
        if (i <= num2.intValue()) {
            iArr[0] = i2;
            return num2;
        }
        int i3 = 0;
        int i4 = 0;
        while (i3 < size) {
            i4 = (i3 + size) / 2;
            Integer num3 = (Integer) arrayList.get(i4);
            if (num3.intValue() == i) {
                iArr[0] = i4;
                return num3;
            }
            if (i < num3.intValue()) {
                if (i4 > 0) {
                    int i5 = i4 - 1;
                    Integer num4 = (Integer) arrayList.get(i5);
                    if (i > num4.intValue()) {
                        iArr[0] = i5;
                        return num4;
                    }
                }
                i3 = i4 + 1;
            } else {
                if (i4 > 0 && i < ((Integer) arrayList.get(i4 - 1)).intValue()) {
                    iArr[0] = i4;
                    return num3;
                }
                size = i4;
            }
        }
        iArr[0] = i4;
        return (Integer) arrayList.get(i4);
    }

    private void fixLayout() {
        ChatAvatarContainer chatAvatarContainer = this.avatarContainer;
        if (chatAvatarContainer != null) {
            chatAvatarContainer.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
                @Override
                public boolean onPreDraw() {
                    ChatAvatarContainer chatAvatarContainer2 = ChatActivity.this.avatarContainer;
                    if (chatAvatarContainer2 != null) {
                        chatAvatarContainer2.getViewTreeObserver().removeOnPreDrawListener(this);
                    }
                    return ChatActivity.this.fixLayoutInternal();
                }
            });
        }
    }

    public boolean fixLayoutInternal() {
        boolean z;
        ActionBar actionBar;
        BackDrawable backDrawable;
        MessageObject.GroupedMessages currentMessagesGroup;
        NumberTextView numberTextView = this.selectedMessagesCountTextView;
        if (numberTextView != null) {
            numberTextView.setTextSize((AndroidUtilities.isTablet() || ApplicationLoader.applicationContext.getResources().getConfiguration().orientation != 2) ? 20 : 18);
        }
        int childCount = this.chatListView.getChildCount();
        HashMap hashMap = null;
        int i = 0;
        while (true) {
            z = true;
            if (i >= childCount) {
                break;
            }
            View childAt = this.chatListView.getChildAt(i);
            if ((childAt instanceof ChatMessageCell) && (currentMessagesGroup = ((ChatMessageCell) childAt).getCurrentMessagesGroup()) != null && currentMessagesGroup.hasSibling && !currentMessagesGroup.messages.isEmpty()) {
                if (hashMap == null) {
                    hashMap = new HashMap();
                }
                if (!hashMap.containsKey(Long.valueOf(currentMessagesGroup.groupId))) {
                    hashMap.put(Long.valueOf(currentMessagesGroup.groupId), currentMessagesGroup);
                    ArrayList arrayList = currentMessagesGroup.messages;
                    int indexOf = this.messages.indexOf((MessageObject) arrayList.get(arrayList.size() - 1));
                    if (indexOf >= 0) {
                        ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
                        chatActivityAdapter.notifyItemRangeChanged(indexOf + chatActivityAdapter.messagesStartRow, currentMessagesGroup.messages.size());
                        this.chatListView.setItemAnimator((RecyclerView.ItemAnimator) null);
                    }
                }
            }
            i++;
        }
        if (!AndroidUtilities.isTablet()) {
            return true;
        }
        if (AndroidUtilities.isSmallTablet() && ApplicationLoader.applicationContext.getResources().getConfiguration().orientation == 1) {
            actionBar = ((BaseFragment) this).actionBar;
            backDrawable = new BackDrawable(false);
        } else {
            actionBar = ((BaseFragment) this).actionBar;
            INavigationLayout iNavigationLayout = ((BaseFragment) this).parentLayout;
            if (iNavigationLayout != null && !iNavigationLayout.getFragmentStack().isEmpty() && ((BaseFragment) this).parentLayout.getFragmentStack().get(0) != this && ((BaseFragment) this).parentLayout.getFragmentStack().size() != 1) {
                z = false;
            }
            backDrawable = new BackDrawable(z);
        }
        actionBar.setBackButtonDrawable(backDrawable);
        return false;
    }

    private void forwardMessages(ArrayList arrayList, boolean z, boolean z2, boolean z3, int i, long j) {
        if (arrayList == null || arrayList.isEmpty() || !checkSlowModeAlert()) {
            return;
        }
        if ((i != 0) == (this.chatMode == 1)) {
            this.waitingForSendingMessageLoad = true;
        }
        int sendMessage = getSendMessagesHelper().sendMessage(arrayList, this.dialog_id, z, z2, z3, i, getThreadMessage(), -1, j, getSendMonoForumPeerId(), getSendMessageSuggestionParams());
        AlertsCreator.showSendMediaAlert(sendMessage, this, this.themeDelegate);
        if (sendMessage != 0) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$forwardMessages$140();
                }
            });
        }
    }

    private int getHeightForMessage(MessageObject messageObject, boolean z) {
        boolean z2 = false;
        if (getParentActivity() == null) {
            return 0;
        }
        if (this.dummyMessageCell == null) {
            this.dummyMessageCell = new ChatMessageCell(getParentActivity(), ((BaseFragment) this).currentAccount, true, this.sharedResources, this.themeDelegate);
        }
        this.dummyMessageCell.isChat = this.currentChat != null || UserObject.isUserSelf(this.currentUser);
        ChatMessageCell chatMessageCell = this.dummyMessageCell;
        int i = this.chatMode;
        chatMessageCell.isSavedChat = i == 3;
        chatMessageCell.isSavedPreviewChat = i == 3 && this.isInsideContainer;
        TLRPC.User user = this.currentUser;
        chatMessageCell.isBot = user != null && user.bot;
        if (ChatObject.isChannel(this.currentChat) && this.currentChat.megagroup) {
            z2 = true;
        }
        chatMessageCell.isMegagroup = z2;
        this.dummyMessageCell.isAllChats = isAllChats();
        this.dummyMessageCell.isSideMenued = isSideMenued();
        this.dummyMessageCell.isSideMenuEnabled = isSideMenuEnabled();
        return this.dummyMessageCell.computeHeight(messageObject, (MessageObject.GroupedMessages) this.groupedMessagesMap.get(messageObject.getGroupId()), z);
    }

    private boolean getLiteModeChat() {
        if (this.liteModeChat == null) {
            this.liteModeChat = Boolean.valueOf(LiteMode.isEnabled(98784));
        }
        return this.liteModeChat.booleanValue();
    }

    private CharSequence getMessageCaption(MessageObject messageObject, MessageObject.GroupedMessages groupedMessages) {
        return getMessageCaption(messageObject, groupedMessages, null);
    }

    public static CharSequence getMessageCaption(MessageObject messageObject, MessageObject.GroupedMessages groupedMessages, int[] iArr) {
        if (messageObject == null) {
            return null;
        }
        String restrictionReason = MessagesController.getInstance(messageObject.currentAccount).getRestrictionReason(messageObject.messageOwner.restriction_reason);
        if (!TextUtils.isEmpty(restrictionReason)) {
            return restrictionReason;
        }
        if (messageObject.isVoiceTranscriptionOpen() && !TranscribeButton.isTranscribing(messageObject)) {
            return messageObject.getVoiceTranscription();
        }
        CharSequence charSequence = messageObject.caption;
        if (charSequence != null) {
            return charSequence;
        }
        if (groupedMessages == null) {
            return null;
        }
        int size = groupedMessages.messages.size();
        CharSequence charSequence2 = null;
        for (int i = 0; i < size; i++) {
            MessageObject messageObject2 = (MessageObject) groupedMessages.messages.get(i);
            CharSequence charSequence3 = messageObject2.caption;
            if (charSequence3 != null) {
                if (charSequence2 != null) {
                    return null;
                }
                if (iArr != null) {
                    iArr[0] = messageObject2.getId();
                }
                charSequence2 = charSequence3;
            }
        }
        return charSequence2;
    }

    public static CharSequence getMessageContent(MessageObject messageObject, long j, boolean z) {
        TLRPC.Chat chat;
        String str;
        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
        if (z) {
            long fromChatId = messageObject.getFromChatId();
            if (j != fromChatId) {
                if (fromChatId > 0) {
                    TLRPC.User user = MessagesController.getInstance(messageObject.currentAccount).getUser(Long.valueOf(fromChatId));
                    if (user != null) {
                        str = ContactsController.formatName(user.first_name, user.last_name);
                        spannableStringBuilder.append((CharSequence) str).append((CharSequence) ":\n");
                    }
                } else if (fromChatId < 0 && (chat = MessagesController.getInstance(messageObject.currentAccount).getChat(Long.valueOf(-fromChatId))) != null) {
                    str = chat.title;
                    spannableStringBuilder.append((CharSequence) str).append((CharSequence) ":\n");
                }
            }
        }
        CharSequence restrictionReason = MessagesController.getInstance(messageObject.currentAccount).getRestrictionReason(messageObject.messageOwner.restriction_reason);
        if (TextUtils.isEmpty(restrictionReason) && (restrictionReason = messageObject.caption) == null) {
            spannableStringBuilder.append(messageObject.messageText);
        } else {
            spannableStringBuilder.append(restrictionReason);
        }
        return spannableStringBuilder;
    }

    public int getMessageType(MessageObject messageObject) {
        String str;
        String str2;
        if (messageObject == null) {
            return -1;
        }
        boolean z = false;
        if (this.currentEncryptedChat != null) {
            if (messageObject.isSending()) {
                return -1;
            }
            if (messageObject.isAnimatedEmoji()) {
                return 2;
            }
            if (messageObject.type == 6) {
                return -1;
            }
            if (messageObject.isSendError()) {
                return !messageObject.isMediaEmpty() ? 0 : 20;
            }
            int i = messageObject.type;
            if (i == 10 || i == 11) {
                return (messageObject.getId() == 0 || messageObject.isSending()) ? -1 : 1;
            }
            if (messageObject.isVoice()) {
                return 2;
            }
            if (!messageObject.isAnimatedEmoji() && (messageObject.isSticker() || messageObject.isAnimatedSticker())) {
                TLRPC.InputStickerSet inputStickerSet = messageObject.getInputStickerSet();
                if ((inputStickerSet instanceof TLRPC.TL_inputStickerSetShortName) && !getMediaDataController().isStickerPackInstalled(inputStickerSet.short_name)) {
                    return 7;
                }
            } else if (!messageObject.isRoundVideo() && ((messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) || messageObject.getDocument() != null || messageObject.isMusic() || messageObject.isVideo())) {
                if (!TextUtils.isEmpty(messageObject.messageOwner.attachPath) && new File(messageObject.messageOwner.attachPath).exists()) {
                    z = true;
                }
                if ((z || !FileLoader.getInstance(((BaseFragment) this).currentAccount).getPathToMessage(messageObject.messageOwner).exists()) ? z : true) {
                    if (messageObject.getDocument() != null && (str = messageObject.getDocument().mime_type) != null && str.endsWith("text/xml")) {
                        return 5;
                    }
                    if (messageObject.messageOwner.ttl <= 0) {
                        return 4;
                    }
                }
            } else {
                if (messageObject.type == 12) {
                    return 8;
                }
                if (messageObject.isMediaEmpty()) {
                    return 3;
                }
            }
            return 2;
        }
        if (messageObject.isEditing()) {
            return -1;
        }
        if (messageObject.getId() <= 0 && messageObject.isOut()) {
            if (messageObject.isSendError()) {
                return !messageObject.isMediaEmpty() ? 0 : 20;
            }
            return -1;
        }
        if (messageObject.isAnimatedEmoji()) {
            return 2;
        }
        int i2 = messageObject.type;
        if (i2 == 6) {
            return -1;
        }
        if (i2 == 10 || i2 == 11 || i2 == 21 || i2 == 30 || messageObject.isWallpaperAction()) {
            return messageObject.getId() == 0 ? -1 : 1;
        }
        if (messageObject.isVoice()) {
            return 2;
        }
        if (messageObject.isSticker() || messageObject.isAnimatedSticker()) {
            TLRPC.InputStickerSet inputStickerSet2 = messageObject.getInputStickerSet();
            return inputStickerSet2 instanceof TLRPC.TL_inputStickerSetID ? !getMediaDataController().isStickerPackInstalled(inputStickerSet2.id) ? 7 : 9 : (!(inputStickerSet2 instanceof TLRPC.TL_inputStickerSetShortName) || getMediaDataController().isStickerPackInstalled(inputStickerSet2.short_name)) ? 9 : 7;
        }
        if (!messageObject.isRoundVideo() && ((messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) || messageObject.getDocument() != null || messageObject.isMusic() || messageObject.isVideo())) {
            if (!TextUtils.isEmpty(messageObject.messageOwner.attachPath) && new File(messageObject.messageOwner.attachPath).exists()) {
                z = true;
            }
            if ((z || !messageObject.mediaExists()) ? z : true) {
                if (messageObject.getDocument() != null && !messageObject.isMusic() && (str2 = messageObject.getDocument().mime_type) != null) {
                    if (messageObject.getDocumentName().toLowerCase().endsWith("attheme")) {
                        return 10;
                    }
                    if (str2.endsWith("/xml")) {
                        return 5;
                    }
                    if ((!messageObject.isNewGif() && str2.endsWith("/mp4")) || str2.endsWith("/png") || str2.endsWith("/jpg") || str2.endsWith("/jpeg")) {
                        return 6;
                    }
                }
                return 4;
            }
        } else {
            if (messageObject.type == 12) {
                return 8;
            }
            if (messageObject.isMediaEmpty()) {
                return 3;
            }
        }
        return 2;
    }

    public MessageSkeleton getNewSkeleton(boolean z) {
        MessageSkeleton messageSkeleton = new MessageSkeleton();
        TLRPC.Chat chat = this.currentChat;
        messageSkeleton.height = ((chat == null || !ChatObject.isChannelAndNotMegaGroup(chat)) ? AndroidUtilities.dp(64.0f) : AndroidUtilities.dp(128.0f)) + Utilities.fastRandom.nextInt(AndroidUtilities.dp(64.0f));
        messageSkeleton.width = (int) Math.min((this.chatListView.getWidth() * 0.8f) - (z ? 0 : AndroidUtilities.dp(42.0f)), AndroidUtilities.dp(42.0f) + (((Utilities.fastRandom.nextFloat() * 0.35f) + 0.4f) * this.chatListView.getWidth()));
        return messageSkeleton;
    }

    public int getPinnedMessagesCount() {
        return Math.max(this.loadedPinnedMessagesCount, this.totalPinnedMessagesCount);
    }

    public org.telegram.ui.PhotoViewer.PlaceProviderObject getPlaceForPhoto(org.telegram.messenger.MessageObject r17, org.telegram.tgnet.TLRPC.FileLocation r18, int r19, boolean r20, boolean r21) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.getPlaceForPhoto(org.telegram.messenger.MessageObject, org.telegram.tgnet.TLRPC$FileLocation, int, boolean, boolean):org.telegram.ui.PhotoViewer$PlaceProviderObject");
    }

    private int getScrollOffsetForMessage(int i) {
        return (int) Math.max(-AndroidUtilities.dp(2.0f), (((this.chatListView.getMeasuredHeight() - this.blurredViewBottomOffset) - this.chatListViewPaddingTop) - i) / 2.0f);
    }

    private int getScrollOffsetForMessage(MessageObject messageObject) {
        return getScrollOffsetForMessage(getHeightForMessage(messageObject, !TextUtils.isEmpty(this.highlightMessageQuote))) - scrollOffsetForQuote(messageObject);
    }

    public int getScrollingOffsetForView(View view) {
        FileLog.d("getScrollingOffsetForView view=" + view + " results in {" + ((this.chatListView.getMeasuredHeight() - view.getBottom()) - this.chatListView.getPaddingBottom()) + "} chatHeight=" + this.chatListView.getMeasuredHeight() + " bottom=" + view.getBottom() + " paddingBottom=" + this.chatListView.getPaddingBottom());
        return (this.chatListView.getMeasuredHeight() - view.getBottom()) - this.chatListView.getPaddingBottom();
    }

    private SearchItemListener getSearchItemListener() {
        if (this.searchItemListener == null) {
            this.searchItemListener = new SearchItemListener();
        }
        return this.searchItemListener;
    }

    public float getServiceTop(View view) {
        return ((view.getY() + (isKeyboardVisible() ? this.chatListView.getTop() : ((BaseFragment) this).actionBar.getMeasuredHeight())) - this.contentView.getBackgroundTranslationY()) - ((1.0f - this.contentPanTranslationT) * this.chatListViewPaddingTop);
    }

    public float getSideMenuAlpha() {
        TopicsTabsView topicsTabsView = this.topicsTabs;
        if (topicsTabsView != null) {
            return topicsTabsView.sidemenuT;
        }
        return 0.0f;
    }

    public int getSideMenuWidth() {
        return (int) (AndroidUtilities.dp(64.0f) * getSideMenuAlpha());
    }

    private int getSponsoredMessagesCount() {
        int i = 0;
        while (i < this.messages.size() && ((MessageObject) this.messages.get(i)).isSponsored()) {
            i++;
        }
        return i;
    }

    private int getStableIdForConversionObject(int i) {
        int i2 = this.conversionObjectsStableIds.get(i, -1);
        if (i2 != -1) {
            return i2;
        }
        int i3 = lastStableId;
        lastStableId = i3 + 1;
        this.conversionObjectsStableIds.put(i, i3);
        return i3;
    }

    private int getStableIdForDateObject(int i) {
        int i2 = this.dateObjectsStableIds.get(i, -1);
        if (i2 != -1) {
            return i2;
        }
        int i3 = lastStableId;
        lastStableId = i3 + 1;
        this.dateObjectsStableIds.put(i, i3);
        return i3;
    }

    private void gotChatInfo() {
        TLRPC.ChatFull chatFull = this.chatInfo;
        if (chatFull != null && chatFull.paid_reactions_available) {
            getMessagesController().getPaidReactionsDialogId();
            if (!StarsController.getInstance(((BaseFragment) this).currentAccount).balanceAvailable()) {
                StarsController.getInstance(((BaseFragment) this).currentAccount).getBalance();
            }
        }
        TLRPC.ChatFull chatFull2 = this.chatInfo;
        if (chatFull2 != null && chatFull2.bot_verification != null) {
            updateTopPanel(true);
        }
        TLRPC.ChatFull chatFull3 = this.chatInfo;
        if (chatFull3 != null) {
            boolean z = chatFull3.stargifts_available;
            ImageView imageView = this.bottomGiftButton;
            boolean z2 = z != (imageView != null && imageView.getVisibility() == 0);
            TLRPC.Chat chat = this.currentChat;
            boolean z3 = (chat == null || !chat.broadcast_messages_allowed || chat.linked_monoforum_id == 0) ? false : true;
            ImageView imageView2 = this.bottomSuggestButton;
            boolean z4 = z3 != (imageView2 != null && imageView2.getVisibility() == 0);
            if (z2 || z4) {
                updateBottomOverlay(true);
            }
        }
    }

    private boolean hasSelectedNoforwardsMessage() {
        TLRPC.Message message;
        for (int i = 0; i < this.selectedMessagesIds.length; i++) {
            try {
                for (int i2 = 0; i2 < this.selectedMessagesIds[i].size(); i2++) {
                    MessageObject messageObject = (MessageObject) this.selectedMessagesIds[i].valueAt(i2);
                    if (messageObject != null && (message = messageObject.messageOwner) != null && message.noforwards) {
                        return true;
                    }
                }
            } catch (Exception unused) {
            }
        }
        return false;
    }

    public void hideActionMode() {
        EditTextCaption editField;
        ActionBar actionBar = ((BaseFragment) this).actionBar;
        if (actionBar != null) {
            if (!actionBar.isActionModeShowed()) {
                return;
            } else {
                ((BaseFragment) this).actionBar.hideActionMode();
            }
        }
        this.cantDeleteMessagesCount = 0;
        this.canEditMessagesCount = 0;
        this.cantForwardMessagesCount = 0;
        this.canSaveMusicCount = 0;
        this.canSaveDocumentsCount = 0;
        this.cantSaveMessagesCount = 0;
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView != null && (editField = chatActivityEnterView.getEditField()) != null) {
            if (this.chatActivityEnterView.getVisibility() == 0) {
                editField.requestFocus();
            }
            editField.setAllowDrawCursor(true);
        }
        ChatActivityTextSelectionHelper chatActivityTextSelectionHelper = this.textSelectionHelper;
        if (chatActivityTextSelectionHelper != null) {
            chatActivityTextSelectionHelper.clear(true);
            this.textSelectionHelper.cancelAllAnimators();
        }
        TextSelectionHint textSelectionHint = this.textSelectionHint;
        if (textSelectionHint != null) {
            textSelectionHint.hide();
        }
        ChatActivityEnterView chatActivityEnterView2 = this.chatActivityEnterView;
        if (chatActivityEnterView2 != null) {
            chatActivityEnterView2.preventInput = false;
        }
        this.textSelectionHintWasShowed = false;
        if (this.tagSelector != null) {
            hideTagSelector();
        }
    }

    public void hideAds() {
        if (!getUserConfig().isPremium()) {
            showDialog(new PremiumFeatureBottomSheet(this, 3, true));
            return;
        }
        BulletinFactory.of(this).createAdReportedBulletin(LocaleController.getString(R.string.AdHidden)).show();
        getMessagesController().disableAds(true);
        removeFromSponsored(this.selectedObject);
        removeMessageWithThanos(this.selectedObject);
    }

    public void hideFloatingDateView(boolean z) {
        if (this.floatingDateView.getTag() == null || this.currentFloatingDateOnScreen) {
            return;
        }
        if (!this.scrollingFloatingDate || this.currentFloatingTopIsNotMessage) {
            this.floatingDateView.setTag(null);
            if (z) {
                AnimatorSet animatorSet = new AnimatorSet();
                this.floatingDateAnimation = animatorSet;
                animatorSet.setDuration(150L);
                this.floatingDateAnimation.playTogether(ObjectAnimator.ofFloat(this.floatingDateView, (Property<ChatActionCell, Float>) View.ALPHA, 0.0f));
                this.floatingDateAnimation.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animator) {
                        if (animator.equals(ChatActivity.this.floatingDateAnimation)) {
                            ChatActivity.this.floatingDateAnimation = null;
                        }
                    }
                });
                this.floatingDateAnimation.setStartDelay(this.hideDateDelay);
                this.floatingDateAnimation.start();
            } else {
                AnimatorSet animatorSet2 = this.floatingDateAnimation;
                if (animatorSet2 != null) {
                    animatorSet2.cancel();
                    this.floatingDateAnimation = null;
                }
                this.floatingDateView.setAlpha(0.0f);
            }
            this.hideDateDelay = 500;
        }
    }

    public void hideFloatingTopicView(boolean z) {
        if (this.floatingTopicSeparator.getTag() == null || this.currentFloatingTopicOnScreen) {
            return;
        }
        if (!this.scrollingFloatingTopic || this.currentFloatingTopIsNotMessage) {
            this.floatingTopicSeparator.setTag(null);
            if (z) {
                ValueAnimator ofFloat = ValueAnimator.ofFloat(this.floatingTopicViewAlpha, 0.0f);
                this.floatingTopicAnimation = ofFloat;
                ofFloat.setDuration(150L);
                this.floatingTopicAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                    @Override
                    public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                        ChatActivity.this.lambda$hideFloatingTopicView$123(valueAnimator);
                    }
                });
                this.floatingTopicAnimation.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animator) {
                        if (animator.equals(ChatActivity.this.floatingTopicAnimation)) {
                            ChatActivity.this.floatingTopicViewAlpha = 0.0f;
                            ChatActivity.this.updateFloatingTopicView();
                            ChatActivity.this.floatingTopicAnimation = null;
                        }
                    }
                });
                this.floatingTopicAnimation.setStartDelay(this.hideDateDelay);
                this.floatingTopicAnimation.start();
            } else {
                ValueAnimator valueAnimator = this.floatingTopicAnimation;
                if (valueAnimator != null) {
                    valueAnimator.cancel();
                    this.floatingTopicAnimation = null;
                }
                this.floatingTopicViewAlpha = 0.0f;
                updateFloatingTopicView();
            }
            this.hideDateDelay = 500;
        }
    }

    private void hideHints() {
        HintView2 hintView2 = this.savedMessagesTagHint;
        if (hintView2 != null && hintView2.shown()) {
            this.savedMessagesTagHint.hide();
        }
        HintView2 hintView22 = this.videoConversionTimeHint;
        if (hintView22 != null && hintView22.shown()) {
            this.videoConversionTimeHint.hide();
        }
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView != null) {
            chatActivityEnterView.hideHints();
        }
    }

    public void hideHints(boolean z) {
        if (!z) {
            HintView hintView = this.slowModeHint;
            if (hintView != null) {
                hintView.hide();
            }
            HintView hintView2 = this.scheduledOrNoSoundHint;
            if (hintView2 != null) {
                hintView2.hide();
            }
            HintView hintView3 = this.scheduledHint;
            if (hintView3 != null) {
                hintView3.hide();
            }
        }
        HintView hintView4 = this.fwdRestrictedBottomHint;
        if (hintView4 != null) {
            hintView4.hide();
        }
        HintView hintView5 = this.fwdRestrictedTopHint;
        if (hintView5 != null) {
            hintView5.hide();
        }
        HintView hintView6 = this.noSoundHintView;
        if (hintView6 != null) {
            hintView6.hide();
        }
        HintView hintView7 = this.forwardHintView;
        if (hintView7 != null) {
            hintView7.hide();
        }
        HintView hintView8 = this.pollHintView;
        if (hintView8 != null) {
            hintView8.hide();
        }
        HintView hintView9 = this.timerHintView;
        if (hintView9 != null) {
            hintView9.hide();
        }
        ChecksHintView checksHintView = this.checksHintView;
        if (checksHintView != null) {
            checksHintView.hide();
        }
        HintView2 hintView22 = this.bottomGiftHintView;
        if (hintView22 != null) {
            hintView22.hide();
        }
        HintView2 hintView23 = this.bottomSuggestHintView;
        if (hintView23 != null) {
            hintView23.hide();
        }
    }

    private void hideInfoView() {
        Animator animator = this.infoTopViewAnimator;
        if (animator != null) {
            animator.cancel();
        }
        ChatActionCell chatActionCell = this.infoTopView;
        if (chatActionCell == null || chatActionCell.getTag() == null) {
            return;
        }
        this.infoTopView.setTag(null);
        final ChatActionCell chatActionCell2 = this.infoTopView;
        ValueAnimator ofFloat = ValueAnimator.ofFloat(1.0f, 0.0f);
        ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                ChatActivity.this.lambda$hideInfoView$113(chatActionCell2, valueAnimator);
            }
        });
        ofFloat.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animator2) {
                ChatActivity.this.topViewOffset = 0.0f;
                if (animator2 == ChatActivity.this.infoTopViewAnimator) {
                    ViewGroup viewGroup = (ViewGroup) chatActionCell2.getParent();
                    if (viewGroup != null) {
                        viewGroup.removeView(chatActionCell2);
                    }
                    ChatActivity.this.infoTopView = null;
                    ChatActivity.this.infoTopViewAnimator = null;
                }
            }
        });
        ofFloat.setDuration(150L);
        this.infoTopViewAnimator = ofFloat;
        ofFloat.start();
    }

    private boolean hidePinnedMessageView(boolean z) {
        BlurredFrameLayout blurredFrameLayout = this.pinnedMessageView;
        if (blurredFrameLayout == null || blurredFrameLayout.getTag() != null) {
            return false;
        }
        int i = 0;
        while (true) {
            AnimatorSet[] animatorSetArr = this.pinnedNextAnimation;
            if (i >= animatorSetArr.length) {
                break;
            }
            AnimatorSet animatorSet = animatorSetArr[i];
            if (animatorSet != null) {
                animatorSet.cancel();
                this.pinnedNextAnimation[i] = null;
            }
            i++;
        }
        this.setPinnedTextTranslationX = false;
        this.pinnedMessageView.setTag(1);
        AnimatorSet animatorSet2 = this.pinnedMessageViewAnimator;
        if (animatorSet2 != null) {
            animatorSet2.cancel();
            this.pinnedMessageViewAnimator = null;
        }
        if (z) {
            this.pinnedMessageViewAnimator = new AnimatorSet();
            ValueAnimator ofFloat = ValueAnimator.ofFloat(this.pinnedMessageEnterOffset, -AndroidUtilities.dp(50.0f));
            ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                    ChatActivity.this.lambda$hidePinnedMessageView$225(valueAnimator);
                }
            });
            this.pinnedMessageViewAnimator.playTogether(ofFloat);
            this.pinnedMessageViewAnimator.setDuration(200L);
            this.pinnedMessageViewAnimator.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationCancel(Animator animator) {
                    if (ChatActivity.this.pinnedMessageViewAnimator == null || !ChatActivity.this.pinnedMessageViewAnimator.equals(animator)) {
                        return;
                    }
                    ChatActivity.this.pinnedMessageViewAnimator = null;
                }

                @Override
                public void onAnimationEnd(Animator animator) {
                    if (ChatActivity.this.pinnedMessageViewAnimator == null || !ChatActivity.this.pinnedMessageViewAnimator.equals(animator)) {
                        return;
                    }
                    if (ChatActivity.this.pinnedMessageView != null) {
                        ChatActivity.this.pinnedMessageView.setVisibility(8);
                    }
                    ChatActivity.this.pinnedMessageViewAnimator = null;
                }
            });
            this.pinnedMessageViewAnimator.start();
        } else {
            this.pinnedMessageEnterOffset = -AndroidUtilities.dp(50.0f);
            this.pinnedMessageView.setVisibility(8);
            this.chatListView.invalidate();
        }
        return true;
    }

    public void hideSendButtonHints() {
        HintView hintView = this.scheduledOrNoSoundHint;
        if (hintView != null) {
            hintView.hide();
        }
        HintView hintView2 = this.scheduledHint;
        if (hintView2 != null) {
            hintView2.hide();
        }
    }

    public void hideTagSelector() {
        final ReactionsContainerLayout reactionsContainerLayout = this.tagSelector;
        if (reactionsContainerLayout == null) {
            return;
        }
        this.tagSelector = null;
        reactionsContainerLayout.dismissWindow();
        if (reactionsContainerLayout.getReactionsWindow() != null && reactionsContainerLayout.getReactionsWindow().containerView != null) {
            reactionsContainerLayout.getReactionsWindow().containerView.animate().alpha(0.0f).setDuration(180L).start();
        }
        reactionsContainerLayout.animate().alpha(0.01f).translationY(-AndroidUtilities.dp(12.0f)).scaleX(0.7f).scaleY(0.7f).withEndAction(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$hideTagSelector$93(reactionsContainerLayout);
            }
        }).setDuration(180L).start();
    }

    private void hideUndoViews() {
        UndoView undoView = this.undoView;
        if (undoView != null) {
            undoView.hide(true, 0);
        }
        Bulletin bulletin = this.pinBulletin;
        if (bulletin != null) {
            bulletin.hide(false, 0L);
        }
        UndoView undoView2 = this.topUndoView;
        if (undoView2 != null) {
            undoView2.hide(true, 0);
        }
    }

    public void inlineUpdate1() {
        int i = this.prevSetUnreadCount;
        int i2 = this.newUnreadMessageCount;
        if (i != i2) {
            this.prevSetUnreadCount = i2;
            this.pagedownButtonCounter.setCount(i2, this.openAnimationEnded);
        }
    }

    public void inlineUpdate2() {
        int i = this.prevSetUnreadCount;
        int i2 = this.newUnreadMessageCount;
        if (i != i2) {
            this.prevSetUnreadCount = i2;
            this.pagedownButtonCounter.setCount(i2, true);
        }
    }

    public void invalidateChatListViewTopPadding() {
        int i;
        int i2;
        if (!this.invalidateChatListViewTopPadding) {
            this.invalidateChatListViewTopPadding = true;
            SizeNotifierFrameLayout sizeNotifierFrameLayout = this.contentView;
            if (sizeNotifierFrameLayout != null) {
                sizeNotifierFrameLayout.invalidate();
            }
            RecyclerListView recyclerListView = this.chatListView;
            if (recyclerListView != null) {
                recyclerListView.invalidate();
            }
        }
        BlurredFrameLayout blurredFrameLayout = this.topChatPanelView;
        if (blurredFrameLayout == null || blurredFrameLayout.getVisibility() != 0) {
            i = 0;
        } else {
            i = (this.topChatPanelView.getLayoutParams() == null ? AndroidUtilities.dp(50.0f) : this.topChatPanelView.getLayoutParams().height) - AndroidUtilities.dp(2.0f);
        }
        int max = i + ((int) Math.max(-i, this.topChatPanelViewOffset));
        float max2 = this.contentPanTranslation + this.contentPaddingTop + Math.max(0, max);
        if (this.topicsTabs != null) {
            max2 += AndroidUtilities.dp(48.0f) * (1.0f - this.topicsTabs.sidemenuT);
        }
        BlurredFrameLayout blurredFrameLayout2 = this.pinnedMessageView;
        if (blurredFrameLayout2 != null) {
            float f = max2 + this.pinnedMessageEnterOffset;
            blurredFrameLayout2.setTranslationY(f);
            max2 = f + AndroidUtilities.dp(48.0f);
        }
        BlurredFrameLayout blurredFrameLayout3 = this.topChatPanelView2;
        if (blurredFrameLayout3 == null || blurredFrameLayout3.getVisibility() != 0) {
            i2 = 0;
        } else {
            i2 = (this.topChatPanelView2.getLayoutParams() == null ? AndroidUtilities.dp(50.0f) : this.topChatPanelView2.getLayoutParams().height) - AndroidUtilities.dp(2.0f);
        }
        float max3 = max2 + Math.max(0, i2 + ((int) Math.max(-i2, this.topChatPanelView2Offset)));
        ChatActivityMemberRequestsDelegate chatActivityMemberRequestsDelegate = this.pendingRequestsDelegate;
        View view = chatActivityMemberRequestsDelegate != null ? chatActivityMemberRequestsDelegate.getView() : null;
        if (view != null) {
            view.setTranslationY(max3 + this.pendingRequestsDelegate.getViewEnterOffset());
        }
        float dp = (this.topicsTabs != null ? (AndroidUtilities.dp(48.0f) * (1.0f - this.topicsTabs.sidemenuT)) + 0.0f : 0.0f) + (this.actionBarSearchTags != null ? r5.getCurrentHeight() : 0.0f) + (this.hashtagSearchTabs != null ? r5.getCurrentHeight() : 0.0f);
        if (this.fragmentContextView != null) {
            FragmentContextView fragmentContextView = this.fragmentLocationContextView;
            float dp2 = (fragmentContextView == null || fragmentContextView.getVisibility() != 0) ? 0.0f : AndroidUtilities.dp(36.0f) + 0.0f;
            FragmentContextView fragmentContextView2 = this.fragmentContextView;
            fragmentContextView2.setTranslationY(this.contentPanTranslation + dp + dp2 + fragmentContextView2.getTopPadding());
        }
        if (this.fragmentLocationContextView != null) {
            FragmentContextView fragmentContextView3 = this.fragmentContextView;
            float dp3 = (fragmentContextView3 == null || fragmentContextView3.getVisibility() != 0) ? 0.0f : AndroidUtilities.dp(this.fragmentContextView.getStyleHeight()) + this.fragmentContextView.getTopPadding() + 0.0f;
            FragmentContextView fragmentContextView4 = this.fragmentLocationContextView;
            fragmentContextView4.setTranslationY(this.contentPanTranslation + dp + dp3 + fragmentContextView4.getTopPadding());
        }
        BlurredFrameLayout blurredFrameLayout4 = this.topChatPanelView;
        if (blurredFrameLayout4 != null) {
            blurredFrameLayout4.setTranslationY(this.contentPanTranslation + dp + this.contentPaddingTop + this.topChatPanelViewOffset);
        }
        BlurredFrameLayout blurredFrameLayout5 = this.topChatPanelView2;
        if (blurredFrameLayout5 != null) {
            blurredFrameLayout5.setTranslationY(this.contentPanTranslation + dp + this.contentPaddingTop + this.topChatPanelView2Offset + max + Math.max(0.0f, this.topChatPanelViewOffset) + Math.max(0.0f, this.pinnedMessageView != null ? AndroidUtilities.dp(48.0f) + this.pinnedMessageEnterOffset : 0.0f));
        }
        FrameLayout frameLayout = this.alertView;
        if (frameLayout != null && frameLayout.getVisibility() == 0) {
            this.alertView.setTranslationY(((this.contentPanTranslation + dp) + this.contentPaddingTop) - (AndroidUtilities.dp(50.0f) * (1.0f - this.alertViewEnterProgress)));
        }
        BlurredFrameLayout blurredFrameLayout6 = this.bottomOverlayChat;
        if (blurredFrameLayout6 != null) {
            blurredFrameLayout6.setTranslationY(this.bottomPanelTranslationYReverse);
        }
        BlurredFrameLayout blurredFrameLayout7 = this.bottomMessagesActionContainer;
        if (blurredFrameLayout7 != null) {
            blurredFrameLayout7.setTranslationY(this.bottomPanelTranslationYReverse);
        }
        UndoView undoView = this.undoView;
        if (undoView != null) {
            undoView.setAdditionalTranslationY(this.chatActivityEnterView.getHeightWithTopView() - this.chatActivityEnterView.getAnimatedTop());
        }
        FrameLayout frameLayout2 = this.messagesSearchListContainer;
        if (frameLayout2 != null) {
            frameLayout2.setTranslationY(getHashtagTabsHeight() + this.contentPanTranslation);
            FrameLayout frameLayout3 = this.messagesSearchListContainer;
            SearchTagsList searchTagsList = this.actionBarSearchTags;
            frameLayout3.setPadding(0, (searchTagsList == null || !searchTagsList.shown()) ? 0 : this.actionBarSearchTags.getHeight(), 0, getHashtagTabsHeight());
        }
        HashtagHistoryView hashtagHistoryView = this.hashtagHistoryView;
        if (hashtagHistoryView != null) {
            hashtagHistoryView.setTranslationY(getHashtagTabsHeight() + this.contentPanTranslation);
        }
    }

    private void invalidatePremiumBlocked() {
        TLRPC.User user;
        if (getDialogId() == getUserConfig().getClientUserId() || getUserConfig().isPremium() || (user = this.currentUser) == null || !user.contact_require_premium) {
            return;
        }
        if (this.messages.isEmpty() == (getMessagesController().isUserContactBlocked(getDialogId()) != null)) {
            return;
        }
        getMessagesController().invalidateUserPremiumBlocked(getDialogId(), ((BaseFragment) this).classGuid);
    }

    public boolean isAllChats() {
        return this.topicsTabs != null && this.threadMessageId == 0;
    }

    public static boolean isClickableLink(String str) {
        return str.startsWith("https://") || str.startsWith("@") || str.startsWith("#") || str.startsWith("$") || str.startsWith("video?");
    }

    private boolean isSideMenuAnimating() {
        TopicsTabsView topicsTabsView = this.topicsTabs;
        return topicsTabsView != null && topicsTabsView.sidemenuAnimating;
    }

    public boolean isSideMenuEnabled() {
        TopicsTabsView topicsTabsView = this.topicsTabs;
        return topicsTabsView != null && topicsTabsView.sidemenuEnabled;
    }

    public boolean isSideMenued() {
        return this.topicsTabs != null || (!this.isSubscriberSuggestions && ChatObject.isMonoForum(this.currentChat)) || (ChatObject.isForum(this.currentChat) && ChatObject.areTabsEnabled(this.currentChat));
    }

    public boolean isSkeletonVisible() {
        FrameLayout frameLayout;
        if (this.justCreatedTopic || this.justCreatedChat || this.currentUser != null || this.chatListView == null || !SharedConfig.animationsEnabled() || !getLiteModeChat()) {
            return false;
        }
        int i = Integer.MAX_VALUE;
        int i2 = 0;
        for (int i3 = 0; i3 < this.chatListView.getChildCount(); i3++) {
            i2 += this.chatListView.getChildAt(i3).getHeight();
            int top = this.chatListView.getChildAt(i3).getTop();
            if (top < i) {
                i = top;
            }
        }
        float f = i;
        if (f <= this.chatListViewPaddingTop) {
            checkDispatchHideSkeletons(((BaseFragment) this).fragmentBeginToShow);
        }
        boolean[] zArr = this.endReached;
        boolean z = (!zArr[0] || (!(this.mergeDialogId == 0 || zArr[1]) || this.messages.isEmpty())) && this.loading && f > this.chatListViewPaddingTop && (!this.messages.isEmpty() ? i2 == 0 : !this.animateProgressViewTo);
        if (z && ((BaseFragment) this).inTransitionAnimation && (frameLayout = this.emptyViewContainer) != null && frameLayout.getVisibility() == 0 && this.emptyViewContainer.getChildCount() > 0) {
            return false;
        }
        if (!z && this.startMessageAppearTransitionMs == 0) {
            checkDispatchHideSkeletons(((BaseFragment) this).fragmentBeginToShow);
        }
        if (SharedConfig.getDevicePerformanceClass() != 0 && !this.fromPullingDownTransition && ((BaseFragment) this).fragmentBeginToShow) {
            boolean z2 = z && this.startMessageAppearTransitionMs == 0;
            Drawable wallpaperDrawable = this.themeDelegate.getWallpaperDrawable();
            SizeNotifierFrameLayout sizeNotifierFrameLayout = ((BaseFragment) this).fragmentView;
            if (sizeNotifierFrameLayout != null) {
                wallpaperDrawable = sizeNotifierFrameLayout.getBackgroundImage();
            }
            if (wallpaperDrawable instanceof MotionBackgroundDrawable) {
                MotionBackgroundDrawable motionBackgroundDrawable = (MotionBackgroundDrawable) wallpaperDrawable;
                if (motionBackgroundDrawable.isIndeterminateAnimation() != z2) {
                    if (!z2) {
                        motionBackgroundDrawable.generateNextGradient();
                    }
                    motionBackgroundDrawable.setIndeterminateAnimation(z2);
                    motionBackgroundDrawable.setIndeterminateSpeedScale(z2 ? 1.5f : 1.0f);
                    motionBackgroundDrawable.updateAnimation(true);
                } else if (z2) {
                    motionBackgroundDrawable.updateAnimation(false);
                }
            }
        }
        return z || (this.startMessageAppearTransitionMs != 0 && System.currentTimeMillis() - this.startMessageAppearTransitionMs <= 200);
    }

    public boolean isSupportedTags() {
        return getUserConfig().getClientUserId() == getDialogId() && !getMessagesController().getSavedMessagesController().unsupported && getUserConfig().isPremium();
    }

    public boolean lambda$applyChatLinkMessageMaybe$251(org.telegram.tgnet.TLRPC.MessageEntity r11) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.lambda$applyChatLinkMessageMaybe$251(org.telegram.tgnet.TLRPC$MessageEntity):boolean");
    }

    public void lambda$applyDraftMaybe$252() {
        ChatActivityEnterView chatActivityEnterView;
        if (BaseFragment.hasSheets(this) || (chatActivityEnterView = this.chatActivityEnterView) == null) {
            return;
        }
        chatActivityEnterView.setFieldFocused(true);
        this.chatActivityEnterView.openKeyboard();
    }

    public void lambda$checkGroupEmojiPackHint$204() {
        FrameLayout.LayoutParams createFrame = LayoutHelper.createFrame(-1, -2.0f, 87, 0.0f, 0.0f, 0.0f, 0.0f);
        createFrame.bottomMargin = this.chatActivityEnterView.getMeasuredHeight();
        this.contentView.addView(this.groupEmojiPackHint, createFrame);
        this.groupEmojiPackHint.setJointPx(0.0f, this.chatActivityEnterView.getEmojiButton().getX() + AndroidUtilities.dp(18.0f));
        this.groupEmojiPackHint.show();
    }

    public static int lambda$checkGroupMessagesOrder$395(MessageObject messageObject, MessageObject messageObject2) {
        return messageObject2.getId() - messageObject.getId();
    }

    public void lambda$checkListViewPaddings$248() {
        this.checkPaddingsRunnable = null;
        invalidateChatListViewTopPadding();
        invalidateMessagesVisiblePart();
    }

    public void lambda$checkRecordLocked$353(boolean z, AlertDialog alertDialog, int i) {
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView != null) {
            if (z) {
                lambda$onBackPressed$354();
            } else {
                chatActivityEnterView.cancelRecordingAudioVideo();
            }
        }
    }

    public void lambda$checkScrollForLoad$124(int i, int i2, int i3, int i4) {
        MessagesController messagesController;
        long j;
        long j2;
        int i5;
        int i6;
        int i7;
        int i8;
        long j3;
        int i9;
        int i10;
        boolean z;
        int i11;
        int i12;
        int i13;
        boolean z2;
        int i14;
        MessagesController messagesController2;
        long j4;
        long j5;
        int i15;
        boolean z3;
        int i16;
        if ((i - i2) - i3 <= i4 && !this.loading) {
            boolean[] zArr = this.endReached;
            if (!zArr[0]) {
                this.loading = true;
                this.waitingForLoad.add(Integer.valueOf(this.lastLoadIndex));
                if (this.messagesByDays.size() != 0) {
                    MessagesController messagesController3 = getMessagesController();
                    long j6 = this.dialog_id;
                    long j7 = this.mergeDialogId;
                    i13 = this.maxMessageId[0];
                    z2 = !this.cacheEndReached[0];
                    i14 = this.minDate[0];
                    messagesController2 = messagesController3;
                    j5 = j6;
                    j4 = j7;
                } else {
                    MessagesController messagesController4 = getMessagesController();
                    long j8 = this.dialog_id;
                    messagesController2 = messagesController4;
                    j5 = j8;
                    j4 = this.mergeDialogId;
                    z3 = !this.cacheEndReached[0];
                    i15 = this.minDate[0];
                    i16 = 0;
                    int i17 = ((BaseFragment) this).classGuid;
                    int i18 = this.chatMode;
                    long j9 = this.threadMessageId;
                    int i19 = this.replyMaxReadId;
                    int i20 = this.lastLoadIndex;
                    this.lastLoadIndex = i20 + 1;
                    messagesController2.loadMessages(j5, j4, false, 50, i16, 0, z3, i15, i17, 0, 0, i18, j9, i19, i20, this.isTopic);
                }
            } else if (this.mergeDialogId != 0 && !zArr[1]) {
                this.loading = true;
                this.waitingForLoad.add(Integer.valueOf(this.lastLoadIndex));
                MessagesController messagesController5 = getMessagesController();
                long j10 = this.mergeDialogId;
                i13 = this.maxMessageId[1];
                z2 = !this.cacheEndReached[1];
                i14 = this.minDate[1];
                messagesController2 = messagesController5;
                j4 = 0;
                j5 = j10;
            }
            i16 = i13;
            z3 = z2;
            i15 = i14;
            int i172 = ((BaseFragment) this).classGuid;
            int i182 = this.chatMode;
            long j92 = this.threadMessageId;
            int i192 = this.replyMaxReadId;
            int i202 = this.lastLoadIndex;
            this.lastLoadIndex = i202 + 1;
            messagesController2.loadMessages(j5, j4, false, 50, i16, 0, z3, i15, i172, 0, 0, i182, j92, i192, i202, this.isTopic);
        }
        if (i3 <= 0 || this.loadingForward || i2 > 10) {
            return;
        }
        if (this.mergeDialogId != 0 && !this.forwardEndReached[1]) {
            this.waitingForLoad.add(Integer.valueOf(this.lastLoadIndex));
            messagesController = getMessagesController();
            j = this.mergeDialogId;
            i5 = this.minMessageId[1];
            i6 = this.maxDate[1];
            i7 = ((BaseFragment) this).classGuid;
            i8 = this.chatMode;
            j3 = this.threadMessageId;
            i9 = this.replyMaxReadId;
            int i21 = this.lastLoadIndex;
            i10 = i21;
            this.lastLoadIndex = i21 + 1;
            z = this.isTopic;
            i11 = 1;
            i12 = 0;
            j2 = 0;
        } else {
            if (this.forwardEndReached[0]) {
                return;
            }
            this.waitingForLoad.add(Integer.valueOf(this.lastLoadIndex));
            messagesController = getMessagesController();
            j = this.dialog_id;
            j2 = this.mergeDialogId;
            i5 = this.minMessageId[0];
            i6 = this.maxDate[0];
            i7 = ((BaseFragment) this).classGuid;
            i8 = this.chatMode;
            j3 = this.threadMessageId;
            i9 = this.replyMaxReadId;
            int i22 = this.lastLoadIndex;
            i10 = i22;
            this.lastLoadIndex = i22 + 1;
            z = this.isTopic;
            i11 = 1;
            i12 = 0;
        }
        messagesController.loadMessages(j, j2, false, 50, i5, 0, true, i6, i7, i11, i12, i8, j3, i9, i10, z);
        this.loadingForward = true;
    }

    public void lambda$checkSecretMessageForLocation$195() {
        int childCount = this.chatListView.getChildCount();
        for (int i = 0; i < childCount; i++) {
            View childAt = this.chatListView.getChildAt(i);
            if (childAt instanceof ChatMessageCell) {
                ChatMessageCell chatMessageCell = (ChatMessageCell) childAt;
                if (chatMessageCell.getMessageObject().type == 4) {
                    chatMessageCell.forceResetMessageObject();
                }
            }
        }
    }

    public void lambda$checkShowBlur$112(View view) {
        finishPreviewFragment();
    }

    public void lambda$checkStarsNeedSheet$350(AmountUtils.Amount amount, Runnable runnable) {
        if (((BaseFragment) this).isFinished) {
            return;
        }
        if (AmountUtils.Amount.ofSafe(StarsController.getInstance(((BaseFragment) this).currentAccount, amount.currency).getBalance()).asNano() >= amount.asNano()) {
            runnable.run();
            return;
        }
        AmountUtils.Currency currency = amount.currency;
        if (currency == AmountUtils.Currency.STARS) {
            new StarsIntroActivity.StarsNeededSheet(getContext(), getResourceProvider(), amount.asDecimal(), 13, ForumUtilities.getMonoForumTitle(((BaseFragment) this).currentAccount, getDialogId(), true), (Runnable) null).show();
        } else if (currency == AmountUtils.Currency.TON) {
            new TONIntroActivity.StarsNeededSheet(getContext(), getResourceProvider(), amount, true, (Runnable) null).show();
        }
    }

    public void lambda$checkThemeEmoticonOrWallpaper$387() {
        TLRPC.UserFull userFull = this.userInfo;
        setChatThemeEmoticon(userFull != null ? userFull.theme_emoticon : null);
    }

    public void lambda$closeMenu$306(ValueAnimator valueAnimator) {
        this.scrimViewAlpha = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        SizeNotifierFrameLayout sizeNotifierFrameLayout = this.contentView;
        if (sizeNotifierFrameLayout != null) {
            sizeNotifierFrameLayout.invalidate();
            this.chatListView.invalidate();
        }
    }

    public static boolean lambda$createActionMode$92(View view, MotionEvent motionEvent) {
        return true;
    }

    public void lambda$createBottomMessagesActionButtons$79(View view) {
        int i;
        MessageObject messageObject = null;
        for (int i2 = 1; i2 >= 0; i2--) {
            if (messageObject == null && this.selectedMessagesIds[i2].size() != 0) {
                messageObject = (MessageObject) this.messagesDict[i2].get(this.selectedMessagesIds[i2].keyAt(0));
            }
            this.selectedMessagesIds[i2].clear();
            this.selectedMessagesCanCopyIds[i2].clear();
            this.selectedMessagesCanStarIds[i2].clear();
        }
        hideActionMode();
        if (messageObject != null && ((i = messageObject.messageOwner.id) > 0 || (i < 0 && this.currentEncryptedChat != null))) {
            showFieldPanelForReply(messageObject);
        }
        updatePinnedMessageView(true);
        updateVisibleRows();
        updateSelectedMessageReactions();
    }

    public void lambda$createBottomMessagesActionButtons$80(View view) {
        openForward(false);
    }

    public void lambda$createDeleteMessagesAlert$253() {
        hideActionMode();
        updatePinnedMessageView(true);
    }

    public void lambda$createDeleteMessagesAlert$254() {
        dimBehindView(false);
    }

    public void lambda$createEmptyView$301(TLRPC.Document document) {
        this.animatingDocuments.put(document, 0);
        SendMessagesHelper.getInstance(((BaseFragment) this).currentAccount).sendSticker(document, (String) null, this.dialog_id, (MessageObject) null, (MessageObject) null, (TL_stories.StoryItem) null, this.replyingQuote, (MessageObject.SendAnimationData) null, true, 0, false, (Object) null, this.quickReplyShortcut, getQuickReplyId(), 0L, getSendMonoForumPeerId(), getSendMessageSuggestionParams());
    }

    public void lambda$createEmptyView$302(TLRPC.Document document) {
        this.animatingDocuments.put(document, 0);
        SendMessagesHelper.getInstance(((BaseFragment) this).currentAccount).sendSticker(document, (String) null, this.dialog_id, (MessageObject) null, (MessageObject) null, (TL_stories.StoryItem) null, this.replyingQuote, (MessageObject.SendAnimationData) null, true, 0, false, (Object) null, this.quickReplyShortcut, getQuickReplyId(), 0L, getSendMonoForumPeerId(), getSendMessageSuggestionParams());
    }

    public void lambda$createMenu$255(MessageObject messageObject) {
        scrollToMessageId(messageObject.getReplyMsgId(), messageObject.messageOwner.id, true, messageObject.getDialogId() == this.mergeDialogId ? 1 : 0, false, 0);
    }

    public void lambda$createMenu$256(TLObject tLObject) {
        if (tLObject instanceof TLRPC.TL_payments_paymentReceiptStars) {
            StarsIntroActivity.showTransactionSheet(getContext(), false, ((BaseFragment) this).currentAccount, (TLRPC.TL_payments_paymentReceiptStars) tLObject, ((BaseFragment) this).resourceProvider);
        } else if (tLObject instanceof TLRPC.PaymentReceipt) {
            presentFragment(new PaymentFormActivity((TLRPC.PaymentReceipt) tLObject));
        }
    }

    public void lambda$createMenu$257(final TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$createMenu$256(tLObject);
            }
        });
    }

    public static void lambda$createMenu$258(ActionBarPopupWindow.ActionBarPopupWindowLayout actionBarPopupWindowLayout, View view) {
        actionBarPopupWindowLayout.getSwipeBack().closeForeground();
    }

    public static void lambda$createMenu$259(HorizontalScrollView horizontalScrollView, float f, float f2, ReactionTabHolderView reactionTabHolderView, ReactionTabHolderView reactionTabHolderView2, ValueAnimator valueAnimator) {
        float floatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        horizontalScrollView.setScrollX((int) (f + ((f2 - f) * floatValue)));
        reactionTabHolderView.setOutlineProgress(1.0f - floatValue);
        reactionTabHolderView2.setOutlineProgress(floatValue);
    }

    public static void lambda$createMenu$260(ViewPager viewPager, int i, LinearLayout linearLayout, AtomicBoolean atomicBoolean, final HorizontalScrollView horizontalScrollView, final ReactionTabHolderView reactionTabHolderView, View view) {
        int currentItem = viewPager.getCurrentItem();
        if (i == currentItem) {
            return;
        }
        final ReactionTabHolderView childAt = linearLayout.getChildAt(currentItem);
        atomicBoolean.set(true);
        viewPager.setCurrentItem(i, true);
        final float scrollX = horizontalScrollView.getScrollX();
        final float x = reactionTabHolderView.getX() - ((horizontalScrollView.getWidth() - reactionTabHolderView.getWidth()) / 2.0f);
        ValueAnimator duration = ValueAnimator.ofFloat(0.0f, 1.0f).setDuration(150L);
        duration.setInterpolator(CubicBezierInterpolator.DEFAULT);
        duration.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                ChatActivity.lambda$createMenu$259(horizontalScrollView, scrollX, x, childAt, reactionTabHolderView, valueAnimator);
            }
        });
        duration.start();
    }

    public void lambda$createMenu$261(ReactedUsersListView reactedUsersListView, ArrayList arrayList) {
        EmojiPacksAlert emojiPacksAlert = new EmojiPacksAlert(this, getParentActivity(), this.themeDelegate, arrayList) {
            public void dismiss() {
                super.dismiss();
                ChatActivity.this.dimBehindView(false);
            }
        };
        emojiPacksAlert.setCalcMandatoryInsets(isKeyboardVisible());
        emojiPacksAlert.setDimBehind(false);
        closeMenu(false);
        showDialog(emojiPacksAlert);
    }

    public void lambda$createMenu$262(MessageObject messageObject, ReactedUsersListView reactedUsersListView, long j, TLRPC.MessagePeerReaction messagePeerReaction) {
        String str;
        Bundle bundle = new Bundle();
        if (j > 0) {
            str = "user_id";
        } else {
            j = -j;
            str = "chat_id";
        }
        bundle.putLong(str, j);
        bundle.putInt("report_reaction_message_id", messageObject.getId());
        bundle.putLong("report_reaction_from_dialog_id", this.dialog_id);
        presentFragment(new ProfileActivity(bundle));
        closeMenu();
    }

    public static void lambda$createMenu$263(ActionBarPopupWindow.ActionBarPopupWindowLayout actionBarPopupWindowLayout, int[] iArr, ReactedUsersListView reactedUsersListView, int i) {
        actionBarPopupWindowLayout.getSwipeBack().setNewForegroundHeight(iArr[0], AndroidUtilities.dp(52.0f) + i, true);
    }

    public static void lambda$createMenu$264(ReactedUsersListView reactedUsersListView, ActionBarPopupWindow.ActionBarPopupWindowLayout actionBarPopupWindowLayout, int[] iArr, View view) {
        if (reactedUsersListView == null || reactedUsersListView.isLoaded) {
            actionBarPopupWindowLayout.getSwipeBack().openForeground(iArr[0]);
        }
    }

    public void lambda$createMenu$265(MessageSeenView messageSeenView, View view, int i) {
        long j;
        String str;
        TLRPC.User user = (TLObject) messageSeenView.users.get(i);
        if (user == null) {
            return;
        }
        closeMenu(true);
        Bundle bundle = new Bundle();
        if (!(user instanceof TLRPC.User)) {
            if (user instanceof TLRPC.Chat) {
                j = ((TLRPC.Chat) user).id;
                str = "chat_id";
            }
            presentFragment(new ProfileActivity(bundle));
        }
        j = user.id;
        str = "user_id";
        bundle.putLong(str, j);
        presentFragment(new ProfileActivity(bundle));
    }

    public void lambda$createMenu$266() {
        closeMenu(true);
    }

    public void lambda$createMenu$267() {
        closeMenu(true);
    }

    public void lambda$createMenu$269(MessageObject messageObject, View view) {
        UndoView undoView;
        if (getMediaDataController().saveToRingtones(messageObject.getDocument()) && (undoView = getUndoView()) != null) {
            undoView.showWithAction(this.dialog_id, UndoView.ACTION_RINGTONE_ADDED, new Runnable() {
                boolean clicked;

                @Override
                public void run() {
                    if (this.clicked) {
                        return;
                    }
                    this.clicked = true;
                    ChatActivity.this.presentFragment(new NotificationsSettingsActivity());
                }
            });
        }
        closeMenu(true);
    }

    public void lambda$createMenu$270(View view) {
        closeMenu();
    }

    public static void lambda$createMenu$271(CrossfadeDrawable crossfadeDrawable, ValueAnimator valueAnimator) {
        crossfadeDrawable.setProgress(((Float) valueAnimator.getAnimatedValue()).floatValue());
    }

    public static void lambda$createMenu$272(long[] jArr, boolean[] zArr, ImageView imageView, ImageView imageView2) {
        jArr[0] = SystemClock.elapsedRealtime();
        if (!zArr[0]) {
            imageView = imageView2;
        }
        final CrossfadeDrawable drawable = imageView.getDrawable();
        ValueAnimator ofFloat = ValueAnimator.ofFloat(0.0f, 1.0f);
        ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                ChatActivity.lambda$createMenu$271(drawable, valueAnimator);
            }
        });
        ofFloat.setDuration(150L);
        ofFloat.setInterpolator(CubicBezierInterpolator.DEFAULT);
        ofFloat.start();
    }

    public void lambda$createMenu$273() {
        closeMenu();
        BulletinFactory.of(this).createSimpleBulletin(R.raw.chats_infotip, LocaleController.getString(R.string.TranscriptionReportSent)).show();
    }

    public void lambda$createMenu$274(Runnable runnable, long[] jArr, TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.cancelRunOnUIThread(runnable);
        this.selectedObject.messageOwner.voiceTranscriptionRated = true;
        getMessagesStorage().updateMessageVoiceTranscriptionOpen(this.selectedObject.getDialogId(), this.selectedObject.getId(), this.selectedObject.messageOwner);
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$createMenu$273();
            }
        }, jArr[0] > 0 ? Math.max(0L, 300 - (SystemClock.elapsedRealtime() - jArr[0])) : 0L);
    }

    public void lambda$createMenu$275(boolean[] zArr, final boolean[] zArr2, final ImageView imageView, final ImageView imageView2) {
        if (zArr[0]) {
            return;
        }
        zArr[0] = true;
        final long[] jArr = {-1};
        final Runnable runnable = new Runnable() {
            @Override
            public final void run() {
                ChatActivity.lambda$createMenu$272(jArr, zArr2, imageView, imageView2);
            }
        };
        TLRPC.TL_messages_rateTranscribedAudio tL_messages_rateTranscribedAudio = new TLRPC.TL_messages_rateTranscribedAudio();
        tL_messages_rateTranscribedAudio.msg_id = this.selectedObject.getId();
        tL_messages_rateTranscribedAudio.peer = getMessagesController().getInputPeer(this.selectedObject.messageOwner.peer_id);
        tL_messages_rateTranscribedAudio.transcription_id = this.selectedObject.messageOwner.voiceTranscriptionId;
        tL_messages_rateTranscribedAudio.good = zArr2[0];
        getConnectionsManager().sendRequest(tL_messages_rateTranscribedAudio, new RequestDelegate() {
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                ChatActivity.this.lambda$createMenu$274(runnable, jArr, tLObject, tL_error);
            }
        });
        AndroidUtilities.runOnUIThread(runnable, 150L);
    }

    public static void lambda$createMenu$276(boolean[] zArr, Runnable runnable, View view) {
        zArr[0] = true;
        runnable.run();
    }

    public static void lambda$createMenu$277(boolean[] zArr, Runnable runnable, View view) {
        zArr[0] = false;
        runnable.run();
    }

    public static void lambda$createMenu$278(ActionBarPopupWindow.ActionBarPopupWindowLayout actionBarPopupWindowLayout, View view) {
        actionBarPopupWindowLayout.getSwipeBack().closeForeground();
    }

    public void lambda$createMenu$279(View view) {
        MessageObject messageObject = this.selectedObject;
        if (messageObject == null) {
            return;
        }
        logSponsoredClicked(messageObject, false, false);
        Browser.openUrl(getContext(), Uri.parse(this.selectedObject.sponsoredUrl), true, false, false, (Browser.Progress) null, (String) null, false, getMessagesController().sponsoredLinksInappAllow, false);
    }

    public boolean lambda$createMenu$280(View view) {
        MessageObject messageObject = this.selectedObject;
        if (messageObject == null) {
            return false;
        }
        if (!AndroidUtilities.addToClipboard(messageObject.sponsoredUrl)) {
            return true;
        }
        BulletinFactory.of(Bulletin.BulletinWindow.make(getParentActivity()), this.themeDelegate).createCopyLinkBulletin().show();
        return true;
    }

    public void lambda$createMenu$281(View view) {
        if (AndroidUtilities.addToClipboard(this.selectedObject.sponsoredInfo)) {
            BulletinFactory.of(Bulletin.BulletinWindow.make(getParentActivity()), this.themeDelegate).createCopyBulletin(LocaleController.getString(R.string.TextCopied)).show();
        }
    }

    public void lambda$createMenu$282(View view) {
        if (AndroidUtilities.addToClipboard(this.selectedObject.sponsoredAdditionalInfo)) {
            BulletinFactory.of(Bulletin.BulletinWindow.make(getParentActivity()), this.themeDelegate).createCopyBulletin(LocaleController.getString(R.string.TextCopied)).show();
        }
    }

    public void lambda$createMenu$283(ActionBarPopupWindow.ActionBarPopupWindowLayout actionBarPopupWindowLayout, int i, View view) {
        if (this.contentView == null || getParentActivity() == null) {
            return;
        }
        actionBarPopupWindowLayout.getSwipeBack().openForeground(i);
    }

    public void lambda$createMenu$284(View view) {
        if (this.contentView == null || getParentActivity() == null) {
            return;
        }
        BottomSheet.Builder builder = new BottomSheet.Builder(this.contentView.getContext());
        builder.setCustomView(new SponsoredMessageInfoView(getParentActivity(), null, this.themeDelegate));
        builder.show();
    }

    public void lambda$createMenu$285(int i, ArrayList arrayList, View view) {
        if (this.selectedObject == null || i >= arrayList.size()) {
            return;
        }
        processSelectedOption(((Integer) arrayList.get(i)).intValue());
    }

    public Boolean lambda$createMenu$286(View view, URLSpan uRLSpan) {
        didPressMessageUrl(uRLSpan, false, this.selectedObject, view instanceof ChatMessageCell ? (ChatMessageCell) view : null);
        return Boolean.TRUE;
    }

    public void lambda$createMenu$287() {
        dimBehindView(false);
    }

    public void lambda$createMenu$288(int i, ArrayList arrayList, String str, String str2, String str3, TLRPC.InputPeer inputPeer, int[] iArr, CharSequence charSequence, boolean z, Utilities.CallbackReturn callbackReturn, View view) {
        TLRPC.Message message;
        if (this.selectedObject == null || i >= arrayList.size() || getParentActivity() == null) {
            return;
        }
        String str4 = (str == null || !str.equals(str2)) ? str2 : str3;
        MessageObject messageObject = this.selectedObject;
        TranslateAlert2.showAlert(getParentActivity(), this, ((BaseFragment) this).currentAccount, inputPeer, iArr[0], str, str4, charSequence, (messageObject == null || (message = messageObject.messageOwner) == null) ? null : message.entities, z, callbackReturn, new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$createMenu$287();
            }
        }).setDimBehind(false);
        closeMenu(false);
        int i2 = MessagesController.getNotificationsSettings(((BaseFragment) this).currentAccount).getInt("dialog_show_translate_count" + getDialogId(), 5);
        if (i2 > 0) {
            MessagesController.getNotificationsSettings(((BaseFragment) this).currentAccount).edit().putInt("dialog_show_translate_count" + getDialogId(), i2 - 1).apply();
            updateTopPanel(true);
        }
    }

    public void lambda$createMenu$289(String[] strArr, String str, String str2, boolean z, ActionBarMenuSubItem actionBarMenuSubItem, AtomicBoolean atomicBoolean, AtomicReference atomicReference, String str3) {
        TLRPC.Chat chat;
        strArr[0] = str3;
        if (str3 != null && ((!str3.equals(str) || !strArr[0].equals(str2) || strArr[0].equals("und")) && ((z && !RestrictedLanguagesSelectActivity.getRestrictedLanguages().contains(strArr[0])) || ((((chat = this.currentChat) != null && (chat.has_link || ChatObject.isPublic(chat))) || this.selectedObject.messageOwner.fwd_from != null) && ("uk".equals(strArr[0]) || "ru".equals(strArr[0])))))) {
            actionBarMenuSubItem.setVisibility(0);
        }
        atomicBoolean.set(false);
        if (atomicReference.get() != null) {
            ((Runnable) atomicReference.get()).run();
            atomicReference.set(null);
        }
    }

    public static void lambda$createMenu$290(AtomicBoolean atomicBoolean, AtomicReference atomicReference, Exception exc) {
        FileLog.e("mlkit: failed to detect language in message");
        atomicBoolean.set(false);
        if (atomicReference.get() != null) {
            ((Runnable) atomicReference.get()).run();
            atomicReference.set(null);
        }
    }

    public void lambda$createMenu$291() {
        dimBehindView(false);
    }

    public void lambda$createMenu$292(int i, ArrayList arrayList, String[] strArr, String str, String str2, TLRPC.InputPeer inputPeer, int[] iArr, CharSequence charSequence, boolean z, Utilities.CallbackReturn callbackReturn, View view) {
        TLRPC.Message message;
        if (this.selectedObject == null || i >= arrayList.size() || getParentActivity() == null) {
            return;
        }
        String str3 = strArr[0];
        String str4 = (str3 == null || !str3.equals(str)) ? str : str2;
        MessageObject messageObject = this.selectedObject;
        TranslateAlert2.showAlert(getParentActivity(), this, ((BaseFragment) this).currentAccount, inputPeer, iArr[0], strArr[0], str4, charSequence, (messageObject == null || (message = messageObject.messageOwner) == null) ? null : message.entities, z, callbackReturn, new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$createMenu$291();
            }
        }).setDimBehind(false);
        closeMenu(false);
        int i2 = MessagesController.getNotificationsSettings(((BaseFragment) this).currentAccount).getInt("dialog_show_translate_count" + getDialogId(), 5);
        if (i2 > 0) {
            MessagesController.getNotificationsSettings(((BaseFragment) this).currentAccount).edit().putInt("dialog_show_translate_count" + getDialogId(), i2 - 1).apply();
            updateTopPanel(true);
        }
    }

    public static void lambda$createMenu$293(AtomicReference atomicReference) {
        if (atomicReference.get() != null) {
            ((Runnable) atomicReference.getAndSet(null)).run();
        }
    }

    public void lambda$createMenu$294() {
        dimBehindView(false);
    }

    public void lambda$createMenu$295(int i, ArrayList arrayList, TLRPC.InputPeer inputPeer, int[] iArr, String str, CharSequence charSequence, boolean z, Utilities.CallbackReturn callbackReturn, View view) {
        if (this.selectedObject == null || i >= arrayList.size() || getParentActivity() == null) {
            return;
        }
        TranslateAlert2.showAlert(getParentActivity(), this, ((BaseFragment) this).currentAccount, inputPeer, iArr[0], "und", str, charSequence, (ArrayList) null, z, callbackReturn, new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$createMenu$294();
            }
        }).setDimBehind(false);
        closeMenu(false);
        int i2 = MessagesController.getNotificationsSettings(((BaseFragment) this).currentAccount).getInt("dialog_show_translate_count" + getDialogId(), 5);
        if (i2 > 0) {
            MessagesController.getNotificationsSettings(((BaseFragment) this).currentAccount).edit().putInt("dialog_show_translate_count" + getDialogId(), i2 - 1).apply();
            updateTopPanel(true);
        }
    }

    public void lambda$createMenu$296(DialogInterface dialogInterface) {
        dimBehindView(false);
    }

    public void lambda$createMenu$297() {
        closeMenu(false);
        PremiumFeatureBottomSheet premiumFeatureBottomSheet = new PremiumFeatureBottomSheet(this, 24, true);
        premiumFeatureBottomSheet.setDimBehind(false);
        premiumFeatureBottomSheet.setOnHideListener(new DialogInterface.OnDismissListener() {
            @Override
            public final void onDismiss(DialogInterface dialogInterface) {
                ChatActivity.this.lambda$createMenu$296(dialogInterface);
            }
        });
        premiumFeatureBottomSheet.show();
    }

    public void lambda$createMenu$298(ArrayList arrayList, View view) {
        EmojiPacksAlert emojiPacksAlert = new EmojiPacksAlert(this, getParentActivity(), this.themeDelegate, arrayList) {
            public void dismiss() {
                super.dismiss();
                ChatActivity.this.dimBehindView(false);
            }
        };
        emojiPacksAlert.setCalcMandatoryInsets(isKeyboardVisible());
        emojiPacksAlert.setDimBehind(false);
        closeMenu(false);
        showDialog(emojiPacksAlert);
    }

    public void lambda$createMenu$299() {
        ActionBarMenuSubItem actionBarMenuSubItem;
        ActionBarMenuSubItem[] actionBarMenuSubItemArr = this.scrimPopupWindowItems;
        if (actionBarMenuSubItemArr == null || actionBarMenuSubItemArr.length <= 0 || (actionBarMenuSubItem = actionBarMenuSubItemArr[0]) == null) {
            return;
        }
        actionBarMenuSubItem.requestFocus();
        this.scrimPopupWindowItems[0].performAccessibilityAction(64, null);
        this.scrimPopupWindowItems[0].sendAccessibilityEvent(8);
    }

    public void lambda$createMenu$300(int i, int i2, boolean z, ReactionsContainerLayout reactionsContainerLayout) {
        ActionBarPopupWindow actionBarPopupWindow = this.scrimPopupWindow;
        if (actionBarPopupWindow == null || ((BaseFragment) this).fragmentView == null || actionBarPopupWindow.isShowing() || !AndroidUtilities.isActivityRunning(getParentActivity())) {
            return;
        }
        this.scrimPopupWindow.showAtLocation(this.chatListView, 51, i, i2);
        if (z && reactionsContainerLayout != null) {
            reactionsContainerLayout.startEnterAnimation(true);
        }
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$createMenu$299();
            }
        }, 420L);
    }

    public void lambda$createPinnedMessageView$106(View view) {
        int i;
        this.wasManualScroll = true;
        if (isThreadChat() && !this.isTopic) {
            scrollToMessageId((int) this.threadMessageId, 0, true, 0, true, 0);
            return;
        }
        int i2 = this.currentPinnedMessageId;
        if (i2 != 0) {
            if (this.pinnedMessageIds.isEmpty()) {
                i = 0;
            } else {
                ArrayList arrayList = this.pinnedMessageIds;
                if (i2 == ((Integer) arrayList.get(arrayList.size() - 1)).intValue()) {
                    i = ((Integer) this.pinnedMessageIds.get(0)).intValue() + 1;
                    this.forceScrollToFirst = true;
                } else {
                    i = i2 - 1;
                    this.forceScrollToFirst = false;
                }
            }
            this.forceNextPinnedMessageId = i;
            scrollToMessageId(i2, 0, true, 0, true, !this.forceScrollToFirst ? -i : i);
            updateMessagesVisiblePart(false);
        }
    }

    public void lambda$createPinnedMessageView$107(View view) {
        openPinnedMessagesList(false);
    }

    public void lambda$createPinnedMessageView$108(AlertDialog alertDialog, int i) {
        MessageObject messageObject = (MessageObject) this.pinnedMessageObjects.get(Integer.valueOf(this.currentPinnedMessageId));
        if (messageObject == null) {
            messageObject = (MessageObject) this.messagesDict[0].get(this.currentPinnedMessageId);
        }
        unpinMessage(messageObject);
    }

    public void lambda$createPinnedMessageView$109(View view) {
        TLRPC.UserFull userFull;
        boolean z;
        if (getParentActivity() == null) {
            return;
        }
        TLRPC.Chat chat = this.currentChat;
        if (chat != null) {
            if (ChatObject.canPinMessages(chat) && !this.currentChat.monoforum) {
                z = true;
            }
            z = false;
        } else {
            if (this.currentEncryptedChat == null && (userFull = this.userInfo) != null) {
                z = userFull.can_pin_message;
            }
            z = false;
        }
        if (z) {
            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity(), this.themeDelegate);
            builder.setTitle(LocaleController.getString(R.string.UnpinMessageAlertTitle));
            builder.setMessage(LocaleController.getString(R.string.UnpinMessageAlert));
            builder.setPositiveButton(LocaleController.getString(R.string.UnpinMessage), new AlertDialog.OnButtonClickListener() {
                @Override
                public final void onClick(AlertDialog alertDialog, int i) {
                    ChatActivity.this.lambda$createPinnedMessageView$108(alertDialog, i);
                }
            });
            builder.setNegativeButton(LocaleController.getString(R.string.Cancel), null);
            showDialog(builder.create());
            return;
        }
        if (this.pinnedMessageIds.isEmpty()) {
            return;
        }
        MessagesController.getNotificationsSettings(((BaseFragment) this).currentAccount).edit().putInt("pin_" + this.dialog_id, ((Integer) this.pinnedMessageIds.get(0)).intValue()).commit();
        updatePinnedMessageView(true);
    }

    public void lambda$createSearchContainer$94(View view) {
        toggleMesagesSearchListView();
    }

    public void lambda$createSearchContainer$95(View view) {
        setFilterMessages(!this.chatAdapter.isFiltered);
    }

    public void lambda$createSearchContainer$96(View view) {
        MentionsContainerView mentionsContainerView = this.mentionContainer;
        if (mentionsContainerView != null) {
            mentionsContainerView.setReversed(true);
            this.mentionContainer.getAdapter().setSearchingMentions(true);
        }
        this.searchCalendarButton.setVisibility(8);
        this.searchUserButton.setVisibility(8);
        this.searchingForUser = true;
        this.searchingUserMessages = null;
        this.searchingChatMessages = null;
        this.searchItem.setSearchFieldHint(LocaleController.getString(R.string.SearchMembers));
        this.searchItem.setSearchFieldCaption(LocaleController.getString(R.string.SearchFrom));
        AndroidUtilities.showKeyboard(this.searchItem.getSearchField());
        this.searchItem.clearSearchText();
    }

    public void lambda$createSearchContainer$97(View view) {
        if (getParentActivity() == null) {
            return;
        }
        ActionBarMenuItem actionBarMenuItem = this.searchItem;
        if (actionBarMenuItem != null) {
            AndroidUtilities.hideKeyboard(actionBarMenuItem.getSearchField());
        }
        showDialog(AlertsCreator.createCalendarPickerDialog(getParentActivity(), 1375315200000L, new MessagesStorage.IntCallback() {
            public void run(int i) {
                ChatActivity.this.jumpToDate(i);
            }
        }, this.themeDelegate).create());
    }

    public void lambda$createTopPanel$81(int i) {
        if (i == 0) {
            updateTopPanel(true);
        } else {
            lambda$onBackPressed$354();
        }
    }

    public void lambda$createTopPanel$82(View view) {
        AlertsCreator.showBlockReportSpamAlert(this, this.dialog_id, this.currentUser, this.currentChat, this.currentEncryptedChat, this.reportSpamButton.getTag(R.id.object_tag) != null, this.chatInfo, new MessagesStorage.IntCallback() {
            public final void run(int i) {
                ChatActivity.this.lambda$createTopPanel$81(i);
            }
        }, this.themeDelegate);
    }

    public void lambda$createTopPanel$83(ArrayList arrayList, int i) {
        getMessagesController().addUsersToChat(this.currentChat, this, arrayList, i, (androidx.core.util.Consumer) null, (androidx.core.util.Consumer) null, (Runnable) null);
        getMessagesController().hidePeerSettingsBar(this.dialog_id, this.currentUser, this.currentChat);
        updateTopPanel(true);
        updateInfoTopView(true);
    }

    public void lambda$createTopPanel$84() {
        if (this.undoView != null || getContext() == null) {
            return;
        }
        createUndoView();
        this.undoView.showWithAction(this.dialog_id, 8, this.currentUser);
    }

    public void lambda$createTopPanel$85(View view) {
        if (this.addToContactsButtonArchive) {
            getMessagesController().addDialogToFolder(this.dialog_id, 0, 0, 0L);
            createUndoView();
            this.undoView.showWithAction(this.dialog_id, 23, (Runnable) null);
            SharedPreferences.Editor edit = MessagesController.getNotificationsSettings(((BaseFragment) this).currentAccount).edit();
            edit.putBoolean("dialog_bar_archived" + this.dialog_id, false);
            edit.putBoolean("dialog_bar_block" + this.dialog_id, false);
            edit.putBoolean("dialog_bar_report" + this.dialog_id, false);
            edit.commit();
            updateTopPanel(false);
            getNotificationsController().clearDialogNotificationsSettings(this.dialog_id, getTopicId());
            return;
        }
        if (this.addToContactsButton.getTag() == null || ((Integer) this.addToContactsButton.getTag()).intValue() != 4) {
            if (this.addToContactsButton.getTag() != null) {
                shareMyContact(1, null);
                return;
            }
            Bundle bundle = new Bundle();
            bundle.putLong("user_id", this.currentUser.id);
            bundle.putBoolean("addContact", true);
            ContactAddActivity contactAddActivity = new ContactAddActivity(bundle);
            contactAddActivity.setDelegate(new ContactAddActivity.ContactAddActivityDelegate() {
                @Override
                public final void didAddToContacts() {
                    ChatActivity.this.lambda$createTopPanel$84();
                }
            });
            presentFragment(contactAddActivity);
            return;
        }
        TLRPC.ChatFull chatFull = this.chatInfo;
        if (chatFull == null || chatFull.participants == null) {
            return;
        }
        LongSparseArray longSparseArray = new LongSparseArray();
        for (int i = 0; i < this.chatInfo.participants.participants.size(); i++) {
            longSparseArray.put(((TLRPC.ChatParticipant) this.chatInfo.participants.participants.get(i)).user_id, (Object) null);
        }
        long j = this.chatInfo.id;
        InviteMembersBottomSheet inviteMembersBottomSheet = new InviteMembersBottomSheet(getContext(), ((BaseFragment) this).currentAccount, longSparseArray, this.chatInfo.id, this, this.themeDelegate);
        inviteMembersBottomSheet.setDelegate(new GroupCreateActivity.ContactsAddActivityDelegate() {
            @Override
            public final void didSelectUsers(ArrayList arrayList, int i2) {
                ChatActivity.this.lambda$createTopPanel$83(arrayList, i2);
            }

            @Override
            public void needAddBot(TLRPC.User user) {
                GroupCreateActivity.ContactsAddActivityDelegate.CC.$default$needAddBot(this, user);
            }
        });
        inviteMembersBottomSheet.show();
    }

    public void lambda$createTopPanel$86(View view) {
        TopicsController topicsController = getMessagesController().getTopicsController();
        long j = this.currentChat.id;
        TLRPC.TL_forumTopic tL_forumTopic = this.forumTopic;
        int i = tL_forumTopic.id;
        tL_forumTopic.closed = false;
        topicsController.toggleCloseTopic(j, i, false);
        updateTopicButtons();
        updateBottomOverlay();
        updateTopPanel(true);
    }

    public void lambda$createTopPanel$87(View view) {
        long j = this.dialog_id;
        if (this.currentEncryptedChat != null) {
            j = this.currentUser.id;
        }
        this.shownBotVerification = false;
        getMessagesController().hidePeerSettingsBar(j, this.currentUser, this.currentChat);
        updateTopPanel(true);
        updateInfoTopView(true);
    }

    public void lambda$createTopicsTabs$88() {
        presentFragment(TopicCreateFragment.create(-this.dialog_id, 0L).setOpenInChatActivity(this));
    }

    public void lambda$createTopicsTabs$89(java.lang.Integer r13, java.lang.Boolean r14) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.lambda$createTopicsTabs$89(java.lang.Integer, java.lang.Boolean):void");
    }

    public void lambda$createTopicsTabs$90(java.lang.Long r10, java.lang.Boolean r11) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.lambda$createTopicsTabs$90(java.lang.Long, java.lang.Boolean):void");
    }

    public boolean lambda$createView$18(View view, MotionEvent motionEvent) {
        ChatThemeBottomSheet chatThemeBottomSheet = this.chatThemeBottomSheet;
        if (chatThemeBottomSheet == null) {
            return false;
        }
        chatThemeBottomSheet.close();
        return true;
    }

    public void lambda$createView$19(int i, View view) {
        jumpToDate(i);
    }

    public void lambda$createView$20(int i) {
        ((BaseFragment) this).actionBar.setSubtitle(LocaleController.formatPluralString("messages", i, new Object[0]));
    }

    public void lambda$createView$21(final int i) {
        if (i != 0) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$createView$20(i);
                }
            });
        } else {
            ((BaseFragment) this).actionBar.setSubtitle(LocaleController.getString(R.string.NoMessagesForThisDay));
        }
    }

    public void lambda$createView$22(TLObject tLObject, TLObject tLObject2, TLRPC.TL_error tL_error) {
        if (tLObject2 instanceof TLRPC.messages_Messages) {
            TLRPC.messages_Messages messages_messages = (TLRPC.messages_Messages) tLObject2;
            boolean isEmpty = messages_messages.messages.isEmpty();
            final int i = ((TLRPC.messages_Messages) tLObject).offset_id_offset;
            if (!isEmpty) {
                i -= messages_messages.offset_id_offset;
            }
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$createView$21(i);
                }
            });
        }
    }

    public void lambda$createView$23(final TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tLObject instanceof TLRPC.messages_Messages) {
            if (((TLRPC.messages_Messages) tLObject).messages.isEmpty()) {
                ((BaseFragment) this).actionBar.setSubtitle(LocaleController.getString(R.string.NoMessagesForThisDay));
                return;
            }
            TLRPC.TL_messages_getHistory tL_messages_getHistory = new TLRPC.TL_messages_getHistory();
            tL_messages_getHistory.peer = getMessagesController().getInputPeer(this.dialog_id);
            tL_messages_getHistory.offset_date = this.startLoadFromDate + 86400;
            tL_messages_getHistory.limit = 1;
            getConnectionsManager().sendRequest(tL_messages_getHistory, new RequestDelegate() {
                public final void run(TLObject tLObject2, TLRPC.TL_error tL_error2) {
                    ChatActivity.this.lambda$createView$22(tLObject, tLObject2, tL_error2);
                }
            });
        }
    }

    public void lambda$createView$24() {
        toggleMute(true);
    }

    public void lambda$createView$25(View view) {
        if (!MessagesController.getInstance(((BaseFragment) this).currentAccount).isDialogMuted(this.dialog_id, getTopicId())) {
            this.muteItem.openSwipeBack();
            return;
        }
        updateTitleIcons(true);
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$createView$24();
            }
        }, 150L);
        this.headerItem.toggleSubMenu();
        if (getParentActivity() != null) {
            BulletinFactory.createMuteBulletin(this, false, this.themeDelegate).show();
        }
    }

    public void lambda$createView$26(Long l) {
        TopicsTabsView topicsTabsView = this.topicsTabs;
        if (topicsTabsView != null) {
            topicsTabsView.selectTopic(l.longValue(), true);
        }
    }

    public void lambda$createView$27(View view) {
        if (this.floatingDateView.getAlpha() == 0.0f || ((BaseFragment) this).actionBar.isActionModeShowed() || isReport()) {
            return;
        }
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(this.floatingDateView.getCustomDate() * 1000);
        int i = calendar.get(1);
        int i2 = calendar.get(2);
        int i3 = calendar.get(5);
        calendar.clear();
        calendar.set(i, i2, i3);
        jumpToDate((int) (calendar.getTime().getTime() / 1000));
    }

    public void lambda$createView$28(View view) {
        onPageDownClicked();
    }

    public void lambda$createView$29(View view) {
        if (this.chatMode == 7) {
            HashtagSearchController.getInstance(((BaseFragment) this).currentAccount).jumpToMessage(((BaseFragment) this).classGuid, this.hashtagSearchSelectedIndex + 1, this.searchType);
        } else {
            getMediaDataController().searchMessagesInChat((String) null, this.dialog_id, this.mergeDialogId, ((BaseFragment) this).classGuid, this.reversed ? 2 : 1, this.threadMessageId, this.searchingUserMessages, this.searchingChatMessages, this.searchingReaction);
            showMessagesSearchListView(false);
        }
    }

    public void lambda$createView$30(View view) {
        if (this.chatMode == 7) {
            HashtagSearchController.getInstance(((BaseFragment) this).currentAccount).jumpToMessage(((BaseFragment) this).classGuid, this.hashtagSearchSelectedIndex - 1, this.searchType);
        } else {
            getMediaDataController().searchMessagesInChat((String) null, this.dialog_id, this.mergeDialogId, ((BaseFragment) this).classGuid, this.reversed ? 1 : 2, this.threadMessageId, this.searchingUserMessages, this.searchingChatMessages, this.searchingReaction);
            showMessagesSearchListView(false);
        }
    }

    public void lambda$createView$31() {
        for (int i = 0; i < this.messages.size(); i++) {
            MessageObject messageObject = (MessageObject) this.messages.get(i);
            if (messageObject.messageOwner.mentioned && !messageObject.isContentUnread()) {
                messageObject.setContentIsRead();
            }
        }
        this.newMentionsCount = 0;
        getMessagesController().markMentionsAsRead(this.dialog_id, getTopicId());
        this.hasAllMentionsLocal = true;
        showMentionDownButton(false, true);
        ActionBarPopupWindow actionBarPopupWindow = this.scrimPopupWindow;
        if (actionBarPopupWindow != null) {
            actionBarPopupWindow.dismiss();
        }
    }

    public void lambda$createView$32() {
        this.scrimPopupWindow = null;
        this.menuDeleteItem = null;
        this.scrimPopupWindowItems = null;
        this.chatLayoutManager.setCanScrollVertically(true);
        dimBehindView(false);
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView == null || chatActivityEnterView.getEditField() == null) {
            return;
        }
        this.chatActivityEnterView.getEditField().setAllowDrawCursor(true);
    }

    public boolean lambda$createView$33(View view) {
        this.scrimPopupWindow = ReadAllMentionsMenu.show(1, getParentActivity(), getParentLayout(), this.contentView, view, getResourceProvider(), new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$createView$31();
            }
        });
        dimBehindView((View) this.mentiondownButton, true);
        this.scrimPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public final void onDismiss() {
                ChatActivity.this.lambda$createView$32();
            }
        });
        try {
            view.performHapticFeedback(0, 2);
        } catch (Exception unused) {
        }
        return true;
    }

    public boolean lambda$createView$34(View view, MotionEvent motionEvent) {
        return ContentPreviewViewer.getInstance().onTouch(motionEvent, this.mentionContainer.getListView(), 0, this.mentionsOnItemClickListener, this.mentionContainer.getAdapter().isStickers() ? this.contentPreviewViewerDelegate : null, this.themeDelegate);
    }

    public void lambda$createView$35(Object obj, Long l) {
        TLRPC.TL_messages_sendQuickReplyMessages tL_messages_sendQuickReplyMessages = new TLRPC.TL_messages_sendQuickReplyMessages();
        tL_messages_sendQuickReplyMessages.peer = getMessagesController().getInputPeer(this.dialog_id);
        tL_messages_sendQuickReplyMessages.shortcut_id = ((QuickRepliesController.QuickReply) obj).id;
        getConnectionsManager().sendRequest(tL_messages_sendQuickReplyMessages, (RequestDelegate) null);
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView != null) {
            chatActivityEnterView.setFieldText((CharSequence) null);
        }
    }

    public void lambda$createView$36(TLRPC.TL_document tL_document, String str, Object obj, boolean z, int i) {
        SendMessagesHelper.getInstance(((BaseFragment) this).currentAccount).sendSticker(tL_document, str, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TL_stories.StoryItem) null, this.replyingQuote, (MessageObject.SendAnimationData) null, z, i, false, obj, this.quickReplyShortcut, getQuickReplyId(), 0L, getSendMonoForumPeerId(), getSendMessageSuggestionParams());
    }

    public void lambda$createView$37(final TLRPC.TL_document tL_document, final String str, final Object obj, MessageObject.SendAnimationData sendAnimationData, Long l) {
        if (this.chatMode == 1) {
            AlertsCreator.createScheduleDatePickerDialog(getParentActivity(), this.dialog_id, new AlertsCreator.ScheduleDatePickerDelegate() {
                public final void didSelectDate(boolean z, int i) {
                    ChatActivity.this.lambda$createView$36(tL_document, str, obj, z, i);
                }
            }, this.themeDelegate);
        } else {
            getSendMessagesHelper().sendSticker(tL_document, str, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TL_stories.StoryItem) null, this.replyingQuote, sendAnimationData, true, 0, false, obj, this.quickReplyShortcut, getQuickReplyId(), l.longValue(), getSendMonoForumPeerId(), getSendMessageSuggestionParams());
        }
        hideFieldPanel(false);
        this.chatActivityEnterView.addStickerToRecent(tL_document);
        this.chatActivityEnterView.setFieldText("");
    }

    public void lambda$createView$38(Object obj, boolean z, int i) {
        getSendMessagesHelper().sendMessage(SendMessagesHelper.SendMessageParams.of((String) obj, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TLRPC.WebPage) null, false, (ArrayList) null, (TLRPC.ReplyMarkup) null, (HashMap) null, z, i, (MessageObject.SendAnimationData) null, false));
        this.chatActivityEnterView.setFieldText("");
        hideFieldPanel(false);
    }

    public void lambda$createView$39(Object obj, Long l) {
        SendMessagesHelper.SendMessageParams of = SendMessagesHelper.SendMessageParams.of((String) obj, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TLRPC.WebPage) null, false, (ArrayList) null, (TLRPC.ReplyMarkup) null, (HashMap) null, true, 0, (MessageObject.SendAnimationData) null, false);
        of.quick_reply_shortcut = this.quickReplyShortcut;
        of.quick_reply_shortcut_id = getQuickReplyId();
        of.payStars = l.longValue();
        of.monoForumPeer = getSendMonoForumPeerId();
        of.suggestionParams = this.messageSuggestionParams;
        getSendMessagesHelper().sendMessage(of);
        this.chatActivityEnterView.setFieldText("");
        hideFieldPanel(false);
    }

    public void lambda$createView$40(TLRPC.BotInlineResult botInlineResult, Long l, boolean z, int i) {
        sendBotInlineResult(botInlineResult, z, i, l.longValue());
    }

    public void lambda$createView$41(final TLRPC.BotInlineResult botInlineResult, final Long l) {
        if (this.chatMode == 1) {
            AlertsCreator.createScheduleDatePickerDialog(getParentActivity(), this.dialog_id, new AlertsCreator.ScheduleDatePickerDelegate() {
                public final void didSelectDate(boolean z, int i) {
                    ChatActivity.this.lambda$createView$40(botInlineResult, l, z, i);
                }
            }, this.themeDelegate);
        } else {
            sendBotInlineResult(botInlineResult, true, 0, l.longValue());
        }
    }

    public void lambda$createView$42(View view, int i) {
        int i2;
        long dialogId;
        Utilities.Callback callback;
        ChatActivityEnterView chatActivityEnterView;
        StringBuilder sb;
        String str;
        BlurredFrameLayout blurredFrameLayout;
        BlurredFrameLayout blurredFrameLayout2;
        if (i == 0 || this.mentionContainer.getAdapter().isBannedInline()) {
            return;
        }
        int i3 = i - 1;
        final Object item = this.mentionContainer.getAdapter().getItem(i3);
        int resultStartPosition = this.mentionContainer.getAdapter().getResultStartPosition();
        int resultLength = this.mentionContainer.getAdapter().getResultLength();
        char c = 0;
        if (this.mentionContainer.getAdapter().isLocalHashtagHint(i3)) {
            this.chatActivityEnterView.replaceWithText(resultStartPosition, resultLength, this.mentionContainer.getAdapter().getHashtagHint() + "@" + ChatObject.getPublicUsername(this.currentChat) + " ", false);
            return;
        }
        if (this.mentionContainer.getAdapter().isGlobalHashtagHint(i3)) {
            this.chatActivityEnterView.replaceWithText(resultStartPosition, resultLength, this.mentionContainer.getAdapter().getHashtagHint() + " ", false);
            return;
        }
        if (item instanceof QuickRepliesController.QuickReply) {
            if (getUserConfig().isPremium()) {
                AlertsCreator.ensurePaidMessageConfirmation(((BaseFragment) this).currentAccount, this.dialog_id, Math.max(1, ((QuickRepliesController.QuickReply) item).getMessagesCount()), new Utilities.Callback() {
                    public final void run(Object obj) {
                        ChatActivity.this.lambda$createView$35(item, (Long) obj);
                    }
                });
                return;
            } else {
                showDialog(new PremiumFeatureBottomSheet(this, getContext(), ((BaseFragment) this).currentAccount, true, 31, false, null));
                return;
            }
        }
        Paint.FontMetricsInt fontMetricsInt = null;
        if (item instanceof TLRPC.TL_document) {
            if (this.chatMode == 0 && checkSlowMode(view)) {
                return;
            }
            final MessageObject.SendAnimationData sendAnimationData = view instanceof StickerCell ? ((StickerCell) view).getSendAnimationData() : null;
            final TLRPC.TL_document tL_document = (TLRPC.TL_document) item;
            final Object itemParent = this.mentionContainer.getAdapter().getItemParent(i3);
            final String findAnimatedEmojiEmoticon = MessageObject.findAnimatedEmojiEmoticon(tL_document);
            AlertsCreator.ensurePaidMessageConfirmation(((BaseFragment) this).currentAccount, getDialogId(), 1, new Utilities.Callback() {
                public final void run(Object obj) {
                    ChatActivity.this.lambda$createView$37(tL_document, findAnimatedEmojiEmoticon, itemParent, sendAnimationData, (Long) obj);
                }
            });
            return;
        }
        if (item instanceof TLRPC.Chat) {
            TLRPC.Chat chat = (TLRPC.Chat) item;
            if (this.searchingForUser && (blurredFrameLayout2 = this.searchContainer) != null && blurredFrameLayout2.getVisibility() == 0) {
                searchUserMessages(null, chat);
                return;
            }
            String publicUsername = ChatObject.getPublicUsername(chat);
            if (publicUsername != null) {
                this.chatActivityEnterView.replaceWithText(resultStartPosition, resultLength, "@" + publicUsername + " ", false);
                return;
            }
            return;
        }
        if (!(item instanceof TLRPC.User)) {
            if (item instanceof String) {
                if (!this.mentionContainer.getAdapter().isBotCommands()) {
                    chatActivityEnterView = this.chatActivityEnterView;
                    sb = new StringBuilder();
                    sb.append(item);
                } else if (this.chatMode == 1) {
                    AlertsCreator.createScheduleDatePickerDialog(getParentActivity(), this.dialog_id, new AlertsCreator.ScheduleDatePickerDelegate() {
                        public final void didSelectDate(boolean z, int i4) {
                            ChatActivity.this.lambda$createView$38(item, z, i4);
                        }
                    }, this.themeDelegate);
                    return;
                } else {
                    if (checkSlowMode(view)) {
                        return;
                    }
                    i2 = ((BaseFragment) this).currentAccount;
                    dialogId = this.dialog_id;
                    callback = new Utilities.Callback() {
                        public final void run(Object obj) {
                            ChatActivity.this.lambda$createView$39(item, (Long) obj);
                        }
                    };
                }
            } else {
                if (!(item instanceof TLRPC.BotInlineResult)) {
                    if (item instanceof TLRPC.TL_inlineBotWebView) {
                        processInlineBotWebView((TLRPC.TL_inlineBotWebView) item);
                        return;
                    }
                    if (item instanceof TLRPC.TL_inlineBotSwitchPM) {
                        processInlineBotContextPM((TLRPC.TL_inlineBotSwitchPM) item);
                        return;
                    }
                    if (item instanceof MediaDataController.KeywordResult) {
                        String str2 = ((MediaDataController.KeywordResult) item).emoji;
                        this.chatActivityEnterView.addEmojiToRecent(str2);
                        if (str2 != null && str2.startsWith("animated_")) {
                            try {
                                try {
                                    fontMetricsInt = this.chatActivityEnterView.getEditField().getPaint().getFontMetricsInt();
                                } catch (Exception e) {
                                    FileLog.e(e, false);
                                }
                                long parseLong = Long.parseLong(str2.substring(9));
                                TLRPC.Document findDocument = AnimatedEmojiDrawable.findDocument(((BaseFragment) this).currentAccount, parseLong);
                                SpannableString spannableString = new SpannableString(MessageObject.findAnimatedEmojiEmoticon(findDocument));
                                spannableString.setSpan(findDocument != null ? new AnimatedEmojiSpan(findDocument, fontMetricsInt) : new AnimatedEmojiSpan(parseLong, fontMetricsInt), 0, spannableString.length(), 33);
                                this.chatActivityEnterView.replaceWithText(resultStartPosition, resultLength, spannableString, false);
                            } catch (Exception unused) {
                            }
                            this.mentionContainer.updateVisibility(false);
                            return;
                        }
                        this.chatActivityEnterView.replaceWithText(resultStartPosition, resultLength, str2, true);
                        this.mentionContainer.updateVisibility(false);
                        return;
                    }
                    return;
                }
                if (this.chatActivityEnterView.getFieldText() == null) {
                    return;
                }
                if (this.chatMode != 1 && checkSlowMode(view)) {
                    return;
                }
                final TLRPC.BotInlineResult botInlineResult = (TLRPC.BotInlineResult) item;
                if (this.currentEncryptedChat != null) {
                    if ((botInlineResult.send_message instanceof TLRPC.TL_botInlineMessageMediaAuto) && "game".equals(botInlineResult.type)) {
                        c = 1;
                    } else if (botInlineResult.send_message instanceof TLRPC.TL_botInlineMessageMediaInvoice) {
                        c = 2;
                    }
                    if (c != 0) {
                        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity(), this.themeDelegate);
                        builder.setTitle(LocaleController.getString(R.string.SendMessageTitle));
                        builder.setMessage(LocaleController.getString(c == 1 ? R.string.GameCantSendSecretChat : R.string.InvoiceCantSendSecretChat));
                        builder.setNegativeButton(LocaleController.getString(R.string.OK), null);
                        showDialog(builder.create());
                        return;
                    }
                }
                if ((botInlineResult.type.equals("photo") && (botInlineResult.photo != null || botInlineResult.content != null)) || ((botInlineResult.type.equals("gif") && (botInlineResult.document != null || botInlineResult.content != null)) || (botInlineResult.type.equals("video") && botInlineResult.document != null))) {
                    ArrayList arrayList = new ArrayList(this.mentionContainer.getAdapter().getSearchResultBotContext());
                    this.botContextResults = arrayList;
                    PhotoViewer.getInstance().setParentActivity(this, this.themeDelegate);
                    PhotoViewer.getInstance().openPhotoForSelect(arrayList, this.mentionContainer.getAdapter().getItemPosition(i3), 3, false, this.botContextProvider, this);
                    return;
                }
                i2 = ((BaseFragment) this).currentAccount;
                dialogId = getDialogId();
                callback = new Utilities.Callback() {
                    public final void run(Object obj) {
                        ChatActivity.this.lambda$createView$41(botInlineResult, (Long) obj);
                    }
                };
            }
            AlertsCreator.ensurePaidMessageConfirmation(i2, dialogId, 1, callback);
            return;
        }
        TLRPC.User user = (TLRPC.User) item;
        if (this.searchingForUser && (blurredFrameLayout = this.searchContainer) != null && blurredFrameLayout.getVisibility() == 0) {
            searchUserMessages(user, null);
            return;
        }
        if (UserObject.getPublicUsername(user) == null) {
            ?? spannableString2 = new SpannableString(UserObject.getFirstName(user, false) + " ");
            spannableString2.setSpan(new URLSpanUserMention("" + user.id, 3), 0, spannableString2.length(), 33);
            chatActivityEnterView = this.chatActivityEnterView;
            str = spannableString2;
            chatActivityEnterView.replaceWithText(resultStartPosition, resultLength, str, false);
        }
        chatActivityEnterView = this.chatActivityEnterView;
        sb = new StringBuilder();
        sb.append("@");
        sb.append(UserObject.getPublicUsername(user));
        sb.append(" ");
        str = sb.toString();
        chatActivityEnterView.replaceWithText(resultStartPosition, resultLength, str, false);
    }

    public void lambda$createView$43(AlertDialog alertDialog, int i) {
        this.mentionContainer.getAdapter().clearRecentHashtags();
    }

    public boolean lambda$createView$44(View view, int i) {
        boolean z = false;
        if (getParentActivity() != null && this.mentionContainer.getAdapter().isLongClickEnabled() && i != 0 && !this.mentionContainer.getAdapter().isBannedInline()) {
            Object item = this.mentionContainer.getAdapter().getItem(i - 1);
            if (item instanceof String) {
                if (!this.mentionContainer.getAdapter().isBotCommands()) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity(), this.themeDelegate);
                    builder.setTitle(LocaleController.getString(R.string.AppName));
                    builder.setMessage(LocaleController.getString(R.string.ClearSearch));
                    builder.setPositiveButton(LocaleController.getString(R.string.ClearButton), new AlertDialog.OnButtonClickListener() {
                        @Override
                        public final void onClick(AlertDialog alertDialog, int i2) {
                            ChatActivity.this.lambda$createView$43(alertDialog, i2);
                        }
                    });
                    builder.setNegativeButton(LocaleController.getString(R.string.Cancel), null);
                    showDialog(builder.create());
                    return true;
                }
                if (!URLSpanBotCommand.enabled) {
                    return false;
                }
                this.chatActivityEnterView.setFieldText("");
                ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
                String str = (String) item;
                TLRPC.Chat chat = this.currentChat;
                if (chat != null && chat.megagroup) {
                    z = true;
                }
                chatActivityEnterView.setCommand((MessageObject) null, str, true, z);
                return true;
            }
        }
        return false;
    }

    public void lambda$createView$45(Integer num) {
        if (num.intValue() != 0) {
            updateReactionsMentionButton(true);
            scrollToMessageId(num.intValue(), 0, false, 0, true, 0);
        } else {
            this.reactionsMentionCount = 0;
            updateReactionsMentionButton(true);
            getMessagesController().markReactionsAsRead(this.dialog_id, getTopicId());
        }
    }

    public void lambda$createView$46(View view) {
        this.wasManualScroll = true;
        getMessagesController().getNextReactionMention(this.dialog_id, getTopicId(), this.reactionsMentionCount, new androidx.core.util.Consumer() {
            public final void accept(Object obj) {
                ChatActivity.this.lambda$createView$45((Integer) obj);
            }
        });
    }

    public void lambda$createView$47() {
        for (int i = 0; i < this.messages.size(); i++) {
            ((MessageObject) this.messages.get(i)).markReactionsAsRead();
        }
        this.reactionsMentionCount = 0;
        updateReactionsMentionButton(true);
        getMessagesController().markReactionsAsRead(this.dialog_id, getTopicId());
        ActionBarPopupWindow actionBarPopupWindow = this.scrimPopupWindow;
        if (actionBarPopupWindow != null) {
            actionBarPopupWindow.dismiss();
        }
    }

    public void lambda$createView$48() {
        this.scrimPopupWindow = null;
        this.menuDeleteItem = null;
        this.scrimPopupWindowItems = null;
        this.chatLayoutManager.setCanScrollVertically(true);
        dimBehindView(false);
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView == null || chatActivityEnterView.getEditField() == null) {
            return;
        }
        this.chatActivityEnterView.getEditField().setAllowDrawCursor(true);
    }

    public boolean lambda$createView$49(View view) {
        this.scrimPopupWindow = ReadAllMentionsMenu.show(0, getParentActivity(), getParentLayout(), this.contentView, view, getResourceProvider(), new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$createView$47();
            }
        });
        dimBehindView((View) this.reactionsMentiondownButton, true);
        this.scrimPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public final void onDismiss() {
                ChatActivity.this.lambda$createView$48();
            }
        });
        try {
            view.performHapticFeedback(0, 2);
        } catch (Exception unused) {
        }
        return false;
    }

    public void lambda$createView$50(DialogInterface dialogInterface) {
        showPinnedProgress(false);
    }

    public void lambda$createView$51() {
        AlertDialog alertDialog = new AlertDialog(getParentActivity(), 3, this.themeDelegate);
        this.progressDialog = alertDialog;
        alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {
            @Override
            public final void onShow(DialogInterface dialogInterface) {
                ChatActivity.this.lambda$createView$50(dialogInterface);
            }
        });
        this.progressDialog.setOnCancelListener(this.postponedScrollCancelListener);
        this.progressDialog.showDelayed(500L);
    }

    public void lambda$createView$52(MessageObject messageObject) {
        scrollToMessageId(messageObject.getId(), 0, true, 0, true, 0, new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$createView$51();
            }
        });
        if (this.waitingForLoad.isEmpty()) {
            showMessagesSearchListView(false);
        }
    }

    public void lambda$createView$53(View view, int i) {
        if (this.chatMode != 7) {
            if (this.searchingReaction == null) {
                getMediaDataController().jumpToSearchedMessage(((BaseFragment) this).classGuid, i);
                showMessagesSearchListView(false);
                return;
            } else {
                if (i < 0 || i >= getMediaDataController().searchResultMessages.size()) {
                    return;
                }
                final MessageObject messageObject = (MessageObject) getMediaDataController().searchResultMessages.get(i);
                this.searchingFiltered = false;
                setFilterMessages(false, true, false);
                getMediaDataController().setSearchedPosition(i);
                updateSearchButtons(getMediaDataController().getMask(), getMediaDataController().getSearchPosition(), getMediaDataController().getSearchCount());
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.this.lambda$createView$52(messageObject);
                    }
                });
                return;
            }
        }
        Object item = this.messagesSearchAdapter.getItem(i);
        if (i == 0) {
            MessagesSearchAdapter messagesSearchAdapter = this.messagesSearchAdapter;
            if (messagesSearchAdapter.containsStories && messagesSearchAdapter.storiesList != null) {
                Bundle bundle = new Bundle();
                bundle.putInt("type", 3);
                bundle.putString("hashtag", this.messagesSearchAdapter.storiesList.query);
                String str = this.messagesSearchAdapter.storiesList.username;
                if (str != null) {
                    bundle.putString("username", str);
                }
                bundle.putInt("storiesCount", this.messagesSearchAdapter.storiesList.getCount());
                presentFragment(new MediaActivity(bundle, (SharedMediaLayout.SharedMediaPreloader) null));
                return;
            }
        }
        if (item instanceof MessageObject) {
            openMessageInOriginalDialog((MessageObject) item);
        }
    }

    public boolean lambda$createView$54(View view, MotionEvent motionEvent) {
        if (motionEvent.getAction() == 0) {
            checkRecordLocked(false);
        }
        this.overlayView.getParent().requestDisallowInterceptTouchEvent(true);
        return true;
    }

    public static boolean lambda$createView$55(View view, MotionEvent motionEvent) {
        return true;
    }

    public void lambda$createView$56(Integer num) {
        if (this.chatAttachAlert == null) {
            createChatAttachView();
        }
        this.chatAttachAlert.setEditingMessageObject(num.intValue(), this.editingMessageObject);
        openAttachMenu();
    }

    public void lambda$createView$57(boolean[] zArr, Context context, View view) {
        MessageObject messageObject;
        MessageObject messageObject2;
        boolean z = zArr[0];
        if (z) {
            zArr[0] = false;
        }
        int i = this.fieldPanelShown;
        if (i == 5) {
            int i2 = ((BaseFragment) this).currentAccount;
            long j = this.dialog_id;
            MessageSuggestionParams messageSuggestionParams = this.messageSuggestionParams;
            if (messageSuggestionParams == null) {
                messageSuggestionParams = MessageSuggestionParams.empty();
            }
            new MessageSuggestionOfferSheet(context, i2, j, messageSuggestionParams, this, getResourceProvider(), 0, new ChatActivity$$ExternalSyntheticLambda115(this)).show();
            return;
        }
        if (i != 1 || (messageObject2 = this.editingMessageObject) == null) {
            if (this.messagePreviewParams == null) {
                return;
            }
            this.forbidForwardingWithDismiss = false;
            if (i != 2) {
                if (i == 3) {
                    SharedConfig.forwardingOptionsHintHintShowed();
                    openForwardingPreview(1);
                    return;
                } else {
                    if (i == 4) {
                        openForwardingPreview(2);
                        return;
                    }
                    return;
                }
            }
            if (!DialogObject.isEncryptedDialog(this.dialog_id)) {
                MessagePreviewParams messagePreviewParams = this.messagePreviewParams;
                if (!messagePreviewParams.hasSecretMessages && this.chatMode != 5) {
                    this.forbidForwardingWithDismiss = messagePreviewParams.quote == null;
                    SharedConfig.replyingOptionsHintHintShowed();
                    openForwardingPreview(0);
                    return;
                }
            }
            messageObject = this.replyingMessageObject;
            if (messageObject == null) {
                return;
            }
        } else {
            if (messageObject2.needResendWhenEdit() && !z) {
                MessageSuggestionParams messageSuggestionParams2 = this.messageSuggestionParams;
                if (messageSuggestionParams2 == null) {
                    messageSuggestionParams2 = MessageSuggestionParams.empty();
                }
                showSuggestionOfferForEditMessage(messageSuggestionParams2);
                return;
            }
            if (this.editingMessageObject.canEditMedia() && this.editingMessageObjectReqId == 0) {
                new Utilities.Callback() {
                    public final void run(Object obj) {
                        ChatActivity.this.lambda$createView$56((Integer) obj);
                    }
                }.run(-1);
                return;
            }
            messageObject = this.editingMessageObject;
        }
        scrollToMessageId(messageObject.getId(), 0, true, 0, true, 0);
    }

    public boolean lambda$createView$58(View view) {
        MessageObject messageObject;
        MessageObject messageObject2;
        int i = this.fieldPanelShown;
        if (i == 1 && (messageObject2 = this.editingMessageObject) != null) {
            scrollToMessageId(messageObject2.getId(), 0, true, 0, true, 0);
            return true;
        }
        if (this.messagePreviewParams == null || i != 2 || (messageObject = this.replyingMessageObject) == null) {
            return false;
        }
        scrollToMessageId(messageObject.getId(), 0, true, 0, true, 0);
        return true;
    }

    public void lambda$createView$59(View view) {
        MessageObject messageObject;
        this.messageSuggestionParams = null;
        int i = this.fieldPanelShown;
        if (i == 2) {
            this.replyingQuote = null;
            this.replyingMessageObject = null;
            MessagePreviewParams messagePreviewParams = this.messagePreviewParams;
            if (messagePreviewParams != null) {
                messagePreviewParams.updateReply((MessageObject) null, (MessageObject.GroupedMessages) null, this.dialog_id, (ReplyQuote) null);
            }
        } else {
            if (i == 3) {
                openAnotherForward();
                return;
            }
            if (i != 4) {
                if (ChatObject.isForum(this.currentChat) && !this.isTopic && (messageObject = this.replyingMessageObject) != null) {
                    long topicId = MessageObject.getTopicId(((BaseFragment) this).currentAccount, messageObject.messageOwner, true);
                    if (topicId != 0) {
                        getMediaDataController().cleanDraft(this.dialog_id, topicId, false);
                    }
                }
                showFieldPanel(false, null, null, null, null, true, 0, null, true, 0L, true);
                return;
            }
            this.foundWebPage = null;
            MessagePreviewParams messagePreviewParams2 = this.messagePreviewParams;
            if (messagePreviewParams2 != null) {
                int i2 = ((BaseFragment) this).currentAccount;
                MessageObject messageObject2 = this.replyingMessageObject;
                messagePreviewParams2.updateLink(i2, (TLRPC.WebPage) null, (CharSequence) null, messageObject2 == this.threadMessageObject ? null : messageObject2, this.replyingQuote, this.editingMessageObject);
            }
            this.chatActivityEnterView.setWebPage((TLRPC.WebPage) null, false);
            editResetMediaManual();
        }
        fallbackFieldPanel();
    }

    public void lambda$createView$60(View view) {
        MessageObject messageObject = this.editingMessageObject;
        if (messageObject != null) {
            scrollToMessageId(messageObject.getId(), 0, true, 0, true, 0);
        }
    }

    public void lambda$createView$61(ChatActivityEnterTopView.EditViewButton editViewButton, boolean[] zArr, FrameLayout frameLayout, View view) {
        MessageObject messageObject = this.editingMessageObject;
        if (messageObject != null && messageObject.canEditMedia() && this.editingMessageObjectReqId == 0) {
            if (editViewButton.isEditButton()) {
                openEditingMessageInPhotoEditor();
            } else {
                zArr[0] = true;
                frameLayout.callOnClick();
            }
        }
    }

    public void lambda$createView$62(View view) {
        this.bottomOverlayChatText.callOnClick();
    }

    public void lambda$createView$63(View view) {
        if (this.chatMode != 0 || getMessagesController().freezeUntilDate <= getConnectionsManager().getCurrentTime() || AccountFrozenAlert.isSpamBot(((BaseFragment) this).currentAccount, this.currentUser)) {
            return;
        }
        AccountFrozenAlert.show(getContext(), ((BaseFragment) this).currentAccount, getResourceProvider());
    }

    public void lambda$createView$64(Boolean bool) {
        showBottomOverlayProgress(true, false);
        if (bool.booleanValue()) {
            lambda$onBackPressed$354();
        }
    }

    public void lambda$createView$65(String str) {
        if (str == null || str.length() == 0) {
            getSendMessagesHelper().sendMessage(SendMessagesHelper.SendMessageParams.of("/start", this.dialog_id, (MessageObject) null, (MessageObject) null, (TLRPC.WebPage) null, false, (ArrayList) null, (TLRPC.ReplyMarkup) null, (HashMap) null, true, 0, (MessageObject.SendAnimationData) null, false));
        } else {
            getMessagesController().sendBotStart(this.currentUser, str);
        }
    }

    public void lambda$createView$66(AlertDialog alertDialog, int i) {
        getMessagesController().unblockPeer(this.currentUser.id);
    }

    public void lambda$createView$67() {
        showBottomOverlayProgress(false, true);
    }

    public boolean lambda$createView$68(Context context, TLRPC.TL_error tL_error) {
        MessagesController.getNotificationsSettings(((BaseFragment) this).currentAccount).edit().putLong("dialog_join_requested_time_" + this.dialog_id, System.currentTimeMillis()).commit();
        if (tL_error != null && "INVITE_REQUEST_SENT".equals(tL_error.text)) {
            JoinGroupAlert.showBulletin(context, this, ChatObject.isChannel(this.currentChat) && !this.currentChat.megagroup);
        }
        showBottomOverlayProgress(false, true);
        return false;
    }

    public void lambda$createView$69(boolean z) {
        NotificationCenter notificationCenter = getNotificationCenter();
        int i = NotificationCenter.closeChats;
        notificationCenter.removeObserver(this, i);
        getNotificationCenter().postNotificationName(i, new Object[0]);
        lambda$onBackPressed$354();
        getNotificationCenter().postNotificationName(NotificationCenter.needDeleteDialog, new Object[]{Long.valueOf(this.dialog_id), this.currentUser, this.currentChat, Boolean.valueOf(z)});
    }

    public void lambda$createView$70(final Context context, View view) {
        String str;
        String str2;
        if (getParentActivity() == null || this.pullingDownOffset != 0.0f) {
            return;
        }
        if (this.chatMode == 3) {
            Bundle bundle = new Bundle();
            long savedDialogId = getSavedDialogId();
            if (savedDialogId >= 0) {
                str2 = "user_id";
            } else {
                savedDialogId = -savedDialogId;
                str2 = "chat_id";
            }
            bundle.putLong(str2, savedDialogId);
            presentFragment(new ChatActivity(bundle));
            return;
        }
        if (isReport()) {
            ArrayList arrayList = new ArrayList();
            for (int i = 0; i < this.selectedMessagesIds[0].size(); i++) {
                arrayList.add(Integer.valueOf(this.selectedMessagesIds[0].keyAt(i)));
            }
            showBottomOverlayProgress(true, true);
            ReportBottomSheet.continueReport(this, this.reportOption, this.reportMessage, arrayList, new Utilities.Callback() {
                public final void run(Object obj) {
                    ChatActivity.this.lambda$createView$64((Boolean) obj);
                }
            });
            return;
        }
        if (this.chatMode == 2) {
            lambda$onBackPressed$354();
            this.chatActivityDelegate.onUnpin(true, this.bottomOverlayChatText.getTag() == null);
            return;
        }
        TLRPC.User user = this.currentUser;
        if (user == null || user.id != 489000) {
            if (user != null && this.userBlocked) {
                if (user.bot) {
                    final String str3 = this.botUser;
                    this.botUser = null;
                    getMessagesController().unblockPeer(this.currentUser.id, new Runnable() {
                        @Override
                        public final void run() {
                            ChatActivity.this.lambda$createView$65(str3);
                        }
                    });
                    return;
                } else {
                    AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity(), this.themeDelegate);
                    builder.setMessage(LocaleController.getString(R.string.AreYouSureUnblockContact));
                    builder.setPositiveButton(LocaleController.getString(R.string.OK), new AlertDialog.OnButtonClickListener() {
                        @Override
                        public final void onClick(AlertDialog alertDialog, int i2) {
                            ChatActivity.this.lambda$createView$66(alertDialog, i2);
                        }
                    });
                    builder.setTitle(LocaleController.getString(R.string.AppName));
                    builder.setNegativeButton(LocaleController.getString(R.string.Cancel), null);
                    showDialog(builder.create());
                    return;
                }
            }
            if (!UserObject.isReplyUser(user)) {
                TLRPC.User user2 = this.currentUser;
                if (user2 != null && user2.bot && (str = this.botUser) != null) {
                    if (str.length() != 0) {
                        getMessagesController().sendBotStart(this.currentUser, this.botUser);
                    } else {
                        getSendMessagesHelper().sendMessage(SendMessagesHelper.SendMessageParams.of("/start", this.dialog_id, (MessageObject) null, (MessageObject) null, (TLRPC.WebPage) null, false, (ArrayList) null, (TLRPC.ReplyMarkup) null, (HashMap) null, true, 0, (MessageObject.SendAnimationData) null, false));
                    }
                    this.botUser = null;
                    updateBottomOverlay();
                    return;
                }
                if (ChatObject.isChannel(this.currentChat)) {
                    TLRPC.Chat chat = this.currentChat;
                    if (!(chat instanceof TLRPC.TL_channelForbidden)) {
                        if (ChatObject.isNotInChat(chat)) {
                            if (this.currentChat.join_request) {
                                showBottomOverlayProgress(true, true);
                                MessagesController.getInstance(((BaseFragment) this).currentAccount).addUserToChat(this.currentChat.id, UserConfig.getInstance(((BaseFragment) this).currentAccount).getCurrentUser(), 0, (String) null, (BaseFragment) null, true, new Runnable() {
                                    @Override
                                    public final void run() {
                                        ChatActivity.this.lambda$createView$67();
                                    }
                                }, new MessagesController.ErrorDelegate() {
                                    public final boolean run(TLRPC.TL_error tL_error) {
                                        boolean lambda$createView$68;
                                        lambda$createView$68 = ChatActivity.this.lambda$createView$68(context, tL_error);
                                        return lambda$createView$68;
                                    }
                                });
                                return;
                            }
                            Runnable runnable = this.chatInviteRunnable;
                            if (runnable != null) {
                                AndroidUtilities.cancelRunOnUIThread(runnable);
                                this.chatInviteRunnable = null;
                            }
                            showBottomOverlayProgress(true, true);
                            getMessagesController().addUserToChat(this.currentChat.id, getUserConfig().getCurrentUser(), 0, (String) null, this, (Runnable) null);
                            NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.closeSearchByActiveAction, new Object[0]);
                            if (!hasReportSpam() || this.reportSpamButton.getTag(R.id.object_tag) == null) {
                                return;
                            }
                            MessagesController.getNotificationsSettings(((BaseFragment) this).currentAccount).edit().putInt("dialog_bar_vis3" + this.dialog_id, 3).commit();
                            getNotificationCenter().postNotificationName(NotificationCenter.peerSettingsDidLoad, new Object[]{Long.valueOf(this.dialog_id)});
                            return;
                        }
                    }
                }
                TLRPC.ChatFull chatFull = this.chatInfo;
                AlertsCreator.createClearOrDeleteDialogAlert(this, false, this.currentChat, this.currentUser, this.currentEncryptedChat != null, true, chatFull != null && chatFull.can_delete_channel, new MessagesStorage.BooleanCallback() {
                    public final void run(boolean z) {
                        ChatActivity.this.lambda$createView$69(z);
                    }
                }, this.themeDelegate);
                return;
            }
        }
        toggleMute(true);
    }

    public void lambda$createView$71(View view) {
        createUndoView();
        this.undoView.showWithAction(this.dialog_id, 18, LocaleController.getString(R.string.BroadcastGroupInfo));
    }

    public boolean lambda$createView$72() {
        return this.currentEncryptedChat != null || getMessagesController().isChatNoForwards(this.currentChat);
    }

    public void lambda$createView$73(float[] fArr) {
        fArr[1] = this.chatListView.getBottom() - this.blurredViewBottomOffset;
        fArr[0] = (this.chatListView.getTop() + this.chatListViewPaddingTop) - AndroidUtilities.dp(4.0f);
    }

    public void lambda$createView$74() {
        HintView2 hintView2;
        BlurredFrameLayout blurredFrameLayout = this.searchContainer;
        if ((blurredFrameLayout == null || blurredFrameLayout.getVisibility() != 0) && (hintView2 = this.savedMessagesSearchHint) != null) {
            hintView2.show();
        }
    }

    public void lambda$deleteHistory$2() {
        this.chatAdapter.frozenMessages.clear();
        ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
        chatActivityAdapter.isFrozen = false;
        chatActivityAdapter.notifyDataSetChanged(true);
        showProgressView(false);
    }

    public void lambda$deleteHistory$3(int i, int i2, boolean z) {
        getMessagesController().deleteMessagesRange(this.dialog_id, ChatObject.isChannel(this.currentChat) ? this.dialog_id : 0L, i, i2, z, new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$deleteHistory$2();
            }
        });
    }

    public void lambda$deleteHistory$4() {
        this.chatAdapter.frozenMessages.clear();
        ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
        chatActivityAdapter.isFrozen = false;
        chatActivityAdapter.notifyDataSetChanged(true);
        showProgressView(false);
    }

    public void lambda$didLongPressCard$401(ScrimOptions scrimOptions, String str) {
        scrimOptions.dismiss();
        AndroidUtilities.addToClipboard(str);
        BulletinFactory.of(this).createCopyBulletin(LocaleController.getString(R.string.CardNumberCopied)).show();
    }

    public void lambda$didLongPressCard$402(TLRPC.TL_bankCardOpenUrl tL_bankCardOpenUrl) {
        Browser.openUrl(getContext(), tL_bankCardOpenUrl.url, this.inlineReturn == 0, false);
    }

    public void lambda$didLongPressCard$403(Browser.Progress progress, ChatMessageCell chatMessageCell, final String str, TLObject tLObject, CharacterStyle characterStyle) {
        progress.end();
        ItemOptions makeOptions = ItemOptions.makeOptions(this, chatMessageCell, true);
        final ScrimOptions scrimOptions = new ScrimOptions(getContext(), this.themeDelegate);
        makeOptions.setOnDismiss(new ChatActivity$$ExternalSyntheticLambda97(scrimOptions));
        makeOptions.add(R.drawable.msg_copy, LocaleController.getString(R.string.CopyCardNumber), new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$didLongPressCard$401(scrimOptions, str);
            }
        });
        if (tLObject instanceof TLRPC.TL_payments_bankCardData) {
            TLRPC.TL_payments_bankCardData tL_payments_bankCardData = (TLRPC.TL_payments_bankCardData) tLObject;
            Iterator it = tL_payments_bankCardData.open_urls.iterator();
            while (it.hasNext()) {
                final TLRPC.TL_bankCardOpenUrl tL_bankCardOpenUrl = (TLRPC.TL_bankCardOpenUrl) it.next();
                makeOptions.add(R.drawable.msg_payment_card, tL_bankCardOpenUrl.name, new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.this.lambda$didLongPressCard$402(tL_bankCardOpenUrl);
                    }
                });
            }
            if (!TextUtils.isEmpty(tL_payments_bankCardData.title)) {
                makeOptions.addGap();
                makeOptions.addText(tL_payments_bankCardData.title, 13, AndroidUtilities.dp(200.0f));
            }
        }
        scrimOptions.setItemOptions(makeOptions);
        scrimOptions.setScrim(chatMessageCell, characterStyle, (CharSequence) null);
        showDialog(scrimOptions);
    }

    public void lambda$didLongPressCard$404(final Browser.Progress progress, final ChatMessageCell chatMessageCell, final String str, final CharacterStyle characterStyle, final TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$didLongPressCard$403(progress, chatMessageCell, str, tLObject, characterStyle);
            }
        });
    }

    public void lambda$didLongPressCard$405(int i) {
        getConnectionsManager().cancelRequest(i, true);
    }

    public void lambda$didLongPressCopyButton$420(String str, DialogInterface dialogInterface, int i) {
        AndroidUtilities.addToClipboard(str);
        BulletinFactory.of(this).createCopyBulletin(LocaleController.formatString(R.string.ExactTextCopied, new Object[]{str})).show();
    }

    public void lambda$didLongPressLink$397(String str, CharacterStyle characterStyle, MessageObject messageObject, ChatMessageCell chatMessageCell, boolean z, boolean z2) {
        if (str.startsWith("video?")) {
            didPressMessageUrl(characterStyle, false, messageObject, chatMessageCell);
        } else if (z && !z2) {
            Browser.openInTelegramBrowser(getParentActivity(), str, (Browser.Progress) null);
        } else {
            logSponsoredClicked(messageObject, false, false);
            openClickableLink(characterStyle, str, false, chatMessageCell, messageObject, false);
        }
    }

    public void lambda$didLongPressLink$398(String str) {
        Browser.openInExternalBrowser(getParentActivity(), str, false);
    }

    public void lambda$didLongPressLink$399(MessageObject messageObject) {
        TLRPC.WebPage webPage;
        TLRPC.MessageMedia messageMedia = messageObject.messageOwner.media;
        if (messageMedia == null || (webPage = messageMedia.webpage) == null || webPage.cached_page == null) {
            return;
        }
        LaunchActivity launchActivity = LaunchActivity.instance;
        if (launchActivity == null || launchActivity.getBottomSheetTabs() == null || LaunchActivity.instance.getBottomSheetTabs().tryReopenTab(messageObject) == null) {
            createArticleViewer(false).open(messageObject);
        }
    }

    public void lambda$didLongPressLink$400(java.lang.String r8, org.telegram.messenger.MessageObject r9, boolean r10) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.lambda$didLongPressLink$400(java.lang.String, org.telegram.messenger.MessageObject, boolean):void");
    }

    public void lambda$didLongPressUsername$406(long j) {
        presentFragment(of(j));
    }

    public void lambda$didLongPressUsername$407(ScrimOptions scrimOptions, String str) {
        scrimOptions.dismiss();
        AndroidUtilities.addToClipboard("@" + str);
        BulletinFactory.of(this).createCopyBulletin(LocaleController.getString(R.string.UsernameCopied)).show();
    }

    public void lambda$didLongPressUsername$408(String str) {
        Browser.openUrl(getContext(), "https://fragment.com/username/" + str);
    }

    public void lambda$didLongPressUsername$409(long j) {
        presentFragment(ProfileActivity.of(j));
    }

    public void lambda$didLongPressUsername$410(Browser.Progress progress, ChatMessageCell chatMessageCell, final String str, CharacterStyle characterStyle, TLObject tLObject, Boolean bool) {
        final long j;
        boolean z;
        progress.end();
        boolean z2 = false;
        if (tLObject instanceof TLRPC.User) {
            j = ((TLRPC.User) tLObject).id;
            z = true;
        } else {
            if (tLObject instanceof TLRPC.Chat) {
                TLRPC.Chat chat = (TLRPC.Chat) tLObject;
                j = -chat.id;
                z2 = ChatObject.isChannelAndNotMegaGroup(chat);
            } else {
                j = 0;
            }
            z = false;
        }
        ItemOptions makeOptions = ItemOptions.makeOptions(this, chatMessageCell, true);
        final ScrimOptions scrimOptions = new ScrimOptions(getContext(), this.themeDelegate);
        makeOptions.setOnDismiss(new ChatActivity$$ExternalSyntheticLambda97(scrimOptions));
        if (j != 0) {
            makeOptions.add(z2 ? R.drawable.msg_channel : R.drawable.msg_discussion, LocaleController.getString(z2 ? R.string.ViewChannel : R.string.SendMessage), new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$didLongPressUsername$406(j);
                }
            });
        }
        makeOptions.add(R.drawable.msg_copy, LocaleController.getString(R.string.ProfileCopyUsername), new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$didLongPressUsername$407(scrimOptions, str);
            }
        });
        if (bool.booleanValue()) {
            makeOptions.add(R.drawable.msg_ton, LocaleController.getString(R.string.BuyUsernameOnFragment), new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$didLongPressUsername$408(str);
                }
            });
        }
        makeOptions.addGap();
        if (j != 0) {
            makeOptions.addProfile(tLObject, LocaleController.getString(z ? R.string.ViewProfile : z2 ? R.string.ViewChannelProfile : R.string.ViewGroupProfile), new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$didLongPressUsername$409(j);
                }
            });
        } else {
            makeOptions.addText(LocaleController.getString(R.string.NoUsernameFound2), 13, AndroidUtilities.dp(200.0f));
        }
        scrimOptions.setItemOptions(makeOptions);
        scrimOptions.setScrim(chatMessageCell, characterStyle, (CharSequence) null);
        showDialog(scrimOptions);
    }

    public void lambda$didLongPressUsername$411(Browser.Progress progress, TLObject tLObject, Utilities.Callback2 callback2, boolean z) {
        TLRPC.User user;
        progress.end();
        if (tLObject instanceof TLRPC.TL_contacts_resolvedPeer) {
            TLRPC.TL_contacts_resolvedPeer tL_contacts_resolvedPeer = (TLRPC.TL_contacts_resolvedPeer) tLObject;
            getMessagesController().putUsers(tL_contacts_resolvedPeer.users, false);
            getMessagesController().putChats(tL_contacts_resolvedPeer.chats, false);
            long peerDialogId = DialogObject.getPeerDialogId(tL_contacts_resolvedPeer.peer);
            if (peerDialogId >= 0) {
                user = getMessagesController().getUser(Long.valueOf(peerDialogId));
            } else if (peerDialogId < 0) {
                user = getMessagesController().getChat(Long.valueOf(-peerDialogId));
            }
            callback2.run(user, Boolean.valueOf(z));
        }
        user = null;
        callback2.run(user, Boolean.valueOf(z));
    }

    public void lambda$didLongPressUsername$412(final Browser.Progress progress, final Utilities.Callback2 callback2, final boolean z, final TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$didLongPressUsername$411(progress, tLObject, callback2, z);
            }
        });
    }

    public void lambda$didLongPressUsername$413(int i) {
        getConnectionsManager().cancelRequest(i, true);
    }

    public void lambda$didLongPressUsername$414(TLRPC.TL_error tL_error, TLObject tLObject, TLObject tLObject2, final Utilities.Callback2 callback2, String str, final Browser.Progress progress) {
        final boolean z = tL_error != null && "USERNAME_PURCHASE_AVAILABLE".equals(tL_error.text);
        if (tLObject != null || (tL_error == null && (tLObject2 instanceof TLRPC.TL_boolTrue))) {
            callback2.run(tLObject, Boolean.valueOf(z));
            return;
        }
        TLRPC.TL_contacts_resolveUsername tL_contacts_resolveUsername = new TLRPC.TL_contacts_resolveUsername();
        tL_contacts_resolveUsername.username = str;
        final int sendRequest = getConnectionsManager().sendRequest(tL_contacts_resolveUsername, new RequestDelegate() {
            public final void run(TLObject tLObject3, TLRPC.TL_error tL_error2) {
                ChatActivity.this.lambda$didLongPressUsername$412(progress, callback2, z, tLObject3, tL_error2);
            }
        });
        progress.onCancel(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$didLongPressUsername$413(sendRequest);
            }
        });
        progress.init();
    }

    public void lambda$didLongPressUsername$415(final TLObject tLObject, final Utilities.Callback2 callback2, final String str, final Browser.Progress progress, final TLObject tLObject2, final TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$didLongPressUsername$414(tL_error, tLObject, tLObject2, callback2, str, progress);
            }
        });
    }

    public void lambda$didLongPressUsername$416(int i) {
        getConnectionsManager().cancelRequest(i, true);
    }

    public void lambda$didPressPhoneNumber$421(TLRPC.User user, String str, Boolean bool) {
        Intent intent;
        String str2;
        if (getParentActivity() == null) {
            return;
        }
        if (bool.booleanValue()) {
            intent = new Intent("android.intent.action.INSERT");
            str2 = "vnd.android.cursor.dir/raw_contact";
        } else {
            intent = new Intent("android.intent.action.INSERT_OR_EDIT");
            str2 = "vnd.android.cursor.item/contact";
        }
        intent.setType(str2);
        if (user != null) {
            intent.putExtra("name", ContactsController.formatName(user.first_name, user.last_name));
        }
        ArrayList<? extends Parcelable> arrayList = new ArrayList<>();
        ContentValues contentValues = new ContentValues();
        contentValues.put("mimetype", "vnd.android.cursor.item/phone_v2");
        if (!str.startsWith("+")) {
            TLRPC.User currentUser = getUserConfig().getCurrentUser();
            HashMap hashMap = new HashMap();
            boolean z = false;
            try {
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(ApplicationLoader.applicationContext.getResources().getAssets().open("countries.txt")));
                while (true) {
                    String readLine = bufferedReader.readLine();
                    if (readLine == null) {
                        break;
                    }
                    String[] split = readLine.split(";");
                    CountrySelectActivity.Country country = new CountrySelectActivity.Country();
                    country.name = split[2];
                    String str3 = split[0];
                    country.code = str3;
                    country.shortname = split[1];
                    List list = (List) hashMap.get(str3);
                    if (list == null) {
                        String str4 = split[0];
                        list = new ArrayList();
                        hashMap.put(str4, list);
                    }
                    list.add(country);
                }
                bufferedReader.close();
            } catch (Exception e) {
                FileLog.e(e);
            }
            String str5 = currentUser.phone;
            int i = 4;
            while (true) {
                if (i < 1) {
                    break;
                }
                List list2 = (List) hashMap.get(str5.substring(0, i));
                if (list2 == null || list2.size() <= 0) {
                    i--;
                } else {
                    String str6 = ((CountrySelectActivity.Country) list2.get(0)).code;
                    if (str6.endsWith("0") && str.startsWith("0")) {
                        str = str.substring(1);
                    }
                    str = "+" + str6 + str;
                    z = true;
                }
            }
            if (!z && Build.VERSION.SDK_INT >= 23) {
                Context context = ApplicationLoader.applicationContext;
                String upperCase = context != null ? ((TelephonyManager) ShortcutManagerCompat$.ExternalSyntheticApiModelOutline1.m(context, TelephonyManager.class)).getSimCountryIso().toUpperCase(Locale.US) : Locale.getDefault().getCountry();
                if (upperCase.endsWith("0") && str.startsWith("0")) {
                    str = str.substring(1);
                }
                str = "+" + upperCase + str;
            }
        }
        contentValues.put("data1", str);
        contentValues.put("data2", (Integer) 2);
        arrayList.add(contentValues);
        intent.putExtra("finishActivityOnSaveCompleted", true);
        intent.putParcelableArrayListExtra("data", arrayList);
        getParentActivity().startActivity(intent);
    }

    public void lambda$didPressPhoneNumber$422(ItemOptions itemOptions, String str) {
        itemOptions.dismiss();
        new NewContactBottomSheet(this, getContext()).setInitialPhoneNumber(str, false).show();
    }

    public static void lambda$didPressPhoneNumber$423(Utilities.Callback callback) {
        callback.run(Boolean.FALSE);
    }

    public void lambda$didPressPhoneNumber$425(String str) {
        if (getParentActivity() == null) {
            return;
        }
        try {
            Intent intent = new Intent("android.intent.action.VIEW", Uri.fromParts("sms", str, null));
            intent.putExtra("sms_body", ContactsController.getInstance(((BaseFragment) this).currentAccount).getInviteText(1));
            getParentActivity().startActivityForResult(intent, 500);
        } catch (Exception e) {
            FileLog.e(e);
        }
    }

    public void lambda$didPressPhoneNumber$426(String str) {
        Browser.openUrl(getContext(), "tel:" + str);
    }

    public void lambda$didPressPhoneNumber$427(String str) {
        AndroidUtilities.addToClipboard(str);
        BulletinFactory.of(this).createCopyBulletin(LocaleController.getString(R.string.PhoneCopied)).show();
    }

    public void lambda$didPressPhoneNumber$428(TLRPC.User user) {
        presentFragment(of(user.id));
    }

    public void lambda$didPressPhoneNumber$429(TLRPC.User user, TLRPC.UserFull userFull) {
        VoIPHelper.startCall(user, false, userFull != null && userFull.video_calls_available, getParentActivity(), userFull, getAccountInstance());
    }

    public void lambda$didPressPhoneNumber$430(TLRPC.User user, TLRPC.UserFull userFull) {
        VoIPHelper.startCall(user, true, userFull != null && userFull.video_calls_available, getParentActivity(), userFull, getAccountInstance());
    }

    public void lambda$didPressPhoneNumber$431(String str) {
        Browser.openUrl(getContext(), "tel:" + str);
    }

    public void lambda$didPressPhoneNumber$432(String str) {
        AndroidUtilities.addToClipboard(str);
        BulletinFactory.of(this).createCopyBulletin(LocaleController.getString(R.string.PhoneCopied)).show();
    }

    public void lambda$didPressPhoneNumber$433(ScrimOptions scrimOptions, TLRPC.User user) {
        scrimOptions.dismiss();
        presentFragment(ProfileActivity.of(user.id));
    }

    public void lambda$didPressPhoneNumber$434(ChatMessageCell chatMessageCell, final String str, TLRPC.TL_contact tL_contact, CharacterStyle characterStyle, final TLRPC.User user) {
        final TLRPC.UserFull userFull = user != null ? getMessagesController().getUserFull(user.id) : null;
        final ItemOptions makeOptions = ItemOptions.makeOptions(this, chatMessageCell, true);
        final ScrimOptions scrimOptions = new ScrimOptions(getContext(), this.themeDelegate);
        makeOptions.setOnDismiss(new Runnable() {
            @Override
            public final void run() {
                scrimOptions.dismiss();
            }
        });
        final Utilities.Callback callback = new Utilities.Callback() {
            public final void run(Object obj) {
                ChatActivity.this.lambda$didPressPhoneNumber$421(user, str, (Boolean) obj);
            }
        };
        final ItemOptions makeSwipeback = makeOptions.makeSwipeback();
        makeSwipeback.add(R.drawable.ic_ab_back, LocaleController.getString(R.string.Back), new Runnable() {
            @Override
            public final void run() {
                makeOptions.closeSwipeback();
            }
        });
        makeSwipeback.addGap();
        makeSwipeback.add(R.drawable.msg_addbot, LocaleController.getString(R.string.CreateNewContact), new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$didPressPhoneNumber$422(makeOptions, str);
            }
        });
        makeSwipeback.add(R.drawable.menu_contact_existing, LocaleController.getString(R.string.AddToExistingContact), new Runnable() {
            @Override
            public final void run() {
                ChatActivity.lambda$didPressPhoneNumber$423(callback);
            }
        });
        if (tL_contact == null && (user == null || !getContactsController().contactsDict.containsKey(Long.valueOf(user.id)))) {
            makeOptions.add(R.drawable.msg_contact_add, LocaleController.getString(R.string.AddToContacts), new Runnable() {
                @Override
                public final void run() {
                    makeOptions.openSwipeback(makeSwipeback);
                }
            });
            makeOptions.addGap();
        }
        if (user == null) {
            makeOptions.add(R.drawable.menu_invit_telegram, LocaleController.getString(R.string.InviteToTelegramShort), new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$didPressPhoneNumber$425(str);
                }
            });
            makeOptions.add(R.drawable.msg_calls_regular, LocaleController.getString(R.string.VoiceCallViaCarrier), new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$didPressPhoneNumber$426(str);
                }
            });
            makeOptions.add(R.drawable.msg_copy, LocaleController.getString(R.string.CopyNumber), new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$didPressPhoneNumber$427(str);
                }
            });
            makeOptions.addGap();
            makeOptions.addText(LocaleController.getString(R.string.NumberNotOnTelegram), 13);
        } else {
            makeOptions.add(R.drawable.msg_discussion, LocaleController.getString(R.string.SendMessage), new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$didPressPhoneNumber$428(user);
                }
            });
            if (!UserObject.isUserSelf(user)) {
                makeOptions.add(R.drawable.msg_calls, LocaleController.getString(R.string.VoiceCallViaTelegram), new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.this.lambda$didPressPhoneNumber$429(user, userFull);
                    }
                });
                makeOptions.add(R.drawable.msg_videocall, LocaleController.getString(R.string.VideoCallViaTelegram), new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.this.lambda$didPressPhoneNumber$430(user, userFull);
                    }
                });
            }
            makeOptions.add(R.drawable.msg_calls_regular, LocaleController.getString(R.string.VoiceCallViaCarrier), new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$didPressPhoneNumber$431(str);
                }
            });
            makeOptions.add(R.drawable.msg_copy, LocaleController.getString(R.string.CopyNumber), new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$didPressPhoneNumber$432(str);
                }
            });
            makeOptions.addGap();
            makeOptions.addProfile(user, LocaleController.getString(R.string.ViewProfile), new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$didPressPhoneNumber$433(scrimOptions, user);
                }
            });
        }
        scrimOptions.setItemOptions(makeOptions);
        scrimOptions.setScrim(chatMessageCell, characterStyle, (CharSequence) null);
        showDialog(scrimOptions);
    }

    public void lambda$didPressPhoneNumber$436(TLRPC.TL_contact tL_contact, final Utilities.Callback callback) {
        final TLRPC.User user = getMessagesStorage().getUser(tL_contact.user_id);
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                callback.run(user);
            }
        });
    }

    public void lambda$didPressPhoneNumber$437(Browser.Progress progress, TLObject tLObject, Utilities.Callback callback) {
        TLRPC.User user;
        progress.end();
        if (tLObject instanceof TLRPC.TL_contacts_resolvedPeer) {
            TLRPC.TL_contacts_resolvedPeer tL_contacts_resolvedPeer = (TLRPC.TL_contacts_resolvedPeer) tLObject;
            getMessagesController().putUsers(tL_contacts_resolvedPeer.users, false);
            getMessagesController().putChats(tL_contacts_resolvedPeer.chats, false);
            long peerDialogId = DialogObject.getPeerDialogId(tL_contacts_resolvedPeer.peer);
            if (peerDialogId >= 0) {
                user = getMessagesController().getUser(Long.valueOf(peerDialogId));
                callback.run(user);
            }
        }
        user = null;
        callback.run(user);
    }

    public void lambda$didPressPhoneNumber$438(final Browser.Progress progress, final Utilities.Callback callback, final TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$didPressPhoneNumber$437(progress, tLObject, callback);
            }
        });
    }

    public void lambda$didPressPhoneNumber$439(int i) {
        getConnectionsManager().cancelRequest(i, true);
    }

    public void lambda$didPressReaction$440(TLRPC.ReactionCount reactionCount, View view) {
        closeMenu();
        SearchTagsList.openRenameTagAlert(getContext(), ((BaseFragment) this).currentAccount, reactionCount.reaction, this.themeDelegate, false);
    }

    public void lambda$didPressReaction$441(TLRPC.ReactionCount reactionCount, View view) {
        closeMenu();
        lambda$openSearchWithText$357("");
        SearchTagsList searchTagsList = this.actionBarSearchTags;
        if (searchTagsList != null) {
            searchTagsList.setChosen(ReactionsLayoutInBubble.VisibleReaction.fromTL(reactionCount.reaction), true);
        }
    }

    public void lambda$didPressReaction$442(View view, TLRPC.ReactionCount reactionCount, View view2) {
        pressedReaction(view, reactionCount, 0.0f, 0.0f);
    }

    public void lambda$didPressReaction$443(ReactedUsersListView reactedUsersListView, ArrayList arrayList) {
        EmojiPacksAlert emojiPacksAlert = new EmojiPacksAlert(this, getParentActivity(), this.themeDelegate, arrayList) {
            public void dismiss() {
                super.dismiss();
                ChatActivity.this.dimBehindView(false);
            }
        };
        emojiPacksAlert.setCalcMandatoryInsets(isKeyboardVisible());
        emojiPacksAlert.setDimBehind(false);
        closeMenu(false);
        showDialog(emojiPacksAlert);
    }

    public void lambda$didPressReaction$444(MessageObject messageObject, ReactedUsersListView reactedUsersListView, long j, TLRPC.MessagePeerReaction messagePeerReaction) {
        String str;
        Bundle bundle = new Bundle();
        if (j > 0) {
            str = "user_id";
        } else {
            j = -j;
            str = "chat_id";
        }
        bundle.putLong(str, j);
        bundle.putInt("report_reaction_message_id", messageObject.getId());
        bundle.putLong("report_reaction_from_dialog_id", this.dialog_id);
        presentFragment(new ProfileActivity(bundle));
        closeMenu();
    }

    public void lambda$didPressReaction$445(ArrayList arrayList, View view) {
        new EmojiPacksAlert(new BaseFragment() {
            public Context getContext() {
                return ChatActivity.this.getContext();
            }

            public int getCurrentAccount() {
                return ((BaseFragment) this).currentAccount;
            }

            public Theme.ResourcesProvider getResourceProvider() {
                return ChatActivity.this.themeDelegate;
            }
        }, getContext(), this.themeDelegate, arrayList).show();
        closeMenu();
    }

    public void lambda$didReceivedNotification$168() {
        getNotificationCenter().onAnimationFinish(this.transitionAnimationIndex);
    }

    public void lambda$didReceivedNotification$169() {
        createEmptyView(false);
        if (((BaseFragment) this).fragmentBeginToShow) {
            this.chatListView.setEmptyView(this.emptyViewContainer);
            return;
        }
        this.chatListView.setAnimateEmptyView(false, 0);
        this.chatListView.setEmptyView(this.emptyViewContainer);
        this.chatListView.setAnimateEmptyView(true, 1);
    }

    public void lambda$didReceivedNotification$170() {
        resumeDelayedFragmentAnimation();
        AndroidUtilities.cancelRunOnUIThread(this.fragmentTransitionRunnable);
        this.fragmentTransitionRunnable.run();
        getNotificationCenter().runDelayedNotifications();
    }

    public void lambda$didReceivedNotification$171(Object[] objArr, StickersAlert stickersAlert, boolean z, TLRPC.StickerSet stickerSet, DialogInterface dialogInterface) {
        if (objArr.length > 2) {
            Object obj = objArr[2];
            if (obj instanceof TLRPC.Document) {
                TLRPC.Document document = (TLRPC.Document) obj;
                if (objArr.length > 3) {
                    Object obj2 = objArr[3];
                    if (obj2 instanceof String) {
                        document.localThumbPath = (String) obj2;
                    }
                }
                BulletinFactory.of(stickersAlert.container, ((BaseFragment) this).resourceProvider).createEmojiBulletin(document, LocaleController.formatString(z ? R.string.StickersStickerEditedInSetToast : R.string.StickersStickerAddedToSetToast, new Object[]{stickerSet.title})).setDuration(2750).show(true);
            }
        }
    }

    public void lambda$didReceivedNotification$172(MessageObject messageObject, int i) {
        this.delayedReadRunnable = null;
        messageObject.messageOwner.replies.read_max_id = i;
    }

    public void lambda$didReceivedNotification$173(int i) {
        INavigationLayout iNavigationLayout = ((BaseFragment) this).parentLayout;
        if (iNavigationLayout == null) {
            return;
        }
        BaseFragment backgroundFragment = iNavigationLayout.getBackgroundFragment();
        if (backgroundFragment instanceof ChatActivity) {
            ChatActivity chatActivity = (ChatActivity) backgroundFragment;
            if (chatActivity.getDialogId() == this.dialog_id) {
                lambda$onBackPressed$354();
                chatActivity.scrollToMessageId(i, 0, true, 0, true, 0);
                return;
            }
        }
        presentFragment(of(this.dialog_id, i));
    }

    public void lambda$didReceivedNotification$174() {
        BulletinFactory.of(this).createSimpleBulletin(R.raw.chats_infotip, LocaleController.getString(R.string.BoostingRemoveRestrictionsSuccessTitle), LocaleController.getString(R.string.BoostingRemoveRestrictionsSuccessSubTitle)).show();
    }

    public void lambda$didReceivedNotification$175(ChannelBoostsController.CanApplyBoost canApplyBoost) {
        this.canApplyBoosts = canApplyBoost;
    }

    public void lambda$didReceivedNotification$176(TL_stories.TL_premium_boostsStatus tL_premium_boostsStatus) {
        if (tL_premium_boostsStatus == null) {
            return;
        }
        this.boostsStatus = tL_premium_boostsStatus;
        getMessagesController().getBoostsController().userCanBoostChannel(this.dialog_id, tL_premium_boostsStatus, new Consumer() {
            public final void accept(Object obj) {
                ChatActivity.this.lambda$didReceivedNotification$175((ChannelBoostsController.CanApplyBoost) obj);
            }
        });
    }

    public void lambda$didReceivedNotification$177(Object[] objArr, long j) {
        MessageObject messageObject = (MessageObject) this.messagesDict[j == this.dialog_id ? (char) 0 : (char) 1].get(((Integer) objArr[1]).intValue());
        if (messageObject != null) {
            messageObject.messageOwner.media.extended_media = (ArrayList) objArr[2];
            messageObject.forceUpdate = true;
            messageObject.setType();
            updateMessageAnimated(messageObject, false);
        }
    }

    public void lambda$didReceivedNotification$178(Object[] objArr, long j) {
        MessageObject messageObject;
        int intValue = ((Integer) objArr[1]).intValue();
        LongSparseArray longSparseArray = this.filteredMessagesDict;
        if (longSparseArray != null && (messageObject = (MessageObject) longSparseArray.get(intValue)) != null) {
            MessageObject.updateReactions(messageObject.messageOwner, (TLRPC.TL_messageReactions) objArr[2]);
            messageObject.forceUpdate = true;
            messageObject.reactionsChanged = true;
        }
        MessageObject messageObject2 = (MessageObject) this.messagesDict[j == this.dialog_id ? (char) 0 : (char) 1].get(intValue);
        if (messageObject2 != null) {
            MessageObject.updateReactions(messageObject2.messageOwner, (TLRPC.TL_messageReactions) objArr[2]);
            messageObject2.forceUpdate = true;
            messageObject2.reactionsChanged = true;
            updateMessageAnimated(messageObject2, true);
        }
    }

    public static void lambda$didReceivedNotification$179(View view) {
        MessageObject messageObject;
        if (!(view instanceof ChatMessageCell) || (messageObject = ((ChatMessageCell) view).getMessageObject()) == null) {
            return;
        }
        messageObject.forceUpdate = true;
        messageObject.reactionsChanged = true;
    }

    public void lambda$didReceivedNotification$180() {
        AndroidUtilities.forEachViews(this.chatListView, new Consumer() {
            public final void accept(Object obj) {
                ChatActivity.lambda$didReceivedNotification$179((View) obj);
            }
        });
        ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
        if (chatActivityAdapter != null) {
            chatActivityAdapter.notifyDataSetChanged(true);
        }
    }

    public static void lambda$didReceivedNotification$181(View view) {
        MessageObject messageObject;
        if (!(view instanceof ChatMessageCell) || (messageObject = ((ChatMessageCell) view).getMessageObject()) == null) {
            return;
        }
        messageObject.forceUpdate = true;
    }

    public void lambda$didReceivedNotification$182() {
        AndroidUtilities.forEachViews(this.chatListView, new Consumer() {
            public final void accept(Object obj) {
                ChatActivity.lambda$didReceivedNotification$181((View) obj);
            }
        });
        ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
        if (chatActivityAdapter != null) {
            chatActivityAdapter.notifyDataSetChanged(false);
        }
    }

    public void lambda$didReceivedNotification$183() {
        updateMessagesVisiblePart(false);
    }

    public void lambda$didReceivedNotification$184(ArrayList arrayList, int i) {
        replaceMessageObjects(arrayList, i, false);
    }

    public static int lambda$didReceivedNotification$185(Integer num, Integer num2) {
        return num2.compareTo(num);
    }

    public void lambda$didReceivedNotification$186() {
        checkScrollForLoad(false);
    }

    public static void lambda$didReceivedNotification$187(Theme.ThemeAccent themeAccent, Theme.ThemeInfo themeInfo, boolean z) {
        if (themeAccent == null) {
            NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.needSetDayNightTheme, new Object[]{themeInfo, Boolean.FALSE, null, -1});
            return;
        }
        Theme.ThemeAccent accent = themeInfo.getAccent(false);
        NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.needSetDayNightTheme, new Object[]{themeInfo, Boolean.FALSE, null, Integer.valueOf(themeAccent.id)});
        if (z) {
            Theme.deleteThemeAccent(themeInfo, accent, true);
        }
    }

    public void lambda$didReceivedNotification$188(int i) {
        playReactionAnimation(Integer.valueOf(i));
    }

    public static Boolean lambda$didReceivedNotification$189(MessageObject messageObject) {
        return Boolean.valueOf((messageObject == null || messageObject.getFactCheck() == null) ? false : true);
    }

    public static Boolean lambda$didReceivedNotification$190(MessageObject messageObject) {
        return Boolean.valueOf((messageObject == null || messageObject.getEffect() == null) ? false : true);
    }

    public void lambda$didSelectDialogs$351(DialogsActivity dialogsActivity, ArrayList arrayList, CharSequence charSequence, boolean z, int i, ArrayList arrayList2, HashMap hashMap) {
        long j;
        if (dialogsActivity.resetDelegate) {
            dialogsActivity.setDelegate(null);
        }
        if (this.forwardingMessage != null) {
            this.forwardingMessage = null;
            this.forwardingMessageGroup = null;
        } else {
            for (int i2 = 1; i2 >= 0; i2--) {
                this.selectedMessagesCanCopyIds[i2].clear();
                this.selectedMessagesCanStarIds[i2].clear();
                this.selectedMessagesIds[i2].clear();
            }
            hideActionMode();
            updatePinnedMessageView(true);
            updateVisibleRows();
        }
        this.messagePreviewParams = null;
        hideFieldPanel(false);
        for (int i3 = 0; i3 < arrayList.size(); i3++) {
            long j2 = ((MessagesStorage.TopicKey) arrayList.get(i3)).dialogId;
            Long l = hashMap == null ? 0L : (Long) hashMap.get(Long.valueOf(j2));
            if (charSequence != null) {
                j = j2;
                SendMessagesHelper.SendMessageParams of = SendMessagesHelper.SendMessageParams.of(charSequence.toString(), j2, (MessageObject) null, (MessageObject) null, (TLRPC.WebPage) null, true, (ArrayList) null, (TLRPC.ReplyMarkup) null, (HashMap) null, z, i, (MessageObject.SendAnimationData) null, false);
                of.quick_reply_shortcut = this.quickReplyShortcut;
                of.quick_reply_shortcut_id = getQuickReplyId();
                of.payStars = l == null ? 0L : l.longValue();
                of.monoForumPeer = getSendMonoForumPeerId();
                of.suggestionParams = this.messageSuggestionParams;
                getSendMessagesHelper().sendMessage(of);
            } else {
                j = j2;
            }
            getSendMessagesHelper().sendMessage(arrayList2, j, false, false, z, i, (MessageObject) null, -1, l == null ? 0L : l.longValue(), getSendMonoForumPeerId(), getSendMessageSuggestionParams());
        }
        dialogsActivity.finishFragment();
        createUndoView();
        if (this.undoView != null) {
            if (arrayList.size() != 1) {
                this.undoView.showWithAction(0L, 53, Integer.valueOf(arrayList2.size()), Integer.valueOf(arrayList.size()), (Runnable) null, (Runnable) null);
            } else {
                if (BulletinFactory.of(this).showForwardedBulletinWithTag(((MessagesStorage.TopicKey) arrayList.get(0)).dialogId, arrayList2.size())) {
                    return;
                }
                this.undoView.showWithAction(((MessagesStorage.TopicKey) arrayList.get(0)).dialogId, 53, Integer.valueOf(arrayList2.size()));
            }
        }
    }

    public void lambda$didSelectDialogs$352() {
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView != null) {
            chatActivityEnterView.hideTopView(true);
        }
    }

    public void lambda$dimBehindView$100(Bitmap bitmap) {
        this.scrimBlurBitmap = bitmap;
        Paint paint = new Paint(1);
        this.scrimBlurBitmapPaint = paint;
        Bitmap bitmap2 = this.scrimBlurBitmap;
        Shader.TileMode tileMode = Shader.TileMode.CLAMP;
        BitmapShader bitmapShader = new BitmapShader(bitmap2, tileMode, tileMode);
        this.scrimBlurBitmapShader = bitmapShader;
        paint.setShader(bitmapShader);
        ColorMatrix colorMatrix = new ColorMatrix();
        AndroidUtilities.adjustSaturationColorMatrix(colorMatrix, Theme.isCurrentThemeDark() ? 0.08f : 0.25f);
        AndroidUtilities.adjustBrightnessColorMatrix(colorMatrix, Theme.isCurrentThemeDark() ? -0.02f : -0.07f);
        this.scrimBlurBitmapPaint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
        this.scrimBlurMatrix = new Matrix();
    }

    public void lambda$dimBehindView$101(float f, ValueAnimator valueAnimator) {
        float floatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        this.scrimPaintAlpha = floatValue;
        this.scrimViewProgress = floatValue / f;
        View view = ((BaseFragment) this).fragmentView;
        if (view != null) {
            view.invalidate();
        }
    }

    public void lambda$forwardMessages$140() {
        this.waitingForSendingMessageLoad = false;
        hideFieldPanel(true);
    }

    public void lambda$getChatThanosEffect$394(ThanosEffect[] thanosEffectArr) {
        ThanosEffect thanosEffect;
        if (this.removingFromParent || (thanosEffect = thanosEffectArr[0]) == null) {
            return;
        }
        thanosEffectArr[0] = null;
        if (this.chatListThanosEffect == thanosEffect) {
            this.chatListThanosEffect = null;
        }
        AndroidUtilities.removeFromParent(thanosEffect);
    }

    public void lambda$getThemeDescriptions$383() {
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView != null) {
            chatActivityEnterView.updateColors();
        }
        Theme.refreshAttachButtonsColors();
        ChatAttachAlert chatAttachAlert = this.chatAttachAlert;
        if (chatAttachAlert != null) {
            chatAttachAlert.checkColors();
        }
        RecyclerListView recyclerListView = this.chatListView;
        int i = 0;
        if (recyclerListView != null) {
            int childCount = recyclerListView.getChildCount();
            for (int i2 = 0; i2 < childCount; i2++) {
                View childAt = this.chatListView.getChildAt(i2);
                if (childAt instanceof ChatMessageCell) {
                    ((ChatMessageCell) childAt).createSelectorDrawable(0);
                } else if (childAt instanceof ChatActionCell) {
                    ((ChatActionCell) childAt).setInvalidateColors(true);
                }
            }
        }
        RecyclerListView recyclerListView2 = this.messagesSearchListView;
        if (recyclerListView2 != null) {
            int childCount2 = recyclerListView2.getChildCount();
            for (int i3 = 0; i3 < childCount2; i3++) {
                View childAt2 = this.messagesSearchListView.getChildAt(i3);
                if (childAt2 instanceof DialogCell) {
                    ((DialogCell) childAt2).update(0);
                }
            }
        }
        if (this.scrimPopupWindowItems != null) {
            while (true) {
                ActionBarMenuSubItem[] actionBarMenuSubItemArr = this.scrimPopupWindowItems;
                if (i >= actionBarMenuSubItemArr.length) {
                    break;
                }
                actionBarMenuSubItemArr[i].setColors(getThemedColor(Theme.key_actionBarDefaultSubmenuItem), getThemedColor(Theme.key_actionBarDefaultSubmenuItemIcon));
                this.scrimPopupWindowItems[i].setSelectorColor(getThemedColor(Theme.key_dialogButtonSelector));
                i++;
            }
        }
        ActionBarPopupWindow actionBarPopupWindow = this.scrimPopupWindow;
        if (actionBarPopupWindow != null) {
            View contentView = actionBarPopupWindow.getContentView();
            contentView.setBackgroundColor(getThemedColor(Theme.key_actionBarDefaultSubmenuBackground));
            contentView.invalidate();
        }
        InstantCameraView instantCameraView = this.instantCameraView;
        if (instantCameraView != null) {
            instantCameraView.invalidateBlur();
        }
        PinnedLineView pinnedLineView = this.pinnedLineView;
        if (pinnedLineView != null) {
            pinnedLineView.updateColors();
        }
        ChatActivityEnterTopView chatActivityEnterTopView = this.chatActivityEnterTopView;
        if (chatActivityEnterTopView != null && chatActivityEnterTopView.getEditView() != null) {
            this.chatActivityEnterTopView.getEditView().updateColors();
        }
        ActionBarMenuItem actionBarMenuItem = this.headerItem;
        if (actionBarMenuItem != null) {
            actionBarMenuItem.updateColor();
        }
        setNavigationBarColor(getThemedColor(Theme.key_windowBackgroundGray));
        FragmentContextView fragmentContextView = this.fragmentContextView;
        if (fragmentContextView != null) {
            fragmentContextView.updateColors();
        }
        ChatAvatarContainer chatAvatarContainer = this.avatarContainer;
        if (chatAvatarContainer != null) {
            chatAvatarContainer.updateColors();
        }
        BlurredFrameLayout blurredFrameLayout = this.pinnedMessageView;
        if (blurredFrameLayout != null) {
            blurredFrameLayout.backgroundColor = getThemedColor(Theme.key_chat_topPanelBackground);
        }
        BlurredFrameLayout blurredFrameLayout2 = this.topChatPanelView;
        if (blurredFrameLayout2 != null) {
            blurredFrameLayout2.backgroundColor = getThemedColor(Theme.key_chat_topPanelBackground);
        }
        BlurredFrameLayout blurredFrameLayout3 = this.topChatPanelView2;
        if (blurredFrameLayout3 != null) {
            blurredFrameLayout3.backgroundColor = getThemedColor(Theme.key_chat_topPanelBackground);
        }
        ChatActivityFragmentView chatActivityFragmentView = this.contentView;
        if (chatActivityFragmentView != null) {
            chatActivityFragmentView.invalidateBlurredViews();
            this.contentView.invalidateBackground();
        }
        INavigationLayout iNavigationLayout = ((BaseFragment) this).parentLayout;
        if (iNavigationLayout != null && iNavigationLayout.getDrawerLayoutContainer() != null) {
            ((BaseFragment) this).parentLayout.getDrawerLayoutContainer().setBehindKeyboardColor(getThemedColor(Theme.key_windowBackgroundWhite));
        }
        SuggestEmojiView suggestEmojiView = this.suggestEmojiPanel;
        if (suggestEmojiView != null) {
            suggestEmojiView.updateColors();
        }
        ChatAvatarContainer chatAvatarContainer2 = this.avatarContainer;
        if (chatAvatarContainer2 != null && chatAvatarContainer2.getTimeItem() != null) {
            this.avatarContainer.getTimeItem().invalidate();
        }
        TranslateButton translateButton = this.translateButton;
        if (translateButton != null) {
            translateButton.updateColors();
        }
        ImageView imageView = this.bottomGiftButton;
        if (imageView != null) {
            int i4 = Theme.key_featuredStickers_addButton;
            imageView.setColorFilter(new PorterDuffColorFilter(getThemedColor(i4), PorterDuff.Mode.SRC_IN));
            this.bottomGiftButton.setBackground(Theme.createSelectorDrawable(Theme.multAlpha(getThemedColor(i4), 0.1f), 1));
        }
    }

    public void lambda$hideFloatingTopicView$123(ValueAnimator valueAnimator) {
        this.floatingTopicViewAlpha = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        updateFloatingTopicView();
    }

    public void lambda$hideInfoView$113(View view, ValueAnimator valueAnimator) {
        float floatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        this.topViewOffset = AndroidUtilities.dp(30.0f) * floatValue;
        invalidateChatListViewTopPadding();
        invalidateMessagesVisiblePart();
        view.setAlpha(floatValue);
    }

    public void lambda$hidePinnedMessageView$225(ValueAnimator valueAnimator) {
        this.pinnedMessageEnterOffset = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        invalidateChatListViewTopPadding();
        invalidateMessagesVisiblePart();
        this.chatListView.invalidate();
    }

    public void lambda$hideTagSelector$93(ReactionsContainerLayout reactionsContainerLayout) {
        this.contentView.removeView(reactionsContainerLayout);
    }

    public void lambda$migrateToNewChat$200(BaseFragment baseFragment, MessageObject messageObject, INavigationLayout iNavigationLayout) {
        if (baseFragment instanceof NotificationCenter.NotificationCenterDelegate) {
            getNotificationCenter().removeObserver((NotificationCenter.NotificationCenterDelegate) baseFragment, NotificationCenter.closeChats);
        }
        getNotificationCenter().postNotificationName(NotificationCenter.closeChats, new Object[0]);
        Bundle bundle = new Bundle();
        bundle.putLong("chat_id", messageObject.messageOwner.action.channel_id);
        iNavigationLayout.addFragmentToStack(new ChatActivity(bundle), iNavigationLayout.getFragmentStack().size() - 1);
        baseFragment.finishFragment();
    }

    public void lambda$migrateToNewChat$201(long j) {
        getMessagesController().loadFullChat(j, 0, true);
    }

    public void lambda$new$1(DialogInterface dialogInterface) {
        this.postponedScrollIsCanceled = true;
        this.postponedScrollMessageId = 0;
        this.nextScrollToMessageId = 0;
        this.forceNextPinnedMessageId = 0;
        invalidateMessagesVisiblePart();
        showPinnedProgress(false);
    }

    public void lambda$new$194() {
        this.lastTranslationCheck = System.currentTimeMillis();
        if (this.chatListView != null && this.chatAdapter != null) {
            int i = Integer.MAX_VALUE;
            int i2 = Integer.MIN_VALUE;
            for (int i3 = 0; i3 < this.chatListView.getChildCount(); i3++) {
                View childAt = this.chatListView.getChildAt(i3);
                if (childAt instanceof ChatMessageCell) {
                    ChatMessageCell chatMessageCell = (ChatMessageCell) childAt;
                    if (chatMessageCell.getCurrentMessagesGroup() != null) {
                        for (int i4 = 0; i4 < chatMessageCell.getCurrentMessagesGroup().messages.size(); i4++) {
                            int id = ((MessageObject) chatMessageCell.getCurrentMessagesGroup().messages.get(i4)).getId();
                            i = Math.min(i, id);
                            i2 = Math.max(i2, id);
                        }
                    } else if (chatMessageCell.getMessageObject() != null) {
                        int id2 = chatMessageCell.getMessageObject().getId();
                        i = Math.min(i, id2);
                        i2 = Math.max(i2, id2);
                    }
                }
            }
            if (i <= i2) {
                ArrayList arrayList = new ArrayList();
                for (int i5 = 0; i5 < this.messages.size(); i5++) {
                    MessageObject messageObject = (MessageObject) this.messages.get(i5);
                    MessageObject.GroupedMessages groupedMessages = (MessageObject.GroupedMessages) this.groupedMessagesMap.get(messageObject.getGroupId());
                    if (groupedMessages == null) {
                        int id3 = messageObject.getId();
                        getMessagesController().getTranslateController().checkTranslation(messageObject, id3 >= i + (-7) && id3 <= i2 + 7);
                    } else if (!arrayList.contains(Long.valueOf(groupedMessages.groupId))) {
                        for (int i6 = 0; i6 < groupedMessages.messages.size(); i6++) {
                            MessageObject messageObject2 = (MessageObject) groupedMessages.messages.get(i6);
                            if (messageObject2 != null) {
                                int id4 = messageObject2.getId();
                                getMessagesController().getTranslateController().checkTranslation(messageObject2, id4 >= i + (-7) && id4 <= i2 + 7);
                            }
                        }
                        arrayList.add(Long.valueOf(groupedMessages.groupId));
                    }
                }
            }
        }
        if (this.currentPinnedMessageId > 0 && this.pinnedMessageObjects != null) {
            getMessagesController().getTranslateController().checkTranslation((MessageObject) this.pinnedMessageObjects.get(Integer.valueOf(this.currentPinnedMessageId)), true);
        }
        updateTranslateItemVisibility();
    }

    public void lambda$new$7() {
        ChatActivityEnterView chatActivityEnterView;
        View sendButton;
        if (getParentActivity() == null || ((BaseFragment) this).fragmentView == null || (chatActivityEnterView = this.chatActivityEnterView) == null || (sendButton = chatActivityEnterView.getSendButton()) == null || this.chatActivityEnterView.getEditField() == null || this.chatActivityEnterView.getEditField().getText().length() < 5) {
            return;
        }
        SharedConfig.increaseScheduledOrNoSoundHintShowed();
        if (this.scheduledOrNoSoundHint == null) {
            HintView hintView = new HintView(getParentActivity(), 4, this.themeDelegate);
            this.scheduledOrNoSoundHint = hintView;
            hintView.createCloseButton();
            this.scheduledOrNoSoundHint.setAlpha(0.0f);
            this.scheduledOrNoSoundHint.setVisibility(4);
            this.scheduledOrNoSoundHint.setText(LocaleController.getString(R.string.ScheduledOrNoSoundHint));
            this.contentView.addView(this.scheduledOrNoSoundHint, LayoutHelper.createFrame(-2, -2.0f, 51, 10.0f, 0.0f, 10.0f, 0.0f));
        }
        this.scheduledOrNoSoundHint.showForView(sendButton, true);
        this.scheduledOrNoSoundHintShown = true;
    }

    public void lambda$new$8() {
        View sendButton;
        if (getParentActivity() == null || ((BaseFragment) this).fragmentView == null || this.chatActivityEnterView == null || this.forwardingPreviewView != null || getMessagesController().getSendPaidMessagesStars(getDialogId()) > 0 || (sendButton = this.chatActivityEnterView.getSendButton()) == null || this.chatActivityEnterView.getEditField() == null || this.chatActivityEnterView.getEditField().getText().length() == 0) {
            return;
        }
        SharedConfig.increaseScheduledHintShowed();
        if (this.scheduledHint == null) {
            HintView hintView = new HintView(getParentActivity(), 4, this.themeDelegate);
            this.scheduledHint = hintView;
            hintView.createCloseButton();
            this.scheduledHint.setAlpha(0.0f);
            this.scheduledHint.setVisibility(4);
            this.scheduledHint.setText(LocaleController.getString(R.string.ScheduledHint));
            this.contentView.addView(this.scheduledHint, LayoutHelper.createFrame(-2, -2.0f, 51, 10.0f, 0.0f, 10.0f, 0.0f));
        }
        this.scheduledHint.showForView(sendButton, true);
        this.scheduledHintShown = true;
    }

    public void lambda$onActivityResultFragment$165(Uri uri, boolean z, int i) {
        fillEditingMediaWithCaption(null, null);
        SendMessagesHelper.prepareSendingPhoto(getAccountInstance(), (String) null, uri, this.dialog_id, this.replyingMessageObject, getThreadMessage(), this.replyingQuote, (CharSequence) null, (ArrayList) null, (ArrayList) null, (InputContentInfoCompat) null, 0, this.editingMessageObject, z, i, this.chatMode, this.quickReplyShortcut, getQuickReplyId());
    }

    public void lambda$onActivityResultFragment$166(Intent intent, boolean z, int i) {
        fillEditingMediaWithCaption(null, null);
        sendUriAsDocument(intent.getData(), z, i);
        afterMessageSend();
    }

    public void lambda$onActivityResultFragment$167(Intent intent, boolean z, int i) {
        fillEditingMediaWithCaption(null, null);
        ClipData clipData = intent.getClipData();
        for (int i2 = 0; i2 < clipData.getItemCount(); i2++) {
            sendUriAsDocument(clipData.getItemAt(i2).getUri(), z, i);
        }
        afterMessageSend();
    }

    public void lambda$onCustomTransitionAnimation$384(ChatActivity chatActivity, boolean z, ValueAnimator valueAnimator) {
        float floatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        chatActivity.setTransitionToChatProgress(floatValue);
        float f = 1.0f - floatValue;
        float dp = AndroidUtilities.dp(8.0f) * f;
        this.avatarContainer.setTranslationY(dp);
        this.avatarContainer.getAvatarImageView().setTranslationY(-dp);
        float f2 = (-AndroidUtilities.dp(8.0f)) * floatValue;
        chatActivity.avatarContainer.setTranslationY(f2);
        chatActivity.avatarContainer.getAvatarImageView().setTranslationY(-f2);
        float f3 = (floatValue * 0.2f) + 0.8f;
        this.avatarContainer.getAvatarImageView().setScaleX(f3);
        this.avatarContainer.getAvatarImageView().setScaleY(f3);
        this.avatarContainer.getAvatarImageView().setAlpha(floatValue);
        float f4 = (0.2f * f) + 0.8f;
        chatActivity.avatarContainer.getAvatarImageView().setScaleX(f4);
        chatActivity.avatarContainer.getAvatarImageView().setScaleY(f4);
        chatActivity.avatarContainer.getAvatarImageView().setAlpha(f);
        ChatActivityEnterView chatActivityEnterView = chatActivity.chatActivityEnterView;
        if (chatActivityEnterView != null) {
            chatActivityEnterView.setTranslationY((-this.pullingBottomOffset) * floatValue);
        }
        FrameLayout frameLayout = chatActivity.bottomOverlay;
        if (frameLayout != null) {
            frameLayout.setTranslationY((-this.pullingBottomOffset) * floatValue);
        }
        if (z) {
            chatActivity.fragmentContextView.setAlpha(f);
        }
        BlurredFrameLayout blurredFrameLayout = chatActivity.pinnedMessageView;
        if (blurredFrameLayout != null) {
            blurredFrameLayout.setAlpha(f);
        }
        BlurredFrameLayout blurredFrameLayout2 = chatActivity.topChatPanelView;
        if (blurredFrameLayout2 != null) {
            blurredFrameLayout2.setAlpha(f);
        }
        BlurredFrameLayout blurredFrameLayout3 = chatActivity.topChatPanelView2;
        if (blurredFrameLayout3 != null) {
            blurredFrameLayout3.setAlpha(f);
        }
    }

    public void lambda$onEditTextDialogClose$117() {
        this.chatActivityEnterView.openKeyboard();
    }

    public void lambda$onFragmentCreate$10(Boolean bool) {
        boolean booleanValue = bool.booleanValue();
        this.waitingForGetDifference = booleanValue;
        if (booleanValue) {
            return;
        }
        firstLoadMessages();
    }

    public void lambda$onFragmentCreate$11(MessagesStorage messagesStorage, long j, CountDownLatch countDownLatch) {
        this.currentUser = messagesStorage.getUser(j);
        countDownLatch.countDown();
    }

    public void lambda$onFragmentCreate$12(MessagesStorage messagesStorage, int i, CountDownLatch countDownLatch) {
        this.currentEncryptedChat = messagesStorage.getEncryptedChat(i);
        countDownLatch.countDown();
    }

    public void lambda$onFragmentCreate$13(MessagesStorage messagesStorage, CountDownLatch countDownLatch) {
        this.currentUser = messagesStorage.getUser(this.currentEncryptedChat.user_id);
        countDownLatch.countDown();
    }

    public void lambda$onFragmentCreate$14(long j) {
        getMediaDataController().loadBotInfo(j, j, true, ((BaseFragment) this).classGuid);
    }

    public void lambda$onFragmentCreate$15(AlertDialog alertDialog, int i) {
        UnreadCounterTextView unreadCounterTextView = this.bottomOverlayChatText;
        if (unreadCounterTextView != null) {
            unreadCounterTextView.callOnClick();
        }
    }

    public void lambda$onFragmentCreate$16(AlertDialog alertDialog, int i) {
        lambda$onBackPressed$354();
    }

    public void lambda$onFragmentCreate$17() {
        int i;
        this.chatInviteRunnable = null;
        if (getParentActivity() == null) {
            return;
        }
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity(), this.themeDelegate);
        if (!ChatObject.isChannel(this.currentChat) || this.currentChat.megagroup) {
            builder.setMessage(LocaleController.getString(R.string.JoinByPeekGroupText));
            i = R.string.JoinByPeekGroupTitle;
        } else {
            builder.setMessage(LocaleController.getString(R.string.JoinByPeekChannelText));
            i = R.string.JoinByPeekChannelTitle;
        }
        builder.setTitle(LocaleController.getString(i));
        builder.setPositiveButton(LocaleController.getString(R.string.JoinByPeekJoin), new AlertDialog.OnButtonClickListener() {
            @Override
            public final void onClick(AlertDialog alertDialog, int i2) {
                ChatActivity.this.lambda$onFragmentCreate$15(alertDialog, i2);
            }
        });
        builder.setNegativeButton(LocaleController.getString(R.string.Cancel), new AlertDialog.OnButtonClickListener() {
            @Override
            public final void onClick(AlertDialog alertDialog, int i2) {
                ChatActivity.this.lambda$onFragmentCreate$16(alertDialog, i2);
            }
        });
        showDialog(builder.create());
    }

    public void lambda$onFragmentCreate$9(MessagesStorage messagesStorage, long j, CountDownLatch countDownLatch) {
        this.currentChat = messagesStorage.getChat(j);
        countDownLatch.countDown();
    }

    public void lambda$onGetDebugItems$5() {
        this.shareAlertDebugMode = (this.shareAlertDebugMode + 1) % 3;
    }

    public void lambda$onGetDebugItems$6() {
        this.shareAlertDebugTopicsSlowMotion = !this.shareAlertDebugTopicsSlowMotion;
    }

    public void lambda$onPageDownClicked$99() {
        setPagedownLoading(true, true);
    }

    public void lambda$onRequestPermissionsResultFragment$163(AlertDialog alertDialog, int i) {
        try {
            Intent intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS");
            intent.setData(Uri.parse("package:" + ApplicationLoader.applicationContext.getPackageName()));
            getParentActivity().startActivity(intent);
        } catch (Exception e) {
            FileLog.e(e);
        }
    }

    public void lambda$onResume$249(DialogInterface dialogInterface) {
        FragmentContextView fragmentContextView = this.fragmentContextView;
        if (fragmentContextView != null) {
            fragmentContextView.checkImport(false);
        }
    }

    public void lambda$onResume$250() {
        openVideoEditor(this.startVideoEdit, null);
        this.startVideoEdit = null;
    }

    public void lambda$openAnotherForward$110(AlertDialog alertDialog, int i) {
        this.forbidForwardingWithDismiss = false;
        MessagePreviewParams messagePreviewParams = this.messagePreviewParams;
        if (messagePreviewParams != null) {
            messagePreviewParams.updateForward((ArrayList) null, this.dialog_id);
        }
        fallbackFieldPanel();
    }

    public void lambda$openAnotherForward$111(AlertDialog alertDialog, int i) {
        openForwardingPreview(1);
    }

    public void lambda$openAttachBotLayout$205(TLRPC.TL_attachMenuBot tL_attachMenuBot, TLRPC.TL_error tL_error, TLRPC.User user) {
        tL_attachMenuBot.side_menu_disclaimer_needed = false;
        tL_attachMenuBot.inactive = false;
        if (tL_error == null) {
            MediaDataController.getInstance(((BaseFragment) this).currentAccount).loadAttachMenuBots(false, true);
            openAttachBotLayout(user.id, this.attachMenuBotStartCommand, false);
        }
    }

    public void lambda$openAttachBotLayout$206(final TLRPC.TL_attachMenuBot tL_attachMenuBot, final TLRPC.User user, TLObject tLObject, final TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$openAttachBotLayout$205(tL_attachMenuBot, tL_error, user);
            }
        });
    }

    public void lambda$openAttachBotLayout$207(final TLRPC.User user, final TLRPC.TL_attachMenuBot tL_attachMenuBot, Boolean bool) {
        TLRPC.TL_messages_toggleBotInAttachMenu tL_messages_toggleBotInAttachMenu = new TLRPC.TL_messages_toggleBotInAttachMenu();
        tL_messages_toggleBotInAttachMenu.bot = MessagesController.getInstance(((BaseFragment) this).currentAccount).getInputUser(user.id);
        tL_messages_toggleBotInAttachMenu.enabled = true;
        tL_messages_toggleBotInAttachMenu.write_allowed = true;
        ConnectionsManager.getInstance(((BaseFragment) this).currentAccount).sendRequest(tL_messages_toggleBotInAttachMenu, new RequestDelegate() {
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                ChatActivity.this.lambda$openAttachBotLayout$206(tL_attachMenuBot, user, tLObject, tL_error);
            }
        }, 66);
    }

    public void lambda$openAttachBotLayout$208(TLRPC.TL_error tL_error, TLRPC.TL_attachMenuBot tL_attachMenuBot, TLRPC.User user) {
        if (tL_error == null) {
            tL_attachMenuBot.side_menu_disclaimer_needed = false;
            tL_attachMenuBot.inactive = false;
            MediaDataController.getInstance(((BaseFragment) this).currentAccount).loadAttachMenuBots(false, true);
            openAttachBotLayout(user.id, this.attachMenuBotStartCommand, false);
        }
    }

    public void lambda$openAttachBotLayout$209(final TLRPC.TL_attachMenuBot tL_attachMenuBot, final TLRPC.User user, TLObject tLObject, final TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$openAttachBotLayout$208(tL_error, tL_attachMenuBot, user);
            }
        });
    }

    public void lambda$openAttachBotLayout$210(final TLRPC.User user, AtomicBoolean atomicBoolean, final TLRPC.TL_attachMenuBot tL_attachMenuBot, AlertDialog alertDialog, int i) {
        TLRPC.TL_messages_toggleBotInAttachMenu tL_messages_toggleBotInAttachMenu = new TLRPC.TL_messages_toggleBotInAttachMenu();
        tL_messages_toggleBotInAttachMenu.bot = MessagesController.getInstance(((BaseFragment) this).currentAccount).getInputUser(user.id);
        tL_messages_toggleBotInAttachMenu.enabled = true;
        tL_messages_toggleBotInAttachMenu.write_allowed = atomicBoolean.get();
        ConnectionsManager.getInstance(((BaseFragment) this).currentAccount).sendRequest(tL_messages_toggleBotInAttachMenu, new RequestDelegate() {
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                ChatActivity.this.lambda$openAttachBotLayout$209(tL_attachMenuBot, user, tLObject, tL_error);
            }
        }, 66);
    }

    public static void lambda$openAttachBotLayout$211(CheckBoxCell checkBoxCell, AtomicBoolean atomicBoolean, View view) {
        boolean z = !checkBoxCell.isChecked();
        checkBoxCell.setChecked(z, true);
        atomicBoolean.set(z);
    }

    public void lambda$openAttachBotLayout$212(TLObject tLObject, final TLRPC.User user) {
        BulletinFactory of;
        int i;
        if (tLObject instanceof TLRPC.TL_attachMenuBotsBot) {
            TLRPC.TL_attachMenuBotsBot tL_attachMenuBotsBot = (TLRPC.TL_attachMenuBotsBot) tLObject;
            MessagesController.getInstance(((BaseFragment) this).currentAccount).putUsers(tL_attachMenuBotsBot.users, false);
            final TLRPC.TL_attachMenuBot tL_attachMenuBot = tL_attachMenuBotsBot.bot;
            if (MediaDataController.canShowAttachMenuBot(tL_attachMenuBot, getCurrentUser() != null ? getCurrentUser() : getCurrentChat())) {
                if (!tL_attachMenuBot.inactive) {
                    openAttachBotLayout(user.id, this.attachMenuBotStartCommand, false);
                    return;
                }
                if (tL_attachMenuBot.show_in_attach_menu || tL_attachMenuBot.show_in_side_menu) {
                    WebAppDisclaimerAlert.show(getContext(), new Consumer() {
                        public final void accept(Object obj) {
                            ChatActivity.this.lambda$openAttachBotLayout$207(user, tL_attachMenuBot, (Boolean) obj);
                        }
                    }, null, null);
                    return;
                }
                View attachBotIntroTopView = new AttachBotIntroTopView(getParentActivity());
                attachBotIntroTopView.setColor(Theme.getColor(Theme.key_chat_attachIcon));
                attachBotIntroTopView.setBackgroundColor(Theme.getColor(Theme.key_dialogTopBackground));
                attachBotIntroTopView.setAttachBot(tL_attachMenuBot);
                final AtomicBoolean atomicBoolean = new AtomicBoolean();
                AlertDialog.Builder negativeButton = new AlertDialog.Builder(getParentActivity()).setTopView(attachBotIntroTopView).setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("BotRequestAttachPermission", R.string.BotRequestAttachPermission, new Object[]{UserObject.getUserName(user)}))).setPositiveButton(LocaleController.getString(R.string.BotAddToMenu), new AlertDialog.OnButtonClickListener() {
                    @Override
                    public final void onClick(AlertDialog alertDialog, int i2) {
                        ChatActivity.this.lambda$openAttachBotLayout$210(user, atomicBoolean, tL_attachMenuBot, alertDialog, i2);
                    }
                }).setNegativeButton(LocaleController.getString(R.string.Cancel), null);
                if (tL_attachMenuBot.request_write_access) {
                    atomicBoolean.set(true);
                    final CheckBoxCell checkBoxCell = new CheckBoxCell(getParentActivity(), 5, getResourceProvider());
                    checkBoxCell.setPadding(0, AndroidUtilities.dp(8.0f), 0, AndroidUtilities.dp(8.0f));
                    checkBoxCell.setBackground(Theme.getSelectorDrawable(false));
                    checkBoxCell.setMultiline(true);
                    checkBoxCell.setText(AndroidUtilities.replaceTags(LocaleController.formatString(R.string.OpenUrlOption2, new Object[]{UserObject.getUserName(user)})), "", true, false);
                    checkBoxCell.setPadding(LocaleController.isRTL ? AndroidUtilities.dp(16.0f) : AndroidUtilities.dp(8.0f), 0, LocaleController.isRTL ? AndroidUtilities.dp(8.0f) : AndroidUtilities.dp(16.0f), 0);
                    checkBoxCell.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public final void onClick(View view) {
                            ChatActivity.lambda$openAttachBotLayout$211(CheckBoxCell.this, atomicBoolean, view);
                        }
                    });
                    negativeButton.setCustomViewOffset(6);
                    negativeButton.setView(checkBoxCell);
                }
                negativeButton.show();
                return;
            }
            TLRPC.User user2 = this.currentUser;
            if (user2 != null && user2.bot && user.id == tL_attachMenuBot.bot_id) {
                of = BulletinFactory.of(this);
                i = R.string.BotCantOpenAttachMenuSameBot;
            } else if (user2 != null && user2.bot && user.id != tL_attachMenuBot.bot_id) {
                of = BulletinFactory.of(this);
                i = R.string.BotCantOpenAttachMenuBot;
            } else if (user2 == null || user2.bot) {
                TLRPC.Chat chat = this.currentChat;
                if (chat == null || ChatObject.isChannelAndNotMegaGroup(chat)) {
                    TLRPC.Chat chat2 = this.currentChat;
                    if (chat2 == null || !ChatObject.isChannelAndNotMegaGroup(chat2)) {
                        return;
                    }
                    of = BulletinFactory.of(this);
                    i = R.string.BotCantOpenAttachMenuChannel;
                } else {
                    of = BulletinFactory.of(this);
                    i = R.string.BotCantOpenAttachMenuGroup;
                }
            } else {
                of = BulletinFactory.of(this);
                i = R.string.BotCantOpenAttachMenuUser;
            }
            of.createErrorBulletin(LocaleController.getString(i)).show();
        }
    }

    public void lambda$openAttachBotLayout$213(final TLRPC.User user, final TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$openAttachBotLayout$212(tLObject, user);
            }
        });
    }

    public void lambda$openAttachBotLayout$214(TLObject tLObject) {
        if (tLObject != null) {
            TLRPC.TL_contacts_resolvedPeer tL_contacts_resolvedPeer = (TLRPC.TL_contacts_resolvedPeer) tLObject;
            if (tL_contacts_resolvedPeer.users.isEmpty()) {
                return;
            }
            final TLRPC.User user = (TLRPC.User) tL_contacts_resolvedPeer.users.get(0);
            if (user.bot && user.bot_attach_menu) {
                TLRPC.TL_messages_getAttachMenuBot tL_messages_getAttachMenuBot = new TLRPC.TL_messages_getAttachMenuBot();
                tL_messages_getAttachMenuBot.bot = MessagesController.getInstance(((BaseFragment) this).currentAccount).getInputUser(user.id);
                ConnectionsManager.getInstance(((BaseFragment) this).currentAccount).sendRequest(tL_messages_getAttachMenuBot, new RequestDelegate() {
                    public final void run(TLObject tLObject2, TLRPC.TL_error tL_error) {
                        ChatActivity.this.lambda$openAttachBotLayout$213(user, tLObject2, tL_error);
                    }
                });
            }
        }
    }

    public void lambda$openAttachBotLayout$215(final TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$openAttachBotLayout$214(tLObject);
            }
        });
    }

    public void lambda$openClickableLink$380(String str, CharacterStyle characterStyle, MessageObject messageObject, ChatMessageCell chatMessageCell, int i, DialogInterface dialogInterface, int i2) {
        UndoView undoView;
        int i3;
        String publicUsername;
        StringBuilder sb;
        String str2;
        MessageObject messageObject2;
        if (i2 == 0) {
            if (str.startsWith("video?")) {
                didPressMessageUrl(characterStyle, false, messageObject, chatMessageCell);
                return;
            } else {
                logSponsoredClicked(messageObject, false, false);
                openClickableLink(characterStyle, str, false, chatMessageCell, messageObject, true);
                return;
            }
        }
        if (i2 == 1) {
            if (!str.startsWith("video?") || messageObject == null || messageObject.scheduled) {
                AndroidUtilities.addToClipboard(str);
            } else {
                if (!messageObject.isVideo() && !messageObject.isRoundVideo() && !messageObject.isVoice() && !messageObject.isMusic() && (messageObject2 = messageObject.replyMessageObject) != null) {
                    messageObject = messageObject2;
                }
                long dialogId = messageObject.getDialogId();
                int id = messageObject.getId();
                TLRPC.MessageFwdHeader messageFwdHeader = messageObject.messageOwner.fwd_from;
                if (messageFwdHeader != null) {
                    TLRPC.Peer peer = messageFwdHeader.saved_from_peer;
                    if (peer != null) {
                        dialogId = MessageObject.getPeerId(peer);
                        id = messageObject.messageOwner.fwd_from.saved_from_msg_id;
                    } else {
                        TLRPC.Peer peer2 = messageFwdHeader.from_id;
                        if (peer2 != null) {
                            dialogId = MessageObject.getPeerId(peer2);
                            id = messageObject.messageOwner.fwd_from.channel_post;
                        }
                    }
                }
                if (DialogObject.isChatDialog(dialogId)) {
                    TLRPC.Chat chat = MessagesController.getInstance(((BaseFragment) this).currentAccount).getChat(Long.valueOf(-dialogId));
                    publicUsername = ChatObject.getPublicUsername(chat);
                    if (chat != null && publicUsername != null) {
                        sb = new StringBuilder();
                        sb.append("https://t.me/");
                        sb.append(publicUsername);
                        sb.append("/");
                        sb.append(id);
                        sb.append("?t=");
                        sb.append(AndroidUtilities.formatTimestamp(i));
                        str2 = sb.toString();
                    }
                    str2 = null;
                } else {
                    TLRPC.User user = MessagesController.getInstance(((BaseFragment) this).currentAccount).getUser(Long.valueOf(dialogId));
                    publicUsername = UserObject.getPublicUsername(user);
                    if (user != null && publicUsername != null) {
                        sb = new StringBuilder();
                        sb.append("https://t.me/");
                        sb.append(publicUsername);
                        sb.append("/");
                        sb.append(id);
                        sb.append("?t=");
                        sb.append(AndroidUtilities.formatTimestamp(i));
                        str2 = sb.toString();
                    }
                    str2 = null;
                }
                if (str2 == null) {
                    return;
                } else {
                    AndroidUtilities.addToClipboard(str2);
                }
            }
            createUndoView();
            if (this.undoView == null) {
                return;
            }
            if (str.startsWith("@")) {
                undoView = this.undoView;
                i3 = 56;
            } else if (str.startsWith("#") || str.startsWith("$")) {
                undoView = this.undoView;
                i3 = 57;
            } else {
                undoView = this.undoView;
                i3 = 59;
            }
            undoView.showWithAction(0L, i3, (Runnable) null);
        }
    }

    public static void lambda$openClickableLink$381(ChatMessageCell chatMessageCell, DialogInterface dialogInterface) {
        if (chatMessageCell != null) {
            chatMessageCell.resetPressedLink(-1);
        }
    }

    public void lambda$openDiscussionMessageChat$368(int i, TLObject tLObject, TLRPC.TL_error tL_error, int i2, MessageObject messageObject, TLRPC.TL_messages_getDiscussionMessage tL_messages_getDiscussionMessage, TLRPC.Chat chat, int i3, MessageObject messageObject2) {
        if (i != this.commentMessagesLoadingGuid) {
            return;
        }
        this.commentMessagesRequestId = -1;
        if (tLObject != null) {
            this.savedHistory = (TLRPC.messages_Messages) tLObject;
        } else {
            if ("CHANNEL_PRIVATE".equals(tL_error.text)) {
                MessagesController.showCantOpenAlert(this, LocaleController.getString(R.string.ChannelCantOpenBannedByAdmin));
                this.commentLoadingMessageId = 0;
                this.hideCommentLoading = false;
                this.chatListView.invalidateViews();
                return;
            }
            this.savedNoHistory = true;
        }
        processLoadedDiscussionMessage(this.savedNoDiscussion, this.savedDiscussionMessage, this.savedNoHistory, this.savedHistory, i2, messageObject, tL_messages_getDiscussionMessage, chat, i3, messageObject2);
    }

    public void lambda$openDiscussionMessageChat$369(final int i, final TLObject tLObject, final TLRPC.TL_error tL_error, final int i2, final MessageObject messageObject, final TLRPC.TL_messages_getDiscussionMessage tL_messages_getDiscussionMessage, final TLRPC.Chat chat, final int i3, final MessageObject messageObject2) {
        lambda$openDiscussionMessageChat$372(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$openDiscussionMessageChat$368(i, tLObject, tL_error, i2, messageObject, tL_messages_getDiscussionMessage, chat, i3, messageObject2);
            }
        });
    }

    public void lambda$openDiscussionMessageChat$370(final int i, final int i2, final MessageObject messageObject, final TLRPC.TL_messages_getDiscussionMessage tL_messages_getDiscussionMessage, final TLRPC.Chat chat, final int i3, final MessageObject messageObject2, final TLObject tLObject, final TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$openDiscussionMessageChat$369(i, tLObject, tL_error, i2, messageObject, tL_messages_getDiscussionMessage, chat, i3, messageObject2);
            }
        });
    }

    public void lambda$openDiscussionMessageChat$371(int i, final int i2, long j, TLObject tLObject, final int i3, final MessageObject messageObject, final TLRPC.TL_messages_getDiscussionMessage tL_messages_getDiscussionMessage, final TLRPC.Chat chat, final MessageObject messageObject2) {
        int i4;
        if (i != this.commentLoadingGuid) {
            return;
        }
        this.commentRequestId = -1;
        if (tLObject instanceof TLRPC.TL_messages_discussionMessage) {
            this.savedDiscussionMessage = (TLRPC.TL_messages_discussionMessage) tLObject;
            getMessagesController().putUsers(this.savedDiscussionMessage.users, false);
            getMessagesController().putChats(this.savedDiscussionMessage.chats, false);
        } else {
            this.savedNoDiscussion = true;
        }
        ArrayList arrayList = new ArrayList();
        TLRPC.TL_messages_discussionMessage tL_messages_discussionMessage = this.savedDiscussionMessage;
        if (tL_messages_discussionMessage != null && tL_messages_discussionMessage.messages != null) {
            for (int i5 = 0; i5 < this.savedDiscussionMessage.messages.size(); i5++) {
                TLRPC.Message message = (TLRPC.Message) this.savedDiscussionMessage.messages.get(i5);
                if (!(message instanceof TLRPC.TL_messageEmpty)) {
                    arrayList.add(message);
                }
            }
        }
        if (arrayList.size() <= 0) {
            this.savedNoHistory = true;
            processLoadedDiscussionMessage(this.savedNoDiscussion, this.savedDiscussionMessage, true, this.savedHistory, i2, messageObject, tL_messages_getDiscussionMessage, chat, i3, messageObject2);
            return;
        }
        TLRPC.Message message2 = (TLRPC.Message) arrayList.get(0);
        TLRPC.TL_messages_getReplies tL_messages_getReplies = new TLRPC.TL_messages_getReplies();
        tL_messages_getReplies.peer = getMessagesController().getInputPeer(message2.peer_id);
        tL_messages_getReplies.msg_id = message2.id;
        tL_messages_getReplies.offset_date = 0;
        tL_messages_getReplies.limit = 30;
        if (i3 > 0) {
            tL_messages_getReplies.offset_id = i3;
            i4 = -15;
        } else {
            tL_messages_getReplies.offset_id = i2 == 0 ? 1 : i2;
            i4 = -20;
        }
        tL_messages_getReplies.add_offset = i4;
        final int i6 = 1 + this.commentMessagesLoadingGuid;
        this.commentMessagesLoadingGuid = i6;
        this.commentMessagesRequestId = getConnectionsManager().sendRequest(tL_messages_getReplies, new RequestDelegate() {
            public final void run(TLObject tLObject2, TLRPC.TL_error tL_error) {
                ChatActivity.this.lambda$openDiscussionMessageChat$370(i6, i2, messageObject, tL_messages_getDiscussionMessage, chat, i3, messageObject2, tLObject2, tL_error);
            }
        });
    }

    public void lambda$openDiscussionMessageChat$373(final int i, final int i2, final long j, final int i3, final MessageObject messageObject, final TLRPC.TL_messages_getDiscussionMessage tL_messages_getDiscussionMessage, final TLRPC.Chat chat, final MessageObject messageObject2, final TLObject tLObject, TLRPC.TL_error tL_error) {
        final Runnable runnable = new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$openDiscussionMessageChat$371(i, i2, j, tLObject, i3, messageObject, tL_messages_getDiscussionMessage, chat, messageObject2);
            }
        };
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$openDiscussionMessageChat$372(runnable);
            }
        });
    }

    public void lambda$openLinkInternally$382(int i, int i2, CharacterStyle characterStyle, ChatMessageCell chatMessageCell) {
        this.progressDialogAtMessageId = i;
        this.progressDialogAtMessageType = i2;
        this.progressDialogLinkSpan = characterStyle;
        chatMessageCell.invalidate();
    }

    public void lambda$openPollCreate$125(TLRPC.MessageMedia messageMedia, HashMap hashMap, boolean z, int i) {
        if (checkSlowModeAlert()) {
            SendMessagesHelper.SendMessageParams of = SendMessagesHelper.SendMessageParams.of(messageMedia, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TLRPC.ReplyMarkup) null, hashMap, z, i);
            of.quick_reply_shortcut = this.quickReplyShortcut;
            of.quick_reply_shortcut_id = getQuickReplyId();
            getSendMessagesHelper().sendMessage(of);
            afterMessageSend();
        }
    }

    public void lambda$performHistoryClear$118(long j, boolean z) {
        if (!this.pinnedMessageIds.isEmpty()) {
            MessagesController.getNotificationsSettings(((BaseFragment) this).currentAccount).edit().putInt("pin_" + this.dialog_id, ((Integer) this.pinnedMessageIds.get(0)).intValue()).commit();
            this.pinnedMessageIds.clear();
            this.pinnedMessageObjects.clear();
            this.currentPinnedMessageId = 0;
            this.loadedPinnedMessagesCount = 0;
            this.totalPinnedMessagesCount = 0;
            updatePinnedMessageView(true);
        }
        if (!ChatObject.isMonoForum(this.currentChat) || !ChatObject.canManageMonoForum(((BaseFragment) this).currentAccount, this.currentChat)) {
            getMessagesController().deleteDialog(this.dialog_id, 1, z);
        } else if (j != 0) {
            getMessagesStorage().removeTopic(-this.currentChat.id, j);
            getMessagesController().deleteSavedDialog(j, getMessagesController().getInputPeer(-this.currentChat.id));
            getMessagesController().getTopicsController().onTopicsDeletedServerSide(this.currentChat.id, j);
        }
        setClearingHistory(j, false);
        if (j == getThreadId()) {
            clearHistory(false, null);
            this.chatAdapter.notifyDataSetChanged();
        }
    }

    public void lambda$performHistoryClear$119(long j) {
        setClearingHistory(j, false);
        if (j == getThreadId()) {
            this.chatAdapter.notifyDataSetChanged();
        }
    }

    public void lambda$processInlineBotWebView$115(TLRPC.TL_inlineBotWebView tL_inlineBotWebView) {
        TLRPC.User foundContextBot = this.mentionContainer.getAdapter().getFoundContextBot();
        int i = ((BaseFragment) this).currentAccount;
        TLRPC.User user = this.currentUser;
        WebViewRequestProps of = WebViewRequestProps.of(i, user != null ? user.id : this.currentChat.id, foundContextBot.id, tL_inlineBotWebView.text, tL_inlineBotWebView.url, 1, 0, getSendMonoForumPeerId(), false, (TLRPC.BotApp) null, false, (String) null, (TLRPC.User) null, 1, false, false);
        LaunchActivity launchActivity = LaunchActivity.instance;
        if (launchActivity == null || launchActivity.getBottomSheetTabs() == null || LaunchActivity.instance.getBottomSheetTabs().tryReopenTab(of) == null) {
            String restrictionReason = MessagesController.getInstance(((BaseFragment) this).currentAccount).getRestrictionReason(foundContextBot.restriction_reason);
            if (!TextUtils.isEmpty(restrictionReason)) {
                MessagesController.getInstance(((BaseFragment) this).currentAccount);
                MessagesController.showCantOpenAlert(this, restrictionReason);
                return;
            }
            BotWebViewSheet botWebViewSheet = new BotWebViewSheet(getContext(), getResourceProvider());
            botWebViewSheet.setDefaultFullsize(false);
            botWebViewSheet.setNeedsContext(true);
            botWebViewSheet.setParentActivity(getParentActivity());
            botWebViewSheet.requestWebView(this, of);
            botWebViewSheet.show();
        }
    }

    public void lambda$processInlineBotWebView$116(Runnable runnable, Boolean bool) {
        this.approved = true;
        runnable.run();
    }

    public void lambda$processLoadedDiscussionMessage$364() {
        this.commentLoadingMessageId = 0;
        this.hideCommentLoading = false;
        this.chatListView.invalidateViews();
    }

    public void lambda$processLoadedDiscussionMessage$365(boolean[] zArr, int i, ChatActivity chatActivity) {
        ChatActivityEnterView chatActivityEnterView;
        if (zArr[0] || i != this.commentLoadingMessageId || !this.isFullyVisible || isFinishing()) {
            return;
        }
        zArr[0] = true;
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$processLoadedDiscussionMessage$364();
            }
        }, 200L);
        presentFragment(chatActivity);
        if (!isKeyboardVisible() || chatActivity.hideKeyboardOnShow() || (chatActivityEnterView = chatActivity.chatActivityEnterView) == null || chatActivityEnterView.getEditField() == null) {
            return;
        }
        chatActivity.chatActivityEnterView.getEditField().requestFocus();
    }

    public void lambda$processLoadedDiscussionMessage$366(TLRPC.messages_Messages messages_messages, long j, int i, int i2, int i3, int i4, ArrayList arrayList) {
        getMessagesController().processLoadedMessages(messages_messages, messages_messages.messages.size(), j, 0L, 30, i > 0 ? i : i2, 0, false, i3, i4, 0, 0, 0, i > 0 ? 3 : 2, true, 0, ((MessageObject) arrayList.get(arrayList.size() - 1)).getId(), 1, false, 0, true, this.isTopic, (Timer) null);
    }

    public void lambda$processLoadedDiscussionMessage$367(final ArrayList arrayList, TLRPC.TL_messages_discussionMessage tL_messages_discussionMessage, final TLRPC.messages_Messages messages_messages, TLRPC.Chat chat, TLRPC.TL_messages_getDiscussionMessage tL_messages_getDiscussionMessage, final int i, MessageObject messageObject, final int i2, final int i3, MessageObject messageObject2) {
        int i4;
        TLRPC.TL_messageReactions tL_messageReactions;
        TLRPC.MessageReplies messageReplies;
        TLRPC.MessageReplies messageReplies2;
        if (arrayList.isEmpty() || tL_messages_discussionMessage == null) {
            this.commentLoadingMessageId = 0;
            this.hideCommentLoading = false;
            this.chatListView.invalidateViews();
            if (messageObject2 != null) {
                openOriginalReplyChat(messageObject2);
                return;
            } else {
                if (getParentActivity() != null) {
                    BulletinFactory.of(this).createErrorBulletin(LocaleController.getString(R.string.ChannelPostDeleted), this.themeDelegate).show();
                    return;
                }
                return;
            }
        }
        this.hideCommentLoading = true;
        this.chatListView.invalidateViews();
        Bundle bundle = new Bundle();
        final long dialogId = ((MessageObject) arrayList.get(0)).getDialogId();
        bundle.putLong("chat_id", -dialogId);
        bundle.putInt("message_id", Math.max(1, tL_messages_discussionMessage.read_inbox_max_id));
        bundle.putInt("unread_count", tL_messages_discussionMessage.unread_count);
        bundle.putBoolean("historyPreloaded", messages_messages != null);
        final ChatActivity chatActivity = new ChatActivity(bundle);
        chatActivity.setThreadMessages(arrayList, chat, tL_messages_getDiscussionMessage.msg_id, tL_messages_discussionMessage.read_inbox_max_id, tL_messages_discussionMessage.read_outbox_max_id, null);
        if (i != 0) {
            chatActivity.highlightMessageId = i;
        }
        if (messageObject != null && (messageReplies = messageObject.messageOwner.replies) != null && (messageReplies2 = chatActivity.threadMessageObject.messageOwner.replies) != null) {
            messageReplies.replies = messageReplies2.replies;
        }
        if (messageObject != null && (tL_messageReactions = messageObject.messageOwner.reactions) != null) {
            chatActivity.threadMessageObject.messageOwner.reactions = tL_messageReactions;
        }
        final boolean[] zArr = {false};
        Runnable runnable = new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$processLoadedDiscussionMessage$365(zArr, i2, chatActivity);
            }
        };
        if (messages_messages == null) {
            runnable.run();
            return;
        }
        if (!messages_messages.messages.isEmpty()) {
            for (int size = messages_messages.messages.size() - 1; size >= 0; size--) {
                TLRPC.Message message = (TLRPC.Message) messages_messages.messages.get(size);
                int i5 = message.id;
                if (i5 > i3 && !message.out) {
                    i4 = i5;
                    break;
                }
            }
        }
        i4 = 0;
        final int classGuid = chatActivity.getClassGuid();
        NotificationCenter.getInstance(((BaseFragment) this).currentAccount).addObserver(new AnonymousClass153(classGuid, runnable, chatActivity), NotificationCenter.messagesDidLoad);
        final int i6 = i4;
        Utilities.stageQueue.postRunnable(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$processLoadedDiscussionMessage$366(messages_messages, dialogId, i, i3, classGuid, i6, arrayList);
            }
        });
    }

    public void lambda$processNewMessages$199(int i) {
        scrollToMessageId(i, 0, false, 0, true, 0);
    }

    public void lambda$processSelectedOption$313(MessageObject.GroupedMessages groupedMessages, MessageObject messageObject, Long l) {
        if (groupedMessages != null) {
            boolean z = true;
            for (int i = 0; i < groupedMessages.messages.size(); i++) {
                if (!getSendMessagesHelper().retrySendMessage((MessageObject) groupedMessages.messages.get(i), false, l.longValue())) {
                    z = false;
                }
            }
            if (!z || this.chatMode != 0) {
                return;
            }
        } else {
            if (!getSendMessagesHelper().retrySendMessage(messageObject, false, l.longValue())) {
                return;
            }
            updateVisibleRows();
            if (this.chatMode != 0) {
                return;
            }
        }
        moveScrollToLastMessage(false);
    }

    public void lambda$processSelectedOption$314(DialogInterface dialogInterface) {
        dimBehindView(false);
    }

    public void lambda$processSelectedOption$315(DialogInterface dialogInterface) {
        dimBehindView(false);
    }

    public void lambda$processSelectedOption$316() {
        dimBehindView(false);
    }

    public void lambda$processSelectedOption$317(boolean z, int i) {
        if (getParentActivity() == null || ((BaseFragment) this).fragmentView == null || i <= 0) {
            return;
        }
        BulletinFactory.of(this).createDownloadBulletin(z ? BulletinFactory.FileType.AUDIOS : BulletinFactory.FileType.UNKNOWNS, i, this.themeDelegate).show();
    }

    public void lambda$processSelectedOption$318(boolean z, boolean z2, boolean z3, Uri uri) {
        if (getParentActivity() == null) {
            return;
        }
        BulletinFactory.of(this).createDownloadBulletin(z ? BulletinFactory.FileType.PHOTO_TO_DOWNLOADS : z2 ? BulletinFactory.FileType.VIDEO_TO_DOWNLOADS : z3 ? BulletinFactory.FileType.GIF_TO_DOWNLOADS : BulletinFactory.FileType.UNKNOWN, this.themeDelegate).show();
    }

    public void lambda$processSelectedOption$319(MessageObject messageObject, Long l, Runnable runnable) {
        StarsController.getInstance(((BaseFragment) this).currentAccount).updateMediaPrice(messageObject, l.longValue(), runnable);
    }

    public void lambda$processSelectedOption$320(DialogInterface dialogInterface) {
        dimBehindView(false);
    }

    public static void lambda$processSelectedOption$321(boolean[] zArr, View view) {
        boolean z = !zArr[1];
        zArr[1] = z;
        ((CheckBoxCell) view).setChecked(z, true);
    }

    public static void lambda$processSelectedOption$322(boolean[] zArr, View view) {
        boolean z = !zArr[0];
        zArr[0] = z;
        ((CheckBoxCell) view).setChecked(z, true);
    }

    public static void lambda$processSelectedOption$323(View view) {
        try {
            view.performHapticFeedback(3, 2);
        } catch (Exception unused) {
        }
    }

    public void lambda$processSelectedOption$324(int i, boolean[] zArr, AlertDialog alertDialog, int i2) {
        getMessagesController().pinMessage(this.currentChat, this.currentUser, i, false, !zArr[1], zArr[0]);
        Bulletin createPinMessageBulletin = BulletinFactory.createPinMessageBulletin(this, this.themeDelegate);
        createPinMessageBulletin.show();
        final Bulletin.Layout layout = createPinMessageBulletin.getLayout();
        layout.postDelayed(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.lambda$processSelectedOption$323(layout);
            }
        }, 550L);
    }

    public void lambda$processSelectedOption$325(TLObject tLObject) {
        if (tLObject != null) {
            TLRPC.TL_exportedMessageLink tL_exportedMessageLink = (TLRPC.TL_exportedMessageLink) tLObject;
            try {
                ((ClipboardManager) ApplicationLoader.applicationContext.getSystemService("clipboard")).setPrimaryClip(ClipData.newPlainText("label", tL_exportedMessageLink.link));
                if (BulletinFactory.canShowBulletin(this)) {
                    BulletinFactory.of(this).createCopyLinkBulletin(!isThreadChat() && tL_exportedMessageLink.link.contains("/c/")).show();
                }
            } catch (Exception e) {
                FileLog.e(e);
            }
        }
    }

    public void lambda$processSelectedOption$326(final TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$processSelectedOption$325(tLObject);
            }
        });
    }

    public void lambda$processSelectedOption$327() {
        dimBehindView(false);
    }

    public static void lambda$processSelectedOption$328(AlertDialog[] alertDialogArr) {
        try {
            alertDialogArr[0].dismiss();
        } catch (Throwable unused) {
        }
        alertDialogArr[0] = null;
    }

    public void lambda$processSelectedOption$329(int i, DialogInterface dialogInterface) {
        getConnectionsManager().cancelRequest(i, true);
    }

    public void lambda$processSelectedOption$330(AlertDialog[] alertDialogArr, final int i) {
        AlertDialog alertDialog = alertDialogArr[0];
        if (alertDialog == null) {
            return;
        }
        alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
            @Override
            public final void onCancel(DialogInterface dialogInterface) {
                ChatActivity.this.lambda$processSelectedOption$329(i, dialogInterface);
            }
        });
        showDialog(alertDialogArr[0]);
    }

    public void lambda$processSelectedOption$331(boolean z, MessageObject messageObject, int i, TLRPC.MessageMedia messageMedia, HashMap hashMap, boolean z2, int i2) {
        if (!z) {
            if (messageMedia instanceof TLRPC.TL_messageMediaToDo) {
                TLRPC.TL_messageMediaToDo tL_messageMediaToDo = messageObject.messageOwner.media;
                if (tL_messageMediaToDo instanceof TLRPC.TL_messageMediaToDo) {
                    ((TLRPC.TL_messageMediaToDo) messageMedia).completions = tL_messageMediaToDo.completions;
                }
            }
            messageObject.messageOwner.media = messageMedia;
            getSendMessagesHelper().editMessage(messageObject, (TLRPC.TL_photo) null, (VideoEditedInfo) null, (TLRPC.TL_document) null, (String) null, (TLRPC.PhotoSize) null, (HashMap) null, false, false, (Object) null);
            return;
        }
        TLRPC.TL_messages_appendTodoList tL_messages_appendTodoList = new TLRPC.TL_messages_appendTodoList();
        tL_messages_appendTodoList.peer = getMessagesController().getInputPeer(messageObject.getDialogId());
        tL_messages_appendTodoList.msg_id = messageObject.getId();
        if (messageMedia instanceof TLRPC.TL_messageMediaToDo) {
            TLRPC.TL_messageMediaToDo tL_messageMediaToDo2 = (TLRPC.TL_messageMediaToDo) messageMedia;
            int i3 = i;
            int i4 = 0;
            for (int i5 = 0; i5 < i3; i5++) {
                i4 = Math.max(i4, ((TLRPC.TodoItem) tL_messageMediaToDo2.todo.list.get(i5)).id);
            }
            while (i3 < tL_messageMediaToDo2.todo.list.size()) {
                TLRPC.TodoItem todoItem = (TLRPC.TodoItem) tL_messageMediaToDo2.todo.list.get(i3);
                if (todoItem.id <= i4) {
                    todoItem.id = i4 + 1;
                }
                tL_messages_appendTodoList.list.add(todoItem);
                i4 = Math.max(i4, todoItem.id);
                i3++;
            }
            TLRPC.TL_messageMediaToDo tL_messageMediaToDo3 = messageObject.messageOwner.media;
            if (tL_messageMediaToDo3 instanceof TLRPC.TL_messageMediaToDo) {
                tL_messageMediaToDo2.completions = tL_messageMediaToDo3.completions;
            }
        }
        messageObject.messageOwner.media = messageMedia;
        getConnectionsManager().sendRequest(tL_messages_appendTodoList, (RequestDelegate) null);
    }

    public void lambda$processSelectedOption$332(DialogInterface dialogInterface) {
        dimBehindView(false);
    }

    public static void lambda$processSelectedOption$333(AlertDialog[] alertDialogArr) {
        try {
            alertDialogArr[0].dismiss();
        } catch (Throwable unused) {
        }
        alertDialogArr[0] = null;
    }

    public void lambda$processSelectedOption$334(TLRPC.TL_error tL_error, TLRPC.TL_messages_editMessage tL_messages_editMessage) {
        AlertsCreator.processError(((BaseFragment) this).currentAccount, tL_error, this, tL_messages_editMessage, new Object[0]);
    }

    public void lambda$processSelectedOption$335(final AlertDialog[] alertDialogArr, final TLRPC.TL_messages_editMessage tL_messages_editMessage, TLObject tLObject, final TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.lambda$processSelectedOption$333(alertDialogArr);
            }
        });
        if (tL_error == null) {
            getMessagesController().processUpdates((TLRPC.Updates) tLObject, false);
        } else {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$processSelectedOption$334(tL_error, tL_messages_editMessage);
                }
            });
        }
    }

    public void lambda$processSelectedOption$336(int i, DialogInterface dialogInterface) {
        getConnectionsManager().cancelRequest(i, true);
    }

    public void lambda$processSelectedOption$337(AlertDialog[] alertDialogArr, final int i) {
        AlertDialog alertDialog = alertDialogArr[0];
        if (alertDialog == null) {
            return;
        }
        alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
            @Override
            public final void onCancel(DialogInterface dialogInterface) {
                ChatActivity.this.lambda$processSelectedOption$336(i, dialogInterface);
            }
        });
        showDialog(alertDialogArr[0]);
    }

    public void lambda$processSelectedOption$338(MessageObject messageObject, AlertDialog alertDialog, int i) {
        final AlertDialog[] alertDialogArr = {new AlertDialog(getParentActivity(), 3, this.themeDelegate)};
        final TLRPC.TL_messages_editMessage tL_messages_editMessage = new TLRPC.TL_messages_editMessage();
        TLRPC.TL_messageMediaPoll tL_messageMediaPoll = messageObject.messageOwner.media;
        TLRPC.TL_inputMediaPoll tL_inputMediaPoll = new TLRPC.TL_inputMediaPoll();
        TLRPC.TL_poll tL_poll = new TLRPC.TL_poll();
        tL_inputMediaPoll.poll = tL_poll;
        TLRPC.Poll poll = tL_messageMediaPoll.poll;
        ((TLRPC.Poll) tL_poll).id = poll.id;
        ((TLRPC.Poll) tL_poll).question = poll.question;
        ((TLRPC.Poll) tL_poll).answers = poll.answers;
        ((TLRPC.Poll) tL_poll).closed = true;
        tL_messages_editMessage.media = tL_inputMediaPoll;
        tL_messages_editMessage.peer = getMessagesController().getInputPeer(this.dialog_id);
        tL_messages_editMessage.id = messageObject.getId();
        tL_messages_editMessage.flags |= 16384;
        final int sendRequest = getConnectionsManager().sendRequest(tL_messages_editMessage, new RequestDelegate() {
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                ChatActivity.this.lambda$processSelectedOption$335(alertDialogArr, tL_messages_editMessage, tLObject, tL_error);
            }
        });
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$processSelectedOption$337(alertDialogArr, sendRequest);
            }
        }, 500L);
    }

    public void lambda$processSelectedOption$339(TLRPC.TL_messages_sendScheduledMessages tL_messages_sendScheduledMessages) {
        NotificationCenter notificationCenter = NotificationCenter.getInstance(((BaseFragment) this).currentAccount);
        int i = NotificationCenter.messagesDeleted;
        ArrayList arrayList = tL_messages_sendScheduledMessages.id;
        long clientUserId = getUserConfig().getClientUserId();
        long j = this.dialog_id;
        Long valueOf = Long.valueOf(clientUserId == j ? 0L : -j);
        Boolean bool = Boolean.TRUE;
        notificationCenter.postNotificationName(i, new Object[]{arrayList, valueOf, bool, bool});
    }

    public void lambda$processSelectedOption$340(TLRPC.TL_error tL_error) {
        String str;
        int i;
        if (tL_error.text.startsWith("SLOWMODE_WAIT_")) {
            i = R.string.SlowmodeSendError;
        } else {
            if (!tL_error.text.equals("CHAT_SEND_MEDIA_FORBIDDEN")) {
                str = tL_error.text;
                AlertsCreator.showSimpleToast(this, str);
            }
            i = R.string.AttachMediaRestrictedForever;
        }
        str = LocaleController.getString(i);
        AlertsCreator.showSimpleToast(this, str);
    }

    public void lambda$processSelectedOption$341(final TLRPC.TL_messages_sendScheduledMessages tL_messages_sendScheduledMessages, TLObject tLObject, final TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            getMessagesController().processUpdates((TLRPC.Updates) tLObject, false);
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$processSelectedOption$339(tL_messages_sendScheduledMessages);
                }
            });
        } else if (tL_error.text != null) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$processSelectedOption$340(tL_error);
                }
            });
        }
    }

    public void lambda$processSelectedOption$342() {
        if (checkSlowMode(this.chatActivityEnterView.getSendButton())) {
            return;
        }
        if (getMediaController().isPlayingMessage(this.selectedObject)) {
            getMediaController().cleanupPlayer(true, true);
        }
        final TLRPC.TL_messages_sendScheduledMessages tL_messages_sendScheduledMessages = new TLRPC.TL_messages_sendScheduledMessages();
        tL_messages_sendScheduledMessages.peer = getMessagesController().getInputPeer(this.dialog_id);
        if (this.selectedObjectGroup != null) {
            for (int i = 0; i < this.selectedObjectGroup.messages.size(); i++) {
                tL_messages_sendScheduledMessages.id.add(Integer.valueOf(((MessageObject) this.selectedObjectGroup.messages.get(i)).getId()));
            }
        } else {
            tL_messages_sendScheduledMessages.id.add(Integer.valueOf(this.selectedObject.getId()));
        }
        ConnectionsManager.getInstance(((BaseFragment) this).currentAccount).sendRequest(tL_messages_sendScheduledMessages, new RequestDelegate() {
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                ChatActivity.this.lambda$processSelectedOption$341(tL_messages_sendScheduledMessages, tLObject, tL_error);
            }
        });
    }

    public void lambda$processSelectedOption$344(MessageObject.GroupedMessages groupedMessages, MessageObject messageObject, boolean z, int i) {
        SendMessagesHelper sendMessagesHelper;
        boolean z2;
        ArrayList arrayList;
        String str;
        MessageObject messageObject2;
        if (groupedMessages == null || groupedMessages.messages.isEmpty()) {
            sendMessagesHelper = SendMessagesHelper.getInstance(((BaseFragment) this).currentAccount);
            z2 = false;
            arrayList = null;
            str = null;
            messageObject2 = messageObject;
        } else {
            sendMessagesHelper = SendMessagesHelper.getInstance(((BaseFragment) this).currentAccount);
            messageObject2 = (MessageObject) groupedMessages.messages.get(0);
            z2 = false;
            arrayList = null;
            str = null;
        }
        sendMessagesHelper.editMessage(messageObject2, str, z2, this, arrayList, i);
    }

    public void lambda$processSelectedOption$345(DialogInterface dialogInterface) {
        dimBehindView(false);
    }

    public void lambda$processSelectedOption$346(MessageObject messageObject, MessageSuggestionParams messageSuggestionParams) {
        TLRPC.SuggestedPost tl = messageSuggestionParams.toTl();
        if (messageObject == null || messageObject.messageOwner == null || tl == null) {
            return;
        }
        getMessagesController().addOfferToSuggestedMessage(messageObject, tl);
    }

    public void lambda$processSelectedOption$347(TLRPC.SuggestedPost suggestedPost, MessageObject messageObject, boolean z, int i) {
        if (z) {
            TLRPC.SuggestedPost tl = MessageSuggestionParams.of(AmountUtils.Amount.of(suggestedPost != null ? suggestedPost.price : null), i).toTl();
            if (messageObject == null || messageObject.messageOwner == null || tl == null) {
                return;
            }
            getMessagesController().addOfferToSuggestedMessage(messageObject, tl);
        }
    }

    public void lambda$processSelectedOption$348(final TLRPC.SuggestedPost suggestedPost, final MessageObject messageObject) {
        AlertsCreator.createSuggestedMessageDatePickerDialog(getContext(), suggestedPost != null ? suggestedPost.schedule_date : 0L, new AlertsCreator.ScheduleDatePickerDelegate() {
            public final void didSelectDate(boolean z, int i) {
                ChatActivity.this.lambda$processSelectedOption$347(suggestedPost, messageObject, z, i);
            }
        }, getResourceProvider(), 0).show();
    }

    public void lambda$removeKeyboardPositionBeforeTransition$203() {
        this.cancelFixedPositionRunnable = null;
        this.fixedKeyboardHeight = -1;
        View view = ((BaseFragment) this).fragmentView;
        if (view != null) {
            view.requestLayout();
        }
    }

    public static void lambda$requestLinkPreview$134(Utilities.Callback2 callback2, TLRPC.WebPage webPage) {
        callback2.run(Boolean.TRUE, webPage);
    }

    public static void lambda$requestLinkPreview$135(Utilities.Callback2 callback2) {
        callback2.run(Boolean.FALSE, (Object) null);
    }

    public static void lambda$requestLinkPreview$136(LongSparseArray longSparseArray, final Utilities.Callback2 callback2) {
        TLRPC.Message message;
        TLRPC.MessageMedia messageMedia;
        TLRPC.WebPage webPage;
        MessageObject messageObject = (longSparseArray.size() == 1 && longSparseArray.valueAt(0) != null && ((ArrayList) longSparseArray.valueAt(0)).size() == 1) ? (MessageObject) ((ArrayList) longSparseArray.valueAt(0)).get(0) : null;
        if (messageObject != null && (message = messageObject.messageOwner) != null && (messageMedia = message.media) != null && (webPage = messageMedia.webpage) != null && webPage.attributes != null) {
            for (int i = 0; i < messageObject.messageOwner.media.webpage.attributes.size(); i++) {
                TLRPC.TL_webPageAttributeStory tL_webPageAttributeStory = (TLRPC.WebPageAttribute) messageObject.messageOwner.media.webpage.attributes.get(i);
                if ((tL_webPageAttributeStory instanceof TLRPC.TL_webPageAttributeStory) && tL_webPageAttributeStory.storyItem != null) {
                    final TLRPC.WebPage webPage2 = messageObject.messageOwner.media.webpage;
                    AndroidUtilities.runOnUIThread(new Runnable() {
                        @Override
                        public final void run() {
                            ChatActivity.lambda$requestLinkPreview$134(callback2, webPage2);
                        }
                    });
                    return;
                }
            }
        }
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.lambda$requestLinkPreview$135(callback2);
            }
        });
    }

    public void lambda$requestLinkPreview$137(TLRPC.TL_messageMediaWebPage tL_messageMediaWebPage, TLRPC.TL_webPageAttributeStory tL_webPageAttributeStory, final Utilities.Callback2 callback2) {
        try {
            final LongSparseArray longSparseArray = new LongSparseArray();
            TLRPC.TL_message tL_message = new TLRPC.TL_message();
            ((TLRPC.Message) tL_message).message = "";
            ((TLRPC.Message) tL_message).id = 0;
            ((TLRPC.Message) tL_message).media = tL_messageMediaWebPage;
            ArrayList arrayList = new ArrayList();
            arrayList.add(new MessageObject(((BaseFragment) this).currentAccount, tL_message, false, false));
            longSparseArray.put(DialogObject.getPeerDialogId(tL_webPageAttributeStory.peer), arrayList);
            getMessagesController().getStoriesController().getStoriesStorage().fillMessagesWithStories(longSparseArray, new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.lambda$requestLinkPreview$136(longSparseArray, callback2);
                }
            }, ((BaseFragment) this).classGuid, false, (Timer) null);
        } catch (Exception unused) {
        }
    }

    public void lambda$requestLinkPreview$138(org.telegram.tgnet.TLObject r5, final org.telegram.messenger.Utilities.Callback2 r6) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.lambda$requestLinkPreview$138(org.telegram.tgnet.TLObject, org.telegram.messenger.Utilities$Callback2):void");
    }

    public void lambda$requestLinkPreview$139(final Utilities.Callback2 callback2, final TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$requestLinkPreview$138(tLObject, callback2);
            }
        });
    }

    public void lambda$requestLinkPreviewCached$133(TL_account.getWebPagePreview getwebpagepreview, Utilities.Callback2 callback2, Boolean bool, TLRPC.WebPage webPage) {
        if (bool.booleanValue() && !(webPage instanceof TLRPC.TL_webPagePending)) {
            Iterator it = this.lastLinkPreviewResults.keySet().iterator();
            while (it.hasNext() && this.lastLinkPreviewResults.size() > 5) {
                it.next();
                it.remove();
            }
            this.lastLinkPreviewResults.put(getwebpagepreview.message, webPage);
        }
        callback2.run(bool, webPage);
    }

    public void lambda$scrollToLastMessage$145(int i, boolean z) {
        this.chatScrollHelper.scrollToPosition(this.chatScrollHelperCallback.position = i, this.chatScrollHelperCallback.offset = 0, this.chatScrollHelperCallback.bottom = !z, true, true);
        this.canShowPagedownButton = false;
        updatePagedownButtonVisibility(true);
    }

    public void lambda$scrollToLastMessage$147() {
        MessagesController messagesController = getMessagesController();
        long j = this.dialog_id;
        long j2 = this.mergeDialogId;
        int i = ((BaseFragment) this).classGuid;
        int i2 = this.chatMode;
        long j3 = this.threadMessageId;
        int i3 = this.replyMaxReadId;
        int i4 = this.lastLoadIndex;
        this.lastLoadIndex = i4 + 1;
        messagesController.loadMessages(j, j2, false, 30, 0, 0, true, 0, i, 0, 0, i2, j3, i3, i4, this.isTopic);
    }

    public void lambda$scrollToMessageId$153() {
        int i = this.nextScrollToMessageId;
        if (i != 0) {
            scrollToMessageId(i, this.nextScrollFromMessageId, this.nextScrollSelect, this.nextScrollLoadIndex, this.nextScrollForce, this.nextScrollForcePinnedMessageId);
            this.nextScrollToMessageId = 0;
        }
    }

    public void lambda$scrollToMessageId$154(DialogInterface dialogInterface) {
        showPinnedProgress(false);
    }

    public void lambda$searchLinks$126() {
        this.foundWebPage = null;
        fallbackFieldPanel();
    }

    public void lambda$searchLinks$127() {
        this.foundWebPage = null;
        fallbackFieldPanel();
    }

    public void lambda$searchLinks$128(MessagesController messagesController, CharSequence charSequence, boolean z, AlertDialog alertDialog, int i) {
        messagesController.secretWebpagePreview = 1;
        MessagesController.getGlobalMainSettings().edit().putInt("secretWebpage2", getMessagesController().secretWebpagePreview).commit();
        this.foundUrls = null;
        searchLinks(charSequence, z);
    }

    public void lambda$searchLinks$129(final MessagesController messagesController, final CharSequence charSequence, final boolean z) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity(), this.themeDelegate);
        builder.setTitle(LocaleController.getString(R.string.AppName));
        builder.setPositiveButton(LocaleController.getString(R.string.OK), new AlertDialog.OnButtonClickListener() {
            @Override
            public final void onClick(AlertDialog alertDialog, int i) {
                ChatActivity.this.lambda$searchLinks$128(messagesController, charSequence, z, alertDialog, i);
            }
        });
        builder.setNegativeButton(LocaleController.getString(R.string.Cancel), null);
        builder.setMessage(LocaleController.getString(R.string.SecretLinkPreviewAlert));
        showDialog(builder.create());
        messagesController.secretWebpagePreview = 0;
        MessagesController.getGlobalMainSettings().edit().putInt("secretWebpage2", messagesController.secretWebpagePreview).commit();
    }

    public void lambda$searchLinks$130(int i, Boolean bool, TLRPC.WebPage webPage, TL_account.getWebPagePreview getwebpagepreview) {
        if (this.waitingForWebpageId != i) {
            return;
        }
        if (bool.booleanValue()) {
            this.foundWebPage = webPage;
            String str = getwebpagepreview.message;
            webPage.display_url = str;
            if ((webPage instanceof TLRPC.TL_webPage) || (webPage instanceof TLRPC.TL_webPagePending)) {
                boolean z = webPage instanceof TLRPC.TL_webPagePending;
                if (z) {
                    this.pendingLinkSearchString = str;
                }
                if (this.currentEncryptedChat != null && z) {
                    webPage.url = str;
                }
                MessagePreviewParams messagePreviewParams = this.messagePreviewParams;
                if (messagePreviewParams != null) {
                    int i2 = ((BaseFragment) this).currentAccount;
                    CharSequence fieldText = this.chatActivityEnterView.getFieldText();
                    MessageObject messageObject = this.replyingMessageObject;
                    messagePreviewParams.updateLink(i2, (TLRPC.WebPage) null, fieldText, messageObject == this.threadMessageObject ? null : messageObject, this.replyingQuote, this.editingMessageObject);
                }
                showFieldPanelForWebPage(true, this.foundWebPage, false);
                return;
            }
            this.foundWebPage = null;
            MessagePreviewParams messagePreviewParams2 = this.messagePreviewParams;
            if (messagePreviewParams2 != null) {
                int i3 = ((BaseFragment) this).currentAccount;
                CharSequence fieldText2 = this.chatActivityEnterView.getFieldText();
                MessageObject messageObject2 = this.replyingMessageObject;
                messagePreviewParams2.updateLink(i3, (TLRPC.WebPage) null, fieldText2, messageObject2 == this.threadMessageObject ? null : messageObject2, this.replyingQuote, this.editingMessageObject);
            }
        } else {
            this.foundWebPage = null;
        }
        fallbackFieldPanel();
    }

    public void lambda$searchLinks$131(final int i, final TL_account.getWebPagePreview getwebpagepreview, final Boolean bool, final TLRPC.WebPage webPage) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$searchLinks$130(i, bool, webPage, getwebpagepreview);
            }
        });
    }

    public void lambda$searchLinks$132(final CharSequence charSequence, final MessagesController messagesController, final boolean z) {
        boolean z2;
        CharSequence charSequence2;
        URLSpan[] uRLSpanArr;
        if (this.linkSearchRequestId != 0) {
            getConnectionsManager().cancelRequest(this.linkSearchRequestId, true);
            this.linkSearchRequestId = 0;
            z2 = true;
        } else {
            z2 = false;
        }
        ArrayList arrayList = null;
        try {
            Matcher matcher = AndroidUtilities.WEB_URL.matcher(charSequence);
            while (matcher.find()) {
                if (matcher.start() <= 0 || charSequence.charAt(matcher.start() - 1) != '@') {
                    if (arrayList == null) {
                        arrayList = new ArrayList();
                    }
                    arrayList.add(charSequence.subSequence(matcher.start(), matcher.end()));
                }
            }
            if ((charSequence instanceof Spannable) && (uRLSpanArr = (URLSpanReplacement[]) ((Spannable) charSequence).getSpans(0, charSequence.length(), URLSpanReplacement.class)) != null && uRLSpanArr.length > 0) {
                if (arrayList == null) {
                    arrayList = new ArrayList();
                }
                for (URLSpan uRLSpan : uRLSpanArr) {
                    arrayList.add(uRLSpan.getURL());
                }
            }
            if (arrayList != null && this.foundUrls != null && arrayList.size() == this.foundUrls.size()) {
                boolean z3 = true;
                for (int i = 0; i < arrayList.size(); i++) {
                    if (!TextUtils.equals((CharSequence) arrayList.get(i), (CharSequence) this.foundUrls.get(i))) {
                        z3 = false;
                    }
                }
                if (z3 && !z2) {
                    return;
                }
            }
            this.foundUrls = arrayList;
        } catch (Exception e) {
            FileLog.e(e);
            String lowerCase = charSequence.toString().toLowerCase();
            if (charSequence.length() < 13 || !(lowerCase.contains("http://") || lowerCase.contains("https://"))) {
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.this.lambda$searchLinks$127();
                    }
                });
                return;
            }
            charSequence2 = charSequence;
        }
        if (arrayList == null) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$searchLinks$126();
                }
            });
            return;
        }
        charSequence2 = TextUtils.join(" ", arrayList);
        if (arrayList != null && !arrayList.isEmpty()) {
            ((CharSequence) arrayList.get(0)).toString();
        }
        if (this.currentEncryptedChat != null && messagesController.secretWebpagePreview == 2) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$searchLinks$129(messagesController, charSequence, z);
                }
            });
            return;
        }
        final TL_account.getWebPagePreview getwebpagepreview = new TL_account.getWebPagePreview();
        if (charSequence2 instanceof String) {
            getwebpagepreview.message = (String) charSequence2;
        } else {
            getwebpagepreview.message = charSequence2.toString();
        }
        TLRPC.WebPage webPage = this.foundWebPage;
        if (webPage == null || !getwebpagepreview.message.equals(webPage.displayedText)) {
            final int i2 = this.waitingForWebpageId + 1;
            this.waitingForWebpageId = i2;
            requestLinkPreviewCached(getwebpagepreview, new Utilities.Callback2() {
                public final void run(Object obj, Object obj2) {
                    ChatActivity.this.lambda$searchLinks$131(i2, getwebpagepreview, (Boolean) obj, (TLRPC.WebPage) obj2);
                }
            });
        }
    }

    public void lambda$sendMedia$361() {
        this.closeInstantCameraAnimation = null;
        runCloseInstantCameraAnimation();
    }

    public void lambda$sendMedia$362(MediaController.PhotoEntry photoEntry, VideoEditedInfo videoEditedInfo, boolean z, int i, boolean z2, Long l) {
        AccountInstance accountInstance;
        String str;
        String str2;
        long j;
        MessageObject messageObject;
        MessageObject threadMessage;
        ReplyQuote replyQuote;
        ArrayList arrayList;
        ArrayList arrayList2;
        int i2;
        MessageObject messageObject2;
        CharSequence charSequence;
        String str3;
        int quickReplyId;
        long j2;
        long longValue;
        long sendMonoForumPeerId;
        MessageSuggestionParams sendMessageSuggestionParams;
        InputContentInfoCompat inputContentInfoCompat;
        int i3;
        Uri uri;
        TL_stories.StoryItem storyItem;
        AccountInstance accountInstance2;
        String str4;
        String str5;
        TLRPC.Photo photo;
        long j3;
        MessageObject messageObject3;
        MessageObject threadMessage2;
        ReplyQuote replyQuote2;
        ArrayList arrayList3;
        int i4;
        MessageObject messageObject4;
        boolean z3;
        CharSequence charSequence2;
        String str6;
        int quickReplyId2;
        long j4;
        long longValue2;
        long sendMonoForumPeerId2;
        MessageSuggestionParams sendMessageSuggestionParams2;
        TL_stories.StoryItem storyItem2;
        VideoEditedInfo videoEditedInfo2;
        boolean z4;
        int i5;
        boolean z5;
        MessageObject messageObject5 = this.editingMessageObject;
        if (messageObject5 != null && messageObject5.needResendWhenEdit()) {
            MessageSuggestionParams messageSuggestionParams = this.messageSuggestionParams;
            if (messageSuggestionParams == null) {
                messageSuggestionParams = MessageSuggestionParams.of(this.editingMessageObject.messageOwner.suggested_post);
            }
            sendMessageSuggestionParams = messageSuggestionParams;
            if (photoEntry.isVideo) {
                accountInstance2 = getAccountInstance();
                str4 = photoEntry.path;
                str5 = ((MediaController.MediaEditState) photoEntry).coverPath;
                photo = ((MediaController.MediaEditState) photoEntry).coverPhoto;
                j3 = this.dialog_id;
                messageObject3 = this.editingMessageObject;
                threadMessage2 = getThreadMessage();
                replyQuote2 = this.replyingQuote;
                arrayList3 = ((MediaController.MediaEditState) photoEntry).entities;
                i4 = ((MediaController.MediaEditState) photoEntry).ttl;
                z3 = photoEntry.hasSpoiler;
                charSequence2 = ((MediaController.MediaEditState) photoEntry).caption;
                str6 = this.quickReplyShortcut;
                quickReplyId2 = getQuickReplyId();
                j4 = ((MediaController.MediaEditState) photoEntry).effectId;
                longValue2 = l.longValue();
                sendMonoForumPeerId2 = getSendMonoForumPeerId();
                storyItem2 = null;
                messageObject4 = null;
                videoEditedInfo2 = videoEditedInfo;
                z4 = z;
                i5 = i;
                z5 = z2;
                sendMessageSuggestionParams2 = sendMessageSuggestionParams;
                SendMessagesHelper.prepareSendingVideo(accountInstance2, str4, videoEditedInfo2, str5, photo, j3, messageObject3, threadMessage2, storyItem2, replyQuote2, arrayList3, i4, messageObject4, z4, i5, z5, z3, charSequence2, str6, quickReplyId2, j4, longValue2, sendMonoForumPeerId2, sendMessageSuggestionParams2);
            } else {
                if (((MediaController.MediaEditState) photoEntry).imagePath != null) {
                    accountInstance = getAccountInstance();
                    str = ((MediaController.MediaEditState) photoEntry).imagePath;
                } else if (photoEntry.path != null) {
                    accountInstance = getAccountInstance();
                    str = photoEntry.path;
                }
                str2 = ((MediaController.MediaEditState) photoEntry).thumbPath;
                j = this.dialog_id;
                messageObject = this.editingMessageObject;
                threadMessage = getThreadMessage();
                replyQuote = this.replyingQuote;
                arrayList = ((MediaController.MediaEditState) photoEntry).entities;
                arrayList2 = ((MediaController.MediaEditState) photoEntry).stickers;
                i2 = ((MediaController.MediaEditState) photoEntry).ttl;
                charSequence = ((MediaController.MediaEditState) photoEntry).caption;
                str3 = this.quickReplyShortcut;
                quickReplyId = getQuickReplyId();
                j2 = ((MediaController.MediaEditState) photoEntry).effectId;
                longValue = l.longValue();
                sendMonoForumPeerId = getSendMonoForumPeerId();
                messageObject2 = null;
                i3 = 0;
                uri = null;
                storyItem = null;
                inputContentInfoCompat = null;
                SendMessagesHelper.prepareSendingPhoto(accountInstance, str, str2, uri, j, messageObject, threadMessage, storyItem, replyQuote, arrayList, arrayList2, inputContentInfoCompat, i2, messageObject2, videoEditedInfo, z, i, i3, z2, charSequence, str3, quickReplyId, j2, longValue, sendMonoForumPeerId, sendMessageSuggestionParams);
            }
        } else if (photoEntry.isVideo) {
            accountInstance2 = getAccountInstance();
            str4 = photoEntry.path;
            str5 = ((MediaController.MediaEditState) photoEntry).coverPath;
            photo = ((MediaController.MediaEditState) photoEntry).coverPhoto;
            j3 = this.dialog_id;
            messageObject3 = this.replyingMessageObject;
            threadMessage2 = getThreadMessage();
            replyQuote2 = this.replyingQuote;
            arrayList3 = ((MediaController.MediaEditState) photoEntry).entities;
            i4 = ((MediaController.MediaEditState) photoEntry).ttl;
            messageObject4 = this.editingMessageObject;
            z3 = photoEntry.hasSpoiler;
            charSequence2 = ((MediaController.MediaEditState) photoEntry).caption;
            str6 = this.quickReplyShortcut;
            quickReplyId2 = getQuickReplyId();
            j4 = ((MediaController.MediaEditState) photoEntry).effectId;
            longValue2 = l.longValue();
            sendMonoForumPeerId2 = getSendMonoForumPeerId();
            sendMessageSuggestionParams2 = getSendMessageSuggestionParams();
            storyItem2 = null;
            videoEditedInfo2 = videoEditedInfo;
            z4 = z;
            i5 = i;
            z5 = z2;
            SendMessagesHelper.prepareSendingVideo(accountInstance2, str4, videoEditedInfo2, str5, photo, j3, messageObject3, threadMessage2, storyItem2, replyQuote2, arrayList3, i4, messageObject4, z4, i5, z5, z3, charSequence2, str6, quickReplyId2, j4, longValue2, sendMonoForumPeerId2, sendMessageSuggestionParams2);
        } else {
            if (((MediaController.MediaEditState) photoEntry).imagePath != null) {
                accountInstance = getAccountInstance();
                str = ((MediaController.MediaEditState) photoEntry).imagePath;
            } else if (photoEntry.path != null) {
                accountInstance = getAccountInstance();
                str = photoEntry.path;
            }
            str2 = ((MediaController.MediaEditState) photoEntry).thumbPath;
            j = this.dialog_id;
            messageObject = this.replyingMessageObject;
            threadMessage = getThreadMessage();
            replyQuote = this.replyingQuote;
            arrayList = ((MediaController.MediaEditState) photoEntry).entities;
            arrayList2 = ((MediaController.MediaEditState) photoEntry).stickers;
            i2 = ((MediaController.MediaEditState) photoEntry).ttl;
            messageObject2 = this.editingMessageObject;
            charSequence = ((MediaController.MediaEditState) photoEntry).caption;
            str3 = this.quickReplyShortcut;
            quickReplyId = getQuickReplyId();
            j2 = ((MediaController.MediaEditState) photoEntry).effectId;
            longValue = l.longValue();
            sendMonoForumPeerId = getSendMonoForumPeerId();
            sendMessageSuggestionParams = getSendMessageSuggestionParams();
            inputContentInfoCompat = null;
            i3 = 0;
            uri = null;
            storyItem = null;
            SendMessagesHelper.prepareSendingPhoto(accountInstance, str, str2, uri, j, messageObject, threadMessage, storyItem, replyQuote, arrayList, arrayList2, inputContentInfoCompat, i2, messageObject2, videoEditedInfo, z, i, i3, z2, charSequence, str3, quickReplyId, j2, longValue, sendMonoForumPeerId, sendMessageSuggestionParams);
        }
        afterMessageSend();
    }

    public void lambda$sendSecretMediaDelete$144(long j, MessageObject messageObject) {
        getMessagesController().doDeleteShowOnceTask(j, this.dialog_id, messageObject.getId());
    }

    public void lambda$sendSecretMessageRead$143(MessageObject messageObject) {
        TLRPC.Message message = messageObject.messageOwner;
        int i = message.ttl;
        boolean z = i != Integer.MAX_VALUE;
        if (i == Integer.MAX_VALUE) {
            i = 0;
        }
        message.destroyTime = getConnectionsManager().getCurrentTime() + i;
        messageObject.messageOwner.destroyTimeMillis = (i * 1000) + getConnectionsManager().getCurrentTimeMillis();
        if (this.currentEncryptedChat != null) {
            getMessagesController().markMessageAsRead(this.dialog_id, messageObject.messageOwner.random_id, i);
        } else {
            getMessagesController().markMessageAsRead2(this.dialog_id, messageObject.getId(), (TLRPC.InputChannel) null, i, 0L, z);
        }
    }

    public void lambda$setChatThemeEmoticon$388(EmojiThemes emojiThemes) {
        ThemeDelegate themeDelegate = this.themeDelegate;
        themeDelegate.setCurrentTheme(emojiThemes, themeDelegate.wallpaper, this.openAnimationStartTime != 0, null);
    }

    public void lambda$setPagedownLoading$114(boolean[] zArr, boolean z, ValueAnimator valueAnimator) {
        float floatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        this.pagedownLoadingT = floatValue;
        if (!zArr[0] && z && floatValue > 0.5f) {
            zArr[0] = true;
            this.pagedownButtonLoadingDrawable.reset();
            this.pagedownButtonLoading.setVisibility(0);
        }
        this.pagedownButtonLoading.setAlpha(Math.max(0.0f, (this.pagedownLoadingT - 0.5f) * 2.0f));
        this.pagedownButtonArrow.setScaleX(1.0f - this.pagedownLoadingT);
        this.pagedownButtonArrow.setScaleY(1.0f - this.pagedownLoadingT);
    }

    public void lambda$shareMyContact$120(TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error != null) {
            return;
        }
        getMessagesController().processUpdates((TLRPC.Updates) tLObject, false);
    }

    public void lambda$shareMyContact$121(int i, MessageObject messageObject, AlertDialog alertDialog, int i2) {
        if (i == 1) {
            TLRPC.TL_contacts_acceptContact tL_contacts_acceptContact = new TLRPC.TL_contacts_acceptContact();
            tL_contacts_acceptContact.id = getMessagesController().getInputUser(this.currentUser);
            getConnectionsManager().sendRequest(tL_contacts_acceptContact, new RequestDelegate() {
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    ChatActivity.this.lambda$shareMyContact$120(tLObject, tL_error);
                }
            });
            return;
        }
        SendMessagesHelper.SendMessageParams of = SendMessagesHelper.SendMessageParams.of(getUserConfig().getCurrentUser(), this.dialog_id, messageObject, getThreadMessage(), (TLRPC.ReplyMarkup) null, (HashMap) null, true, 0);
        of.quick_reply_shortcut_id = getQuickReplyId();
        of.quick_reply_shortcut = this.quickReplyShortcut;
        SendMessagesHelper.getInstance(((BaseFragment) this).currentAccount).sendMessage(of);
        if (this.chatMode == 0) {
            moveScrollToLastMessage(false);
        }
        hideFieldPanel(false);
    }

    public void lambda$showAlert$224(ValueAnimator valueAnimator) {
        this.alertViewEnterProgress = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        invalidateChatListViewTopPadding();
    }

    public void lambda$showBotMessageHint$75(HintView2 hintView2) {
        this.contentView.removeView(hintView2);
    }

    public void lambda$showBotMessageHint$76(ChatMessageCell chatMessageCell) {
        chatMessageCell.getLocationInWindow(new int[2]);
        this.botMessageHint.setTranslationY(((r0[1] - r1.getTop()) - AndroidUtilities.dp(120.0f)) + chatMessageCell.getTimeY());
        this.botMessageHint.setJointPx(0.0f, ((((-AndroidUtilities.dp(16.0f)) + r0[0]) + chatMessageCell.timeX) + chatMessageCell.timeWidth) - (chatMessageCell.signWidth / 2.0f));
        this.botMessageHint.show();
    }

    public static boolean lambda$showChatThemeBottomSheet$385(MotionEvent motionEvent) {
        return true;
    }

    public void lambda$showChatThemeBottomSheet$386(DialogInterface dialogInterface) {
        this.chatThemeBottomSheet = null;
        this.chatListView.setOnInterceptTouchListener((RecyclerListView.OnInterceptTouchListener) null);
        setChildrenEnabled(this.contentView, true);
        ChatThemeController.getInstance(((BaseFragment) this).currentAccount).clearWallpaperThumbImages();
    }

    public void lambda$showFieldPanel$141() {
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView == null || this.fieldPanelShown == 5) {
            return;
        }
        chatActivityEnterView.openKeyboard();
    }

    public void lambda$showFieldPanel$142() {
        ViewPropertyAnimator scaleY;
        this.showTapForForwardingOptionsHit = !this.showTapForForwardingOptionsHit;
        this.replyObjectTextView.setPivotX(0.0f);
        this.replyObjectHintTextView.setPivotX(0.0f);
        if (this.showTapForForwardingOptionsHit) {
            this.replyObjectTextView.animate().alpha(0.0f).scaleX(0.98f).scaleY(0.98f).setDuration(150L).start();
            scaleY = this.replyObjectHintTextView.animate().alpha(1.0f).scaleX(1.0f).scaleY(1.0f);
        } else {
            this.replyObjectTextView.animate().alpha(1.0f).scaleX(1.0f).scaleY(1.0f).setDuration(150L).start();
            scaleY = this.replyObjectHintTextView.animate().alpha(0.0f).scaleX(0.98f).scaleY(0.98f);
        }
        scaleY.setDuration(150L).start();
        AndroidUtilities.runOnUIThread(this.tapForForwardingOptionsHitRunnable, 6000L);
    }

    public void lambda$showFloatingTopicView$122(ValueAnimator valueAnimator) {
        this.floatingTopicViewAlpha = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        updateFloatingTopicView();
    }

    public void lambda$showGiftButton$220(View view) {
        MessagesController.getGlobalMainSettings().edit().putInt("channelgifthint", 3).apply();
        showDialog(new GiftSheet(getContext(), ((BaseFragment) this).currentAccount, getDialogId(), (List) null, (Runnable) null));
    }

    public void lambda$showGiftButton$221() {
        AndroidUtilities.removeFromParent(this.bottomGiftHintView);
    }

    public void lambda$showGigagroupConvertAlert$196(AlertDialog alertDialog, int i) {
        showDialog(new AnonymousClass108(getParentActivity(), this));
    }

    public void lambda$showGigagroupConvertAlert$197(AlertDialog alertDialog, int i) {
        createUndoView();
        UndoView undoView = this.undoView;
        if (undoView == null) {
            return;
        }
        undoView.showWithAction(0L, 75, (Runnable) null);
    }

    public void lambda$showGigagroupConvertAlert$198() {
        TLRPC.ChatFull chatFull = this.chatInfo;
        if (chatFull == null || this.paused) {
            return;
        }
        TLRPC.Chat chat = this.currentChat;
        if (chat.creator && chat.megagroup && !chat.gigagroup && chatFull.pending_suggestions.contains("CONVERT_GIGAGROUP") && ((BaseFragment) this).visibleDialog == null) {
            SharedPreferences notificationsSettings = MessagesController.getNotificationsSettings(((BaseFragment) this).currentAccount);
            int i = notificationsSettings.getInt("group_convert_time", 0);
            int i2 = BuildVars.DEBUG_PRIVATE_VERSION ? 120 : 604800;
            int currentTime = getConnectionsManager().getCurrentTime();
            if (Math.abs(currentTime - i) < i2 || ((BaseFragment) this).visibleDialog != null || getParentActivity() == null) {
                return;
            }
            notificationsSettings.edit().putInt("group_convert_time", currentTime).commit();
            showDialog(AlertsCreator.createGigagroupConvertAlert(getParentActivity(), new AlertDialog.OnButtonClickListener() {
                @Override
                public final void onClick(AlertDialog alertDialog, int i3) {
                    ChatActivity.this.lambda$showGigagroupConvertAlert$196(alertDialog, i3);
                }
            }, new AlertDialog.OnButtonClickListener() {
                @Override
                public final void onClick(AlertDialog alertDialog, int i3) {
                    ChatActivity.this.lambda$showGigagroupConvertAlert$197(alertDialog, i3);
                }
            }).create());
        }
    }

    public void lambda$showGreetInfo$307(View view) {
        showDialog(new PremiumFeatureBottomSheet(this, 28, true));
    }

    public void lambda$showInfoHint$202(int i) {
        ChatMessageCell chatMessageCell;
        MessageObject messageObject;
        RecyclerListView recyclerListView = this.chatListView;
        if (recyclerListView != null) {
            int childCount = recyclerListView.getChildCount();
            for (int i2 = 0; i2 < childCount; i2++) {
                View childAt = this.chatListView.getChildAt(i2);
                if ((childAt instanceof ChatMessageCell) && (messageObject = (chatMessageCell = (ChatMessageCell) childAt).getMessageObject()) != null && messageObject.equals(this.hintMessageObject)) {
                    chatMessageCell.showHintButton(true, true, i);
                }
            }
        }
        this.hintMessageObject = null;
    }

    public void lambda$showMentionDownButton$160(ValueAnimator valueAnimator) {
        this.mentionsButtonEnterProgress = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        this.contentView.invalidate();
    }

    public void lambda$showMentionDownButton$161(ValueAnimator valueAnimator) {
        this.mentionsButtonEnterProgress = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        this.contentView.invalidate();
    }

    public void lambda$showOpenGameAlert$363(TLRPC.TL_game tL_game, MessageObject messageObject, String str, long j, AlertDialog alertDialog, int i) {
        showOpenGameAlert(tL_game, messageObject, str, false, j);
        MessagesController.getNotificationsSettings(((BaseFragment) this).currentAccount).edit().putBoolean("askgame_" + j, false).commit();
    }

    public void lambda$showPinnedProgress$155() {
        this.pinnedProgressIsShowing = true;
        updatePinnedListButton(true);
    }

    public void lambda$showPremiumFloodWaitBulletin$396(boolean z) {
        presentFragment(new PremiumPreviewFragment(z ? "upload_speed" : "download_speed"));
    }

    public void lambda$showQuickRepliesRemoveAlert$355(AlertDialog alertDialog, int i) {
        lambda$onBackPressed$354();
    }

    public void lambda$showQuoteMessageUpdate$191(AlertDialog alertDialog, int i) {
        MessagePreviewParams messagePreviewParams = this.messagePreviewParams;
        if (messagePreviewParams == null || messagePreviewParams.quote == null) {
            return;
        }
        openForwardingPreview(0);
    }

    public void lambda$showQuoteMessageUpdate$192(AlertDialog alertDialog, int i) {
        hideFieldPanel(true);
    }

    public void lambda$showQuoteMessageUpdate$193(DialogInterface dialogInterface) {
        this.quoteMessageUpdateAlert = null;
    }

    public static void lambda$showRequestUrlAlert$374(CheckBoxCell[] checkBoxCellArr, View view) {
        if (view.isEnabled()) {
            Integer num = (Integer) view.getTag();
            checkBoxCellArr[num.intValue()].setChecked(!checkBoxCellArr[num.intValue()].isChecked(), true);
            if (num.intValue() != 0 || checkBoxCellArr[1] == null) {
                return;
            }
            if (checkBoxCellArr[num.intValue()].isChecked()) {
                checkBoxCellArr[1].setEnabled(true);
            } else {
                checkBoxCellArr[1].setChecked(false, true);
                checkBoxCellArr[1].setEnabled(false);
            }
        }
    }

    public void lambda$showRequestUrlAlert$375(TLObject tLObject, String str, TLRPC.TL_messages_requestUrlAuth tL_messages_requestUrlAuth, boolean z) {
        if (tLObject instanceof TLRPC.TL_urlAuthResultAccepted) {
            Browser.openUrl(getParentActivity(), ((TLRPC.TL_urlAuthResultAccepted) tLObject).url, false);
            return;
        }
        if (tLObject instanceof TLRPC.TL_urlAuthResultDefault) {
            Browser.openUrl(getParentActivity(), str, false);
            return;
        }
        String str2 = tL_messages_requestUrlAuth.url;
        if (str2 != null) {
            AlertsCreator.showOpenUrlAlert(this, str2, false, z, this.themeDelegate);
        }
    }

    public void lambda$showRequestUrlAlert$376(final String str, final TLRPC.TL_messages_requestUrlAuth tL_messages_requestUrlAuth, final boolean z, final TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$showRequestUrlAlert$375(tLObject, str, tL_messages_requestUrlAuth, z);
            }
        });
    }

    public void lambda$showRequestUrlAlert$377(int i, DialogInterface dialogInterface) {
        getConnectionsManager().cancelRequest(i, true);
    }

    public void lambda$showRequestUrlAlert$378(AlertDialog[] alertDialogArr, final int i) {
        AlertDialog alertDialog = alertDialogArr[0];
        if (alertDialog == null) {
            return;
        }
        alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
            @Override
            public final void onCancel(DialogInterface dialogInterface) {
                ChatActivity.this.lambda$showRequestUrlAlert$377(i, dialogInterface);
            }
        });
        showDialog(alertDialogArr[0]);
    }

    public void lambda$showRequestUrlAlert$379(CheckBoxCell[] checkBoxCellArr, final String str, final TLRPC.TL_messages_requestUrlAuth tL_messages_requestUrlAuth, TLRPC.TL_urlAuthResultRequest tL_urlAuthResultRequest, final boolean z, AlertDialog alertDialog, int i) {
        int i2;
        if (!checkBoxCellArr[0].isChecked()) {
            Browser.openUrl(getParentActivity(), str, false);
            return;
        }
        final AlertDialog[] alertDialogArr = {new AlertDialog(getParentActivity(), 3, this.themeDelegate)};
        TLRPC.TL_messages_acceptUrlAuth tL_messages_acceptUrlAuth = new TLRPC.TL_messages_acceptUrlAuth();
        String str2 = tL_messages_requestUrlAuth.url;
        if (str2 != null) {
            tL_messages_acceptUrlAuth.url = str2;
            i2 = tL_messages_acceptUrlAuth.flags | 4;
        } else {
            tL_messages_acceptUrlAuth.button_id = tL_messages_requestUrlAuth.button_id;
            tL_messages_acceptUrlAuth.msg_id = tL_messages_requestUrlAuth.msg_id;
            tL_messages_acceptUrlAuth.peer = tL_messages_requestUrlAuth.peer;
            i2 = tL_messages_acceptUrlAuth.flags | 2;
        }
        tL_messages_acceptUrlAuth.flags = i2;
        if (tL_urlAuthResultRequest.request_write_access) {
            tL_messages_acceptUrlAuth.write_allowed = checkBoxCellArr[1].isChecked();
        }
        try {
            alertDialogArr[0].dismiss();
        } catch (Throwable unused) {
        }
        alertDialogArr[0] = null;
        final int sendRequest = getConnectionsManager().sendRequest(tL_messages_acceptUrlAuth, new RequestDelegate() {
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                ChatActivity.this.lambda$showRequestUrlAlert$376(str, tL_messages_requestUrlAuth, z, tLObject, tL_error);
            }
        });
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$showRequestUrlAlert$378(alertDialogArr, sendRequest);
            }
        }, 500L);
    }

    public void lambda$showSuggestButton$222(View view) {
        MessagesController.getGlobalMainSettings().edit().putInt("channelsuggesthint", 3).apply();
        TLRPC.Chat chat = this.currentChat;
        if (chat == null || chat.linked_monoforum_id == 0) {
            return;
        }
        MessagesController messagesController = getMessagesController();
        TLRPC.Chat chat2 = this.currentChat;
        messagesController.putMonoForumLinkedChat(chat2.id, chat2.linked_monoforum_id);
        Bundle bundle = new Bundle();
        bundle.putLong("chat_id", this.currentChat.linked_monoforum_id);
        bundle.putInt("chatMode", 8);
        bundle.putBoolean("isSubscriberSuggestions", true);
        presentFragment(new ChatActivity(bundle));
    }

    public void lambda$showSuggestButton$223() {
        AndroidUtilities.removeFromParent(this.bottomSuggestHintView);
    }

    public void lambda$showSuggestionOfferForEditMessage$349(MessageSuggestionParams messageSuggestionParams) {
        this.messageSuggestionParams = messageSuggestionParams;
        this.editingMessageObject.messageOwner.suggested_post = messageSuggestionParams.toTl();
        showFieldPanelForEdit(true, this.editingMessageObject);
    }

    public void lambda$startEditingMessageObject$309(TLObject tLObject) {
        this.editingMessageObjectReqId = 0;
        if (tLObject != null || getParentActivity() == null) {
            return;
        }
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity(), this.themeDelegate);
        builder.setTitle(LocaleController.getString(R.string.AppName));
        builder.setMessage(LocaleController.getString(R.string.EditMessageError));
        builder.setPositiveButton(LocaleController.getString(R.string.OK), null);
        showDialog(builder.create());
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView != null) {
            chatActivityEnterView.setEditingMessageObject((MessageObject) null, (MessageObject.GroupedMessages) null, false);
            hideFieldPanel(true);
        }
    }

    public void lambda$startEditingMessageObject$310(final TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$startEditingMessageObject$309(tLObject);
            }
        });
    }

    public void lambda$startMessageUnselect$152() {
        this.highlightMessageId = Integer.MAX_VALUE;
        this.highlightMessageQuoteFirst = false;
        this.highlightMessageQuoteFirstTime = 0L;
        this.highlightMessageQuote = null;
        this.highlightTaskId = null;
        this.highlightMessageQuoteOffset = -1;
        this.showNoQuoteAlert = false;
        updateVisibleRows();
        this.unselectRunnable = null;
    }

    public void lambda$toggleIsAllChats$91(boolean z, View view) {
        if (!(view instanceof ChatMessageCell)) {
            if (view instanceof ChatActionCell) {
                ((ChatActionCell) view).isAllChats = z;
                return;
            }
            return;
        }
        ChatMessageCell chatMessageCell = (ChatMessageCell) view;
        if ((chatMessageCell.isAllChats && chatMessageCell.isSideMenuEnabled) == z || !isSideMenuEnabled()) {
            return;
        }
        chatMessageCell.isAllChats = z;
        chatMessageCell.isSideMenuEnabled = isSideMenuEnabled();
        chatMessageCell.relayout();
    }

    public void lambda$unpinMessage$311(ArrayList arrayList, ArrayList arrayList2, int i) {
        getNotificationCenter().postNotificationName(NotificationCenter.didLoadPinnedMessages, new Object[]{Long.valueOf(this.dialog_id), arrayList, Boolean.TRUE, arrayList2, null, 0, Integer.valueOf(i), Boolean.valueOf(this.pinnedEndReached)});
        this.pinBulletin = null;
    }

    public void lambda$unpinMessage$312(MessageObject messageObject) {
        getMessagesController().pinMessage(this.currentChat, this.currentUser, messageObject.getId(), true, false, false);
        this.pinBulletin = null;
    }

    public void lambda$updateBotHelpCellClick$389(String str, String str2, CharSequence charSequence, Runnable[] runnableArr, View view) {
        TranslateAlert2.showAlert(getContext(), this, ((BaseFragment) this).currentAccount, str, str2, charSequence, (ArrayList) null, false, (Utilities.CallbackReturn) null, (Runnable) null);
        Runnable runnable = runnableArr[0];
        if (runnable != null) {
            runnable.run();
        }
    }

    public void lambda$updateBotHelpCellClick$391(final String str, final String str2, final CharSequence charSequence, BotHelpCell botHelpCell, View view) {
        ActionBarPopupWindow.ActionBarPopupWindowLayout actionBarPopupWindowLayout = new ActionBarPopupWindow.ActionBarPopupWindowLayout(getContext());
        Drawable mutate = ContextCompat.getDrawable(getContext(), R.drawable.popup_fixed_alert).mutate();
        mutate.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_actionBarDefaultSubmenuBackground), PorterDuff.Mode.MULTIPLY));
        actionBarPopupWindowLayout.setBackground(mutate);
        ActionBarMenuSubItem actionBarMenuSubItem = new ActionBarMenuSubItem(getContext(), true, true);
        actionBarMenuSubItem.setTextAndIcon(LocaleController.getString(R.string.TranslateMessage), R.drawable.msg_translate);
        actionBarMenuSubItem.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view2) {
                ChatActivity.this.lambda$updateBotHelpCellClick$389(str, str2, charSequence, r5, view2);
            }
        });
        actionBarPopupWindowLayout.addView(actionBarMenuSubItem);
        final ActionBarPopupWindow actionBarPopupWindow = new ActionBarPopupWindow(actionBarPopupWindowLayout, -2, -2);
        final Runnable[] runnableArr = {new Runnable() {
            @Override
            public final void run() {
                ActionBarPopupWindow.this.dismiss();
            }
        }};
        actionBarPopupWindow.setPauseNotifications(true);
        actionBarPopupWindow.setDismissAnimationDuration(220);
        actionBarPopupWindow.setOutsideTouchable(true);
        actionBarPopupWindow.setClippingEnabled(true);
        actionBarPopupWindow.setAnimationStyle(R.style.PopupContextAnimation);
        actionBarPopupWindow.setFocusable(true);
        actionBarPopupWindow.showAsDropDown(botHelpCell, (botHelpCell.getWidth() / 2) - AndroidUtilities.dp(90.0f), AndroidUtilities.dp(-16.0f), 83);
    }

    public void lambda$updateBotHelpCellClick$392(final BotHelpCell botHelpCell, final CharSequence charSequence, final String str) {
        final String language = LocaleController.getInstance().getCurrentLocale().getLanguage();
        if (str == null || ((str.equals(language) && !str.equals("und")) || RestrictedLanguagesSelectActivity.getRestrictedLanguages().contains(str))) {
            botHelpCell.setClickable(false);
        } else {
            botHelpCell.setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    ChatActivity.this.lambda$updateBotHelpCellClick$391(str, language, charSequence, botHelpCell, view);
                }
            });
        }
    }

    public void lambda$updateBottomOverlay$216() {
        ChatGreetingsView.showPremiumSheet(getContext(), ((BaseFragment) this).currentAccount, this.dialog_id, this.themeDelegate);
    }

    public void lambda$updateBottomOverlay$217(ValueAnimator valueAnimator) {
        float floatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        this.searchExpandProgress = floatValue;
        this.chatListView.setTranslationY(floatValue * (this.chatActivityEnterView.getMeasuredHeight() - AndroidUtilities.dp(51.0f)));
        this.chatActivityEnterView.setChatSearchExpandOffset(this.searchExpandProgress * (r5.getMeasuredHeight() - AndroidUtilities.dp(51.0f)));
        invalidateChatListViewTopPadding();
    }

    public void lambda$updateBottomOverlay$218(ValueAnimator valueAnimator) {
        float floatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        this.searchExpandProgress = floatValue;
        this.chatListView.setTranslationY(floatValue * (this.chatActivityEnterView.getMeasuredHeight() - AndroidUtilities.dp(51.0f)));
        this.chatActivityEnterView.setChatSearchExpandOffset(this.searchExpandProgress * (r5.getMeasuredHeight() - AndroidUtilities.dp(51.0f)));
        invalidateChatListViewTopPadding();
    }

    public void lambda$updateBottomOverlay$219() {
        this.chatActivityEnterView.openKeyboard();
    }

    public static int lambda$updateFilteredMessages$77(MessageObject messageObject, MessageObject messageObject2) {
        return messageObject.getId() - messageObject2.getId();
    }

    public static int lambda$updateFilteredMessages$78(MessageObject messageObject, MessageObject messageObject2) {
        return messageObject2.getId() - messageObject.getId();
    }

    public void lambda$updateGreetingLock$303(long j, View view) {
        if (StarsController.getInstance(((BaseFragment) this).currentAccount).getBalance().amount < j) {
            new StarsIntroActivity.StarsNeededSheet(getContext(), getResourceProvider(), j, 13, DialogObject.getShortName(getDialogId()), new ChatActivity$$ExternalSyntheticLambda291(this)).show();
        } else {
            new StarsIntroActivity.StarsOptionsSheet(getContext(), ((BaseFragment) this).resourceProvider).show();
        }
    }

    public static void lambda$updateGreetingLock$304(View view) {
        BaseFragment lastFragment = LaunchActivity.getLastFragment();
        if (lastFragment != null) {
            lastFragment.presentFragment(new PremiumPreviewFragment("contact"));
        }
    }

    public void lambda$updateGreetingLock$305(long j, View view) {
        if (StarsController.getInstance(((BaseFragment) this).currentAccount).getBalance().amount < j) {
            new StarsIntroActivity.StarsNeededSheet(getContext(), getResourceProvider(), j, 13, DialogObject.getShortName(getDialogId()), new ChatActivity$$ExternalSyntheticLambda291(this)).show();
        } else {
            new StarsIntroActivity.StarsOptionsSheet(getContext(), ((BaseFragment) this).resourceProvider).show();
        }
    }

    public void lambda$updateInfoTopView$104(View view) {
        Bundle bundle = new Bundle();
        bundle.putLong("user_id", this.chatInviterId);
        presentFragment(new ProfileActivity(bundle));
    }

    public void lambda$updateInfoTopView$105(View view, ValueAnimator valueAnimator) {
        float floatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        this.topViewOffset = AndroidUtilities.dp(30.0f) * floatValue;
        invalidateChatListViewTopPadding();
        view.setAlpha(floatValue);
    }

    public void lambda$updateMessagesVisiblePart$148(MessageObject messageObject) {
        if (messageObject.isVideo()) {
            openPhotoViewerForMessage(null, messageObject);
        } else {
            MediaController.getInstance().playMessage(messageObject);
        }
    }

    public void lambda$updateMessagesVisiblePart$149() {
        updatePinnedMessageView(this.openAnimationStartTime != 0 && SystemClock.elapsedRealtime() >= this.openAnimationStartTime + 150);
    }

    public void lambda$updateMessagesVisiblePart$151(boolean z) {
        lambda$updateMessagesVisiblePart$150(z, 0);
    }

    public void lambda$updatePagedownButtonVisibility$156(ValueAnimator valueAnimator) {
        this.pagedownButtonEnterProgress = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        this.contentView.invalidate();
    }

    public void lambda$updatePagedownButtonVisibility$157(ValueAnimator valueAnimator) {
        this.pagedownButtonEnterProgress = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        this.contentView.invalidate();
    }

    public void lambda$updatePinnedMessageView$226(TLRPC.KeyboardButton keyboardButton, MessageObject messageObject, View view) {
        if (getParentActivity() != null) {
            if (this.bottomOverlayChat.getVisibility() != 0 || (keyboardButton instanceof TLRPC.TL_keyboardButtonSwitchInline) || (keyboardButton instanceof TLRPC.TL_keyboardButtonCallback) || (keyboardButton instanceof TLRPC.TL_keyboardButtonGame) || (keyboardButton instanceof TLRPC.TL_keyboardButtonUrl) || (keyboardButton instanceof TLRPC.TL_keyboardButtonBuy) || (keyboardButton instanceof TLRPC.TL_keyboardButtonUrlAuth) || (keyboardButton instanceof TLRPC.TL_keyboardButtonUserProfile)) {
                this.chatActivityEnterView.didPressedBotButton(keyboardButton, messageObject, messageObject);
            }
        }
    }

    public boolean lambda$updatePinnedMessageView$227(TLRPC.KeyboardButton keyboardButton, MessageObject messageObject, PinnedMessageButton pinnedMessageButton, View view) {
        if (getParentActivity() == null || !((this.bottomOverlayChat.getVisibility() != 0 || (keyboardButton instanceof TLRPC.TL_keyboardButtonSwitchInline) || (keyboardButton instanceof TLRPC.TL_keyboardButtonCallback) || (keyboardButton instanceof TLRPC.TL_keyboardButtonGame) || (keyboardButton instanceof TLRPC.TL_keyboardButtonUrl) || (keyboardButton instanceof TLRPC.TL_keyboardButtonBuy) || (keyboardButton instanceof TLRPC.TL_keyboardButtonUrlAuth) || (keyboardButton instanceof TLRPC.TL_keyboardButtonUserProfile)) && (keyboardButton instanceof TLRPC.TL_keyboardButtonUrl))) {
            return false;
        }
        openClickableLink(null, keyboardButton.url, true, null, messageObject, false);
        try {
            pinnedMessageButton.performHapticFeedback(0, 1);
        } catch (Exception unused) {
        }
        return true;
    }

    public void lambda$updatePinnedMessageView$228(String str, View view) {
        String str2 = Uri.parse(str).getPathSegments().get(r4.getPathSegments().size() - 1);
        TLRPC.TL_inputGroupCallSlug tL_inputGroupCallSlug = new TLRPC.TL_inputGroupCallSlug();
        ((TLRPC.InputGroupCall) tL_inputGroupCallSlug).slug = str2;
        VoIPHelper.joinConference(getParentActivity(), ((BaseFragment) this).currentAccount, tL_inputGroupCallSlug, false, null);
    }

    public void lambda$updateReactionsMentionButton$102(ValueAnimator valueAnimator) {
        this.reactionsMentionButtonEnterProgress = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        this.contentView.invalidate();
    }

    public void lambda$updateReactionsMentionButton$103(ValueAnimator valueAnimator) {
        this.reactionsMentionButtonEnterProgress = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        this.contentView.invalidate();
    }

    public void lambda$updateSearchUpDownButtonVisibility$158(ValueAnimator valueAnimator) {
        this.searchUpDownEnterProgress = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        this.contentView.invalidate();
    }

    public void lambda$updateSearchUpDownButtonVisibility$159(ValueAnimator valueAnimator) {
        this.searchUpDownEnterProgress = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        this.contentView.invalidate();
    }

    public void lambda$updateSecretStatus$162(View view) {
        LimitReachedBottomSheet.openBoostsForRemoveRestrictions(this, this.boostsStatus, this.canApplyBoosts, this.dialog_id, false);
    }

    public void lambda$updateSelectedMessageReactions$164() {
        ReactionsContainerLayout reactionsContainerLayout = this.tagSelector;
        if (reactionsContainerLayout != null) {
            reactionsContainerLayout.requestLayout();
        }
    }

    public void lambda$updateTopPanel$230(ItemOptions itemOptions, View view) {
        if (this.botSponsoredMessage == null) {
            return;
        }
        itemOptions.dismiss();
        logSponsoredClicked(this.botSponsoredMessage, false, true);
        Browser.openUrl(getContext(), Uri.parse(this.botSponsoredMessage.sponsoredUrl), true, false, false, (Browser.Progress) null, (String) null, false, MessagesController.getInstance(((BaseFragment) this).currentAccount).sponsoredLinksInappAllow, false);
    }

    public boolean lambda$updateTopPanel$231(View view) {
        MessageObject messageObject = this.botSponsoredMessage;
        if (messageObject == null) {
            return false;
        }
        if (!AndroidUtilities.addToClipboard(messageObject.sponsoredUrl)) {
            return true;
        }
        BulletinFactory.of(Bulletin.BulletinWindow.make(getContext()), ((BaseFragment) this).resourceProvider).createCopyLinkBulletin().show();
        return true;
    }

    public void lambda$updateTopPanel$232(View view) {
        if (AndroidUtilities.addToClipboard(this.botSponsoredMessage.sponsoredInfo)) {
            BulletinFactory.of(Bulletin.BulletinWindow.make(getContext()), ((BaseFragment) this).resourceProvider).createCopyBulletin(LocaleController.getString(R.string.TextCopied)).show();
        }
    }

    public void lambda$updateTopPanel$233(View view) {
        if (AndroidUtilities.addToClipboard(this.botSponsoredMessage.sponsoredAdditionalInfo)) {
            BulletinFactory.of(Bulletin.BulletinWindow.make(getContext()), ((BaseFragment) this).resourceProvider).createCopyBulletin(LocaleController.getString(R.string.TextCopied)).show();
        }
    }

    public void lambda$updateTopPanel$235(ItemOptions itemOptions, RevenueSharingAdsInfoBottomSheet[] revenueSharingAdsInfoBottomSheetArr) {
        itemOptions.dismiss();
        GroupCallActivity groupCallActivity = revenueSharingAdsInfoBottomSheetArr[0];
        if (groupCallActivity != 0) {
            groupCallActivity.dismiss();
        }
        ReportBottomSheet.openSponsored(this, this.botSponsoredMessage, this.themeDelegate);
    }

    public void lambda$updateTopPanel$236(ItemOptions itemOptions, RevenueSharingAdsInfoBottomSheet[] revenueSharingAdsInfoBottomSheetArr) {
        itemOptions.dismiss();
        GroupCallActivity groupCallActivity = revenueSharingAdsInfoBottomSheetArr[0];
        if (groupCallActivity != 0) {
            groupCallActivity.dismiss();
        }
        if (!getUserConfig().isPremium()) {
            showDialog(new PremiumFeatureBottomSheet(this, 3, true));
            return;
        }
        this.botSponsoredMessage = null;
        updateTopPanel(true);
        BulletinFactory.of(this).createAdReportedBulletin(LocaleController.getString(R.string.AdHidden)).show();
        getMessagesController().disableAds(true);
    }

    public void lambda$updateTopPanel$237(final org.telegram.ui.RevenueSharingAdsInfoBottomSheet[] r17, final org.telegram.ui.Components.ItemOptions r18) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.lambda$updateTopPanel$237(org.telegram.ui.RevenueSharingAdsInfoBottomSheet[], org.telegram.ui.Components.ItemOptions):void");
    }

    public void lambda$updateTopPanel$238() {
        if (this.botSponsoredMessage == null) {
            return;
        }
        final RevenueSharingAdsInfoBottomSheet[] revenueSharingAdsInfoBottomSheetArr = new RevenueSharingAdsInfoBottomSheet[1];
        revenueSharingAdsInfoBottomSheetArr[0] = RevenueSharingAdsInfoBottomSheet.showAlert(getContext(), this, true, ((BaseFragment) this).resourceProvider, new Utilities.Callback() {
            public final void run(Object obj) {
                ChatActivity.this.lambda$updateTopPanel$237(revenueSharingAdsInfoBottomSheetArr, (ItemOptions) obj);
            }
        });
    }

    public void lambda$updateTopPanel$239() {
        if (!getUserConfig().isPremium()) {
            showDialog(new PremiumFeatureBottomSheet(this, 3, true));
            return;
        }
        this.botSponsoredMessage = null;
        updateTopPanel(true);
        BulletinFactory.of(this).createAdReportedBulletin(LocaleController.getString(R.string.AdHidden)).show();
        getMessagesController().disableAds(true);
    }

    public void lambda$updateTopPanel$240(TLRPC.User user, TLRPC.EmojiStatus emojiStatus) {
        long j;
        ?? premiumPreviewBottomSheet = new PremiumPreviewBottomSheet(this, ((BaseFragment) this).currentAccount, user, getResourceProvider());
        if (emojiStatus instanceof TLRPC.TL_emojiStatus) {
            j = ((TLRPC.TL_emojiStatus) emojiStatus).document_id;
        } else {
            if (!(emojiStatus instanceof TLRPC.TL_emojiStatusCollectible)) {
                return;
            }
            TLRPC.TL_emojiStatusCollectible tL_emojiStatusCollectible = (TLRPC.TL_emojiStatusCollectible) emojiStatus;
            long j2 = tL_emojiStatusCollectible.document_id;
            premiumPreviewBottomSheet.emojiStatusCollectible = tL_emojiStatusCollectible;
            j = j2;
        }
        BackupImageView backupImageView = new BackupImageView(getContext());
        final AnimatedEmojiDrawable.SwapAnimatedEmojiDrawable swapAnimatedEmojiDrawable = new AnimatedEmojiDrawable.SwapAnimatedEmojiDrawable(backupImageView, AndroidUtilities.dp(160.0f), 4);
        backupImageView.setImageDrawable(swapAnimatedEmojiDrawable);
        backupImageView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
            @Override
            public void onViewAttachedToWindow(View view) {
                swapAnimatedEmojiDrawable.attach();
            }

            @Override
            public void onViewDetachedFromWindow(View view) {
                swapAnimatedEmojiDrawable.detach();
            }
        });
        swapAnimatedEmojiDrawable.set(j, false);
        premiumPreviewBottomSheet.isEmojiStatus = true;
        premiumPreviewBottomSheet.overrideTitleIcon = backupImageView;
        showDialog((Dialog) premiumPreviewBottomSheet);
    }

    public void lambda$updateTopPanel$241(long j, long j2, Long l, Boolean bool) {
        StarsController.getInstance(((BaseFragment) this).currentAccount).stopPaidMessages(j, j2, l.longValue() > 0 && bool.booleanValue(), true);
    }

    public void lambda$updateTopPanel$242(final long j, final long j2, final Long l) {
        if (getContext() == null) {
            return;
        }
        AlertsCreator.showAlertWithCheckbox(getContext(), LocaleController.getString(R.string.RemoveMessageFeeTitle), AndroidUtilities.replaceTags(LocaleController.formatString(ChatObject.isMonoForum(this.currentChat) ? R.string.RemoveMessageFeeMessageChannel : R.string.RemoveMessageFeeMessage, new Object[]{DialogObject.getShortName(j)})), l.longValue() > 0 ? LocaleController.formatPluralStringComma("RemoveMessageFeeRefund", (int) l.longValue()) : null, LocaleController.getString(R.string.Confirm), new Utilities.Callback() {
            public final void run(Object obj) {
                ChatActivity.this.lambda$updateTopPanel$241(j, j2, l, (Boolean) obj);
            }
        }, ((BaseFragment) this).resourceProvider);
    }

    public void lambda$updateTopPanel$243(final long j, final long j2) {
        StarsController.getInstance(((BaseFragment) this).currentAccount).getPaidRevenue(j, j2, new Utilities.Callback() {
            public final void run(Object obj) {
                ChatActivity.this.lambda$updateTopPanel$242(j, j2, (Long) obj);
            }
        });
    }

    public void lambda$updateTopPanel$244(ValueAnimator valueAnimator) {
        this.topChatPanelViewOffset = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        invalidateChatListViewTopPadding();
        invalidateMessagesVisiblePart();
    }

    public void lambda$updateTopPanel$245(ValueAnimator valueAnimator) {
        this.topChatPanelViewOffset = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        invalidateChatListViewTopPadding();
        invalidateMessagesVisiblePart();
    }

    public void lambda$updateTopPanel$246(ValueAnimator valueAnimator) {
        this.topChatPanelView2Offset = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        invalidateChatListViewTopPadding();
        invalidateMessagesVisiblePart();
    }

    public void lambda$updateTopPanel$247(ValueAnimator valueAnimator) {
        this.topChatPanelView2Offset = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        invalidateChatListViewTopPadding();
        invalidateMessagesVisiblePart();
    }

    private void loadSendAsPeers(boolean z) {
        TLRPC.Chat chat;
        if (this.sendAsPeersObj != null || (chat = this.currentChat) == null || !ChatObject.canSendAsPeers(chat) || this.chatActivityEnterView == null || ChatObject.isMonoForum(this.currentChat)) {
            return;
        }
        TLRPC.TL_channels_sendAsPeers sendAsPeers = getMessagesController().getSendAsPeers(this.dialog_id);
        this.sendAsPeersObj = sendAsPeers;
        if (sendAsPeers != null) {
            this.chatActivityEnterView.updateSendAsButton(z);
        }
    }

    public Browser.Progress makeProgressForBotButton(ChatMessageCell chatMessageCell, String str) {
        Browser.Progress progress = this.progressDialogCurrent;
        if (progress != null) {
            progress.cancel(true);
            this.progressDialogCurrent = null;
        }
        if (str == null || chatMessageCell == null || chatMessageCell.getMessageObject() == null) {
            this.progressDialogCurrent = null;
            return null;
        }
        AnonymousClass156 anonymousClass156 = new AnonymousClass156(chatMessageCell.getMessageObject().getId(), str, chatMessageCell);
        this.progressDialogCurrent = anonymousClass156;
        return anonymousClass156;
    }

    public Browser.Progress makeProgressForForward(ChatMessageCell chatMessageCell) {
        Browser.Progress progress = this.progressDialogCurrent;
        if (progress != null) {
            progress.cancel(true);
            this.progressDialogCurrent = null;
        }
        if (chatMessageCell == null || chatMessageCell.getMessageObject() == null) {
            this.progressDialogCurrent = null;
            return null;
        }
        AnonymousClass155 anonymousClass155 = new AnonymousClass155(chatMessageCell.getMessageObject().getId(), chatMessageCell);
        this.progressDialogCurrent = anonymousClass155;
        return anonymousClass155;
    }

    private Browser.Progress makeProgressForLink(ChatMessageCell chatMessageCell, CharacterStyle characterStyle) {
        Browser.Progress progress = this.progressDialogCurrent;
        if (progress != null) {
            progress.cancel(true);
            this.progressDialogCurrent = null;
        }
        if (characterStyle == null || chatMessageCell == null || chatMessageCell.getMessageObject() == null) {
            this.progressDialogCurrent = null;
            return null;
        }
        AnonymousClass154 anonymousClass154 = new AnonymousClass154(chatMessageCell.getMessageObject().getId(), characterStyle, chatMessageCell);
        this.progressDialogCurrent = anonymousClass154;
        return anonymousClass154;
    }

    public Browser.Progress makeProgressForPaidMedia(ChatMessageCell chatMessageCell) {
        Browser.Progress progress = this.progressDialogCurrent;
        if (progress != null) {
            progress.cancel(true);
            this.progressDialogCurrent = null;
        }
        if (chatMessageCell == null || chatMessageCell.getMessageObject() == null) {
            this.progressDialogCurrent = null;
            return null;
        }
        AnonymousClass157 anonymousClass157 = new AnonymousClass157(chatMessageCell.getMessageObject().getId(), chatMessageCell);
        this.progressDialogCurrent = anonymousClass157;
        return anonymousClass157;
    }

    private void markSponsoredAsRead(MessageObject messageObject) {
        if (messageObject == null || !messageObject.isSponsored() || messageObject.viewsReloaded) {
            return;
        }
        messageObject.viewsReloaded = true;
        TLRPC.TL_messages_viewSponsoredMessage tL_messages_viewSponsoredMessage = new TLRPC.TL_messages_viewSponsoredMessage();
        tL_messages_viewSponsoredMessage.random_id = messageObject.sponsoredId;
        getConnectionsManager().sendRequest(tL_messages_viewSponsoredMessage, (RequestDelegate) null);
        getMessagesController().markSponsoredAsRead(this.dialog_id, messageObject);
    }

    private void migrateToNewChat(final MessageObject messageObject) {
        BaseFragment chatUsersActivity;
        INavigationLayout iNavigationLayout = ((BaseFragment) this).parentLayout;
        if (iNavigationLayout == null) {
            return;
        }
        final long j = messageObject.messageOwner.action.channel_id;
        final BaseFragment baseFragment = iNavigationLayout.getFragmentStack().size() > 0 ? (BaseFragment) ((BaseFragment) this).parentLayout.getFragmentStack().get(((BaseFragment) this).parentLayout.getFragmentStack().size() - 1) : null;
        int indexOf = ((BaseFragment) this).parentLayout.getFragmentStack().indexOf(this);
        final INavigationLayout iNavigationLayout2 = ((BaseFragment) this).parentLayout;
        if (indexOf <= 0 || (baseFragment instanceof ChatActivity) || (baseFragment instanceof ProfileActivity) || !this.currentChat.creator) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$migrateToNewChat$200(baseFragment, messageObject, iNavigationLayout2);
                }
            });
        } else {
            int size = iNavigationLayout2.getFragmentStack().size() - 1;
            while (indexOf < size) {
                BaseFragment baseFragment2 = (BaseFragment) iNavigationLayout2.getFragmentStack().get(indexOf);
                if (baseFragment2 instanceof ChatActivity) {
                    Bundle bundle = new Bundle();
                    bundle.putLong("chat_id", j);
                    chatUsersActivity = new ChatActivity(bundle);
                } else if (baseFragment2 instanceof ProfileActivity) {
                    Bundle bundle2 = new Bundle();
                    bundle2.putLong("chat_id", j);
                    chatUsersActivity = new ProfileActivity(bundle2);
                } else if (baseFragment2 instanceof ChatEditActivity) {
                    Bundle bundle3 = new Bundle();
                    bundle3.putLong("chat_id", j);
                    chatUsersActivity = new ChatEditActivity(bundle3);
                } else if (baseFragment2 instanceof ChatUsersActivity) {
                    if (!((ChatUsersActivity) baseFragment2).hasSelectType()) {
                        Bundle arguments = baseFragment2.getArguments();
                        arguments.putLong("chat_id", j);
                        chatUsersActivity = new ChatUsersActivity(arguments);
                    }
                    baseFragment2.removeSelfFromStack();
                    indexOf++;
                } else {
                    indexOf++;
                }
                iNavigationLayout2.addFragmentToStack(chatUsersActivity, indexOf);
                baseFragment2.removeSelfFromStack();
                indexOf++;
            }
        }
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$migrateToNewChat$201(j);
            }
        }, 1000L);
    }

    private void moveScrollToLastMessage(boolean z) {
        if (this.chatListView == null || this.messages.isEmpty() || this.pinchToZoomHelper.isInOverlayMode()) {
            return;
        }
        this.chatLayoutManager.scrollToPositionWithOffset(z ? getSponsoredMessagesCount() : 0, 0);
        this.chatListView.stopScroll();
    }

    public static ChatActivity of(long j) {
        String str;
        Bundle bundle = new Bundle();
        if (j >= 0) {
            str = "user_id";
        } else {
            j = -j;
            str = "chat_id";
        }
        bundle.putLong(str, j);
        return new ChatActivity(bundle);
    }

    public static ChatActivity of(long j, int i) {
        String str;
        Bundle bundle = new Bundle();
        if (j >= 0) {
            str = "user_id";
        } else {
            j = -j;
            str = "chat_id";
        }
        bundle.putLong(str, j);
        bundle.putInt("message_id", i);
        return new ChatActivity(bundle);
    }

    private void openAnotherForward() {
        MessagePreviewParams.Messages messages;
        ArrayList arrayList;
        String formatString;
        MessagePreviewParams messagePreviewParams = this.messagePreviewParams;
        if (messagePreviewParams == null || messagePreviewParams.isEmpty() || (messages = this.messagePreviewParams.forwardMessages) == null || (arrayList = messages.messages) == null) {
            return;
        }
        int size = arrayList.size();
        long j = 0;
        long j2 = 0;
        for (int i = 0; i < size; i++) {
            MessageObject messageObject = (MessageObject) this.messagePreviewParams.forwardMessages.messages.get(i);
            if (j != 0) {
                if (j != messageObject.getFromChatId()) {
                    break;
                }
            } else {
                j2 = messageObject.getDialogId();
                j = messageObject.getFromChatId();
            }
        }
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity(), this.themeDelegate);
        builder.setButtonsVertical(true);
        MessagesController messagesController = getMessagesController();
        if (j2 > 0) {
            TLRPC.User user = messagesController.getUser(Long.valueOf(j2));
            if (user == null) {
                return;
            } else {
                formatString = LocaleController.formatString("CancelForwardPrivate", R.string.CancelForwardPrivate, new Object[]{LocaleController.formatPluralString("MessagesBold", this.messagePreviewParams.forwardMessages.messages.size(), new Object[0]), ContactsController.formatName(user.first_name, user.last_name)});
            }
        } else {
            TLRPC.Chat chat = messagesController.getChat(Long.valueOf(-j2));
            if (chat == null) {
                return;
            } else {
                formatString = LocaleController.formatString("CancelForwardChat", R.string.CancelForwardChat, new Object[]{LocaleController.formatPluralString("MessagesBold", this.messagePreviewParams.forwardMessages.messages.size(), new Object[0]), chat.title});
            }
        }
        builder.setMessage(AndroidUtilities.replaceTags(formatString));
        builder.setTitle(LocaleController.formatPluralString("messages", this.messagePreviewParams.forwardMessages.messages.size(), new Object[0]));
        builder.setPositiveButton(LocaleController.getString(R.string.CancelForwarding), new AlertDialog.OnButtonClickListener() {
            @Override
            public final void onClick(AlertDialog alertDialog, int i2) {
                ChatActivity.this.lambda$openAnotherForward$110(alertDialog, i2);
            }
        });
        builder.setNegativeButton(LocaleController.getString(R.string.ShowForwardingOptions), new AlertDialog.OnButtonClickListener() {
            @Override
            public final void onClick(AlertDialog alertDialog, int i2) {
                ChatActivity.this.lambda$openAnotherForward$111(alertDialog, i2);
            }
        });
        AlertDialog create = builder.create();
        showDialog(create);
        TextView textView = (TextView) create.getButton(-1);
        if (textView != null) {
            textView.setTextColor(getThemedColor(Theme.key_text_RedBold));
        }
    }

    public void openAttachMenu() {
        ChatAttachAlert chatAttachAlert;
        int i;
        if (getParentActivity() != null) {
            ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
            if (chatActivityEnterView == null || TextUtils.isEmpty(chatActivityEnterView.getSlowModeTimer())) {
                createChatAttachView();
                this.chatAttachAlert.getPhotoLayout().loadGalleryPhotos();
                int i2 = Build.VERSION.SDK_INT;
                if (i2 == 21 || i2 == 22) {
                    this.chatActivityEnterView.closeKeyboard();
                }
                TLRPC.Chat chat = this.currentChat;
                if (chat == null || this.messageSuggestionParams == null) {
                    if (chat == null || ChatObject.hasAdminRights(chat) || !this.currentChat.slowmode_enabled) {
                        chatAttachAlert = this.chatAttachAlert;
                        i = -1;
                    } else {
                        chatAttachAlert = this.chatAttachAlert;
                        i = 10;
                    }
                    chatAttachAlert.setMaxSelectedPhotos(i, true);
                } else {
                    this.chatAttachAlert.setMaxSelectedPhotos(1, true);
                }
                this.chatAttachAlert.enableDefaultMode();
                this.chatAttachAlert.init();
                this.chatAttachAlert.getCommentView().setText(this.chatActivityEnterView.getFieldText());
                ChatAttachAlert chatAttachAlert2 = this.chatAttachAlert;
                chatAttachAlert2.parentThemeDelegate = this.themeDelegate;
                showDialog(chatAttachAlert2);
            }
        }
    }

    public void openClickableLink(final android.text.style.CharacterStyle r14, final java.lang.String r15, boolean r16, final org.telegram.ui.Cells.ChatMessageCell r17, final org.telegram.messenger.MessageObject r18, boolean r19) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.openClickableLink(android.text.style.CharacterStyle, java.lang.String, boolean, org.telegram.ui.Cells.ChatMessageCell, org.telegram.messenger.MessageObject, boolean):void");
    }

    public void openDiscussionMessageChat(long j, final MessageObject messageObject, int i, final long j2, final int i2, final int i3, final MessageObject messageObject2) {
        int i4 = i;
        final TLRPC.Chat chat = getMessagesController().getChat(Long.valueOf(j));
        final TLRPC.TL_messages_getDiscussionMessage tL_messages_getDiscussionMessage = new TLRPC.TL_messages_getDiscussionMessage();
        tL_messages_getDiscussionMessage.peer = MessagesController.getInputPeer(chat);
        tL_messages_getDiscussionMessage.msg_id = i4;
        if (BuildVars.LOGS_ENABLED) {
            FileLog.d("getDiscussionMessage chat = " + chat.id + " msg_id = " + i4);
        }
        this.commentLoadingMessageId = 0;
        this.hideCommentLoading = false;
        this.savedDiscussionMessage = null;
        this.savedNoDiscussion = false;
        this.savedNoHistory = false;
        this.savedHistory = null;
        RecyclerListView recyclerListView = this.chatListView;
        if (recyclerListView != null) {
            recyclerListView.invalidateViews();
        }
        if (this.commentMessagesRequestId != -1) {
            getConnectionsManager().cancelRequest(this.commentMessagesRequestId, false);
        }
        if (this.commentRequestId != -1) {
            getConnectionsManager().cancelRequest(this.commentRequestId, false);
        }
        if (messageObject2 != null) {
            i4 = messageObject2.getId();
        }
        this.commentLoadingMessageId = i4;
        this.hideCommentLoading = false;
        this.commentLoadingStartedAt = System.currentTimeMillis();
        RecyclerListView recyclerListView2 = this.chatListView;
        if (recyclerListView2 != null) {
            recyclerListView2.invalidateViews();
        }
        final int i5 = this.commentLoadingGuid + 1;
        this.commentLoadingGuid = i5;
        this.commentRequestId = getConnectionsManager().sendRequest(tL_messages_getDiscussionMessage, new RequestDelegate() {
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                ChatActivity.this.lambda$openDiscussionMessageChat$373(i5, i2, j2, i3, messageObject2, tL_messages_getDiscussionMessage, chat, messageObject, tLObject, tL_error);
            }
        });
        getConnectionsManager().bindRequestToGuid(this.commentRequestId, ((BaseFragment) this).classGuid);
    }

    private void openEditingMessageInPhotoEditor() {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.openEditingMessageInPhotoEditor():void");
    }

    public void openForward(boolean z) {
        HintView hintView;
        View view;
        if (getMessagesController().isChatNoForwards(this.currentChat) || hasSelectedNoforwardsMessage()) {
            String string = LocaleController.getString(getMessagesController().isChatNoForwards(this.currentChat) ? (!ChatObject.isChannel(this.currentChat) || this.currentChat.megagroup) ? R.string.ForwardsRestrictedInfoGroup : R.string.ForwardsRestrictedInfoChannel : R.string.ForwardsRestrictedInfoBot);
            if (z) {
                if (this.fwdRestrictedTopHint == null) {
                    SizeNotifierFrameLayout sizeNotifierFrameLayout = ((BaseFragment) this).fragmentView;
                    int indexOfChild = sizeNotifierFrameLayout.indexOfChild(this.chatActivityEnterView);
                    if (indexOfChild == -1) {
                        return;
                    }
                    HintView hintView2 = new HintView(getParentActivity(), 7, true);
                    this.fwdRestrictedTopHint = hintView2;
                    sizeNotifierFrameLayout.addView(hintView2, indexOfChild + 1, LayoutHelper.createFrame(-2, -2.0f, 51, 12.0f, 0.0f, 12.0f, 0.0f));
                    this.fwdRestrictedTopHint.setAlpha(0.0f);
                    this.fwdRestrictedTopHint.setVisibility(4);
                }
                this.fwdRestrictedTopHint.setText(string);
                hintView = this.fwdRestrictedTopHint;
                view = ((BaseFragment) this).actionBar.getActionMode().getItem(11);
            } else {
                if (this.fwdRestrictedBottomHint == null) {
                    SizeNotifierFrameLayout sizeNotifierFrameLayout2 = ((BaseFragment) this).fragmentView;
                    int indexOfChild2 = sizeNotifierFrameLayout2.indexOfChild(this.chatActivityEnterView);
                    if (indexOfChild2 == -1) {
                        return;
                    }
                    HintView hintView3 = new HintView(getParentActivity(), 9);
                    this.fwdRestrictedBottomHint = hintView3;
                    sizeNotifierFrameLayout2.addView(hintView3, indexOfChild2 + 1, LayoutHelper.createFrame(-2, -2.0f, 51, 12.0f, 0.0f, 12.0f, 0.0f));
                    this.fwdRestrictedBottomHint.setAlpha(0.0f);
                    this.fwdRestrictedBottomHint.setVisibility(4);
                }
                this.fwdRestrictedBottomHint.setText(string);
                hintView = this.fwdRestrictedBottomHint;
                view = this.forwardButton;
            }
            hintView.showForView(view, true);
            return;
        }
        int i = 0;
        boolean z2 = false;
        for (int i2 = 0; i2 < 2; i2++) {
            for (int i3 = 0; i3 < this.selectedMessagesIds[i2].size(); i3++) {
                MessageObject messageObject = (MessageObject) this.selectedMessagesIds[i2].valueAt(i3);
                if (messageObject.isTodo()) {
                    i = 3;
                } else if (messageObject.isPoll()) {
                    i = messageObject.isPublicPoll() ? 2 : 1;
                    if (i == 2) {
                        break;
                    }
                } else if (messageObject.isInvoice()) {
                    z2 = true;
                }
            }
            if (i == 2) {
                break;
            }
        }
        ChatSelectionReactionMenuOverlay chatSelectionReactionMenuOverlay = this.selectionReactionsOverlay;
        if (chatSelectionReactionMenuOverlay != null && chatSelectionReactionMenuOverlay.isVisible()) {
            this.selectionReactionsOverlay.setHiddenByScroll(true);
        }
        Bundle bundle = new Bundle();
        bundle.putBoolean("onlySelect", true);
        bundle.putInt("dialogsType", 3);
        bundle.putInt("messagesCount", this.canForwardMessagesCount);
        bundle.putInt("hasPoll", i);
        bundle.putBoolean("hasInvoice", z2);
        bundle.putBoolean("canSelectTopics", true);
        DialogsActivity dialogsActivity = new DialogsActivity(bundle);
        dialogsActivity.setDelegate(this);
        presentFragment(dialogsActivity);
    }

    private void openForwardingPreview(int i) {
        TLRPC.TL_channels_sendAsPeers tL_channels_sendAsPeers;
        MessagePreviewParams messagePreviewParams = this.messagePreviewParams;
        if (messagePreviewParams == null || this.forwardingPreviewView != null) {
            return;
        }
        if (messagePreviewParams.linkMessage != null) {
            int i2 = ((BaseFragment) this).currentAccount;
            TLRPC.WebPage webPage = this.foundWebPage;
            CharSequence fieldText = this.chatActivityEnterView.getFieldText();
            MessageObject messageObject = this.replyingMessageObject;
            if (messageObject == this.threadMessageObject) {
                messageObject = null;
            }
            messagePreviewParams.updateLink(i2, webPage, fieldText, messageObject, this.replyingQuote, this.editingMessageObject);
        }
        if (this.messagePreviewParams.isEmpty()) {
            return;
        }
        this.keyboardWasVisible = this.chatActivityEnterView.isKeyboardVisible();
        Context context = this.contentView.getContext();
        MessagePreviewParams messagePreviewParams2 = this.messagePreviewParams;
        TLRPC.User user = this.currentUser;
        TLRPC.Chat chat = this.currentChat;
        int i3 = ((BaseFragment) this).currentAccount;
        ThemeDelegate themeDelegate = this.themeDelegate;
        ReplyQuote replyQuote = this.replyingQuote;
        AnonymousClass68 anonymousClass68 = new AnonymousClass68(context, this, messagePreviewParams2, user, chat, i3, themeDelegate, i, replyQuote != null && replyQuote.outdated);
        this.forwardingPreviewView = anonymousClass68;
        this.messagePreviewParams.attach(anonymousClass68);
        TLRPC.ChatFull chatFull = this.chatInfo;
        TLRPC.Peer peer = chatFull != null ? chatFull.default_send_as : null;
        if (peer == null && (tL_channels_sendAsPeers = this.sendAsPeersObj) != null && !tL_channels_sendAsPeers.peers.isEmpty()) {
            peer = ((TLRPC.TL_sendAsPeer) this.sendAsPeersObj.peers.get(0)).peer;
        }
        this.forwardingPreviewView.setSendAsPeer(peer);
        checkShowBlur(true);
        this.contentView.addView(this.forwardingPreviewView);
        if (this.keyboardWasVisible) {
            this.chatActivityEnterView.freezeEmojiView(true);
            this.chatActivityEnterView.showEmojiView();
            this.openKeyboardOnAttachMenuClose = true;
        }
        AndroidUtilities.setAdjustResizeToNothing(getParentActivity(), ((BaseFragment) this).classGuid);
        ((BaseFragment) this).fragmentView.requestLayout();
    }

    private boolean openLinkInternally(String str, ChatMessageCell chatMessageCell, CharacterStyle characterStyle, int i) {
        return openLinkInternally(str, chatMessageCell, characterStyle, i, 1);
    }

    public boolean openLinkInternally(String str, final ChatMessageCell chatMessageCell, final CharacterStyle characterStyle, final int i, final int i2) {
        TLRPC.TL_forumTopic findTopic;
        String group;
        int i3;
        if (this.currentChat != null && str != null && this.chatMode == 0) {
            Integer num = null;
            Runnable runnable = (chatMessageCell == null || (characterStyle == null && i2 == 1)) ? null : new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$openLinkInternally$382(i, i2, characterStyle, chatMessageCell);
                }
            };
            if (str.startsWith("tg:privatepost") || str.startsWith("tg://privatepost")) {
                Uri parse = Uri.parse(str.replace("tg:privatepost", "tg://telegram.org").replace("tg://privatepost", "tg://telegram.org"));
                int intValue = Utilities.parseInt(parse.getQueryParameter("post")).intValue();
                long longValue = Utilities.parseLong(parse.getQueryParameter("channel")).longValue();
                int intValue2 = Utilities.parseInt(parse.getQueryParameter("thread")).intValue();
                long j = this.currentChat.id;
                if (longValue == j && intValue != 0) {
                    if (intValue2 != 0) {
                        openDiscussionMessageChat(j, null, intValue2, 0L, -1, 0, null);
                    } else {
                        this.showScrollToMessageError = true;
                        if (this.chatMode == 2) {
                            this.chatActivityDelegate.openReplyMessage(intValue);
                            lambda$onBackPressed$354();
                        } else {
                            scrollToMessageId(intValue, i, true, 0, false, 0, runnable);
                        }
                    }
                    return true;
                }
            } else {
                try {
                    if (ChatObject.getPublicUsername(this.currentChat) != null) {
                        if (publicMsgUrlPattern == null) {
                            publicMsgUrlPattern = Pattern.compile("(https://)?t.me/([0-9a-zA-Z_]+)/([0-9]+)/?([0-9]+)?");
                            voiceChatUrlPattern = Pattern.compile("(https://)?t.me/([0-9a-zA-Z_]+)\\?(voicechat+)");
                        }
                        Matcher matcher = publicMsgUrlPattern.matcher(str);
                        if (matcher.find(2) && matcher.find(3) && ChatObject.hasPublicLink(this.currentChat, matcher.group(2))) {
                            Uri parse2 = Uri.parse(str);
                            int intValue3 = Utilities.parseInt(parse2.getQueryParameter("thread")).intValue();
                            int intValue4 = Utilities.parseInt(parse2.getQueryParameter("comment")).intValue();
                            if (intValue3 == 0 && intValue4 == 0) {
                                if (matcher.group(4) != null) {
                                    i3 = Integer.parseInt(matcher.group(3));
                                    group = matcher.group(4);
                                } else {
                                    group = matcher.group(3);
                                    i3 = 0;
                                }
                                int parseInt = Integer.parseInt(group);
                                if (ChatObject.isForum(this.currentChat) && i3 != getTopicId()) {
                                    return false;
                                }
                                this.showScrollToMessageError = true;
                                if (this.chatMode == 2) {
                                    this.chatActivityDelegate.openReplyMessage(parseInt);
                                    lambda$onBackPressed$354();
                                } else {
                                    int timestampFromLink = LaunchActivity.getTimestampFromLink(parse2);
                                    this.startFromVideoTimestamp = timestampFromLink;
                                    if (timestampFromLink >= 0) {
                                        this.startFromVideoMessageId = parseInt;
                                    }
                                    scrollToMessageId(parseInt, i, true, 0, false, 0, runnable);
                                }
                                return true;
                            }
                            return false;
                        }
                        if (!str.startsWith("tg:resolve") && !str.startsWith("tg://resolve")) {
                            Matcher matcher2 = voiceChatUrlPattern.matcher(str);
                            try {
                                if (matcher2.find(2) && matcher2.find(3) && ChatObject.hasPublicLink(this.currentChat, matcher2.group(2))) {
                                    String queryParameter = Uri.parse(str).getQueryParameter("voicechat");
                                    if (!TextUtils.isEmpty(queryParameter)) {
                                        this.voiceChatHash = queryParameter;
                                        checkGroupCallJoin(true);
                                        return true;
                                    }
                                }
                            } catch (Exception e) {
                                FileLog.e(e);
                            }
                        }
                        Uri parse3 = Uri.parse(str.replace("tg:resolve", "tg://telegram.org").replace("tg://resolve", "tg://telegram.org"));
                        String lowerCase = parse3.getQueryParameter("domain").toLowerCase();
                        int intValue5 = Utilities.parseInt(parse3.getQueryParameter("post")).intValue();
                        int intValue6 = Utilities.parseInt(parse3.getQueryParameter("thread")).intValue();
                        int intValue7 = Utilities.parseInt(parse3.getQueryParameter("comment")).intValue();
                        if (ChatObject.hasPublicLink(this.currentChat, lowerCase) && intValue5 != 0 && intValue6 == 0 && intValue7 == 0) {
                            if (this.chatMode == 2) {
                                this.chatActivityDelegate.openReplyMessage(intValue5);
                                lambda$onBackPressed$354();
                            } else {
                                scrollToMessageId(intValue5, i, true, 0, false, 0, runnable);
                            }
                            return true;
                        }
                        return false;
                    }
                    if (privateMsgUrlPattern == null) {
                        privateMsgUrlPattern = Pattern.compile("(https://)?t.me/c/([0-9]+)/([0-9]+)/?([0-9]+)?");
                    }
                    Matcher matcher3 = privateMsgUrlPattern.matcher(str);
                    if (matcher3.find(2) && matcher3.find(3) && matcher3.group(4) == null) {
                        long parseLong = Long.parseLong(matcher3.group(2));
                        int parseInt2 = Integer.parseInt(matcher3.group(3));
                        if (parseLong == this.currentChat.id && parseInt2 != 0) {
                            Uri parse4 = Uri.parse(str);
                            int intValue8 = Utilities.parseInt(parse4.getQueryParameter("thread")).intValue();
                            int intValue9 = Utilities.parseInt(parse4.getQueryParameter("topic")).intValue();
                            int intValue10 = Utilities.parseInt(parse4.getQueryParameter("comment")).intValue();
                            Integer parseInt3 = Utilities.parseInt(parse4.getQueryParameter("task"));
                            int intValue11 = parseInt3.intValue();
                            if (intValue8 == 0 && intValue9 == 0 && intValue10 == 0) {
                                if (ChatObject.isForum(this.currentChat) && (findTopic = getMessagesController().getTopicsController().findTopic(parseLong, parseInt2)) != null) {
                                    TLRPC.TL_forumTopic tL_forumTopic = this.forumTopic;
                                    return tL_forumTopic != null && tL_forumTopic.id == findTopic.id;
                                }
                                this.showScrollToMessageError = true;
                                if (this.chatMode == 2) {
                                    this.chatActivityDelegate.openReplyMessage(parseInt2);
                                    lambda$onBackPressed$354();
                                } else {
                                    if (intValue11 != 0) {
                                        num = parseInt3;
                                    }
                                    this.highlightTaskId = num;
                                    scrollToMessageId(parseInt2, i, true, 0, false, 0, runnable);
                                }
                                return true;
                            }
                            return false;
                        }
                    }
                } catch (Exception e2) {
                    FileLog.e(e2);
                }
            }
        }
        return false;
    }

    public void openMessageInOriginalDialog(org.telegram.messenger.MessageObject r8) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.openMessageInOriginalDialog(org.telegram.messenger.MessageObject):void");
    }

    public void openOriginalReplyChat(org.telegram.messenger.MessageObject r14) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.openOriginalReplyChat(org.telegram.messenger.MessageObject):void");
    }

    public void openPinnedMessagesList(boolean z) {
        INavigationLayout iNavigationLayout;
        long j;
        String str;
        if (getParentActivity() == null || (iNavigationLayout = ((BaseFragment) this).parentLayout) == null || iNavigationLayout.getLastFragment() != this || this.pinnedMessageIds.isEmpty()) {
            return;
        }
        Bundle bundle = new Bundle();
        TLRPC.Chat chat = this.currentChat;
        if (chat != null) {
            j = chat.id;
            str = "chat_id";
        } else {
            j = this.currentUser.id;
            str = "user_id";
        }
        bundle.putLong(str, j);
        bundle.putInt("chatMode", 2);
        ChatActivity chatActivity = new ChatActivity(bundle);
        chatActivity.pinnedMessageIds = new ArrayList(this.pinnedMessageIds);
        chatActivity.pinnedMessageObjects = new HashMap(this.pinnedMessageObjects);
        int size = this.pinnedMessageIds.size();
        for (int i = 0; i < size; i++) {
            Integer num = (Integer) this.pinnedMessageIds.get(i);
            MessageObject messageObject = (MessageObject) this.pinnedMessageObjects.get(num);
            MessageObject messageObject2 = (MessageObject) this.messagesDict[0].get(num.intValue());
            if (messageObject == null) {
                messageObject = messageObject2;
            } else if (messageObject2 != null) {
                messageObject.mediaExists = messageObject2.mediaExists;
                messageObject.attachPathExists = messageObject2.attachPathExists;
            }
            if (messageObject != null) {
                chatActivity.pinnedMessageObjects.put(num, messageObject);
                chatActivity.updatePinnedTopicStarterMessage();
            }
        }
        chatActivity.loadedPinnedMessagesCount = this.loadedPinnedMessagesCount;
        chatActivity.totalPinnedMessagesCount = this.isTopic ? this.pinnedMessageIds.size() : this.totalPinnedMessagesCount;
        chatActivity.pinnedEndReached = this.pinnedEndReached;
        chatActivity.userInfo = this.userInfo;
        chatActivity.chatInfo = this.chatInfo;
        chatActivity.chatActivityDelegate = new AnonymousClass74();
        if (!z) {
            presentFragment(chatActivity, false);
        } else {
            presentFragmentAsPreview(chatActivity);
            checkShowBlur(true);
        }
    }

    public static ChatActivity openReportChat(long j, String str, byte[] bArr, String str2) {
        String str3;
        BaseFragment safeLastFragment = LaunchActivity.getSafeLastFragment();
        if (safeLastFragment == null) {
            return null;
        }
        Bundle bundle = new Bundle();
        if (DialogObject.isUserDialog(j)) {
            str3 = "user_id";
        } else {
            j = -j;
            str3 = "chat_id";
        }
        bundle.putLong(str3, j);
        bundle.putString("reportTitle", str);
        bundle.putByteArray("reportOption", bArr);
        bundle.putString("reportMessage", str2);
        ChatActivity chatActivity = new ChatActivity(bundle);
        safeLastFragment.presentFragment(chatActivity);
        return chatActivity;
    }

    public void openScheduledMessages() {
        openScheduledMessages(0, false);
    }

    private void openScheduledMessages(int i, boolean z) {
        long j;
        String str;
        INavigationLayout iNavigationLayout = ((BaseFragment) this).parentLayout;
        if (iNavigationLayout == null || iNavigationLayout.getLastFragment() != this) {
            return;
        }
        Bundle bundle = new Bundle();
        TLRPC.EncryptedChat encryptedChat = this.currentEncryptedChat;
        if (encryptedChat != null) {
            bundle.putInt("enc_id", encryptedChat.id);
        } else {
            TLRPC.Chat chat = this.currentChat;
            if (chat != null) {
                j = chat.id;
                str = "chat_id";
            } else {
                j = this.currentUser.id;
                str = "user_id";
            }
            bundle.putLong(str, j);
        }
        bundle.putInt("chatMode", 1);
        if (z) {
            bundle.putInt("converting_toast_from", i);
            bundle.putBoolean("converting_toast", true);
        }
        ChatActivity chatActivity = new ChatActivity(bundle);
        if (this.isTopic) {
            ForumUtilities.applyTopic(chatActivity, MessagesStorage.TopicKey.of(getDialogId(), getTopicId()));
        }
        chatActivity.chatActivityDelegate = new ChatActivityDelegate() {
            @Override
            public void onUnpin(boolean z2, boolean z3) {
                ChatActivityDelegate.CC.$default$onUnpin(this, z2, z3);
            }

            @Override
            public void openHashtagSearch(String str2) {
                ChatActivity.this.lambda$openHashtagSearch$358(str2);
            }

            @Override
            public void openReplyMessage(int i2) {
                ChatActivity.this.scrollToMessageId(i2, 0, true, 0, true, 0);
            }
        };
        presentFragment(chatActivity, false);
    }

    public void lambda$openSearchWithChat$360(final TLRPC.Chat chat) {
        boolean z;
        HintView2 hintView2 = this.savedMessagesHint;
        if (hintView2 == null || !hintView2.shown()) {
            z = false;
        } else {
            this.savedMessagesHint.hide();
            z = true;
        }
        HintView2 hintView22 = this.savedMessagesSearchHint;
        if (hintView22 != null && hintView22.shown()) {
            this.savedMessagesSearchHint.hide();
            z = true;
        }
        if (z) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$openSearchWithChat$360(chat);
                }
            }, 200L);
            return;
        }
        if (!((BaseFragment) this).actionBar.isSearchFieldVisible()) {
            AndroidUtilities.updateViewVisibilityAnimated(this.avatarContainer, false, 0.95f, true);
            ActionBarMenuItem actionBarMenuItem = this.headerItem;
            if (actionBarMenuItem != null) {
                actionBarMenuItem.setVisibility(8);
            }
            ActionBarMenu.LazyItem lazyItem = this.attachItem;
            if (lazyItem != null) {
                lazyItem.setVisibility(8);
            }
            ActionBarMenu.LazyItem lazyItem2 = this.editTextItem;
            if (lazyItem2 != null) {
                lazyItem2.setVisibility(8);
            }
            ActionBarMenuItem actionBarMenuItem2 = this.searchItem;
            if (actionBarMenuItem2 != null) {
                actionBarMenuItem2.setVisibility(0);
            }
            ActionBarMenuItem actionBarMenuItem3 = this.searchIconItem;
            if (actionBarMenuItem3 != null && this.showSearchAsIcon) {
                actionBarMenuItem3.setVisibility(8);
            }
            ActionBarMenu.LazyItem lazyItem3 = this.audioCallIconItem;
            if (lazyItem3 != null && this.showAudioCallAsIcon) {
                lazyItem3.setVisibility(8);
            }
            this.searchItemVisible = true;
            updateSearchButtons(0, 0, -1);
            updateBottomOverlay();
            ImageView imageView = this.searchCalendarButton;
            if (imageView != null) {
                imageView.setVisibility(8);
            }
            ImageView imageView2 = this.searchUserButton;
            if (imageView2 != null) {
                imageView2.setVisibility(8);
            }
        }
        ActionBarMenuItem actionBarMenuItem4 = this.searchItem;
        if (actionBarMenuItem4 != null) {
            this.preventReopenSearchWithText = true;
            this.openSearchKeyboard = false;
            actionBarMenuItem4.openSearch(false);
            this.preventReopenSearchWithText = false;
        }
        searchUserMessages(null, chat);
        updatePinnedMessageView(true);
    }

    public void lambda$openSearchWithUser$359(final TLRPC.User user) {
        boolean z;
        HintView2 hintView2 = this.savedMessagesHint;
        if (hintView2 == null || !hintView2.shown()) {
            z = false;
        } else {
            this.savedMessagesHint.hide();
            z = true;
        }
        HintView2 hintView22 = this.savedMessagesSearchHint;
        if (hintView22 != null && hintView22.shown()) {
            this.savedMessagesSearchHint.hide();
            z = true;
        }
        if (z) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$openSearchWithUser$359(user);
                }
            }, 200L);
            return;
        }
        if (!((BaseFragment) this).actionBar.isSearchFieldVisible()) {
            AndroidUtilities.updateViewVisibilityAnimated(this.avatarContainer, false, 0.95f, true);
            ActionBarMenuItem actionBarMenuItem = this.headerItem;
            if (actionBarMenuItem != null) {
                actionBarMenuItem.setVisibility(8);
            }
            ActionBarMenu.LazyItem lazyItem = this.attachItem;
            if (lazyItem != null) {
                lazyItem.setVisibility(8);
            }
            ActionBarMenu.LazyItem lazyItem2 = this.editTextItem;
            if (lazyItem2 != null) {
                lazyItem2.setVisibility(8);
            }
            ActionBarMenuItem actionBarMenuItem2 = this.searchItem;
            if (actionBarMenuItem2 != null) {
                actionBarMenuItem2.setVisibility(0);
            }
            ActionBarMenuItem actionBarMenuItem3 = this.searchIconItem;
            if (actionBarMenuItem3 != null && this.showSearchAsIcon) {
                actionBarMenuItem3.setVisibility(8);
            }
            ActionBarMenu.LazyItem lazyItem3 = this.audioCallIconItem;
            if (lazyItem3 != null && this.showAudioCallAsIcon) {
                lazyItem3.setVisibility(8);
            }
            this.searchItemVisible = true;
            updateSearchButtons(0, 0, -1);
            updateBottomOverlay();
            ImageView imageView = this.searchCalendarButton;
            if (imageView != null) {
                imageView.setVisibility(8);
            }
            ImageView imageView2 = this.searchUserButton;
            if (imageView2 != null) {
                imageView2.setVisibility(8);
            }
        }
        ActionBarMenuItem actionBarMenuItem4 = this.searchItem;
        if (actionBarMenuItem4 != null) {
            this.preventReopenSearchWithText = true;
            this.openSearchKeyboard = false;
            actionBarMenuItem4.openSearch(false);
            this.preventReopenSearchWithText = false;
        }
        searchUserMessages(user, null);
        updatePinnedMessageView(true);
    }

    public void openUserProfile(long j) {
        BaseFragment profileActivity;
        if (j < 0) {
            if (j != getDialogId()) {
                Bundle bundle = new Bundle();
                bundle.putLong("chat_id", -j);
                if (getMessagesController().checkCanOpenChat(bundle, this)) {
                    profileActivity = new ChatActivity(bundle);
                    presentFragment(profileActivity);
                    return;
                }
                return;
            }
            this.avatarContainer.openProfile(true);
        }
        if (j == getUserConfig().getClientUserId()) {
            Bundle bundle2 = new Bundle();
            bundle2.putLong("user_id", j);
            bundle2.putBoolean("my_profile", true);
            profileActivity = new ProfileActivity(bundle2, null);
            presentFragment(profileActivity);
            return;
        }
        if (j != getDialogId()) {
            Bundle bundle3 = new Bundle();
            bundle3.putLong("user_id", j);
            if (this.currentEncryptedChat != null && j == this.currentUser.id) {
                bundle3.putLong("dialog_id", this.dialog_id);
            }
            ProfileActivity profileActivity2 = new ProfileActivity(bundle3);
            TLRPC.User user = this.currentUser;
            profileActivity2.setPlayProfileAnimation((user == null || user.id != j) ? 0 : 1);
            presentFragment(profileActivity2);
            return;
        }
        this.avatarContainer.openProfile(true);
    }

    private TLRPC.KeyboardButton pinnedButton(MessageObject messageObject) {
        TLRPC.Message message;
        TLRPC.ReplyMarkup replyMarkup;
        ArrayList arrayList;
        if (messageObject == null || (message = messageObject.messageOwner) == null || (replyMarkup = message.reply_markup) == null || (arrayList = replyMarkup.rows) == null || arrayList.size() != 1 || messageObject.messageOwner.reply_markup.rows.get(0) == null || ((TLRPC.TL_keyboardButtonRow) messageObject.messageOwner.reply_markup.rows.get(0)).buttons == null || ((TLRPC.TL_keyboardButtonRow) messageObject.messageOwner.reply_markup.rows.get(0)).buttons.size() != 1) {
            return null;
        }
        return (TLRPC.KeyboardButton) ((TLRPC.TL_keyboardButtonRow) messageObject.messageOwner.reply_markup.rows.get(0)).buttons.get(0);
    }

    private boolean pinnedOnlyStarterMessage() {
        return this.pinnedMessageIds.size() == 1 && this.topicStarterMessageObject != null && ((Integer) this.pinnedMessageIds.get(0)).intValue() == this.topicStarterMessageObject.getId();
    }

    private void playReactionAnimation(Integer num) {
        if (((BaseFragment) this).fragmentView == null) {
            return;
        }
        BaseCell findMessageCell = findMessageCell(num.intValue(), false);
        if (findMessageCell instanceof ChatMessageCell) {
            ChatMessageCell chatMessageCell = (ChatMessageCell) findMessageCell;
            TLRPC.MessagePeerReaction randomUnreadReaction = chatMessageCell.getMessageObject().getRandomUnreadReaction();
            if (randomUnreadReaction != null && chatMessageCell.reactionsLayoutInBubble.hasUnreadReactions) {
                ReactionsEffectOverlay.show(this, null, findMessageCell, null, 0.0f, 0.0f, ReactionsLayoutInBubble.VisibleReaction.fromTL(randomUnreadReaction.reaction), ((BaseFragment) this).currentAccount, !randomUnreadReaction.big ? 1 : 0);
                ReactionsEffectOverlay.startAnimation();
            }
            chatMessageCell.markReactionsAsRead();
            return;
        }
        if (findMessageCell instanceof ChatActionCell) {
            ChatActionCell chatActionCell = (ChatActionCell) findMessageCell;
            TLRPC.MessagePeerReaction randomUnreadReaction2 = chatActionCell.getMessageObject().getRandomUnreadReaction();
            if (randomUnreadReaction2 != null && chatActionCell.reactionsLayoutInBubble.hasUnreadReactions) {
                ReactionsEffectOverlay.show(this, null, findMessageCell, null, 0.0f, 0.0f, ReactionsLayoutInBubble.VisibleReaction.fromTL(randomUnreadReaction2.reaction), ((BaseFragment) this).currentAccount, !randomUnreadReaction2.big ? 1 : 0);
                ReactionsEffectOverlay.startAnimation();
            }
            chatActionCell.markReactionsAsRead();
        }
    }

    private void pressedReaction(View view, TLRPC.ReactionCount reactionCount, float f, float f2) {
        MessageObject messageObject;
        TLRPC.Message message;
        ReactionsLayoutInBubble.VisibleReaction fromTL = ReactionsLayoutInBubble.VisibleReaction.fromTL(reactionCount.reaction);
        if (view instanceof ChatMessageCell) {
            messageObject = ((ChatMessageCell) view).getPrimaryMessageObject();
        } else if (!(view instanceof ChatActionCell)) {
            return;
        } else {
            messageObject = ((ChatActionCell) view).getMessageObject();
        }
        MessageObject messageObject2 = messageObject;
        selectReaction(view, messageObject2, null, null, f, f2, fromTL, false, false, false, false);
        if ((messageObject2 != null) & (messageObject2.messageOwner != null)) {
            boolean z = this.chatAdapter.isFiltered;
            if (z) {
                MessageObject messageObject3 = (MessageObject) this.messagesDict[0].get(messageObject2.getId());
                if (messageObject3 != null && (message = messageObject3.messageOwner) != null) {
                    message.reactions = messageObject2.messageOwner.reactions;
                }
            } else if (!z && this.searchingReaction != null) {
                updateFilteredMessages(false);
            }
        }
        if (!this.chatAdapter.isFiltered || messageObject2.hasReaction(this.searchingReaction)) {
            return;
        }
        MessageObject.GroupedMessages validGroupedMessage = getValidGroupedMessage(messageObject2);
        if (validGroupedMessage != null) {
            for (int i = 0; i < validGroupedMessage.messages.size(); i++) {
                getMediaDataController().removeMessageFromResults(((MessageObject) validGroupedMessage.messages.get(i)).getId());
            }
        } else {
            getMediaDataController().removeMessageFromResults(messageObject2.getId());
        }
        MessagesSearchAdapter messagesSearchAdapter = this.messagesSearchAdapter;
        if (messagesSearchAdapter != null) {
            messagesSearchAdapter.notifyDataSetChanged();
        }
        updateFilteredMessages(true);
    }

    private void processDeletedMessages(ArrayList arrayList, long j, boolean z) {
        processDeletedMessages(arrayList, j, z, true);
    }

    private void processDeletedMessages(java.util.ArrayList r43, long r44, boolean r46, boolean r47) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.processDeletedMessages(java.util.ArrayList, long, boolean, boolean):void");
    }

    public void processExternalUrl(int r13, java.lang.String r14, android.text.style.CharacterStyle r15, org.telegram.ui.Cells.ChatMessageCell r16, boolean r17, boolean r18) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.processExternalUrl(int, java.lang.String, android.text.style.CharacterStyle, org.telegram.ui.Cells.ChatMessageCell, boolean, boolean):void");
    }

    private void processLoadedDiscussionMessage(boolean r17, final org.telegram.tgnet.TLRPC.TL_messages_discussionMessage r18, boolean r19, org.telegram.tgnet.TLRPC.messages_Messages r20, final int r21, final org.telegram.messenger.MessageObject r22, final org.telegram.tgnet.TLRPC.TL_messages_getDiscussionMessage r23, final org.telegram.tgnet.TLRPC.Chat r24, final int r25, final org.telegram.messenger.MessageObject r26) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.processLoadedDiscussionMessage(boolean, org.telegram.tgnet.TLRPC$TL_messages_discussionMessage, boolean, org.telegram.tgnet.TLRPC$messages_Messages, int, org.telegram.messenger.MessageObject, org.telegram.tgnet.TLRPC$TL_messages_getDiscussionMessage, org.telegram.tgnet.TLRPC$Chat, int, org.telegram.messenger.MessageObject):void");
    }

    private void processNewMessages(ArrayList arrayList) {
        processNewMessages(arrayList, true);
    }

    private void processNewMessages(java.util.ArrayList r31, boolean r32) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.processNewMessages(java.util.ArrayList, boolean):void");
    }

    public void processRowSelect(View view, boolean z, float f, float f2) {
        MessageObject messageObject;
        int i;
        if (view instanceof ChatMessageCell) {
            ChatMessageCell chatMessageCell = (ChatMessageCell) view;
            messageObject = chatMessageCell.getMessageObject();
            chatMessageCell.setLastTouchCoords(f, f2);
        } else {
            messageObject = view instanceof ChatActionCell ? ((ChatActionCell) view).getMessageObject() : null;
        }
        int messageType = getMessageType(messageObject);
        if ((messageObject == null || !messageObject.isAnyGift()) && messageType >= 2 && messageType != 20 && messageType != 21) {
            if (messageObject == null || !((i = messageObject.type) == 27 || i == 30)) {
                if (messageObject == null || !messageObject.isWallpaperAction()) {
                    addToSelectedMessages(messageObject, z);
                    updateActionModeTitle();
                    updateVisibleRows();
                }
            }
        }
    }

    public void processSelectedAttach(int i) {
        TLRPC.TL_chatBannedRights tL_chatBannedRights;
        try {
            if (i == 0) {
                int i2 = Build.VERSION.SDK_INT;
                if (i2 >= 23 && FilesMigrationService$FilesMigrationBottomSheet$.ExternalSyntheticApiModelOutline0.m(getParentActivity(), "android.permission.CAMERA") != 0) {
                    FilesMigrationService$FilesMigrationBottomSheet$.ExternalSyntheticApiModelOutline1.m(getParentActivity(), new String[]{"android.permission.CAMERA"}, 19);
                    return;
                }
                Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
                File generatePicturePath = AndroidUtilities.generatePicturePath();
                if (generatePicturePath != null) {
                    if (i2 >= 24) {
                        intent.putExtra("output", FileProvider.getUriForFile(getParentActivity(), ApplicationLoader.getApplicationId() + ".provider", generatePicturePath));
                        intent.addFlags(2);
                        intent.addFlags(1);
                    } else {
                        intent.putExtra("output", Uri.fromFile(generatePicturePath));
                    }
                    this.currentPicturePath = generatePicturePath.getAbsolutePath();
                }
                startActivityForResult(intent, 0);
                return;
            }
            if (i == 1) {
                Activity parentActivity = getParentActivity();
                int i3 = Build.VERSION.SDK_INT;
                if (i3 >= 33) {
                    if (FilesMigrationService$FilesMigrationBottomSheet$.ExternalSyntheticApiModelOutline0.m(parentActivity, "android.permission.READ_MEDIA_IMAGES") != 0) {
                        try {
                            FilesMigrationService$FilesMigrationBottomSheet$.ExternalSyntheticApiModelOutline1.m(getParentActivity(), new String[]{"android.permission.READ_MEDIA_IMAGES", "android.permission.READ_MEDIA_VIDEO"}, 4);
                            return;
                        } catch (Throwable unused) {
                            return;
                        }
                    }
                } else if (i3 >= 23 && FilesMigrationService$FilesMigrationBottomSheet$.ExternalSyntheticApiModelOutline0.m(parentActivity, "android.permission.READ_EXTERNAL_STORAGE") != 0) {
                    try {
                        FilesMigrationService$FilesMigrationBottomSheet$.ExternalSyntheticApiModelOutline1.m(getParentActivity(), new String[]{"android.permission.READ_EXTERNAL_STORAGE"}, 4);
                        return;
                    } catch (Throwable unused2) {
                        return;
                    }
                }
                PhotoAlbumPickerActivity photoAlbumPickerActivity = new PhotoAlbumPickerActivity(PhotoAlbumPickerActivity.SELECT_TYPE_ALL, (ChatObject.isChannel(this.currentChat) && (tL_chatBannedRights = this.currentChat.banned_rights) != null && tL_chatBannedRights.send_gifs) ? false : true, true, this);
                TLRPC.Chat chat = this.currentChat;
                if (chat == null || ChatObject.hasAdminRights(chat) || !this.currentChat.slowmode_enabled) {
                    MessageObject messageObject = this.editingMessageObject;
                    photoAlbumPickerActivity.setMaxSelectedPhotos(messageObject != null ? 1 : 0, messageObject == null);
                } else {
                    photoAlbumPickerActivity.setMaxSelectedPhotos(10, true);
                }
                photoAlbumPickerActivity.setDelegate(new PhotoAlbumPickerActivity.PhotoAlbumPickerActivityDelegate() {
                    @Override
                    public void didSelectPhotos(ArrayList arrayList, boolean z, int i4) {
                    }

                    @Override
                    public void startPhotoSelectActivity() {
                        try {
                            Intent intent2 = new Intent();
                            intent2.setType("video/*");
                            intent2.setAction("android.intent.action.GET_CONTENT");
                            intent2.putExtra("android.intent.extra.sizeLimit", 2097152000L);
                            Intent intent3 = new Intent("android.intent.action.PICK");
                            intent3.setType("image/*");
                            Intent createChooser = Intent.createChooser(intent3, null);
                            createChooser.putExtra("android.intent.extra.INITIAL_INTENTS", new Intent[]{intent2});
                            ChatActivity.this.startActivityForResult(createChooser, 1);
                        } catch (Exception e) {
                            FileLog.e(e);
                        }
                    }
                });
                presentFragment(photoAlbumPickerActivity);
                return;
            }
            if (i == 2) {
                int i4 = Build.VERSION.SDK_INT;
                if (i4 >= 23 && FilesMigrationService$FilesMigrationBottomSheet$.ExternalSyntheticApiModelOutline0.m(getParentActivity(), "android.permission.CAMERA") != 0) {
                    try {
                        FilesMigrationService$FilesMigrationBottomSheet$.ExternalSyntheticApiModelOutline1.m(getParentActivity(), new String[]{"android.permission.CAMERA"}, 20);
                        return;
                    } catch (Throwable unused3) {
                        return;
                    }
                }
                Intent intent2 = new Intent("android.media.action.VIDEO_CAPTURE");
                File generateVideoPath = AndroidUtilities.generateVideoPath();
                if (generateVideoPath != null) {
                    if (i4 >= 24) {
                        intent2.putExtra("output", FileProvider.getUriForFile(getParentActivity(), ApplicationLoader.getApplicationId() + ".provider", generateVideoPath));
                        intent2.addFlags(2);
                        intent2.addFlags(1);
                    } else {
                        intent2.putExtra("output", Uri.fromFile(generateVideoPath));
                    }
                    intent2.putExtra("android.intent.extra.sizeLimit", 2097152000L);
                    this.currentPicturePath = generateVideoPath.getAbsolutePath();
                }
                startActivityForResult(intent2, 2);
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
    }

    public void processSelectedOption(int r23) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.processSelectedOption(int):void");
    }

    private void putFilteredDate(int i, MessageObject messageObject) {
        TLRPC.TL_message tL_message = new TLRPC.TL_message();
        ((TLRPC.Message) tL_message).message = LocaleController.formatDateChat(messageObject.messageOwner.date);
        ((TLRPC.Message) tL_message).id = 0;
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(messageObject.messageOwner.date * 1000);
        calendar.set(11, 0);
        calendar.set(12, 0);
        calendar.set(13, 0);
        calendar.set(14, 0);
        ((TLRPC.Message) tL_message).date = (int) (calendar.getTimeInMillis() / 1000);
        MessageObject messageObject2 = new MessageObject(((BaseFragment) this).currentAccount, tL_message, false, false);
        messageObject2.type = 10;
        messageObject2.contentType = 1;
        messageObject2.isDateObject = true;
        messageObject2.stableId = getStableIdForDateObject(messageObject.dateKeyInt);
        this.chatAdapter.filteredMessages.add(i, messageObject2);
    }

    public void removeMessageObject(MessageObject messageObject) {
        int indexOf = this.messages.indexOf(messageObject);
        if (indexOf == -1) {
            return;
        }
        this.messages.remove(indexOf);
        ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
        if (chatActivityAdapter == null || chatActivityAdapter.isFiltered) {
            return;
        }
        chatActivityAdapter.notifyItemRemoved(chatActivityAdapter.messagesStartRow + indexOf);
    }

    public void removeSelectedMessageHighlight() {
        if (this.highlightMessageQuote == null && this.highlightTaskId == null) {
            Runnable runnable = this.unselectRunnable;
            if (runnable != null) {
                AndroidUtilities.cancelRunOnUIThread(runnable);
                this.unselectRunnable = null;
            }
            this.highlightMessageId = Integer.MAX_VALUE;
            this.highlightMessageQuoteFirst = false;
            this.highlightMessageQuoteFirstTime = 0L;
            this.highlightMessageQuote = null;
            this.highlightTaskId = null;
        }
    }

    private void removeUnreadPlane(boolean z) {
        MessageObject messageObject = this.unreadMessageObject;
        if (messageObject != null) {
            if (z) {
                boolean[] zArr = this.forwardEndReached;
                zArr[1] = true;
                zArr[0] = true;
                this.first_unread_id = 0;
                this.last_message_id = 0;
            }
            this.createUnreadMessageAfterId = 0;
            this.createUnreadMessageAfterIdLoading = false;
            removeMessageObject(messageObject);
            this.unreadMessageObject = null;
        }
    }

    private void replaceMessageObjects(ArrayList arrayList, int i, boolean z) {
        ChatActivityAdapter chatActivityAdapter;
        int i2;
        int i3;
        MessageObject.GroupedMessages groupedMessages;
        int indexOf;
        ArrayList arrayList2;
        MessageObject messageObject;
        TL_stories.StoryItem storyItem;
        TL_stories.StoryItem storyItem2 = null;
        boolean z2 = false;
        LongSparseArray longSparseArray = null;
        int i4 = 0;
        while (i4 < arrayList.size()) {
            MessageObject messageObject2 = (MessageObject) arrayList.get(i4);
            if (((MessageObject) this.pinnedMessageObjects.get(Integer.valueOf(messageObject2.getId()))) != null) {
                this.pinnedMessageObjects.put(Integer.valueOf(messageObject2.getId()), messageObject2);
            }
            MessageObject messageObject3 = (MessageObject) this.messagesDict[i].get(messageObject2.getId());
            if (this.pinnedMessageObjects.containsKey(Integer.valueOf(messageObject2.getId()))) {
                this.pinnedMessageObjects.put(Integer.valueOf(messageObject2.getId()), messageObject2);
                if (messageObject2.getId() == this.currentPinnedMessageId) {
                    updatePinnedMessageView(true);
                }
            }
            if (i == 0 && this.repliesMessagesDict.indexOfKey(messageObject2.getId()) >= 0) {
                this.repliesMessagesDict.put(messageObject2.getId(), messageObject2);
            }
            if (messageObject3 != null && ((!z || messageObject3.messageOwner.date == messageObject2.messageOwner.date) && (!messageObject2.scheduled || this.chatMode == 1))) {
                if (z) {
                    arrayList.remove(i4);
                    i4--;
                }
                addToPolls(messageObject2, messageObject3);
                if (messageObject2.type >= 0) {
                    MessageObject messageObject4 = messageObject3.replyMessageObject;
                    if (messageObject4 != null) {
                        messageObject2.replyMessageObject = messageObject4;
                        TLRPC.MessageAction messageAction = messageObject2.messageOwner.action;
                        if (messageAction instanceof TLRPC.TL_messageActionGameScore) {
                            messageObject2.generateGameMessageText(storyItem2);
                        } else if (messageAction instanceof TLRPC.TL_messageActionPaymentSent) {
                            messageObject2.generatePaymentSentMessageText(storyItem2, z2);
                        } else if (messageAction instanceof TLRPC.TL_messageActionPaymentSentMe) {
                            messageObject2.generatePaymentSentMessageText(storyItem2, true);
                        } else if (messageAction instanceof TLRPC.TL_messageActionSuggestedPostApproval) {
                            messageObject2.generateSuggestionApprovalMessageText();
                        }
                    }
                    if (messageObject3.isWebpage() && messageObject2.isWebpage()) {
                        TLRPC.TL_messageMediaWebPage media = MessageObject.getMedia(messageObject3.messageOwner);
                        TLRPC.WebPage webPage = ((TLRPC.MessageMedia) media).webpage;
                        if (webPage != null && "telegram_story".equals(webPage.type)) {
                            int i5 = 0;
                            while (true) {
                                if (i5 >= ((TLRPC.MessageMedia) media).webpage.attributes.size()) {
                                    storyItem = storyItem2;
                                    break;
                                }
                                TLRPC.TL_webPageAttributeStory tL_webPageAttributeStory = (TLRPC.WebPageAttribute) ((TLRPC.MessageMedia) media).webpage.attributes.get(i5);
                                if (tL_webPageAttributeStory instanceof TLRPC.TL_webPageAttributeStory) {
                                    storyItem = tL_webPageAttributeStory.storyItem;
                                    break;
                                }
                                i5++;
                            }
                            if (storyItem != null) {
                                TLRPC.TL_messageMediaWebPage media2 = MessageObject.getMedia(messageObject2.messageOwner);
                                int i6 = 0;
                                while (true) {
                                    if (i6 >= ((TLRPC.MessageMedia) media2).webpage.attributes.size()) {
                                        break;
                                    }
                                    TLRPC.TL_webPageAttributeStory tL_webPageAttributeStory2 = (TLRPC.WebPageAttribute) ((TLRPC.MessageMedia) media2).webpage.attributes.get(i6);
                                    if (tL_webPageAttributeStory2 instanceof TLRPC.TL_webPageAttributeStory) {
                                        TLRPC.TL_webPageAttributeStory tL_webPageAttributeStory3 = tL_webPageAttributeStory2;
                                        if (!(tL_webPageAttributeStory3.storyItem instanceof TL_stories.TL_storyItem)) {
                                            tL_webPageAttributeStory3.storyItem = storyItem;
                                        }
                                    } else {
                                        i6++;
                                    }
                                }
                            }
                        }
                    }
                    if (!messageObject3.isEditing()) {
                        if (messageObject3.getFileName().equals(messageObject2.getFileName())) {
                            messageObject2.messageOwner.attachPath = messageObject3.messageOwner.attachPath;
                            messageObject2.attachPathExists = messageObject3.attachPathExists;
                            messageObject2.mediaExists = messageObject3.mediaExists;
                        } else {
                            messageObject2.checkMediaExistance();
                        }
                    }
                    this.messagesDict[i].put(messageObject3.getId(), messageObject2);
                } else {
                    this.messagesDict[i].remove(messageObject3.getId());
                }
                int indexOf2 = this.messages.indexOf(messageObject3);
                if (indexOf2 >= 0) {
                    ArrayList arrayList3 = (ArrayList) this.messagesByDays.get(messageObject3.dateKey);
                    int indexOf3 = arrayList3 != null ? arrayList3.indexOf(messageObject3) : -1;
                    if (messageObject3.getGroupId() != 0 && (groupedMessages = (MessageObject.GroupedMessages) this.groupedMessagesMap.get(messageObject3.getGroupId())) != null && (indexOf = groupedMessages.messages.indexOf(messageObject3)) >= 0) {
                        if (messageObject3.getGroupId() != messageObject2.getGroupId()) {
                            this.groupedMessagesMap.put(messageObject2.getGroupId(), groupedMessages);
                        }
                        if (messageObject2.isMusic() || messageObject2.isDocument() || !((arrayList2 = messageObject2.photoThumbs) == null || arrayList2.isEmpty())) {
                            groupedMessages.messages.set(indexOf, messageObject2);
                            messageObject3 = messageObject3;
                            MessageObject.GroupedMessagePosition groupedMessagePosition = (MessageObject.GroupedMessagePosition) groupedMessages.positions.remove(messageObject3);
                            groupedMessages.positionsArray.remove(messageObject3.getId());
                            if (groupedMessagePosition != null) {
                                groupedMessages.positions.put(messageObject2, groupedMessagePosition);
                                groupedMessages.positionsArray.put(messageObject2.getId(), groupedMessagePosition);
                            }
                            if (longSparseArray == null) {
                                longSparseArray = new LongSparseArray();
                            }
                            longSparseArray.put(groupedMessages.groupId, groupedMessages);
                        } else {
                            if (longSparseArray == null) {
                                longSparseArray = new LongSparseArray();
                            }
                            longSparseArray.put(groupedMessages.groupId, groupedMessages);
                            if (indexOf <= 0 || indexOf >= groupedMessages.messages.size() - 1) {
                                messageObject = messageObject3;
                            } else {
                                MessageObject.GroupedMessages groupedMessages2 = new MessageObject.GroupedMessages();
                                groupedMessages2.reversed = this.reversed;
                                messageObject = messageObject3;
                                groupedMessages2.groupId = Utilities.random.nextLong();
                                ArrayList arrayList4 = groupedMessages2.messages;
                                ArrayList arrayList5 = groupedMessages.messages;
                                int i7 = indexOf + 1;
                                arrayList4.addAll(arrayList5.subList(i7, arrayList5.size()));
                                for (int i8 = 0; i8 < groupedMessages2.messages.size(); i8++) {
                                    ((MessageObject) groupedMessages2.messages.get(i8)).localGroupId = groupedMessages2.groupId;
                                    groupedMessages.messages.remove(i7);
                                }
                                longSparseArray.put(groupedMessages2.groupId, groupedMessages2);
                                this.groupedMessagesMap.put(groupedMessages2.groupId, groupedMessages2);
                            }
                            groupedMessages.messages.remove(indexOf);
                            messageObject3 = messageObject;
                        }
                    }
                    if (this.chatMode == 3) {
                        messageObject2.isSaved = true;
                    }
                    if (messageObject2.type >= 0) {
                        messageObject2.copyStableParams(messageObject3);
                        this.messages.set(indexOf2, messageObject2);
                        ChatActivityAdapter chatActivityAdapter2 = this.chatAdapter;
                        if (chatActivityAdapter2 != null && !chatActivityAdapter2.isFiltered) {
                            chatActivityAdapter2.updateRowAtPosition(chatActivityAdapter2.messagesStartRow + indexOf2);
                        }
                        if (indexOf3 >= 0) {
                            arrayList3.set(indexOf3, messageObject2);
                        }
                    } else {
                        this.messages.remove(indexOf2);
                        ChatActivityAdapter chatActivityAdapter3 = this.chatAdapter;
                        if (chatActivityAdapter3 != null && !chatActivityAdapter3.isFiltered) {
                            chatActivityAdapter3.notifyItemRemoved(chatActivityAdapter3.messagesStartRow + indexOf2);
                        }
                        if (((MessageObject) this.conversionMessages.get(messageObject3.getId())) != null) {
                            this.conversionMessages.remove(messageObject3.getId());
                            this.messages.remove(indexOf2);
                            int i9 = this.chatAdapter.loadingUpRow;
                            int i10 = this.chatAdapter.loadingDownRow;
                            int i11 = this.chatAdapter.userNameTimeRow;
                            int i12 = this.chatAdapter.userPhotoTimeRow;
                            ChatActivityAdapter chatActivityAdapter4 = this.chatAdapter;
                            if (!chatActivityAdapter4.isFiltered) {
                                chatActivityAdapter4.notifyItemRemoved(chatActivityAdapter4.messagesStartRow + indexOf2);
                                if (this.messages.isEmpty()) {
                                    if (i9 >= 0) {
                                        i3 = 0;
                                        this.chatAdapter.notifyItemRemoved(0);
                                    } else {
                                        i3 = 0;
                                    }
                                    if (i10 >= 0) {
                                        this.chatAdapter.notifyItemRemoved(i3);
                                    }
                                    if (i11 >= 0) {
                                        this.chatAdapter.notifyItemRemoved(i3);
                                    }
                                    if (i12 >= 0) {
                                        this.chatAdapter.notifyItemRemoved(i3);
                                    }
                                }
                            }
                        }
                        if (indexOf3 >= 0) {
                            arrayList3.remove(indexOf3);
                            if (arrayList3.isEmpty()) {
                                this.messagesByDays.remove(messageObject3.dateKey);
                                this.messagesByDaysSorted.remove(messageObject3.dateKeyInt);
                                this.messages.remove(indexOf2);
                                int i13 = this.chatAdapter.loadingUpRow;
                                int i14 = this.chatAdapter.loadingDownRow;
                                int i15 = this.chatAdapter.userNameTimeRow;
                                int i16 = this.chatAdapter.userPhotoTimeRow;
                                ChatActivityAdapter chatActivityAdapter5 = this.chatAdapter;
                                if (!chatActivityAdapter5.isFiltered) {
                                    chatActivityAdapter5.notifyItemRemoved(chatActivityAdapter5.messagesStartRow + indexOf2);
                                    if (this.messages.isEmpty()) {
                                        if (i13 >= 0) {
                                            i2 = 0;
                                            this.chatAdapter.notifyItemRemoved(0);
                                        } else {
                                            i2 = 0;
                                        }
                                        if (i14 >= 0) {
                                            this.chatAdapter.notifyItemRemoved(i2);
                                        }
                                        if (i15 >= 0) {
                                            this.chatAdapter.notifyItemRemoved(i2);
                                        }
                                        if (i16 >= 0) {
                                            this.chatAdapter.notifyItemRemoved(i2);
                                        }
                                        updateReplyMessageOwners(messageObject3.getId(), messageObject2);
                                    }
                                }
                            }
                        }
                    }
                }
                updateReplyMessageOwners(messageObject3.getId(), messageObject2);
            }
            i4++;
            storyItem2 = null;
            z2 = false;
        }
        if (longSparseArray != null) {
            for (int i17 = 0; i17 < longSparseArray.size(); i17++) {
                MessageObject.GroupedMessages groupedMessages3 = (MessageObject.GroupedMessages) longSparseArray.valueAt(i17);
                if (groupedMessages3.messages.isEmpty()) {
                    this.groupedMessagesMap.remove(groupedMessages3.groupId);
                } else {
                    groupedMessages3.calculate();
                    ArrayList arrayList6 = groupedMessages3.messages;
                    int indexOf4 = this.messages.indexOf((MessageObject) arrayList6.get(arrayList6.size() - 1));
                    if (indexOf4 >= 0 && (chatActivityAdapter = this.chatAdapter) != null) {
                        chatActivityAdapter.notifyItemRangeChanged(indexOf4 + chatActivityAdapter.messagesStartRow, groupedMessages3.messages.size());
                        ChatListItemAnimator chatListItemAnimator = this.chatListItemAnimator;
                        if (chatListItemAnimator != null) {
                            chatListItemAnimator.groupWillChanged(groupedMessages3);
                        }
                    }
                }
            }
        }
        updatePinnedTopicStarterMessage();
    }

    private void requestLinkPreview(TL_account.getWebPagePreview getwebpagepreview, final Utilities.Callback2 callback2) {
        cancelSearchLinks();
        this.linkSearchRequestId = getConnectionsManager().sendRequest(getwebpagepreview, new RequestDelegate() {
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                ChatActivity.this.lambda$requestLinkPreview$139(callback2, tLObject, tL_error);
            }
        });
        getConnectionsManager().bindRequestToGuid(this.linkSearchRequestId, ((BaseFragment) this).classGuid);
    }

    private void requestLinkPreviewCached(final TL_account.getWebPagePreview getwebpagepreview, final Utilities.Callback2 callback2) {
        if (this.lastLinkPreviewResults == null) {
            this.lastLinkPreviewResults = new HashMap();
        }
        TLRPC.WebPage webPage = (TLRPC.WebPage) this.lastLinkPreviewResults.get(getwebpagepreview.message);
        if (webPage != null) {
            callback2.run(Boolean.TRUE, webPage);
        } else {
            requestLinkPreview(getwebpagepreview, new Utilities.Callback2() {
                public final void run(Object obj, Object obj2) {
                    ChatActivity.this.lambda$requestLinkPreviewCached$133(getwebpagepreview, callback2, (Boolean) obj, (TLRPC.WebPage) obj2);
                }
            });
        }
    }

    public void resetProgressDialogLoading() {
        this.progressDialogLinkSpan = null;
        this.progressDialogAtMessageId = 0;
        this.progressDialogAtMessageType = -1;
        this.progressDialogBotButtonUrl = null;
        this.progressDialogCurrent = null;
        setPagedownLoading(false, true);
    }

    private void rotateMotionBackgroundDrawable() {
        MotionBackgroundDrawable motionBackgroundDrawable;
        ThemeDelegate themeDelegate = this.themeDelegate;
        if (themeDelegate == null) {
            return;
        }
        Drawable wallpaperDrawable = themeDelegate.getWallpaperDrawable();
        SizeNotifierFrameLayout sizeNotifierFrameLayout = ((BaseFragment) this).fragmentView;
        if (sizeNotifierFrameLayout != null) {
            wallpaperDrawable = sizeNotifierFrameLayout.getBackgroundImage();
        }
        if (wallpaperDrawable instanceof ChatBackgroundDrawable) {
            wallpaperDrawable = ((ChatBackgroundDrawable) wallpaperDrawable).getDrawable(true);
        }
        if (wallpaperDrawable instanceof MotionBackgroundDrawable) {
            ((MotionBackgroundDrawable) wallpaperDrawable).switchToNextPosition();
        }
        Drawable themedDrawable = getThemedDrawable("drawableMsgOut");
        if (!(themedDrawable instanceof Theme.MessageDrawable) || (motionBackgroundDrawable = ((Theme.MessageDrawable) themedDrawable).getMotionBackgroundDrawable()) == null) {
            return;
        }
        motionBackgroundDrawable.switchToNextPosition();
    }

    private void runCloseInstantCameraAnimation() {
        InstantCameraView instantCameraView = this.instantCameraView;
        if (instantCameraView == null) {
            return;
        }
        instantCameraView.cancelBlur();
        InstantCameraView.InstantViewCameraContainer cameraContainer = this.instantCameraView.getCameraContainer();
        AnimatorSet animatorSet = new AnimatorSet();
        ObjectAnimator ofFloat = ObjectAnimator.ofFloat(cameraContainer, (Property<InstantCameraView.InstantViewCameraContainer, Float>) View.SCALE_X, 0.5f);
        ObjectAnimator ofFloat2 = ObjectAnimator.ofFloat(cameraContainer, (Property<InstantCameraView.InstantViewCameraContainer, Float>) View.SCALE_Y, 0.5f);
        Property property = View.ALPHA;
        animatorSet.playTogether(ofFloat, ofFloat2, ObjectAnimator.ofFloat(cameraContainer, (Property<InstantCameraView.InstantViewCameraContainer, Float>) property, 0.0f), ObjectAnimator.ofFloat(this.instantCameraView.getSwitchButtonView(), (Property<View, Float>) property, 0.0f), ObjectAnimator.ofFloat(this.instantCameraView.getFlashButtonView(), (Property<View, Float>) property, 0.0f), ObjectAnimator.ofInt(this.instantCameraView.getPaint(), (Property<Paint, Integer>) AnimationProperties.PAINT_ALPHA, 0), ObjectAnimator.ofFloat(this.instantCameraView.getMuteImageView(), (Property<View, Float>) property, 0.0f));
        animatorSet.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animator) {
                InstantCameraView instantCameraView2 = ChatActivity.this.instantCameraView;
                if (instantCameraView2 != null) {
                    instantCameraView2.setIsMessageTransition(false);
                    ChatActivity.this.instantCameraView.hideCamera(true);
                    ChatActivity.this.instantCameraView.setVisibility(4);
                }
            }
        });
        animatorSet.start();
    }

    private void saveMessageToGallery(MessageObject messageObject) {
        File pathToAttach;
        VideoPlayer.VideoUri videoUri;
        File pathToMessage;
        String str = messageObject.messageOwner.attachPath;
        if (!TextUtils.isEmpty(str) && !new File(str).exists()) {
            str = null;
        }
        if (TextUtils.isEmpty(str) && (pathToMessage = FileLoader.getInstance(((BaseFragment) this).currentAccount).getPathToMessage(messageObject.messageOwner)) != null && pathToMessage.exists()) {
            str = pathToMessage.getPath();
        }
        if (TextUtils.isEmpty(str) && (videoUri = messageObject.cachedQuality) != null && videoUri.isCached()) {
            File file = new File(messageObject.cachedQuality.uri.getPath());
            if (file.exists()) {
                str = file.getPath();
            }
        }
        if (TextUtils.isEmpty(str) && messageObject.qualityToSave != null && (pathToAttach = FileLoader.getInstance(((BaseFragment) this).currentAccount).getPathToAttach(messageObject.qualityToSave, (String) null, false, true)) != null && pathToAttach.exists()) {
            str = pathToAttach.getPath();
        }
        if (TextUtils.isEmpty(str)) {
            return;
        }
        MediaController.saveFile(str, getParentActivity(), messageObject.isVideo() ? 1 : 0, (String) null, (String) null);
    }

    private boolean saveScrollOnFilterToggle(boolean r26, boolean r27) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.saveScrollOnFilterToggle(boolean, boolean):boolean");
    }

    private int scrollOffsetForQuote(org.telegram.messenger.MessageObject r10) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.scrollOffsetForQuote(org.telegram.messenger.MessageObject):int");
    }

    private void searchUserMessages(TLRPC.User user, TLRPC.Chat chat) {
        String str;
        this.searchingUserMessages = user;
        this.searchingChatMessages = chat;
        if (this.searchItem == null || this.mentionContainer == null) {
            return;
        }
        if (user == null && chat == null) {
            return;
        }
        if (user != null) {
            str = user.first_name;
            if (TextUtils.isEmpty(str)) {
                str = this.searchingUserMessages.last_name;
            }
        } else {
            str = chat.title;
        }
        if (str == null) {
            return;
        }
        if (str.length() > 10) {
            str = str.substring(0, 10);
        }
        this.searchingForUser = false;
        String string = LocaleController.getString(R.string.SearchFrom);
        SpannableString spannableString = new SpannableString(string + " " + str);
        spannableString.setSpan(new ForegroundColorSpan(getThemedColor(Theme.key_actionBarDefaultSubtitle)), string.length() + 1, spannableString.length(), 33);
        this.searchItem.setSearchFieldCaption(spannableString);
        this.mentionContainer.getAdapter().lambda$searchUsernameOrHashtag$7(null, 0, null, false, true);
        this.searchItem.setSearchFieldHint(null);
        this.searchItem.clearSearchText();
        MediaDataController mediaDataController = getMediaDataController();
        this.searchingQuery = "";
        mediaDataController.searchMessagesInChat("", this.dialog_id, this.mergeDialogId, ((BaseFragment) this).classGuid, 0, this.threadMessageId, this.searchingUserMessages, this.searchingChatMessages, this.searchingReaction);
    }

    public void sendBotInlineResult(TLRPC.BotInlineResult botInlineResult, boolean z, int i, long j) {
        MentionsContainerView mentionsContainerView = this.mentionContainer;
        if (mentionsContainerView == null) {
            return;
        }
        long contextBotId = mentionsContainerView.getAdapter().getContextBotId();
        HashMap hashMap = new HashMap();
        hashMap.put("id", botInlineResult.id);
        hashMap.put("query_id", "" + botInlineResult.query_id);
        hashMap.put("bot", "" + contextBotId);
        hashMap.put("bot_name", this.mentionContainer.getAdapter().getContextBotName());
        SendMessagesHelper.prepareSendingBotContextResult(this, getAccountInstance(), botInlineResult, hashMap, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TL_stories.StoryItem) null, this.replyingQuote, z, i, this.quickReplyShortcut, getQuickReplyId(), j);
        this.chatActivityEnterView.setFieldText("");
        hideFieldPanel(false);
        getMediaDataController().increaseInlineRating(contextBotId);
    }

    public void sendPhotosGroup(ArrayList arrayList, boolean z, int i, boolean z2) {
        String str;
        if (!arrayList.isEmpty()) {
            ArrayList arrayList2 = new ArrayList();
            Iterator it = arrayList.iterator();
            while (it.hasNext()) {
                MediaController.PhotoEntry photoEntry = (MediaController.PhotoEntry) it.next();
                SendMessagesHelper.SendingMediaInfo sendingMediaInfo = new SendMessagesHelper.SendingMediaInfo();
                boolean z3 = photoEntry.isVideo;
                if ((!z3 && (str = ((MediaController.MediaEditState) photoEntry).imagePath) != null) || (str = photoEntry.path) != null) {
                    sendingMediaInfo.path = str;
                }
                sendingMediaInfo.thumbPath = ((MediaController.MediaEditState) photoEntry).thumbPath;
                sendingMediaInfo.coverPath = ((MediaController.MediaEditState) photoEntry).coverPath;
                sendingMediaInfo.isVideo = z3;
                CharSequence charSequence = ((MediaController.MediaEditState) photoEntry).caption;
                sendingMediaInfo.caption = charSequence != null ? charSequence.toString() : null;
                sendingMediaInfo.entities = ((MediaController.MediaEditState) photoEntry).entities;
                sendingMediaInfo.masks = ((MediaController.MediaEditState) photoEntry).stickers;
                sendingMediaInfo.ttl = ((MediaController.MediaEditState) photoEntry).ttl;
                sendingMediaInfo.videoEditedInfo = ((MediaController.MediaEditState) photoEntry).editedInfo;
                sendingMediaInfo.canDeleteAfter = photoEntry.canDeleteAfter;
                arrayList2.add(sendingMediaInfo);
                photoEntry.reset();
            }
            fillEditingMediaWithCaption(((SendMessagesHelper.SendingMediaInfo) arrayList2.get(0)).caption, ((SendMessagesHelper.SendingMediaInfo) arrayList2.get(0)).entities);
            SendMessagesHelper.prepareSendingMedia(getAccountInstance(), arrayList2, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TL_stories.StoryItem) null, this.replyingQuote, z2, true, (MessageObject) null, z, i, this.chatMode, ((SendMessagesHelper.SendingMediaInfo) arrayList2.get(0)).updateStickersOrder, (InputContentInfoCompat) null, this.quickReplyShortcut, getQuickReplyId(), 0L, false, 0L, getSendMonoForumPeerId(), this.messageSuggestionParams);
            afterMessageSend();
            ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
            if (chatActivityEnterView != null) {
                chatActivityEnterView.setFieldText("");
            }
        }
        if (i != 0) {
            if (this.scheduledMessagesCount == -1) {
                this.scheduledMessagesCount = 0;
            }
            this.scheduledMessagesCount += arrayList.size();
            updateScheduledInterface(true);
        }
    }

    public Runnable sendSecretMediaDelete(final MessageObject messageObject) {
        if (messageObject == null || messageObject.isOut() || !messageObject.isSecretMedia() || messageObject.messageOwner.ttl != Integer.MAX_VALUE) {
            return null;
        }
        final long createDeleteShowOnceTask = getMessagesController().createDeleteShowOnceTask(this.dialog_id, messageObject.getId());
        messageObject.forceExpired = true;
        if (messageObject.isOutOwner() || (!messageObject.isRoundOnce() && !messageObject.isVoiceOnce())) {
            ArrayList arrayList = new ArrayList();
            arrayList.add(messageObject);
            updateMessages(arrayList, true);
        }
        return new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$sendSecretMediaDelete$144(createDeleteShowOnceTask, messageObject);
            }
        };
    }

    public Runnable sendSecretMessageRead(final MessageObject messageObject, boolean z) {
        int i;
        if (messageObject == null || messageObject.isOut() || !messageObject.isSecretMedia()) {
            return null;
        }
        TLRPC.Message message = messageObject.messageOwner;
        if (message.destroyTime != 0 || (i = message.ttl) <= 0) {
            return null;
        }
        if (!z) {
            return new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$sendSecretMessageRead$143(messageObject);
                }
            };
        }
        boolean z2 = i != Integer.MAX_VALUE;
        if (i == Integer.MAX_VALUE) {
            i = 0;
        }
        message.destroyTime = getConnectionsManager().getCurrentTime() + i;
        if (this.currentEncryptedChat != null) {
            getMessagesController().markMessageAsRead(this.dialog_id, messageObject.messageOwner.random_id, i);
        } else {
            getMessagesController().markMessageAsRead2(this.dialog_id, messageObject.getId(), (TLRPC.InputChannel) null, i, 0L, z2);
        }
        return null;
    }

    private void sendUriAsDocument(Uri uri) {
        sendUriAsDocument(uri, true, 0);
    }

    private void sendUriAsDocument(android.net.Uri r29, boolean r30, int r31) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.sendUriAsDocument(android.net.Uri, boolean, int):void");
    }

    public void setCellSelectionBackground(MessageObject messageObject, ChatMessageCell chatMessageCell, int i, boolean z) {
        MessageObject.GroupedMessages validGroupedMessage = getValidGroupedMessage(messageObject);
        if (validGroupedMessage != null) {
            int i2 = 0;
            while (true) {
                if (i2 >= validGroupedMessage.messages.size()) {
                    validGroupedMessage = null;
                    break;
                } else if (this.selectedMessagesIds[i].indexOfKey(((MessageObject) validGroupedMessage.messages.get(i2)).getId()) < 0) {
                    break;
                } else {
                    i2++;
                }
            }
        }
        chatMessageCell.setDrawSelectionBackground(validGroupedMessage == null);
        chatMessageCell.setChecked(true, validGroupedMessage == null, z);
    }

    private void setChatThemeEmoticon(String str) {
        if (this.themeDelegate == null || this.parentThemeDelegate != null) {
            return;
        }
        ChatThemeController chatThemeController = ChatThemeController.getInstance(((BaseFragment) this).currentAccount);
        chatThemeController.setDialogTheme(this.dialog_id, str, false);
        if (!TextUtils.isEmpty(str)) {
            chatThemeController.requestChatTheme(str, new ResultCallback() {
                public final void onComplete(Object obj) {
                    ChatActivity.this.lambda$setChatThemeEmoticon$388((EmojiThemes) obj);
                }

                public void onError(TLRPC.TL_error tL_error) {
                    ResultCallback.-CC.$default$onError(this, tL_error);
                }
            });
        }
        TLRPC.WallPaper dialogWallpaper = chatThemeController.getDialogWallpaper(this.dialog_id);
        ThemeDelegate themeDelegate = this.themeDelegate;
        themeDelegate.setCurrentTheme(themeDelegate.chatTheme, dialogWallpaper, this.openAnimationStartTime != 0, null);
    }

    private void setChildrenEnabled(View view, boolean z) {
        if (view instanceof ViewGroup) {
            ViewGroup viewGroup = (ViewGroup) view;
            for (int i = 0; i < viewGroup.getChildCount(); i++) {
                setChildrenEnabled(viewGroup.getChildAt(i), z);
            }
        }
        if (view == this.chatListView || view == this.contentView) {
            return;
        }
        view.setEnabled(z);
    }

    public void setFilterMessages(boolean z) {
        setFilterMessages(z, false, true);
    }

    public void setFilterMessages(boolean z, boolean z2, boolean z3) {
        ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
        if (chatActivityAdapter == null || chatActivityAdapter.isFiltered == z) {
            return;
        }
        chatActivityAdapter.isFiltered = z;
        boolean z4 = true;
        createEmptyView(true);
        if (z) {
            updateFilteredMessages(false);
        }
        if (!saveScrollOnFilterToggle(z3, z2)) {
            this.chatAdapter.isFiltered = !z;
        }
        AnimatedTextView animatedTextView = this.searchOtherButton;
        if (animatedTextView != null) {
            animatedTextView.setText(LocaleController.getString(this.chatAdapter.isFiltered ? R.string.SavedTagShowOtherMessages : R.string.SavedTagHideOtherMessages));
        }
        updateSearchUpDownButtonVisibility(true);
        if (this.chatAdapter.isFiltered ? !getMediaDataController().isSearchLoading() || !this.chatAdapter.filteredMessages.isEmpty() : !this.loading || !this.messages.isEmpty() || this.chatAdapter.botInfoRow >= 0) {
            z4 = false;
        }
        showProgressView(z4);
        if (this.chatListView != null) {
            createEmptyView(false);
            if (this.chatAdapter.isFiltered ? getMediaDataController().isSearchLoading() || !this.chatAdapter.filteredMessages.isEmpty() : this.loading || !this.messages.isEmpty() || this.chatAdapter.botInfoRow >= 0) {
                this.emptyViewContainer.setVisibility(8);
                this.chatListView.setEmptyView((View) null);
            } else {
                this.chatListView.setEmptyView(this.emptyViewContainer);
                this.chatListView.checkIfEmpty();
            }
        }
    }

    private void setPagedownLoading(final boolean z, boolean z2) {
        if (!z2 || Math.abs(this.pagedownLoadingT - (z ? 1.0f : 0.0f)) <= 0.01f) {
            if (z) {
                this.pagedownButtonArrow.setScaleX(0.0f);
                this.pagedownButtonArrow.setScaleY(0.0f);
                this.pagedownButtonArrow.setVisibility(8);
                this.pagedownButtonLoading.setVisibility(0);
                return;
            }
            this.pagedownButtonArrow.setScaleX(1.0f);
            this.pagedownButtonArrow.setScaleY(1.0f);
            this.pagedownButtonArrow.setVisibility(0);
            this.pagedownButtonLoading.setVisibility(8);
            return;
        }
        ValueAnimator valueAnimator = this.pagedownAnimator;
        if (valueAnimator != null) {
            valueAnimator.cancel();
        }
        final boolean[] zArr = new boolean[1];
        this.pagedownButtonArrow.setVisibility(0);
        ValueAnimator ofFloat = ValueAnimator.ofFloat(this.pagedownLoadingT, z ? 1.0f : 0.0f);
        this.pagedownAnimator = ofFloat;
        ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public final void onAnimationUpdate(ValueAnimator valueAnimator2) {
                ChatActivity.this.lambda$setPagedownLoading$114(zArr, z, valueAnimator2);
            }
        });
        this.pagedownAnimator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animator) {
                int i = 8;
                if (z) {
                    ChatActivity.this.pagedownButtonArrow.setVisibility(8);
                    i = 0;
                    if (zArr[0]) {
                        return;
                    } else {
                        ChatActivity.this.pagedownButtonLoadingDrawable.reset();
                    }
                }
                ChatActivity.this.pagedownButtonLoading.setVisibility(i);
            }
        });
        this.pagedownAnimator.setInterpolator(CubicBezierInterpolator.EASE_OUT);
        this.pagedownAnimator.setDuration(260L);
        this.pagedownAnimator.start();
    }

    private void setPullingDownTransition(boolean z) {
        this.fromPullingDownTransition = z;
    }

    public void setScrimView(View view) {
        View view2 = this.scrimView;
        if (view2 == view) {
            return;
        }
        if (view2 != null && (view2 instanceof ChatActionCell)) {
            ((ChatActionCell) view2).setInvalidateWithParent(null);
        }
        this.scrimView = view;
        if (view instanceof ChatActionCell) {
            ((ChatActionCell) view).setInvalidateWithParent(((BaseFragment) this).fragmentView);
        }
    }

    public void setTransitionToChatActivity(ChatActivity chatActivity) {
        this.pullingDownAnimateToActivity = chatActivity;
    }

    public void setTransitionToChatProgress(float f) {
        this.pullingDownAnimateProgress = f;
        ((BaseFragment) this).fragmentView.invalidate();
        this.chatListView.invalidate();
    }

    public void share() {
        MessageObject messageObject = null;
        for (int i = 1; i >= 0; i--) {
            if (messageObject == null && this.selectedMessagesIds[i].size() != 0) {
                messageObject = (MessageObject) this.messagesDict[i].get(this.selectedMessagesIds[i].keyAt(0));
            }
            this.selectedMessagesIds[i].clear();
            this.selectedMessagesCanCopyIds[i].clear();
            this.selectedMessagesCanStarIds[i].clear();
        }
        if (getParentActivity() != null && messageObject != null && ((messageObject.isVoice() || messageObject.isRoundVideo()) && messageObject.getDocument() != null)) {
            File pathToAttach = FileLoader.getInstance(((BaseFragment) this).currentAccount).getPathToAttach(messageObject.getDocument(), (String) null, false, true);
            TLRPC.Message message = messageObject.messageOwner;
            if (message != null && message.attachPath != null && (pathToAttach == null || !pathToAttach.exists())) {
                pathToAttach = new File(messageObject.messageOwner.attachPath);
            }
            if (pathToAttach != null && pathToAttach.exists()) {
                Intent intent = new Intent("android.intent.action.SEND");
                intent.setType((messageObject.isVideo() || messageObject.isRoundVideo()) ? "video/mp4" : messageObject.getMimeType());
                if (Build.VERSION.SDK_INT >= 24) {
                    try {
                        intent.putExtra("android.intent.extra.STREAM", FileProvider.getUriForFile(getParentActivity(), ApplicationLoader.getApplicationId() + ".provider", pathToAttach));
                        intent.setFlags(1);
                    } catch (Exception unused) {
                    }
                    getParentActivity().startActivityForResult(Intent.createChooser(intent, LocaleController.getString(R.string.ShareFile)), 500);
                }
                intent.putExtra("android.intent.extra.STREAM", Uri.fromFile(pathToAttach));
                getParentActivity().startActivityForResult(Intent.createChooser(intent, LocaleController.getString(R.string.ShareFile)), 500);
            }
        }
        hideActionMode();
        updatePinnedMessageView(true);
        updateVisibleRows();
        updateSelectedMessageReactions();
    }

    private boolean shouldDisplaySwipeToLeftToReplyInForum() {
        return isForumInViewAsMessagesMode() && this.replyingMessageObject == null && this.editingMessageObject == null && !canSendMessageToGeneralTopic();
    }

    private void showAttachmentError() {
        if (getParentActivity() == null) {
            return;
        }
        BulletinFactory.of(this).createErrorBulletin(LocaleController.getString(R.string.UnsupportedAttachment), this.themeDelegate).show();
    }

    public void showBotMessageHint(final ChatMessageCell chatMessageCell, boolean z) {
        if (getContext() == null || chatMessageCell == null || chatMessageCell.timeLayout == null || chatMessageCell.getPrimaryMessageObject() == null || chatMessageCell.getPrimaryMessageObject().messageOwner == null || chatMessageCell.getPrimaryMessageObject().messageOwner.via_business_bot_id == 0) {
            return;
        }
        if (!z) {
            if (getMessagesController().getMainSettings().getBoolean("bizbothint", false)) {
                return;
            }
            getMessagesController().getMainSettings().edit().putBoolean("bizbothint", true).apply();
            if (this.bizbothint) {
                return;
            } else {
                this.bizbothint = true;
            }
        }
        final HintView2 hintView2 = this.botMessageHint;
        if (hintView2 != null) {
            if (!z) {
                return;
            }
            hintView2.setOnHiddenListener(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$showBotMessageHint$75(hintView2);
                }
            });
            hintView2.hide();
            this.botMessageHint = null;
        }
        HintView2 rounding = new HintView2(getContext(), 3).setMultilineText(true).setTextAlign(Layout.Alignment.ALIGN_NORMAL).setDuration(-1L).setHideByTouch(true).useScale(true).setCloseButton(true).setRounding(8.0f);
        this.botMessageHint = rounding;
        rounding.setText(AndroidUtilities.replaceTags(LocaleController.getString(R.string.MessageBizBot)));
        HintView2 hintView22 = this.botMessageHint;
        hintView22.setMaxWidthPx(HintView2.cutInFancyHalf(hintView22.getText(), this.botMessageHint.getTextPaint()));
        this.contentView.addView(this.botMessageHint, LayoutHelper.createFrame(-1, 120.0f, 55, 16.0f, 0.0f, 16.0f, 0.0f));
        this.contentView.post(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$showBotMessageHint$76(chatMessageCell);
            }
        });
    }

    public void showBusinessLinksDiscardAlert(final Runnable runnable) {
        AlertDialog create = new AlertDialog.Builder(getContext(), getResourceProvider()).setTitle(LocaleController.getString(R.string.BusinessLinkDiscardChangesTitle)).setMessage(LocaleController.getString(R.string.BusinessLinkDiscardChangesMessage)).setPositiveButton(LocaleController.getString(R.string.Discard), new AlertDialog.OnButtonClickListener() {
            @Override
            public final void onClick(AlertDialog alertDialog, int i) {
                runnable.run();
            }
        }).setNegativeButton(LocaleController.getString(R.string.Cancel), null).create();
        showDialog(create);
        TextView textView = (TextView) create.getButton(-1);
        if (textView != null) {
            textView.setTextColor(getThemedColor(Theme.key_text_RedBold));
        }
    }

    public void showChatThemeBottomSheet() {
        ChannelColorActivity channelColorActivity;
        TLRPC.Chat chat = this.currentChat;
        if (chat == null) {
            this.chatThemeBottomSheet = new ChatThemeBottomSheet(this, this.themeDelegate);
            this.chatListView.setOnInterceptTouchListener(new RecyclerListView.OnInterceptTouchListener() {
                public final boolean onInterceptTouchEvent(MotionEvent motionEvent) {
                    boolean lambda$showChatThemeBottomSheet$385;
                    lambda$showChatThemeBottomSheet$385 = ChatActivity.lambda$showChatThemeBottomSheet$385(motionEvent);
                    return lambda$showChatThemeBottomSheet$385;
                }
            });
            setChildrenEnabled(this.contentView, false);
            showDialog(this.chatThemeBottomSheet, new DialogInterface.OnDismissListener() {
                @Override
                public final void onDismiss(DialogInterface dialogInterface) {
                    ChatActivity.this.lambda$showChatThemeBottomSheet$386(dialogInterface);
                }
            });
            return;
        }
        if (ChatObject.isMegagroup(chat)) {
            if (!ChatObject.hasAdminRights(this.currentChat)) {
                return;
            } else {
                channelColorActivity = new GroupColorActivity(getDialogId());
            }
        } else if (!ChatObject.canChangeChatInfo(this.currentChat)) {
            return;
        } else {
            channelColorActivity = new ChannelColorActivity(getDialogId());
        }
        presentFragment(channelColorActivity.setOnApplied(this));
    }

    public void showChecksHint() {
        ChatMessageCell chatMessageCell;
        MessageObject messageObject;
        if (this.scrollingChatListView || this.chatListView == null || getParentActivity() == null || ((BaseFragment) this).fragmentView == null) {
            return;
        }
        ChecksHintView checksHintView = this.checksHintView;
        if (checksHintView == null || checksHintView.getTag() == null) {
            if (this.checksHintView == null) {
                SizeNotifierFrameLayout sizeNotifierFrameLayout = ((BaseFragment) this).fragmentView;
                int indexOfChild = sizeNotifierFrameLayout.indexOfChild(this.chatActivityEnterView);
                if (indexOfChild == -1) {
                    return;
                }
                ChecksHintView checksHintView2 = new ChecksHintView(getParentActivity(), this.themeDelegate);
                this.checksHintView = checksHintView2;
                sizeNotifierFrameLayout.addView(checksHintView2, indexOfChild + 1, LayoutHelper.createFrame(-2, -2.0f, 51, 10.0f, 0.0f, 10.0f, 0.0f));
                this.checksHintView.setAlpha(0.0f);
                this.checksHintView.setVisibility(4);
            }
            int childCount = this.chatListView.getChildCount();
            for (int i = 0; i < childCount; i++) {
                View childAt = this.chatListView.getChildAt(i);
                if ((childAt instanceof ChatMessageCell) && (messageObject = (chatMessageCell = (ChatMessageCell) childAt).getMessageObject()) != null && messageObject.isOutOwner() && messageObject.isSent() && this.checksHintView.showForMessageCell(chatMessageCell, true)) {
                    getMessagesController().removeSuggestion(0L, "NEWCOMER_TICKS");
                    return;
                }
            }
        }
    }

    public void showFloatingDateView(boolean z) {
        ChatActionCell chatActionCell = this.floatingDateView;
        if (chatActionCell == null || this.chatMode == 5) {
            return;
        }
        if (chatActionCell.getTag() == null) {
            AnimatorSet animatorSet = this.floatingDateAnimation;
            if (animatorSet != null) {
                animatorSet.cancel();
            }
            this.floatingDateView.setTag(1);
            AnimatorSet animatorSet2 = new AnimatorSet();
            this.floatingDateAnimation = animatorSet2;
            animatorSet2.setDuration(150L);
            this.floatingDateAnimation.playTogether(ObjectAnimator.ofFloat(this.floatingDateView, (Property<ChatActionCell, Float>) View.ALPHA, 1.0f));
            this.floatingDateAnimation.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animator) {
                    if (animator.equals(ChatActivity.this.floatingDateAnimation)) {
                        ChatActivity.this.floatingDateAnimation = null;
                    }
                }
            });
            this.floatingDateAnimation.start();
        }
        if (z) {
            return;
        }
        invalidateMessagesVisiblePart();
        this.hideDateDelay = 1000;
    }

    public void showFloatingTopicView(boolean z) {
        TopicSeparator.Cell cell = this.floatingTopicSeparator;
        if (cell == null || this.chatMode == 5) {
            return;
        }
        if (cell.getTag() == null) {
            ValueAnimator valueAnimator = this.floatingTopicAnimation;
            if (valueAnimator != null) {
                valueAnimator.cancel();
            }
            this.floatingTopicSeparator.setTag(1);
            ValueAnimator ofFloat = ValueAnimator.ofFloat(this.floatingTopicViewAlpha, 1.0f);
            this.floatingTopicAnimation = ofFloat;
            ofFloat.setDuration(150L);
            this.floatingTopicAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public final void onAnimationUpdate(ValueAnimator valueAnimator2) {
                    ChatActivity.this.lambda$showFloatingTopicView$122(valueAnimator2);
                }
            });
            this.floatingTopicAnimation.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animator) {
                    if (animator.equals(ChatActivity.this.floatingTopicAnimation)) {
                        ChatActivity.this.floatingTopicViewAlpha = 1.0f;
                        ChatActivity.this.updateFloatingTopicView();
                        ChatActivity.this.floatingTopicAnimation = null;
                    }
                }
            });
            this.floatingTopicAnimation.start();
        }
        if (z) {
            return;
        }
        invalidateMessagesVisiblePart();
        this.hideDateDelay = 1000;
    }

    public void showForwardHint(ChatMessageCell chatMessageCell) {
        SizeNotifierFrameLayout sizeNotifierFrameLayout;
        if (this.scrollingChatListView || this.chatListView == null || getParentActivity() == null || (sizeNotifierFrameLayout = ((BaseFragment) this).fragmentView) == null) {
            return;
        }
        if (this.forwardHintView == null) {
            SizeNotifierFrameLayout sizeNotifierFrameLayout2 = sizeNotifierFrameLayout;
            int indexOfChild = sizeNotifierFrameLayout2.indexOfChild(this.chatActivityEnterView);
            if (indexOfChild == -1) {
                return;
            }
            HintView hintView = new HintView(getParentActivity(), 1, this.themeDelegate);
            this.forwardHintView = hintView;
            sizeNotifierFrameLayout2.addView(hintView, indexOfChild + 1, LayoutHelper.createFrame(-2, -2.0f, 51, 19.0f, 0.0f, 19.0f, 0.0f));
            this.forwardHintView.setAlpha(0.0f);
            this.forwardHintView.setVisibility(4);
        }
        this.forwardHintView.showForMessageCell(chatMessageCell, true);
    }

    private boolean showGifHint() {
        SizeNotifierFrameLayout sizeNotifierFrameLayout;
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView != null && chatActivityEnterView.getVisibility() == 0) {
            SharedPreferences globalMainSettings = MessagesController.getGlobalMainSettings();
            if (globalMainSettings.getBoolean("gifhint", false)) {
                return false;
            }
            globalMainSettings.edit().putBoolean("gifhint", true).commit();
            if (getParentActivity() != null && (sizeNotifierFrameLayout = ((BaseFragment) this).fragmentView) != null && this.gifHintTextView == null) {
                if (!this.allowContextBotPanelSecond) {
                    ChatActivityEnterView chatActivityEnterView2 = this.chatActivityEnterView;
                    if (chatActivityEnterView2 != null) {
                        chatActivityEnterView2.setOpenGifsTabFirst();
                    }
                    return false;
                }
                SizeNotifierFrameLayout sizeNotifierFrameLayout2 = sizeNotifierFrameLayout;
                int indexOfChild = sizeNotifierFrameLayout2.indexOfChild(this.chatActivityEnterView);
                if (indexOfChild == -1) {
                    return false;
                }
                this.chatActivityEnterView.setOpenGifsTabFirst();
                View view = new View(getParentActivity());
                this.emojiButtonRed = view;
                view.setBackgroundResource(R.drawable.redcircle);
                int i = indexOfChild + 1;
                sizeNotifierFrameLayout2.addView(this.emojiButtonRed, i, LayoutHelper.createFrame(10, 10.0f, 83, 30.0f, 0.0f, 0.0f, 27.0f));
                HintView hintView = new HintView(getParentActivity(), 9, this.themeDelegate);
                this.gifHintTextView = hintView;
                hintView.setText(LocaleController.getString(R.string.TapHereGifs));
                sizeNotifierFrameLayout2.addView(this.gifHintTextView, i, LayoutHelper.createFrame(-2, -2.0f, 83, 5.0f, 0.0f, 5.0f, 3.0f));
                AnimatorSet animatorSet = new AnimatorSet();
                HintView hintView2 = this.gifHintTextView;
                Property property = View.ALPHA;
                animatorSet.playTogether(ObjectAnimator.ofFloat(hintView2, (Property<HintView, Float>) property, 0.0f, 1.0f), ObjectAnimator.ofFloat(this.emojiButtonRed, (Property<View, Float>) property, 0.0f, 1.0f));
                animatorSet.addListener(new AnonymousClass90());
                animatorSet.setDuration(300L);
                animatorSet.start();
                View emojiButton = this.chatActivityEnterView.getEmojiButton();
                if (emojiButton != null) {
                    this.gifHintTextView.showForView(emojiButton, true);
                }
                return true;
            }
        }
        return false;
    }

    private void showGiftButton(boolean z, boolean z2) {
        if (getContext() == null) {
            return;
        }
        ImageView imageView = this.bottomGiftButton;
        boolean z3 = imageView != null && imageView.getAlpha() > 0.5f;
        if (this.bottomGiftButton == null) {
            ImageView imageView2 = new ImageView(getContext());
            this.bottomGiftButton = imageView2;
            imageView2.setImageResource(R.drawable.input_gift_s);
            this.bottomGiftButton.setScaleType(ImageView.ScaleType.CENTER);
            ImageView imageView3 = this.bottomGiftButton;
            int i = Theme.key_chat_fieldOverlayText;
            imageView3.setColorFilter(new PorterDuffColorFilter(getThemedColor(i), PorterDuff.Mode.SRC_IN));
            this.bottomOverlayChat.addView(this.bottomGiftButton, LayoutHelper.createFrame(48, 48, 21));
            this.bottomGiftButton.setBackground(Theme.createSelectorDrawable(Theme.multAlpha(getThemedColor(i), 0.1f), 1));
            this.bottomGiftButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    ChatActivity.this.lambda$showGiftButton$220(view);
                }
            });
            this.bottomGiftButton.setContentDescription(LocaleController.getString(R.string.Gift2ChannelSend));
            ScaleStateListAnimator.apply(this.bottomGiftButton);
        }
        AndroidUtilities.updateViewShow(this.bottomGiftButton, z, true, z2);
        if (!z || z3 || this.bottomGiftHintView != null || MessagesController.getGlobalMainSettings().getInt("channelgifthint", 0) >= 2) {
            return;
        }
        HintView2 hintView2 = this.bottomSuggestHintView;
        if (hintView2 == null || !hintView2.shown()) {
            HintView2 hintView22 = new HintView2(getContext(), 3);
            this.bottomGiftHintView = hintView22;
            hintView22.setPadding(AndroidUtilities.dp(7.33f), 0, AndroidUtilities.dp(7.33f), 0);
            this.bottomGiftHintView.setMultilineText(false);
            this.bottomGiftHintView.setText(LocaleController.getString(R.string.Gift2ChannelSendHint));
            this.bottomGiftHintView.setJoint(1.0f, -16.67f);
            this.contentView.addView(this.bottomGiftHintView, LayoutHelper.createFrame(-1, 100.0f, 87, 0.0f, 0.0f, 0.0f, 42.34f));
            this.bottomGiftHintView.setOnHiddenListener(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$showGiftButton$221();
                }
            });
            this.bottomGiftHintView.show();
            MessagesController.getGlobalMainSettings().edit().putInt("channelgifthint", MessagesController.getGlobalMainSettings().getInt("channelgifthint", 0) + 1).apply();
        }
    }

    private void showGigagroupConvertAlert() {
        TLRPC.ChatFull chatFull = this.chatInfo;
        if (chatFull == null || this.paused) {
            return;
        }
        TLRPC.Chat chat = this.currentChat;
        if (chat.creator && chat.megagroup && !chat.gigagroup && chatFull.pending_suggestions.contains("CONVERT_GIGAGROUP") && ((BaseFragment) this).visibleDialog == null) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$showGigagroupConvertAlert$198();
                }
            }, 1000L);
        }
    }

    private void showGreetInfo(boolean z) {
        TL_account.TL_businessIntro tL_businessIntro;
        boolean z2 = false;
        if (this.emptyViewContent == null) {
            return;
        }
        if (z && this.greetingsInfo == null) {
            ChatActionCell chatActionCell = new ChatActionCell(getContext(), z2, getResourceProvider()) {
                @Override
                protected void onLayout(boolean z3, int i, int i2, int i3, int i4) {
                    super.onLayout(z3, i, i2, i3, i4);
                    setVisiblePart(getY() + ChatActivity.this.emptyViewContent.getY(), ChatActivity.this.getServiceHeight(this));
                }
            };
            this.greetingsInfo = chatActionCell;
            ScaleStateListAnimator.apply(chatActionCell, 0.02f, 1.2f);
            this.greetingsInfo.setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    ChatActivity.this.lambda$showGreetInfo$307(view);
                }
            });
        }
        ChatActionCell chatActionCell2 = this.greetingsInfo;
        if (chatActionCell2 == null) {
            return;
        }
        if (!z) {
            chatActionCell2.setVisibility(8);
            return;
        }
        chatActionCell2.setVisibility(0);
        TLRPC.UserFull userFull = this.userInfo;
        String formatString = LocaleController.formatString((userFull == null || (tL_businessIntro = userFull.business_intro) == null || !TextUtils.isEmpty(tL_businessIntro.title) || !TextUtils.isEmpty(this.userInfo.business_intro.title)) ? R.string.GreetingHow : R.string.GreetingHowSticker, new Object[]{UserObject.getFirstName(this.currentUser)});
        int indexOf = formatString.indexOf("**");
        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(formatString);
        if (indexOf > 0) {
            formatString = formatString.substring(0, indexOf) + formatString.substring(indexOf + 2);
            int indexOf2 = formatString.indexOf("**");
            if (indexOf2 > 0) {
                formatString = formatString.substring(0, indexOf2) + formatString.substring(indexOf2 + 2);
                spannableStringBuilder = new SpannableStringBuilder(formatString);
                ProfileActivity.ShowDrawable showDrawable = new ProfileActivity.ShowDrawable(formatString.substring(indexOf, indexOf2));
                showDrawable.setTextColor(-1);
                showDrawable.setBackgroundColor(503316480);
                showDrawable.setBounds(0, 0, showDrawable.getIntrinsicWidth(), showDrawable.getIntrinsicHeight());
                spannableStringBuilder.setSpan(new ImageSpan(showDrawable), indexOf, indexOf2, 33);
            }
        }
        this.greetingsInfo.setCustomText(spannableStringBuilder);
        this.greetingsInfo.setOverrideTextMaxWidth(HintView2.cutInFancyHalf(formatString, (TextPaint) getThemedPaint("paintChatActionText")));
        if (this.greetingsInfo.getParent() != null && (!z || this.greetingsInfo.getParent() != this.emptyViewContent)) {
            ((ViewGroup) this.greetingsInfo.getParent()).removeView(this.greetingsInfo);
        }
        if (z) {
            ViewParent parent = this.greetingsInfo.getParent();
            LinearLayout linearLayout = this.emptyViewContent;
            if (parent != linearLayout) {
                linearLayout.addView(this.greetingsInfo, LayoutHelper.createLinear(-1, -2, 80, 0, 10, 0, 0));
            }
        }
    }

    public void showInfoHint(MessageObject messageObject, CharSequence charSequence, final int i) {
        BulletinFactory.of(this).createSimpleBulletin(R.raw.chats_infotip, charSequence, 9999).setDuration(Math.max(4000, Math.min(((charSequence == null ? 0 : charSequence.length()) / 50) * 1600, 10000))).setOnHideListener(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$showInfoHint$202(i);
            }
        }).show(true);
        this.hintMessageObject = messageObject;
        this.hintMessageType = i;
    }

    public void showMediaBannedHint() {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.showMediaBannedHint():void");
    }

    public void showMentionDownButton(boolean z, boolean z2) {
        ValueAnimator valueAnimator;
        AnimatorListenerAdapter animatorListenerAdapter;
        if (this.mentiondownButton == null) {
            return;
        }
        if (!z || ChatObject.isMonoForum(this.currentChat)) {
            this.returnToMessageId = 0;
            if (this.mentiondownButton.getTag() == null) {
                return;
            }
            this.mentiondownButton.setTag(null);
            ValueAnimator valueAnimator2 = this.mentiondownButtonAnimation;
            if (valueAnimator2 != null) {
                valueAnimator2.removeAllListeners();
                this.mentiondownButtonAnimation.cancel();
                this.mentiondownButtonAnimation = null;
            }
            if (!z2) {
                this.mentionsButtonEnterProgress = 0.0f;
                this.mentiondownButton.setVisibility(4);
                return;
            } else {
                ValueAnimator ofFloat = ValueAnimator.ofFloat(this.mentionsButtonEnterProgress, 0.0f);
                this.mentiondownButtonAnimation = ofFloat;
                ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                    @Override
                    public final void onAnimationUpdate(ValueAnimator valueAnimator3) {
                        ChatActivity.this.lambda$showMentionDownButton$161(valueAnimator3);
                    }
                });
                valueAnimator = this.mentiondownButtonAnimation;
                animatorListenerAdapter = new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animator) {
                        ChatActivity.this.mentionsButtonEnterProgress = 0.0f;
                        ChatActivity.this.mentiondownButton.setVisibility(4);
                        ChatActivity.this.contentView.invalidate();
                    }
                };
            }
        } else {
            if (this.mentiondownButton.getTag() != null) {
                return;
            }
            ValueAnimator valueAnimator3 = this.mentiondownButtonAnimation;
            if (valueAnimator3 != null) {
                valueAnimator3.removeAllListeners();
                this.mentiondownButtonAnimation.cancel();
                this.mentiondownButtonAnimation = null;
            }
            if (!z2) {
                this.mentionsButtonEnterProgress = 1.0f;
                this.contentView.invalidate();
                return;
            }
            this.mentiondownButton.setVisibility(0);
            this.mentiondownButton.setTag(1);
            ValueAnimator ofFloat2 = ValueAnimator.ofFloat(this.mentionsButtonEnterProgress, 1.0f);
            this.mentiondownButtonAnimation = ofFloat2;
            ofFloat2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public final void onAnimationUpdate(ValueAnimator valueAnimator4) {
                    ChatActivity.this.lambda$showMentionDownButton$160(valueAnimator4);
                }
            });
            valueAnimator = this.mentiondownButtonAnimation;
            animatorListenerAdapter = new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animator) {
                    ChatActivity.this.mentionsButtonEnterProgress = 1.0f;
                    ChatActivity.this.contentView.invalidate();
                }
            };
        }
        valueAnimator.addListener(animatorListenerAdapter);
        this.mentiondownButtonAnimation.setDuration(200L);
        this.mentiondownButtonAnimation.start();
    }

    public void showMessagesSearchListView(final boolean z) {
        FrameLayout frameLayout = this.messagesSearchListContainer;
        if (frameLayout != null) {
            if (!z || frameLayout.getTag() == null) {
                if (z || this.messagesSearchListContainer.getTag() != null) {
                    AnimatorSet animatorSet = this.messagesSearchListViewAnimation;
                    if (animatorSet != null) {
                        animatorSet.cancel();
                        this.messagesSearchListViewAnimation = null;
                    }
                    if (z) {
                        this.messagesSearchListContainer.setVisibility(0);
                    }
                    if (!z && this.chatMode == 7) {
                        LinearLayoutManager layoutManager = this.messagesSearchListView.getLayoutManager();
                        Object item = this.messagesSearchAdapter.getItem((layoutManager.findFirstVisibleItemPosition() + layoutManager.findLastVisibleItemPosition()) / 2);
                        Object item2 = this.messagesSearchAdapter.getItem(layoutManager.findFirstVisibleItemPosition());
                        Object item3 = this.messagesSearchAdapter.getItem(layoutManager.findLastVisibleItemPosition());
                        if (item != null && item2 != null && item3 != null) {
                            ArrayList messages = this.chatAdapter.getMessages();
                            int findFirstVisibleItemPosition = this.chatLayoutManager.findFirstVisibleItemPosition();
                            int findLastVisibleItemPosition = this.chatLayoutManager.findLastVisibleItemPosition();
                            int i = ((MessageObject) item).messageOwner.id;
                            int i2 = ((MessageObject) item2).messageOwner.id;
                            int i3 = ((MessageObject) item3).messageOwner.id;
                            boolean z2 = false;
                            boolean z3 = false;
                            int i4 = -1;
                            for (int i5 = 0; i5 < messages.size(); i5++) {
                                if (((MessageObject) messages.get(i5)).messageOwner.id == i2) {
                                    int i6 = this.chatAdapter.messagesStartRow + i5;
                                    z2 = findFirstVisibleItemPosition <= i6 && findLastVisibleItemPosition >= i6;
                                    if (z2) {
                                        break;
                                    }
                                }
                                if (((MessageObject) messages.get(i5)).messageOwner.id == i3) {
                                    int i7 = this.chatAdapter.messagesStartRow + i5;
                                    z3 = findFirstVisibleItemPosition <= i7 && findLastVisibleItemPosition >= i7;
                                    if (z3) {
                                        break;
                                    }
                                }
                                if (((MessageObject) messages.get(i5)).messageOwner.id == i) {
                                    i4 = i5;
                                }
                            }
                            if (!z2 && !z3 && i4 != -1) {
                                this.chatLayoutManager.scrollToPositionWithOffset(this.chatAdapter.messagesStartRow + i4, (this.chatListView.getHeight() - getHeightForMessage((MessageObject) messages.get(i4), true)) / 2);
                            }
                        }
                    }
                    this.messagesSearchListContainer.setTag(z ? 1 : null);
                    FrameLayout frameLayout2 = this.messagesSearchListContainer;
                    SearchTagsList searchTagsList = this.actionBarSearchTags;
                    frameLayout2.setPadding(0, (searchTagsList == null || !searchTagsList.shown()) ? 0 : this.actionBarSearchTags.getHeight(), 0, getHashtagTabsHeight());
                    AnimatorSet animatorSet2 = new AnimatorSet();
                    this.messagesSearchListViewAnimation = animatorSet2;
                    animatorSet2.playTogether(ObjectAnimator.ofFloat(this.messagesSearchListContainer, (Property<FrameLayout, Float>) View.ALPHA, z ? 1.0f : 0.0f));
                    this.messagesSearchListViewAnimation.setInterpolator(CubicBezierInterpolator.EASE_IN);
                    this.messagesSearchListViewAnimation.setDuration(180L);
                    this.messagesSearchListViewAnimation.addListener(new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationCancel(Animator animator) {
                            if (animator.equals(ChatActivity.this.messagesSearchListViewAnimation)) {
                                ChatActivity.this.messagesSearchListViewAnimation = null;
                            }
                        }

                        @Override
                        public void onAnimationEnd(Animator animator) {
                            if (animator.equals(ChatActivity.this.messagesSearchListViewAnimation)) {
                                ChatActivity.this.messagesSearchListViewAnimation = null;
                                if (z) {
                                    return;
                                }
                                ChatActivity.this.messagesSearchListContainer.setVisibility(8);
                            }
                        }
                    });
                    this.messagesSearchListViewAnimation.start();
                    AnimatedTextView animatedTextView = this.searchExpandList;
                    if (animatedTextView != null) {
                        FrameLayout frameLayout3 = this.messagesSearchListContainer;
                        animatedTextView.setText(LocaleController.getString((frameLayout3 == null || frameLayout3.getTag() == null) ? R.string.SearchAsList : R.string.SearchAsChat), true ^ LocaleController.isRTL);
                    }
                    hideHints();
                    updateSearchCountText();
                }
            }
        }
    }

    private void showMultipleReactionsPromo(View view, ReactionsLayoutInBubble.VisibleReaction visibleReaction, int i) {
        TLRPC.Document findDocument;
        if (SharedConfig.multipleReactionsPromoShowed || view == null || visibleReaction == null || getUserConfig().isPremium() || i != 1) {
            return;
        }
        SharedConfig.setMultipleReactionsPromoShowed(true);
        long j = visibleReaction.documentId;
        if (j == 0) {
            TLRPC.TL_availableReaction tL_availableReaction = (TLRPC.TL_availableReaction) MediaDataController.getInstance(((BaseFragment) this).currentAccount).getReactionsMap().get(visibleReaction.emojicon);
            if (tL_availableReaction == null) {
                return;
            } else {
                findDocument = tL_availableReaction.center_icon;
            }
        } else {
            findDocument = AnimatedEmojiDrawable.findDocument(((BaseFragment) this).currentAccount, j);
        }
        if (findDocument == null) {
            return;
        }
        BulletinFactory.of(this).createEmojiBulletin(findDocument, LocaleController.getString(R.string.ChatMultipleReactionsPromo)).setDuration(5000).show();
    }

    public void showNoSoundHint() {
        ChatMessageCell chatMessageCell;
        MessageObject messageObject;
        AnimatedFileDrawable animation;
        if (this.scrollingChatListView || SharedConfig.noSoundHintShowed || this.chatListView == null || getParentActivity() == null || ((BaseFragment) this).fragmentView == null) {
            return;
        }
        HintView hintView = this.noSoundHintView;
        if (hintView == null || hintView.getTag() == null) {
            if (this.noSoundHintView == null) {
                SizeNotifierFrameLayout sizeNotifierFrameLayout = ((BaseFragment) this).fragmentView;
                int indexOfChild = sizeNotifierFrameLayout.indexOfChild(this.chatActivityEnterView);
                if (indexOfChild == -1) {
                    return;
                }
                HintView hintView2 = new HintView(getParentActivity(), 0, this.themeDelegate);
                this.noSoundHintView = hintView2;
                hintView2.setShowingDuration(10000L);
                sizeNotifierFrameLayout.addView(this.noSoundHintView, indexOfChild + 1, LayoutHelper.createFrame(-2, -2.0f, 51, 19.0f, 0.0f, 19.0f, 0.0f));
                this.noSoundHintView.setAlpha(0.0f);
                this.noSoundHintView.setVisibility(4);
            }
            int childCount = this.chatListView.getChildCount();
            for (int i = 0; i < childCount; i++) {
                View childAt = this.chatListView.getChildAt(i);
                if ((childAt instanceof ChatMessageCell) && (messageObject = (chatMessageCell = (ChatMessageCell) childAt).getMessageObject()) != null && messageObject.isVideo() && (animation = chatMessageCell.getPhotoImage().getAnimation()) != null && animation.getCurrentProgressMs() >= 3000 && this.noSoundHintView.showForMessageCell(chatMessageCell, true)) {
                    SharedConfig.setNoSoundHintShowed(true);
                    return;
                }
            }
        }
    }

    private void showPinnedProgress(boolean z) {
        if (z) {
            if (this.updatePinnedProgressRunnable == null) {
                Runnable runnable = new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.this.lambda$showPinnedProgress$155();
                    }
                };
                this.updatePinnedProgressRunnable = runnable;
                AndroidUtilities.runOnUIThread(runnable, 100L);
                return;
            }
            return;
        }
        Runnable runnable2 = this.updatePinnedProgressRunnable;
        if (runnable2 != null) {
            AndroidUtilities.cancelRunOnUIThread(runnable2);
        }
        this.updatePinnedProgressRunnable = null;
        this.pinnedProgressIsShowing = false;
        updatePinnedListButton(true);
    }

    public void showPollSolution(MessageObject messageObject, TLRPC.PollResults pollResults) {
        CharSequence replaceEmoji;
        TLRPC.Message message;
        TranslateController.PollText pollText;
        TLRPC.TL_textWithEntities tL_textWithEntities;
        if (pollResults == null || TextUtils.isEmpty(pollResults.solution)) {
            return;
        }
        String str = pollResults.solution;
        ArrayList arrayList = pollResults.solution_entities;
        if (messageObject != null && messageObject.translated && (message = messageObject.messageOwner) != null && (pollText = message.translatedPoll) != null && (tL_textWithEntities = pollText.solution) != null) {
            str = tL_textWithEntities.text;
            arrayList = tL_textWithEntities.entities;
        }
        ArrayList arrayList2 = arrayList;
        if (arrayList2.isEmpty()) {
            replaceEmoji = Emoji.replaceEmoji(str, Theme.chat_msgBotButtonPaint.getFontMetricsInt(), false);
        } else {
            replaceEmoji = MessageObject.replaceAnimatedEmoji(Emoji.replaceEmoji(new SpannableStringBuilder(str), Theme.chat_msgBotButtonPaint.getFontMetricsInt(), false), arrayList2, Theme.chat_msgBotButtonPaint.getFontMetricsInt());
            MessageObject.addEntitiesToText(replaceEmoji, arrayList2, false, true, true, false);
        }
        showInfoHint(messageObject, replaceEmoji, 0);
    }

    private void showProgressView(boolean z) {
        ViewPropertyAnimator listener;
        if (this.progressView == null) {
            return;
        }
        if (!AndroidUtilities.isTablet() && !this.isComments && this.currentUser == null && getLiteModeChat()) {
            this.animateProgressViewTo = z;
            return;
        }
        if (!this.fragmentOpened || !SharedConfig.animationsEnabled()) {
            this.animateProgressViewTo = z;
            this.progressView.setVisibility(z ? 0 : 4);
            return;
        }
        if (z == this.animateProgressViewTo) {
            return;
        }
        this.animateProgressViewTo = z;
        if (z) {
            if (this.progressView.getVisibility() != 0) {
                this.progressView.setVisibility(0);
                this.progressView.setAlpha(0.0f);
                this.progressView.setScaleX(0.3f);
                this.progressView.setScaleY(0.3f);
            }
            this.progressView.animate().setListener(null).cancel();
            listener = this.progressView.animate().alpha(1.0f).scaleX(1.0f).scaleY(1.0f).setDuration(150L);
        } else {
            this.progressView.animate().setListener(null).cancel();
            listener = this.progressView.animate().alpha(0.0f).scaleX(0.3f).scaleY(0.3f).setDuration(150L).setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animator) {
                    ChatActivity.this.progressView.setVisibility(4);
                }
            });
        }
        listener.start();
    }

    public void showQuickRepliesRemoveAlert() {
        showDialog(new AlertDialog.Builder(getContext(), getResourceProvider()).setTitle(LocaleController.getString(R.string.BusinessRepliesRemoveTitle)).setMessage(LocaleController.getString(R.string.BusinessRepliesRemoveMessage)).setPositiveButton(LocaleController.getString(R.string.Remove), new AlertDialog.OnButtonClickListener() {
            @Override
            public final void onClick(AlertDialog alertDialog, int i) {
                ChatActivity.this.lambda$showQuickRepliesRemoveAlert$355(alertDialog, i);
            }
        }).setNegativeButton(LocaleController.getString(R.string.Cancel), null).create());
    }

    public void showScheduledHint() {
        TLRPC.ChatFull chatFull;
        boolean z = UserObject.isUserSelf(this.currentUser) || ((chatFull = this.chatInfo) != null && chatFull.slowmode_next_send_date > 0 && this.chatMode == 0);
        if (this.scheduledHintShown || this.scheduledOrNoSoundHintShown || z || SharedConfig.scheduledHintShows >= 3 || this.chatActivityEnterView.isEditingMessage()) {
            return;
        }
        AndroidUtilities.cancelRunOnUIThread(this.showScheduledHintRunnable);
        AndroidUtilities.runOnUIThread(this.showScheduledHintRunnable, 4000L);
    }

    private void showScheduledOrNoSoundHint() {
        TLRPC.ChatFull chatFull;
        boolean z = UserObject.isUserSelf(this.currentUser) || ((chatFull = this.chatInfo) != null && chatFull.slowmode_next_send_date > 0 && this.chatMode == 0) || this.chatMode == 6;
        long currentTimeMillis = System.currentTimeMillis() - SharedConfig.scheduledOrNoSoundHintSeenAt;
        long currentTimeMillis2 = System.currentTimeMillis() - SharedConfig.scheduledHintSeenAt;
        if (z || SharedConfig.scheduledOrNoSoundHintShows >= 3 || currentTimeMillis < 86400000 || currentTimeMillis2 < 86400000 || this.chatActivityEnterView.isEditingMessage()) {
            return;
        }
        AndroidUtilities.cancelRunOnUIThread(this.showScheduledOrNoSoundRunnable);
        AndroidUtilities.runOnUIThread(this.showScheduledOrNoSoundRunnable, 200L);
    }

    public void showSlowModeHint(View view, boolean z, CharSequence charSequence) {
        HintView hintView;
        if (getParentActivity() == null || ((BaseFragment) this).fragmentView == null) {
            return;
        }
        if (z || ((hintView = this.slowModeHint) != null && hintView.getVisibility() == 0)) {
            this.slowModeHint.setText(AndroidUtilities.replaceTags(LocaleController.formatString("SlowModeHint", R.string.SlowModeHint, new Object[]{charSequence})));
            if (z) {
                this.slowModeHint.showForView(view, true);
            }
        }
    }

    private void showSuggestButton(boolean z, boolean z2) {
        ImageView imageView = this.bottomSuggestButton;
        if (imageView != null || z) {
            boolean z3 = imageView != null && imageView.getAlpha() > 0.5f;
            if (this.bottomSuggestButton == null) {
                ImageView imageView2 = new ImageView(getContext());
                this.bottomSuggestButton = imageView2;
                imageView2.setImageResource(R.drawable.input_message);
                this.bottomSuggestButton.setScaleType(ImageView.ScaleType.CENTER);
                ImageView imageView3 = this.bottomSuggestButton;
                int i = Theme.key_chat_fieldOverlayText;
                imageView3.setColorFilter(new PorterDuffColorFilter(getThemedColor(i), PorterDuff.Mode.SRC_IN));
                this.bottomOverlayChat.addView(this.bottomSuggestButton, LayoutHelper.createFrame(48, 48, 19));
                this.bottomSuggestButton.setBackground(Theme.createSelectorDrawable(Theme.multAlpha(getThemedColor(i), 0.1f), 1));
                this.bottomSuggestButton.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public final void onClick(View view) {
                        ChatActivity.this.lambda$showSuggestButton$222(view);
                    }
                });
                this.bottomSuggestButton.setContentDescription(LocaleController.getString(R.string.PostSuggestions));
                ScaleStateListAnimator.apply(this.bottomSuggestButton);
            }
            AndroidUtilities.updateViewShow(this.bottomSuggestButton, z, true, z2);
            if (!z || z3 || this.bottomSuggestHintView != null || MessagesController.getGlobalMainSettings().getInt("channelsuggesthint", 0) >= 2) {
                return;
            }
            HintView2 hintView2 = new HintView2(getContext(), 3);
            this.bottomSuggestHintView = hintView2;
            hintView2.setPadding(AndroidUtilities.dp(7.33f), 0, AndroidUtilities.dp(7.33f), 0);
            this.bottomSuggestHintView.setMultilineText(false);
            this.bottomSuggestHintView.setText(TextCell.applyNewSpan(LocaleController.getString(R.string.Suggest2ChannelSendHint), true));
            this.bottomSuggestHintView.setJoint(0.0f, 16.67f);
            this.contentView.addView(this.bottomSuggestHintView, LayoutHelper.createFrame(-1, 100.0f, 87, 0.0f, 0.0f, 0.0f, 42.34f));
            this.bottomSuggestHintView.setOnHiddenListener(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$showSuggestButton$223();
                }
            });
            this.bottomSuggestHintView.show();
            MessagesController.getGlobalMainSettings().edit().putInt("channelsuggesthint", MessagesController.getGlobalMainSettings().getInt("channelsuggesthint", 0) + 1).apply();
        }
    }

    public void showTagSelector() {
        if (getDialogId() == getUserConfig().getClientUserId() && getUserConfig().isPremium() && this.tagSelector == null) {
            ReactionsContainerLayout anonymousClass60 = new AnonymousClass60(3, this, getContext(), ((BaseFragment) this).currentAccount, this.themeDelegate);
            this.tagSelector = anonymousClass60;
            anonymousClass60.setPadding(AndroidUtilities.dp(4.0f), AndroidUtilities.dp(24.0f), AndroidUtilities.dp(4.0f), AndroidUtilities.dp(0.0f));
            this.tagSelector.setDelegate(new ReactionsContainerLayout.ReactionsContainerDelegate() {
                public boolean drawBackground() {
                    return ReactionsContainerLayout.ReactionsContainerDelegate.-CC.$default$drawBackground(this);
                }

                public void drawRoundRect(Canvas canvas, RectF rectF, float f, float f2, float f3, int i, boolean z) {
                    ReactionsContainerLayout.ReactionsContainerDelegate.-CC.$default$drawRoundRect(this, canvas, rectF, f, f2, f3, i, z);
                }

                public boolean needEnterText() {
                    return ReactionsContainerLayout.ReactionsContainerDelegate.-CC.$default$needEnterText(this);
                }

                public void onEmojiWindowDismissed() {
                    ReactionsContainerLayout.ReactionsContainerDelegate.-CC.$default$onEmojiWindowDismissed(this);
                }

                public void onReactionClicked(android.view.View r25, org.telegram.ui.Components.Reactions.ReactionsLayoutInBubble.VisibleReaction r26, boolean r27, boolean r28) {
                    throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.AnonymousClass61.onReactionClicked(android.view.View, org.telegram.ui.Components.Reactions.ReactionsLayoutInBubble$VisibleReaction, boolean, boolean):void");
                }
            });
            this.tagSelector.setTop(true);
            this.tagSelector.setClipChildren(false);
            this.tagSelector.setClipToPadding(false);
            this.tagSelector.setVisibility(0);
            ReactionsContainerLayout reactionsContainerLayout = this.tagSelector;
            reactionsContainerLayout.setHint(LocaleController.getString(reactionsContainerLayout.getSelectedReactions().isEmpty() ? R.string.SavedTagReactionsSelectedAddHint : R.string.SavedTagReactionsSelectedEditHint));
            this.contentView.addView(this.tagSelector, LayoutHelper.createFrame(-2, 92.5f, 49, 0.0f, 0.0f, 0.0f, 0.0f));
            this.tagSelector.setMessage((MessageObject) null, (TLRPC.ChatFull) null, true);
            this.tagSelector.setTranslationY(-AndroidUtilities.dp(12.0f));
            this.tagSelector.setScaleY(0.4f);
            this.tagSelector.setScaleX(0.4f);
            this.tagSelector.animate().scaleY(1.0f).scaleX(1.0f).translationY(0.0f).setDuration(420L).setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT).start();
            updateSelectedMessageReactions();
            this.tagSelector.setTranslationY(this.contentPanTranslation + (this.actionBarSearchTags != null ? r3.getCurrentHeight() : 0));
        }
    }

    private void showTextSelectionHint(MessageObject messageObject) {
        CharSequence charSequence;
        if (getParentActivity() == null || getMessagesController().isChatNoForwards(messageObject.getChatId())) {
            return;
        }
        TLRPC.Message message = messageObject.messageOwner;
        if (message == null || !message.noforwards) {
            ArrayList arrayList = messageObject.textLayoutBlocks;
            boolean z = false;
            if (arrayList == null || arrayList.isEmpty()) {
                charSequence = messageObject.caption;
            } else {
                charSequence = messageObject.messageText;
                if (messageObject.textLayoutBlocks.size() > 1) {
                    z = true;
                }
            }
            if (!z && charSequence != null) {
                z = true;
            }
            if (!z || SharedConfig.textSelectionHintShows > 2 || this.textSelectionHintWasShowed || this.lastTouchY > this.chatActivityEnterView.getTop() - AndroidUtilities.dp(60.0f)) {
                return;
            }
            this.textSelectionHintWasShowed = true;
            SharedConfig.increaseTextSelectionHintShowed();
            if (this.textSelectionHint == null) {
                View view = new TextSelectionHint(getParentActivity(), this.themeDelegate) {
                    protected void onDraw(Canvas canvas) {
                        super.onDraw(canvas);
                        updatePosition();
                    }

                    protected void onMeasure(int i, int i2) {
                        super.onMeasure(i, i2);
                        updatePosition();
                    }

                    public void updatePosition() {
                        int i = -(getMeasuredHeight() + AndroidUtilities.dp(16.0f));
                        setTranslationY((ChatActivity.this.chatActivityEnterView.getTop() - ChatActivity.this.contentView.getMeasuredHeight()) - ((r1 + i) * (1.0f - getPrepareProgress())));
                    }
                };
                this.textSelectionHint = view;
                this.contentView.addView(view, LayoutHelper.createFrame(-2, 56.0f, 83, 8.0f, 0.0f, 8.0f, 8.0f));
            }
            this.textSelectionHint.show();
        }
    }

    public void showVoiceHint(boolean z, boolean z2) {
        ChatActivityEnterView chatActivityEnterView;
        HintView hintView;
        int i;
        if (getParentActivity() == null || ((BaseFragment) this).fragmentView == null) {
            return;
        }
        if ((z && this.voiceHintTextView == null) || this.chatMode != 0 || (chatActivityEnterView = this.chatActivityEnterView) == null || chatActivityEnterView.getAudioVideoButtonContainer() == null || this.chatActivityEnterView.getAudioVideoButtonContainer().getVisibility() != 0 || isInPreviewMode()) {
            return;
        }
        if (this.voiceHintTextView == null) {
            SizeNotifierFrameLayout sizeNotifierFrameLayout = ((BaseFragment) this).fragmentView;
            int indexOfChild = sizeNotifierFrameLayout.indexOfChild(this.chatActivityEnterView);
            if (indexOfChild == -1) {
                return;
            }
            HintView hintView2 = new HintView(getParentActivity(), 9, this.themeDelegate);
            this.voiceHintTextView = hintView2;
            sizeNotifierFrameLayout.addView(hintView2, indexOfChild + 1, LayoutHelper.createFrame(-2, -2.0f, 51, 10.0f, 0.0f, 10.0f, 0.0f));
        }
        if (z) {
            this.voiceHintTextView.hide();
            return;
        }
        if (this.chatActivityEnterView.hasRecordVideo()) {
            hintView = this.voiceHintTextView;
            i = z2 ? R.string.HoldToVideo : R.string.HoldToAudio;
        } else {
            hintView = this.voiceHintTextView;
            i = R.string.HoldToAudioOnly;
        }
        hintView.setText(LocaleController.getString(i));
        this.voiceHintTextView.showForView(this.chatActivityEnterView.getAudioVideoButtonContainer(), true);
    }

    public void startEditingMessageObject(MessageObject messageObject) {
        startEditingMessageObject(messageObject, false);
    }

    private void startEditingMessageObject(MessageObject messageObject, boolean z) {
        if (messageObject == null || getParentActivity() == null) {
            return;
        }
        ChatSelectionReactionMenuOverlay chatSelectionReactionMenuOverlay = this.selectionReactionsOverlay;
        if (chatSelectionReactionMenuOverlay != null && chatSelectionReactionMenuOverlay.isVisible()) {
            this.selectionReactionsOverlay.setHiddenByScroll(true);
        }
        if (this.searchItem != null && ((BaseFragment) this).actionBar.isSearchFieldVisible()) {
            ((BaseFragment) this).actionBar.closeSearchField();
            this.chatActivityEnterView.setFieldFocused();
        }
        this.mentionContainer.getAdapter().setNeedBotContext(false);
        this.chatActivityEnterView.setVisibility(0);
        showFieldPanelForEdit(true, messageObject);
        updateBottomOverlay();
        if (!z) {
            checkEditTimer();
        }
        if (z) {
            this.messageSuggestionParams = MessageSuggestionParams.of(messageObject.messageOwner.suggested_post);
        }
        this.chatActivityEnterView.setAllowStickersAndGifs(true, false, false, true);
        updatePinnedMessageView(true);
        updateVisibleRows();
        if (z || messageObject.scheduled || messageObject.isQuickReply()) {
            this.chatActivityEnterView.showEditDoneProgress(false, true);
            return;
        }
        TLRPC.TL_messages_getMessageEditData tL_messages_getMessageEditData = new TLRPC.TL_messages_getMessageEditData();
        tL_messages_getMessageEditData.peer = getMessagesController().getInputPeer(this.dialog_id);
        tL_messages_getMessageEditData.id = messageObject.getId();
        this.editingMessageObjectReqId = getConnectionsManager().sendRequest(tL_messages_getMessageEditData, new RequestDelegate() {
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                ChatActivity.this.lambda$startEditingMessageObject$310(tLObject, tL_error);
            }
        });
    }

    public void startMessageUnselect() {
        Runnable runnable = this.unselectRunnable;
        if (runnable != null) {
            AndroidUtilities.cancelRunOnUIThread(runnable);
        }
        Runnable runnable2 = new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$startMessageUnselect$152();
            }
        };
        this.unselectRunnable = runnable2;
        AndroidUtilities.runOnUIThread(runnable2, this.highlightMessageQuote != null ? 2500L : 1000L);
    }

    public void startMultiselect(int i) {
        int i2;
        if (!this.isInsideContainer && (i2 = i - this.chatAdapter.messagesStartRow) >= 0 && i2 < this.messages.size()) {
            MessageObject messageObject = (MessageObject) this.messages.get(i2);
            final boolean z = this.selectedMessagesIds[0].get(messageObject.getId(), null) == null && this.selectedMessagesIds[1].get(messageObject.getId(), null) == null;
            final SparseArray sparseArray = new SparseArray();
            for (int i3 = 0; i3 < this.selectedMessagesIds[0].size(); i3++) {
                sparseArray.put(this.selectedMessagesIds[0].keyAt(i3), (MessageObject) this.selectedMessagesIds[0].valueAt(i3));
            }
            for (int i4 = 0; i4 < this.selectedMessagesIds[1].size(); i4++) {
                sparseArray.put(this.selectedMessagesIds[1].keyAt(i4), (MessageObject) this.selectedMessagesIds[1].valueAt(i4));
            }
            this.chatListView.startMultiselect(i, false, new RecyclerListView.onMultiSelectionChanged() {
                boolean limitReached;

                public boolean canSelect(int i5) {
                    int i6 = i5 - ChatActivity.this.chatAdapter.messagesStartRow;
                    if (i6 < 0 || i6 >= ChatActivity.this.messages.size()) {
                        return false;
                    }
                    MessageObject messageObject2 = (MessageObject) ChatActivity.this.messages.get(i6);
                    if (messageObject2.contentType != 0) {
                        return false;
                    }
                    if (z || sparseArray.get(messageObject2.getId(), null) != null) {
                        return z && sparseArray.get(messageObject2.getId(), null) != null;
                    }
                    return true;
                }

                public int checkPosition(int i5, boolean z2) {
                    MessageObject.GroupedMessages groupedMessages;
                    int i6 = i5 - ChatActivity.this.chatAdapter.messagesStartRow;
                    if (i6 >= 0 && i6 < ChatActivity.this.messages.size()) {
                        MessageObject messageObject2 = (MessageObject) ChatActivity.this.messages.get(i6);
                        if (messageObject2.contentType == 0 && messageObject2.hasValidGroupId() && (groupedMessages = (MessageObject.GroupedMessages) ChatActivity.this.groupedMessagesMap.get(messageObject2.getGroupId())) != null) {
                            return ChatActivity.this.chatAdapter.messagesStartRow + ChatActivity.this.messages.indexOf((MessageObject) groupedMessages.messages.get(z2 ? 0 : r5.size() - 1));
                        }
                    }
                    return i5;
                }

                public void getPaddings(int[] iArr) {
                    ChatActivity chatActivity = ChatActivity.this;
                    iArr[0] = (int) chatActivity.chatListViewPaddingTop;
                    iArr[1] = chatActivity.blurredViewBottomOffset;
                }

                public boolean limitReached() {
                    return this.limitReached;
                }

                public void onSelectionChanged(int i5, boolean z2, float f, float f2) {
                    int i6 = i5 - ChatActivity.this.chatAdapter.messagesStartRow;
                    if (z) {
                        z2 = !z2;
                    }
                    if (i6 < 0 || i6 >= ChatActivity.this.messages.size()) {
                        return;
                    }
                    MessageObject messageObject2 = (MessageObject) ChatActivity.this.messages.get(i6);
                    if (!z2 || (ChatActivity.this.selectedMessagesIds[0].indexOfKey(messageObject2.getId()) < 0 && ChatActivity.this.selectedMessagesIds[1].indexOfKey(messageObject2.getId()) < 0)) {
                        if ((z2 || ChatActivity.this.selectedMessagesIds[0].indexOfKey(messageObject2.getId()) >= 0 || ChatActivity.this.selectedMessagesIds[1].indexOfKey(messageObject2.getId()) >= 0) && messageObject2.contentType == 0) {
                            if (!z2 || ChatActivity.this.selectedMessagesIds[0].size() + ChatActivity.this.selectedMessagesIds[1].size() < 100) {
                                this.limitReached = false;
                            } else {
                                this.limitReached = true;
                            }
                            RecyclerView.ViewHolder findViewHolderForAdapterPosition = ChatActivity.this.chatListView.findViewHolderForAdapterPosition(i5);
                            if (findViewHolderForAdapterPosition != null) {
                                View view = findViewHolderForAdapterPosition.itemView;
                                if (view instanceof ChatMessageCell) {
                                    ChatActivity.this.processRowSelect(view, false, f, f2);
                                    return;
                                }
                            }
                            ChatActivity.this.addToSelectedMessages(messageObject2, false);
                            ChatActivity.this.updateActionModeTitle();
                            ChatActivity.this.updateVisibleRows();
                        }
                    }
                }

                public void scrollBy(int i5) {
                    ChatActivity.this.chatListView.scrollBy(0, i5);
                }
            });
        }
    }

    private void toggleIsAllChats() {
        final boolean isAllChats = isAllChats();
        AndroidUtilities.forEachViews(this.chatListView, new Consumer() {
            public final void accept(Object obj) {
                ChatActivity.this.lambda$toggleIsAllChats$91(isAllChats, (View) obj);
            }
        });
    }

    private void toggleMesagesSearchListView() {
        FrameLayout frameLayout = this.messagesSearchListContainer;
        if (frameLayout != null) {
            showMessagesSearchListView(frameLayout.getTag() == null);
        }
    }

    public void toggleMute(boolean z) {
        if (getMessagesController().isDialogMuted(this.dialog_id, getTopicId())) {
            getNotificationsController().muteDialog(this.dialog_id, getTopicId(), false);
            if (z) {
                return;
            }
            BulletinFactory.createMuteBulletin(this, false, this.themeDelegate).show();
            return;
        }
        if (z) {
            getNotificationsController().muteDialog(this.dialog_id, getTopicId(), true);
            return;
        }
        BottomSheet createMuteAlert = AlertsCreator.createMuteAlert(this, this.dialog_id, getTopicId(), this.themeDelegate);
        createMuteAlert.setCalcMandatoryInsets(isKeyboardVisible());
        showDialog(createMuteAlert);
    }

    public void unpinMessage(final MessageObject messageObject) {
        if (messageObject == null) {
            return;
        }
        Bulletin bulletin = this.pinBulletin;
        if (bulletin != null) {
            bulletin.hide(false, 0L);
        }
        final ArrayList arrayList = new ArrayList();
        arrayList.add(this.selectedObject);
        final ArrayList arrayList2 = new ArrayList();
        arrayList2.add(Integer.valueOf(messageObject.getId()));
        final int i = this.totalPinnedMessagesCount;
        getNotificationCenter().postNotificationName(NotificationCenter.didLoadPinnedMessages, new Object[]{Long.valueOf(this.dialog_id), arrayList2, Boolean.FALSE, null, null, 0, Integer.valueOf(this.totalPinnedMessagesCount - 1), Boolean.valueOf(this.pinnedEndReached)});
        this.pinBulletin = BulletinFactory.createUnpinMessageBulletin(this, new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$unpinMessage$311(arrayList2, arrayList, i);
            }
        }, new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$unpinMessage$312(messageObject);
            }
        }, this.themeDelegate).show();
    }

    public void updateActionModeTitle() {
        if (!isReport()) {
            if (((BaseFragment) this).actionBar.isActionModeShowed() && this.selectedMessagesCountTextView != null) {
                if (this.selectedMessagesIds[0].size() == 0 && this.selectedMessagesIds[1].size() == 0) {
                    return;
                }
                this.selectedMessagesCountTextView.setNumber(this.selectedMessagesIds[0].size() + this.selectedMessagesIds[1].size(), true);
                return;
            }
            return;
        }
        int size = this.selectedMessagesIds[0].size() + this.selectedMessagesIds[1].size();
        if (size == 0) {
            this.bottomOverlayChatText.setText(LocaleController.getString(R.string.ReportMessages));
            this.bottomOverlayChatText.setAlpha(0.5f);
            this.bottomOverlayChatText.setEnabled(false);
        } else {
            this.bottomOverlayChatText.setText(LocaleController.formatString("ReportMessagesCount", R.string.ReportMessagesCount, new Object[]{LocaleController.formatPluralString("messages", size, new Object[0])}).toUpperCase());
            this.bottomOverlayChatText.setAlpha(1.0f);
            this.bottomOverlayChatText.setEnabled(true);
        }
    }

    public void updateBackground() {
        if (this.contentView == null || this.parentThemeDelegate != null) {
            return;
        }
        if ((this.themeDelegate.backgroundDrawable == null || this.contentView.getBackgroundImage() == null) && this.contentView.getBackgroundImage() == null) {
            this.contentView.setBackgroundImage(Theme.getCachedWallpaper(), Theme.isWallpaperMotion());
        }
    }

    private void updateBotButtons() {
        TLRPC.User user;
        boolean z;
        int i;
        if (this.headerItem == null || (user = this.currentUser) == null || this.currentEncryptedChat != null || !user.bot) {
            return;
        }
        boolean z2 = false;
        if (this.botInfo.size() != 0) {
            boolean z3 = false;
            z = false;
            for (int i2 = 0; i2 < this.botInfo.size(); i2++) {
                TL_bots.BotInfo botInfo = (TL_bots.BotInfo) this.botInfo.valueAt(i2);
                while (i < botInfo.commands.size()) {
                    TLRPC.TL_botCommand tL_botCommand = (TLRPC.TL_botCommand) botInfo.commands.get(i);
                    if (tL_botCommand.command.toLowerCase().equals("help")) {
                        z3 = true;
                    } else if (tL_botCommand.command.toLowerCase().equals("settings")) {
                        z = true;
                    }
                    i = (z && z3) ? 0 : i + 1;
                }
            }
            z2 = z3;
        } else {
            z = false;
        }
        if (z2) {
            this.headerItem.showSubItem(30);
        } else {
            this.headerItem.hideSubItem(30);
        }
        ActionBarMenuItem actionBarMenuItem = this.headerItem;
        if (z) {
            actionBarMenuItem.showSubItem(31);
        } else {
            actionBarMenuItem.hideSubItem(31);
        }
    }

    public void updateBotHelpCellClick(final BotHelpCell botHelpCell) {
        if (!MessagesController.getInstance(((BaseFragment) this).currentAccount).getTranslateController().isContextTranslateEnabled() || !LanguageDetector.hasSupport()) {
            botHelpCell.setClickable(false);
        } else {
            final CharSequence text = botHelpCell.getText();
            LanguageDetector.detectLanguage(text == null ? "" : text.toString(), new LanguageDetector.StringCallback() {
                public final void run(String str) {
                    ChatActivity.this.lambda$updateBotHelpCellClick$392(botHelpCell, text, str);
                }
            }, new LanguageDetector.ExceptionCallback() {
                public final void run(Exception exc) {
                    BotHelpCell.this.setClickable(false);
                }
            });
        }
    }

    public void updateBulletinLayout() {
        Bulletin visibleBulletin = Bulletin.getVisibleBulletin();
        if (visibleBulletin == null || this.bulletinDelegate == null) {
            return;
        }
        visibleBulletin.updatePosition();
    }

    public void updateChatListViewTopPadding() {
        float f;
        TranslateButton translateButton;
        int i;
        BlurredFrameLayout blurredFrameLayout;
        ChatActivityEnterView chatActivityEnterView;
        float translationY;
        ChatActivityEnterView chatActivityEnterView2;
        if (!this.invalidateChatListViewTopPadding || this.chatListView == null) {
            return;
        }
        if (this.fixedKeyboardHeight <= 0 || this.searchExpandProgress != 0.0f) {
            BlurredFrameLayout blurredFrameLayout2 = this.topChatPanelView;
            float max = Math.max(0, (blurredFrameLayout2 == null || blurredFrameLayout2.getVisibility() != 0) ? 0 : this.topChatPanelView.getLayoutParams().height - AndroidUtilities.dp(2.0f));
            float max2 = max + Math.max(-max, this.topChatPanelViewOffset);
            BlurredFrameLayout blurredFrameLayout3 = this.topChatPanelView2;
            float max3 = Math.max(0, (blurredFrameLayout3 == null || blurredFrameLayout3.getVisibility() != 0) ? 0 : this.topChatPanelView2.getLayoutParams().height - AndroidUtilities.dp(2.0f));
            float max4 = max3 + Math.max(-max3, this.topChatPanelView2Offset);
            BlurredFrameLayout blurredFrameLayout4 = this.pinnedMessageView;
            float max5 = (blurredFrameLayout4 == null || blurredFrameLayout4.getVisibility() != 0) ? 0.0f : Math.max(0.0f, AndroidUtilities.dp(48.0f) + this.pinnedMessageEnterOffset);
            if (this.actionBarSearchTags != null) {
                max5 = Math.max(max5, r6.getCurrentHeight());
            }
            if (this.hashtagSearchTabs != null) {
                max5 = Math.max(max5, r6.getCurrentHeight());
            }
            ChatActivityMemberRequestsDelegate chatActivityMemberRequestsDelegate = this.pendingRequestsDelegate;
            MessageObject messageObject = null;
            View view = chatActivityMemberRequestsDelegate != null ? chatActivityMemberRequestsDelegate.getView() : null;
            float max6 = (view == null || view.getVisibility() != 0) ? 0.0f : Math.max(0.0f, (view.getHeight() + this.pendingRequestsDelegate.getViewEnterOffset()) - AndroidUtilities.dp(4.0f));
            float f2 = this.chatListViewPaddingTop;
            float dp = AndroidUtilities.dp(4.0f) + this.contentPaddingTop;
            float f3 = max2 + max5 + max6 + max4;
            this.paddingTopHeight = f3;
            float dp2 = dp + f3 + (this.topicsTabs != null ? AndroidUtilities.dp(48.0f) * (1.0f - this.topicsTabs.sidemenuT) : 0.0f) + this.blurredViewTopOffset;
            this.chatListViewPaddingVisibleOffset = 0;
            this.chatListViewPaddingTop = dp2 + this.contentPanTranslation + this.bottomPanelTranslationY;
            if (this.searchExpandProgress == 0.0f || (chatActivityEnterView2 = this.chatActivityEnterView) == null || chatActivityEnterView2.getVisibility() != 0) {
                f = 0.0f;
            } else {
                float f4 = this.chatListViewPaddingTop;
                f = this.searchExpandProgress * (this.chatActivityEnterView.getMeasuredHeight() - AndroidUtilities.dp(51.0f));
                this.chatListViewPaddingTop = f4 - f;
            }
            ChatActivityEnterView chatActivityEnterView3 = this.chatActivityEnterView;
            if (chatActivityEnterView3 != null && this.bottomPanelTranslationY == 0.0f && !chatActivityEnterView3.panelAnimationInProgress() && this.contentView.getLayoutParams() != null && (this.contentView.getLayoutParams().height < 0 || (this.contentView.getKeyboardHeight() <= AndroidUtilities.dp(20.0f) && this.chatActivityEnterView.isPopupShowing()))) {
                this.chatListViewPaddingTop += (this.contentView.getKeyboardHeight() > AndroidUtilities.dp(20.0f) || AndroidUtilities.isInMultiwindow || ((BaseFragment) this).inBubbleMode) ? this.contentView.getKeyboardHeight() : this.chatActivityEnterView.getEmojiPadding();
            }
            if (!((BaseFragment) this).inPreviewMode && (chatActivityEnterView = this.chatActivityEnterView) != null) {
                if (chatActivityEnterView.getAnimatedTop() != 0) {
                    translationY = this.chatListViewPaddingTop + ((this.chatActivityEnterView.getHeightWithTopView() - AndroidUtilities.dp(51.0f)) - this.chatActivityEnterView.getAnimatedTop());
                } else if (!this.chatActivityEnterView.panelAnimationInProgress()) {
                    float heightWithTopView = this.chatListViewPaddingTop + (this.chatActivityEnterView.getHeightWithTopView() - AndroidUtilities.dp(51.0f));
                    this.chatListViewPaddingTop = heightWithTopView;
                    if (this.chatActivityEnterView.currentTopViewAnimation == null) {
                        translationY = heightWithTopView - this.chatListView.getTranslationY();
                    }
                }
                this.chatListViewPaddingTop = translationY;
            }
            ChatActionCell chatActionCell = this.infoTopView;
            if (chatActionCell != null) {
                chatActionCell.setTranslationY(((this.chatListView.getTranslationY() + this.chatListViewPaddingTop) + this.topViewOffset) - AndroidUtilities.dp(30.0f));
                float f5 = this.chatListViewPaddingTop;
                float f6 = this.topViewOffset;
                this.chatListViewPaddingTop = f5 + f6;
                this.chatListViewPaddingVisibleOffset = (int) (this.chatListViewPaddingVisibleOffset + f6);
            }
            ChatActionCell chatActionCell2 = this.floatingDateView;
            if (chatActionCell2 != null) {
                chatActionCell2.setTranslationY((((this.chatListView.getTranslationY() - f) + this.chatListViewPaddingTop) + this.floatingDateViewOffset) - AndroidUtilities.dp(4.0f));
            }
            updateFloatingTopicView();
            int measuredHeight = (!this.isInsideContainer || this.chatMode == 7) ? (this.chatListView.getMeasuredHeight() * 2) / 3 : AndroidUtilities.dp(4.0f);
            RecyclerListView recyclerListView = this.chatListView;
            if (recyclerListView != null && this.chatLayoutManager != null && this.chatAdapter != null) {
                if (recyclerListView.getPaddingTop() != measuredHeight) {
                    for (int i2 = 0; i2 < this.chatListView.getChildCount(); i2++) {
                        View childAt = this.chatListView.getChildAt(i2);
                        if (childAt instanceof ChatMessageCell) {
                            messageObject = ((ChatMessageCell) childAt).getMessageObject();
                        } else if (childAt instanceof ChatActionCell) {
                            messageObject = ((ChatActionCell) childAt).getMessageObject();
                        }
                        i = getScrollingOffsetForView(childAt);
                    }
                    i = 0;
                    this.chatListView.setPadding(0, measuredHeight, 0, AndroidUtilities.dp(3.0f) + this.blurredViewBottomOffset + ((this.isInsideContainer && (blurredFrameLayout = this.searchContainer) != null && blurredFrameLayout.getVisibility() == 0) ? AndroidUtilities.dp(50.0f) : 0));
                    if (messageObject != null) {
                        this.chatAdapter.updateRowsSafe();
                        int indexOf = this.messages.indexOf(messageObject);
                        if (indexOf >= 0) {
                            this.chatLayoutManager.scrollToPositionWithOffset(this.chatAdapter.messagesStartRow + indexOf, i);
                        }
                    }
                    invalidateMessagesVisiblePart();
                }
                this.chatListView.setTopGlowOffset((int) ((this.chatListViewPaddingTop - this.chatListViewPaddingVisibleOffset) - AndroidUtilities.dp(4.0f)));
                if (f2 != this.chatListViewPaddingTop) {
                    int childCount = this.chatListView.getChildCount();
                    int i3 = 0;
                    while (true) {
                        if (i3 >= childCount) {
                            break;
                        }
                        if (this.chatListView.getChildAdapterPosition(this.chatListView.getChildAt(i3)) == this.chatAdapter.getItemCount() - 1) {
                            float f7 = this.chatListViewPaddingTop;
                            if (r2.getTop() > f7) {
                                this.chatListView.scrollBy(0, (int) (r2.getTop() - f7));
                            }
                        } else {
                            i3++;
                        }
                    }
                }
                if (!isThreadChat() && !this.wasManualScroll && this.unreadMessageObject != null && this.chatListView != null && ((translateButton = this.translateButton) == null || translateButton.getVisibility() != 0)) {
                    this.chatListView.scrollBy(0, (int) (f2 - this.chatListViewPaddingTop));
                }
            }
            this.invalidateChatListViewTopPadding = false;
            Bulletin.updateCurrentPosition();
        }
    }

    public void updateFilteredMessages(boolean z) {
        boolean z2;
        MessageObject.GroupedMessages groupedMessages;
        TLRPC.Message message;
        TLRPC.TL_messageReactions tL_messageReactions;
        MessageObject messageObject;
        ArrayList arrayList = new ArrayList(MediaDataController.getInstance(((BaseFragment) this).currentAccount).getFoundMessageObjects());
        if (this.filteredMessagesDict == null) {
            this.filteredMessagesDict = new LongSparseArray();
        }
        LongSparseArray longSparseArray = this.filteredMessagesByDays;
        if (longSparseArray == null) {
            this.filteredMessagesByDays = new LongSparseArray();
        } else {
            longSparseArray.clear();
        }
        this.chatAdapter.filteredMessages.clear();
        this.filteredMessagesDict.clear();
        LongSparseArray longSparseArray2 = null;
        LongSparseArray longSparseArray3 = null;
        int i = 0;
        while (true) {
            z2 = true;
            if (i >= arrayList.size()) {
                break;
            }
            MessageObject messageObject2 = (MessageObject) arrayList.get(i);
            int i2 = 0;
            while (true) {
                if (i2 >= this.messages.size()) {
                    messageObject = null;
                    break;
                }
                messageObject = (MessageObject) this.messages.get(i2);
                if (messageObject.getDialogId() == messageObject2.getDialogId() && messageObject.getId() == messageObject2.getId()) {
                    break;
                } else {
                    i2++;
                }
            }
            if (messageObject2.stableId == 0) {
                if (messageObject == null) {
                    messageObject2.checkMediaExistance();
                } else {
                    messageObject2.mediaExists = messageObject.mediaExists;
                    messageObject2.attachPathExists = messageObject.attachPathExists;
                }
            }
            if (messageObject != null) {
                messageObject2.isSaved = messageObject.isSaved;
                if (!this.chatAdapter.isFiltered || messageObject2.stableId == 0) {
                    messageObject2.copyStableParams(messageObject);
                } else {
                    messageObject.copyStableParams(messageObject2);
                }
            } else if (messageObject2.stableId == 0) {
                int i3 = lastStableId;
                lastStableId = i3 + 1;
                messageObject2.stableId = i3;
            }
            messageObject2.isOutOwnerCached = null;
            TLRPC.Message message2 = messageObject2.messageOwner;
            if (message2 != null) {
                message2.out = true;
            }
            messageObject2.isOutOwner();
            if (messageObject2.hasValidGroupId()) {
                MessageObject.GroupedMessages groupedMessages2 = (MessageObject.GroupedMessages) this.groupedMessagesMap.get(messageObject2.getGroupIdForUse());
                if (groupedMessages2 == null) {
                    groupedMessages2 = new MessageObject.GroupedMessages();
                    groupedMessages2.reversed = this.reversed;
                    long groupId = messageObject2.getGroupId();
                    groupedMessages2.groupId = groupId;
                    this.groupedMessagesMap.put(groupId, groupedMessages2);
                } else if (longSparseArray2 == null || longSparseArray2.indexOfKey(messageObject2.getGroupId()) < 0) {
                    if (longSparseArray3 == null) {
                        longSparseArray3 = new LongSparseArray();
                    }
                    longSparseArray3.put(messageObject2.getGroupId(), groupedMessages2);
                }
                if (longSparseArray2 == null) {
                    longSparseArray2 = new LongSparseArray();
                }
                longSparseArray2.put(groupedMessages2.groupId, groupedMessages2);
                if (groupedMessages2.getPosition(messageObject2) == null) {
                    int i4 = 0;
                    while (true) {
                        if (i4 >= groupedMessages2.messages.size()) {
                            groupedMessages2.messages.add(messageObject2);
                            break;
                        } else if (((MessageObject) groupedMessages2.messages.get(i4)).getId() == messageObject2.getId()) {
                            break;
                        } else {
                            i4++;
                        }
                    }
                }
            } else if (messageObject2.getGroupIdForUse() != 0) {
                messageObject2.messageOwner.grouped_id = 0L;
                messageObject2.localSentGroupId = 0L;
            }
            this.chatAdapter.filteredMessages.add(messageObject2);
            this.filteredMessagesDict.put(messageObject2.getId(), messageObject2);
            i++;
        }
        if (longSparseArray2 != null) {
            for (int i5 = 0; i5 < longSparseArray2.size(); i5++) {
                MessageObject.GroupedMessages groupedMessages3 = (MessageObject.GroupedMessages) longSparseArray2.valueAt(i5);
                Collections.sort(groupedMessages3.messages, new Comparator() {
                    @Override
                    public final int compare(Object obj, Object obj2) {
                        int lambda$updateFilteredMessages$77;
                        lambda$updateFilteredMessages$77 = ChatActivity.lambda$updateFilteredMessages$77((MessageObject) obj, (MessageObject) obj2);
                        return lambda$updateFilteredMessages$77;
                    }
                });
                groupedMessages3.calculate();
            }
        }
        ArrayList arrayList2 = new ArrayList();
        if (this.searchingReaction != null && TextUtils.isEmpty(this.searchingQuery)) {
            for (int i6 = 0; i6 < this.messages.size(); i6++) {
                MessageObject messageObject3 = (MessageObject) this.messages.get(i6);
                if (messageObject3 != null && (message = messageObject3.messageOwner) != null && (tL_messageReactions = message.reactions) != null && ((TLRPC.MessageReactions) tL_messageReactions).reactions_as_tags) {
                    int i7 = 0;
                    while (true) {
                        if (i7 >= ((TLRPC.MessageReactions) messageObject3.messageOwner.reactions).results.size()) {
                            break;
                        }
                        if (this.searchingReaction.isSame(((TLRPC.ReactionCount) ((TLRPC.MessageReactions) messageObject3.messageOwner.reactions).results.get(i7)).reaction)) {
                            arrayList2.add(messageObject3);
                            break;
                        }
                        i7++;
                    }
                }
            }
        }
        for (int i8 = 0; i8 < arrayList2.size(); i8++) {
            MessageObject messageObject4 = (MessageObject) arrayList2.get(i8);
            if (!this.filteredMessagesDict.containsKey(messageObject4.getId())) {
                messageObject4.isOutOwnerCached = null;
                TLRPC.Message message3 = messageObject4.messageOwner;
                if (message3 != null) {
                    message3.out = true;
                }
                this.chatAdapter.filteredMessages.add(messageObject4);
                this.filteredMessagesDict.put(messageObject4.getId(), messageObject4);
            }
        }
        int i9 = 0;
        while (i9 < this.chatAdapter.filteredMessages.size()) {
            MessageObject messageObject5 = (MessageObject) this.chatAdapter.filteredMessages.get(i9);
            if (messageObject5.hasValidGroupId() && (groupedMessages = (MessageObject.GroupedMessages) this.groupedMessagesMap.get(messageObject5.getGroupId())) != null) {
                for (int size = groupedMessages.messages.size() - 1; size >= 0; size--) {
                    MessageObject messageObject6 = (MessageObject) groupedMessages.messages.get(size);
                    if (messageObject6 != messageObject5 && !this.filteredMessagesDict.containsKey(messageObject6.getId())) {
                        this.chatAdapter.filteredMessages.add(i9, messageObject6);
                        this.filteredMessagesDict.put(messageObject6.getId(), messageObject6);
                        i9++;
                    }
                }
            }
            i9++;
        }
        Collections.sort(this.chatAdapter.filteredMessages, new Comparator() {
            @Override
            public final int compare(Object obj, Object obj2) {
                int lambda$updateFilteredMessages$78;
                lambda$updateFilteredMessages$78 = ChatActivity.lambda$updateFilteredMessages$78((MessageObject) obj, (MessageObject) obj2);
                return lambda$updateFilteredMessages$78;
            }
        });
        MessageObject messageObject7 = null;
        int i10 = 0;
        while (i10 < this.chatAdapter.filteredMessages.size()) {
            MessageObject messageObject8 = (MessageObject) this.chatAdapter.filteredMessages.get(i10);
            if (this.reversed && messageObject8 != null && i10 == 0) {
                putFilteredDate(i10, messageObject8);
                i10++;
            }
            if (!this.reversed && messageObject7 != null && messageObject8.dateKeyInt != messageObject7.dateKeyInt) {
                putFilteredDate(i10, messageObject7);
                i10++;
            }
            ArrayList arrayList3 = (ArrayList) this.filteredMessagesByDays.get(messageObject8.dateKeyInt);
            if (arrayList3 == null) {
                LongSparseArray longSparseArray4 = this.filteredMessagesByDays;
                long j = messageObject8.dateKeyInt;
                ArrayList arrayList4 = new ArrayList();
                longSparseArray4.put(j, arrayList4);
                arrayList3 = arrayList4;
            }
            arrayList3.add(messageObject8);
            if (this.reversed && messageObject7 != null && messageObject8.dateKeyInt != messageObject7.dateKeyInt) {
                putFilteredDate(i10, messageObject8);
                i10++;
            }
            if (!this.reversed && i10 >= this.chatAdapter.filteredMessages.size() - 1) {
                putFilteredDate(this.chatAdapter.filteredMessages.size(), messageObject8);
                i10++;
            }
            i10++;
            messageObject7 = messageObject8;
        }
        this.chatAdapter.filteredEndReached = MediaDataController.getInstance(((BaseFragment) this).currentAccount).searchEndReached();
        if (z) {
            this.chatAdapter.updateRowsSafe();
            this.chatAdapter.notifyDataSetChanged(true);
            if (this.chatAdapter.isFiltered ? !getMediaDataController().isSearchLoading() || !this.chatAdapter.filteredMessages.isEmpty() : !this.loading || !this.messages.isEmpty() || this.chatAdapter.botInfoRow >= 0) {
                z2 = false;
            }
            showProgressView(z2);
            if (this.chatListView != null) {
                createEmptyView(false);
                if (this.chatAdapter.isFiltered ? getMediaDataController().isSearchLoading() || !this.chatAdapter.filteredMessages.isEmpty() : this.loading || !this.messages.isEmpty() || this.chatAdapter.botInfoRow >= 0) {
                    this.emptyViewContainer.setVisibility(8);
                    this.chatListView.setEmptyView((View) null);
                } else {
                    this.chatListView.setEmptyView(this.emptyViewContainer);
                    this.chatListView.checkIfEmpty();
                }
            }
        }
    }

    public void updateFloatingTopicView() {
        TopicSeparator.Cell cell = this.floatingTopicSeparator;
        if (cell == null) {
            return;
        }
        cell.setTranslationX(getSideMenuWidth() / 2.0f);
        this.floatingTopicSeparator.setTranslationY((((this.chatListView.getTranslationY() + this.chatListViewPaddingTop) + this.floatingTopicViewOffset) - AndroidUtilities.dp(4.0f)) + AndroidUtilities.dp(28.0f));
        float clamp = Utilities.clamp(AndroidUtilities.ilerp(this.floatingTopicViewOffset, -this.floatingTopicSeparator.getHeight(), 0.0f), 1.0f, 0.0f);
        this.floatingTopicSeparator.setAlpha(this.floatingTopicViewAlpha * clamp);
        float lerp = AndroidUtilities.lerp(0.5f, 1.0f, clamp);
        this.floatingTopicSeparator.setScaleX(lerp);
        this.floatingTopicSeparator.setScaleY(lerp);
    }

    private void updateGreetInfo() {
        TLRPC.UserFull userFull;
        showGreetInfo((getDialogId() == getUserConfig().getClientUserId() || (userFull = this.userInfo) == null || userFull.business_intro == null || (userFull.contact_require_premium && !getUserConfig().isPremium()) || this.userInfo.send_paid_messages_stars > 0) ? false : true);
    }

    private void updateGreetingLock() {
        TLRPC.Chat chat;
        if (this.greetingsViewContainer == null) {
            return;
        }
        if (ChatObject.isMonoForum(this.currentChat)) {
            TLRPC.Chat linkedMonoForumChat = getLinkedMonoForumChat();
            if (linkedMonoForumChat != null && (chat = this.currentChat) != null && !ChatObject.canManageMonoForum(((BaseFragment) this).currentAccount, chat)) {
                final long j = this.currentChat.send_paid_messages_stars;
                this.greetingsViewContainer.setPremiumLock(true, true, AndroidUtilities.replaceTags(StarsIntroActivity.replaceStars(j > 0 ? LocaleController.formatString(R.string.SuggestionLockedStars, new Object[]{DialogObject.getShortName(-linkedMonoForumChat.id), LocaleController.formatNumber(j, ',')}) : LocaleController.formatString(R.string.SuggestionUnlockedStars, new Object[]{DialogObject.getShortName(-linkedMonoForumChat.id)}), 1.0f)), j > 0 ? LocaleController.getString(R.string.MessageStarsUnlock) : null, new View.OnClickListener() {
                    @Override
                    public final void onClick(View view) {
                        ChatActivity.this.lambda$updateGreetingLock$303(j, view);
                    }
                });
                return;
            }
        } else if (getDialogId() != getUserConfig().getClientUserId()) {
            TLRPC.UserFull userFull = this.userInfo;
            if (userFull != null && userFull.contact_require_premium) {
                this.greetingsViewContainer.setPremiumLock(!getUserConfig().isPremium(), AndroidUtilities.replaceTags(LocaleController.formatString(getMessagesController().premiumFeaturesBlocked() ? R.string.MessageLockedPremiumLocked : R.string.MessageLockedPremium, new Object[]{DialogObject.getShortName(this.dialog_id)})), LocaleController.getString(R.string.MessagePremiumUnlock), new View.OnClickListener() {
                    @Override
                    public final void onClick(View view) {
                        ChatActivity.lambda$updateGreetingLock$304(view);
                    }
                });
                return;
            } else if (userFull != null) {
                final long j2 = userFull.send_paid_messages_stars;
                if (j2 > 0) {
                    this.greetingsViewContainer.setPremiumLock(j2 > 0, AndroidUtilities.replaceTags(StarsIntroActivity.replaceStars(LocaleController.formatString(R.string.MessageLockedStars, new Object[]{DialogObject.getShortName(this.dialog_id), LocaleController.formatNumber(this.userInfo.send_paid_messages_stars, ',')}), 1.0f)), LocaleController.getString(R.string.MessageStarsUnlock), new View.OnClickListener() {
                        @Override
                        public final void onClick(View view) {
                            ChatActivity.this.lambda$updateGreetingLock$305(j2, view);
                        }
                    });
                    return;
                }
            }
        }
        this.greetingsViewContainer.resetPremiumLock();
    }

    private void updateInfoTopView(boolean r12) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.updateInfoTopView(boolean):void");
    }

    private void updateInformationForScreenshotDetector() {
        if (this.currentUser == null) {
            return;
        }
        if (this.currentEncryptedChat == null) {
            SecretMediaViewer secretMediaViewer = SecretMediaViewer.getInstance();
            MessageObject currentMessageObject = secretMediaViewer.getCurrentMessageObject();
            if (currentMessageObject == null || currentMessageObject.isOut()) {
                return;
            }
            MediaController.getInstance().setLastVisibleMessageIds(((BaseFragment) this).currentAccount, secretMediaViewer.getOpenTime(), secretMediaViewer.getCloseTime(), this.currentUser, (TLRPC.EncryptedChat) null, (ArrayList) null, currentMessageObject.getId());
            return;
        }
        ArrayList arrayList = new ArrayList();
        RecyclerListView recyclerListView = this.chatListView;
        if (recyclerListView != null) {
            int childCount = recyclerListView.getChildCount();
            for (int i = 0; i < childCount; i++) {
                View childAt = this.chatListView.getChildAt(i);
                MessageObject messageObject = childAt instanceof ChatMessageCell ? ((ChatMessageCell) childAt).getMessageObject() : null;
                if (messageObject != null && messageObject.getId() < 0) {
                    long j = messageObject.messageOwner.random_id;
                    if (j != 0) {
                        arrayList.add(Long.valueOf(j));
                    }
                }
            }
        }
        MediaController.getInstance().setLastVisibleMessageIds(((BaseFragment) this).currentAccount, this.chatEnterTime, this.chatLeaveTime, this.currentUser, this.currentEncryptedChat, arrayList, 0);
    }

    public void updateMessageAnimated(final MessageObject messageObject, final boolean z) {
        if (this.chatAdapter == null) {
            return;
        }
        getNotificationCenter().doOnIdle(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$updateMessageAnimated$308(messageObject, z);
            }
        });
    }

    public void lambda$updateMessageAnimated$308(MessageObject messageObject, boolean z) {
        if (this.chatAdapter == null || ((BaseFragment) this).fragmentView == null) {
            return;
        }
        MessageObject.GroupedMessages groupedMessages = (MessageObject.GroupedMessages) this.groupedMessagesMap.get(messageObject.getGroupId());
        if (groupedMessages != null) {
            ChatListItemAnimator chatListItemAnimator = this.chatListItemAnimator;
            if (chatListItemAnimator != null) {
                chatListItemAnimator.groupWillChanged(groupedMessages);
            }
            for (int i = 0; i < groupedMessages.messages.size(); i++) {
                ((MessageObject) groupedMessages.messages.get(i)).forceUpdate = true;
                if (z) {
                    ((MessageObject) groupedMessages.messages.get(i)).reactionsChanged = true;
                }
            }
            this.chatAdapter.notifyDataSetChanged(true);
            return;
        }
        MessageObject messageObject2 = (MessageObject) this.messagesDict[0].get(messageObject.getId());
        if (z) {
            messageObject.forceUpdate = true;
            messageObject.reactionsChanged = true;
        }
        if (!this.chatAdapter.isFiltered) {
            int indexOf = this.messages.indexOf(messageObject2);
            if (indexOf >= 0) {
                ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
                chatActivityAdapter.notifyItemChanged(chatActivityAdapter.messagesStartRow + indexOf);
                return;
            }
            return;
        }
        LongSparseArray longSparseArray = this.filteredMessagesDict;
        MessageObject messageObject3 = longSparseArray != null ? (MessageObject) longSparseArray.get(messageObject.getId()) : null;
        int indexOf2 = this.chatAdapter.filteredMessages.indexOf(messageObject3);
        if (messageObject3 != null && z) {
            messageObject3.forceUpdate = true;
            messageObject3.reactionsChanged = true;
        }
        if (indexOf2 >= 0) {
            ChatActivityAdapter chatActivityAdapter2 = this.chatAdapter;
            chatActivityAdapter2.notifyItemChanged(chatActivityAdapter2.messagesStartRow + indexOf2);
        }
    }

    public void updateMessageListAccessibilityVisibility() {
        ActionBarPopupWindow actionBarPopupWindow;
        if (this.currentEncryptedChat != null) {
            return;
        }
        RecyclerListView recyclerListView = this.chatListView;
        MentionsContainerView mentionsContainerView = this.mentionContainer;
        recyclerListView.setImportantForAccessibility(((mentionsContainerView == null || !mentionsContainerView.isOpen()) && ((actionBarPopupWindow = this.scrimPopupWindow) == null || !actionBarPopupWindow.isShowing())) ? 0 : 4);
    }

    private boolean updateMessageTranslation(org.telegram.messenger.MessageObject r18) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.updateMessageTranslation(org.telegram.messenger.MessageObject):boolean");
    }

    private boolean updateMessagesReplyTranslation(ArrayList arrayList, MessageObject messageObject) {
        ChatMessageCell chatMessageCell;
        MessageObject messageObject2;
        MessageObject messageObject3;
        boolean z = false;
        for (int i = 0; i < this.chatListView.getChildCount(); i++) {
            View childAt = this.chatListView.getChildAt(i);
            if ((childAt instanceof ChatMessageCell) && (messageObject2 = (chatMessageCell = (ChatMessageCell) childAt).getMessageObject()) != null && arrayList.contains(Integer.valueOf(messageObject2.getId())) && (messageObject3 = messageObject2.replyMessageObject) != null && messageObject3.getId() == messageObject.getId()) {
                MessageObject messageObject4 = messageObject2.replyMessageObject;
                TLRPC.Message message = messageObject4.messageOwner;
                TLRPC.Message message2 = messageObject.messageOwner;
                message.translatedText = message2.translatedText;
                message.translatedToLanguage = message2.translatedToLanguage;
                if (messageObject4.updateTranslation(false)) {
                    z = true;
                    messageObject2.forceUpdate = true;
                    chatMessageCell.setMessageObject(messageObject2, chatMessageCell.getCurrentMessagesGroup(), chatMessageCell.isPinnedBottom(), chatMessageCell.isPinnedTop(), chatMessageCell.isFirstInChat());
                    this.chatAdapter.updateRowAtPosition(this.chatListView.getChildAdapterPosition(childAt));
                }
            }
        }
        return z;
    }

    public void updatePagedownButtonVisibility(boolean z) {
        ValueAnimator valueAnimator;
        AnimatorListenerAdapter animatorListenerAdapter;
        if (this.pagedownButton == null) {
            return;
        }
        if (!this.canShowPagedownButton || this.textSelectionHelper.isInSelectionMode() || this.chatActivityEnterView.isRecordingAudioVideo() || this.isInsideContainer || (this.searching && !getMediaDataController().searchResultMessages.isEmpty())) {
            this.returnToMessageId = 0;
            this.newUnreadMessageCount = 0;
            if (this.pagedownButton.getTag() == null) {
                return;
            }
            this.pagedownButton.setTag(null);
            ValueAnimator valueAnimator2 = this.pagedownButtonAnimation;
            if (valueAnimator2 != null) {
                valueAnimator2.removeAllListeners();
                this.pagedownButtonAnimation.cancel();
                this.pagedownButtonAnimation = null;
            }
            if (!z) {
                this.pagedownButtonEnterProgress = 0.0f;
                this.pagedownButton.setVisibility(4);
                return;
            }
            this.pagedownButton.setVisibility(0);
            ValueAnimator ofFloat = ValueAnimator.ofFloat(this.pagedownButtonEnterProgress, 0.0f);
            this.pagedownButtonAnimation = ofFloat;
            ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public final void onAnimationUpdate(ValueAnimator valueAnimator3) {
                    ChatActivity.this.lambda$updatePagedownButtonVisibility$157(valueAnimator3);
                }
            });
            valueAnimator = this.pagedownButtonAnimation;
            animatorListenerAdapter = new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animator) {
                    ChatActivity.this.pagedownButtonEnterProgress = 0.0f;
                    ChatActivity.this.pagedownButton.setVisibility(4);
                    ChatActivity.this.contentView.invalidate();
                }
            };
        } else {
            if (z && (this.openAnimationStartTime == 0 || SystemClock.elapsedRealtime() < this.openAnimationStartTime + 150)) {
                z = false;
            }
            this.pagedownButtonShowedByScroll = false;
            if (this.pagedownButton.getTag() != null) {
                return;
            }
            ValueAnimator valueAnimator3 = this.pagedownButtonAnimation;
            if (valueAnimator3 != null) {
                valueAnimator3.removeAllListeners();
                this.pagedownButtonAnimation.cancel();
                this.pagedownButtonAnimation = null;
            }
            this.pagedownButton.setTag(1);
            if (!z) {
                this.pagedownButtonEnterProgress = 1.0f;
                this.contentView.invalidate();
                this.pagedownButton.setVisibility(0);
                return;
            } else {
                this.pagedownButton.setVisibility(0);
                ValueAnimator ofFloat2 = ValueAnimator.ofFloat(this.pagedownButtonEnterProgress, 1.0f);
                this.pagedownButtonAnimation = ofFloat2;
                ofFloat2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                    @Override
                    public final void onAnimationUpdate(ValueAnimator valueAnimator4) {
                        ChatActivity.this.lambda$updatePagedownButtonVisibility$156(valueAnimator4);
                    }
                });
                valueAnimator = this.pagedownButtonAnimation;
                animatorListenerAdapter = new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animator) {
                        ChatActivity.this.pagedownButtonEnterProgress = 1.0f;
                        ChatActivity.this.contentView.invalidate();
                    }
                };
            }
        }
        valueAnimator.addListener(animatorListenerAdapter);
        this.pagedownButtonAnimation.setDuration(200L);
        this.pagedownButtonAnimation.start();
    }

    public void updatePagedownButtonsPosition() {
        float animatedTop = this.chatActivityEnterView.getAnimatedTop() + this.chatActivityEnterView.getTranslationY() + (this.chatActivityEnterTopView.getVisibility() == 0 ? this.chatActivityEnterTopView.getTranslationY() : 0.0f);
        FrameLayout frameLayout = this.pagedownButton;
        if (frameLayout != null) {
            frameLayout.setTranslationY((AndroidUtilities.dp(100.0f) * (1.0f - this.pagedownButtonEnterProgress)) + animatedTop);
        }
        FrameLayout frameLayout2 = this.searchUpButton;
        if (frameLayout2 != null) {
            frameLayout2.setTranslationY((animatedTop - (AndroidUtilities.dp(51.33f) * this.searchUpDownEnterProgress)) + (AndroidUtilities.dp(100.0f) * (1.0f - this.searchUpDownEnterProgress)));
        }
        FrameLayout frameLayout3 = this.searchDownButton;
        if (frameLayout3 != null) {
            frameLayout3.setTranslationY((AndroidUtilities.dp(100.0f) * (1.0f - this.searchUpDownEnterProgress)) + animatedTop);
        }
        FrameLayout frameLayout4 = this.mentiondownButton;
        if (frameLayout4 != null) {
            frameLayout4.setTranslationY(((AndroidUtilities.dp(100.0f) * (1.0f - this.mentionsButtonEnterProgress)) + animatedTop) - ((AndroidUtilities.dp(72.0f) * this.pagedownButtonEnterProgress) * this.mentionsButtonEnterProgress));
        }
        FrameLayout frameLayout5 = this.reactionsMentiondownButton;
        if (frameLayout5 != null) {
            frameLayout5.setTranslationY(((AndroidUtilities.dp(100.0f) * (1.0f - this.reactionsMentionButtonEnterProgress)) + animatedTop) - ((((AndroidUtilities.dp(50.0f) + (AndroidUtilities.dp(22.0f) * this.pagedownButtonCounter.getEnterProgress())) * this.pagedownButtonEnterProgress) + (AndroidUtilities.dp(72.0f) * this.mentionsButtonEnterProgress)) * this.reactionsMentionButtonEnterProgress));
        }
        SuggestEmojiView suggestEmojiView = this.suggestEmojiPanel;
        if (suggestEmojiView != null) {
            suggestEmojiView.setTranslationY(animatedTop);
        }
    }

    private void updatePinnedListButton(boolean r24) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.updatePinnedListButton(boolean):void");
    }

    public void updatePinnedMessageView(boolean z) {
        lambda$updateMessagesVisiblePart$150(z, 0);
    }

    public void lambda$updateMessagesVisiblePart$150(boolean r34, int r35) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.lambda$updateMessagesVisiblePart$150(boolean, int):void");
    }

    private void updateReactionsMentionButton(boolean z) {
        float f;
        ValueAnimator valueAnimator;
        AnimatorListenerAdapter animatorListenerAdapter;
        int i;
        if (this.reactionsMentiondownButtonCounter == null || getParentActivity() == null) {
            return;
        }
        int i2 = this.reactionsMentionCount;
        boolean z2 = i2 > 0 && ((i = this.chatMode) == 0 || i == 8);
        this.reactionsMentiondownButtonCounter.setCount(i2, z);
        if (z2 && this.reactionsMentiondownButton.getTag() == null) {
            this.reactionsMentiondownButton.setTag(1);
            ValueAnimator valueAnimator2 = this.reactionsMentionButtonAnimation;
            if (valueAnimator2 != null) {
                valueAnimator2.removeAllListeners();
                this.reactionsMentionButtonAnimation.cancel();
                this.reactionsMentionButtonAnimation = null;
            }
            f = 1.0f;
            if (!z) {
                this.reactionsMentiondownButton.setVisibility(0);
                this.reactionsMentionButtonEnterProgress = f;
                this.contentView.invalidate();
                return;
            }
            this.reactionsMentiondownButton.setVisibility(0);
            ValueAnimator ofFloat = ValueAnimator.ofFloat(this.reactionsMentionButtonEnterProgress, 1.0f);
            this.reactionsMentionButtonAnimation = ofFloat;
            ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public final void onAnimationUpdate(ValueAnimator valueAnimator3) {
                    ChatActivity.this.lambda$updateReactionsMentionButton$102(valueAnimator3);
                }
            });
            valueAnimator = this.reactionsMentionButtonAnimation;
            animatorListenerAdapter = new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animator) {
                    ChatActivity.this.reactionsMentionButtonEnterProgress = 1.0f;
                    ChatActivity.this.contentView.invalidate();
                }
            };
            valueAnimator.addListener(animatorListenerAdapter);
            this.reactionsMentionButtonAnimation.setDuration(200L);
            this.reactionsMentionButtonAnimation.start();
        }
        if (z2 || this.reactionsMentiondownButton.getTag() == null) {
            return;
        }
        this.reactionsMentiondownButton.setTag(null);
        ValueAnimator valueAnimator3 = this.reactionsMentionButtonAnimation;
        if (valueAnimator3 != null) {
            valueAnimator3.removeAllListeners();
            this.reactionsMentionButtonAnimation.cancel();
            this.reactionsMentionButtonAnimation = null;
        }
        f = 0.0f;
        if (!z) {
            this.reactionsMentiondownButton.setVisibility(4);
            this.reactionsMentionButtonEnterProgress = f;
            this.contentView.invalidate();
            return;
        }
        this.reactionsMentiondownButton.setVisibility(0);
        ValueAnimator ofFloat2 = ValueAnimator.ofFloat(this.reactionsMentionButtonEnterProgress, 0.0f);
        this.reactionsMentionButtonAnimation = ofFloat2;
        ofFloat2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public final void onAnimationUpdate(ValueAnimator valueAnimator4) {
                ChatActivity.this.lambda$updateReactionsMentionButton$103(valueAnimator4);
            }
        });
        valueAnimator = this.reactionsMentionButtonAnimation;
        animatorListenerAdapter = new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animator) {
                ChatActivity.this.reactionsMentiondownButton.setVisibility(4);
                ChatActivity.this.reactionsMentionButtonEnterProgress = 0.0f;
                ChatActivity.this.contentView.invalidate();
            }
        };
        valueAnimator.addListener(animatorListenerAdapter);
        this.reactionsMentionButtonAnimation.setDuration(200L);
        this.reactionsMentionButtonAnimation.start();
    }

    private void updateReplyMessageOwners(int i, MessageObject messageObject) {
        ArrayList arrayList = (ArrayList) this.replyMessageOwners.get(i);
        if (arrayList == null) {
            return;
        }
        MessageObject messageObject2 = messageObject == null ? new MessageObject(((BaseFragment) this).currentAccount, new TLRPC.TL_messageEmpty(), false, false) : null;
        int size = arrayList.size();
        for (int i2 = 0; i2 < size; i2++) {
            MessageObject messageObject3 = (MessageObject) this.messagesDict[0].get(((Integer) arrayList.get(i2)).intValue());
            if (messageObject3 != null) {
                if (messageObject == null) {
                    messageObject3.replyMessageObject = messageObject2;
                } else {
                    messageObject3.replyMessageObject = messageObject;
                }
                ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
                if (chatActivityAdapter != null) {
                    chatActivityAdapter.updateRowWithMessageObject(messageObject3, true, false);
                }
            }
        }
        if (messageObject == null) {
            this.replyMessageOwners.remove(i);
        }
    }

    public void updateScheduledInterface(boolean z) {
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView != null) {
            chatActivityEnterView.updateScheduleButton(z);
        }
    }

    public void updateSearchButtons(int i, int i2, int i3) {
        FrameLayout frameLayout = this.searchUpButton;
        if (frameLayout != null) {
            frameLayout.setEnabled(((this.reversed ? 2 : 1) & i) != 0);
            this.searchUpButtonArrow.setAlpha(this.searchUpButton.isEnabled() ? 1.0f : 0.5f);
        }
        FrameLayout frameLayout2 = this.searchDownButton;
        if (frameLayout2 != null) {
            frameLayout2.setEnabled((i & (this.reversed ? 1 : 2)) != 0);
            this.searchDownButtonArrow.setAlpha(this.searchDownButton.isEnabled() ? 1.0f : 0.5f);
        }
        this.searchLastCount = i3;
        this.searchLastIndex = i2;
        updateSearchCountText();
        AnimatedTextView animatedTextView = this.searchExpandList;
        if (animatedTextView != null) {
            animatedTextView.setClickable(i3 > 0);
            this.searchExpandList.animate().alpha(i3 > 0 ? 1.0f : 0.5f).start();
        }
    }

    private void updateSearchCountText() {
        String formatPluralString;
        AnimatedTextView animatedTextView = this.searchCountText;
        if (animatedTextView != null) {
            boolean z = !LocaleController.isRTL;
            int i = this.searchLastCount;
            if (i < 0) {
                formatPluralString = "";
            } else if (i == 0) {
                formatPluralString = LocaleController.getString(R.string.NoResult);
            } else if (this.searchingFiltered) {
                formatPluralString = LocaleController.formatPluralString("TaggedMessages", i, new Object[0]);
            } else if (this.chatMode == 7 || this.messagesSearchListContainer.getTag() != null) {
                animatedTextView = this.searchCountText;
                int i2 = this.searchLastCount;
                formatPluralString = LocaleController.formatPluralString("SearchMessagesResultCount", i2, new Object[]{LocaleController.formatNumber(i2, ' ')});
            } else {
                animatedTextView = this.searchCountText;
                formatPluralString = LocaleController.formatString(R.string.Of, new Object[]{Integer.valueOf(this.searchLastIndex + 1), Integer.valueOf(this.searchLastCount)});
            }
            animatedTextView.setText(formatPluralString, z);
        }
    }

    public void updateSearchListEmptyView() {
        String str = this.searchingHashtag;
        if (str != null) {
            this.hashtagSearchEmptyView.subtitle.setText(LocaleController.formatString(R.string.HashtagSearchEmptyViewFilteredSubtitle, new Object[]{str}));
            this.messagesSearchListView.setEmptyView(this.hashtagSearchEmptyView);
        } else {
            this.messagesSearchListView.setEmptyView((View) null);
            this.hashtagSearchEmptyView.setVisibility(8);
        }
    }

    public void updateSearchUpDownButtonVisibility(boolean z) {
        ValueAnimator valueAnimator;
        AnimatorListenerAdapter animatorListenerAdapter;
        if (this.searchUpButton == null || this.searchDownButton == null) {
            return;
        }
        if ((getMediaDataController().searchResultMessages.isEmpty() || !this.searching || this.searchingFiltered) && !(this.chatMode == 7 && this.searchType == 2 && !this.messages.isEmpty())) {
            this.returnToMessageId = 0;
            if (this.searchUpButton.getTag() == null) {
                return;
            }
            this.searchUpButton.setTag(null);
            ValueAnimator valueAnimator2 = this.searchUpButtonAnimation;
            if (valueAnimator2 != null) {
                valueAnimator2.removeAllListeners();
                this.searchUpButtonAnimation.cancel();
                this.searchUpButtonAnimation = null;
            }
            if (!z) {
                this.searchUpDownEnterProgress = 0.0f;
                this.searchUpButton.setVisibility(4);
                this.searchDownButton.setVisibility(4);
                return;
            } else {
                ValueAnimator ofFloat = ValueAnimator.ofFloat(this.searchUpDownEnterProgress, 0.0f);
                this.searchUpButtonAnimation = ofFloat;
                ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                    @Override
                    public final void onAnimationUpdate(ValueAnimator valueAnimator3) {
                        ChatActivity.this.lambda$updateSearchUpDownButtonVisibility$159(valueAnimator3);
                    }
                });
                valueAnimator = this.searchUpButtonAnimation;
                animatorListenerAdapter = new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animator) {
                        ChatActivity.this.searchUpDownEnterProgress = 0.0f;
                        ChatActivity.this.searchUpButton.setVisibility(4);
                        ChatActivity.this.searchDownButton.setVisibility(4);
                        ChatActivity.this.contentView.invalidate();
                    }
                };
            }
        } else {
            if (this.searchUpButton.getTag() != null) {
                return;
            }
            ValueAnimator valueAnimator3 = this.searchUpButtonAnimation;
            if (valueAnimator3 != null) {
                valueAnimator3.removeAllListeners();
                this.searchUpButtonAnimation.cancel();
                this.searchUpButtonAnimation = null;
            }
            if (!z) {
                this.searchUpDownEnterProgress = 1.0f;
                this.contentView.invalidate();
                return;
            }
            this.searchUpButton.setVisibility(0);
            this.searchDownButton.setVisibility(0);
            this.searchUpButton.setTag(1);
            ValueAnimator ofFloat2 = ValueAnimator.ofFloat(this.searchUpDownEnterProgress, 1.0f);
            this.searchUpButtonAnimation = ofFloat2;
            ofFloat2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public final void onAnimationUpdate(ValueAnimator valueAnimator4) {
                    ChatActivity.this.lambda$updateSearchUpDownButtonVisibility$158(valueAnimator4);
                }
            });
            valueAnimator = this.searchUpButtonAnimation;
            animatorListenerAdapter = new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animator) {
                    ChatActivity.this.searchUpDownEnterProgress = 1.0f;
                    ChatActivity.this.contentView.invalidate();
                }
            };
        }
        valueAnimator.addListener(animatorListenerAdapter);
        this.searchUpButtonAnimation.setDuration(200L);
        this.searchUpButtonAnimation.start();
    }

    private void updateSecretStatus() {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.updateSecretStatus():void");
    }

    private void updateSelectedMessageReactions() {
        boolean z;
        if (getDialogId() == getUserConfig().getClientUserId()) {
            ArrayList arrayList = new ArrayList();
            for (int i = 0; i < this.selectedMessagesIds.length; i++) {
                for (int i2 = 0; i2 < this.selectedMessagesIds[i].size(); i2++) {
                    MessageObject messageObject = (MessageObject) this.selectedMessagesIds[i].valueAt(i2);
                    if (messageObject.hasValidGroupId()) {
                        MessageObject.GroupedMessages validGroupedMessage = getValidGroupedMessage(messageObject);
                        MessageObject.GroupedMessagePosition position = validGroupedMessage != null ? validGroupedMessage.getPosition(messageObject) : null;
                        if (position != null) {
                            if (!position.last) {
                            }
                        }
                    }
                    arrayList.add(messageObject);
                }
            }
            ReactionsContainerLayout reactionsContainerLayout = this.tagSelector;
            if (reactionsContainerLayout != null) {
                reactionsContainerLayout.setSelectedReactionsInclusive(arrayList);
                z = !this.tagSelector.getSelectedReactions().isEmpty();
                this.tagSelector.setHint(LocaleController.getString(!z ? R.string.SavedTagReactionsSelectedAddHint : R.string.SavedTagReactionsSelectedEditHint));
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.this.lambda$updateSelectedMessageReactions$164();
                    }
                }, 120L);
            } else {
                z = !ReactionsContainerLayout.getInclusiveReactions(arrayList).isEmpty();
            }
            ActionBarMenuItem item = ((BaseFragment) this).actionBar.createActionMode().getItem(28);
            if (item != null) {
                item.setIcon(z ? R.drawable.menu_tag_edit : R.drawable.menu_tag_plus, true);
            }
        }
        if (this.selectionReactionsOverlay != null) {
            ArrayList arrayList2 = new ArrayList();
            SparseArray sparseArray = this.selectedMessagesIds[0];
            for (int i3 = 0; i3 < sparseArray.size(); i3++) {
                arrayList2.add((MessageObject) sparseArray.valueAt(i3));
            }
            SparseArray sparseArray2 = this.selectedMessagesIds[1];
            for (int i4 = 0; i4 < sparseArray2.size(); i4++) {
                arrayList2.add((MessageObject) sparseArray2.valueAt(i4));
            }
            this.selectionReactionsOverlay.setSelectedMessages(arrayList2);
        }
    }

    public void updateTitleIcons() {
        updateTitleIcons(false);
    }

    private void updateTitleIcons(boolean z) {
        ChatAvatarContainer chatAvatarContainer;
        ActionBarMenuItem.Item item;
        ActionBarMenuItem.Item item2;
        int i;
        if (this.avatarContainer != null) {
            int i2 = this.chatMode;
            if (i2 == 0 || i2 == 8) {
                boolean isDialogMuted = getMessagesController().isDialogMuted(this.dialog_id, getTopicId());
                if (z) {
                    isDialogMuted = !isDialogMuted;
                }
                Drawable drawable = null;
                Drawable themedDrawable = (UserObject.isReplyUser(this.currentUser) || (isThreadChat() && !this.isTopic) || !isDialogMuted) ? null : getThemedDrawable("drawableMuteIcon");
                if (this.currentEncryptedChat != null) {
                    drawable = getThemedDrawable("drawableLockIcon");
                } else {
                    TLObject tLObject = this.currentChat;
                    if (tLObject != null) {
                        chatAvatarContainer = this.avatarContainer;
                    } else {
                        TLRPC.User user = this.currentUser;
                        if (user != null && !UserObject.isUserSelf(user)) {
                            chatAvatarContainer = this.avatarContainer;
                            tLObject = this.currentUser;
                        }
                    }
                    drawable = chatAvatarContainer.getBotVerificationDrawable(DialogObject.getBotVerificationIcon(tLObject), false);
                }
                this.avatarContainer.setTitleIcons(drawable, themedDrawable);
                if (!z && (item = this.muteItem) != null) {
                    if (isDialogMuted) {
                        item.setRightIconVisibility(8);
                        this.muteItem.setText(LocaleController.getString(R.string.Unmute));
                        item2 = this.muteItem;
                        i = R.drawable.msg_mute;
                    } else {
                        item.setRightIconVisibility(0);
                        if (getMessagesController().isDialogNotificationsSoundEnabled(this.dialog_id, getTopicId())) {
                            this.muteItem.setText(LocaleController.getString(R.string.Mute));
                            item2 = this.muteItem;
                            i = R.drawable.msg_unmute;
                        } else {
                            this.muteItem.setText(LocaleController.getString(R.string.Mute));
                            item2 = this.muteItem;
                            i = R.drawable.msg_silent;
                        }
                    }
                    item2.setIcon(i);
                }
                ChatNotificationsPopupWrapper chatNotificationsPopupWrapper = this.chatNotificationsPopupWrapper;
                if (chatNotificationsPopupWrapper != null) {
                    chatNotificationsPopupWrapper.update(this.dialog_id, getTopicId(), (HashSet) null);
                }
            }
        }
    }

    public void updateTopPanelSidemenuTranslation() {
        float sideMenuWidth = getSideMenuWidth();
        PinnedLineView pinnedLineView = this.pinnedLineView;
        if (pinnedLineView != null) {
            pinnedLineView.setTranslationX(sideMenuWidth);
        }
        for (int i = 0; i < 2; i++) {
            TrackingWidthSimpleTextView trackingWidthSimpleTextView = this.pinnedNameTextView[i];
            if (trackingWidthSimpleTextView != null) {
                trackingWidthSimpleTextView.setTranslationX(sideMenuWidth);
            }
            SimpleTextView simpleTextView = this.pinnedMessageTextView[i];
            if (simpleTextView != null) {
                simpleTextView.setTranslationX(sideMenuWidth);
            }
            View view = this.pinnedMessageImageView[i];
            if (view != null) {
                view.setTranslationX(sideMenuWidth);
            }
        }
        NumberTextView numberTextView = this.pinnedCounterTextView;
        if (numberTextView != null) {
            numberTextView.setTranslationX(getSideMenuWidth() + this.pinnedCounterTextViewX);
        }
    }

    public void updateTopicButtons() {
        TLRPC.TL_forumTopic tL_forumTopic;
        ActionBarMenuItem.Item item = this.closeTopicItem;
        if (item != null) {
            TLRPC.Chat chat = this.currentChat;
            item.setVisibility((chat == null || !ChatObject.canManageTopic(((BaseFragment) this).currentAccount, chat, this.forumTopic) || (tL_forumTopic = this.forumTopic) == null || tL_forumTopic.closed) ? 8 : 0);
        }
    }

    private void updateTopicHeader() {
        TLRPC.TL_forumTopic tL_forumTopic;
        ChatAvatarContainer chatAvatarContainer = this.avatarContainer;
        if (chatAvatarContainer != null && (tL_forumTopic = this.forumTopic) != null) {
            chatAvatarContainer.setTitle(tL_forumTopic.title);
        }
        updateTopicTitleIcon();
    }

    private void updateTranslateItemVisibility() {
        ActionBarMenuItem.Item item = this.translateItem;
        if (item == null) {
            return;
        }
        item.setVisibility((getMessagesController().getTranslateController().isTranslateDialogHidden(getDialogId()) && getMessagesController().getTranslateController().isDialogTranslatable(getDialogId())) ? 0 : 8);
    }

    private void updateVisibleRows(Utilities.CallbackReturn callbackReturn) {
        int i;
        int i2;
        RecyclerListView recyclerListView = this.chatListView;
        if (recyclerListView == null) {
            return;
        }
        if (!this.wasManualScroll && this.unreadMessageObject != null) {
            int childCount = recyclerListView.getChildCount();
            int i3 = 0;
            while (true) {
                if (i3 >= childCount) {
                    break;
                }
                View childAt = this.chatListView.getChildAt(i3);
                if (childAt instanceof ChatMessageCell) {
                    MessageObject messageObject = ((ChatMessageCell) childAt).getMessageObject();
                    MessageObject messageObject2 = this.unreadMessageObject;
                    if (messageObject == messageObject2) {
                        if (this.messages.indexOf(messageObject2) >= 0) {
                            i = this.chatAdapter.messagesStartRow + this.messages.indexOf(this.unreadMessageObject);
                            i2 = getScrollingOffsetForView(childAt);
                        }
                    }
                }
                i3++;
            }
        }
        i = -1;
        i2 = 0;
        int childCount2 = this.chatListView.getChildCount();
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView != null) {
            chatActivityEnterView.getEditingMessageObject();
        }
        for (int i4 = 0; i4 < childCount2; i4++) {
            View childAt2 = this.chatListView.getChildAt(i4);
            if (childAt2 instanceof ChatMessageCell) {
                ChatMessageCell chatMessageCell = (ChatMessageCell) childAt2;
                MessageObject messageObject3 = chatMessageCell.getMessageObject();
                if (((Boolean) callbackReturn.run(messageObject3)).booleanValue()) {
                    messageObject3.forceUpdate = true;
                    chatMessageCell.setMessageObject(messageObject3, chatMessageCell.getCurrentMessagesGroup(), chatMessageCell.isPinnedBottom(), chatMessageCell.isPinnedTop(), chatMessageCell.isFirstInChat());
                    this.chatAdapter.updateRowAtPosition(this.chatListView.getChildAdapterPosition(chatMessageCell));
                }
            }
        }
        if (i != -1) {
            this.chatLayoutManager.scrollToPositionWithOffset(i, i2);
        }
    }

    private void updateVisibleRows(boolean r21) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.updateVisibleRows(boolean):void");
    }

    private void updateVisibleWallpaperActions() {
        MessageObject messageObject;
        if (this.chatListView == null || this.chatAdapter == null) {
            return;
        }
        for (int i = 0; i < this.chatListView.getChildCount(); i++) {
            View childAt = this.chatListView.getChildAt(i);
            int childAdapterPosition = this.chatListView.getChildAdapterPosition(childAt) - this.chatAdapter.messagesStartRow;
            if ((childAt instanceof ChatActionCell) && childAdapterPosition >= 0 && childAdapterPosition < this.messages.size() && (messageObject = (MessageObject) this.messages.get(childAdapterPosition)) != null && messageObject.isWallpaperForBoth()) {
                ((ChatActionCell) childAt).setMessageObject(messageObject, true);
            }
        }
    }

    public boolean allowFinishFragmentInsteadOfRemoveFromStack() {
        return !((BaseFragment) this).inPreviewMode;
    }

    protected boolean allowPresentFragment() {
        return !((BaseFragment) this).inPreviewMode;
    }

    public boolean allowSendGifs() {
        TLRPC.TL_chatBannedRights tL_chatBannedRights;
        return (ChatObject.isChannel(this.currentChat) && (tL_chatBannedRights = this.currentChat.banned_rights) != null && tL_chatBannedRights.send_gifs) ? false : true;
    }

    public void applyChatLinkMessageMaybe() {
        ArrayList arrayList;
        if (this.chatActivityEnterView == null || this.chatMode != 0 || this.resolvedChatLink == null) {
            return;
        }
        CharSequence applyMessageEntities = ChatActivityEnterView.applyMessageEntities((UserConfig.getInstance(((BaseFragment) this).currentAccount).isPremium() || UserConfig.getInstance(((BaseFragment) this).currentAccount).getClientUserId() == this.dialog_id || (arrayList = this.resolvedChatLink.entities) == null) ? this.resolvedChatLink.entities : (ArrayList) Collection.-EL.stream(arrayList).filter(new Predicate() {
            public Predicate and(Predicate predicate) {
                return Predicate.-CC.$default$and(this, predicate);
            }

            public Predicate negate() {
                return Predicate.-CC.$default$negate(this);
            }

            public Predicate or(Predicate predicate) {
                return Predicate.-CC.$default$or(this, predicate);
            }

            public final boolean test(Object obj) {
                boolean lambda$applyChatLinkMessageMaybe$251;
                lambda$applyChatLinkMessageMaybe$251 = ChatActivity.this.lambda$applyChatLinkMessageMaybe$251((TLRPC.MessageEntity) obj);
                return lambda$applyChatLinkMessageMaybe$251;
            }
        }).collect(Collectors.toCollection(new Supplier() {
            public final Object get() {
                return new ArrayList();
            }
        })), this.resolvedChatLink.message, this.chatActivityEnterView.getEditField().getPaint().getFontMetricsInt());
        if (applyMessageEntities != null && applyMessageEntities.length() > 0 && applyMessageEntities.charAt(0) == '@') {
            applyMessageEntities = TextUtils.concat(" ", applyMessageEntities);
        }
        this.chatActivityEnterView.setFieldText(applyMessageEntities, true, true);
        this.resolvedChatLink = null;
    }

    public void applyDraftMaybe(boolean z) {
        applyDraftMaybe(z, false);
    }

    public void applyDraftMaybe(boolean z, boolean z2) {
        TLRPC.DraftMessage draft;
        Long l;
        TLRPC.Message message;
        TLRPC.TL_forumTopic findTopic;
        MessageObject messageObject;
        TLRPC.SuggestedPost suggestedPost;
        ?? r11;
        TextStyleSpan textStyleSpan;
        Paint.FontMetricsInt fontMetricsInt;
        TLRPC.InputReplyTo inputReplyTo;
        if (this.chatActivityEnterView != null) {
            int i = this.chatMode;
            int i2 = 8;
            if (i == 0 || i == 8 || (i == 3 && getUserConfig().getClientUserId() == getSavedDialogId())) {
                if (this.chatMode == 8) {
                    if (!ChatObject.isMonoForum(this.currentChat)) {
                        return;
                    }
                    if (this.threadMessageId == 0 && ChatObject.canManageMonoForum(((BaseFragment) this).currentAccount, this.currentChat)) {
                        return;
                    }
                }
                if (isForumInViewAsMessagesMode()) {
                    Pair oneThreadDraft = getMediaDataController().getOneThreadDraft(this.dialog_id);
                    if (oneThreadDraft != null) {
                        l = (Long) oneThreadDraft.first;
                        draft = (TLRPC.DraftMessage) oneThreadDraft.second;
                    } else {
                        draft = null;
                        l = null;
                    }
                } else {
                    draft = getMediaDataController().getDraft(this.dialog_id, this.chatMode == 3 ? 0L : this.threadMessageId);
                    l = null;
                }
                MediaDataController.DraftVoice draftVoice = MediaDataController.getInstance(((BaseFragment) this).currentAccount).getDraftVoice(this.dialog_id, getTopicId());
                if (draft == null || (inputReplyTo = draft.reply_to) == null || inputReplyTo.reply_to_msg_id == 0) {
                    message = null;
                } else {
                    message = getMediaDataController().getDraftMessage(this.dialog_id, l != null ? l.longValue() : this.threadMessageId);
                }
                if ((!z2 || draft == null) && this.chatActivityEnterView.getFieldText() != null && (this.chatMode != 0 || getUserConfig().getClientUserId() != getDialogId() || draft == null || this.appliedDraftDate >= draft.date)) {
                    if (z && draft == null) {
                        this.chatActivityEnterView.setFieldText("");
                        this.chatActivityEnterView.setEffectId(0L);
                        hideFieldPanel(true);
                    }
                } else if (draftVoice != null) {
                    this.chatActivityEnterView.setVoiceDraft(draftVoice);
                } else if (draft != null) {
                    this.appliedDraftDate = draft.date;
                    this.chatActivityEnterView.setWebPage((TLRPC.WebPage) null, !draft.no_webpage);
                    if (draft.entities.isEmpty()) {
                        r11 = draft.message;
                    } else {
                        r11 = SpannableStringBuilder.valueOf(draft.message);
                        MediaDataController.sortEntities(draft.entities);
                        int i3 = 0;
                        while (i3 < draft.entities.size()) {
                            TLRPC.TL_messageEntityCustomEmoji tL_messageEntityCustomEmoji = (TLRPC.MessageEntity) draft.entities.get(i3);
                            boolean z3 = tL_messageEntityCustomEmoji instanceof TLRPC.TL_inputMessageEntityMentionName;
                            if (z3 || (tL_messageEntityCustomEmoji instanceof TLRPC.TL_messageEntityMentionName)) {
                                long j = z3 ? ((TLRPC.TL_inputMessageEntityMentionName) tL_messageEntityCustomEmoji).user_id.user_id : ((TLRPC.TL_messageEntityMentionName) tL_messageEntityCustomEmoji).user_id;
                                if (((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).offset + ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).length < r11.length() && r11.charAt(((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).offset + ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).length) == ' ') {
                                    ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).length++;
                                }
                                URLSpanUserMention uRLSpanUserMention = new URLSpanUserMention("" + j, 3);
                                int i4 = ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).offset;
                                r11.setSpan(uRLSpanUserMention, i4, ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).length + i4, 33);
                            } else {
                                if ((tL_messageEntityCustomEmoji instanceof TLRPC.TL_messageEntityCode) || (tL_messageEntityCustomEmoji instanceof TLRPC.TL_messageEntityPre)) {
                                    TextStyleSpan.TextStyleRun textStyleRun = new TextStyleSpan.TextStyleRun();
                                    textStyleRun.flags |= 4;
                                    textStyleSpan = new TextStyleSpan(textStyleRun);
                                } else if (tL_messageEntityCustomEmoji instanceof TLRPC.TL_messageEntityBold) {
                                    TextStyleSpan.TextStyleRun textStyleRun2 = new TextStyleSpan.TextStyleRun();
                                    textStyleRun2.flags |= 1;
                                    textStyleSpan = new TextStyleSpan(textStyleRun2);
                                } else if (tL_messageEntityCustomEmoji instanceof TLRPC.TL_messageEntityItalic) {
                                    TextStyleSpan.TextStyleRun textStyleRun3 = new TextStyleSpan.TextStyleRun();
                                    textStyleRun3.flags |= 2;
                                    textStyleSpan = new TextStyleSpan(textStyleRun3);
                                } else if (tL_messageEntityCustomEmoji instanceof TLRPC.TL_messageEntityStrike) {
                                    TextStyleSpan.TextStyleRun textStyleRun4 = new TextStyleSpan.TextStyleRun();
                                    textStyleRun4.flags |= i2;
                                    textStyleSpan = new TextStyleSpan(textStyleRun4);
                                } else if (tL_messageEntityCustomEmoji instanceof TLRPC.TL_messageEntityUnderline) {
                                    TextStyleSpan.TextStyleRun textStyleRun5 = new TextStyleSpan.TextStyleRun();
                                    textStyleRun5.flags |= 16;
                                    textStyleSpan = new TextStyleSpan(textStyleRun5);
                                } else if (tL_messageEntityCustomEmoji instanceof TLRPC.TL_messageEntityTextUrl) {
                                    URLSpanReplacement uRLSpanReplacement = new URLSpanReplacement(((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).url);
                                    int i5 = ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).offset;
                                    r11.setSpan(uRLSpanReplacement, i5, ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).length + i5, 33);
                                } else if (tL_messageEntityCustomEmoji instanceof TLRPC.TL_messageEntitySpoiler) {
                                    TextStyleSpan.TextStyleRun textStyleRun6 = new TextStyleSpan.TextStyleRun();
                                    textStyleRun6.flags |= 256;
                                    textStyleSpan = new TextStyleSpan(textStyleRun6);
                                } else if (tL_messageEntityCustomEmoji instanceof TLRPC.TL_messageEntityBlockquote) {
                                    int i6 = ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).offset;
                                    QuoteSpan.putQuoteToEditable((Editable) r11, i6, ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).length + i6, ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).collapsed);
                                } else if (tL_messageEntityCustomEmoji instanceof TLRPC.TL_messageEntityCustomEmoji) {
                                    try {
                                        fontMetricsInt = this.chatActivityEnterView.getEditField().getPaint().getFontMetricsInt();
                                    } catch (Exception e) {
                                        FileLog.e(e, false);
                                        fontMetricsInt = null;
                                    }
                                    TLRPC.TL_messageEntityCustomEmoji tL_messageEntityCustomEmoji2 = tL_messageEntityCustomEmoji;
                                    AnimatedEmojiSpan animatedEmojiSpan = tL_messageEntityCustomEmoji2.document != null ? new AnimatedEmojiSpan(tL_messageEntityCustomEmoji2.document, fontMetricsInt) : new AnimatedEmojiSpan(tL_messageEntityCustomEmoji2.document_id, fontMetricsInt);
                                    int i7 = ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).offset;
                                    r11.setSpan(animatedEmojiSpan, i7, ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).length + i7, 33);
                                }
                                int i8 = ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).offset;
                                MediaDataController.addStyleToText(textStyleSpan, i8, ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).length + i8, (Spannable) r11, true);
                            }
                            i3++;
                            i2 = 8;
                        }
                    }
                    this.chatActivityEnterView.setFieldText((CharSequence) r11, true, true);
                    if (getArguments().getBoolean("hasUrl", false)) {
                        this.chatActivityEnterView.setSelection(draft.message.indexOf(10) + 1);
                        AndroidUtilities.runOnUIThread(new Runnable() {
                            @Override
                            public final void run() {
                                ChatActivity.this.lambda$applyDraftMaybe$252();
                            }
                        }, 700L);
                    }
                    this.chatActivityEnterView.setEffectId(draft.effect);
                }
                if (draft != null && (suggestedPost = draft.suggested_post) != null) {
                    MessageSuggestionParams of = MessageSuggestionParams.of(suggestedPost);
                    this.messageSuggestionParams = of;
                    showFieldPanelForSuggestionParams(of);
                }
                MessageObject messageObject2 = this.replyingMessageObject;
                if (messageObject2 == null || this.threadMessageObject == messageObject2) {
                    if (message != null && ((messageObject = this.threadMessageObject) == null || messageObject.getId() != message.id)) {
                        MessageObject messageObject3 = new MessageObject(((BaseFragment) this).currentAccount, message, getMessagesController().getUsers(), false, false);
                        this.replyingMessageObject = messageObject3;
                        TLRPC.InputReplyTo inputReplyTo2 = draft.reply_to;
                        if (inputReplyTo2 != null) {
                            int i9 = inputReplyTo2.flags;
                            if ((i9 & 4) != 0) {
                                this.replyingQuote = ReplyQuote.from(messageObject3, inputReplyTo2.quote_text, (i9 & 16) != 0 ? inputReplyTo2.quote_offset : -1);
                            }
                        }
                        checkNewMessagesOnQuoteEdit(false);
                        ReplyQuote replyQuote = this.replyingQuote;
                        if (replyQuote != null) {
                            showFieldPanelForReplyQuote(this.replyingMessageObject, replyQuote);
                        } else {
                            showFieldPanelForReply(this.replyingMessageObject);
                        }
                    } else {
                        if (l == null || l.longValue() == 0 || this.currentChat == null || (findTopic = getMessagesController().getTopicsController().findTopic(this.currentChat.id, l.longValue())) == null || findTopic.topicStartMessage == null) {
                            return;
                        }
                        MessageObject messageObject4 = new MessageObject(((BaseFragment) this).currentAccount, findTopic.topicStartMessage, getMessagesController().getUsers(), false, false);
                        this.replyingMessageObject = messageObject4;
                        messageObject4.replyToForumTopic = findTopic;
                        showFieldPanelForReply(messageObject4);
                    }
                    updateBottomOverlay();
                }
            }
        }
    }

    public boolean canBeginSlide() {
        if ((this.chatMode == 5 && (this.messages.isEmpty() || this.threadMessageId == 0)) || !this.swipeBackEnabled || !this.chatActivityEnterView.swipeToBackEnabled() || this.pullingDownOffset != 0.0f) {
            return false;
        }
        QuickShareSelectorOverlayLayout quickShareSelectorOverlayLayout = this.quickShareSelectorOverlay;
        return quickShareSelectorOverlayLayout == null || !quickShareSelectorOverlayLayout.isActive();
    }

    public boolean canScheduleMessage() {
        if (this.chatMode == 5 || getMessagesController().isMonoForum(getDialogId())) {
            return false;
        }
        if ((getMessagesController().isForum(getDialogId()) && !this.isTopic) || getMessagesController().getSendPaidMessagesStars(getDialogId()) > 0 || this.currentEncryptedChat != null) {
            return false;
        }
        BlurredFrameLayout blurredFrameLayout = this.bottomOverlayChat;
        if (blurredFrameLayout == null || blurredFrameLayout.getVisibility() != 0) {
            return !isThreadChat() || this.isTopic;
        }
        return false;
    }

    public boolean canSendMessage() {
        BlurredFrameLayout blurredFrameLayout;
        return this.currentEncryptedChat == null && ((blurredFrameLayout = this.bottomOverlayChat) == null || blurredFrameLayout.getVisibility() != 0);
    }

    public void checkAdjustResize() {
        if (this.isInsideContainer) {
            return;
        }
        if (isReport()) {
            AndroidUtilities.requestAdjustNothing(getParentActivity(), ((BaseFragment) this).classGuid);
        } else {
            AndroidUtilities.requestAdjustResize(getParentActivity(), ((BaseFragment) this).classGuid);
        }
    }

    public void checkAndUpdateAvatar() {
        if (this.isTopic) {
            return;
        }
        if (this.currentUser != null) {
            TLRPC.User user = getMessagesController().getUser(Long.valueOf(this.currentUser.id));
            if (user == null) {
                return;
            } else {
                this.currentUser = user;
            }
        } else if (this.currentChat != null) {
            TLRPC.Chat chat = getMessagesController().getChat(Long.valueOf(this.currentChat.id));
            if (chat == null) {
                return;
            } else {
                this.currentChat = chat;
            }
        }
        ChatAvatarContainer chatAvatarContainer = this.avatarContainer;
        if (chatAvatarContainer != null) {
            chatAvatarContainer.checkAndUpdateAvatar();
        }
    }

    public boolean checkCanRemoveRestrictionsByBoosts() {
        boolean isPossibleRemoveChatRestrictionsByBoosts = ChatObject.isPossibleRemoveChatRestrictionsByBoosts(this.chatInfo);
        if (isPossibleRemoveChatRestrictionsByBoosts) {
            AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
            LimitReachedBottomSheet.openBoostsForRemoveRestrictions(this, this.boostsStatus, this.canApplyBoosts, this.dialog_id, false);
        }
        return isPossibleRemoveChatRestrictionsByBoosts;
    }

    public void checkEditLinkRemoved(CharSequence charSequence) {
        TLRPC.WebPage webPage;
        TLRPC.Message message;
        TLRPC.MessageMedia messageMedia;
        TLRPC.WebPage webPage2;
        MessageObject messageObject = this.editingMessageObject;
        boolean z = (messageObject == null || (message = messageObject.messageOwner) == null || (messageMedia = message.media) == null || (webPage2 = messageMedia.webpage) == null || (webPage2 instanceof TLRPC.TL_webPageEmpty) || !messageMedia.manual) ? false : true;
        MessagePreviewParams messagePreviewParams = this.messagePreviewParams;
        if (messagePreviewParams == null || messageObject == null) {
            return;
        }
        int i = messageObject.type;
        if ((i == 0 || i == 19) && (webPage = this.foundWebPage) != null && !messagePreviewParams.hasLink(charSequence, webPage.url) && z) {
            this.foundWebPage = null;
            ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
            if (chatActivityEnterView != null) {
                chatActivityEnterView.setWebPage((TLRPC.WebPage) null, true);
            }
            MessagePreviewParams messagePreviewParams2 = this.messagePreviewParams;
            if (messagePreviewParams2 != null) {
                int i2 = ((BaseFragment) this).currentAccount;
                CharSequence fieldText = this.chatActivityEnterView.getFieldText();
                MessageObject messageObject2 = this.replyingMessageObject;
                messagePreviewParams2.updateLink(i2, (TLRPC.WebPage) null, fieldText, messageObject2 == this.threadMessageObject ? null : messageObject2, this.replyingQuote, this.editingMessageObject);
            }
            editResetMediaManual();
            fallbackFieldPanel();
        }
    }

    public boolean checkRecordLocked(final boolean z) {
        int i;
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView == null || !chatActivityEnterView.isRecordLocked()) {
            return false;
        }
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity(), this.themeDelegate);
        if (this.chatActivityEnterView.isInVideoMode()) {
            builder.setTitle(LocaleController.getString(R.string.DiscardVideoMessageTitle));
            i = R.string.DiscardVideoMessageDescription;
        } else {
            builder.setTitle(LocaleController.getString(R.string.DiscardVoiceMessageTitle));
            i = R.string.DiscardVoiceMessageDescription;
        }
        builder.setMessage(LocaleController.getString(i));
        builder.setPositiveButton(LocaleController.getString(R.string.DiscardVoiceMessageAction), new AlertDialog.OnButtonClickListener() {
            @Override
            public final void onClick(AlertDialog alertDialog, int i2) {
                ChatActivity.this.lambda$checkRecordLocked$353(z, alertDialog, i2);
            }
        });
        builder.setNegativeButton(LocaleController.getString(R.string.Continue), null);
        showDialog(builder.create());
        return true;
    }

    public boolean checkSlowMode(View view) {
        CharSequence slowModeTimer = this.chatActivityEnterView.getSlowModeTimer();
        if (slowModeTimer == null) {
            return false;
        }
        showSlowModeHint(view, true, slowModeTimer);
        return true;
    }

    public boolean checkSlowModeAlert() {
        CharSequence slowModeTimer = this.chatActivityEnterView.getSlowModeTimer();
        if (slowModeTimer == null) {
            return true;
        }
        new AlertDialog.Builder(getContext()).setTitle(LocaleController.getString(R.string.Slowmode)).setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("SlowModeHint", R.string.SlowModeHint, new Object[]{slowModeTimer}))).setPositiveButton(LocaleController.getString(R.string.OK), null).show();
        return false;
    }

    public void checkStarsNeedSheet(final Runnable runnable, final AmountUtils.Amount amount, boolean z) {
        if (amount == null || !z) {
            runnable.run();
            return;
        }
        Runnable runnable2 = new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$checkStarsNeedSheet$350(amount, runnable);
            }
        };
        StarsController starsController = StarsController.getInstance(((BaseFragment) this).currentAccount, amount.currency);
        if (starsController.balanceAvailable()) {
            runnable2.run();
        } else {
            starsController.getBalance(true, runnable2, true);
        }
    }

    public void clearSearch() {
        SearchItemListener searchItemListener = this.searchItemListener;
        if (searchItemListener != null) {
            searchItemListener.onSearchCollapse();
        }
        this.searching = false;
        this.searchItemVisible = false;
        updateBottomOverlay();
        updateSearchUpDownButtonVisibility(true);
    }

    public void clearSelectionMode() {
        clearSelectionMode(false);
    }

    public void clearSelectionMode(boolean z) {
        for (int i = 1; i >= 0; i--) {
            this.selectedMessagesIds[i].clear();
            this.selectedMessagesCanCopyIds[i].clear();
            this.selectedMessagesCanStarIds[i].clear();
        }
        hideActionMode();
        updatePinnedMessageView(true);
        updateVisibleRows(z);
        updateSelectedMessageReactions();
    }

    public void closeMenu() {
        closeMenu(true);
    }

    public android.view.View createView(final android.content.Context r50) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.createView(android.content.Context):android.view.View");
    }

    public void deleteHistory(final int i, final int i2, final boolean z) {
        this.chatAdapter.frozenMessages.clear();
        for (int i3 = 0; i3 < this.messages.size(); i3++) {
            MessageObject messageObject = (MessageObject) this.messages.get(i3);
            int i4 = messageObject.messageOwner.date;
            if (i4 <= i || i4 >= i2) {
                this.chatAdapter.frozenMessages.add(messageObject);
            }
        }
        RecyclerListView recyclerListView = this.chatListView;
        if (recyclerListView != null) {
            recyclerListView.setEmptyView((View) null);
        }
        if (this.chatAdapter.frozenMessages.isEmpty()) {
            showProgressView(true);
        }
        ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
        chatActivityAdapter.isFrozen = true;
        chatActivityAdapter.notifyDataSetChanged(true);
        UndoView undoView = getUndoView();
        if (undoView == null) {
            return;
        }
        undoView.showWithAction(this.dialog_id, 81, new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$deleteHistory$3(i, i2, z);
            }
        }, new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$deleteHistory$4();
            }
        });
    }

    public void didLongPressCard(final ChatMessageCell chatMessageCell, final CharacterStyle characterStyle, final String str) {
        final Browser.Progress makeProgressForLink = makeProgressForLink(chatMessageCell, characterStyle);
        TLRPC.TL_payments_getBankCardData tL_payments_getBankCardData = new TLRPC.TL_payments_getBankCardData();
        tL_payments_getBankCardData.number = str;
        final int sendRequest = getConnectionsManager().sendRequest(tL_payments_getBankCardData, new RequestDelegate() {
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                ChatActivity.this.lambda$didLongPressCard$404(makeProgressForLink, chatMessageCell, str, characterStyle, tLObject, tL_error);
            }
        }, (QuickAckDelegate) null, (WriteToSocketDelegate) null, 0, getMessagesController().webFileDatacenterId, 1, true);
        makeProgressForLink.onCancel(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$didLongPressCard$405(sendRequest);
            }
        });
        makeProgressForLink.init();
    }

    public void didLongPressCopyButton(final String str) {
        BottomSheet.Builder builder = new BottomSheet.Builder(getParentActivity(), false, this.themeDelegate);
        builder.setTitle(str);
        builder.setTitleMultipleLines(true);
        builder.setItems(new CharSequence[]{LocaleController.getString(R.string.Copy)}, new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                ChatActivity.this.lambda$didLongPressCopyButton$420(str, dialogInterface, i);
            }
        });
        showDialog(builder.create());
    }

    public void didLongPressLink(final ChatMessageCell chatMessageCell, final MessageObject messageObject, final CharacterStyle characterStyle, final String str) {
        String str2;
        ScrimOptions scrimOptions;
        final boolean z;
        ChatMessageCell chatMessageCell2;
        CharacterStyle characterStyle2;
        SpannableString spannableString;
        String str3;
        TLRPC.WebPage webPage;
        ItemOptions makeOptions = ItemOptions.makeOptions(this, chatMessageCell, true);
        ScrimOptions scrimOptions2 = new ScrimOptions(getContext(), this.themeDelegate);
        makeOptions.setOnDismiss(new ChatActivity$$ExternalSyntheticLambda97(scrimOptions2));
        boolean z2 = (!SharedConfig.inappBrowser || str.startsWith("video?") || Browser.isInternalUri(Uri.parse(str), (boolean[]) null)) ? false : true;
        boolean z3 = str.startsWith("#") || str.startsWith("$");
        boolean startsWith = str.startsWith("mailto:");
        if (startsWith) {
            str2 = "mailto:";
            scrimOptions = scrimOptions2;
            z = startsWith;
        } else {
            scrimOptions = scrimOptions2;
            z = startsWith;
            str2 = "mailto:";
            final boolean z4 = z2;
            final boolean z5 = z3;
            makeOptions.add(R.drawable.msg_openin, LocaleController.getString((!z2 || z3) ? R.string.Open : R.string.OpenInTelegramBrowser), new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$didLongPressLink$397(str, characterStyle, messageObject, chatMessageCell, z4, z5);
                }
            });
        }
        if ((z2 && !z3) || z) {
            makeOptions.add(R.drawable.msg_language, LocaleController.getString(R.string.OpenInSystemBrowser), new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$didLongPressLink$398(str);
                }
            });
        }
        TLRPC.MessageMedia media = MessageObject.getMedia(messageObject);
        if ((media instanceof TLRPC.TL_messageMediaWebPage) && (webPage = media.webpage) != null && webPage.cached_page != null && TextUtils.equals(webPage.url, str)) {
            makeOptions.add(R.drawable.menu_instant_view, LocaleController.getString(R.string.OpenInstantView), new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$didLongPressLink$399(messageObject);
                }
            });
        }
        makeOptions.add(R.drawable.msg_copy, LocaleController.getString(z3 ? R.string.CopyHashtag : z ? R.string.CopyMail : R.string.CopyLink), new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$didLongPressLink$400(str, messageObject, z);
            }
        });
        ScrimOptions scrimOptions3 = scrimOptions;
        scrimOptions3.setItemOptions(makeOptions);
        if (str.startsWith(str2)) {
            spannableString = new SpannableString(str.substring(7));
            characterStyle2 = characterStyle;
            spannableString.setSpan(characterStyle2, 0, spannableString.length(), 33);
            chatMessageCell2 = chatMessageCell;
        } else {
            chatMessageCell2 = chatMessageCell;
            characterStyle2 = characterStyle;
            if (characterStyle2 instanceof URLSpanReplacement) {
                String url = ((URLSpanReplacement) characterStyle2).getURL();
                try {
                    try {
                        Uri parse = Uri.parse(url);
                        url = Browser.replaceHostname(parse, Browser.IDN_toUnicode(parse.getHost()), (String) null);
                    } catch (Exception e) {
                        FileLog.e(e, false);
                    }
                    str3 = URLDecoder.decode(url.replaceAll("\\+", "%2b"), "UTF-8");
                } catch (Exception e2) {
                    FileLog.e(e2);
                    str3 = url;
                }
                if (str3.length() > 204) {
                    str3 = str3.substring(0, 204) + "…";
                }
                SpannableString spannableString2 = new SpannableString(str3);
                spannableString2.setSpan(characterStyle2, 0, spannableString2.length(), 33);
                scrimOptions3.setScrim(chatMessageCell2, characterStyle2, spannableString2);
                showDialog(scrimOptions3);
            }
            spannableString = null;
        }
        scrimOptions3.setScrim(chatMessageCell2, characterStyle2, spannableString);
        showDialog(scrimOptions3);
    }

    public void didLongPressUsername(final ChatMessageCell chatMessageCell, final CharacterStyle characterStyle, final String str) {
        final Browser.Progress makeProgressForLink = makeProgressForLink(chatMessageCell, characterStyle);
        final TLObject userOrChat = getMessagesController().getUserOrChat(str);
        final Utilities.Callback2 callback2 = new Utilities.Callback2() {
            public final void run(Object obj, Object obj2) {
                ChatActivity.this.lambda$didLongPressUsername$410(makeProgressForLink, chatMessageCell, str, characterStyle, (TLObject) obj, (Boolean) obj2);
            }
        };
        TL_account.checkUsername checkusername = new TL_account.checkUsername();
        checkusername.username = str;
        final int sendRequest = getConnectionsManager().sendRequest(checkusername, new RequestDelegate() {
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                ChatActivity.this.lambda$didLongPressUsername$415(userOrChat, callback2, str, makeProgressForLink, tLObject, tL_error);
            }
        });
        makeProgressForLink.onCancel(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$didLongPressUsername$416(sendRequest);
            }
        });
        makeProgressForLink.init();
    }

    public void didPressPhoneNumber(final ChatMessageCell chatMessageCell, final CharacterStyle characterStyle, final String str) {
        final Browser.Progress makeProgressForLink = makeProgressForLink(chatMessageCell, characterStyle);
        final TLRPC.TL_contact tL_contact = (TLRPC.TL_contact) getContactsController().contactsByPhone.get(PhoneFormat.stripExceptNumbers(str));
        final Utilities.Callback callback = new Utilities.Callback() {
            public final void run(Object obj) {
                ChatActivity.this.lambda$didPressPhoneNumber$434(chatMessageCell, str, tL_contact, characterStyle, (TLRPC.User) obj);
            }
        };
        if (tL_contact != null) {
            TLRPC.User user = getMessagesController().getUser(Long.valueOf(tL_contact.user_id));
            if (user != null) {
                callback.run(user);
                return;
            } else {
                getMessagesStorage().getStorageQueue().postRunnable(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.this.lambda$didPressPhoneNumber$436(tL_contact, callback);
                    }
                });
                return;
            }
        }
        TLRPC.TL_contacts_resolvePhone tL_contacts_resolvePhone = new TLRPC.TL_contacts_resolvePhone();
        tL_contacts_resolvePhone.phone = PhoneFormat.stripExceptNumbers(str);
        final int sendRequest = getConnectionsManager().sendRequest(tL_contacts_resolvePhone, new RequestDelegate() {
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                ChatActivity.this.lambda$didPressPhoneNumber$438(makeProgressForLink, callback, tLObject, tL_error);
            }
        });
        makeProgressForLink.onCancel(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$didPressPhoneNumber$439(sendRequest);
            }
        });
        makeProgressForLink.init();
    }

    public void didPressReaction(final android.view.View r24, final org.telegram.tgnet.TLRPC.ReactionCount r25, boolean r26, float r27, float r28) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.didPressReaction(android.view.View, org.telegram.tgnet.TLRPC$ReactionCount, boolean, float, float):void");
    }

    public void didReceivedNotification(int r70, int r71, final java.lang.Object... r72) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.didReceivedNotification(int, int, java.lang.Object[]):void");
    }

    @Override
    public boolean didSelectDialogs(final DialogsActivity dialogsActivity, final ArrayList arrayList, final CharSequence charSequence, boolean z, final boolean z2, final int i, TopicsFragment topicsFragment) {
        String str;
        MessageObject messageObject;
        ChatActivityEnterView chatActivityEnterView;
        ChatActivityEnterView chatActivityEnterView2;
        MessageObject messageObject2;
        if (((this.messagePreviewParams == null && (!dialogsActivity.isQuote || this.replyingMessageObject == null)) || (dialogsActivity.isQuote && this.replyingMessageObject == null)) && this.forwardingMessage == null && this.selectedMessagesIds[0].size() == 0 && this.selectedMessagesIds[1].size() == 0) {
            return false;
        }
        final ArrayList arrayList2 = new ArrayList();
        MessageObject messageObject3 = this.forwardingMessage;
        if (messageObject3 != null) {
            MessageObject.GroupedMessages groupedMessages = this.forwardingMessageGroup;
            if (groupedMessages != null) {
                arrayList2.addAll(groupedMessages.messages);
            } else {
                arrayList2.add(messageObject3);
            }
        } else {
            for (int i2 = 1; i2 >= 0; i2--) {
                ArrayList arrayList3 = new ArrayList();
                for (int i3 = 0; i3 < this.selectedMessagesIds[i2].size(); i3++) {
                    arrayList3.add(Integer.valueOf(this.selectedMessagesIds[i2].keyAt(i3)));
                }
                Collections.sort(arrayList3);
                for (int i4 = 0; i4 < arrayList3.size(); i4++) {
                    MessageObject messageObject4 = (MessageObject) this.selectedMessagesIds[i2].get(((Integer) arrayList3.get(i4)).intValue());
                    if (messageObject4 != null) {
                        arrayList2.add(messageObject4);
                    }
                }
            }
        }
        for (int i5 = 0; i5 < arrayList.size(); i5++) {
            TLRPC.Chat chat = getMessagesController().getChat(Long.valueOf(-((MessagesStorage.TopicKey) arrayList.get(i5)).dialogId));
            if (chat != null) {
                for (int i6 = 0; i6 < arrayList2.size(); i6++) {
                    int canSendMessageToChat = SendMessagesHelper.canSendMessageToChat(chat, (MessageObject) arrayList2.get(i6));
                    if (canSendMessageToChat != 0) {
                        AlertsCreator.showSendMediaAlert(canSendMessageToChat, dialogsActivity, (Theme.ResourcesProvider) null);
                        return false;
                    }
                }
            }
        }
        if (!dialogsActivity.isQuote && (arrayList.size() > 1 || ((MessagesStorage.TopicKey) arrayList.get(0)).dialogId == getUserConfig().getClientUserId() || charSequence != null || i != 0 || !z2)) {
            return !AlertsCreator.ensurePaidMessagesMultiConfirmationTopicKeys(((BaseFragment) this).currentAccount, arrayList, arrayList2.size() + (!TextUtils.isEmpty(charSequence) ? 1 : 0), new Utilities.Callback() {
                public final void run(Object obj) {
                    ChatActivity.this.lambda$didSelectDialogs$351(dialogsActivity, arrayList, charSequence, z2, i, arrayList2, (HashMap) obj);
                }
            });
        }
        if (this.forwardingMessage != null) {
            this.forwardingMessage = null;
            this.forwardingMessageGroup = null;
        } else {
            for (int i7 = 1; i7 >= 0; i7--) {
                this.selectedMessagesCanCopyIds[i7].clear();
                this.selectedMessagesCanStarIds[i7].clear();
                this.selectedMessagesIds[i7].clear();
            }
            hideActionMode();
            updatePinnedMessageView(true);
            updateVisibleRows();
        }
        MessagesStorage.TopicKey topicKey = (MessagesStorage.TopicKey) arrayList.get(0);
        long j = topicKey.dialogId;
        if (j == this.dialog_id && getTopicId() == topicKey.topicId && this.chatMode != 2) {
            ArrayList arrayList4 = new ArrayList(getParentLayout().getFragmentStack());
            if (arrayList4.isEmpty() || arrayList4.get(arrayList4.size() - 1) != dialogsActivity) {
                int indexOf = arrayList4.indexOf(dialogsActivity);
                if (indexOf > 0) {
                    while (indexOf < arrayList4.size()) {
                        if (indexOf == arrayList4.size() - 1) {
                            ((BaseFragment) arrayList4.get(indexOf)).finishFragment();
                        } else {
                            dialogsActivity.removeSelfFromStack();
                        }
                        indexOf++;
                    }
                }
            } else {
                dialogsActivity.finishFragment();
            }
            moveScrollToLastMessage(false);
            if (!dialogsActivity.isQuote || (messageObject2 = this.replyingMessageObject) == null) {
                showFieldPanelForForward(true, arrayList2);
            } else {
                showFieldPanelForReplyQuote(messageObject2, this.replyingQuote);
            }
            if (AndroidUtilities.isTablet()) {
                hideActionMode();
                updatePinnedMessageView(true);
            }
            updateVisibleRows();
            if (this.keyboardWasVisible && (chatActivityEnterView2 = this.chatActivityEnterView) != null) {
                chatActivityEnterView2.openKeyboardInternal();
                this.chatActivityEnterView.freezeEmojiView(false);
                this.keyboardWasVisible = false;
            }
        } else {
            Bundle bundle = new Bundle();
            bundle.putBoolean("scrollToTopOnResume", this.scrollToTopOnResume);
            if (DialogObject.isEncryptedDialog(j)) {
                bundle.putInt("enc_id", DialogObject.getEncryptedChatId(j));
            } else {
                if (DialogObject.isUserDialog(j)) {
                    str = "user_id";
                } else {
                    j = -j;
                    str = "chat_id";
                }
                bundle.putLong(str, j);
                if (!getMessagesController().checkCanOpenChat(bundle, dialogsActivity)) {
                    return true;
                }
            }
            if (getMessagesStorage().isMonoForum(topicKey.dialogId)) {
                bundle.putInt("chatMode", 8);
                if (!getMessagesController().isMonoForumWithManageRights(topicKey.dialogId)) {
                    bundle.putBoolean("isSubscriberSuggestions", true);
                }
            }
            bundle.putBoolean("historyPreloaded", false);
            addToPulledDialogsMyself();
            ChatActivity chatActivity = new ChatActivity(bundle);
            if (topicKey.topicId != 0) {
                ForumUtilities.applyTopic(chatActivity, topicKey);
                dialogsActivity.removeSelfFromStack();
            }
            if (presentFragment(chatActivity, true)) {
                if (!dialogsActivity.isQuote || this.replyingMessageObject == null) {
                    chatActivity.showFieldPanelForForward(true, arrayList2);
                } else {
                    ChatActivityEnterView chatActivityEnterView3 = this.chatActivityEnterView;
                    if (chatActivityEnterView3 != null && (chatActivityEnterView = chatActivity.chatActivityEnterView) != null) {
                        chatActivityEnterView.setFieldText(chatActivityEnterView3.getFieldText());
                    }
                    MessageObject.GroupedMessages groupedMessages2 = this.replyingQuoteGroup;
                    if (groupedMessages2 == null) {
                        MessageObject messageObject5 = this.replyingMessageObject;
                        if (messageObject5 != null) {
                            groupedMessages2 = getGroup(messageObject5.getGroupId());
                        }
                        messageObject = this.replyingTopMessage;
                        if (messageObject == null || (messageObject = this.threadMessageObject) != null) {
                            chatActivity.replyingTopMessage = messageObject;
                        }
                        chatActivity.onHideFieldPanelRunnable = new Runnable() {
                            @Override
                            public final void run() {
                                ChatActivity.this.lambda$didSelectDialogs$352();
                            }
                        };
                        chatActivity.showFieldPanelForReplyQuote(this.replyingMessageObject, this.replyingQuote);
                    }
                    chatActivity.replyingQuoteGroup = groupedMessages2;
                    messageObject = this.replyingTopMessage;
                    if (messageObject == null) {
                    }
                    chatActivity.replyingTopMessage = messageObject;
                    chatActivity.onHideFieldPanelRunnable = new Runnable() {
                        @Override
                        public final void run() {
                            ChatActivity.this.lambda$didSelectDialogs$352();
                        }
                    };
                    chatActivity.showFieldPanelForReplyQuote(this.replyingMessageObject, this.replyingQuote);
                }
                if (chatActivity.getDialogId() == getDialogId() && !AndroidUtilities.isTablet()) {
                    removeSelfFromStack();
                }
            } else {
                dialogsActivity.finishFragment();
            }
        }
        return true;
    }

    public void didSelectFiles(ArrayList arrayList, String str, ArrayList arrayList2, boolean z, int i, long j, boolean z2, long j2) {
        String str2 = null;
        fillEditingMediaWithCaption(str, null);
        if (checkSlowModeAlert()) {
            if (arrayList2.isEmpty() || TextUtils.isEmpty(str)) {
                str2 = str;
            } else {
                SendMessagesHelper.SendMessageParams of = SendMessagesHelper.SendMessageParams.of(str, this.dialog_id, (MessageObject) null, (MessageObject) null, (TLRPC.WebPage) null, true, (ArrayList) null, (TLRPC.ReplyMarkup) null, (HashMap) null, true, 0, (MessageObject.SendAnimationData) null, false);
                of.quick_reply_shortcut = this.quickReplyShortcut;
                of.quick_reply_shortcut_id = getQuickReplyId();
                of.invert_media = z2;
                of.payStars = j2;
                of.monoForumPeer = getSendMonoForumPeerId();
                of.suggestionParams = this.messageSuggestionParams;
                SendMessagesHelper.getInstance(((BaseFragment) this).currentAccount).sendMessage(of);
            }
            getSendMessagesHelper().sendMessage(arrayList2, this.dialog_id, false, false, true, 0, (MessageObject) null, -1, j2, getSendMonoForumPeerId(), getSendMessageSuggestionParams());
            SendMessagesHelper.prepareSendingDocuments(getAccountInstance(), arrayList, arrayList, (ArrayList) null, str2, (String) null, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TL_stories.StoryItem) null, this.replyingQuote, this.editingMessageObject, z, i, (InputContentInfoCompat) null, this.quickReplyShortcut, getQuickReplyId(), j, z2, j2, getSendMonoForumPeerId(), getSendMessageSuggestionParams());
            afterMessageSend();
        }
    }

    @Override
    public void didSelectLocation(TLRPC.MessageMedia messageMedia, int i, boolean z, int i2, long j) {
        SendMessagesHelper.SendMessageParams of = SendMessagesHelper.SendMessageParams.of(messageMedia, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TLRPC.ReplyMarkup) null, (HashMap) null, z, i2);
        of.quick_reply_shortcut = this.quickReplyShortcut;
        of.quick_reply_shortcut_id = getQuickReplyId();
        of.payStars = j;
        of.monoForumPeer = getSendMonoForumPeerId();
        of.suggestionParams = this.messageSuggestionParams;
        getSendMessagesHelper().sendMessage(of);
        if (this.chatMode == 0) {
            moveScrollToLastMessage(false);
        }
        if (i == 0 || i == 1) {
            afterMessageSend();
        }
        if (this.paused) {
            this.scrollToTopOnResume = true;
        }
    }

    public void didSelectPhotos(ArrayList arrayList, boolean z, int i, long j) {
        fillEditingMediaWithCaption(((SendMessagesHelper.SendingMediaInfo) arrayList.get(0)).caption, ((SendMessagesHelper.SendingMediaInfo) arrayList.get(0)).entities);
        SendMessagesHelper.prepareSendingMedia(getAccountInstance(), arrayList, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TL_stories.StoryItem) null, this.replyingQuote, true, false, this.editingMessageObject, z, i, this.chatMode, ((SendMessagesHelper.SendingMediaInfo) arrayList.get(0)).updateStickersOrder, (InputContentInfoCompat) null, this.quickReplyShortcut, getQuickReplyId(), 0L, false, j, getSendMonoForumPeerId(), getSendMessageSuggestionParams());
        afterMessageSend();
        if (i != 0) {
            if (this.scheduledMessagesCount == -1) {
                this.scheduledMessagesCount = 0;
            }
            this.scheduledMessagesCount += arrayList.size();
            updateScheduledInterface(true);
        }
    }

    public void didSelectSearchPhotos(ArrayList arrayList, boolean z, int i) {
        int i2;
        ArrayList arrayList2;
        ChatActivity chatActivity = this;
        ArrayList arrayList3 = arrayList;
        if (!arrayList.isEmpty() && checkSlowModeAlert()) {
            int i3 = 0;
            while (true) {
                if (i3 < arrayList.size()) {
                    SendMessagesHelper.SendingMediaInfo sendingMediaInfo = (SendMessagesHelper.SendingMediaInfo) arrayList3.get(i3);
                    if (sendingMediaInfo.inlineResult == null && sendingMediaInfo.videoEditedInfo == null) {
                        break;
                    } else {
                        i3++;
                    }
                } else if (!TextUtils.isEmpty(((SendMessagesHelper.SendingMediaInfo) arrayList3.get(0)).caption)) {
                    SendMessagesHelper.SendMessageParams of = SendMessagesHelper.SendMessageParams.of(((SendMessagesHelper.SendingMediaInfo) arrayList3.get(0)).caption, chatActivity.dialog_id, chatActivity.replyingMessageObject, getThreadMessage(), (TLRPC.WebPage) null, false, ((SendMessagesHelper.SendingMediaInfo) arrayList3.get(0)).entities, (TLRPC.ReplyMarkup) null, (HashMap) null, z, i, (MessageObject.SendAnimationData) null, false);
                    of.quick_reply_shortcut = chatActivity.quickReplyShortcut;
                    of.quick_reply_shortcut_id = getQuickReplyId();
                    SendMessagesHelper.getInstance(((BaseFragment) chatActivity).currentAccount).sendMessage(of);
                }
            }
            for (int i4 = 0; i4 < arrayList.size(); i4 = i2 + 1) {
                SendMessagesHelper.SendingMediaInfo sendingMediaInfo2 = (SendMessagesHelper.SendingMediaInfo) arrayList3.get(i4);
                if (sendingMediaInfo2.inlineResult == null || sendingMediaInfo2.videoEditedInfo != null) {
                    i2 = i4;
                    arrayList2 = arrayList3;
                } else {
                    int i5 = i4;
                    SendMessagesHelper.prepareSendingBotContextResult(this, getAccountInstance(), sendingMediaInfo2.inlineResult, sendingMediaInfo2.params, chatActivity.dialog_id, chatActivity.replyingMessageObject, getThreadMessage(), (TL_stories.StoryItem) null, chatActivity.replyingQuote, z, i, chatActivity.quickReplyShortcut, getQuickReplyId(), 0L);
                    arrayList2 = arrayList;
                    arrayList2.remove(i5);
                    i2 = i5 - 1;
                }
                chatActivity = this;
                arrayList3 = arrayList2;
            }
            ArrayList arrayList4 = arrayList3;
            if (arrayList.isEmpty()) {
                return;
            }
            fillEditingMediaWithCaption(((SendMessagesHelper.SendingMediaInfo) arrayList4.get(0)).caption, ((SendMessagesHelper.SendingMediaInfo) arrayList4.get(0)).entities);
            SendMessagesHelper.prepareSendingMedia(getAccountInstance(), arrayList, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TL_stories.StoryItem) null, this.replyingQuote, false, true, this.editingMessageObject, z, i, this.chatMode, ((SendMessagesHelper.SendingMediaInfo) arrayList4.get(0)).updateStickersOrder, (InputContentInfoCompat) null, this.quickReplyShortcut, getQuickReplyId(), 0L, false, 0L, getSendMonoForumPeerId(), this.messageSuggestionParams);
            afterMessageSend();
            if (i != 0) {
                if (this.scheduledMessagesCount == -1) {
                    this.scheduledMessagesCount = 0;
                }
                this.scheduledMessagesCount += arrayList.size();
                updateScheduledInterface(true);
            }
        }
    }

    public void dimBehindView(boolean z) {
        dimBehindView(z ? 0.2f : 0.0f, false, true);
    }

    public void dismissCurrentDialog() {
        Dialog dialog = this.chatAttachAlert;
        if (dialog == null || ((BaseFragment) this).visibleDialog != dialog) {
            super.dismissCurrentDialog();
            return;
        }
        dialog.getPhotoLayout().closeCamera(false);
        this.chatAttachAlert.dismissInternal();
        this.chatAttachAlert.getPhotoLayout().hideCamera(true);
    }

    public boolean dismissDialogOnPause(Dialog dialog) {
        return (dialog == this.chatAttachAlert || dialog == this.chatThemeBottomSheet || (dialog instanceof BotWebViewSheet) || !super.dismissDialogOnPause(dialog)) ? false : true;
    }

    public void lambda$openDiscussionMessageChat$372(Runnable runnable) {
        NotificationCenter.getInstance(((BaseFragment) this).currentAccount).doOnIdle(runnable);
    }

    public boolean extendActionMode(android.view.Menu r4) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.extendActionMode(android.view.Menu):boolean");
    }

    public void fallbackFieldPanel() {
        MessagePreviewParams.Messages messages;
        MessageSuggestionParams messageSuggestionParams = this.messageSuggestionParams;
        if (messageSuggestionParams != null) {
            showFieldPanelForSuggestionParams(messageSuggestionParams);
            return;
        }
        TLRPC.WebPage webPage = this.foundWebPage;
        if (webPage != null) {
            showFieldPanelForWebPage(true, webPage, false);
            return;
        }
        ReplyQuote replyQuote = this.replyingQuote;
        if (replyQuote != null) {
            showFieldPanelForReplyQuote(this.replyingMessageObject, replyQuote);
            return;
        }
        MessageObject messageObject = this.replyingMessageObject;
        if (messageObject != null && messageObject != this.threadMessageObject) {
            showFieldPanelForReply(messageObject);
            return;
        }
        MessagePreviewParams messagePreviewParams = this.messagePreviewParams;
        if (messagePreviewParams != null && (messages = messagePreviewParams.forwardMessages) != null) {
            showFieldPanelForForward(true, messages.messages);
            return;
        }
        MessageObject messageObject2 = this.editingMessageObject;
        if (messageObject2 != null) {
            showFieldPanelForEdit(true, messageObject2);
        } else {
            showFieldPanelForWebPage(false, null, true);
        }
    }

    public void fillMessageMenu(org.telegram.messenger.MessageObject r30, java.util.ArrayList r31, java.util.ArrayList r32, java.util.ArrayList r33) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.fillMessageMenu(org.telegram.messenger.MessageObject, java.util.ArrayList, java.util.ArrayList, java.util.ArrayList):void");
    }

    public View findCell(int i, boolean z) {
        MessageObject messageObject;
        RecyclerListView recyclerListView = this.chatListView;
        if (recyclerListView == null) {
            return null;
        }
        int childCount = recyclerListView.getChildCount();
        for (int i2 = 0; i2 < childCount; i2++) {
            View childAt = this.chatListView.getChildAt(i2);
            if (childAt instanceof ChatMessageCell) {
                messageObject = ((ChatMessageCell) childAt).getMessageObject();
            } else if (childAt instanceof ChatActionCell) {
                messageObject = ((ChatActionCell) childAt).getMessageObject();
            } else {
                continue;
            }
            if (messageObject != null && messageObject.getId() == i) {
                if (z) {
                    if (childAt.getY() + childAt.getMeasuredHeight() < (this.chatListViewPaddingTop - this.chatListViewPaddingVisibleOffset) - AndroidUtilities.dp(4.0f) || childAt.getY() > this.chatListView.getMeasuredHeight() - this.blurredViewBottomOffset) {
                        return null;
                    }
                }
                return childAt;
            }
        }
        return null;
    }

    public BaseCell findMessageCell(int i, boolean z) {
        MessageObject messageObject;
        RecyclerListView recyclerListView = this.chatListView;
        if (recyclerListView == null) {
            return null;
        }
        int childCount = recyclerListView.getChildCount();
        for (int i2 = 0; i2 < childCount; i2++) {
            View childAt = this.chatListView.getChildAt(i2);
            if (childAt instanceof ChatMessageCell) {
                messageObject = ((ChatMessageCell) childAt).getMessageObject();
            } else if (childAt instanceof ChatActionCell) {
                messageObject = ((ChatActionCell) childAt).getMessageObject();
            } else {
                continue;
            }
            if (messageObject != null && messageObject.getId() == i) {
                if (z) {
                    if (childAt.getY() + childAt.getMeasuredHeight() < (this.chatListViewPaddingTop - this.chatListViewPaddingVisibleOffset) - AndroidUtilities.dp(4.0f) || childAt.getY() > this.chatListView.getMeasuredHeight() - this.blurredViewBottomOffset) {
                        return null;
                    }
                }
                return (BaseCell) childAt;
            }
        }
        return null;
    }

    public void lambda$onBackPressed$354() {
        super.finishFragment();
        ActionBarPopupWindow actionBarPopupWindow = this.scrimPopupWindow;
        if (actionBarPopupWindow != null) {
            actionBarPopupWindow.setPauseNotifications(false);
            closeMenu();
        }
    }

    public void firstLoadMessages() {
        MessagesController messagesController;
        long j;
        long j2;
        boolean z;
        int i;
        int i2;
        int i3;
        int i4;
        long j3;
        int i5;
        int i6;
        boolean z2;
        int i7;
        int i8;
        int i9;
        if (this.firstMessagesLoaded) {
            return;
        }
        this.firstMessagesLoaded = true;
        this.waitingForLoad.add(Integer.valueOf(this.lastLoadIndex));
        if (this.chatMode == 7) {
            HashtagSearchController hashtagSearchController = HashtagSearchController.getInstance(((BaseFragment) this).currentAccount);
            String str = this.searchingHashtag;
            int i10 = ((BaseFragment) this).classGuid;
            int i11 = this.searchType;
            int i12 = this.lastLoadIndex;
            this.lastLoadIndex = i12 + 1;
            hashtagSearchController.searchHashtag(str, i10, i11, i12);
        } else {
            if (this.startLoadFromDate != 0) {
                messagesController = getMessagesController();
                j = this.dialog_id;
                j2 = this.mergeDialogId;
                i9 = this.startLoadFromDate;
                i3 = ((BaseFragment) this).classGuid;
                i4 = this.chatMode;
                j3 = this.threadMessageId;
                i5 = this.replyMaxReadId;
                int i13 = this.lastLoadIndex;
                i6 = i13;
                this.lastLoadIndex = i13 + 1;
                z2 = this.isTopic;
                i7 = 4;
                i8 = 0;
                z = false;
                i = 30;
                i2 = 0;
            } else if (this.startLoadFromMessageId != 0 && (!isThreadChat() || this.startLoadFromMessageId == this.highlightMessageId || this.isTopic)) {
                this.startLoadFromMessageIdSaved = this.startLoadFromMessageId;
                int i14 = this.migrated_to;
                if (i14 != 0) {
                    this.mergeDialogId = i14;
                    messagesController = getMessagesController();
                    j = this.mergeDialogId;
                    z = this.loadInfo;
                    i = this.initialMessagesSize;
                    i2 = this.startLoadFromMessageId;
                    i3 = ((BaseFragment) this).classGuid;
                    i4 = this.chatMode;
                    j3 = this.threadMessageId;
                    i5 = this.replyMaxReadId;
                    int i15 = this.lastLoadIndex;
                    i6 = i15;
                    this.lastLoadIndex = i15 + 1;
                    z2 = this.isTopic;
                    i7 = 3;
                    i8 = 0;
                    j2 = 0;
                    i9 = 0;
                } else {
                    MessagesController messagesController2 = getMessagesController();
                    long j4 = this.dialog_id;
                    long j5 = this.mergeDialogId;
                    boolean z3 = this.loadInfo;
                    int i16 = this.initialMessagesSize;
                    int i17 = this.startLoadFromMessageId;
                    int i18 = ((BaseFragment) this).classGuid;
                    int i19 = this.chatMode;
                    long j6 = this.threadMessageId;
                    int i20 = this.replyMaxReadId;
                    int i21 = this.lastLoadIndex;
                    this.lastLoadIndex = i21 + 1;
                    messagesController2.loadMessages(j4, j5, z3, i16, i17, 0, true, 0, i18, 3, 0, i19, j6, i20, i21, this.isTopic);
                }
            } else if (this.historyPreloaded) {
                this.lastLoadIndex++;
            } else {
                messagesController = getMessagesController();
                j = this.dialog_id;
                j2 = this.mergeDialogId;
                z = this.loadInfo;
                i = this.initialMessagesSize;
                i2 = this.startLoadFromMessageId;
                i3 = ((BaseFragment) this).classGuid;
                i4 = this.chatMode;
                j3 = this.threadMessageId;
                i5 = this.replyMaxReadId;
                int i22 = this.lastLoadIndex;
                i6 = i22;
                this.lastLoadIndex = i22 + 1;
                z2 = this.isTopic;
                i7 = 2;
                i8 = 0;
                i9 = 0;
            }
            messagesController.loadMessages(j, j2, z, i, i2, i9, true, 0, i3, i7, i8, i4, j3, i5, i6, z2);
        }
        int i23 = this.chatMode;
        if (i23 == 0 || (i23 == 3 && getSavedDialogId() == getUserConfig().getClientUserId())) {
            if (!isThreadChat() || this.isTopic) {
                this.waitingForLoad.add(Integer.valueOf(this.lastLoadIndex));
                MessagesController messagesController3 = getMessagesController();
                long j7 = this.dialog_id;
                long j8 = this.mergeDialogId;
                int i24 = ((BaseFragment) this).classGuid;
                long j9 = this.chatMode == 3 ? 0L : this.threadMessageId;
                int i25 = this.replyMaxReadId;
                int i26 = this.lastLoadIndex;
                this.lastLoadIndex = i26 + 1;
                messagesController3.loadMessages(j7, j8, false, 1, 0, 0, true, 0, i24, 2, 0, 1, j9, i25, i26, this.isTopic);
            }
        }
    }

    public void forceEmptyHistory() {
        this.forceHistoryEmpty = true;
    }

    public ChatAvatarContainer getAvatarContainer() {
        return this.avatarContainer;
    }

    public INavigationLayout.BackButtonState getBackButtonState() {
        return INavigationLayout.BackButtonState.BACK;
    }

    public ChatActivityEnterView getChatActivityEnterView() {
        return this.chatActivityEnterView;
    }

    public ChatActivityEnterView getChatActivityEnterViewForStickers() {
        TLRPC.Chat chat;
        if (this.bottomOverlayChat.getVisibility() == 0 || !((chat = this.currentChat) == null || ChatObject.canSendStickers(chat))) {
            return null;
        }
        return this.chatActivityEnterView;
    }

    public RecyclerListView getChatListView() {
        return this.chatListView;
    }

    public float getChatListViewPadding() {
        return this.chatListViewPaddingTop;
    }

    public int getChatMode() {
        return this.chatMode;
    }

    public ThanosEffect getChatThanosEffect() {
        if (LiteMode.isEnabled(65536) && ThanosEffect.supports()) {
            ThanosEffect thanosEffect = this.chatListThanosEffect;
            if (thanosEffect == null || thanosEffect.destroyed) {
                if (getContext() != null && ThanosEffect.supports() && this.chatListView != null && this.contentView != null) {
                    ThanosEffect thanosEffect2 = this.chatListThanosEffect;
                    if (thanosEffect2 != null) {
                        AndroidUtilities.removeFromParent(thanosEffect2);
                    }
                    View thanosEffect3 = new ThanosEffect(getContext(), new Runnable() {
                        @Override
                        public final void run() {
                            ChatActivity.this.lambda$getChatThanosEffect$394(r2);
                        }
                    });
                    this.chatListThanosEffect = thanosEffect3;
                    final ThanosEffect[] thanosEffectArr = {thanosEffect3};
                    SizeNotifierFrameLayout sizeNotifierFrameLayout = this.contentView;
                    sizeNotifierFrameLayout.addView(thanosEffect3, sizeNotifierFrameLayout.indexOfChild(this.chatListView) + 1, LayoutHelper.createFrame(-1, -1.0f));
                }
            }
            return this.chatListThanosEffect;
        }
        return null;
    }

    public float getClipBottom() {
        return (((BaseFragment) this).fragmentView.getBottom() - this.chatListView.getBottom()) + (((this.fragmentTransition == null || (this.fromPullingDownTransition && !this.toPullingDownTransition)) && !this.isInsideContainer) ? this.blurredViewBottomOffset : 0);
    }

    public float getClipTop() {
        return this.chatListView.getY() + (((this.fragmentTransition == null || (this.fromPullingDownTransition && !this.toPullingDownTransition)) && !this.isInsideContainer) ? (this.chatListViewPaddingTop - this.chatListViewPaddingVisibleOffset) - AndroidUtilities.dp(4.0f) : 0.0f);
    }

    public SizeNotifierFrameLayout getContentView() {
        return this.contentView;
    }

    public TLRPC.Chat getCurrentChat() {
        return this.currentChat;
    }

    public TLRPC.ChatFull getCurrentChatInfo() {
        return this.chatInfo;
    }

    public TLRPC.EncryptedChat getCurrentEncryptedChat() {
        return this.currentEncryptedChat;
    }

    public TLRPC.User getCurrentUser() {
        return this.currentUser;
    }

    public TLRPC.UserFull getCurrentUserInfo() {
        return this.userInfo;
    }

    public int getDialogFilterId() {
        return this.dialogFilterId;
    }

    public int getDialogFolderId() {
        return this.dialogFolderId;
    }

    public long getDialogId() {
        return this.dialog_id;
    }

    public String getFilterQuery() {
        ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
        if (chatActivityAdapter == null || !chatActivityAdapter.isFiltered) {
            return null;
        }
        return this.searchingQuery;
    }

    public ReactionsLayoutInBubble.VisibleReaction getFilterTag() {
        ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
        if (chatActivityAdapter == null || !chatActivityAdapter.isFiltered) {
            return null;
        }
        return this.searchingReaction;
    }

    public ArrayList getFilteredMessages() {
        ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
        if (chatActivityAdapter != null) {
            return chatActivityAdapter.filteredMessages;
        }
        return null;
    }

    public FragmentContextView getFragmentContextView() {
        return this.fragmentContextView;
    }

    public MessageObject.GroupedMessages getGroup(long j) {
        return (MessageObject.GroupedMessages) this.groupedMessagesMap.get(j);
    }

    public ChatObject.Call getGroupCall() {
        ChatObject.Call call;
        if (this.chatMode == 0 && (call = this.groupCall) != null && (call.call instanceof TLRPC.TL_groupCall)) {
            return call;
        }
        return null;
    }

    public int getHashtagTabsHeight() {
        ChatActivity chatActivity = this.parentChatActivity;
        if (chatActivity == null) {
            chatActivity = this;
        }
        ChatSearchTabs chatSearchTabs = chatActivity.hashtagSearchTabs;
        if (chatSearchTabs == null) {
            return 0;
        }
        return chatSearchTabs.getCurrentHeight();
    }

    public long getInlineReturn() {
        return this.inlineReturn;
    }

    public TLRPC.Chat getLinkedMonoForumChat() {
        if (this.currentChat != null) {
            return getMessagesController().getMonoForumLinkedChat(this.currentChat.id);
        }
        return null;
    }

    public long getMergeDialogId() {
        return this.mergeDialogId;
    }

    public int getOtherSameChatsDiff() {
        INavigationLayout iNavigationLayout = ((BaseFragment) this).parentLayout;
        int i = 0;
        if (iNavigationLayout == null || iNavigationLayout.getFragmentStack() == null) {
            return 0;
        }
        int indexOf = ((BaseFragment) this).parentLayout.getFragmentStack().indexOf(this);
        if (indexOf == -1) {
            indexOf = ((BaseFragment) this).parentLayout.getFragmentStack().size();
        }
        while (true) {
            if (i >= ((BaseFragment) this).parentLayout.getFragmentStack().size()) {
                i = indexOf;
                break;
            }
            BaseFragment baseFragment = (BaseFragment) ((BaseFragment) this).parentLayout.getFragmentStack().get(i);
            if (baseFragment != this && (baseFragment instanceof ChatActivity) && ((ChatActivity) baseFragment).dialog_id == this.dialog_id) {
                break;
            }
            i++;
        }
        return i - indexOf;
    }

    public int getPreviewHeight() {
        return (this.chatMode == 2 && this.messages.size() == 2) ? getHeightForMessage((MessageObject) this.messages.get(0), false) + AndroidUtilities.dp(80.0f) + ActionBar.getCurrentActionBarHeight() : super.getPreviewHeight();
    }

    public float getPullingDownOffset() {
        return this.pullingDownOffset;
    }

    public int getQuickReplyId() {
        if (this.chatMode == 5) {
            return (int) this.threadMessageId;
        }
        return 0;
    }

    public MessageObject getReplyMessage() {
        return this.replyingMessageObject;
    }

    public SimpleTextView getReplyNameTextView() {
        return this.replyNameTextView;
    }

    public SimpleTextView getReplyObjectTextView() {
        return this.replyObjectTextView;
    }

    public ReplyQuote getReplyQuote() {
        return this.replyingQuote;
    }

    public MessageObject getReplyTopMessage() {
        return this.replyingTopMessage;
    }

    public Theme.ResourcesProvider getResourceProvider() {
        return this.themeDelegate;
    }

    public long getSavedDialogId() {
        if (this.chatMode == 3) {
            return this.threadMessageId;
        }
        return 0L;
    }

    public MessageSuggestionParams getSendMessageSuggestionParams() {
        return this.messageSuggestionParams;
    }

    public long getSendMonoForumPeerId() {
        MessageObject messageObject;
        TLRPC.Message message;
        MessageObject messageObject2;
        if (!ChatObject.isMonoForum(this.currentChat) || !ChatObject.canManageMonoForum(((BaseFragment) this).currentAccount, this.currentChat)) {
            return 0L;
        }
        long threadId = getThreadId();
        return ((threadId != 0 || (messageObject2 = this.editingMessageObject) == null || (message = messageObject2.messageOwner) == null) && (threadId != 0 || (messageObject = this.replyingMessageObject) == null || (message = messageObject.messageOwner) == null)) ? threadId : DialogObject.getPeerDialogId(message.saved_peer_id);
    }

    public int getServiceHeight(View view) {
        return this.contentView.getBackgroundSizeY();
    }

    public StarReactionsOverlay getStarReactionsOverlay() {
        if (this.starReactionsOverlay == null) {
            this.starReactionsOverlay = new StarReactionsOverlay(this);
        }
        FrameLayout layoutContainer = getLayoutContainer();
        if (layoutContainer == null) {
            return null;
        }
        if (this.starReactionsOverlay.getParent() != layoutContainer) {
            AndroidUtilities.removeFromParent(this.starReactionsOverlay);
            layoutContainer.addView((View) this.starReactionsOverlay, (ViewGroup.LayoutParams) LayoutHelper.createFrame(-1, -1.0f));
        } else if (layoutContainer.indexOfChild(this.starReactionsOverlay) < layoutContainer.indexOfChild(((BaseFragment) this).fragmentView)) {
            this.starReactionsOverlay.bringToFront();
        }
        return this.starReactionsOverlay;
    }

    public ArrayList getThemeDescriptions() {
        ThemeDescription themeDescription;
        if (this.forceDisallowRedrawThemeDescriptions) {
            return null;
        }
        if (this.isPauseOnThemePreview) {
            this.isPauseOnThemePreview = false;
            return null;
        }
        ThemeDescription.ThemeDescriptionDelegate themeDescriptionDelegate = new ThemeDescription.ThemeDescriptionDelegate() {
            @Override
            public final void didSetColor() {
                ChatActivity.this.lambda$getThemeDescriptions$383();
            }

            @Override
            public void onAnimationProgress(float f) {
                ThemeDescription.ThemeDescriptionDelegate.CC.$default$onAnimationProgress(this, f);
            }
        };
        ArrayList arrayList = new ArrayList();
        arrayList.add(new ThemeDescription(((BaseFragment) this).fragmentView, 0, null, null, null, null, Theme.key_chat_wallpaper));
        arrayList.add(new ThemeDescription(((BaseFragment) this).fragmentView, 0, null, null, null, null, Theme.key_chat_wallpaper_gradient_to1));
        arrayList.add(new ThemeDescription(((BaseFragment) this).fragmentView, 0, null, null, null, null, Theme.key_chat_wallpaper_gradient_to2));
        arrayList.add(new ThemeDescription(((BaseFragment) this).fragmentView, 0, null, null, null, null, Theme.key_chat_wallpaper_gradient_to3));
        arrayList.add(new ThemeDescription(this.messagesSearchListContainer, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite));
        if (isReport()) {
            arrayList.add(new ThemeDescription(((BaseFragment) this).actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_actionBarActionModeDefault));
            ActionBar actionBar = ((BaseFragment) this).actionBar;
            int i = ThemeDescription.FLAG_AB_ITEMSCOLOR;
            int i2 = Theme.key_actionBarActionModeDefaultIcon;
            arrayList.add(new ThemeDescription(actionBar, i, null, null, null, null, i2));
            arrayList.add(new ThemeDescription(((BaseFragment) this).actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarActionModeDefaultSelector));
            arrayList.add(new ThemeDescription(((BaseFragment) this).actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, i2));
            themeDescription = new ThemeDescription(((BaseFragment) this).actionBar, ThemeDescription.FLAG_AB_SUBTITLECOLOR, null, null, null, null, i2);
        } else {
            arrayList.add(new ThemeDescription(((BaseFragment) this).actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_actionBarDefault));
            arrayList.add(new ThemeDescription(((BaseFragment) this).actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_actionBarDefaultIcon));
            arrayList.add(new ThemeDescription(((BaseFragment) this).actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarDefaultSelector));
            arrayList.add(new ThemeDescription(((BaseFragment) this).actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, Theme.key_actionBarDefaultTitle));
            themeDescription = new ThemeDescription(((BaseFragment) this).actionBar, ThemeDescription.FLAG_AB_SUBTITLECOLOR, null, null, null, null, Theme.key_actionBarDefaultSubtitle);
        }
        arrayList.add(themeDescription);
        arrayList.add(new ThemeDescription(((BaseFragment) this).actionBar, ThemeDescription.FLAG_AB_SUBMENUBACKGROUND, null, null, null, themeDescriptionDelegate, Theme.key_actionBarDefaultSubmenuBackground));
        arrayList.add(new ThemeDescription(((BaseFragment) this).actionBar, ThemeDescription.FLAG_AB_SUBMENUITEM, null, null, null, themeDescriptionDelegate, Theme.key_actionBarDefaultSubmenuItem));
        arrayList.add(new ThemeDescription(((BaseFragment) this).actionBar, ThemeDescription.FLAG_AB_SUBMENUITEM | ThemeDescription.FLAG_IMAGECOLOR, null, null, null, themeDescriptionDelegate, Theme.key_actionBarDefaultSubmenuItemIcon));
        arrayList.add(new ThemeDescription(this.chatListView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_actionBarDefault));
        ChatAvatarContainer chatAvatarContainer = this.avatarContainer;
        arrayList.add(new ThemeDescription(chatAvatarContainer != null ? chatAvatarContainer.getTitleTextView() : null, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_actionBarDefaultTitle));
        ChatAvatarContainer chatAvatarContainer2 = this.avatarContainer;
        SimpleTextView titleTextView = chatAvatarContainer2 != null ? chatAvatarContainer2.getTitleTextView() : null;
        int i3 = ThemeDescription.FLAG_IMAGECOLOR;
        int i4 = Theme.key_actionBarDefaultSubtitle;
        arrayList.add(new ThemeDescription(titleTextView, i3, null, null, null, null, i4));
        ChatAvatarContainer chatAvatarContainer3 = this.avatarContainer;
        arrayList.add(new ThemeDescription(chatAvatarContainer3 != null ? chatAvatarContainer3.getSubtitleTextView() : null, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, (Class[]) null, new Paint[]{Theme.chat_statusPaint, Theme.chat_statusRecordPaint}, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_chat_status, (Object) null));
        ChatAvatarContainer chatAvatarContainer4 = this.avatarContainer;
        arrayList.add(new ThemeDescription(chatAvatarContainer4 != null ? chatAvatarContainer4.getSubtitleTextView() : null, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, (Class[]) null, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i4, (Object) null));
        arrayList.add(new ThemeDescription(((BaseFragment) this).actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarDefaultSelector));
        arrayList.add(new ThemeDescription(((BaseFragment) this).actionBar, ThemeDescription.FLAG_AB_SEARCH, null, null, null, null, Theme.key_actionBarDefaultSearch));
        ActionBar actionBar2 = ((BaseFragment) this).actionBar;
        int i5 = ThemeDescription.FLAG_AB_SEARCHPLACEHOLDER;
        int i6 = Theme.key_actionBarDefaultSearchPlaceholder;
        arrayList.add(new ThemeDescription(actionBar2, i5, null, null, null, null, i6));
        arrayList.add(new ThemeDescription(((BaseFragment) this).actionBar, ThemeDescription.FLAG_AB_SEARCHPLACEHOLDER, null, null, null, null, i6));
        ActionBar actionBar3 = ((BaseFragment) this).actionBar;
        int i7 = ThemeDescription.FLAG_AB_AM_ITEMSCOLOR;
        int i8 = Theme.key_actionBarActionModeDefaultIcon;
        arrayList.add(new ThemeDescription(actionBar3, i7, null, null, null, null, i8));
        arrayList.add(new ThemeDescription(((BaseFragment) this).actionBar, ThemeDescription.FLAG_AB_AM_BACKGROUND, null, null, null, null, Theme.key_actionBarActionModeDefault));
        arrayList.add(new ThemeDescription(((BaseFragment) this).actionBar, ThemeDescription.FLAG_AB_AM_TOPBACKGROUND, null, null, null, null, Theme.key_actionBarActionModeDefaultTop));
        arrayList.add(new ThemeDescription(((BaseFragment) this).actionBar, ThemeDescription.FLAG_AB_AM_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarActionModeDefaultSelector));
        arrayList.add(new ThemeDescription(this.selectedMessagesCountTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, i8));
        ChatAvatarContainer chatAvatarContainer5 = this.avatarContainer;
        arrayList.add(new ThemeDescription(chatAvatarContainer5 != null ? chatAvatarContainer5.getTitleTextView() : null, 0, null, null, new Drawable[]{Theme.chat_muteIconDrawable}, null, Theme.key_chat_muteIcon));
        ChatAvatarContainer chatAvatarContainer6 = this.avatarContainer;
        arrayList.add(new ThemeDescription(chatAvatarContainer6 != null ? chatAvatarContainer6.getTitleTextView() : null, 0, null, null, new Drawable[]{Theme.chat_lockIconDrawable}, null, Theme.key_chat_lockIcon));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, Theme.avatarDrawables, null, Theme.key_avatar_text));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_avatar_backgroundRed));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_avatar_backgroundOrange));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_avatar_backgroundViolet));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_avatar_backgroundGreen));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_avatar_backgroundCyan));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_avatar_backgroundBlue));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_avatar_backgroundPink));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_avatar_nameInMessageRed));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_avatar_nameInMessageOrange));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_avatar_nameInMessageViolet));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_avatar_nameInMessageGreen));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_avatar_nameInMessageCyan));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_avatar_nameInMessageBlue));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_avatar_nameInMessagePink));
        Theme.MessageDrawable messageDrawable = (Theme.MessageDrawable) getThemedDrawable("drawableMsgIn");
        Theme.MessageDrawable messageDrawable2 = (Theme.MessageDrawable) getThemedDrawable("drawableMsgInMedia");
        Theme.MessageDrawable messageDrawable3 = (Theme.MessageDrawable) getThemedDrawable("drawableMsgInSelected");
        Theme.MessageDrawable messageDrawable4 = (Theme.MessageDrawable) getThemedDrawable("drawableMsgInMediaSelected");
        Theme.MessageDrawable messageDrawable5 = (Theme.MessageDrawable) getThemedDrawable("drawableMsgOut");
        Theme.MessageDrawable messageDrawable6 = (Theme.MessageDrawable) getThemedDrawable("drawableMsgOutMedia");
        Theme.MessageDrawable messageDrawable7 = (Theme.MessageDrawable) getThemedDrawable("drawableMsgOutSelected");
        Theme.MessageDrawable messageDrawable8 = (Theme.MessageDrawable) getThemedDrawable("drawableMsgOutMediaSelected");
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class, BotHelpCell.class}, null, new Drawable[]{messageDrawable, messageDrawable2}, null, Theme.key_chat_inBubble));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{messageDrawable3, messageDrawable4}, null, Theme.key_chat_inBubbleSelected));
        if (messageDrawable != null) {
            Drawable[] shadowDrawables = messageDrawable.getShadowDrawables();
            int i9 = Theme.key_chat_inBubbleShadow;
            arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, shadowDrawables, null, i9));
            arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, messageDrawable2.getShadowDrawables(), null, i9));
            Drawable[] shadowDrawables2 = messageDrawable5.getShadowDrawables();
            int i10 = Theme.key_chat_outBubbleShadow;
            arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, shadowDrawables2, null, i10));
            arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, messageDrawable6.getShadowDrawables(), null, i10));
        }
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{messageDrawable5, messageDrawable6}, null, Theme.key_chat_outBubble));
        if (!this.themeDelegate.isThemeChangeAvailable(false)) {
            arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{messageDrawable5, messageDrawable6}, null, Theme.key_chat_outBubbleGradient1));
            arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{messageDrawable5, messageDrawable6}, null, Theme.key_chat_outBubbleGradient2));
            arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{messageDrawable5, messageDrawable6}, null, Theme.key_chat_outBubbleGradient3));
        }
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{messageDrawable7, messageDrawable8}, null, Theme.key_chat_outBubbleSelected));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{messageDrawable7, messageDrawable8}, null, Theme.key_chat_outBubbleGradientSelectedOverlay));
        Paint themedPaint = getThemedPaint("paintChatActionText");
        int i11 = Theme.key_chat_serviceText;
        arrayList.add(new ThemeDescription(this.chatListView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{ChatActionCell.class}, themedPaint, null, null, i11));
        arrayList.add(new ThemeDescription(this.chatListView, ThemeDescription.FLAG_LINKCOLOR, new Class[]{ChatActionCell.class}, getThemedPaint("paintChatActionText"), null, null, Theme.key_chat_serviceLink));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_botCardDrawable, getThemedDrawable("drawableShareIcon"), getThemedDrawable("drawableReplyIcon"), getThemedDrawable("drawableBotInline"), getThemedDrawable("drawableBotLink"), getThemedDrawable("drawableBotLock"), getThemedDrawable("drawable_botInvite"), getThemedDrawable("drawableGoIcon"), getThemedDrawable("drawableCommentSticker")}, null, Theme.key_chat_serviceIcon));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class, ChatActionCell.class}, null, null, null, Theme.key_chat_serviceBackground));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class, ChatActionCell.class}, null, null, null, Theme.key_chat_serviceBackgroundSelected));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class, BotHelpCell.class}, null, null, null, Theme.key_chat_messageTextIn));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_messageTextOut));
        arrayList.add(new ThemeDescription((View) this.chatListView, ThemeDescription.FLAG_LINKCOLOR, new Class[]{ChatMessageCell.class, BotHelpCell.class}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_chat_messageLinkIn, (Object) null));
        arrayList.add(new ThemeDescription((View) this.chatListView, ThemeDescription.FLAG_LINKCOLOR, new Class[]{ChatMessageCell.class}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_chat_messageLinkOut, (Object) null));
        Drawable[] drawableArr = {Theme.chat_msgNoSoundDrawable};
        int i12 = Theme.key_chat_mediaTimeText;
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, drawableArr, null, i12));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{getThemedDrawable("drawableMsgOutCheck")}, null, Theme.key_chat_outSentCheck));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{getThemedDrawable("drawableMsgOutCheckSelected")}, null, Theme.key_chat_outSentCheckSelected));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{getThemedDrawable("drawableMsgOutCheckRead"), getThemedDrawable("drawableMsgOutHalfCheck")}, null, Theme.key_chat_outSentCheckRead));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{getThemedDrawable("drawableMsgOutCheckReadSelected"), getThemedDrawable("drawableMsgOutHalfCheckSelected")}, null, Theme.key_chat_outSentCheckReadSelected));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outSentClock));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outSentClockSelected));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inSentClock));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inSentClockSelected));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgMediaCheckDrawable, Theme.chat_msgMediaHalfCheckDrawable}, null, Theme.key_chat_mediaSentCheck));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{getThemedDrawable("drawableMsgStickerHalfCheck"), getThemedDrawable("drawableMsgStickerCheck"), getThemedDrawable("drawableMsgStickerClock"), getThemedDrawable("drawableMsgStickerViews"), getThemedDrawable("drawableMsgStickerReplies"), getThemedDrawable("drawableMsgStickerPinned")}, null, i11));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_mediaSentClock));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{getThemedDrawable("drawableMsgOutViews"), getThemedDrawable("drawableMsgOutReplies"), getThemedDrawable("drawableMsgOutPinned")}, null, Theme.key_chat_outViews));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{getThemedDrawable("drawableMsgOutViewsSelected"), getThemedDrawable("drawableMsgOutReplies"), getThemedDrawable("drawableMsgOutPinnedSelected")}, null, Theme.key_chat_outViewsSelected));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgInViewsDrawable, Theme.chat_msgInRepliesDrawable, Theme.chat_msgInPinnedDrawable}, null, Theme.key_chat_inViews));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgInViewsSelectedDrawable, Theme.chat_msgInRepliesSelectedDrawable, Theme.chat_msgInPinnedSelectedDrawable}, null, Theme.key_chat_inViewsSelected));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgMediaViewsDrawable, Theme.chat_msgMediaRepliesDrawable, Theme.chat_msgMediaPinnedDrawable}, null, Theme.key_chat_mediaViews));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{getThemedDrawable("drawableMsgOutMenu")}, null, Theme.key_chat_outMenu));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{getThemedDrawable("drawableMsgOutMenuSelected")}, null, Theme.key_chat_outMenuSelected));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgInMenuDrawable}, null, Theme.key_chat_inMenu));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgInMenuSelectedDrawable}, null, Theme.key_chat_inMenuSelected));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgMediaMenuDrawable}, null, Theme.key_chat_mediaMenu));
        Drawable[] drawableArr2 = {getThemedDrawable("drawableMsgOutInstant")};
        int i13 = Theme.key_chat_outInstant;
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, drawableArr2, null, i13));
        Drawable[] drawableArr3 = {Theme.chat_msgInInstantDrawable, Theme.chat_commentDrawable, Theme.chat_commentArrowDrawable};
        int i14 = Theme.key_chat_inInstant;
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, drawableArr3, null, i14));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{getThemedDrawable("drawableMsgOutCallAudio"), getThemedDrawable("drawableMsgOutCallVideo")}, null, i13));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{getThemedDrawable("drawableMsgOutCallAudioSelected"), getThemedDrawable("drawableMsgOutCallVideo")}, null, i13));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, Theme.chat_msgInCallDrawable, null, i14));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, Theme.chat_msgInCallSelectedDrawable, null, Theme.key_chat_inInstantSelected));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgCallUpGreenDrawable}, null, Theme.key_chat_outGreenCall));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgCallDownRedDrawable}, null, Theme.key_fill_RedNormal));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgCallDownGreenDrawable}, null, Theme.key_chat_inGreenCall));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, Theme.chat_msgErrorPaint, null, null, Theme.key_chat_sentError));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgErrorDrawable}, null, Theme.key_chat_sentErrorIcon));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, themeDescriptionDelegate, Theme.key_chat_selectedBackground));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, Theme.chat_durationPaint, null, null, Theme.key_chat_previewDurationText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, Theme.chat_gamePaint, null, null, Theme.key_chat_previewGameText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inPreviewInstantText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outPreviewInstantText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, Theme.chat_deleteProgressPaint, null, null, Theme.key_chat_secretTimeText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_stickerNameText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, getThemedPaint("paintChatBotButton"), null, null, Theme.key_chat_botButtonText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, getThemedPaint("paintChatTimeBackground"), null, null, Theme.key_chat_mediaTimeBackground));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inForwardedNameText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outForwardedNameText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inPsaNameText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outPsaNameText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inViaBotNameText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outViaBotNameText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_stickerViaBotNameText));
        int i15 = Theme.key_chat_inReplyLine;
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, i15));
        int i16 = Theme.key_chat_outReplyLine;
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, i16));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_stickerReplyLine));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inReplyNameText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outReplyNameText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_stickerReplyNameText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inReplyMessageText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outReplyMessageText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inReplyMediaMessageText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outReplyMediaMessageText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inReplyMediaMessageSelectedText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outReplyMediaMessageSelectedText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_stickerReplyMessageText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inPreviewLine));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outPreviewLine));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inSiteNameText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outSiteNameText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inContactNameText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outContactNameText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inContactPhoneText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inContactPhoneSelectedText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outContactPhoneText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outContactPhoneSelectedText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_mediaProgress));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inAudioProgress));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outAudioProgress));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inAudioSelectedProgress));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outAudioSelectedProgress));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, i12));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inTimeText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outTimeText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inTimeSelectedText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inAdminText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inAdminSelectedText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outAdminText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outAdminSelectedText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outTimeSelectedText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inAudioPerformerText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inAudioPerformerSelectedText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outAudioPerformerText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outAudioPerformerSelectedText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inAudioTitleText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outAudioTitleText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inAudioDurationText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outAudioDurationText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inAudioDurationSelectedText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outAudioDurationSelectedText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inAudioSeekbar));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outAudioSeekbar));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inAudioSeekbarSelected));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outAudioSeekbarSelected));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inAudioSeekbarFill));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inAudioCacheSeekbar));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outAudioSeekbarFill));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outAudioCacheSeekbar));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inVoiceSeekbar));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outVoiceSeekbar));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inVoiceSeekbarSelected));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outVoiceSeekbarSelected));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inVoiceSeekbarFill));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outVoiceSeekbarFill));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inFileProgress));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outFileProgress));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inFileProgressSelected));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outFileProgressSelected));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inFileNameText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outFileNameText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inFileInfoText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outFileInfoText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inFileInfoSelectedText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outFileInfoSelectedText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inFileBackground));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outFileBackground));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inFileBackgroundSelected));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outFileBackgroundSelected));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inVenueInfoText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outVenueInfoText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inVenueInfoSelectedText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outVenueInfoSelectedText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_mediaInfoText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, Theme.chat_urlPaint, null, null, Theme.key_chat_linkSelectBackground));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, Theme.chat_outUrlPaint, null, null, i16));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, Theme.chat_textSearchSelectionPaint, null, null, i15));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outLoader));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outMediaIcon));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outLoaderSelected));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outMediaIconSelected));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inLoader));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inMediaIcon));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inLoaderSelected));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inMediaIconSelected));
        arrayList.add(new ThemeDescription(this.chatListView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_contactDrawable[0]}, null, Theme.key_chat_inContactBackground));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_contactDrawable[0]}, null, Theme.key_chat_inContactIcon));
        arrayList.add(new ThemeDescription(this.chatListView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_contactDrawable[1]}, null, Theme.key_chat_outContactBackground));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_contactDrawable[1]}, null, Theme.key_chat_outContactIcon));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inLocationBackground));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_locationDrawable[0]}, null, Theme.key_chat_inLocationIcon));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_locationDrawable[1]}, null, Theme.key_chat_outLocationIcon));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inPollCorrectAnswer));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outPollCorrectAnswer));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inPollWrongAnswer));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outPollWrongAnswer));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_pollHintDrawable[0]}, null, Theme.key_chat_inPreviewInstantText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_pollHintDrawable[1]}, null, Theme.key_chat_outPreviewInstantText));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_psaHelpDrawable[0]}, null, Theme.key_chat_inViews));
        arrayList.add(new ThemeDescription(this.chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_psaHelpDrawable[1]}, null, Theme.key_chat_outViews));
        if (!this.themeDelegate.isThemeChangeAvailable(false)) {
            arrayList.add(new ThemeDescription(this.messagesSearchListView, 0, new Class[]{DialogCell.class}, null, Theme.avatarDrawables, null, Theme.key_avatar_text));
            arrayList.add(new ThemeDescription(this.messagesSearchListView, 0, new Class[]{DialogCell.class}, Theme.dialogs_countPaint, null, null, Theme.key_chats_unreadCounter));
            arrayList.add(new ThemeDescription((View) this.messagesSearchListView, 0, new Class[]{DialogCell.class}, (String[]) null, new Paint[]{Theme.dialogs_namePaint[0], Theme.dialogs_namePaint[1], Theme.dialogs_searchNamePaint}, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_chats_name));
            arrayList.add(new ThemeDescription((View) this.messagesSearchListView, 0, new Class[]{DialogCell.class}, (String[]) null, new Paint[]{Theme.dialogs_nameEncryptedPaint[0], Theme.dialogs_nameEncryptedPaint[1], Theme.dialogs_searchNameEncryptedPaint}, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_chats_secretName));
            arrayList.add(new ThemeDescription(this.messagesSearchListView, 0, new Class[]{DialogCell.class}, null, new Drawable[]{Theme.dialogs_lockDrawable}, null, Theme.key_chats_secretIcon));
            arrayList.add(new ThemeDescription(this.messagesSearchListView, 0, new Class[]{DialogCell.class}, null, new Drawable[]{Theme.dialogs_scamDrawable, Theme.dialogs_fakeDrawable}, null, Theme.key_chats_draft));
            arrayList.add(new ThemeDescription(this.messagesSearchListView, 0, new Class[]{DialogCell.class}, Theme.dialogs_messagePaint[1], null, null, Theme.key_chats_message_threeLines));
            arrayList.add(new ThemeDescription(this.messagesSearchListView, 0, new Class[]{DialogCell.class}, Theme.dialogs_messageNamePaint, null, null, Theme.key_chats_nameMessage_threeLines));
            arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, Theme.key_chats_nameMessage));
            arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, Theme.key_chats_attachMessage));
            arrayList.add(new ThemeDescription((View) this.messagesSearchListView, 0, new Class[]{DialogCell.class}, (String[]) null, (Paint[]) Theme.dialogs_messagePrintingPaint, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_chats_actionMessage));
            arrayList.add(new ThemeDescription(this.messagesSearchListView, 0, new Class[]{DialogCell.class}, Theme.dialogs_timePaint, null, null, Theme.key_chats_date));
            arrayList.add(new ThemeDescription(this.messagesSearchListView, 0, new Class[]{DialogCell.class}, null, new Drawable[]{Theme.dialogs_checkDrawable}, null, Theme.key_chats_sentCheck));
            arrayList.add(new ThemeDescription(this.messagesSearchListView, 0, new Class[]{DialogCell.class}, null, new Drawable[]{Theme.dialogs_checkReadDrawable, Theme.dialogs_halfCheckDrawable}, null, Theme.key_chats_sentReadCheck));
        }
        MentionsContainerView mentionsContainerView = this.mentionContainer;
        Paint themedPaint2 = getThemedPaint("paintChatComposeBackground");
        int i17 = Theme.key_chat_messagePanelBackground;
        arrayList.add(new ThemeDescription(mentionsContainerView, 0, null, themedPaint2, null, null, i17));
        MentionsContainerView mentionsContainerView2 = this.mentionContainer;
        Drawable[] drawableArr4 = {Theme.chat_composeShadowDrawable};
        int i18 = Theme.key_chat_messagePanelShadow;
        arrayList.add(new ThemeDescription(mentionsContainerView2, 0, null, null, drawableArr4, null, i18));
        arrayList.add(new ThemeDescription(this.mentionContainer, 0, null, null, new Drawable[]{Theme.chat_composeShadowRoundDrawable}, null, i17));
        arrayList.add(new ThemeDescription(this.searchContainer, 0, null, getThemedPaint("paintChatComposeBackground"), null, null, i17));
        arrayList.add(new ThemeDescription(this.searchContainer, 0, null, null, new Drawable[]{Theme.chat_composeShadowDrawable}, null, i18));
        arrayList.add(new ThemeDescription(this.bottomOverlay, 0, null, getThemedPaint("paintChatComposeBackground"), null, null, i17));
        arrayList.add(new ThemeDescription(this.bottomOverlay, 0, null, null, new Drawable[]{Theme.chat_composeShadowDrawable}, null, i18));
        arrayList.add(new ThemeDescription(this.bottomOverlayChat, 0, null, getThemedPaint("paintChatComposeBackground"), null, null, i17));
        arrayList.add(new ThemeDescription(this.bottomOverlayChat, 0, null, null, new Drawable[]{Theme.chat_composeShadowDrawable}, null, i18));
        arrayList.add(new ThemeDescription(this.bottomMessagesActionContainer, 0, null, getThemedPaint("paintChatComposeBackground"), null, null, i17));
        arrayList.add(new ThemeDescription(this.bottomMessagesActionContainer, 0, null, null, new Drawable[]{Theme.chat_composeShadowDrawable}, null, i18));
        arrayList.add(new ThemeDescription(this.chatActivityEnterView, 0, null, getThemedPaint("paintChatComposeBackground"), null, null, i17));
        arrayList.add(new ThemeDescription(this.chatActivityEnterView, 0, null, null, new Drawable[]{Theme.chat_composeShadowDrawable}, null, i18));
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{ChatActivityEnterView.class}, new String[]{"messageEditText"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_chat_messagePanelText));
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, ThemeDescription.FLAG_CURSORCOLOR, new Class[]{ChatActivityEnterView.class}, new String[]{"messageEditText"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_chat_messagePanelCursor));
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, ThemeDescription.FLAG_HINTTEXTCOLOR, new Class[]{ChatActivityEnterView.class}, new String[]{"messageEditText"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_chat_messagePanelHint));
        int i19 = Theme.key_chat_messagePanelSend;
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, ThemeDescription.FLAG_IMAGECOLOR, new Class[]{ChatActivityEnterView.class}, new String[]{"sendButton"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i19));
        arrayList.add(new ThemeDescription(this.chatActivityEnterView, ThemeDescription.FLAG_USEBACKGROUNDDRAWABLE | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, new Class[]{ChatActivityEnterView.class}, new String[]{"sendButton"}, null, null, 24, null, i19));
        int i20 = Theme.key_chat_messagePanelIcons;
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, 0, new Class[]{ChatActivityEnterView.class}, new String[]{"botButton"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i20));
        int i21 = Theme.key_listSelector;
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, ThemeDescription.FLAG_USEBACKGROUNDDRAWABLE | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, new Class[]{ChatActivityEnterView.class}, new String[]{"botButton"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i21));
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, 0, new Class[]{ChatActivityEnterView.class}, new String[]{"notifyButton"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i20));
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, ThemeDescription.FLAG_IMAGECOLOR | ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{ChatActivityEnterView.class}, new String[]{"scheduledButton"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i20));
        int i22 = Theme.key_chat_recordedVoiceDot;
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, ThemeDescription.FLAG_IMAGECOLOR, new Class[]{ChatActivityEnterView.class}, new String[]{"scheduledButton"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i22));
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, ThemeDescription.FLAG_USEBACKGROUNDDRAWABLE | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, new Class[]{ChatActivityEnterView.class}, new String[]{"scheduledButton"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i21));
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, 0, new Class[]{ChatActivityEnterView.class}, new String[]{"attachButton"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i20));
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, ThemeDescription.FLAG_USEBACKGROUNDDRAWABLE | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, new Class[]{ChatActivityEnterView.class}, new String[]{"attachButton"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i21));
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, 0, new Class[]{ChatActivityEnterView.class}, new String[]{"suggestButton"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i20));
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, ThemeDescription.FLAG_USEBACKGROUNDDRAWABLE | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, new Class[]{ChatActivityEnterView.class}, new String[]{"suggestButton"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i21));
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, ThemeDescription.FLAG_USEBACKGROUNDDRAWABLE | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, new Class[]{ChatActivityEnterView.class}, new String[]{"notifyButton"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i21));
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, 0, new Class[]{ChatActivityEnterView.class}, new String[]{"videoTimelineView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i19));
        int i23 = Theme.key_chat_messagePanelVoicePressed;
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, 0, new Class[]{ChatActivityEnterView.class}, new String[]{"micDrawable"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i23));
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, 0, new Class[]{ChatActivityEnterView.class}, new String[]{"cameraDrawable"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i23));
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, 0, new Class[]{ChatActivityEnterView.class}, new String[]{"sendDrawable"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i23));
        arrayList.add(new ThemeDescription(this.chatActivityEnterView, 0, null, null, null, null, Theme.key_chat_messagePanelVoiceLock));
        arrayList.add(new ThemeDescription(this.chatActivityEnterView, 0, new Class[]{ChatActivityEnterView.class}, null, null, null, Theme.key_chat_messagePanelVoiceLockBackground));
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, 0, new Class[]{ChatActivityEnterView.class}, new String[]{"lockShadowDrawable"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_chat_messagePanelVoiceLockShadow));
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, ThemeDescription.FLAG_USEBACKGROUNDDRAWABLE | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, new Class[]{ChatActivityEnterView.class}, new String[]{"recordDeleteImageView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i21));
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{ChatActivityEnterView.class}, new String[]{"recordedAudioBackground"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_chat_recordedVoiceBackground));
        arrayList.add(new ThemeDescription(this.chatActivityEnterView, 0, null, null, null, null, Theme.key_chat_recordTime));
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        int i24 = Theme.key_chat_recordVoiceCancel;
        arrayList.add(new ThemeDescription(chatActivityEnterView, 0, null, null, null, null, i24));
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{ChatActivityEnterView.class}, new String[]{"recordedAudioTimeTextView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_chat_messagePanelVoiceDuration));
        arrayList.add(new ThemeDescription(this.chatActivityEnterView, 0, null, null, null, null, i24));
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, ThemeDescription.FLAG_IMAGECOLOR, new Class[]{ChatActivityEnterView.class}, new String[]{"cancelBotButton"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_chat_messagePanelCancelInlineBot));
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, ThemeDescription.FLAG_USEBACKGROUNDDRAWABLE | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, new Class[]{ChatActivityEnterView.class}, new String[]{"cancelBotButton"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i21));
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, 0, new Class[]{ChatActivityEnterView.class}, new String[]{"redDotPaint"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i22));
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, 0, new Class[]{ChatActivityEnterView.class}, new String[]{"paint"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_chat_messagePanelVoiceBackground));
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, 0, new Class[]{ChatActivityEnterView.class}, new String[]{"dotPaint"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_chat_emojiPanelNewTrending));
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, 0, new Class[]{ChatActivityEnterView.class}, (String[]) null, (Paint[]) null, (Drawable[]) null, themeDescriptionDelegate, Theme.key_chat_recordedVoicePlayPause));
        ChatActivityEnterView chatActivityEnterView2 = this.chatActivityEnterView;
        arrayList.add(new ThemeDescription(chatActivityEnterView2 != null ? chatActivityEnterView2.getEmojiView() : null, 0, new Class[]{EmojiView.class}, (String[]) null, (Paint[]) null, (Drawable[]) null, themeDescriptionDelegate, Theme.key_chat_emojiPanelBackground));
        ChatActivityEnterView chatActivityEnterView3 = this.chatActivityEnterView;
        arrayList.add(new ThemeDescription(chatActivityEnterView3 != null ? chatActivityEnterView3.getEmojiView() : null, 0, new Class[]{EmojiView.class}, (String[]) null, (Paint[]) null, (Drawable[]) null, themeDescriptionDelegate, Theme.key_chat_emojiPanelShadowLine));
        ChatActivityEnterView chatActivityEnterView4 = this.chatActivityEnterView;
        arrayList.add(new ThemeDescription(chatActivityEnterView4 != null ? chatActivityEnterView4.getEmojiView() : null, 0, new Class[]{EmojiView.class}, (String[]) null, (Paint[]) null, (Drawable[]) null, themeDescriptionDelegate, Theme.key_chat_emojiPanelEmptyText));
        ChatActivityEnterView chatActivityEnterView5 = this.chatActivityEnterView;
        arrayList.add(new ThemeDescription(chatActivityEnterView5 != null ? chatActivityEnterView5.getEmojiView() : null, 0, new Class[]{EmojiView.class}, (String[]) null, (Paint[]) null, (Drawable[]) null, themeDescriptionDelegate, Theme.key_chat_emojiPanelIcon));
        ChatActivityEnterView chatActivityEnterView6 = this.chatActivityEnterView;
        arrayList.add(new ThemeDescription(chatActivityEnterView6 != null ? chatActivityEnterView6.getEmojiView() : null, 0, new Class[]{EmojiView.class}, (String[]) null, (Paint[]) null, (Drawable[]) null, themeDescriptionDelegate, Theme.key_chat_emojiPanelIconSelected));
        ChatActivityEnterView chatActivityEnterView7 = this.chatActivityEnterView;
        arrayList.add(new ThemeDescription(chatActivityEnterView7 != null ? chatActivityEnterView7.getEmojiView() : null, 0, new Class[]{EmojiView.class}, (String[]) null, (Paint[]) null, (Drawable[]) null, themeDescriptionDelegate, Theme.key_chat_emojiPanelStickerPackSelector));
        ChatActivityEnterView chatActivityEnterView8 = this.chatActivityEnterView;
        arrayList.add(new ThemeDescription(chatActivityEnterView8 != null ? chatActivityEnterView8.getEmojiView() : null, 0, new Class[]{EmojiView.class}, (String[]) null, (Paint[]) null, (Drawable[]) null, themeDescriptionDelegate, Theme.key_chat_emojiPanelBackspace));
        ChatActivityEnterView chatActivityEnterView9 = this.chatActivityEnterView;
        arrayList.add(new ThemeDescription(chatActivityEnterView9 != null ? chatActivityEnterView9.getEmojiView() : null, 0, new Class[]{EmojiView.class}, (String[]) null, (Paint[]) null, (Drawable[]) null, themeDescriptionDelegate, Theme.key_chat_emojiPanelTrendingTitle));
        ChatActivityEnterView chatActivityEnterView10 = this.chatActivityEnterView;
        arrayList.add(new ThemeDescription(chatActivityEnterView10 != null ? chatActivityEnterView10.getEmojiView() : null, 0, new Class[]{EmojiView.class}, (String[]) null, (Paint[]) null, (Drawable[]) null, themeDescriptionDelegate, Theme.key_chat_emojiPanelTrendingDescription));
        ChatActivityEnterView chatActivityEnterView11 = this.chatActivityEnterView;
        arrayList.add(new ThemeDescription(chatActivityEnterView11 != null ? chatActivityEnterView11.getEmojiView() : null, 0, new Class[]{EmojiView.class}, (String[]) null, (Paint[]) null, (Drawable[]) null, themeDescriptionDelegate, Theme.key_chat_emojiBottomPanelIcon));
        ChatActivityEnterView chatActivityEnterView12 = this.chatActivityEnterView;
        arrayList.add(new ThemeDescription(chatActivityEnterView12 != null ? chatActivityEnterView12.getEmojiView() : null, 0, new Class[]{EmojiView.class}, (String[]) null, (Paint[]) null, (Drawable[]) null, themeDescriptionDelegate, Theme.key_chat_emojiSearchIcon));
        ChatActivityEnterView chatActivityEnterView13 = this.chatActivityEnterView;
        arrayList.add(new ThemeDescription(chatActivityEnterView13 != null ? chatActivityEnterView13.getEmojiView() : null, 0, new Class[]{EmojiView.class}, (String[]) null, (Paint[]) null, (Drawable[]) null, themeDescriptionDelegate, Theme.key_chat_emojiPanelStickerSetNameHighlight));
        ChatActivityEnterView chatActivityEnterView14 = this.chatActivityEnterView;
        arrayList.add(new ThemeDescription((View) (chatActivityEnterView14 != null ? chatActivityEnterView14.getEmojiView() : null), 0, new Class[]{EmojiView.class}, (String[]) null, (Paint[]) null, (Drawable[]) null, themeDescriptionDelegate, Theme.key_chat_emojiPanelStickerPackSelectorLine));
        ChatActivityEnterView chatActivityEnterView15 = this.chatActivityEnterView;
        if (chatActivityEnterView15 != null) {
            TrendingStickersAlert trendingStickersAlert = chatActivityEnterView15.getTrendingStickersAlert();
            if (trendingStickersAlert != null) {
                arrayList.addAll(trendingStickersAlert.getThemeDescriptions());
            }
            arrayList.add(new ThemeDescription((View) null, 0, (Class[]) null, (String[]) null, (Paint[]) null, new Drawable[]{this.chatActivityEnterView.getStickersArrowDrawable()}, (ThemeDescription.ThemeDescriptionDelegate) null, i20));
        }
        int i25 = 0;
        while (i25 < 2) {
            UndoView undoView = i25 == 0 ? this.undoView : this.topUndoView;
            arrayList.add(new ThemeDescription(undoView, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_undo_background));
            int i26 = Theme.key_undo_cancelColor;
            arrayList.add(new ThemeDescription((View) undoView, 0, new Class[]{UndoView.class}, new String[]{"undoImageView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i26));
            arrayList.add(new ThemeDescription((View) undoView, 0, new Class[]{UndoView.class}, new String[]{"undoTextView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i26));
            int i27 = Theme.key_undo_infoColor;
            arrayList.add(new ThemeDescription((View) undoView, 0, new Class[]{UndoView.class}, new String[]{"infoTextView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i27));
            arrayList.add(new ThemeDescription((View) undoView, 0, new Class[]{UndoView.class}, new String[]{"subinfoTextView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i27));
            arrayList.add(new ThemeDescription((View) undoView, ThemeDescription.FLAG_LINKCOLOR, new Class[]{UndoView.class}, new String[]{"subinfoTextView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i26));
            arrayList.add(new ThemeDescription((View) undoView, 0, new Class[]{UndoView.class}, new String[]{"textPaint"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i27));
            arrayList.add(new ThemeDescription((View) undoView, 0, new Class[]{UndoView.class}, new String[]{"progressPaint"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i27));
            arrayList.add(new ThemeDescription((View) undoView, ThemeDescription.FLAG_IMAGECOLOR, new Class[]{UndoView.class}, new String[]{"leftImageView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i27));
            i25++;
        }
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_chat_botKeyboardButtonText));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_chat_botKeyboardButtonBackground));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_chat_botKeyboardButtonBackgroundPressed));
        arrayList.add(new ThemeDescription(((BaseFragment) this).fragmentView, ThemeDescription.FLAG_BACKGROUND | ThemeDescription.FLAG_CHECKTAG, new Class[]{FragmentContextView.class}, new String[]{"frameLayout"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_inappPlayerBackground));
        arrayList.add(new ThemeDescription(((BaseFragment) this).fragmentView, ThemeDescription.FLAG_IMAGECOLOR, new Class[]{FragmentContextView.class}, new String[]{"playButton"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_inappPlayerPlayPause));
        arrayList.add(new ThemeDescription(((BaseFragment) this).fragmentView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, new Class[]{FragmentContextView.class}, new String[]{"titleTextView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_inappPlayerTitle));
        arrayList.add(new ThemeDescription(((BaseFragment) this).fragmentView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, new Class[]{FragmentContextView.class}, new String[]{"titleTextView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_inappPlayerPerformer));
        int i28 = Theme.key_inappPlayerClose;
        arrayList.add(new ThemeDescription(((BaseFragment) this).fragmentView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_FASTSCROLL, new Class[]{FragmentContextView.class}, new String[]{"subtitleTextView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i28));
        arrayList.add(new ThemeDescription(((BaseFragment) this).fragmentView, ThemeDescription.FLAG_IMAGECOLOR, new Class[]{FragmentContextView.class}, new String[]{"closeButton"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i28));
        arrayList.add(new ThemeDescription(((BaseFragment) this).fragmentView, ThemeDescription.FLAG_BACKGROUND | ThemeDescription.FLAG_CHECKTAG, new Class[]{FragmentContextView.class}, new String[]{"frameLayout"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_returnToCallBackground));
        arrayList.add(new ThemeDescription(((BaseFragment) this).fragmentView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, new Class[]{FragmentContextView.class}, new String[]{"titleTextView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_returnToCallText));
        arrayList.add(new ThemeDescription(this.pinnedLineView, 0, null, null, null, themeDescriptionDelegate, Theme.key_chat_topPanelLine));
        arrayList.add(new ThemeDescription(this.pinnedLineView, 0, null, null, null, themeDescriptionDelegate, Theme.key_windowBackgroundWhite));
        arrayList.add(new ThemeDescription(this.pinnedCounterTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_chat_topPanelTitle));
        for (int i29 = 0; i29 < 2; i29++) {
            arrayList.add(new ThemeDescription(this.pinnedNameTextView[i29], ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_chat_topPanelTitle));
            arrayList.add(new ThemeDescription(this.pinnedMessageTextView[i29], ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_chat_topPanelMessage));
        }
        arrayList.add(new ThemeDescription(this.alertNameTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_chat_topPanelTitle));
        arrayList.add(new ThemeDescription(this.alertTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_chat_topPanelMessage));
        ImageView imageView = this.closePinned;
        int i30 = ThemeDescription.FLAG_IMAGECOLOR;
        int i31 = Theme.key_chat_topPanelClose;
        arrayList.add(new ThemeDescription(imageView, i30, null, null, null, null, i31));
        arrayList.add(new ThemeDescription(this.pinnedListButton, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, i31));
        arrayList.add(new ThemeDescription(this.closeReportSpam, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, i31));
        BlurredFrameLayout blurredFrameLayout = this.topChatPanelView;
        int i32 = ThemeDescription.FLAG_BACKGROUNDFILTER;
        int i33 = Theme.key_chat_topPanelBackground;
        arrayList.add(new ThemeDescription(blurredFrameLayout, i32, null, null, null, null, i33));
        arrayList.add(new ThemeDescription(this.topChatPanelView2, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, i33));
        arrayList.add(new ThemeDescription(this.alertView, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, i33));
        arrayList.add(new ThemeDescription(this.pinnedMessageView, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, i33));
        TextView textView = this.addToContactsButton;
        int i34 = ThemeDescription.FLAG_TEXTCOLOR;
        int i35 = Theme.key_chat_addContact;
        arrayList.add(new ThemeDescription(textView, i34, null, null, null, null, i35));
        arrayList.add(new ThemeDescription(this.reportSpamButton, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, null, null, null, null, Theme.key_text_RedBold));
        arrayList.add(new ThemeDescription(this.reportSpamButton, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, null, null, null, null, i35));
        arrayList.add(new ThemeDescription(this.replyLineView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_chat_replyPanelLine));
        SimpleTextView simpleTextView = this.replyNameTextView;
        int i36 = ThemeDescription.FLAG_TEXTCOLOR;
        int i37 = Theme.key_chat_replyPanelName;
        arrayList.add(new ThemeDescription(simpleTextView, i36, null, null, null, null, i37));
        SimpleTextView simpleTextView2 = this.replyObjectTextView;
        int i38 = ThemeDescription.FLAG_TEXTCOLOR;
        int i39 = Theme.key_windowBackgroundWhiteGrayText;
        arrayList.add(new ThemeDescription(simpleTextView2, i38, null, null, null, null, i39));
        arrayList.add(new ThemeDescription(this.replyObjectHintTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, i39));
        arrayList.add(new ThemeDescription(this.replyIconImageView, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_chat_replyPanelIcons));
        arrayList.add(new ThemeDescription(this.replyCloseImageView, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_chat_replyPanelClose));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, i37));
        ImageView imageView2 = this.searchCalendarButton;
        int i40 = ThemeDescription.FLAG_IMAGECOLOR;
        int i41 = Theme.key_chat_searchPanelIcons;
        arrayList.add(new ThemeDescription(imageView2, i40, null, null, null, null, i41));
        ImageView imageView3 = this.searchCalendarButton;
        int i42 = ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE;
        int i43 = Theme.key_actionBarActionModeDefaultSelector;
        arrayList.add(new ThemeDescription(imageView3, i42, null, null, null, null, i43));
        arrayList.add(new ThemeDescription(this.searchUserButton, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, i41));
        arrayList.add(new ThemeDescription(this.searchUserButton, ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, null, null, null, null, i43));
        TextView textView2 = this.replyButton;
        int i44 = ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_IMAGECOLOR;
        int i45 = Theme.key_actionBarActionModeDefaultIcon;
        arrayList.add(new ThemeDescription(textView2, i44, null, null, null, null, i45));
        arrayList.add(new ThemeDescription(this.replyButton, ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, null, null, null, null, i43));
        arrayList.add(new ThemeDescription(this.forwardButton, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, i45));
        arrayList.add(new ThemeDescription(this.forwardButton, ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, null, null, null, null, i43));
        arrayList.add(new ThemeDescription(this.bottomOverlayText, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_chat_secretChatStatusText));
        UnreadCounterTextView unreadCounterTextView = this.bottomOverlayChatText;
        int i46 = Theme.key_chat_fieldOverlayText;
        arrayList.add(new ThemeDescription(unreadCounterTextView, 0, null, null, null, null, i46));
        UnreadCounterTextView unreadCounterTextView2 = this.bottomOverlayChatText;
        int i47 = Theme.key_chat_goDownButtonCounterBackground;
        arrayList.add(new ThemeDescription(unreadCounterTextView2, 0, null, null, null, null, i47));
        arrayList.add(new ThemeDescription(this.bottomOverlayChatText, 0, null, null, null, null, Theme.key_chat_messagePanelBackground));
        arrayList.add(new ThemeDescription(this.bottomOverlayProgress, 0, null, null, null, null, i46));
        arrayList.add(new ThemeDescription(this.bottomOverlayImage, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, i46));
        ChatBigEmptyView chatBigEmptyView = this.bigEmptyView;
        int i48 = ThemeDescription.FLAG_TEXTCOLOR;
        int i49 = Theme.key_chat_serviceText;
        arrayList.add(new ThemeDescription(chatBigEmptyView, i48, null, null, null, null, i49));
        arrayList.add(new ThemeDescription(this.emptyView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, i49));
        arrayList.add(new ThemeDescription(this.progressBar, ThemeDescription.FLAG_PROGRESSBAR, null, null, null, null, i49));
        arrayList.add(new ThemeDescription((View) this.chatListView, ThemeDescription.FLAG_USEBACKGROUNDDRAWABLE, new Class[]{ChatUnreadCell.class}, new String[]{"backgroundLayout"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_chat_unreadMessagesStartBackground));
        arrayList.add(new ThemeDescription((View) this.chatListView, ThemeDescription.FLAG_IMAGECOLOR, new Class[]{ChatUnreadCell.class}, new String[]{"imageView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_chat_unreadMessagesStartArrowIcon));
        arrayList.add(new ThemeDescription((View) this.chatListView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{ChatUnreadCell.class}, new String[]{"textView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_chat_unreadMessagesStartText));
        View view = this.progressView2;
        int i50 = ThemeDescription.FLAG_SERVICEBACKGROUND;
        int i51 = Theme.key_chat_serviceBackground;
        arrayList.add(new ThemeDescription(view, i50, null, null, null, null, i51));
        arrayList.add(new ThemeDescription(this.emptyView, ThemeDescription.FLAG_SERVICEBACKGROUND, null, null, null, null, i51));
        arrayList.add(new ThemeDescription(this.bigEmptyView, ThemeDescription.FLAG_SERVICEBACKGROUND, null, null, null, null, i51));
        if (this.mentionContainer != null) {
            arrayList.add(new ThemeDescription((View) this.mentionContainer.getListView(), ThemeDescription.FLAG_TEXTCOLOR, new Class[]{BotSwitchCell.class}, new String[]{"textView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_chat_botSwitchToInlineText));
            int i52 = Theme.key_windowBackgroundWhiteBlackText;
            arrayList.add(new ThemeDescription((View) this.mentionContainer.getListView(), ThemeDescription.FLAG_TEXTCOLOR, new Class[]{MentionCell.class}, new String[]{"nameTextView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i52));
            arrayList.add(new ThemeDescription((View) this.mentionContainer.getListView(), ThemeDescription.FLAG_TEXTCOLOR, new Class[]{MentionCell.class}, new String[]{"usernameTextView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_windowBackgroundWhiteGrayText3));
            arrayList.add(new ThemeDescription(this.mentionContainer.getListView(), 0, new Class[]{ContextLinkCell.class}, null, new Drawable[]{Theme.chat_inlineResultFile, Theme.chat_inlineResultAudio, Theme.chat_inlineResultLocation}, null, Theme.key_chat_inlineResultIcon));
            arrayList.add(new ThemeDescription(this.mentionContainer.getListView(), 0, new Class[]{ContextLinkCell.class}, null, null, null, Theme.key_windowBackgroundWhiteGrayText2));
            arrayList.add(new ThemeDescription(this.mentionContainer.getListView(), 0, new Class[]{ContextLinkCell.class}, null, null, null, Theme.key_windowBackgroundWhiteLinkText));
            arrayList.add(new ThemeDescription(this.mentionContainer.getListView(), 0, new Class[]{ContextLinkCell.class}, null, null, null, i52));
            arrayList.add(new ThemeDescription(this.mentionContainer.getListView(), 0, new Class[]{ContextLinkCell.class}, null, null, null, Theme.key_chat_inAudioProgress));
            arrayList.add(new ThemeDescription(this.mentionContainer.getListView(), 0, new Class[]{ContextLinkCell.class}, null, null, null, Theme.key_chat_inAudioSelectedProgress));
            arrayList.add(new ThemeDescription(this.mentionContainer.getListView(), 0, new Class[]{ContextLinkCell.class}, null, null, null, Theme.key_divider));
        }
        HintView hintView = this.gifHintTextView;
        int i53 = ThemeDescription.FLAG_BACKGROUNDFILTER;
        int i54 = Theme.key_chat_gifSaveHintBackground;
        arrayList.add(new ThemeDescription(hintView, i53, null, null, null, null, i54));
        HintView hintView2 = this.gifHintTextView;
        int i55 = ThemeDescription.FLAG_TEXTCOLOR;
        int i56 = Theme.key_chat_gifSaveHintText;
        arrayList.add(new ThemeDescription(hintView2, i55, null, null, null, null, i56));
        arrayList.add(new ThemeDescription((View) this.noSoundHintView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{HintView.class}, new String[]{"textView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i56));
        arrayList.add(new ThemeDescription((View) this.noSoundHintView, ThemeDescription.FLAG_IMAGECOLOR, new Class[]{HintView.class}, new String[]{"imageView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i56));
        arrayList.add(new ThemeDescription((View) this.noSoundHintView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{HintView.class}, new String[]{"arrowImageView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i54));
        arrayList.add(new ThemeDescription((View) this.forwardHintView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{HintView.class}, new String[]{"textView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i56));
        arrayList.add(new ThemeDescription((View) this.forwardHintView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{HintView.class}, new String[]{"arrowImageView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i54));
        arrayList.add(new ThemeDescription(this.pagedownButtonCounter, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, i47));
        CounterView counterView = this.pagedownButtonCounter;
        int i57 = ThemeDescription.FLAG_TEXTCOLOR;
        int i58 = Theme.key_chat_goDownButtonCounter;
        arrayList.add(new ThemeDescription(counterView, i57, null, null, null, null, i58));
        ImageView imageView4 = this.pagedownButtonImage;
        int i59 = ThemeDescription.FLAG_BACKGROUNDFILTER;
        int i60 = Theme.key_chat_goDownButton;
        arrayList.add(new ThemeDescription(imageView4, i59, null, null, null, null, i60));
        ImageView imageView5 = this.pagedownButtonImage;
        int i61 = ThemeDescription.FLAG_IMAGECOLOR;
        int i62 = Theme.key_chat_goDownButtonIcon;
        arrayList.add(new ThemeDescription(imageView5, i61, null, null, null, null, i62));
        arrayList.add(new ThemeDescription(this.mentiondownButtonCounter, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, i47));
        arrayList.add(new ThemeDescription(this.mentiondownButtonCounter, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, i58));
        arrayList.add(new ThemeDescription(this.mentiondownButtonImage, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, i60));
        arrayList.add(new ThemeDescription(this.mentiondownButtonImage, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, i62));
        arrayList.add(new ThemeDescription(this.floatingDateView, 0, null, null, null, null, i49));
        arrayList.add(new ThemeDescription(this.floatingDateView, 0, null, null, null, null, i51));
        arrayList.add(new ThemeDescription(this.infoTopView, 0, null, null, null, null, i49));
        arrayList.add(new ThemeDescription(this.infoTopView, 0, null, null, null, null, i51));
        int i63 = Theme.key_chat_attachIcon;
        arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, i63));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, Theme.key_chat_attachGalleryBackground));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, Theme.key_chat_attachGalleryText));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, i63));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, Theme.key_chat_attachAudioBackground));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, Theme.key_chat_attachAudioText));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, i63));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, Theme.key_chat_attachFileBackground));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, Theme.key_chat_attachFileText));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, i63));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, Theme.key_chat_attachContactBackground));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, Theme.key_chat_attachContactText));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, i63));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, Theme.key_chat_attachLocationBackground));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, Theme.key_chat_attachLocationText));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, i63));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, Theme.key_chat_attachPollBackground));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, Theme.key_chat_attachPollText));
        arrayList.add(new ThemeDescription(null, 0, null, null, new Drawable[]{Theme.chat_attachEmptyDrawable}, null, Theme.key_chat_attachEmptyImage));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, Theme.key_chat_attachPhotoBackground));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, Theme.key_dialogBackground));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, Theme.key_dialogBackgroundGray));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, Theme.key_dialogTextGray2));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, Theme.key_dialogScrollGlow));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, Theme.key_dialogGrayLine));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, Theme.key_dialogCameraIcon));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, Theme.key_dialogButtonSelector));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_windowBackgroundWhiteLinkSelection));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_windowBackgroundWhiteInputField));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_chat_outTextSelectionHighlight));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_chat_inTextSelectionHighlight));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_chat_TextSelectionCursor));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayGreen1));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayGreen2));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayBlue1));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayBlue2));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_topPanelGreen1));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_topPanelGreen2));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_topPanelBlue1));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_topPanelBlue2));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_topPanelGray));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayAlertGradientMuted));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayAlertGradientMuted2));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayAlertGradientUnmuted));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayAlertGradientUnmuted2));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_mutedByAdminGradient));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_mutedByAdminGradient2));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_mutedByAdminGradient3));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayAlertMutedByAdmin));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayAlertMutedByAdmin2));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_windowBackgroundGray));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_chat_outReactionButtonBackground));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_chat_inReactionButtonBackground));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_chat_inReactionButtonText));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_chat_outReactionButtonText));
        int i64 = Theme.key_chat_inReactionButtonTextSelected;
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, i64));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, i64));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, Theme.key_chat_BlurAlpha));
        ChatActivityEnterView chatActivityEnterView16 = this.chatActivityEnterView;
        if (chatActivityEnterView16 != null && chatActivityEnterView16.botCommandsMenuContainer != null) {
            arrayList.add(new ThemeDescription((View) this.chatActivityEnterView.botCommandsMenuContainer.listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{BotCommandsMenuView.BotCommandView.class}, new String[]{"description"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_windowBackgroundWhiteBlackText));
            arrayList.add(new ThemeDescription((View) this.chatActivityEnterView.botCommandsMenuContainer.listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{BotCommandsMenuView.BotCommandView.class}, new String[]{"command"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i39));
        }
        ChatActivityMemberRequestsDelegate chatActivityMemberRequestsDelegate = this.pendingRequestsDelegate;
        if (chatActivityMemberRequestsDelegate != null) {
            chatActivityMemberRequestsDelegate.fillThemeDescriptions(arrayList);
        }
        Iterator it = arrayList.iterator();
        while (it.hasNext()) {
            ((ThemeDescription) it.next()).resourcesProvider = this.themeDelegate;
        }
        return arrayList;
    }

    public Drawable getThemedDrawable(String str) {
        Drawable drawable = this.themeDelegate.getDrawable(str);
        return drawable != null ? drawable : super.getThemedDrawable(str);
    }

    public Paint getThemedPaint(String str) {
        Paint paint = this.themeDelegate.getPaint(str);
        return paint != null ? paint : Theme.getThemePaint(str);
    }

    public long getThreadId() {
        return this.threadMessageId;
    }

    public MessageObject getThreadMessage() {
        return this.threadMessageObject;
    }

    public long getTopicId() {
        int i;
        if (this.isTopic || (i = this.chatMode) == 3 || i == 5 || i == 8) {
            return this.threadMessageId;
        }
        return 0L;
    }

    public UndoView getUndoView() {
        createUndoView();
        return this.undoView;
    }

    public MessageObject.GroupedMessages getValidGroupedMessage(MessageObject messageObject) {
        if (messageObject.getGroupId() == 0) {
            return null;
        }
        MessageObject.GroupedMessages groupedMessages = (MessageObject.GroupedMessages) this.groupedMessagesMap.get(messageObject.getGroupId());
        if (groupedMessages == null || (groupedMessages.messages.size() > 1 && groupedMessages.getPosition(messageObject) != null)) {
            return groupedMessages;
        }
        return null;
    }

    public boolean groupEmojiPackHintWasVisible() {
        boolean z;
        HintView2 hintView2 = this.groupEmojiPackHint;
        if (hintView2 != null) {
            if (hintView2.shown()) {
                this.groupEmojiPackHint.hide();
            }
            z = true;
        } else {
            z = false;
        }
        this.groupEmojiPackHint = null;
        return z;
    }

    public boolean hasReportSpam() {
        BlurredFrameLayout blurredFrameLayout = this.topChatPanelView;
        return (blurredFrameLayout == null || blurredFrameLayout.getTag() != null || this.reportSpamButton.getVisibility() == 8) ? false : true;
    }

    public void hideFieldPanel(boolean z) {
        showFieldPanel(false, null, null, null, null, true, 0, null, false, 0L, z);
    }

    public void hideFieldPanel(boolean z, int i, long j, boolean z2) {
        showFieldPanel(false, null, null, null, null, z, i, null, false, j, z2);
    }

    protected boolean hideKeyboardOnShow() {
        MessageObject messageObject = this.threadMessageObject;
        if (messageObject != null && messageObject.getRepliesCount() == 0 && ChatObject.canSendMessages(this.currentChat)) {
            return false;
        }
        return super.hideKeyboardOnShow();
    }

    public void hitSearch() {
        this.searchWas = true;
        updateSearchButtons(0, 0, -1);
        getMediaDataController().searchMessagesInChat(this.searchingQuery, this.dialog_id, this.mergeDialogId, ((BaseFragment) this).classGuid, 0, this.threadMessageId, this.searchingUserMessages, this.searchingChatMessages, this.searchingReaction);
        boolean z = (TextUtils.isEmpty(this.searchingQuery) && this.searchingReaction == null) ? false : true;
        this.searching = z;
        this.searchItemVisible = z;
        updateBottomOverlay();
        updateSearchUpDownButtonVisibility(true);
    }

    public void invalidateMessagesVisiblePart() {
        this.invalidateMessagesVisiblePart = true;
        View view = ((BaseFragment) this).fragmentView;
        if (view != null) {
            view.invalidate();
        }
    }

    boolean isClearingHistory() {
        return this.clearingHistoryArr.get(getThreadId(), 0) != 0;
    }

    public boolean isEditingMessageMedia() {
        ChatAttachAlert chatAttachAlert = this.chatAttachAlert;
        return (chatAttachAlert == null || chatAttachAlert.getEditingMessageObject() == null) ? false : true;
    }

    public boolean isFiltered() {
        ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
        return chatActivityAdapter != null && chatActivityAdapter.isFiltered;
    }

    public boolean isForumInViewAsMessagesMode() {
        return (ChatObject.isForum(this.currentChat) && !this.isTopic) || (ChatObject.isMonoForum(this.currentChat) && getTopicId() == 0 && !this.isSubscriberSuggestions);
    }

    public boolean isInScheduleMode() {
        return this.chatMode == 1;
    }

    public boolean isKeyboardVisible() {
        return this.contentView.getKeyboardHeight() > AndroidUtilities.dp(20.0f);
    }

    public boolean isLightStatusBar() {
        if (isReport()) {
            Theme.ResourcesProvider resourceProvider = getResourceProvider();
            return ColorUtils.calculateLuminance(resourceProvider != null ? resourceProvider.getColorOrDefault(Theme.key_actionBarActionModeDefault) : Theme.getColor(Theme.key_actionBarActionModeDefault, null, true)) > 0.699999988079071d;
        }
        ActionBar actionBar = ((BaseFragment) this).actionBar;
        return actionBar == null ? !Theme.isCurrentThemeDark() : AndroidUtilities.computePerceivedBrightness(actionBar.getBackgroundColor()) > 0.721f;
    }

    public boolean isReplyChatComment() {
        return this.threadMessageObject != null && this.isComments;
    }

    public boolean isReport() {
        return !TextUtils.isEmpty(this.reportTitle);
    }

    public boolean isSecretChat() {
        return this.currentEncryptedChat != null;
    }

    public boolean isSwipeBackEnabled(MotionEvent motionEvent) {
        if ((this.chatMode == 5 && (this.messages.isEmpty() || this.threadMessageId == 0)) || !this.swipeBackEnabled) {
            return false;
        }
        MessagePreviewView messagePreviewView = this.forwardingPreviewView;
        if (messagePreviewView != null && messagePreviewView.isShowing()) {
            return false;
        }
        QuickShareSelectorOverlayLayout quickShareSelectorOverlayLayout = this.quickShareSelectorOverlay;
        return quickShareSelectorOverlayLayout == null || !quickShareSelectorOverlayLayout.isActive();
    }

    public boolean isThreadChat() {
        return this.threadMessageObject != null;
    }

    public void jumpToDate(int i) {
        int i2;
        TLRPC.Message message;
        if (this.messages.isEmpty()) {
            return;
        }
        MessageObject messageObject = (MessageObject) this.messages.get(0);
        ArrayList arrayList = this.messages;
        MessageObject messageObject2 = (MessageObject) arrayList.get(arrayList.size() - 1);
        if ((messageObject.messageOwner.date >= i && messageObject2.messageOwner.date <= i) || (messageObject2.messageOwner.date >= i && this.endReached[0])) {
            for (int size = this.messages.size() - 1; size >= 0; size--) {
                MessageObject messageObject3 = (MessageObject) this.messages.get(size);
                if (messageObject3.messageOwner.date >= i && messageObject3.getId() != 0) {
                    scrollToMessageId(messageObject3.getId(), 0, false, messageObject3.getDialogId() == this.mergeDialogId ? 1 : 0, true, 0);
                    return;
                }
            }
            return;
        }
        if (DialogObject.isEncryptedDialog(this.dialog_id)) {
            return;
        }
        int findLastVisibleItemPosition = this.chatLayoutManager.findLastVisibleItemPosition();
        int findFirstVisibleItemPosition = this.chatLayoutManager.findFirstVisibleItemPosition();
        while (true) {
            if (findFirstVisibleItemPosition > findLastVisibleItemPosition) {
                i2 = -1;
                break;
            }
            ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
            if (findFirstVisibleItemPosition < chatActivityAdapter.messagesStartRow || findFirstVisibleItemPosition >= chatActivityAdapter.messagesEndRow || (message = ((MessageObject) this.messages.get(findFirstVisibleItemPosition - this.chatAdapter.messagesStartRow)).messageOwner) == null) {
                findFirstVisibleItemPosition++;
            } else {
                int i3 = message.date < i ? 1 : 0;
                if (isSecretChat()) {
                    i3 ^= 1;
                }
                i2 = i3 ^ 1;
            }
        }
        this.chatScrollHelper.setScrollDirection(i2);
        AlertDialog alertDialog = this.progressDialog;
        if (alertDialog != null) {
            alertDialog.dismiss();
        }
        updatePinnedListButton(false);
        AlertDialog alertDialog2 = new AlertDialog(getParentActivity(), 3, this.themeDelegate);
        this.progressDialog = alertDialog2;
        alertDialog2.setOnCancelListener(this.postponedScrollCancelListener);
        this.progressDialog.showDelayed(1000L);
        int i4 = this.lastLoadIndex;
        this.postponedScrollToLastMessageQueryIndex = i4;
        this.fakePostponedScroll = false;
        this.waitingForLoad.add(Integer.valueOf(i4));
        this.postponedScrollMessageId = 0;
        this.postponedScrollIsCanceled = false;
        MessagesController messagesController = getMessagesController();
        long j = this.dialog_id;
        long j2 = this.mergeDialogId;
        int i5 = ((BaseFragment) this).classGuid;
        int i6 = this.chatMode;
        long j3 = this.threadMessageId;
        int i7 = this.replyMaxReadId;
        int i8 = this.lastLoadIndex;
        this.lastLoadIndex = i8 + 1;
        messagesController.loadMessages(j, j2, false, 30, 0, i, true, 0, i5, 4, 0, i6, j3, i7, i8, this.isTopic);
        this.floatingDateView.setAlpha(0.0f);
        this.floatingDateView.setTag(null);
        this.floatingTopicViewAlpha = 0.0f;
        updateFloatingTopicView();
        this.floatingTopicSeparator.setTag(null);
    }

    public void logSponsoredClicked(MessageObject messageObject, boolean z, boolean z2) {
        if (messageObject == null || !messageObject.isSponsored()) {
            return;
        }
        TLRPC.TL_messages_clickSponsoredMessage tL_messages_clickSponsoredMessage = new TLRPC.TL_messages_clickSponsoredMessage();
        tL_messages_clickSponsoredMessage.random_id = messageObject.sponsoredId;
        tL_messages_clickSponsoredMessage.media = z;
        tL_messages_clickSponsoredMessage.fullscreen = z2;
        getConnectionsManager().sendRequest(tL_messages_clickSponsoredMessage, (RequestDelegate) null);
    }

    public boolean maybePlayVisibleVideo() {
        AnimatedFileDrawable animatedFileDrawable;
        MessageObject messageObject;
        ImageReceiver photoImage;
        AnimatedFileDrawable animation;
        ChatMessageCell messageCell;
        if (this.chatListView == null) {
            return false;
        }
        MessageObject playingMessageObject = MediaController.getInstance().getPlayingMessageObject();
        if (playingMessageObject != null && !playingMessageObject.isVideo()) {
            return false;
        }
        HintView hintView = this.noSoundHintView;
        if (hintView == null || hintView.getTag() == null || (messageCell = this.noSoundHintView.getMessageCell()) == null) {
            animatedFileDrawable = null;
            messageObject = null;
        } else {
            ImageReceiver photoImage2 = messageCell.getPhotoImage();
            animatedFileDrawable = photoImage2.getAnimation();
            if (animatedFileDrawable != null) {
                messageObject = messageCell.getMessageObject();
                this.scrollToVideo = ((float) messageCell.getTop()) + photoImage2.getImageY2() > ((float) this.chatListView.getMeasuredHeight());
            } else {
                messageObject = null;
            }
        }
        if (messageObject == null) {
            int childCount = this.chatListView.getChildCount();
            int i = 0;
            while (true) {
                if (i >= childCount) {
                    break;
                }
                View childAt = this.chatListView.getChildAt(i);
                if (childAt instanceof ChatMessageCell) {
                    ChatMessageCell chatMessageCell = (ChatMessageCell) childAt;
                    MessageObject messageObject2 = chatMessageCell.getMessageObject();
                    boolean isRoundVideo = messageObject2.isRoundVideo();
                    if (!messageObject2.isRoundOnce() && !messageObject2.isVoiceOnce() && ((messageObject2.isVideo() || isRoundVideo) && messageObject2.videoEditedInfo == null && (animation = (photoImage = chatMessageCell.getPhotoImage()).getAnimation()) != null)) {
                        float top = childAt.getTop() + photoImage.getImageY();
                        float imageHeight = photoImage.getImageHeight() + top;
                        if (imageHeight >= 0.0f && top <= this.chatListView.getMeasuredHeight()) {
                            if (messageObject != null && top < 0.0f) {
                                break;
                            }
                            this.scrollToVideo = top < 0.0f || imageHeight > ((float) this.chatListView.getMeasuredHeight());
                            if (top >= 0.0f && imageHeight <= this.chatListView.getMeasuredHeight()) {
                                messageObject = messageObject2;
                                animatedFileDrawable = animation;
                                break;
                            }
                            messageObject = messageObject2;
                            animatedFileDrawable = animation;
                        }
                    }
                }
                i++;
            }
        }
        if (messageObject == null || MediaController.getInstance().isPlayingMessage(messageObject)) {
            return false;
        }
        hideHints(true);
        if (messageObject.isRoundVideo()) {
            boolean playMessage = MediaController.getInstance().playMessage(messageObject);
            MediaController.getInstance().setVoiceMessagesPlaylist(playMessage ? createVoiceMessagesPlaylist(messageObject, false) : null, false);
            return playMessage;
        }
        SharedConfig.setNoSoundHintShowed(true);
        messageObject.audioProgress = animatedFileDrawable.getCurrentProgress();
        messageObject.audioProgressMs = animatedFileDrawable.getCurrentProgressMs();
        animatedFileDrawable.stop();
        if (PhotoViewer.isPlayingMessageInPip(messageObject)) {
            PhotoViewer.getPipInstance().destroyPhotoViewer();
        }
        return MediaController.getInstance().playMessage(messageObject);
    }

    public boolean needDelayOpenAnimation() {
        if (this.chatMode != 1 && getParentLayout() != null && getParentLayout().getFragmentStack().size() > 1) {
            BaseFragment baseFragment = (BaseFragment) getParentLayout().getFragmentStack().get(getParentLayout().getFragmentStack().size() - 2);
            if ((baseFragment instanceof ChatActivity) && ((ChatActivity) baseFragment).isKeyboardVisible()) {
                return false;
            }
        }
        return this.firstLoading;
    }

    public boolean needEnterText() {
        boolean isKeyboardVisible = this.chatActivityEnterView.isKeyboardVisible();
        if (isKeyboardVisible) {
            this.chatActivityEnterView.showEmojiView();
            this.openKeyboardOnAttachMenuClose = true;
        }
        AndroidUtilities.setAdjustResizeToNothing(getParentActivity(), ((BaseFragment) this).classGuid);
        ((BaseFragment) this).fragmentView.requestLayout();
        return isKeyboardVisible;
    }

    public void onActivityResultFragment(int r25, int r26, final android.content.Intent r27) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.onActivityResultFragment(int, int, android.content.Intent):void");
    }

    public boolean onBackPressed() {
        Bulletin visibleBulletin = Bulletin.getVisibleBulletin();
        if (visibleBulletin != null && (visibleBulletin.getLayout() instanceof Bulletin.LottieLayoutWithReactions)) {
            visibleBulletin.getLayout().hideReactionsDialog();
            visibleBulletin.hide();
            return false;
        }
        SecretVoicePlayer secretVoicePlayer = this.secretVoicePlayer;
        if (secretVoicePlayer != null && secretVoicePlayer.isShown()) {
            this.secretVoicePlayer.dismiss();
            return false;
        }
        if (closeSheet()) {
            return false;
        }
        ChatSelectionReactionMenuOverlay chatSelectionReactionMenuOverlay = this.selectionReactionsOverlay;
        if (chatSelectionReactionMenuOverlay != null && !chatSelectionReactionMenuOverlay.onBackPressed()) {
            return false;
        }
        if (ContentPreviewViewer.getInstance().isVisible()) {
            ContentPreviewViewer.getInstance().closeWithMenu();
            return false;
        }
        MessagePreviewView messagePreviewView = this.forwardingPreviewView;
        if (messagePreviewView != null && messagePreviewView.isShowing()) {
            this.forwardingPreviewView.dismiss(true);
            return false;
        }
        if (this.messagesSearchListContainer.getTag() != null) {
            showMessagesSearchListView(false);
            return false;
        }
        if (this.scrimPopupWindow != null) {
            closeMenu();
            return false;
        }
        if (checkRecordLocked(false)) {
            return false;
        }
        if (this.textSelectionHelper.isInSelectionMode()) {
            this.textSelectionHelper.clear();
            return false;
        }
        ActionBar actionBar = ((BaseFragment) this).actionBar;
        if (actionBar != null && actionBar.isActionModeShowed()) {
            clearSelectionMode();
            return false;
        }
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView != null && chatActivityEnterView.isPopupShowing()) {
            return !this.chatActivityEnterView.hidePopup(true);
        }
        ChatActivityEnterView chatActivityEnterView2 = this.chatActivityEnterView;
        if (chatActivityEnterView2 != null && chatActivityEnterView2.hasBotWebView() && this.chatActivityEnterView.botCommandsMenuIsShowing() && this.chatActivityEnterView.onBotWebViewBackPressed()) {
            return false;
        }
        ChatActivityEnterView chatActivityEnterView3 = this.chatActivityEnterView;
        if (chatActivityEnterView3 != null && chatActivityEnterView3.botCommandsMenuIsShowing()) {
            this.chatActivityEnterView.hideBotCommands();
            return false;
        }
        ChatActivityEnterView chatActivityEnterView4 = this.chatActivityEnterView;
        if (chatActivityEnterView4 != null && chatActivityEnterView4.closeCreationLinkDialog()) {
            return false;
        }
        if (this.chatMode == 6 && BusinessLinksActivity.closeRenameAlert()) {
            return false;
        }
        if (ChatObject.isMonoForum(this.currentChat) && !this.isSubscriberSuggestions && this.topicsTabs != null && getTopicId() != 0) {
            this.topicsTabs.selectTopic(0L, this.topicChangedFromMessage);
            return false;
        }
        ChatActivity chatActivity = this.backToPreviousFragment;
        if (chatActivity != null) {
            INavigationLayout iNavigationLayout = ((BaseFragment) this).parentLayout;
            iNavigationLayout.addFragmentToStack(chatActivity, iNavigationLayout.getFragmentStack().size() - 1);
            this.backToPreviousFragment = null;
        }
        InstantCameraView instantCameraView = this.instantCameraView;
        if (instantCameraView != null) {
            instantCameraView.cancel(false);
        }
        if (this.chatMode == 5 && !"hello".equalsIgnoreCase(this.quickReplyShortcut) && !"away".equalsIgnoreCase(this.quickReplyShortcut) && (this.messages.isEmpty() || this.threadMessageId == 0)) {
            showQuickRepliesRemoveAlert();
            return false;
        }
        if (this.chatMode != 6 || !this.chatActivityEnterView.businessLinkHasChanges()) {
            return true;
        }
        showBusinessLinksDiscardAlert(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$onBackPressed$354();
            }
        });
        return false;
    }

    public void onBecomeFullyHidden() {
        hideTagSelector();
        if (!getMessagesController().premiumFeaturesBlocked() && getMessagesController().transcribeAudioTrialWeeklyNumber <= 0 && !getMessagesController().didPressTranscribeButtonEnough() && !getUserConfig().isPremium() && this.messages != null) {
            for (int i = 0; i < this.messages.size(); i++) {
                MessageObject messageObject = (MessageObject) this.messages.get(i);
                if (messageObject != null && !messageObject.isOutOwner() && ((messageObject.isVoice() || messageObject.isRoundVideo()) && !messageObject.isUnread() && (messageObject.isContentUnread() || ChatObject.isChannelAndNotMegaGroup(this.currentChat)))) {
                    TranscribeButton.showOffTranscribe(messageObject, false);
                }
            }
        }
        this.isFullyVisible = false;
        hideUndoViews();
        INavigationLayout iNavigationLayout = ((BaseFragment) this).parentLayout;
        if (iNavigationLayout != null && iNavigationLayout.getDrawerLayoutContainer() != null) {
            ((BaseFragment) this).parentLayout.getDrawerLayoutContainer().setBehindKeyboardColor(Theme.getColor(Theme.key_windowBackgroundWhite));
        }
        TranscribeButton.resetVideoTranscriptionsOpen();
        Browser.Progress progress = this.progressDialogCurrent;
        if (progress != null) {
            progress.cancel();
            this.progressDialogCurrent = null;
        }
        this.flagSecure.detach();
        super.onBecomeFullyHidden();
    }

    public void onBecomeFullyVisible() {
        this.isFullyVisible = true;
        super.onBecomeFullyVisible();
        if (this.showCloseChatDialogLater) {
            showDialog(this.closeChatDialog);
        }
        INavigationLayout iNavigationLayout = ((BaseFragment) this).parentLayout;
        if (iNavigationLayout != null && iNavigationLayout.getDrawerLayoutContainer() != null) {
            ((BaseFragment) this).parentLayout.getDrawerLayoutContainer().setBehindKeyboardColor(getThemedColor(Theme.key_windowBackgroundWhite));
        }
        if (this.keyboardWasVisible) {
            ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
            if (chatActivityEnterView != null) {
                chatActivityEnterView.openKeyboardInternal();
                this.chatActivityEnterView.freezeEmojiView(false);
            }
            this.keyboardWasVisible = false;
        }
        if (this.savedMessagesHint != null) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.checkSavedMessagesHint();
                }
            }, 600L);
        }
        if (!this.convertingToast || this.convertingToastShown) {
            return;
        }
        this.convertingToastShown = true;
        BulletinFactory.of(this).createSimpleBulletin(R.raw.convert_video, LocaleController.getString(R.string.VideoConversionTitle), LocaleController.getString(R.string.VideoConversionText)).setDuration(5000).setOnHideListener(new ChatActivity$$ExternalSyntheticLambda96(this)).show(true);
    }

    public void onBeginSlide() {
        super.onBeginSlide();
        ChatSelectionReactionMenuOverlay chatSelectionReactionMenuOverlay = this.selectionReactionsOverlay;
        if (chatSelectionReactionMenuOverlay == null || !chatSelectionReactionMenuOverlay.isVisible()) {
            return;
        }
        this.selectionReactionsOverlay.setHiddenByScroll(true);
    }

    public void onConfigurationChanged(Configuration configuration) {
        MessageObject playingMessageObject;
        fixLayout();
        Dialog dialog = ((BaseFragment) this).visibleDialog;
        if (dialog instanceof DatePickerDialog) {
            dialog.dismiss();
        }
        closeMenu();
        if (AndroidUtilities.isTablet()) {
            return;
        }
        if (configuration.orientation != 2) {
            if (PhotoViewer.hasInstance() && PhotoViewer.getInstance().isOpenedFullScreenVideo()) {
                PhotoViewer.getInstance().injectVideoPlayerToMediaController();
                PhotoViewer.getInstance().closePhoto(false, true);
                return;
            }
            return;
        }
        if ((PhotoViewer.hasInstance() && PhotoViewer.getInstance().isVisible()) || (playingMessageObject = MediaController.getInstance().getPlayingMessageObject()) == null || !playingMessageObject.isVideo()) {
            return;
        }
        PhotoViewer.getInstance().setParentActivity(this, this.themeDelegate);
        getFileLoader().setLoadingVideoForPlayer(playingMessageObject.getDocument(), false);
        MediaController.getInstance().cleanupPlayer(true, true, false, true);
        PhotoViewer photoViewer = PhotoViewer.getInstance();
        int i = playingMessageObject.type;
        if (photoViewer.openPhoto(playingMessageObject, i != 0 ? this.dialog_id : 0L, i != 0 ? this.mergeDialogId : 0L, i != 0 ? getTopicId() : 0L, this.photoViewerProvider, false)) {
            PhotoViewer.getInstance().setParentChatActivity(this);
        }
        hideHints(false);
        MediaController.getInstance().resetGoingToShowMessageObject();
    }

    public AnimatorSet onCustomTransitionAnimation(boolean z, Runnable runnable) {
        ValueAnimator ofFloat;
        if (z && this.fromPullingDownTransition && getParentLayout() != null && getParentLayout().getFragmentStack().size() > 1) {
            BaseFragment baseFragment = (BaseFragment) getParentLayout().getFragmentStack().get(getParentLayout().getFragmentStack().size() - 2);
            if (baseFragment instanceof ChatActivity) {
                this.wasManualScroll = true;
                final ChatActivity chatActivity = (ChatActivity) baseFragment;
                chatActivity.setTransitionToChatActivity(this);
                ((BaseFragment) this).fragmentView.setAlpha(0.0f);
                this.contentView.setSkipBackgroundDrawing(true);
                this.avatarContainer.setTranslationY(AndroidUtilities.dp(8.0f));
                this.avatarContainer.getAvatarImageView().setAlpha(0.0f);
                this.avatarContainer.getAvatarImageView().setTranslationY(-AndroidUtilities.dp(8.0f));
                this.toPullingDownTransition = true;
                ValueAnimator ofFloat2 = ValueAnimator.ofFloat(0.0f, 1.0f);
                ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
                if (chatActivityEnterView != null) {
                    chatActivityEnterView.measure(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.displaySize.x, 1073741824), View.MeasureSpec.makeMeasureSpec(999999, Integer.MIN_VALUE));
                }
                FrameLayout frameLayout = this.bottomOverlay;
                if (frameLayout != null) {
                    frameLayout.measure(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.displaySize.x, 1073741824), View.MeasureSpec.makeMeasureSpec(999999, Integer.MIN_VALUE));
                }
                ChatActivityEnterView chatActivityEnterView2 = this.chatActivityEnterView;
                int measuredHeight = chatActivityEnterView2 == null ? 0 : chatActivityEnterView2.getMeasuredHeight();
                FrameLayout frameLayout2 = this.bottomOverlay;
                int max = Math.max(measuredHeight, frameLayout2 == null ? 0 : frameLayout2.getMeasuredHeight());
                ChatActivityEnterView chatActivityEnterView3 = chatActivity.chatActivityEnterView;
                int measuredHeight2 = chatActivityEnterView3 == null ? 0 : chatActivityEnterView3.getMeasuredHeight();
                this.pullingBottomOffset = -(Math.max(measuredHeight2, this.bottomOverlay == null ? 0 : r5.getMeasuredHeight()) - max);
                final boolean z2 = chatActivity.fragmentContextView.getMeasuredHeight() != this.fragmentContextView.getMeasuredHeight();
                ofFloat2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                    @Override
                    public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                        ChatActivity.this.lambda$onCustomTransitionAnimation$384(chatActivity, z2, valueAnimator);
                    }
                });
                updateChatListViewTopPadding();
                AnimatorSet animatorSet = new AnimatorSet();
                this.fragmentTransition = animatorSet;
                animatorSet.addListener(new AnonymousClass158(chatActivity, runnable));
                this.fragmentTransition.setDuration(300L);
                this.fragmentTransition.setInterpolator(CubicBezierInterpolator.DEFAULT);
                this.fragmentTransition.playTogether(ofFloat2);
                AndroidUtilities.runOnUIThread(this.fragmentTransitionRunnable, 200L);
                return this.fragmentTransition;
            }
        }
        if (!this.switchFromTopics || getParentLayout() == null || getParentLayout().getFragmentStack().size() <= 1) {
            return null;
        }
        BaseFragment baseFragment2 = (BaseFragment) getParentLayout().getFragmentStack().get(getParentLayout().getFragmentStack().size() - 2);
        if (!(baseFragment2 instanceof TopicsFragment)) {
            return null;
        }
        float[] fArr = {1.0f, 0.0f};
        if (z) {
            
            fArr[0] = 0.0f;
            fArr[1] = 1.0f;
            ofFloat = ValueAnimator.ofFloat(fArr);
        } else {
            ofFloat = ValueAnimator.ofFloat(fArr);
        }
        baseFragment2.getFragmentView().getWidth();
        this.switchingFromTopicsProgress = z ? 0.0f : 1.0f;
        ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                ChatActivity.this.switchingFromTopicsProgress = ((Float) valueAnimator.getAnimatedValue()).floatValue();
                ChatActivity.this.contentView.invalidate();
            }
        });
        this.switchingFromTopics = true;
        ActionBar actionBar = ((BaseFragment) this).actionBar;
        if (actionBar != null) {
            actionBar.invalidate();
        }
        SizeNotifierFrameLayout sizeNotifierFrameLayout = this.contentView;
        if (sizeNotifierFrameLayout != null) {
            sizeNotifierFrameLayout.invalidate();
        }
        AnimatorSet animatorSet2 = new AnimatorSet();
        this.fragmentTransition = animatorSet2;
        animatorSet2.addListener(new AnonymousClass160(z, runnable));
        this.fragmentTransition.setDuration(150L);
        this.fragmentTransition.playTogether(ofFloat);
        if (z) {
            AndroidUtilities.runOnUIThread(this.fragmentTransitionRunnable, 200L);
        } else {
            this.fragmentTransition.start();
        }
        return this.fragmentTransition;
    }

    protected void onDialogDismiss(Dialog dialog) {
        Dialog dialog2 = this.closeChatDialog;
        if (dialog2 == null || dialog != dialog2) {
            return;
        }
        getMessagesController().deleteDialog(this.dialog_id, 0);
        INavigationLayout iNavigationLayout = ((BaseFragment) this).parentLayout;
        if (iNavigationLayout == null || iNavigationLayout.getFragmentStack().isEmpty() || ((BaseFragment) this).parentLayout.getFragmentStack().get(((BaseFragment) this).parentLayout.getFragmentStack().size() - 1) == this) {
            lambda$onBackPressed$354();
            return;
        }
        BaseFragment baseFragment = (BaseFragment) ((BaseFragment) this).parentLayout.getFragmentStack().get(((BaseFragment) this).parentLayout.getFragmentStack().size() - 1);
        removeSelfFromStack();
        baseFragment.finishFragment();
    }

    public void onEditTextDialogClose(boolean z, boolean z2) {
        if (this.openKeyboardOnAttachMenuClose) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$onEditTextDialogClose$117();
                }
            }, 200L);
            if (z2) {
                this.openKeyboardOnAttachMenuClose = false;
            }
        }
        if (!z || this.isInsideContainer) {
            return;
        }
        AndroidUtilities.requestAdjustResize(getParentActivity(), ((BaseFragment) this).classGuid);
    }

    public boolean onFragmentCreate() {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.onFragmentCreate():boolean");
    }

    public void onFragmentDestroy() {
        super.onFragmentDestroy();
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView != null) {
            chatActivityEnterView.onDestroy();
        }
        ChatAvatarContainer chatAvatarContainer = this.avatarContainer;
        if (chatAvatarContainer != null) {
            chatAvatarContainer.onDestroy();
        }
        MentionsContainerView mentionsContainerView = this.mentionContainer;
        if (mentionsContainerView != null && mentionsContainerView.getAdapter() != null) {
            this.mentionContainer.getAdapter().onDestroy();
        }
        ChatAttachAlert chatAttachAlert = this.chatAttachAlert;
        if (chatAttachAlert != null) {
            chatAttachAlert.dismissInternal();
        }
        ContentPreviewViewer.getInstance().clearDelegate(this.contentPreviewViewerDelegate);
        getNotificationCenter().onAnimationFinish(this.transitionAnimationIndex);
        NotificationCenter.getGlobalInstance().onAnimationFinish(this.transitionAnimationGlobalIndex);
        getNotificationCenter().onAnimationFinish(this.scrollAnimationIndex);
        getNotificationCenter().onAnimationFinish(this.scrollCallbackAnimationIndex);
        hideUndoViews();
        Runnable runnable = this.chatInviteRunnable;
        if (runnable != null) {
            AndroidUtilities.cancelRunOnUIThread(runnable);
            this.chatInviteRunnable = null;
        }
        getNotificationCenter().removePostponeNotificationsCallback(this.postponeNotificationsWhileLoadingCallback);
        getMessagesController().setLastCreatedDialogId(this.dialog_id, this.chatMode == 1, false);
        getNotificationCenter().removeObserver(this, NotificationCenter.messagesDidLoad);
        getNotificationCenter().removeObserver(this, NotificationCenter.loadingMessagesFailed);
        getNotificationCenter().removeObserver(this, NotificationCenter.premiumFloodWaitReceived);
        NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.emojiLoaded);
        NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.invalidateMotionBackground);
        getNotificationCenter().removeObserver(this, NotificationCenter.didUpdateConnectionState);
        getNotificationCenter().removeObserver(this, NotificationCenter.updateInterfaces);
        getNotificationCenter().removeObserver(this, NotificationCenter.updateDefaultSendAsPeer);
        getNotificationCenter().removeObserver(this, NotificationCenter.userIsPremiumBlockedUpadted);
        getNotificationCenter().removeObserver(this, NotificationCenter.didReceiveNewMessages);
        getNotificationCenter().removeObserver(this, NotificationCenter.closeChats);
        getNotificationCenter().removeObserver(this, NotificationCenter.messagesRead);
        getNotificationCenter().removeObserver(this, NotificationCenter.threadMessagesRead);
        getNotificationCenter().removeObserver(this, NotificationCenter.monoForumMessagesRead);
        getNotificationCenter().removeObserver(this, NotificationCenter.commentsRead);
        getNotificationCenter().removeObserver(this, NotificationCenter.changeRepliesCounter);
        getNotificationCenter().removeObserver(this, NotificationCenter.messagesDeleted);
        getNotificationCenter().removeObserver(this, NotificationCenter.historyCleared);
        getNotificationCenter().removeObserver(this, NotificationCenter.messageReceivedByServer);
        getNotificationCenter().removeObserver(this, NotificationCenter.messageReceivedByAck);
        getNotificationCenter().removeObserver(this, NotificationCenter.messageSendError);
        getNotificationCenter().removeObserver(this, NotificationCenter.chatInfoDidLoad);
        getNotificationCenter().removeObserver(this, NotificationCenter.groupRestrictionsUnlockedByBoosts);
        getNotificationCenter().removeObserver(this, NotificationCenter.customStickerCreated);
        getNotificationCenter().removeObserver(this, NotificationCenter.didLoadChatInviter);
        getNotificationCenter().removeObserver(this, NotificationCenter.groupCallUpdated);
        getNotificationCenter().removeObserver(this, NotificationCenter.encryptedChatUpdated);
        getNotificationCenter().removeObserver(this, NotificationCenter.messagesReadEncrypted);
        getNotificationCenter().removeObserver(this, NotificationCenter.removeAllMessagesFromDialog);
        getNotificationCenter().removeObserver(this, NotificationCenter.contactsDidLoad);
        getNotificationCenter().removeObserver(this, NotificationCenter.messagePlayingProgressDidChanged);
        getNotificationCenter().removeObserver(this, NotificationCenter.messagePlayingDidReset);
        getNotificationCenter().removeObserver(this, NotificationCenter.screenshotTook);
        getNotificationCenter().removeObserver(this, NotificationCenter.blockedUsersDidLoad);
        getNotificationCenter().removeObserver(this, NotificationCenter.fileNewChunkAvailable);
        getNotificationCenter().removeObserver(this, NotificationCenter.didCreatedNewDeleteTask);
        getNotificationCenter().removeObserver(this, NotificationCenter.messagePlayingDidStart);
        getNotificationCenter().removeObserver(this, NotificationCenter.messagePlayingGoingToStop);
        getNotificationCenter().removeObserver(this, NotificationCenter.updateMessageMedia);
        getNotificationCenter().removeObserver(this, NotificationCenter.voiceTranscriptionUpdate);
        getNotificationCenter().removeObserver(this, NotificationCenter.animatedEmojiDocumentLoaded);
        getNotificationCenter().removeObserver(this, NotificationCenter.replaceMessagesObjects);
        getNotificationCenter().removeObserver(this, NotificationCenter.notificationsSettingsUpdated);
        getNotificationCenter().removeObserver(this, NotificationCenter.replyMessagesDidLoad);
        getNotificationCenter().removeObserver(this, NotificationCenter.didReceivedWebpages);
        getNotificationCenter().removeObserver(this, NotificationCenter.didReceivedWebpagesInUpdates);
        getNotificationCenter().removeObserver(this, NotificationCenter.messagesReadContent);
        getNotificationCenter().removeObserver(this, NotificationCenter.botInfoDidLoad);
        getNotificationCenter().removeObserver(this, NotificationCenter.botKeyboardDidLoad);
        getNotificationCenter().removeObserver(this, NotificationCenter.chatSearchResultsAvailable);
        getNotificationCenter().removeObserver(this, NotificationCenter.chatSearchResultsLoading);
        getNotificationCenter().removeObserver(this, NotificationCenter.messagePlayingPlayStateChanged);
        getNotificationCenter().removeObserver(this, NotificationCenter.didUpdateMessagesViews);
        getNotificationCenter().removeObserver(this, NotificationCenter.chatInfoCantLoad);
        getNotificationCenter().removeObserver(this, NotificationCenter.didLoadPinnedMessages);
        getNotificationCenter().removeObserver(this, NotificationCenter.peerSettingsDidLoad);
        getNotificationCenter().removeObserver(this, NotificationCenter.newDraftReceived);
        getNotificationCenter().removeObserver(this, NotificationCenter.userInfoDidLoad);
        getNotificationCenter().removeObserver(this, NotificationCenter.pinnedInfoDidLoad);
        getNotificationCenter().removeObserver(this, NotificationCenter.topicsDidLoaded);
        getNotificationCenter().removeObserver(this, NotificationCenter.chatWasBoostedByUser);
        NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didSetNewWallpapper);
        NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didApplyNewTheme);
        NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.goingToPreviewTheme);
        getNotificationCenter().removeObserver(this, NotificationCenter.channelRightsUpdated);
        getNotificationCenter().removeObserver(this, NotificationCenter.updateMentionsCount);
        getNotificationCenter().removeObserver(this, NotificationCenter.audioRecordTooShort);
        getNotificationCenter().removeObserver(this, NotificationCenter.didUpdatePollResults);
        getNotificationCenter().removeObserver(this, NotificationCenter.didUpdateReactions);
        getNotificationCenter().removeObserver(this, NotificationCenter.savedReactionTagsUpdate);
        getNotificationCenter().removeObserver(this, NotificationCenter.updateAllMessages);
        getNotificationCenter().removeObserver(this, NotificationCenter.didUpdateExtendedMedia);
        getNotificationCenter().removeObserver(this, NotificationCenter.chatOnlineCountDidLoad);
        getNotificationCenter().removeObserver(this, NotificationCenter.videoLoadingStateChanged);
        getNotificationCenter().removeObserver(this, NotificationCenter.scheduledMessagesUpdated);
        getNotificationCenter().removeObserver(this, NotificationCenter.diceStickersDidLoad);
        getNotificationCenter().removeObserver(this, NotificationCenter.dialogDeleted);
        getNotificationCenter().removeObserver(this, NotificationCenter.chatAvailableReactionsUpdated);
        getNotificationCenter().removeObserver(this, NotificationCenter.didLoadSponsoredMessages);
        getNotificationCenter().removeObserver(this, NotificationCenter.didLoadSendAsPeers);
        getNotificationCenter().removeObserver(this, NotificationCenter.dialogsUnreadReactionsCounterChanged);
        getNotificationCenter().removeObserver(this, NotificationCenter.groupStickersDidLoad);
        getNotificationCenter().removeObserver(this, NotificationCenter.dialogTranslate);
        getNotificationCenter().removeObserver(this, NotificationCenter.dialogIsTranslatable);
        getNotificationCenter().removeObserver(this, NotificationCenter.messageTranslated);
        getNotificationCenter().removeObserver(this, NotificationCenter.messageTranslating);
        getNotificationCenter().removeObserver(this, NotificationCenter.onReceivedChannelDifference);
        getNotificationCenter().removeObserver(this, NotificationCenter.storiesUpdated);
        getNotificationCenter().removeObserver(this, NotificationCenter.channelRecommendationsLoaded);
        getNotificationCenter().removeObserver(this, NotificationCenter.updateTranscriptionLock);
        getNotificationCenter().removeObserver(this, NotificationCenter.savedMessagesDialogsUpdate);
        getNotificationCenter().removeObserver(this, NotificationCenter.quickRepliesDeleted);
        getNotificationCenter().removeObserver(this, NotificationCenter.quickRepliesUpdated);
        getNotificationCenter().removeObserver(this, NotificationCenter.availableEffectsUpdate);
        getNotificationCenter().removeObserver(this, NotificationCenter.starReactionAnonymousUpdate);
        getNotificationCenter().removeObserver(this, NotificationCenter.factCheckLoaded);
        getNotificationCenter().removeObserver(this, NotificationCenter.messagesFeeUpdated);
        getNotificationCenter().removeObserver(this, NotificationCenter.starBalanceUpdated);
        if (this.chatMode == 6) {
            getNotificationCenter().removeObserver(this, NotificationCenter.businessLinksUpdated);
        }
        if (this.chatMode == 7) {
            getNotificationCenter().removeObserver(this, NotificationCenter.hashtagSearchUpdated);
        }
        SearchTagsList searchTagsList = this.actionBarSearchTags;
        if (searchTagsList != null) {
            searchTagsList.detach();
        }
        if (this.currentEncryptedChat != null) {
            getNotificationCenter().removeObserver(this, NotificationCenter.didVerifyMessagesStickers);
        }
        NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.needSetDayNightTheme);
        if (this.chatMode == 0 && AndroidUtilities.isTablet()) {
            getNotificationCenter().postNotificationName(NotificationCenter.openedChatChanged, new Object[]{Long.valueOf(this.dialog_id), Long.valueOf(getTopicId()), Boolean.TRUE});
        }
        if (this.currentUser != null) {
            MediaController.getInstance().stopMediaObserver();
        }
        FlagSecureReason flagSecureReason = this.flagSecure;
        if (flagSecureReason != null) {
            flagSecureReason.detach();
        }
        if (this.currentUser != null) {
            getMessagesController().cancelLoadFullUser(this.currentUser.id);
        }
        AndroidUtilities.removeAdjustResize(getParentActivity(), ((BaseFragment) this).classGuid);
        ChatAttachAlert chatAttachAlert2 = this.chatAttachAlert;
        if (chatAttachAlert2 != null) {
            chatAttachAlert2.onDestroy();
        }
        AndroidUtilities.unlockOrientation(getParentActivity());
        if (ChatObject.isChannel(this.currentChat)) {
            getMessagesController().startShortPoll(this.currentChat, ((BaseFragment) this).classGuid, true);
            TLRPC.ChatFull chatFull = this.chatInfo;
            if (chatFull != null && chatFull.linked_chat_id != 0) {
                getMessagesController().startShortPoll(getMessagesController().getChat(Long.valueOf(this.chatInfo.linked_chat_id)), ((BaseFragment) this).classGuid, true);
            }
        }
        ChatActivityTextSelectionHelper chatActivityTextSelectionHelper = this.textSelectionHelper;
        if (chatActivityTextSelectionHelper != null) {
            chatActivityTextSelectionHelper.clear();
        }
        ChatListItemAnimator chatListItemAnimator = this.chatListItemAnimator;
        if (chatListItemAnimator != null) {
            chatListItemAnimator.onDestroy();
        }
        PinchToZoomHelper pinchToZoomHelper = this.pinchToZoomHelper;
        if (pinchToZoomHelper != null) {
            pinchToZoomHelper.clear();
        }
        this.chatThemeBottomSheet = null;
        INavigationLayout parentLayout = getParentLayout();
        if (parentLayout != null && parentLayout.getFragmentStack() != null) {
            BackButtonMenu.clearPulledDialogs(this, parentLayout.getFragmentStack().indexOf(this) - (!replacingChatActivity ? 1 : 0));
        }
        replacingChatActivity = false;
        Browser.Progress progress = this.progressDialogCurrent;
        if (progress != null) {
            progress.cancel();
            this.progressDialogCurrent = null;
        }
        this.chatMessagesMetadataController.onFragmentDestroy();
        ProfileBirthdayEffect.BirthdayEffectFetcher birthdayEffectFetcher = this.birthdayAssetsFetcher;
        if (birthdayEffectFetcher != null) {
            birthdayEffectFetcher.detach(true);
            this.birthdayAssetsFetcher = null;
        }
        StarReactionsOverlay starReactionsOverlay = this.starReactionsOverlay;
        if (starReactionsOverlay != null) {
            starReactionsOverlay.setMessageCell((BaseCell) null);
            AndroidUtilities.removeFromParent(this.starReactionsOverlay);
            this.starReactionsOverlay = null;
        }
    }

    public List onGetDebugItems() {
        ArrayList arrayList = new ArrayList();
        if (ChatObject.isChannel(this.currentChat)) {
            arrayList.add(new FloatingDebugController.DebugItem(LocaleController.getString(R.string.DebugShareAlert)));
            int i = this.shareAlertDebugMode;
            arrayList.add(new FloatingDebugController.DebugItem(LocaleController.formatString(R.string.DebugShareAlertSwitchDialogsMode, new Object[]{LocaleController.getString(i != 1 ? i != 2 ? R.string.DebugShareAlertDialogsModeNormal : R.string.DebugShareAlertDialogsModeMore : R.string.DebugShareAlertDialogsModeLess)}), new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$onGetDebugItems$5();
                }
            }));
            arrayList.add(new FloatingDebugController.DebugItem(LocaleController.getString(R.string.DebugShareAlertTopicsSlowMotion), new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$onGetDebugItems$6();
                }
            }));
        }
        if (this.currentUser == null) {
            arrayList.add(new FloatingDebugController.DebugItem(LocaleController.getString(R.string.DebugMessageSkeletons)));
            String str = "";
            arrayList.add(new FloatingDebugController.DebugItem(LocaleController.getString(R.string.DebugMessageSkeletonsLightOverlayAlpha), 0.0f, 255.0f, new AnimationProperties.FloatProperty(str) {
                public Object get(Object obj) {
                    return Float.valueOf(ChatActivity.SKELETON_LIGHT_OVERLAY_ALPHA);
                }

                public void setValue(Object obj, float f) {
                    int unused = ChatActivity.SKELETON_LIGHT_OVERLAY_ALPHA = (int) f;
                }
            }));
            arrayList.add(new FloatingDebugController.DebugItem(LocaleController.getString(R.string.DebugMessageSkeletonsSaturation), 1.0f, 10.0f, new AnimationProperties.FloatProperty(str) {
                public Object get(Object obj) {
                    return Float.valueOf(ChatActivity.SKELETON_SATURATION);
                }

                public void setValue(Object obj, float f) {
                    float unused = ChatActivity.SKELETON_SATURATION = f;
                    ChatActivity.this.skeletonColorMatrix.setSaturation(f);
                    ChatActivity.this.skeletonServicePaint.setColorFilter(new ColorMatrixColorFilter(ChatActivity.this.skeletonColorMatrix));
                }
            }));
        }
        return arrayList;
    }

    public void onListItemAnimatorTick() {
        invalidateMessagesVisiblePart();
        if (this.scrimView != null) {
            ((BaseFragment) this).fragmentView.invalidate();
        }
    }

    public void onPageDownClicked() {
        int i;
        boolean z;
        int i2;
        int i3;
        boolean z2;
        this.wasManualScroll = true;
        this.textSelectionHelper.cancelTextSelectionRunnable();
        Runnable runnable = new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$onPageDownClicked$99();
            }
        };
        int i4 = this.createUnreadMessageAfterId;
        if (i4 != 0) {
            i = this.returnToLoadIndex;
            z = true;
            i2 = 0;
            i3 = 0;
            z2 = false;
        } else {
            i4 = this.returnToMessageId;
            if (i4 <= 0) {
                scrollToLastMessage(true, true, runnable);
                if (this.pinnedMessageIds.isEmpty()) {
                    return;
                }
                this.forceScrollToFirst = true;
                this.forceNextPinnedMessageId = ((Integer) this.pinnedMessageIds.get(0)).intValue();
                return;
            }
            i = this.returnToLoadIndex;
            z = true;
            i2 = 0;
            i3 = 0;
            z2 = true;
        }
        scrollToMessageId(i4, i3, z2, i, z, i2, runnable);
    }

    public void onPause() {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.onPause():void");
    }

    public void onRemoveFromParent() {
        this.removingFromParent = true;
        MessageObject playingMessageObject = MediaController.getInstance().getPlayingMessageObject();
        if (playingMessageObject == null || !playingMessageObject.isVideo()) {
            MediaController.getInstance().setTextureView(this.videoTextureView, (AspectRatioFrameLayout) null, (FrameLayout) null, false);
        } else {
            MediaController.getInstance().cleanupPlayer(true, true);
        }
        StarReactionsOverlay starReactionsOverlay = this.starReactionsOverlay;
        if (starReactionsOverlay != null) {
            starReactionsOverlay.setMessageCell((BaseCell) null);
            AndroidUtilities.removeFromParent(this.starReactionsOverlay);
            this.starReactionsOverlay = null;
        }
        super.onRemoveFromParent();
    }

    public void onRequestPermissionsResultFragment(int i, String[] strArr, int[] iArr) {
        ChatAttachAlert chatAttachAlert;
        ChatAttachAlert chatAttachAlert2;
        ChatAttachAlert chatAttachAlert3;
        boolean z;
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView != null) {
            chatActivityEnterView.onRequestPermissionsResultFragment(i, strArr, iArr);
        }
        MentionsContainerView mentionsContainerView = this.mentionContainer;
        if (mentionsContainerView != null && mentionsContainerView.getAdapter() != null) {
            this.mentionContainer.getAdapter().onRequestPermissionsResultFragment(i, strArr, iArr);
        }
        if (i == 4) {
            ChatAttachAlert chatAttachAlert4 = this.chatAttachAlert;
            if (chatAttachAlert4 != null) {
                chatAttachAlert4.getPhotoLayout().checkStorage();
            }
            ChatThemeBottomSheet chatThemeBottomSheet = this.chatThemeBottomSheet;
            if (chatThemeBottomSheet == null || (chatAttachAlert3 = chatThemeBottomSheet.chatAttachAlert) == null) {
                return;
            }
        } else {
            if ((i == 5 || i == 30) && (chatAttachAlert = this.chatAttachAlert) != null) {
                chatAttachAlert.onRequestPermissionsResultFragment(i, strArr, iArr);
                return;
            }
            if ((i != 17 && i != 18) || (chatAttachAlert2 = this.chatAttachAlert) == null) {
                if (i == 21) {
                    if (getParentActivity() == null || iArr == null || iArr.length == 0 || iArr[0] == 0) {
                        return;
                    }
                    AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity(), this.themeDelegate);
                    builder.setTitle(LocaleController.getString(R.string.AppName));
                    builder.setMessage(LocaleController.getString(R.string.PermissionNoAudioVideoWithHint));
                    builder.setNegativeButton(LocaleController.getString(R.string.PermissionOpenSettings), new AlertDialog.OnButtonClickListener() {
                        @Override
                        public final void onClick(AlertDialog alertDialog, int i2) {
                            ChatActivity.this.lambda$onRequestPermissionsResultFragment$163(alertDialog, i2);
                        }
                    });
                    builder.setPositiveButton(LocaleController.getString(R.string.OK), null);
                    builder.show();
                    return;
                }
                if (i == 19 && iArr != null && iArr.length > 0 && iArr[0] == 0) {
                    processSelectedAttach(0);
                    return;
                }
                if (i == 20 && iArr != null && iArr.length > 0 && iArr[0] == 0) {
                    processSelectedAttach(2);
                    return;
                }
                if (((i == 101 || i == 102) && this.currentUser != null) || (i == 103 && this.currentChat != null)) {
                    int i2 = 0;
                    while (true) {
                        if (i2 >= iArr.length) {
                            z = true;
                            break;
                        } else {
                            if (iArr[i2] != 0) {
                                z = false;
                                break;
                            }
                            i2++;
                        }
                    }
                    if (iArr.length <= 0 || !z) {
                        VoIPHelper.permissionDenied(getParentActivity(), null, i);
                        return;
                    }
                    if (i == 103) {
                        VoIPHelper.startCall(this.currentChat, null, null, this.createGroupCall, getParentActivity(), this, getAccountInstance());
                        return;
                    }
                    TLRPC.User user = this.currentUser;
                    boolean z2 = i == 102;
                    TLRPC.UserFull userFull = this.userInfo;
                    VoIPHelper.startCall(user, z2, userFull != null && userFull.video_calls_available, getParentActivity(), getMessagesController().getUserFull(this.currentUser.id), getAccountInstance());
                    return;
                }
                return;
            }
            chatAttachAlert2.getPhotoLayout().checkCamera(iArr.length > 0 && iArr[0] == 0);
            chatAttachAlert3 = this.chatAttachAlert;
        }
        chatAttachAlert3.getPhotoLayout().checkStorage();
    }

    public void onResume() {
        ChatActivityEnterView chatActivityEnterView;
        MessageObject messageObject;
        boolean z;
        BackupImageView backupImageView;
        super.onResume();
        checkShowBlur(false);
        this.activityResumeTime = System.currentTimeMillis();
        if (this.openImport && getSendMessagesHelper().getImportingHistory(this.dialog_id) != null) {
            ImportingAlert importingAlert = new ImportingAlert(getParentActivity(), (String) null, this, this.themeDelegate);
            importingAlert.setOnHideListener(new DialogInterface.OnDismissListener() {
                @Override
                public final void onDismiss(DialogInterface dialogInterface) {
                    ChatActivity.this.lambda$onResume$249(dialogInterface);
                }
            });
            showDialog(importingAlert);
            this.openImport = false;
        }
        checkAdjustResize();
        MediaController.getInstance().startRaiseToEarSensors(this);
        checkRaiseSensors();
        ChatAttachAlert chatAttachAlert = this.chatAttachAlert;
        if (chatAttachAlert != null) {
            chatAttachAlert.onResume();
        }
        ChatActivityFragmentView chatActivityFragmentView = this.contentView;
        if (chatActivityFragmentView != null) {
            chatActivityFragmentView.onResume();
        }
        checkChecksHint();
        Bulletin.Delegate delegate = new Bulletin.Delegate() {
            public boolean allowLayoutChanges() {
                return false;
            }

            public boolean bottomOffsetAnimated() {
                return Bulletin.Delegate.-CC.$default$bottomOffsetAnimated(this);
            }

            public boolean clipWithGradient(int i) {
                return Bulletin.Delegate.-CC.$default$clipWithGradient(this, i);
            }

            public int getBottomOffset(int i) {
                int i2 = 0;
                if (i == 1) {
                    return 0;
                }
                ChatActivityEnterView chatActivityEnterView2 = ChatActivity.this.chatActivityEnterView;
                if (chatActivityEnterView2 != null && chatActivityEnterView2.getVisibility() == 0) {
                    i2 = ((ChatActivity.this.contentView.getKeyboardHeight() >= AndroidUtilities.dp(20.0f) || !ChatActivity.this.chatActivityEnterView.isPopupShowing()) && !ChatActivity.this.chatActivityEnterView.panelAnimationInProgress()) ? ChatActivity.this.chatActivityEnterView.getHeight() : ChatActivity.this.chatActivityEnterView.getHeight() + ChatActivity.this.chatActivityEnterView.getEmojiPadding();
                } else if (!ChatActivity.this.isInsideContainer) {
                    i2 = AndroidUtilities.dp(51.0f);
                }
                if (ChatActivity.this.chatActivityEnterView.panelAnimationInProgress()) {
                    i2 = (int) (i2 + (ChatActivity.this.bottomPanelTranslationY - ChatActivity.this.chatActivityEnterView.getEmojiPadding()));
                }
                return ((int) (i2 + ChatActivity.this.contentPanTranslation)) - AndroidUtilities.dp(1.5f);
            }

            public int getTopOffset(int i) {
                return Math.max(AndroidUtilities.statusBarHeight + ActionBar.getCurrentActionBarHeight(), ((BaseFragment) ChatActivity.this).actionBar != null ? ((BaseFragment) ChatActivity.this).actionBar.getMeasuredHeight() + ((BaseFragment) ChatActivity.this).actionBar.getTop() : 0) + ((int) Math.max(0.0f, ChatActivity.this.paddingTopHeight));
            }

            public void onBottomOffsetChange(float f) {
                Bulletin.Delegate.-CC.$default$onBottomOffsetChange(this, f);
            }

            public void onHide(Bulletin bulletin) {
                Bulletin.Delegate.-CC.$default$onHide(this, bulletin);
            }

            public void onShow(Bulletin bulletin) {
                Bulletin.Delegate.-CC.$default$onShow(this, bulletin);
            }
        };
        this.bulletinDelegate = delegate;
        Bulletin.addDelegate(this, delegate);
        checkActionBarMenu(false);
        TLRPC.PhotoSize photoSize = this.replyImageLocation;
        if (photoSize != null && (backupImageView = this.replyImageView) != null) {
            backupImageView.setImage(ImageLocation.getForObject(photoSize, this.replyImageLocationObject), "50_50", ImageLocation.getForObject(this.replyImageThumbLocation, this.replyImageLocationObject), "50_50_b", (String) null, this.replyImageSize, this.replyImageCacheType, this.replyingMessageObject);
        }
        if (this.pinnedImageLocation != null && this.pinnedMessageImageView != null) {
            this.pinnedMessageImageView[0].setImage(ImageLocation.getForObject(this.pinnedImageLocation, this.pinnedImageLocationObject), "50_50", ImageLocation.getForObject(this.pinnedImageThumbLocation, this.pinnedImageLocationObject), "50_50_b", (String) null, this.pinnedImageSize, this.pinnedImageCacheType, (MessageObject) this.pinnedMessageObjects.get(Integer.valueOf(this.currentPinnedMessageId)));
            this.pinnedMessageImageView[0].setHasBlur(this.pinnedImageHasBlur);
        }
        if (this.chatMode == 0) {
            getNotificationsController().setOpenedDialogId(this.dialog_id, getTopicId());
        }
        getMessagesController().setLastVisibleDialogId(this.dialog_id, this.chatMode == 1, true);
        if (this.scrollToTopOnResume) {
            if (!this.scrollToTopUnReadOnResume || (messageObject = this.scrollToMessage) == null) {
                moveScrollToLastMessage(false);
            } else if (this.chatListView != null) {
                int i = this.scrollToMessagePosition;
                if (i == -9000) {
                    i = getScrollOffsetForMessage(messageObject);
                } else if (i == -10000) {
                    i = -AndroidUtilities.dp(11.0f);
                } else {
                    z = true;
                    this.chatLayoutManager.scrollToPositionWithOffset(this.chatAdapter.messagesStartRow + this.messages.indexOf(this.scrollToMessage), i, z);
                }
                z = false;
                this.chatLayoutManager.scrollToPositionWithOffset(this.chatAdapter.messagesStartRow + this.messages.indexOf(this.scrollToMessage), i, z);
            }
            this.scrollToTopUnReadOnResume = false;
            this.scrollToTopOnResume = false;
            this.scrollToMessage = null;
        }
        this.paused = false;
        this.pausedOnLastMessage = false;
        checkScrollForLoad(false);
        if (this.wasPaused) {
            this.wasPaused = false;
            ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
            if (chatActivityAdapter != null) {
                chatActivityAdapter.notifyDataSetChanged(false);
            }
        }
        fixLayout();
        applyDraftMaybe(false);
        applyChatLinkMessageMaybe();
        BlurredFrameLayout blurredFrameLayout = this.bottomOverlayChat;
        if (blurredFrameLayout != null && blurredFrameLayout.getVisibility() != 0 && !((BaseFragment) this).actionBar.isSearchFieldVisible() && this.chatMode != 7 && !BaseFragment.hasSheets(this)) {
            this.chatActivityEnterView.setFieldFocused(true);
        }
        ChatActivityEnterView chatActivityEnterView2 = this.chatActivityEnterView;
        if (chatActivityEnterView2 != null) {
            chatActivityEnterView2.onResume();
        }
        if (this.currentUser != null) {
            this.chatEnterTime = System.currentTimeMillis();
            this.chatLeaveTime = 0L;
        }
        if (this.startVideoEdit != null) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$onResume$250();
                }
            });
        }
        if (this.chatListView != null && ((chatActivityEnterView = this.chatActivityEnterView) == null || !chatActivityEnterView.isEditingMessage())) {
            this.chatListView.setOnItemLongClickListener(this.onItemLongClickListener);
            this.chatListView.setOnItemClickListener(this.onItemClickListener);
            this.chatListView.setLongClickable(true);
        }
        checkBotCommands();
        updateTitle(false);
        showGigagroupConvertAlert();
        if (this.pullingDownOffset != 0.0f) {
            this.pullingDownOffset = 0.0f;
            this.chatListView.invalidate();
        }
        this.flagSecure.attach();
        StarReactionsOverlay starReactionsOverlay = this.starReactionsOverlay;
        if (starReactionsOverlay != null) {
            starReactionsOverlay.bringToFront();
        }
    }

    protected void onSearchLoadingUpdate(boolean z) {
    }

    public void onTransitionAnimationEnd(boolean z, boolean z2) {
        String string;
        int i;
        SharedPreferences.Editor putBoolean;
        MessageObject messageObject;
        INavigationLayout iNavigationLayout;
        Bulletin bulletin;
        super.onTransitionAnimationEnd(z, z2);
        if (z && z2 && this.showPinBulletin && (bulletin = this.pinBulletin) != null) {
            bulletin.show();
            this.showPinBulletin = false;
        }
        Runnable runnable = this.cancelFixedPositionRunnable;
        if (runnable != null) {
            AndroidUtilities.cancelRunOnUIThread(runnable);
        }
        this.fixedKeyboardHeight = -1;
        if (z) {
            checkShowBlur(false);
            this.openAnimationEnded = true;
            getNotificationCenter().onAnimationFinish(this.transitionAnimationIndex);
            NotificationCenter.getGlobalInstance().onAnimationFinish(this.transitionAnimationGlobalIndex);
            checkGroupCallJoin(this.lastCallCheckFromServer);
            if (!((!ChatObject.isMonoForum(this.currentChat) || ChatObject.canManageMonoForum(((BaseFragment) this).currentAccount, this.currentChat)) ? false : this.chatActivityEnterView.showSendSuggestionHint()) && this.chatActivityEnterView.hasRecordVideo() && !this.chatActivityEnterView.isSendButtonVisible()) {
                TLRPC.Chat chat = this.currentChat;
                boolean z3 = (chat == null || !ChatObject.isChannel(chat) || this.currentChat.megagroup) ? false : true;
                SharedPreferences globalMainSettings = MessagesController.getGlobalMainSettings();
                String str = z3 ? "needShowRoundHintChannel2" : "needShowRoundHint2";
                int i2 = globalMainSettings.getInt(str, 0);
                if (i2 < 3 && Utilities.random.nextFloat() <= 0.2f) {
                    showVoiceHint(false, this.chatActivityEnterView.isInVideoMode());
                    globalMainSettings.edit().putInt(str, i2 + 1).commit();
                }
            }
            if (!z2 && (iNavigationLayout = ((BaseFragment) this).parentLayout) != null && this.needRemovePreviousSameChatActivity) {
                int size = iNavigationLayout.getFragmentStack().size() - 1;
                int i3 = 0;
                while (true) {
                    if (i3 >= size) {
                        break;
                    }
                    BaseFragment baseFragment = (BaseFragment) ((BaseFragment) this).parentLayout.getFragmentStack().get(i3);
                    if (baseFragment != this && (baseFragment instanceof ChatActivity)) {
                        ChatActivity chatActivity = (ChatActivity) baseFragment;
                        if (chatActivity.needRemovePreviousSameChatActivity && chatActivity.dialog_id == this.dialog_id && chatActivity.getTopicId() == getTopicId() && chatActivity.getChatMode() == getChatMode() && chatActivity.threadMessageId == this.threadMessageId && chatActivity.isReport() == isReport()) {
                            baseFragment.removeSelfFromStack();
                            break;
                        }
                    }
                    i3++;
                }
            }
            showScheduledOrNoSoundHint();
            if (!z2 && this.firstOpen) {
                if (this.chatActivityEnterView != null && (((messageObject = this.threadMessageObject) != null && messageObject.getRepliesCount() == 0 && ChatObject.canSendMessages(this.currentChat) && !this.isTopic) || this.chatMode == 6)) {
                    this.chatActivityEnterView.setFieldFocused();
                    this.chatActivityEnterView.openKeyboard();
                }
                if (getMessagesController().isPromoDialog(this.dialog_id, true)) {
                    int i4 = getMessagesController().promoDialogType;
                    SharedPreferences globalNotificationsSettings = MessagesController.getGlobalNotificationsSettings();
                    if (i4 == MessagesController.PROMO_TYPE_PROXY) {
                        if (AndroidUtilities.getPrefIntOrLong(globalNotificationsSettings, "proxychannel", 0L) != this.dialog_id) {
                            i = R.string.UseProxySponsorInfo;
                            string = LocaleController.getString(i);
                        }
                        string = null;
                    } else {
                        if (i4 == MessagesController.PROMO_TYPE_PSA) {
                            String str2 = getMessagesController().promoPsaType;
                            if (!globalNotificationsSettings.getBoolean(str2 + "_shown", false)) {
                                string = LocaleController.getString("PsaInfo_" + str2);
                                if (TextUtils.isEmpty(string)) {
                                    i = R.string.PsaInfoDefault;
                                    string = LocaleController.getString(i);
                                }
                            }
                        }
                        string = null;
                    }
                    if (!TextUtils.isEmpty(string)) {
                        checkTopUndoView();
                        if (this.topUndoView != null) {
                            if (i4 == MessagesController.PROMO_TYPE_PROXY) {
                                putBoolean = globalNotificationsSettings.edit().putLong("proxychannel", this.dialog_id);
                            } else {
                                if (i4 == MessagesController.PROMO_TYPE_PSA) {
                                    String str3 = getMessagesController().promoPsaType;
                                    putBoolean = globalNotificationsSettings.edit().putBoolean(str3 + "_shown", true);
                                }
                                SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(string);
                                MessageObject.addLinks(false, spannableStringBuilder);
                                this.topUndoView.showWithAction(0L, 18, spannableStringBuilder, (Runnable) null, (Runnable) null);
                            }
                            putBoolean.commit();
                            SpannableStringBuilder spannableStringBuilder2 = new SpannableStringBuilder(string);
                            MessageObject.addLinks(false, spannableStringBuilder2);
                            this.topUndoView.showWithAction(0L, 18, spannableStringBuilder2, (Runnable) null, (Runnable) null);
                        }
                    }
                }
                this.firstOpen = false;
            }
            ChatActivityMemberRequestsDelegate chatActivityMemberRequestsDelegate = this.pendingRequestsDelegate;
            if (chatActivityMemberRequestsDelegate != null && z2) {
                chatActivityMemberRequestsDelegate.onBackToScreen();
            }
            updateMessagesVisiblePart(false);
        } else {
            getNotificationCenter().onAnimationFinish(this.transitionAnimationIndex);
            NotificationCenter.getGlobalInstance().onAnimationFinish(this.transitionAnimationGlobalIndex);
        }
        this.contentView.invalidate();
        if (!TextUtils.isEmpty(this.attachMenuBotToOpen)) {
            openAttachBotLayout(this.attachMenuBotToOpen);
            this.attachMenuBotToOpen = null;
        }
        checkGroupEmojiPackHint();
    }

    public void onTransitionAnimationStart(boolean z, boolean z2) {
        int[] iArr;
        super.onTransitionAnimationStart(z, z2);
        this.startMs = System.currentTimeMillis();
        if (z) {
            if (!this.fragmentOpened) {
                this.fragmentOpened = true;
                updateMessagesVisiblePart(false);
            }
            iArr = this.transitionAnimationIndex == 0 ? new int[]{NotificationCenter.dialogsNeedReload, NotificationCenter.closeChats, NotificationCenter.botKeyboardDidLoad, NotificationCenter.needDeleteDialog, NotificationCenter.messagesDidLoad} : new int[]{NotificationCenter.dialogsNeedReload, NotificationCenter.closeChats, NotificationCenter.botKeyboardDidLoad, NotificationCenter.needDeleteDialog};
            this.openAnimationEnded = false;
            if (!z2) {
                this.openAnimationStartTime = SystemClock.elapsedRealtime();
            }
        } else {
            iArr = UserObject.isUserSelf(this.currentUser) ? new int[]{NotificationCenter.dialogsNeedReload, NotificationCenter.closeChats, NotificationCenter.botKeyboardDidLoad, NotificationCenter.needDeleteDialog, NotificationCenter.mediaDidLoad} : null;
            ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
            if (chatActivityEnterView != null) {
                chatActivityEnterView.onBeginHide();
            }
        }
        checkShowBlur(true);
        this.transitionAnimationIndex = getNotificationCenter().setAnimationInProgress(this.transitionAnimationIndex, iArr);
    }

    public void openAttachBotLayout(long j, String str, boolean z) {
        openAttachMenu();
        createChatAttachView();
        ChatAttachAlert chatAttachAlert = this.chatAttachAlert;
        if (chatAttachAlert != null) {
            chatAttachAlert.showBotLayout(j, str, z, false);
        }
    }

    public void openAttachBotLayout(String str) {
        TLRPC.TL_contacts_resolveUsername tL_contacts_resolveUsername = new TLRPC.TL_contacts_resolveUsername();
        tL_contacts_resolveUsername.username = str;
        getConnectionsManager().sendRequest(tL_contacts_resolveUsername, new RequestDelegate() {
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                ChatActivity.this.lambda$openAttachBotLayout$215(tLObject, tL_error);
            }
        });
    }

    public void openAttachMenuForCreatingSticker() {
        ContentPreviewViewer.getInstance().setStickerSetForCustomSticker(null);
        if (getParentActivity() == null) {
            return;
        }
        createChatAttachView();
        this.chatAttachAlert.getPhotoLayout().loadGalleryPhotos();
        int i = Build.VERSION.SDK_INT;
        if (i == 21 || i == 22) {
            this.chatActivityEnterView.closeKeyboard();
        }
        this.chatAttachAlert.setMaxSelectedPhotos(1, false);
        this.chatAttachAlert.setOpenWithFrontFaceCamera(true);
        this.chatAttachAlert.enableStickerMode((Utilities.Callback2) null);
        this.chatAttachAlert.init();
        ChatAttachAlert chatAttachAlert = this.chatAttachAlert;
        chatAttachAlert.parentThemeDelegate = this.themeDelegate;
        if (((BaseFragment) this).visibleDialog != null) {
            chatAttachAlert.show();
        } else {
            showDialog(chatAttachAlert);
        }
    }

    public void lambda$openHashtagSearch$358(String str) {
        openHashtagSearch(str, false);
    }

    public void openHashtagSearch(final String str, boolean z) {
        boolean z2;
        ChatSearchTabs chatSearchTabs;
        ActionBarMenuItem actionBarMenuItem;
        int i;
        if (str.isEmpty()) {
            return;
        }
        if (str.startsWith("#") || str.startsWith("$")) {
            HintView2 hintView2 = this.savedMessagesHint;
            if (hintView2 == null || !hintView2.shown()) {
                z2 = false;
            } else {
                this.savedMessagesHint.hide();
                z2 = true;
            }
            HintView2 hintView22 = this.savedMessagesSearchHint;
            if (hintView22 != null && hintView22.shown()) {
                this.savedMessagesSearchHint.hide();
                z2 = true;
            }
            if (z2) {
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.this.lambda$openHashtagSearch$358(str);
                    }
                }, 200L);
                return;
            }
            this.searchingHashtag = str;
            this.searchingQuery = str;
            boolean contains = str.contains("@");
            checkHashtagStories(true);
            if (!((BaseFragment) this).actionBar.isSearchFieldVisible()) {
                AndroidUtilities.updateViewVisibilityAnimated(this.avatarContainer, false, 0.95f, true);
                ActionBarMenuItem actionBarMenuItem2 = this.headerItem;
                if (actionBarMenuItem2 != null) {
                    actionBarMenuItem2.setVisibility(8);
                }
                ActionBarMenu.LazyItem lazyItem = this.attachItem;
                if (lazyItem != null) {
                    lazyItem.setVisibility(8);
                }
                ActionBarMenu.LazyItem lazyItem2 = this.editTextItem;
                if (lazyItem2 != null) {
                    lazyItem2.setVisibility(8);
                }
                if ((this.threadMessageId == 0 || (i = this.chatMode) == 3 || i == 8) && (actionBarMenuItem = this.searchItem) != null) {
                    actionBarMenuItem.setVisibility(0);
                }
                ActionBarMenuItem actionBarMenuItem3 = this.searchIconItem;
                if (actionBarMenuItem3 != null && this.showSearchAsIcon) {
                    actionBarMenuItem3.setVisibility(8);
                }
                ActionBarMenu.LazyItem lazyItem3 = this.audioCallIconItem;
                if (lazyItem3 != null && this.showAudioCallAsIcon) {
                    lazyItem3.setVisibility(8);
                }
                this.searchItemVisible = true;
                updateSearchButtons(0, 0, -1);
                updateBottomOverlay();
            }
            SearchTagsList searchTagsList = this.actionBarSearchTags;
            if (searchTagsList != null && searchTagsList.shown()) {
                this.actionBarSearchTags.show(false);
            }
            ImageView imageView = this.searchUserButton;
            if (imageView != null) {
                imageView.setVisibility(8);
            }
            if (contains || z || (ChatObject.isChannelAndNotMegaGroup(this.currentChat) && ChatObject.isPublic(this.currentChat) && this.searchingHashtag != null)) {
                this.defaultSearchPage = 2;
            } else {
                this.defaultSearchPage = 0;
            }
            this.openSearchKeyboard = false;
            if (this.searchType == 3) {
                HashtagSearchController.getInstance(((BaseFragment) this).currentAccount).clearSearchResults(3);
            } else {
                HashtagSearchController.getInstance(((BaseFragment) this).currentAccount).clearSearchResults();
            }
            ViewPagerFixed viewPagerFixed = this.searchViewPager;
            if (viewPagerFixed != null) {
                viewPagerFixed.clearViews();
            }
            ActionBarMenuItem actionBarMenuItem4 = this.searchItem;
            if (actionBarMenuItem4 != null) {
                this.preventReopenSearchWithText = true;
                actionBarMenuItem4.openSearch(false);
                this.preventReopenSearchWithText = false;
            }
            ActionBarMenuItem actionBarMenuItem5 = this.searchItem;
            if (actionBarMenuItem5 != null) {
                actionBarMenuItem5.setSearchFieldCaption(null);
                this.searchItem.setSearchFieldText(str, false);
                this.searchItem.setSearchFieldHint(LocaleController.getString(R.string.SearchHashtagsHint));
            }
            getMediaDataController().searchMessagesInChat(this.searchingQuery, this.dialog_id, this.mergeDialogId, ((BaseFragment) this).classGuid, 0, this.threadMessageId, false, this.searchingUserMessages, this.searchingChatMessages, false, this.searchingReaction);
            updatePinnedMessageView(true);
            this.hashtagSearchEmptyView.showProgress(true);
            showMessagesSearchListView(true);
            ChatSearchTabs chatSearchTabs2 = this.hashtagSearchTabs;
            if (chatSearchTabs2 != null) {
                chatSearchTabs2.show(!contains);
                this.messagesSearchListContainer.setPadding(0, 0, 0, getHashtagTabsHeight());
                updateSearchListEmptyView();
            }
            if ((contains || z) && this.searchingHashtag != null && (chatSearchTabs = this.hashtagSearchTabs) != null) {
                int currentPosition = chatSearchTabs.tabs.getCurrentPosition();
                int i2 = this.defaultSearchPage;
                if (currentPosition != i2) {
                    this.hashtagSearchTabs.tabs.scrollToTab(i2, i2);
                }
            }
            HashtagSearchController.getInstance(((BaseFragment) this).currentAccount).putToHistory(this.searchingHashtag);
            this.hashtagHistoryView.update();
            View currentView = this.searchViewPager.getCurrentView();
            if (currentView instanceof ChatActivityContainer) {
                ((ChatActivityContainer) currentView).chatActivity.updateSearchingHashtag(this.searchingHashtag);
            }
        }
    }

    void openPhotoViewerForMessage(ChatMessageCell chatMessageCell, MessageObject messageObject) {
        ChatMessageCell chatMessageCell2;
        AnimatedFileDrawable animation;
        Bitmap animatedBitmap;
        if (chatMessageCell == null) {
            int childCount = this.chatListView.getChildCount();
            for (int i = 0; i < childCount; i++) {
                View childAt = this.chatListView.getChildAt(i);
                if (childAt instanceof ChatMessageCell) {
                    chatMessageCell2 = (ChatMessageCell) childAt;
                    if (chatMessageCell2.getMessageObject().equals(messageObject)) {
                        break;
                    }
                }
            }
        }
        chatMessageCell2 = chatMessageCell;
        if (messageObject.isVideo()) {
            sendSecretMessageRead(messageObject, true);
        }
        PhotoViewer.getInstance().setParentActivity(this, this.themeDelegate);
        MessageObject playingMessageObject = MediaController.getInstance().getPlayingMessageObject();
        if (chatMessageCell2 != null && playingMessageObject != null && playingMessageObject.isVideo()) {
            getFileLoader().setLoadingVideoForPlayer(playingMessageObject.getDocument(), false);
            if (playingMessageObject.equals(messageObject) && (animation = chatMessageCell2.getPhotoImage().getAnimation()) != null && this.videoTextureView != null && this.videoPlayerContainer.getTag() != null && (animatedBitmap = animation.getAnimatedBitmap()) != null) {
                try {
                    Bitmap bitmap = this.videoTextureView.getBitmap(animatedBitmap.getWidth(), animatedBitmap.getHeight());
                    new Canvas(animatedBitmap).drawBitmap(bitmap, 0.0f, 0.0f, (Paint) null);
                    bitmap.recycle();
                } catch (Throwable th) {
                    FileLog.e(th);
                }
            }
            MediaController.getInstance().cleanupPlayer(true, true, false, playingMessageObject.equals(messageObject));
        }
        if (this.chatMode == 1 && (messageObject.isVideo() || messageObject.type == 1)) {
            PhotoViewer.getInstance().setParentChatActivity(this);
            ArrayList arrayList = new ArrayList();
            int size = this.messages.size();
            for (int i2 = 0; i2 < size; i2++) {
                MessageObject messageObject2 = (MessageObject) this.messages.get(i2);
                if (messageObject2.isVideo() || messageObject2.type == 1) {
                    arrayList.add(0, messageObject2);
                }
            }
            PhotoViewer.getInstance().openPhoto(arrayList, arrayList.indexOf(messageObject), this.dialog_id, 0L, getTopicId(), this.photoViewerProvider);
        } else {
            PhotoViewer photoViewer = PhotoViewer.getInstance();
            int i3 = messageObject.type;
            photoViewer.openPhoto(messageObject, this, i3 != 0 ? this.dialog_id : 0L, i3 != 0 ? this.mergeDialogId : 0L, i3 != 0 ? getTopicId() : 0L, this.photoViewerProvider);
        }
        hideHints(false);
        MediaController.getInstance().resetGoingToShowMessageObject();
    }

    public boolean openPhotosEditor(ArrayList arrayList, CharSequence charSequence) {
        String str;
        final ArrayList arrayList2 = new ArrayList();
        int i = 0;
        while (true) {
            String str2 = null;
            if (i >= arrayList.size()) {
                break;
            }
            SendMessagesHelper.SendingMediaInfo sendingMediaInfo = (SendMessagesHelper.SendingMediaInfo) arrayList.get(i);
            String str3 = sendingMediaInfo.path;
            if (str3 != null) {
                str = str3;
            } else {
                if (sendingMediaInfo.uri != null) {
                    try {
                        File generatePicturePath = AndroidUtilities.generatePicturePath(isSecretChat(), "");
                        InputStream openInputStream = ApplicationLoader.applicationContext.getContentResolver().openInputStream(sendingMediaInfo.uri);
                        FileOutputStream fileOutputStream = new FileOutputStream(generatePicturePath);
                        byte[] bArr = new byte[8192];
                        while (true) {
                            int read = openInputStream.read(bArr);
                            if (read <= 0) {
                                break;
                            }
                            fileOutputStream.write(bArr, 0, read);
                            fileOutputStream.flush();
                        }
                        openInputStream.close();
                        fileOutputStream.close();
                        str2 = generatePicturePath.getAbsolutePath();
                    } catch (Exception e) {
                        FileLog.e(e);
                    }
                }
                str = str2;
            }
            if (str != null) {
                Pair imageOrientation = AndroidUtilities.getImageOrientation(str);
                MediaController.PhotoEntry orientation = new MediaController.PhotoEntry(0, 0, 0L, str, ((Integer) imageOrientation.first).intValue(), sendingMediaInfo.isVideo, 0, 0, 0L).setOrientation(imageOrientation);
                if (i == arrayList.size() - 1 && charSequence != null) {
                    ((MediaController.MediaEditState) orientation).caption = charSequence;
                }
                arrayList2.add(orientation);
            }
            i++;
        }
        if (arrayList2.isEmpty()) {
            return false;
        }
        if (getParentActivity() != null) {
            final boolean[] zArr = new boolean[arrayList2.size()];
            Arrays.fill(zArr, true);
            PhotoViewer.getInstance().setParentActivity(this, this.themeDelegate);
            PhotoViewer.getInstance().openPhotoForSelect(new ArrayList(arrayList2), arrayList2.size() - 1, 0, false, new PhotoViewer.EmptyPhotoViewerProvider() {
                @Override
                public boolean canScrollAway() {
                    return false;
                }

                @Override
                public ImageReceiver.BitmapHolder getThumbForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int i2) {
                    return null;
                }

                @Override
                public boolean isPhotoChecked(int i2) {
                    return zArr[i2];
                }

                @Override
                public void sendButtonPressed(int i2, VideoEditedInfo videoEditedInfo, boolean z, int i3, boolean z2) {
                    for (int size = arrayList2.size() - 1; size >= 0; size--) {
                        if (!zArr[size]) {
                            arrayList2.remove(size);
                        }
                    }
                    ChatActivity.this.sendPhotosGroup(arrayList2, z, i3, z2);
                }

                @Override
                public int setPhotoChecked(int i2, VideoEditedInfo videoEditedInfo) {
                    return i2;
                }
            }, this);
        } else {
            fillEditingMediaWithCaption(charSequence, null);
            sendPhotosGroup(arrayList2, false, 0, false);
            afterMessageSend();
        }
        return true;
    }

    public void openPollCreate(Boolean bool) {
        PollCreateActivity pollCreateActivity = new PollCreateActivity(this, false, bool);
        pollCreateActivity.setDelegate(new PollCreateActivity.PollCreateActivityDelegate() {
            @Override
            public final void sendPoll(TLRPC.MessageMedia messageMedia, HashMap hashMap, boolean z, int i) {
                ChatActivity.this.lambda$openPollCreate$125(messageMedia, hashMap, z, i);
            }
        });
        presentFragment(pollCreateActivity);
    }

    public void lambda$openSearchWithText$357(final String str) {
        boolean z;
        int i;
        ActionBarMenuItem actionBarMenuItem;
        int i2;
        HintView2 hintView2 = this.savedMessagesHint;
        if (hintView2 == null || !hintView2.shown()) {
            z = false;
        } else {
            this.savedMessagesHint.hide();
            z = true;
        }
        HintView2 hintView22 = this.savedMessagesSearchHint;
        if (hintView22 != null && hintView22.shown()) {
            this.savedMessagesSearchHint.hide();
            z = true;
        }
        if (z) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$openSearchWithText$357(str);
                }
            }, 200L);
            return;
        }
        if (!((BaseFragment) this).actionBar.isSearchFieldVisible()) {
            AndroidUtilities.updateViewVisibilityAnimated(this.avatarContainer, false, 0.95f, true);
            ActionBarMenuItem actionBarMenuItem2 = this.headerItem;
            if (actionBarMenuItem2 != null) {
                actionBarMenuItem2.setVisibility(8);
            }
            ActionBarMenu.LazyItem lazyItem = this.attachItem;
            if (lazyItem != null) {
                lazyItem.setVisibility(8);
            }
            ActionBarMenu.LazyItem lazyItem2 = this.editTextItem;
            if (lazyItem2 != null) {
                lazyItem2.setVisibility(8);
            }
            if ((this.threadMessageId == 0 || (i2 = this.chatMode) == 3 || i2 == 8) && (actionBarMenuItem = this.searchItem) != null) {
                actionBarMenuItem.setVisibility(0);
            }
            ActionBarMenuItem actionBarMenuItem3 = this.searchIconItem;
            if (actionBarMenuItem3 != null && this.showSearchAsIcon) {
                actionBarMenuItem3.setVisibility(8);
            }
            ActionBarMenu.LazyItem lazyItem3 = this.audioCallIconItem;
            if (lazyItem3 != null && this.showAudioCallAsIcon) {
                lazyItem3.setVisibility(8);
            }
            this.searchItemVisible = true;
            updateSearchButtons(0, 0, -1);
            updateBottomOverlay();
        }
        if ((this.threadMessageId == 0 || this.isTopic || (i = this.chatMode) == 3 || i == 8) && !UserObject.isReplyUser(this.currentUser)) {
            boolean z2 = str == null;
            this.openSearchKeyboard = z2;
            ActionBarMenuItem actionBarMenuItem4 = this.searchItem;
            if (actionBarMenuItem4 != null) {
                actionBarMenuItem4.openSearch(z2);
            }
        }
        ActionBarMenuItem actionBarMenuItem5 = this.searchItem;
        if (actionBarMenuItem5 != null) {
            actionBarMenuItem5.setSearchFieldText(str, false);
        }
        MediaDataController mediaDataController = getMediaDataController();
        String str2 = str == null ? "" : str;
        this.searchingQuery = str2;
        mediaDataController.searchMessagesInChat(str2, this.dialog_id, this.mergeDialogId, ((BaseFragment) this).classGuid, 0, this.threadMessageId, false, this.searchingUserMessages, this.searchingChatMessages, !TextUtils.isEmpty(str), this.searchingReaction);
        updatePinnedMessageView(true);
    }

    public void openThisProfile() {
        ChatAvatarContainer chatAvatarContainer = this.avatarContainer;
        if (chatAvatarContainer == null) {
            return;
        }
        chatAvatarContainer.openProfile(true);
    }

    public void openVCard(TLRPC.User user, String str, String str2, String str3, String str4) {
        File file;
        if (user != null) {
            Bundle bundle = new Bundle();
            bundle.putLong("user_id", user.id);
            bundle.putBoolean("show_add_to_contacts", true);
            bundle.putString("vcard", str2);
            bundle.putString("vcard_phone", str);
            bundle.putString("vcard_first_name", str3);
            bundle.putString("vcard_last_name", str4);
            presentFragment(new ProfileActivity(bundle));
            return;
        }
        try {
            if (TextUtils.isEmpty(str2)) {
                file = null;
            } else {
                File sharingDirectory = AndroidUtilities.getSharingDirectory();
                sharingDirectory.mkdirs();
                File file2 = new File(sharingDirectory, "vcard.vcf");
                BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(file2));
                bufferedWriter.write(str2);
                bufferedWriter.close();
                file = file2;
            }
            showDialog(new PhonebookShareAlert(this, (ContactsController.Contact) null, user, (Uri) null, file, PhoneFormat.stripExceptNumbers(str), str3, str4, this.themeDelegate));
        } catch (Exception e) {
            FileLog.e(e);
        }
    }

    public void openVideoEditor(String str, String str2) {
        if (getParentActivity() == null) {
            fillEditingMediaWithCaption(str2, null);
            SendMessagesHelper.prepareSendingVideo(getAccountInstance(), str, (VideoEditedInfo) null, (String) null, (TLRPC.Photo) null, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TL_stories.StoryItem) null, this.replyingQuote, (ArrayList) null, 0, this.editingMessageObject, true, 0, false, false, (CharSequence) null, this.quickReplyShortcut, getQuickReplyId(), 0L, 0L, getSendMonoForumPeerId(), getSendMessageSuggestionParams());
            afterMessageSend();
            return;
        }
        final Bitmap createVideoThumbnail = SendMessagesHelper.createVideoThumbnail(str, 1);
        PhotoViewer.getInstance().setParentActivity(this, this.themeDelegate);
        final ArrayList arrayList = new ArrayList();
        MediaController.PhotoEntry photoEntry = new MediaController.PhotoEntry(0, 0, 0L, str, 0, true, 0, 0, 0L);
        ((MediaController.MediaEditState) photoEntry).caption = str2;
        arrayList.add(photoEntry);
        if (PhotoViewer.getInstance().isVisible()) {
            PhotoViewer.getInstance().closePhoto(false, false);
        }
        PhotoViewer.getInstance().openPhotoForSelect(arrayList, 0, 0, false, new PhotoViewer.EmptyPhotoViewerProvider() {
            @Override
            public boolean canCaptureMorePhotos() {
                return false;
            }

            @Override
            public boolean canScrollAway() {
                return false;
            }

            @Override
            public ImageReceiver.BitmapHolder getThumbForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int i) {
                return new ImageReceiver.BitmapHolder(createVideoThumbnail, (String) null, 0);
            }

            @Override
            public void sendButtonPressed(int i, VideoEditedInfo videoEditedInfo, boolean z, int i2, boolean z2) {
                ChatActivity.this.sendMedia((MediaController.PhotoEntry) arrayList.get(0), videoEditedInfo, z, i2, z2, 0L);
            }
        }, this);
    }

    public void openedInstantly() {
        this.fragmentOpened = true;
        ((BaseFragment) this).fragmentBeginToShow = true;
        this.fragmentTransition = null;
        this.contentView.invalidate();
        this.contentView.setSkipBackgroundDrawing(false);
        this.toPullingDownTransition = false;
        ((BaseFragment) this).fragmentView.setAlpha(1.0f);
        this.avatarContainer.setTranslationY(0.0f);
        this.avatarContainer.getAvatarImageView().setScaleX(1.0f);
        this.avatarContainer.getAvatarImageView().setScaleY(1.0f);
        this.avatarContainer.getAvatarImageView().setAlpha(1.0f);
    }

    public boolean openedWithLivestream() {
        return this.livestream;
    }

    public void performHistoryClear(final long j, final boolean z, boolean z2) {
        setClearingHistory(j, true);
        createUndoView();
        UndoView undoView = this.undoView;
        if (undoView == null) {
            return;
        }
        undoView.showWithAction(this.dialog_id, 0, new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$performHistoryClear$118(j, z);
            }
        }, new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$performHistoryClear$119(j);
            }
        });
        this.chatAdapter.notifyDataSetChanged();
    }

    public void performHistoryClear(boolean z, boolean z2) {
        performHistoryClear(getThreadId(), z, z2);
    }

    public boolean playFirstUnreadVoiceMessage() {
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView != null && chatActivityEnterView.isRecordingAudioVideo()) {
            return true;
        }
        for (int size = this.messages.size() - 1; size >= 0; size--) {
            MessageObject messageObject = (MessageObject) this.messages.get(size);
            if ((messageObject.isVoice() || messageObject.isRoundVideo()) && messageObject.isContentUnread() && !messageObject.isOut()) {
                MediaController.getInstance().setVoiceMessagesPlaylist(MediaController.getInstance().playMessage(messageObject) ? createVoiceMessagesPlaylist(messageObject, true) : null, true);
                return true;
            }
        }
        if (Build.VERSION.SDK_INT < 23 || getParentActivity() == null || FilesMigrationService$FilesMigrationBottomSheet$.ExternalSyntheticApiModelOutline0.m(getParentActivity(), "android.permission.RECORD_AUDIO") == 0) {
            return false;
        }
        FilesMigrationService$FilesMigrationBottomSheet$.ExternalSyntheticApiModelOutline1.m(getParentActivity(), new String[]{"android.permission.RECORD_AUDIO"}, 3);
        return true;
    }

    public void processInlineBotContextPM(TLRPC.TL_inlineBotSwitchPM tL_inlineBotSwitchPM) {
        MentionsContainerView mentionsContainerView;
        TLRPC.User contextBotUser;
        if (tL_inlineBotSwitchPM == null || (mentionsContainerView = this.mentionContainer) == null || (contextBotUser = mentionsContainerView.getAdapter().getContextBotUser()) == null) {
            return;
        }
        this.chatActivityEnterView.setFieldText("");
        long j = this.dialog_id;
        if (j == contextBotUser.id) {
            this.inlineReturn = j;
            getMessagesController().sendBotStart(this.currentUser, tL_inlineBotSwitchPM.start_param);
            return;
        }
        Bundle bundle = new Bundle();
        bundle.putLong("user_id", contextBotUser.id);
        bundle.putString("inline_query", tL_inlineBotSwitchPM.start_param);
        bundle.putLong("inline_return", this.dialog_id);
        if (getMessagesController().checkCanOpenChat(bundle, this)) {
            presentFragment(new ChatActivity(bundle));
        }
    }

    public void processInlineBotWebView(final TLRPC.TL_inlineBotWebView tL_inlineBotWebView) {
        final Runnable runnable = new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$processInlineBotWebView$115(tL_inlineBotWebView);
            }
        };
        if (this.approved) {
            runnable.run();
        } else {
            WebAppDisclaimerAlert.show(getContext(), new Consumer() {
                public final void accept(Object obj) {
                    ChatActivity.this.lambda$processInlineBotWebView$116(runnable, (Boolean) obj);
                }
            }, null, null);
        }
    }

    public boolean processSwitchButton(TLRPC.TL_keyboardButtonSwitchInline tL_keyboardButtonSwitchInline) {
        long j;
        String str;
        if (this.inlineReturn == 0 || ((TLRPC.KeyboardButton) tL_keyboardButtonSwitchInline).same_peer || ((BaseFragment) this).parentLayout == null) {
            return false;
        }
        String str2 = "@" + this.currentUser.username + " " + ((TLRPC.KeyboardButton) tL_keyboardButtonSwitchInline).query;
        if (this.inlineReturn == this.dialog_id) {
            this.inlineReturn = 0L;
            this.chatActivityEnterView.setFieldText(str2);
        } else {
            getMediaDataController().saveDraft(this.inlineReturn, 0, str2, (ArrayList) null, (TLRPC.Message) null, false, 0L);
            if (((BaseFragment) this).parentLayout.getFragmentStack().size() > 1) {
                BaseFragment baseFragment = (BaseFragment) ((BaseFragment) this).parentLayout.getFragmentStack().get(((BaseFragment) this).parentLayout.getFragmentStack().size() - 2);
                if ((baseFragment instanceof ChatActivity) && ((ChatActivity) baseFragment).dialog_id == this.inlineReturn) {
                    lambda$onBackPressed$354();
                } else {
                    Bundle bundle = new Bundle();
                    if (DialogObject.isEncryptedDialog(this.inlineReturn)) {
                        bundle.putInt("enc_id", DialogObject.getEncryptedChatId(this.inlineReturn));
                    } else {
                        if (DialogObject.isUserDialog(this.inlineReturn)) {
                            j = this.inlineReturn;
                            str = "user_id";
                        } else {
                            j = -this.inlineReturn;
                            str = "chat_id";
                        }
                        bundle.putLong(str, j);
                    }
                    addToPulledDialogsMyself();
                    presentFragment(new ChatActivity(bundle), true);
                }
            }
        }
        return true;
    }

    public void reloadPinnedMessages() {
        this.pinnedMessageIds.clear();
        this.pinnedMessageObjects.clear();
        this.currentPinnedMessageId = 0;
        this.loadedPinnedMessagesCount = 0;
        this.totalPinnedMessagesCount = 0;
        updatePinnedMessageView(true);
        MediaDataController mediaDataController = getMediaDataController();
        long dialogId = getDialogId();
        TLRPC.ChatFull chatFull = this.chatInfo;
        mediaDataController.loadPinnedMessages(dialogId, 0, chatFull == null ? 0 : chatFull.pinned_msg_id);
        this.loadingPinnedMessagesList = true;
        updatePinnedTopicStarterMessage();
    }

    public void removeFromSponsored(MessageObject messageObject) {
        if (messageObject == this.botSponsoredMessage) {
            this.botSponsoredMessage = null;
            updateTopPanel(true);
        } else {
            MessagesController.SponsoredMessagesInfo sponsoredMessages = getMessagesController().getSponsoredMessages(this.dialog_id);
            if (sponsoredMessages != null) {
                sponsoredMessages.messages.remove(messageObject);
            }
        }
    }

    public void removeKeyboardPositionBeforeTransition() {
        if (this.fixedKeyboardHeight > 0) {
            Runnable runnable = new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$removeKeyboardPositionBeforeTransition$203();
                }
            };
            this.cancelFixedPositionRunnable = runnable;
            AndroidUtilities.runOnUIThread(runnable, 200L);
        }
    }

    public void removeMessageWithThanos(MessageObject messageObject) {
        int indexOf = this.messages.indexOf(messageObject);
        if (indexOf == -1) {
            return;
        }
        this.messages.remove(indexOf);
        ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
        if (chatActivityAdapter == null || chatActivityAdapter.isFiltered) {
            return;
        }
        chatActivityAdapter.notifyItemRemoved(chatActivityAdapter.messagesStartRow + indexOf, true);
    }

    public void resetForReload() {
        getConnectionsManager().cancelRequestsForGuid(((BaseFragment) this).classGuid);
        getMessagesStorage().cancelTasksForGuid(((BaseFragment) this).classGuid);
        ((BaseFragment) this).classGuid = ConnectionsManager.generateClassGuid();
        this.startLoadFromMessageId = 0;
        this.firstMessagesLoaded = false;
        this.clearOnLoad = true;
        this.waitingForLoad.clear();
    }

    public void restartSticker(ChatMessageCell chatMessageCell) {
        MessageObject messageObject = chatMessageCell.getMessageObject();
        TLRPC.Document document = messageObject.getDocument();
        if (!messageObject.isAnimatedAnimatedEmoji()) {
            setupStickerVibrationAndSound(chatMessageCell);
        }
        if (!messageObject.isAnimatedEmoji()) {
            if (!MessageObject.isAnimatedStickerDocument(document, this.currentEncryptedChat == null || messageObject.isOut()) || SharedConfig.loopStickers()) {
                return;
            }
        }
        RLottieDrawable lottieAnimation = chatMessageCell.getPhotoImage().getLottieAnimation();
        if (lottieAnimation != null) {
            lottieAnimation.restart();
        }
    }

    public void restoreSelfArgs(Bundle bundle) {
        this.currentPicturePath = bundle.getString("path");
    }

    public void saveDraft() {
        MessageObject messageObject;
        CharSequence charSequence;
        boolean z;
        long j;
        long j2;
        BlurredFrameLayout blurredFrameLayout;
        if (this.ignoreAttachOnPause || this.chatActivityEnterView == null || (blurredFrameLayout = this.bottomOverlayChat) == null || blurredFrameLayout.getVisibility() == 0) {
            messageObject = null;
            charSequence = null;
            z = true;
        } else {
            messageObject = this.replyingMessageObject;
            charSequence = AndroidUtilities.getTrimmedString(this.chatActivityEnterView.getDraftMessage());
            z = this.chatActivityEnterView.isMessageWebPageSearchEnabled();
        }
        if (this.ignoreDraft) {
            charSequence = null;
        }
        CharSequence[] charSequenceArr = {charSequence};
        MediaDataController mediaDataController = getMediaDataController();
        TLRPC.EncryptedChat encryptedChat = this.currentEncryptedChat;
        ArrayList entities = mediaDataController.getEntities(charSequenceArr, encryptedChat == null || AndroidUtilities.getPeerLayerVersion(encryptedChat.layer) >= 101);
        if (this.chatMode == 3) {
            j2 = 0;
        } else {
            if (!ChatObject.isForum(this.currentChat) || this.isTopic || messageObject == null) {
                j = this.threadMessageId;
            } else {
                j = messageObject.replyToForumTopic != null ? r5.id : MessageObject.getTopicId(((BaseFragment) this).currentAccount, messageObject.messageOwner, ChatObject.isForum(this.currentChat));
            }
            j2 = j;
        }
        MediaDataController mediaDataController2 = getMediaDataController();
        long j3 = this.dialog_id;
        CharSequence charSequence2 = charSequenceArr[0];
        TLRPC.Message message = (messageObject == null || messageObject.isTopicMainMessage || messageObject.replyToForumTopic != null || this.ignoreDraft) ? null : messageObject.messageOwner;
        ReplyQuote replyQuote = this.replyingQuote;
        MessageSuggestionParams messageSuggestionParams = this.messageSuggestionParams;
        TLRPC.SuggestedPost tl = messageSuggestionParams != null ? messageSuggestionParams.toTl() : null;
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        mediaDataController2.saveDraft(j3, j2, charSequence2, entities, message, replyQuote, tl, chatActivityEnterView != null ? chatActivityEnterView.getEffectId() : 0L, !z, false);
    }

    public void saveKeyboardPositionBeforeTransition() {
        Runnable runnable = this.cancelFixedPositionRunnable;
        if (runnable != null) {
            AndroidUtilities.cancelRunOnUIThread(runnable);
        }
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        this.fixedKeyboardHeight = (chatActivityEnterView == null || this.contentView == null || chatActivityEnterView.getAdjustPanLayoutHelper() == null || this.chatActivityEnterView.getAdjustPanLayoutHelper().animationInProgress()) ? -1 : this.contentView.getKeyboardHeight();
    }

    public void savePositionForTopicChange(long j) {
        GridLayoutManagerFixed gridLayoutManagerFixed;
        MessageObject messageObject;
        int scrollingOffsetForView;
        int abs;
        int i = -1;
        if (this.chatListView == null || (gridLayoutManagerFixed = this.chatLayoutManager) == null || gridLayoutManagerFixed.hasPendingScrollPosition()) {
            this.clearOnLoadAndScrollMessageId = -1;
            return;
        }
        int i2 = 0;
        int i3 = Integer.MAX_VALUE;
        for (int childCount = this.chatListView.getChildCount() - 1; childCount >= 0; childCount--) {
            View childAt = this.chatListView.getChildAt(childCount);
            if (this.chatListView.getChildAdapterPosition(childAt) >= 0 && (childAt instanceof ChatMessageCell) && (messageObject = ((ChatMessageCell) childAt).getMessageObject()) != null && messageObject.getTopicId() == j && (abs = Math.abs((scrollingOffsetForView = getScrollingOffsetForView(childAt)))) < i3) {
                i = messageObject.getId();
                i2 = scrollingOffsetForView;
                i3 = abs;
            }
        }
        this.clearOnLoadAndScrollMessageId = i;
        this.clearOnLoadAndScrollOffset = i2;
    }

    public void saveSelfArgs(Bundle bundle) {
        String str = this.currentPicturePath;
        if (str != null) {
            bundle.putString("path", str);
        }
    }

    public void scrollToLastMessage(boolean z, boolean z2) {
        scrollToLastMessage(z, z2, null);
    }

    public void scrollToLastMessage(boolean z, final boolean z2, Runnable runnable) {
        ArrayList arrayList;
        int i;
        if (this.chatListView.isFastScrollAnimationRunning()) {
            return;
        }
        final int i2 = 0;
        this.forceNextPinnedMessageId = 0;
        this.nextScrollToMessageId = 0;
        this.forceScrollToFirst = false;
        this.chatScrollHelper.setScrollDirection(0);
        if (!this.forwardEndReached[0] || this.first_unread_id != 0 || this.startLoadFromMessageId != 0) {
            AlertDialog alertDialog = this.progressDialog;
            if (alertDialog != null) {
                alertDialog.dismiss();
            }
            updatePinnedListButton(false);
            if (runnable != null) {
                runnable.run();
            } else {
                resetProgressDialogLoading();
                AlertDialog alertDialog2 = new AlertDialog(getParentActivity(), 3, this.themeDelegate);
                this.progressDialog = alertDialog2;
                alertDialog2.setOnCancelListener(this.postponedScrollCancelListener);
                this.progressDialog.showDelayed(1000L);
            }
            this.postponedScrollToLastMessageQueryIndex = this.lastLoadIndex;
            this.fakePostponedScroll = false;
            this.postponedScrollMessageId = 0;
            this.postponedScrollIsCanceled = false;
            this.waitingForLoad.clear();
            this.waitingForLoad.add(Integer.valueOf(this.lastLoadIndex));
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$scrollToLastMessage$147();
                }
            }, 0L);
            return;
        }
        setPagedownLoading(false, true);
        if (this.chatLayoutManager.findFirstCompletelyVisibleItemPosition() == 0) {
            this.canShowPagedownButton = false;
            updatePagedownButtonVisibility(true);
            removeSelectedMessageHighlight();
            updateVisibleRows();
            return;
        }
        this.chatAdapter.updateRowsSafe();
        this.chatScrollHelperCallback.scrollTo = null;
        if (z) {
            int i3 = 0;
            while (i3 < this.messages.size() && ((MessageObject) this.messages.get(i3)).isSponsored()) {
                i3++;
                z2 = false;
            }
            i2 = i3;
        }
        if (z2 && (arrayList = this.messages) != null && !arrayList.isEmpty() && this.messages.get(i2) != null) {
            long groupId = ((MessageObject) this.messages.get(i2)).getGroupId();
            while (groupId != 0 && (i = i2 + 1) < this.messages.size() && groupId == ((MessageObject) this.messages.get(i)).getGroupId()) {
                i2 = i;
            }
        }
        ArrayList arrayList2 = this.messages;
        if (arrayList2 != null && !arrayList2.isEmpty()) {
            i2 = Math.min(i2, this.messages.size() - 1);
        }
        new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$scrollToLastMessage$145(i2, z2);
            }
        }.run();
    }

    public void scrollToMessageId(int i, int i2, boolean z, int i3, boolean z2, int i4) {
        scrollToMessageId(i, i2, z, i3, z2, i4, null);
    }

    public void scrollToMessageId(int r27, int r28, boolean r29, int r30, boolean r31, int r32, java.lang.Runnable r33) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.scrollToMessageId(int, int, boolean, int, boolean, int, java.lang.Runnable):void");
    }

    public void searchLinks(final java.lang.CharSequence r18, final boolean r19) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.searchLinks(java.lang.CharSequence, boolean):void");
    }

    public void selectReaction(android.view.View r21, org.telegram.messenger.MessageObject r22, org.telegram.ui.Components.ReactionsContainerLayout r23, android.view.View r24, float r25, float r26, org.telegram.ui.Components.Reactions.ReactionsLayoutInBubble.VisibleReaction r27, boolean r28, boolean r29, boolean r30, boolean r31) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.selectReaction(android.view.View, org.telegram.messenger.MessageObject, org.telegram.ui.Components.ReactionsContainerLayout, android.view.View, float, float, org.telegram.ui.Components.Reactions.ReactionsLayoutInBubble$VisibleReaction, boolean, boolean, boolean, boolean):void");
    }

    public void sendAnimatedEmoji(TLRPC.Document document, boolean z, int i) {
        String findAnimatedEmojiEmoticon;
        if (document == null || (findAnimatedEmojiEmoticon = MessageObject.findAnimatedEmojiEmoticon(document, (String) null)) == null) {
            return;
        }
        ArrayList arrayList = new ArrayList();
        TLRPC.TL_messageEntityCustomEmoji tL_messageEntityCustomEmoji = new TLRPC.TL_messageEntityCustomEmoji();
        tL_messageEntityCustomEmoji.document = document;
        tL_messageEntityCustomEmoji.document_id = document.id;
        ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).offset = 0;
        ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).length = findAnimatedEmojiEmoticon.length();
        arrayList.add(tL_messageEntityCustomEmoji);
        SendMessagesHelper.SendMessageParams of = SendMessagesHelper.SendMessageParams.of(findAnimatedEmojiEmoticon, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TLRPC.WebPage) null, false, arrayList, (TLRPC.ReplyMarkup) null, (HashMap) null, z, i, (MessageObject.SendAnimationData) null, false);
        of.quick_reply_shortcut = this.quickReplyShortcut;
        of.quick_reply_shortcut_id = getQuickReplyId();
        SendMessagesHelper.getInstance(((BaseFragment) this).currentAccount).sendMessage(of);
        afterMessageSend();
    }

    public void sendAudio(ArrayList arrayList, CharSequence charSequence, boolean z, int i, long j, boolean z2, long j2) {
        if (checkSlowModeAlert()) {
            fillEditingMediaWithCaption(charSequence, null);
            SendMessagesHelper.prepareSendingAudioDocuments(getAccountInstance(), arrayList, charSequence != null ? charSequence : null, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TL_stories.StoryItem) null, z, i, this.editingMessageObject, this.quickReplyShortcut, getQuickReplyId(), j, z2, j2);
            afterMessageSend();
        }
    }

    public void sendContact(TLRPC.User user, boolean z, int i, long j, boolean z2, long j2) {
        if (checkSlowModeAlert()) {
            SendMessagesHelper.SendMessageParams of = SendMessagesHelper.SendMessageParams.of(user, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TLRPC.ReplyMarkup) null, (HashMap) null, z, i);
            of.quick_reply_shortcut = this.quickReplyShortcut;
            of.quick_reply_shortcut_id = getQuickReplyId();
            of.effect_id = j;
            of.invert_media = z2;
            of.payStars = j2;
            of.monoForumPeer = getSendMonoForumPeerId();
            of.suggestionParams = this.messageSuggestionParams;
            getSendMessagesHelper().sendMessage(of);
            afterMessageSend();
        }
    }

    public void sendContacts(ArrayList arrayList, String str, boolean z, int i, long j, boolean z2, long j2) {
        long j3;
        if (checkSlowModeAlert()) {
            if (TextUtils.isEmpty(str)) {
                j3 = j;
            } else {
                SendMessagesHelper.SendMessageParams of = SendMessagesHelper.SendMessageParams.of(str, this.dialog_id, (MessageObject) null, (MessageObject) null, (TLRPC.WebPage) null, true, (ArrayList) null, (TLRPC.ReplyMarkup) null, (HashMap) null, true, 0, (MessageObject.SendAnimationData) null, false);
                of.quick_reply_shortcut = this.quickReplyShortcut;
                of.quick_reply_shortcut_id = getQuickReplyId();
                of.effect_id = j;
                of.invert_media = z2;
                of.payStars = j2;
                of.monoForumPeer = getSendMonoForumPeerId();
                of.suggestionParams = this.messageSuggestionParams;
                SendMessagesHelper.getInstance(((BaseFragment) this).currentAccount).sendMessage(of);
                j3 = 0;
            }
            Iterator it = arrayList.iterator();
            while (it.hasNext()) {
                SendMessagesHelper.SendMessageParams of2 = SendMessagesHelper.SendMessageParams.of((TLRPC.User) it.next(), this.dialog_id, (MessageObject) null, (MessageObject) null, (TLRPC.ReplyMarkup) null, (HashMap) null, z, i);
                of2.quick_reply_shortcut = this.quickReplyShortcut;
                of2.quick_reply_shortcut_id = getQuickReplyId();
                of2.effect_id = j3;
                of2.invert_media = z2;
                of2.payStars = j2;
                of2.monoForumPeer = getSendMonoForumPeerId();
                of2.suggestionParams = this.messageSuggestionParams;
                getSendMessagesHelper().sendMessage(of2);
                j3 = 0;
            }
            afterMessageSend();
        }
    }

    public void sendMedia(final MediaController.PhotoEntry photoEntry, final VideoEditedInfo videoEditedInfo, final boolean z, final int i, final boolean z2, long j) {
        if (photoEntry == null) {
            return;
        }
        MessageObject messageObject = this.editingMessageObject;
        if (messageObject != null && messageObject.needResendWhenEdit()) {
            MessageSuggestionParams messageSuggestionParams = this.messageSuggestionParams;
            if (messageSuggestionParams == null) {
                messageSuggestionParams = MessageSuggestionParams.of(this.editingMessageObject.messageOwner.suggested_post);
            }
            if (!StarsController.isEnoughAmount(((BaseFragment) this).currentAccount, messageSuggestionParams.amount)) {
                showSuggestionOfferForEditMessage(messageSuggestionParams);
                return;
            }
        }
        if (videoEditedInfo != null && videoEditedInfo.roundVideo) {
            Runnable runnable = new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$sendMedia$361();
                }
            };
            this.closeInstantCameraAnimation = runnable;
            AndroidUtilities.runOnUIThread(runnable, 3000L);
        }
        fillEditingMediaWithCaption(((MediaController.MediaEditState) photoEntry).caption, ((MediaController.MediaEditState) photoEntry).entities);
        AlertsCreator.ensurePaidMessageConfirmation(((BaseFragment) this).currentAccount, getDialogId(), 1, new Utilities.Callback() {
            public final void run(Object obj) {
                ChatActivity.this.lambda$sendMedia$362(photoEntry, videoEditedInfo, z, i, z2, (Long) obj);
            }
        }, j);
    }

    public void sendPoll(TLRPC.TL_messageMediaPoll tL_messageMediaPoll, HashMap hashMap, boolean z, int i, long j) {
        if (checkSlowModeAlert()) {
            SendMessagesHelper.SendMessageParams of = SendMessagesHelper.SendMessageParams.of(tL_messageMediaPoll, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TLRPC.ReplyMarkup) null, hashMap, z, i);
            of.quick_reply_shortcut = this.quickReplyShortcut;
            of.quick_reply_shortcut_id = getQuickReplyId();
            of.payStars = j;
            of.monoForumPeer = getSendMonoForumPeerId();
            of.suggestionParams = this.messageSuggestionParams;
            getSendMessagesHelper().sendMessage(of);
            afterMessageSend();
        }
    }

    public void sendTodo(TLRPC.TL_messageMediaToDo tL_messageMediaToDo, boolean z, int i, long j) {
        if (checkSlowModeAlert()) {
            SendMessagesHelper.SendMessageParams of = SendMessagesHelper.SendMessageParams.of((TLRPC.TL_messageMediaPoll) null, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TLRPC.ReplyMarkup) null, (HashMap) null, z, i);
            of.todo = tL_messageMediaToDo;
            of.quick_reply_shortcut = this.quickReplyShortcut;
            of.quick_reply_shortcut_id = getQuickReplyId();
            of.payStars = j;
            of.monoForumPeer = getSendMonoForumPeerId();
            of.suggestionParams = this.messageSuggestionParams;
            getSendMessagesHelper().sendMessage(of);
            afterMessageSend();
        }
    }

    public void setBotUser(String str) {
        if (this.inlineReturn != 0) {
            getMessagesController().sendBotStart(this.currentUser, str);
            return;
        }
        this.sentBotStart = true;
        MessagesController messagesController = getMessagesController();
        TLRPC.User user = this.currentUser;
        this.botUser = str;
        messagesController.sendBotStart(user, str);
        updateBottomOverlay();
    }

    public void setChatInvite(TLRPC.ChatInvite chatInvite) {
        this.chatInvite = chatInvite;
    }

    void setClearingHistory(long j, boolean z) {
        this.clearingHistoryArr.put(j, z ? 1 : 0);
    }

    public void setHighlightMessageId(int i) {
        this.highlightMessageId = i;
    }

    public void setHighlightQuote(int i, String str, int i2) {
        this.highlightMessageId = i;
        this.highlightMessageQuoteFirst = true;
        this.highlightMessageQuoteFirstTime = 0L;
        this.highlightMessageQuote = str;
        this.highlightMessageQuoteOffset = i2;
        this.showNoQuoteAlert = true;
    }

    protected void setIgnoreAttachOnPause(boolean z) {
        this.ignoreAttachOnPause = z;
    }

    public void setInMenuMode(boolean z) {
        super.setInMenuMode(z);
        ActionBar actionBar = ((BaseFragment) this).actionBar;
        if (actionBar != null) {
            actionBar.createMenu().setVisibility(((BaseFragment) this).inMenuMode ? 8 : 0);
        }
    }

    public void setInPreviewMode(boolean z) {
        TLRPC.Message message;
        ChatActivityEnterView chatActivityEnterView;
        super.setInPreviewMode(z);
        int i = 8;
        boolean z2 = false;
        if (this.currentUser != null && this.audioCallIconItem != null) {
            TLRPC.UserFull userFull = getMessagesController().getUserFull(this.currentUser.id);
            if (userFull == null || !userFull.phone_calls_available) {
                this.showAudioCallAsIcon = false;
                this.audioCallIconItem.setVisibility(8);
            } else {
                this.showAudioCallAsIcon = !((BaseFragment) this).inPreviewMode;
                this.audioCallIconItem.setVisibility(0);
            }
        }
        ChatAvatarContainer chatAvatarContainer = this.avatarContainer;
        if (chatAvatarContainer != null) {
            chatAvatarContainer.setOccupyStatusBar(!z);
            this.avatarContainer.setTitleExpand(this.showAudioCallAsIcon);
            this.avatarContainer.setLayoutParams(LayoutHelper.createFrame(-2, -1.0f, 51, z ? this.chatMode == 2 ? 10 : 0 : 56.0f, 0.0f, 40.0f, 0.0f));
        }
        ChatActivityEnterView chatActivityEnterView2 = this.chatActivityEnterView;
        if (chatActivityEnterView2 != null) {
            chatActivityEnterView2.setVisibility(!z ? 0 : 4);
        }
        SuggestEmojiView suggestEmojiView = this.suggestEmojiPanel;
        if (suggestEmojiView != null) {
            if (this.allowStickersPanel && !z && ((chatActivityEnterView = this.chatActivityEnterView) == null || !chatActivityEnterView.isStickersExpanded())) {
                i = 0;
            }
            suggestEmojiView.setVisibility(i);
        }
        MentionsContainerView mentionsContainerView = this.mentionContainer;
        if (mentionsContainerView != null) {
            mentionsContainerView.animate().alpha((this.chatActivityEnterView.isStickersExpanded() || isInPreviewMode()) ? 0.0f : 1.0f).setInterpolator(CubicBezierInterpolator.DEFAULT).start();
        }
        ActionBar actionBar = ((BaseFragment) this).actionBar;
        if (actionBar != null) {
            actionBar.setBackButtonDrawable(!z ? new BackDrawable(false) : null);
            ActionBarMenuItem actionBarMenuItem = this.headerItem;
            if (actionBarMenuItem != null) {
                actionBarMenuItem.setAlpha(!z ? 1.0f : 0.0f);
            }
            ActionBarMenu.LazyItem lazyItem = this.attachItem;
            if (lazyItem != null) {
                lazyItem.setAlpha(z ? 0.0f : 1.0f);
            }
        }
        RecyclerListView recyclerListView = this.chatListView;
        if (recyclerListView != null) {
            int childCount = recyclerListView.getChildCount();
            for (int i2 = 0; i2 < childCount; i2++) {
                View childAt = this.chatListView.getChildAt(i2);
                boolean z3 = childAt instanceof ChatMessageCell;
                MessageObject messageObject = z3 ? ((ChatMessageCell) childAt).getMessageObject() : childAt instanceof ChatActionCell ? ((ChatActionCell) childAt).getMessageObject() : null;
                if (messageObject != null && (message = messageObject.messageOwner) != null && message.media_unread && message.mentioned) {
                    if (!messageObject.isVoice() && !messageObject.isRoundVideo()) {
                        int i3 = this.newMentionsCount - 1;
                        this.newMentionsCount = i3;
                        if (i3 <= 0) {
                            this.newMentionsCount = 0;
                            this.hasAllMentionsLocal = true;
                            showMentionDownButton(false, true);
                        } else {
                            this.mentiondownButtonCounter.setText(String.format(Locale.US, "%d", Integer.valueOf(i3)));
                        }
                        getMessagesController().markMentionMessageAsRead(messageObject.getId(), ChatObject.isChannel(this.currentChat) ? this.currentChat.id : 0L, this.dialog_id);
                        messageObject.setContentIsRead();
                    }
                    if (z3) {
                        ChatMessageCell chatMessageCell = (ChatMessageCell) childAt;
                        chatMessageCell.setHighlighted(false);
                        chatMessageCell.setHighlightedAnimated();
                    }
                }
            }
            this.chatListView.setItemAnimator((RecyclerView.ItemAnimator) null);
        }
        updateBottomOverlay();
        updateSecretStatus();
        FragmentContextView fragmentContextView = this.fragmentContextView;
        if (fragmentContextView != null) {
            fragmentContextView.setEnabled((z || this.isInsideContainer) ? false : true);
        }
        FragmentContextView fragmentContextView2 = this.fragmentLocationContextView;
        if (fragmentContextView2 != null) {
            if (!z && !this.isInsideContainer) {
                z2 = true;
            }
            fragmentContextView2.setEnabled(z2);
        }
        BlurredFrameLayout blurredFrameLayout = this.pinnedMessageView;
        if (blurredFrameLayout != null) {
            blurredFrameLayout.setEnabled(!isInPreviewMode());
        }
    }

    public void setMonoForumThreadMessages(int i, int i2, TLRPC.TL_forumTopic tL_forumTopic) {
        this.threadMaxInboxReadId = i;
        this.threadMaxOutboxReadId = i2;
        this.replyMaxReadId = Math.max(1, i);
        this.threadMessageId = tL_forumTopic != null ? DialogObject.getPeerDialogId(tL_forumTopic.from_id) : 0L;
        updatePinnedTopicStarterMessage();
        updateTopPanel(false);
        updateBottomOverlay();
    }

    public void setNextChannels(ArrayList arrayList) {
        this.nextChannels = arrayList;
    }

    public void setOpenImport() {
        this.openImport = true;
    }

    public void setPreloadedSticker(TLRPC.Document document, boolean z) {
        this.preloadedGreetingsSticker = document;
        this.forceHistoryEmpty = z;
    }

    public void setQuickReplyId(long j) {
        this.threadMessageId = j;
        TLRPC.TL_message tL_message = new TLRPC.TL_message();
        ((TLRPC.Message) tL_message).id = (int) j;
        this.quickReplyMessage = new MessageObject(((BaseFragment) this).currentAccount, tL_message, false, false);
    }

    public void setResolvedChatLink(TL_account.resolvedBusinessChatLinks resolvedbusinesschatlinks) {
        this.resolvedChatLink = resolvedbusinesschatlinks;
    }

    public void setSavedDialog(long j) {
        this.threadMessageId = j;
    }

    public void setSearchQuery(String str) {
        ActionBarMenuItem actionBarMenuItem = this.searchItem;
        if (actionBarMenuItem != null) {
            this.searchingQuery = str;
            actionBarMenuItem.setSearchFieldText(str, false);
        }
    }

    public void setSwitchFromTopics(boolean z) {
        this.switchFromTopics = z;
    }

    public void setTagFilter(ReactionsLayoutInBubble.VisibleReaction visibleReaction) {
        SearchTagsList searchTagsList = this.actionBarSearchTags;
        if (searchTagsList != null) {
            searchTagsList.setChosen(visibleReaction, true);
        }
        boolean z = (TextUtils.isEmpty(this.searchingQuery) && this.searchingReaction == null) ? false : true;
        this.searching = z;
        this.searchItemVisible = z;
        updateBottomOverlay();
        updateSearchUpDownButtonVisibility(true);
    }

    public void setThreadMessages(ArrayList arrayList, TLRPC.Chat chat, int i, int i2, int i3, TLRPC.TL_forumTopic tL_forumTopic) {
        this.forumTopic = tL_forumTopic;
        this.threadMessageObjects = arrayList;
        MessageObject messageObject = (MessageObject) arrayList.get(arrayList.size() - 1);
        this.threadMessageObject = messageObject;
        this.replyingMessageObject = messageObject;
        this.threadMaxInboxReadId = i2;
        this.threadMaxOutboxReadId = i3;
        this.replyMaxReadId = Math.max(1, i2);
        this.threadMessageId = this.threadMessageObject.getId();
        this.replyOriginalMessageId = i;
        this.replyOriginalChat = chat;
        boolean z = tL_forumTopic != null;
        this.isTopic = z;
        MessageObject messageObject2 = this.replyingMessageObject;
        TLRPC.MessageFwdHeader messageFwdHeader = messageObject2.messageOwner.fwd_from;
        this.isComments = (messageFwdHeader == null || messageFwdHeader.channel_post == 0 || z) ? false : true;
        if (z) {
            messageObject2.isTopicMainMessage = true;
        }
        updatePinnedTopicStarterMessage();
        updateTopPanel(false);
        updateBottomOverlay();
    }

    public void setupStickerVibrationAndSound(org.telegram.ui.Cells.ChatMessageCell r9) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.setupStickerVibrationAndSound(org.telegram.ui.Cells.ChatMessageCell):void");
    }

    public void shakeContent() {
        AndroidUtilities.shakeViewSpring(getChatListView(), 5.0f);
        BotWebViewVibrationEffect.APP_ERROR.vibrate();
        ChatActivityEnterView chatActivityEnterView = getChatActivityEnterView();
        for (int i = 0; i < chatActivityEnterView.getChildCount(); i++) {
            AndroidUtilities.shakeViewSpring(chatActivityEnterView.getChildAt(i), 5.0f);
        }
        ActionBar actionBar = getActionBar();
        for (int i2 = 0; i2 < actionBar.getChildCount(); i2++) {
            AndroidUtilities.shakeViewSpring(actionBar.getChildAt(i2), 5.0f);
        }
    }

    public void shareMyContact(final int i, final MessageObject messageObject) {
        int i2;
        CharSequence charSequence;
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity(), this.themeDelegate);
        builder.setTitle(LocaleController.getString(R.string.ShareYouPhoneNumberTitle));
        TLRPC.User user = this.currentUser;
        if (user == null) {
            i2 = R.string.AreYouSureShareMyContactInfo;
        } else {
            if (!user.bot) {
                int i3 = R.string.AreYouSureShareMyContactInfoUser;
                String format = PhoneFormat.getInstance().format("+" + getUserConfig().getCurrentUser().phone);
                TLRPC.User user2 = this.currentUser;
                charSequence = AndroidUtilities.replaceTags(LocaleController.formatString("AreYouSureShareMyContactInfoUser", i3, new Object[]{format, ContactsController.formatName(user2.first_name, user2.last_name)}));
                builder.setMessage(charSequence);
                builder.setPositiveButton(LocaleController.getString(R.string.ShareContact), new AlertDialog.OnButtonClickListener() {
                    @Override
                    public final void onClick(AlertDialog alertDialog, int i4) {
                        ChatActivity.this.lambda$shareMyContact$121(i, messageObject, alertDialog, i4);
                    }
                });
                builder.setNegativeButton(LocaleController.getString(R.string.Cancel), null);
                showDialog(builder.create());
            }
            i2 = R.string.AreYouSureShareMyContactInfoBot;
        }
        charSequence = LocaleController.getString(i2);
        builder.setMessage(charSequence);
        builder.setPositiveButton(LocaleController.getString(R.string.ShareContact), new AlertDialog.OnButtonClickListener() {
            @Override
            public final void onClick(AlertDialog alertDialog, int i4) {
                ChatActivity.this.lambda$shareMyContact$121(i, messageObject, alertDialog, i4);
            }
        });
        builder.setNegativeButton(LocaleController.getString(R.string.Cancel), null);
        showDialog(builder.create());
    }

    public boolean shouldShowImport() {
        return this.openImport;
    }

    public void showAlert(String str, String str2) {
        createAlertView();
        FrameLayout frameLayout = this.alertView;
        if (frameLayout == null || str == null || str2 == null) {
            return;
        }
        if (frameLayout.getTag() != null) {
            this.alertView.setTag(null);
            AnimatorSet animatorSet = this.alertViewAnimator;
            if (animatorSet != null) {
                animatorSet.cancel();
                this.alertViewAnimator = null;
            }
            if (this.alertView.getVisibility() != 0) {
                this.alertViewEnterProgress = 0.0f;
                invalidateChatListViewTopPadding();
            }
            this.alertView.setVisibility(0);
            this.alertViewAnimator = new AnimatorSet();
            ValueAnimator ofFloat = ValueAnimator.ofFloat(this.alertViewEnterProgress, 1.0f);
            ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                    ChatActivity.this.lambda$showAlert$224(valueAnimator);
                }
            });
            this.alertViewAnimator.playTogether(ofFloat);
            this.alertViewAnimator.setDuration(200L);
            this.alertViewAnimator.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationCancel(Animator animator) {
                    if (ChatActivity.this.alertViewAnimator == null || !ChatActivity.this.alertViewAnimator.equals(animator)) {
                        return;
                    }
                    ChatActivity.this.alertViewAnimator = null;
                }

                @Override
                public void onAnimationEnd(Animator animator) {
                    if (ChatActivity.this.alertViewAnimator == null || !ChatActivity.this.alertViewAnimator.equals(animator)) {
                        return;
                    }
                    ChatActivity.this.alertViewEnterProgress = 1.0f;
                    ChatActivity.this.invalidateChatListViewTopPadding();
                    ChatActivity.this.alertViewAnimator = null;
                }
            });
            this.alertViewAnimator.start();
        }
        this.alertNameTextView.setText(str);
        this.alertTextView.setText(Emoji.replaceEmoji(str2.replace('\n', ' '), this.alertTextView.getPaint().getFontMetricsInt(), false));
        Runnable runnable = this.hideAlertViewRunnable;
        if (runnable != null) {
            AndroidUtilities.cancelRunOnUIThread(runnable);
        }
        AnonymousClass114 anonymousClass114 = new AnonymousClass114();
        this.hideAlertViewRunnable = anonymousClass114;
        AndroidUtilities.runOnUIThread(anonymousClass114, 3000L);
    }

    public void showBottomOverlayProgress(final boolean z, boolean z2) {
        if (!z || this.bottomOverlayProgress.getTag() == null) {
            if (z || this.bottomOverlayProgress.getTag() != null) {
                AnimatorSet animatorSet = this.bottomOverlayAnimation;
                if (animatorSet != null) {
                    animatorSet.cancel();
                    this.bottomOverlayAnimation = null;
                }
                this.bottomOverlayProgress.setTag(z ? 1 : null);
                float f = 0.0f;
                float f2 = 0.1f;
                if (!z2) {
                    this.bottomOverlayProgress.setVisibility(z ? 0 : 4);
                    this.bottomOverlayProgress.setScaleX(z ? 1.0f : 0.1f);
                    this.bottomOverlayProgress.setScaleY(z ? 1.0f : 0.1f);
                    this.bottomOverlayProgress.setAlpha(1.0f);
                    this.bottomOverlayChatText.setVisibility((z || this.bottomOverlayLinks) ? 4 : 0);
                    this.bottomOverlayLinksText.setVisibility((z || !this.bottomOverlayLinks) ? 4 : 0);
                    this.bottomOverlayChatText.setScaleX((z || this.bottomOverlayLinks) ? 0.1f : 1.0f);
                    this.bottomOverlayLinksText.setScaleX((z || !this.bottomOverlayLinks) ? 0.1f : 1.0f);
                    this.bottomOverlayChatText.setScaleY((z || this.bottomOverlayLinks) ? 0.1f : 1.0f);
                    LinkSpanDrawable.LinksTextView linksTextView = this.bottomOverlayLinksText;
                    if (!z && this.bottomOverlayLinks) {
                        f2 = 1.0f;
                    }
                    linksTextView.setScaleY(f2);
                    this.bottomOverlayChatText.setAlpha((z || this.bottomOverlayLinks) ? 0.0f : 1.0f);
                    LinkSpanDrawable.LinksTextView linksTextView2 = this.bottomOverlayLinksText;
                    if (!z && this.bottomOverlayLinks) {
                        f = 1.0f;
                    }
                    linksTextView2.setAlpha(f);
                    return;
                }
                AnimatorSet animatorSet2 = new AnimatorSet();
                this.bottomOverlayAnimation = animatorSet2;
                if (z) {
                    this.bottomOverlayProgress.setVisibility(0);
                    AnimatorSet animatorSet3 = this.bottomOverlayAnimation;
                    UnreadCounterTextView unreadCounterTextView = this.bottomOverlayChatText;
                    Property property = View.SCALE_X;
                    ObjectAnimator ofFloat = ObjectAnimator.ofFloat(unreadCounterTextView, (Property<UnreadCounterTextView, Float>) property, 0.1f);
                    UnreadCounterTextView unreadCounterTextView2 = this.bottomOverlayChatText;
                    Property property2 = View.SCALE_Y;
                    ObjectAnimator ofFloat2 = ObjectAnimator.ofFloat(unreadCounterTextView2, (Property<UnreadCounterTextView, Float>) property2, 0.1f);
                    UnreadCounterTextView unreadCounterTextView3 = this.bottomOverlayChatText;
                    Property property3 = View.ALPHA;
                    animatorSet3.playTogether(ofFloat, ofFloat2, ObjectAnimator.ofFloat(unreadCounterTextView3, (Property<UnreadCounterTextView, Float>) property3, 0.0f), ObjectAnimator.ofFloat(this.bottomOverlayProgress, (Property<RadialProgressView, Float>) property, 1.0f), ObjectAnimator.ofFloat(this.bottomOverlayProgress, (Property<RadialProgressView, Float>) property2, 1.0f), ObjectAnimator.ofFloat(this.bottomOverlayProgress, (Property<RadialProgressView, Float>) property3, 1.0f));
                    this.bottomOverlayAnimation.setStartDelay(200L);
                } else {
                    LinkSpanDrawable.LinksTextView linksTextView3 = this.bottomOverlayLinks ? this.bottomOverlayLinksText : this.bottomOverlayChatText;
                    RadialProgressView radialProgressView = this.bottomOverlayProgress;
                    Property property4 = View.SCALE_X;
                    ObjectAnimator ofFloat3 = ObjectAnimator.ofFloat(radialProgressView, (Property<RadialProgressView, Float>) property4, 0.1f);
                    RadialProgressView radialProgressView2 = this.bottomOverlayProgress;
                    Property property5 = View.SCALE_Y;
                    ObjectAnimator ofFloat4 = ObjectAnimator.ofFloat(radialProgressView2, (Property<RadialProgressView, Float>) property5, 0.1f);
                    RadialProgressView radialProgressView3 = this.bottomOverlayProgress;
                    Property property6 = View.ALPHA;
                    animatorSet2.playTogether(ofFloat3, ofFloat4, ObjectAnimator.ofFloat(radialProgressView3, (Property<RadialProgressView, Float>) property6, 0.0f), ObjectAnimator.ofFloat(linksTextView3, (Property<LinkSpanDrawable.LinksTextView, Float>) property4, 1.0f), ObjectAnimator.ofFloat(linksTextView3, (Property<LinkSpanDrawable.LinksTextView, Float>) property5, 1.0f), ObjectAnimator.ofFloat(linksTextView3, (Property<LinkSpanDrawable.LinksTextView, Float>) property6, 1.0f));
                }
                this.bottomOverlayAnimation.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationCancel(Animator animator) {
                        if (ChatActivity.this.bottomOverlayAnimation == null || !ChatActivity.this.bottomOverlayAnimation.equals(animator)) {
                            return;
                        }
                        ChatActivity.this.bottomOverlayAnimation = null;
                    }

                    @Override
                    public void onAnimationEnd(Animator animator) {
                        if (ChatActivity.this.bottomOverlayAnimation == null || !ChatActivity.this.bottomOverlayAnimation.equals(animator)) {
                            return;
                        }
                        (!z ? ChatActivity.this.bottomOverlayProgress : ChatActivity.this.bottomOverlayLinks ? ChatActivity.this.bottomOverlayLinksText : ChatActivity.this.bottomOverlayChatText).setVisibility(4);
                    }
                });
                this.bottomOverlayAnimation.setDuration(150L);
                this.bottomOverlayAnimation.start();
            }
        }
    }

    public void showFieldPanel(boolean r28, org.telegram.messenger.MessageObject r29, org.telegram.messenger.MessageObject r30, java.util.ArrayList r31, org.telegram.tgnet.TLRPC.WebPage r32, boolean r33, int r34, org.telegram.ui.ChatActivity.ReplyQuote r35, boolean r36, long r37, org.telegram.messenger.MessageSuggestionParams r39, boolean r40) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.showFieldPanel(boolean, org.telegram.messenger.MessageObject, org.telegram.messenger.MessageObject, java.util.ArrayList, org.telegram.tgnet.TLRPC$WebPage, boolean, int, org.telegram.ui.ChatActivity$ReplyQuote, boolean, long, org.telegram.messenger.MessageSuggestionParams, boolean):void");
    }

    public void showFieldPanel(boolean z, MessageObject messageObject, MessageObject messageObject2, ArrayList arrayList, TLRPC.WebPage webPage, boolean z2, int i, ReplyQuote replyQuote, boolean z3, long j, boolean z4) {
        showFieldPanel(z, messageObject, messageObject2, arrayList, webPage, z2, i, replyQuote, z3, j, null, z4);
    }

    public void showFieldPanelForEdit(boolean z, MessageObject messageObject) {
        showFieldPanel(z, null, messageObject, null, null, true, 0, null, false, 0L, true);
    }

    public void showFieldPanelForForward(boolean z, ArrayList arrayList) {
        showFieldPanel(z, null, null, arrayList, null, true, 0, null, false, 0L, true);
    }

    public void showFieldPanelForReply(MessageObject messageObject) {
        showFieldPanel(true, messageObject, null, null, null, true, 0, null, false, 0L, true);
    }

    public void showFieldPanelForReplyQuote(MessageObject messageObject, ReplyQuote replyQuote) {
        showFieldPanel(true, messageObject, null, null, null, true, 0, replyQuote, false, 0L, true);
    }

    public void showFieldPanelForSuggestionParams(MessageSuggestionParams messageSuggestionParams) {
        showFieldPanel(true, null, null, null, null, true, 0, null, false, 0L, messageSuggestionParams, true);
    }

    public void showFieldPanelForWebPage(boolean z, TLRPC.WebPage webPage, boolean z2) {
        showFieldPanel(z, null, null, null, webPage, true, 0, null, z2, 0L, true);
    }

    public void showNoQuoteFound() {
        BulletinFactory.of(this).createSimpleBulletin(R.raw.error, LocaleController.getString(R.string.QuoteNotFound)).show(true);
    }

    public void showOpenGameAlert(final TLRPC.TL_game tL_game, final MessageObject messageObject, final String str, boolean z, final long j) {
        String str2;
        TLRPC.User user = getMessagesController().getUser(Long.valueOf(j));
        str2 = "";
        if (z) {
            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity(), this.themeDelegate);
            builder.setTitle(LocaleController.getString(R.string.AppName));
            builder.setMessage(LocaleController.formatString(R.string.BotPermissionGameAlert, new Object[]{user != null ? ContactsController.formatName(user.first_name, user.last_name) : ""}));
            builder.setPositiveButton(LocaleController.getString(R.string.OK), new AlertDialog.OnButtonClickListener() {
                @Override
                public final void onClick(AlertDialog alertDialog, int i) {
                    ChatActivity.this.lambda$showOpenGameAlert$363(tL_game, messageObject, str, j, alertDialog, i);
                }
            });
            builder.setNegativeButton(LocaleController.getString(R.string.Cancel), null);
            showDialog(builder.create());
            return;
        }
        String publicUsername = UserObject.getPublicUsername(user);
        if (Build.VERSION.SDK_INT >= 21 && !AndroidUtilities.isTablet() && WebviewActivity.supportWebview()) {
            if (((BaseFragment) this).parentLayout.getFragmentStack().get(((BaseFragment) this).parentLayout.getFragmentStack().size() - 1) == this) {
                presentFragment(new WebviewActivity(str, (user == null || TextUtils.isEmpty(publicUsername)) ? "" : publicUsername, tL_game.title, tL_game.short_name, messageObject));
            }
        } else {
            Activity parentActivity = getParentActivity();
            String str3 = tL_game.short_name;
            if (user != null && publicUsername != null) {
                str2 = publicUsername;
            }
            WebviewActivity.openGameInBrowser(str, messageObject, parentActivity, str3, str2);
        }
    }

    public void showPremiumFloodWaitBulletin(final boolean z) {
        long currentTimeMillis = System.currentTimeMillis();
        if (currentTimeMillis - ConnectionsManager.lastPremiumFloodWaitShown < MessagesController.getInstance(((BaseFragment) this).currentAccount).uploadPremiumSpeedupNotifyPeriod * 1000) {
            return;
        }
        ConnectionsManager.lastPremiumFloodWaitShown = currentTimeMillis;
        if (UserConfig.getInstance(((BaseFragment) this).currentAccount).isPremium() || MessagesController.getInstance(((BaseFragment) this).currentAccount).premiumFeaturesBlocked()) {
            return;
        }
        MessagesController messagesController = MessagesController.getInstance(((BaseFragment) this).currentAccount);
        double round = Math.round((z ? messagesController.uploadPremiumSpeedupUpload : messagesController.uploadPremiumSpeedupDownload) * 10.0f);
        Double.isNaN(round);
        SpannableString spannableString = new SpannableString(Double.toString(round / 10.0d).replaceAll("\\.0$", ""));
        spannableString.setSpan(new TypefaceSpan(AndroidUtilities.bold()), 0, spannableString.length(), 33);
        if (hasStoryViewer()) {
            return;
        }
        BulletinFactory.of(this).createSimpleBulletin(R.raw.speed_limit, LocaleController.getString(z ? R.string.UploadSpeedLimited : R.string.DownloadSpeedLimited), AndroidUtilities.replaceCharSequence("%d", AndroidUtilities.premiumText(LocaleController.getString(z ? R.string.UploadSpeedLimitedMessage : R.string.DownloadSpeedLimitedMessage), new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$showPremiumFloodWaitBulletin$396(z);
            }
        }), spannableString)).setDuration(8000).show(true);
    }

    public void showQuoteMessageUpdate() {
        if (this.quoteMessageUpdateAlert != null) {
            return;
        }
        this.quoteMessageUpdateAlert = new AlertDialog.Builder(getContext(), getResourceProvider()).setTitle(LocaleController.getString(R.string.UpdatedQuoteTitle)).setMessage(AndroidUtilities.replaceTags(LocaleController.formatString(R.string.UpdatedQuoteMessage, new Object[]{this.replyingMessageObject != null ? getMessagesController().getFullName(this.replyingMessageObject.getSenderId()) : ""}))).setPositiveButton(LocaleController.getString(R.string.Edit), new AlertDialog.OnButtonClickListener() {
            @Override
            public final void onClick(AlertDialog alertDialog, int i) {
                ChatActivity.this.lambda$showQuoteMessageUpdate$191(alertDialog, i);
            }
        }).setNegativeButton(LocaleController.getString(R.string.Cancel), new AlertDialog.OnButtonClickListener() {
            @Override
            public final void onClick(AlertDialog alertDialog, int i) {
                ChatActivity.this.lambda$showQuoteMessageUpdate$192(alertDialog, i);
            }
        }).setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public final void onDismiss(DialogInterface dialogInterface) {
                ChatActivity.this.lambda$showQuoteMessageUpdate$193(dialogInterface);
            }
        }).show();
    }

    public void showRequestUrlAlert(final TLRPC.TL_urlAuthResultRequest tL_urlAuthResultRequest, final TLRPC.TL_messages_requestUrlAuth tL_messages_requestUrlAuth, final String str, final boolean z) {
        int i = 2;
        if (getParentActivity() == null) {
            return;
        }
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity(), this.themeDelegate);
        builder.setTitle(LocaleController.getString(R.string.OpenUrlTitle));
        String string = LocaleController.getString(R.string.OpenUrlAlert2);
        int indexOf = string.indexOf("%");
        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(String.format(string, str));
        if (indexOf >= 0) {
            spannableStringBuilder.setSpan(new URLSpan(str), indexOf, str.length() + indexOf, 33);
        }
        builder.setMessage(spannableStringBuilder);
        builder.setMessageTextViewClickable(false);
        builder.setNegativeButton(LocaleController.getString(R.string.Cancel), null);
        final CheckBoxCell[] checkBoxCellArr = new CheckBoxCell[2];
        LinearLayout linearLayout = new LinearLayout(getParentActivity());
        linearLayout.setOrientation(1);
        TLRPC.User currentUser = getUserConfig().getCurrentUser();
        int i2 = 0;
        while (true) {
            if (i2 >= (tL_urlAuthResultRequest.request_write_access ? 2 : 1)) {
                builder.setView(linearLayout);
                builder.setPositiveButton(LocaleController.getString(R.string.Open), new AlertDialog.OnButtonClickListener() {
                    @Override
                    public final void onClick(AlertDialog alertDialog, int i3) {
                        ChatActivity.this.lambda$showRequestUrlAlert$379(checkBoxCellArr, str, tL_messages_requestUrlAuth, tL_urlAuthResultRequest, z, alertDialog, i3);
                    }
                });
                showDialog(builder.create());
                return;
            }
            CheckBoxCell checkBoxCell = new CheckBoxCell(getParentActivity(), 5, this.themeDelegate);
            checkBoxCellArr[i2] = checkBoxCell;
            checkBoxCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
            checkBoxCellArr[i2].setMultiline(true);
            checkBoxCellArr[i2].setTag(Integer.valueOf(i2));
            if (i2 == 0) {
                int i3 = R.string.OpenUrlOption1;
                String str2 = tL_urlAuthResultRequest.domain;
                String formatName = ContactsController.formatName(currentUser.first_name, currentUser.last_name);
                Object[] objArr = new Object[i];
                objArr[0] = str2;
                objArr[1] = formatName;
                SpannableStringBuilder replaceTags = AndroidUtilities.replaceTags(LocaleController.formatString("OpenUrlOption1", i3, objArr));
                int indexOf2 = TextUtils.indexOf(replaceTags, tL_urlAuthResultRequest.domain);
                if (indexOf2 >= 0) {
                    replaceTags.setSpan(new URLSpan(""), indexOf2, tL_urlAuthResultRequest.domain.length() + indexOf2, 33);
                }
                checkBoxCellArr[i2].setText(replaceTags, "", true, false);
            } else {
                checkBoxCellArr[i2].setText(AndroidUtilities.replaceTags(LocaleController.formatString("OpenUrlOption2", R.string.OpenUrlOption2, new Object[]{UserObject.getFirstName(tL_urlAuthResultRequest.bot)})), "", true, false);
            }
            checkBoxCellArr[i2].setPadding(LocaleController.isRTL ? AndroidUtilities.dp(16.0f) : AndroidUtilities.dp(8.0f), 0, LocaleController.isRTL ? AndroidUtilities.dp(8.0f) : AndroidUtilities.dp(16.0f), 0);
            linearLayout.addView(checkBoxCellArr[i2], LayoutHelper.createLinear(-1, -2));
            checkBoxCellArr[i2].setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    ChatActivity.lambda$showRequestUrlAlert$374(checkBoxCellArr, view);
                }
            });
            i2++;
            i = 2;
        }
    }

    public void showSuggestionOfferForEditMessage(MessageSuggestionParams messageSuggestionParams) {
        if (this.editingMessageObject == null) {
            return;
        }
        new MessageSuggestionOfferSheet(getContext(), ((BaseFragment) this).currentAccount, this.dialog_id, messageSuggestionParams, this, getResourceProvider(), 0, new Utilities.Callback() {
            public final void run(Object obj) {
                ChatActivity.this.lambda$showSuggestionOfferForEditMessage$349((MessageSuggestionParams) obj);
            }
        }).show();
    }

    public void showTimerHint() {
        if (getParentActivity() == null || ((BaseFragment) this).fragmentView == null || this.chatInfo == null) {
            return;
        }
        if (this.timerHintView == null) {
            HintView hintView = new HintView(getParentActivity(), 7, true, this.themeDelegate);
            this.timerHintView = hintView;
            hintView.setAlpha(0.0f);
            this.timerHintView.setVisibility(4);
            this.timerHintView.setShowingDuration(4000L);
            this.contentView.addView(this.timerHintView, LayoutHelper.createFrame(-2, -2.0f, 51, 19.0f, 0.0f, 19.0f, 0.0f));
        }
        int i = this.chatInfo.ttl_period;
        this.timerHintView.setText(LocaleController.formatString("AutoDeleteSetInfo", R.string.AutoDeleteSetInfo, new Object[]{i > 86400 ? LocaleController.formatPluralString("Days", i / 86400, new Object[0]) : i >= 3600 ? LocaleController.formatPluralString("Hours", i / 3600, new Object[0]) : i >= 60 ? LocaleController.formatPluralString("Minutes", i / 60, new Object[0]) : LocaleController.formatPluralString("Seconds", i, new Object[0])}));
        this.timerHintView.showForView(this.avatarContainer.getTimeItem(), true);
    }

    public void startDocumentSelectActivity() {
        try {
            Intent intent = new Intent("android.intent.action.GET_CONTENT");
            intent.putExtra("android.intent.extra.ALLOW_MULTIPLE", true);
            intent.setType("*/*");
            startActivityForResult(intent, 21);
        } catch (Exception e) {
            FileLog.e(e);
        }
    }

    public void startMusicSelectActivity() {
        ChatAttachAlertDocumentLayout.DocumentSelectActivityDelegate.-CC.$default$startMusicSelectActivity(this);
    }

    public boolean supportsThanosEffect() {
        return ThanosEffect.supports() && LiteMode.isEnabled(65536);
    }

    public void updateBottomOverlay() {
        updateBottomOverlay(false);
    }

    public void updateBottomOverlay(boolean r22) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.updateBottomOverlay(boolean):void");
    }

    public void updateMessages(ArrayList arrayList, boolean z) {
        for (int i = 0; i < arrayList.size(); i++) {
            this.chatAdapter.updateRowWithMessageObject((MessageObject) arrayList.get(i), false, z);
        }
    }

    public void updateMessagesVisiblePart(boolean r76) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.updateMessagesVisiblePart(boolean):void");
    }

    public void updatePinnedTopicStarterMessage() {
        TLRPC.Message message;
        TLRPC.TL_forumTopic tL_forumTopic;
        MessageObject messageObject = (this.isTopic && !this.pinnedMessageObjects.isEmpty() && this.pinnedMessageIds.size() == 1 && ((long) ((Integer) this.pinnedMessageIds.get(0)).intValue()) == getTopicId() + 1) ? (MessageObject) this.pinnedMessageObjects.get(this.pinnedMessageIds.get(0)) : null;
        this.topicStarterMessageObject = messageObject;
        if (!this.isTopic || messageObject == null || (message = messageObject.messageOwner) == null || (tL_forumTopic = this.forumTopic) == null || MessageObject.peersEqual(tL_forumTopic.from_id, message.from_id) || MessageObject.peersEqual(this.currentChat, this.topicStarterMessageObject.messageOwner.from_id)) {
            return;
        }
        this.topicStarterMessageObject = null;
    }

    public void updateReplyMessageHeader(boolean z) {
        String formatPluralString;
        if (this.chatMode == 3) {
            return;
        }
        ChatAvatarContainer chatAvatarContainer = this.avatarContainer;
        if (chatAvatarContainer != null && this.threadMessageId != 0) {
            if (this.isTopic) {
                updateTopicHeader();
            } else {
                if (this.isComments) {
                    MessageObject messageObject = this.threadMessageObject;
                    if (messageObject == null || !messageObject.hasReplies()) {
                        chatAvatarContainer = this.avatarContainer;
                        formatPluralString = LocaleController.getString(R.string.CommentsTitle);
                    } else {
                        chatAvatarContainer = this.avatarContainer;
                        formatPluralString = LocaleController.formatPluralString("Comments", this.threadMessageObject.getRepliesCount(), new Object[0]);
                    }
                } else {
                    MessageObject messageObject2 = this.threadMessageObject;
                    if (messageObject2 != null) {
                        formatPluralString = LocaleController.formatPluralString("Replies", messageObject2.getRepliesCount(), new Object[0]);
                    }
                }
                chatAvatarContainer.setTitle(formatPluralString);
            }
        }
        if (this.replyMessageHeaderObject == null) {
            return;
        }
        String string = LocaleController.getString(this.threadMessageObject.getRepliesCount() == 0 ? this.isComments ? R.string.NoComments : R.string.NoReplies : R.string.DiscussionStarted);
        MessageObject messageObject3 = this.replyMessageHeaderObject;
        messageObject3.messageOwner.message = string;
        messageObject3.messageText = string;
        if (z) {
            this.chatAdapter.updateRowWithMessageObject(messageObject3, true, false);
        }
    }

    protected void updateSearchingHashtag(String str) {
        if (this.chatMode == 7 && !TextUtils.equals(this.searchingHashtag, str)) {
            showMessagesSearchListView(true);
            this.searchingHashtag = str;
            this.searchingQuery = str;
            checkHashtagStories(false);
            clearChatData(true);
            this.startMessageAppearTransitionMs = 0L;
            this.firstMessagesLoaded = false;
            HashtagSearchController.getInstance(((BaseFragment) this).currentAccount).clearSearchResults(this.searchType);
            this.messagesSearchAdapter.notifyDataSetChanged();
            this.messagesSearchListView.requestLayout();
            if (this.messagesSearchListView.getLayoutManager() != null) {
                this.messagesSearchListView.getLayoutManager().scrollToPosition(0);
            }
            updateSearchListEmptyView();
            this.hashtagSearchEmptyView.showProgress(true);
            firstLoadMessages();
        }
    }

    public void updateTextureViewPosition(boolean z, boolean z2) {
        boolean z3;
        MessageObject playingMessageObject;
        if (((BaseFragment) this).fragmentView == null || this.paused) {
            return;
        }
        int childCount = this.chatListView.getChildCount();
        int i = 0;
        while (true) {
            if (i >= childCount) {
                z3 = false;
                break;
            }
            View childAt = this.chatListView.getChildAt(i);
            if (childAt instanceof ChatMessageCell) {
                ChatMessageCell chatMessageCell = (ChatMessageCell) childAt;
                MessageObject messageObject = chatMessageCell.getMessageObject();
                if (this.videoPlayerContainer != null && ((messageObject.isRoundVideo() || messageObject.isVideo()) && !messageObject.isVoiceTranscriptionOpen() && MediaController.getInstance().isPlayingMessage(messageObject))) {
                    ImageReceiver photoImage = chatMessageCell.getPhotoImage();
                    this.videoPlayerContainer.setTranslationX(photoImage.getImageX() + chatMessageCell.getX());
                    this.videoPlayerContainer.setTranslationY((((chatMessageCell.getY() + chatMessageCell.getPaddingTop()) + photoImage.getImageY()) + this.chatListView.getY()) - this.videoPlayerContainer.getTop());
                    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) this.videoPlayerContainer.getLayoutParams();
                    if (messageObject.isRoundVideo()) {
                        this.videoPlayerContainer.setTag(R.id.parent_tag, null);
                        if (layoutParams.width != AndroidUtilities.roundPlayingMessageSize(isSideMenued()) || layoutParams.height != AndroidUtilities.roundPlayingMessageSize(isSideMenued())) {
                            int roundPlayingMessageSize = AndroidUtilities.roundPlayingMessageSize(isSideMenued());
                            layoutParams.height = roundPlayingMessageSize;
                            layoutParams.width = roundPlayingMessageSize;
                            this.aspectRatioFrameLayout.setResizeMode(0);
                            this.videoPlayerContainer.setLayoutParams(layoutParams);
                        }
                        float roundPlayingMessageSize2 = (AndroidUtilities.roundPlayingMessageSize(isSideMenued()) + (AndroidUtilities.roundMessageInset * 2)) / AndroidUtilities.roundPlayingMessageSize(isSideMenued());
                        float imageWidth = chatMessageCell.getPhotoImage().getImageWidth() / AndroidUtilities.roundPlayingMessageSize(isSideMenued());
                        if (this.videoPlayerContainer.getScaleX() != imageWidth) {
                            this.videoPlayerContainer.invalidate();
                            ((BaseFragment) this).fragmentView.invalidate();
                        }
                        this.videoPlayerContainer.setPivotX(0.0f);
                        this.videoPlayerContainer.setPivotY(0.0f);
                        this.videoPlayerContainer.setScaleX(imageWidth);
                        this.videoPlayerContainer.setScaleY(imageWidth);
                        this.videoTextureView.setScaleX(roundPlayingMessageSize2);
                        this.videoTextureView.setScaleY(roundPlayingMessageSize2);
                    } else {
                        this.videoPlayerContainer.setTag(R.id.parent_tag, photoImage);
                        if (layoutParams.width != photoImage.getImageWidth() || layoutParams.height != photoImage.getImageHeight()) {
                            this.aspectRatioFrameLayout.setResizeMode(3);
                            layoutParams.width = (int) photoImage.getImageWidth();
                            layoutParams.height = (int) photoImage.getImageHeight();
                            this.videoPlayerContainer.setLayoutParams(layoutParams);
                        }
                        this.videoTextureView.setScaleX(1.0f);
                        this.videoTextureView.setScaleY(1.0f);
                    }
                    ((BaseFragment) this).fragmentView.invalidate();
                    this.videoPlayerContainer.invalidate();
                    z3 = true;
                }
            }
            i++;
        }
        if (!z || this.videoPlayerContainer == null || (playingMessageObject = MediaController.getInstance().getPlayingMessageObject()) == null || playingMessageObject.eventId != 0) {
            return;
        }
        if (z3) {
            MediaController.getInstance().setCurrentVideoVisible(true);
            if (playingMessageObject.isRoundVideo() || this.scrollToVideo) {
                return;
            }
            this.chatListView.invalidate();
            return;
        }
        if (this.checkTextureViewPosition && playingMessageObject.isVideo()) {
            MediaController.getInstance().cleanupPlayer(true, true);
            return;
        }
        this.videoPlayerContainer.setTranslationY((-AndroidUtilities.roundPlayingMessageSize(isSideMenued())) - 100);
        ((BaseFragment) this).fragmentView.invalidate();
        if (playingMessageObject.isRoundVideo() || playingMessageObject.isVideo()) {
            if (this.checkTextureViewPosition || PipRoundVideoView.getInstance() != null) {
                MediaController.getInstance().setCurrentVideoVisible(false);
            } else if (z2) {
                scrollToMessageId(playingMessageObject.getId(), 0, false, 0, true, 0);
            }
        }
    }

    public void updateTitle(boolean r19) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.updateTitle(boolean):void");
    }

    public void updateTopPanel(boolean r44) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.updateTopPanel(boolean):void");
    }

    public void updateTopicTitleIcon() {
        ChatAvatarContainer chatAvatarContainer;
        if (this.forumTopic == null || (chatAvatarContainer = this.avatarContainer) == null) {
            return;
        }
        chatAvatarContainer.getAvatarImageView().setVisibility(0);
        ForumUtilities.setTopicIcon(this.avatarContainer.getAvatarImageView(), this.forumTopic, true, true, this.themeDelegate);
    }

    public void updateVisibleRows() {
        updateVisibleRows(false);
    }
}