导航菜单

页面标题

页面副标题

Plus 12 v10.13.1.1 - ChatActivity.java 源代码

正在查看: Plus 12 v10.13.1.1 应用的 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.annotation.SuppressLint;
import android.annotation.TargetApi;
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.database.Cursor;
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.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.media.AudioManager;
import android.media.ExifInterface;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcelable;
import android.os.SystemClock;
import android.os.Vibrator;
import android.provider.MediaStore;
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.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.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.collection.LongSparseArray;
import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider;
import androidx.core.graphics.ColorUtils;
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.core.util.Consumer;
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 j$.util.Collection;
import j$.util.Comparator;
import j$.util.function.Predicate;
import j$.util.stream.Collectors;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
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.Stack;
import java.util.concurrent.CountDownLatch;
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.db.entity.DialogEntity;
import org.telegram.messenger.AccountInstance;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
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.EmojiData;
import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog;
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.MessageLoaderLogger;
import org.telegram.messenger.MessageObject;
import org.telegram.messenger.MessagePreviewParams;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.MessagesController$;
import org.telegram.messenger.MessagesStorage;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.PlusRepository;
import org.telegram.messenger.PlusUtils;
import org.telegram.messenger.R;
import org.telegram.messenger.SendMessagesHelper;
import org.telegram.messenger.SharedConfig;
import org.telegram.messenger.SvgHelper;
import org.telegram.messenger.TopicsController;
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.translator.BaseTranslationEngine;
import org.telegram.messenger.translator.TranslateBottomSheet;
import org.telegram.messenger.utils.PhotoUtilities;
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_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.PlusSettings;
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.TextSelectionHelper;
import org.telegram.ui.ChatActivity;
import org.telegram.ui.ChatRightsEditActivity;
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.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.ChatDialogsView;
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.CombinedDrawable;
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.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;
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.ReportAlert;
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.SizeNotifierFrameLayout;
import org.telegram.ui.Components.StickerEmptyView;
import org.telegram.ui.Components.StickersAlert;
import org.telegram.ui.Components.SuggestEmojiView;
import org.telegram.ui.Components.Switch;
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.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.ViewPagerFixed;
import org.telegram.ui.Components.voip.VoIPHelper;
import org.telegram.ui.ContactAddActivity;
import org.telegram.ui.ContactsActivity;
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.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.ReportAdBottomSheet;
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.bots.BotCommandsMenuContainer;
import org.telegram.ui.bots.BotCommandsMenuView;
import org.telegram.ui.bots.BotWebViewSheet;

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

    public interface ChatActivityDelegate {

        public final class CC {
            public static void $default$onReport(ChatActivityDelegate chatActivityDelegate) {
            }

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

            public static void $default$openHashtagSearch(ChatActivityDelegate chatActivityDelegate, String str) {
            }

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

        void onReport();

        void onUnpin(boolean all, boolean hide);

        void openHashtagSearch(String hashtag);

        void openReplyMessage(int mid);
    }

    public interface ChatSearchResultDelegate {
        void onSearchResultsAvailable(int count);
    }

    public static void m2515$$Nest$mcheckBotMessageHint(ChatActivity chatActivity) {
        chatActivity.checkBotMessageHint();
    }

    public static void m2521$$Nest$mcheckSavedMessagesTagHint(ChatActivity chatActivity) {
        chatActivity.checkSavedMessagesTagHint();
    }

    public static void m2586$$Nest$mresetProgressDialogLoading(ChatActivity chatActivity) {
        chatActivity.resetProgressDialogLoading();
    }

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

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

    public static void lambda$markSponsoredAsRead$392(TLObject tLObject, TLRPC.TL_error tL_error) {
    }

    public static boolean lambda$showChatThemeBottomSheet$405(MotionEvent motionEvent) {
        return true;
    }

    public void onSearchLoadingUpdate(boolean loading) {
    }

    public void startMusicSelectActivity() {
        ChatAttachAlertDocumentLayout.DocumentSelectActivityDelegate.-CC.$default$startMusicSelectActivity(this);
    }

    public ReactionsLayoutInBubble.VisibleReaction getFilterTag() {
        ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
        if (chatActivityAdapter == null || !chatActivityAdapter.isFiltered) {
            return null;
        }
        return this.searchingReaction;
    }

    public String getFilterQuery() {
        ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
        if (chatActivityAdapter == null || !chatActivityAdapter.isFiltered) {
            return null;
        }
        return this.searchingQuery;
    }

    public boolean isFiltered() {
        ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
        return chatActivityAdapter != null && chatActivityAdapter.isFiltered;
    }

    public ArrayList<MessageObject> getFilteredMessages() {
        ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
        if (chatActivityAdapter != null) {
            return chatActivityAdapter.filteredMessages;
        }
        return null;
    }

    public void lambda$new$1(DialogInterface dialogInterface) {
        this.postponedScrollIsCanceled = true;
        this.postponedScrollMessageId = 0;
        this.nextScrollToMessageId = 0;
        this.forceNextPinnedMessageId = 0;
        invalidateMessagesVisiblePart();
        showPinnedProgress(false);
    }

    public static ChatActivity of(long dialogId) {
        Bundle bundle = new Bundle();
        if (dialogId >= 0) {
            bundle.putLong("user_id", dialogId);
        } else {
            bundle.putLong("chat_id", -dialogId);
        }
        return new ChatActivity(bundle);
    }

    public void deleteHistory(final int dateSelectedStart, final int dateSelectedEnd, final boolean forAll) {
        this.chatAdapter.frozenMessages.clear();
        for (int i = 0; i < this.messages.size(); i++) {
            MessageObject messageObject = this.messages.get(i);
            int i2 = messageObject.messageOwner.date;
            if (i2 <= dateSelectedStart || i2 >= dateSelectedEnd) {
                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(dateSelectedStart, dateSelectedEnd, forAll);
            }
        }, new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$deleteHistory$4();
            }
        });
    }

    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$2() {
        this.chatAdapter.frozenMessages.clear();
        ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
        chatActivityAdapter.isFrozen = false;
        chatActivityAdapter.notifyDataSetChanged(true);
        showProgressView(false);
    }

    public void lambda$deleteHistory$4() {
        this.chatAdapter.frozenMessages.clear();
        ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
        chatActivityAdapter.isFrozen = false;
        chatActivityAdapter.notifyDataSetChanged(true);
        showProgressView(false);
    }

    public void showHeaderItem(boolean show) {
        if (show) {
            if (this.chatActivityEnterView.hasText() && TextUtils.isEmpty(this.chatActivityEnterView.getSlowModeTimer())) {
                ActionBarMenu.LazyItem lazyItem = this.attachItem;
                if (lazyItem != null) {
                    lazyItem.setVisibility(0);
                }
                ActionBarMenuItem actionBarMenuItem = this.headerItem;
                if (actionBarMenuItem != null) {
                    actionBarMenuItem.setVisibility(8);
                    return;
                }
                return;
            }
            ActionBarMenu.LazyItem lazyItem2 = this.attachItem;
            if (lazyItem2 != null) {
                lazyItem2.setVisibility(8);
            }
            ActionBarMenuItem actionBarMenuItem2 = this.headerItem;
            if (actionBarMenuItem2 != null) {
                actionBarMenuItem2.setVisibility(0);
                return;
            }
            return;
        }
        ActionBarMenu.LazyItem lazyItem3 = this.attachItem;
        if (lazyItem3 != null) {
            lazyItem3.setVisibility(8);
        }
        ActionBarMenuItem actionBarMenuItem3 = this.headerItem;
        if (actionBarMenuItem3 != null) {
            actionBarMenuItem3.setVisibility(8);
        }
    }

    public long getTopicId() {
        int i;
        if (this.isTopic || (i = this.chatMode) == 3 || i == 5) {
            return this.threadMessageId;
        }
        return 0L;
    }

    public int getQuickReplyId() {
        if (this.chatMode == 5) {
            return (int) this.threadMessageId;
        }
        return 0;
    }

    public long getSavedDialogId() {
        if (this.chatMode == 3) {
            return this.threadMessageId;
        }
        return 0L;
    }

    public boolean isForumInViewAsMessagesMode() {
        return ChatObject.isForum(this.currentChat) && !this.isTopic;
    }

    @Override
    public List<FloatingDebugController.DebugItem> onGetDebugItems() {
        String string;
        ArrayList arrayList = new ArrayList();
        if (ChatObject.isChannel(this.currentChat)) {
            arrayList.add(new FloatingDebugController.DebugItem(LocaleController.getString(R.string.DebugShareAlert)));
            int i = this.shareAlertDebugMode;
            if (i == 1) {
                string = LocaleController.getString(R.string.DebugShareAlertDialogsModeLess);
            } else if (i != 2) {
                string = LocaleController.getString(R.string.DebugShareAlertDialogsModeNormal);
            } else {
                string = LocaleController.getString(R.string.DebugShareAlertDialogsModeMore);
            }
            arrayList.add(new FloatingDebugController.DebugItem(LocaleController.formatString(R.string.DebugShareAlertSwitchDialogsMode, new Object[]{string}), 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(this, str) {
                public void setValue(Object object, float value) {
                    ChatActivity.SKELETON_LIGHT_OVERLAY_ALPHA = (int) value;
                }

                public Object get(Object object) {
                    return Float.valueOf(ChatActivity.SKELETON_LIGHT_OVERLAY_ALPHA);
                }
            }));
            arrayList.add(new FloatingDebugController.DebugItem(LocaleController.getString(R.string.DebugMessageSkeletonsSaturation), 1.0f, 10.0f, new AnimationProperties.FloatProperty(str) {
                public void setValue(Object object, float value) {
                    ChatActivity.SKELETON_SATURATION = value;
                    ChatActivity.this.skeletonColorMatrix.setSaturation(value);
                    ChatActivity.this.skeletonServicePaint.setColorFilter(new ColorMatrixColorFilter(ChatActivity.this.skeletonColorMatrix));
                }

                public Object get(Object object) {
                    return Float.valueOf(ChatActivity.SKELETON_SATURATION);
                }
            }));
        }
        return arrayList;
    }

    public void lambda$onGetDebugItems$5() {
        int i = this.shareAlertDebugMode + 1;
        this.shareAlertDebugMode = i;
        this.shareAlertDebugMode = i % 3;
    }

    public void lambda$onGetDebugItems$6() {
        this.shareAlertDebugTopicsSlowMotion = !this.shareAlertDebugTopicsSlowMotion;
    }

    public void updateMessages(ArrayList<MessageObject> messageObjects, boolean replace) {
        for (int i = 0; i < messageObjects.size(); i++) {
            this.chatAdapter.updateRowWithMessageObject(messageObjects.get(i), false, replace);
        }
    }

    public TextView getOrCreateWebBotTitleView() {
        if (this.webBotTitle == null) {
            TextView textView = new TextView(getContext());
            this.webBotTitle = textView;
            textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
            this.webBotTitle.setTypeface(AndroidUtilities.bold());
            this.webBotTitle.setGravity(16);
            ((BaseFragment) this).actionBar.addView(this.webBotTitle, LayoutHelper.createFrame(-1, -1.0f, 0, 72.0f, 0.0f, 72.0f, 0.0f));
        }
        return this.webBotTitle;
    }

    public RecyclerListView getChatListView() {
        return this.chatListView;
    }

    public final void startMultiselect(int position) {
        int i;
        if (!this.isInsideContainer && (i = position - this.chatAdapter.messagesStartRow) >= 0 && i < this.messages.size()) {
            MessageObject messageObject = this.messages.get(i);
            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 i2 = 0; i2 < this.selectedMessagesIds[0].size(); i2++) {
                sparseArray.put(this.selectedMessagesIds[0].keyAt(i2), this.selectedMessagesIds[0].valueAt(i2));
            }
            for (int i3 = 0; i3 < this.selectedMessagesIds[1].size(); i3++) {
                sparseArray.put(this.selectedMessagesIds[1].keyAt(i3), this.selectedMessagesIds[1].valueAt(i3));
            }
            this.chatListView.startMultiselect(position, false, new RecyclerListView.onMultiSelectionChanged() {
                public boolean limitReached;

                public void onSelectionChanged(int r6, boolean r7, float r8, float r9) {
                    throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.AnonymousClass11.onSelectionChanged(int, boolean, float, float):void");
                }

                public boolean canSelect(int position2) {
                    int i4 = position2 - ChatActivity.this.chatAdapter.messagesStartRow;
                    if (i4 < 0 || i4 >= ChatActivity.this.messages.size()) {
                        return false;
                    }
                    MessageObject messageObject2 = ChatActivity.this.messages.get(i4);
                    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 position2, boolean selectionTop) {
                    MessageObject.GroupedMessages groupedMessages;
                    int i4 = position2 - ChatActivity.this.chatAdapter.messagesStartRow;
                    if (i4 >= 0 && i4 < ChatActivity.this.messages.size()) {
                        MessageObject messageObject2 = ChatActivity.this.messages.get(i4);
                        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(selectionTop ? 0 : r5.size() - 1));
                        }
                    }
                    return position2;
                }

                public boolean limitReached() {
                    return this.limitReached;
                }

                public void getPaddings(int[] paddings) {
                    ChatActivity chatActivity = ChatActivity.this;
                    paddings[0] = (int) chatActivity.chatListViewPaddingTop;
                    paddings[1] = chatActivity.blurredViewBottomOffset;
                }

                public void scrollBy(int dy) {
                    ChatActivity.this.chatListView.scrollBy(0, dy);
                }
            });
        }
    }

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

        public void onItemClick(View view, int position, float x, float y) {
            ChatMessageCell chatMessageCell;
            MessageObject messageObject;
            if (((BaseFragment) ChatActivity.this).inPreviewMode) {
                return;
            }
            ChatActivity.this.wasManualScroll = true;
            boolean z = view instanceof ChatActionCell;
            boolean z2 = false;
            if (z) {
                ChatActionCell chatActionCell = (ChatActionCell) view;
                if (chatActionCell.getMessageObject().isDateObject) {
                    if (ChatActivity.this.isInsideContainer) {
                        return;
                    }
                    Bundle bundle = new Bundle();
                    int i = chatActionCell.getMessageObject().messageOwner.date;
                    bundle.putLong("dialog_id", ChatActivity.this.dialog_id);
                    bundle.putLong("topic_id", ChatActivity.this.getTopicId());
                    bundle.putInt("type", 0);
                    ChatActivity.this.presentFragment(new CalendarActivity(bundle, 0, i));
                    return;
                }
            }
            if (z) {
                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 (z) {
                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.reportType >= 0) {
                if (view instanceof ChatMessageCell) {
                    ChatMessageCell chatMessageCell2 = (ChatMessageCell) view;
                    if (ChatActivity.this.textSelectionHelper.isSelected(chatMessageCell2.getMessageObject())) {
                        return;
                    } else {
                        z2 = !chatMessageCell2.isInsideBackground(x, y);
                    }
                }
                ChatActivity.this.processRowSelect(view, z2, x, y);
                return;
            }
            if ((view instanceof ChatMessageCell) && (messageObject = (chatMessageCell = (ChatMessageCell) view).getMessageObject()) != null && messageObject.type == 27) {
                messageObject.toggleChannelRecommendations();
                messageObject.forceUpdate = true;
                chatMessageCell.forceResetMessageObject();
                view.requestLayout();
                if (position >= 0) {
                    ChatActivity.this.chatAdapter.notifyItemChanged(position);
                    return;
                }
                return;
            }
            ChatActivity.this.createMenu(view, true, false, x, y, false);
        }

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

        public boolean hasDoubleTap(View view, int position) {
            TLRPC.ChatFull chatFull;
            if (((PlusSettings.doubleTapActionOut != PlusSettings.doubleTapAction && (view instanceof ChatMessageCell) && ((ChatMessageCell) view).getMessageObject().isOutOwner()) ? PlusSettings.doubleTapActionOut : PlusSettings.doubleTapAction) != 0) {
                return (!(view instanceof ChatMessageCell) || ((ChatMessageCell) view).getMessageObject().type == 16 || ((BaseFragment) ChatActivity.this).actionBar.isActionModeShowed() || ChatActivity.this.isSecretChat() || ChatActivity.this.isInScheduleMode()) ? false : true;
            }
            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 || !(view instanceof ChatMessageCell)) {
                return false;
            }
            ChatMessageCell chatMessageCell = (ChatMessageCell) view;
            return (chatMessageCell.getMessageObject().isSending() || chatMessageCell.getMessageObject().isEditing() || chatMessageCell.getMessageObject().type == 16 || ((BaseFragment) ChatActivity.this).actionBar.isActionModeShowed() || ChatActivity.this.isSecretChat() || ChatActivity.this.isInScheduleMode() || chatMessageCell.getMessageObject().isSponsored()) ? false : true;
        }

        public void onDoubleTap(View view, int position, float x, float y) {
            boolean z;
            TLRPC.ChatFull chatFull;
            TLRPC.ChatFull chatFull2;
            if (!(view instanceof ChatMessageCell) || ChatActivity.this.getParentActivity() == null || ChatActivity.this.isSecretChat() || ChatActivity.this.isInScheduleMode() || ChatActivity.this.chatMode == 5) {
                return;
            }
            ChatMessageCell chatMessageCell = (ChatMessageCell) view;
            MessageObject primaryMessageObject = chatMessageCell.getPrimaryMessageObject();
            int i = (PlusSettings.doubleTapActionOut == PlusSettings.doubleTapAction || !primaryMessageObject.isOutOwner()) ? PlusSettings.doubleTapAction : PlusSettings.doubleTapActionOut;
            if (i != 0) {
                ChatActivity.this.selectedObject = primaryMessageObject;
                ChatActivity.this.selectedObjectGroup = chatMessageCell.getCurrentMessagesGroup();
                ChatActivity.this.checkPlusAction(i);
                return;
            }
            if (primaryMessageObject.isSecretMedia() || primaryMessageObject.isExpiredStory() || primaryMessageObject.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) {
                    ChatActivity.this.selectReaction(primaryMessageObject, null, null, x, y, ReactionsLayoutInBubble.VisibleReaction.fromEmojicon(doubleTapReaction), true, false, false, false);
                    return;
                }
                return;
            }
            TLRPC.TL_availableReaction tL_availableReaction = (TLRPC.TL_availableReaction) ChatActivity.this.getMediaDataController().getReactionsMap().get(doubleTapReaction);
            if (tL_availableReaction == null || chatMessageCell.getMessageObject().isSponsored()) {
                return;
            }
            z = ChatActivity.this.dialog_id >= 0;
            if (!z && (chatFull = ChatActivity.this.chatInfo) != null) {
                z = ChatObject.reactionIsAvailable(chatFull, tL_availableReaction.reaction);
            }
            if (z) {
                ChatActivity.this.selectReaction(primaryMessageObject, null, null, x, y, ReactionsLayoutInBubble.VisibleReaction.fromEmojicon(tL_availableReaction), true, false, false, false);
            }
        }
    }

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

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

        public ChatActivityEnterViewDelegate() {
        }

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

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

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

        public void onMessageSend(CharSequence message, boolean notify, int scheduleDate) {
            MessagePreviewParams messagePreviewParams;
            MessagePreviewParams.Messages messages;
            TLRPC.Message message2;
            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(message);
            }
            boolean z = false;
            if (scheduleDate != 0) {
                if (ChatActivity.this.scheduledMessagesCount == -1) {
                    ChatActivity.this.scheduledMessagesCount = 0;
                }
                if (message != null) {
                    ChatActivity.this.scheduledMessagesCount++;
                }
                MessagePreviewParams messagePreviewParams2 = ChatActivity.this.messagePreviewParams;
                if (messagePreviewParams2 != null && (messages2 = messagePreviewParams2.forwardMessages) != null && !messages2.messages.isEmpty()) {
                    ChatActivity.this.scheduledMessagesCount += ChatActivity.this.messagePreviewParams.forwardMessages.messages.size();
                }
                ChatActivity.this.updateScheduledInterface(false);
            }
            if (!TextUtils.isEmpty(message) && (messagePreviewParams = ChatActivity.this.messagePreviewParams) != null && (messages = messagePreviewParams.forwardMessages) != null && !messages.messages.isEmpty() && ChatActivity.this.messagePreviewParams.quote == null) {
                ArrayList arrayList = new ArrayList();
                ChatActivity.this.messagePreviewParams.forwardMessages.getSelectedMessages(arrayList);
                boolean z2 = arrayList.size() > 0;
                TLRPC.Peer peer = ChatActivity.this.getMessagesController().getPeer(ChatActivity.this.dialog_id);
                int i = 0;
                while (true) {
                    if (i >= arrayList.size()) {
                        z = z2;
                        break;
                    }
                    MessageObject messageObject = (MessageObject) arrayList.get(i);
                    if (messageObject != null && (message2 = messageObject.messageOwner) != null && !MessageObject.peersEqual(message2.peer_id, peer)) {
                        break;
                    } else {
                        i++;
                    }
                }
                if (z) {
                    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 chatActivity2 = ChatActivity.this;
                if (!chatActivity2.isTopic && chatActivity2.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(notify, scheduleDate, 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(message) || ChatActivity.this.messages == null) {
                return;
            }
            for (int i2 = 1; i2 < Math.min(5, ChatActivity.this.messages.size()); i2++) {
                MessageObject messageObject2 = ChatActivity.this.messages.get(i2);
                if (messageObject2 != null && !messageObject2.isOutOwner() && ((messageObject2.isVoice() || messageObject2.isRoundVideo()) && messageObject2.isContentUnread())) {
                    TranscribeButton.showOffTranscribe(messageObject2);
                }
            }
        }

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

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

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

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

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

        public void onUpdateSlowModeButton(View button, boolean show, CharSequence time) {
            ChatActivity.this.showSlowModeHint(button, show, time);
            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 boolean checkCanRemoveRestrictionsByBoosts() {
            return ChatActivity.this.checkCanRemoveRestrictionsByBoosts();
        }

        public void onTextSelectionChanged(int start, int end) {
            if (ChatActivity.this.editTextItem == null) {
                return;
            }
            final ActionBarMenu createMenu = ((BaseFragment) ChatActivity.this).actionBar.createMenu();
            if (ChatActivity.this.suggestEmojiPanel != null) {
                ChatActivity.this.suggestEmojiPanel.onTextSelectionChanged(start, end);
            }
            if (end - start > 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.reportType < 0))) {
                            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);
                            }
                        } else {
                            ValueAnimator ofFloat = ValueAnimator.ofFloat(AndroidUtilities.dp(48.0f), 0.0f);
                            ofFloat.setDuration(220L);
                            ofFloat.setInterpolator(CubicBezierInterpolator.DEFAULT);
                            ofFloat.addListener(new AnimatorListenerAdapter() {
                                @Override
                                public void onAnimationStart(Animator animation) {
                                    ((BaseFragment) ChatActivity.this).actionBar.setMenuOffsetSuppressed(true);
                                    ChatActivity.this.checkEditTextItemMenu();
                                    ChatActivity.this.editTextItem.setVisibility(0);
                                    createMenu.translateXItems(AndroidUtilities.dp(48.0f));
                                }

                                @Override
                                public void onAnimationEnd(Animator animation) {
                                    ((BaseFragment) ChatActivity.this).actionBar.setMenuOffsetSuppressed(false);
                                }
                            });
                            ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                                @Override
                                public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                                    ChatActivity.ChatActivityEnterViewDelegate.lambda$onTextSelectionChanged$0(ActionBarMenu.this, valueAnimator);
                                }
                            });
                            ofFloat.start();
                        }
                    }
                }
                ChatActivity.this.editTextStart = start;
                ChatActivity.this.editTextEnd = end;
                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.reportType < 0))) {
                        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);
                            return;
                        }
                        return;
                    }
                    ValueAnimator ofFloat2 = ValueAnimator.ofFloat(0.0f, AndroidUtilities.dp(48.0f));
                    ofFloat2.setDuration(220L);
                    ofFloat2.setInterpolator(CubicBezierInterpolator.DEFAULT);
                    ofFloat2.addListener(new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationStart(Animator animation) {
                            ((BaseFragment) ChatActivity.this).actionBar.setMenuOffsetSuppressed(true);
                            ChatActivityEnterViewDelegate.this.isEditTextItemVisibilitySuppressed = true;
                        }

                        @Override
                        public void onAnimationEnd(Animator animation) {
                            ChatActivity.this.editTextItem.setVisibility(8);
                            createMenu.translateXItems(0.0f);
                            ((BaseFragment) ChatActivity.this).actionBar.setMenuOffsetSuppressed(false);
                            ChatActivityEnterViewDelegate.this.isEditTextItemVisibilitySuppressed = false;
                        }
                    });
                    ofFloat2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                        @Override
                        public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                            ChatActivity.ChatActivityEnterViewDelegate.lambda$onTextSelectionChanged$1(ActionBarMenu.this, valueAnimator);
                        }
                    });
                    ofFloat2.start();
                }
            }
        }

        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 onTextChanged(final CharSequence text, boolean bigChange, boolean fromDraft) {
            MediaController.getInstance().setInputFieldHasText(!TextUtils.isEmpty(text) || ChatActivity.this.chatActivityEnterView.isEditingMessage());
            MentionsContainerView mentionsContainerView = ChatActivity.this.mentionContainer;
            if (mentionsContainerView != null && mentionsContainerView.getAdapter() != null) {
                ChatActivity.this.mentionContainer.getAdapter().lambda$searchUsernameOrHashtag$7(text, 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 (bigChange) {
                    ChatActivity.this.searchLinks(text, true);
                } else {
                    ChatActivity.this.checkEditLinkRemoved(text);
                    ChatActivity.this.waitingForCharaterEnterRunnable = new Runnable() {
                        @Override
                        public void run() {
                            if (this == ChatActivity.this.waitingForCharaterEnterRunnable) {
                                ChatActivity.this.searchLinks(text, 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 (fromDraft) {
                return;
            }
            if ((ChatActivity.this.scheduledOrNoSoundHint != null && ChatActivity.this.scheduledOrNoSoundHint.getVisibility() == 0) || (ChatActivity.this.scheduledHint != null && ChatActivity.this.scheduledHint.getVisibility() == 0)) {
                ChatActivity.this.hideSendButtonHints();
            } else {
                ChatActivity.this.showScheduledHint();
            }
        }

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

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

        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 onMessageEditEnd(boolean loading) {
            boolean z;
            if (ChatActivity.this.chatListItemAnimator != null) {
                ChatActivity chatActivity = ChatActivity.this;
                chatActivity.chatActivityEnterViewAnimateFromTop = chatActivity.chatActivityEnterView.getBackgroundTop();
                if (ChatActivity.this.chatActivityEnterViewAnimateFromTop != 0) {
                    ChatActivity.this.chatActivityEnterViewAnimateBeforeSending = true;
                }
            }
            if (loading) {
                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();
                z = true;
            } else {
                z = false;
            }
            ChatActivity.this.chatActivityEnterView.setAllowStickersAndGifs(true, true, true, z);
            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 lambda$onMessageEditEnd$2() {
            ChatActivity.this.hideFieldPanel(true);
        }

        public void onWindowSizeChanged(int size) {
            if (size < 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.suggestEmojiPanel.setVisibility(0);
                }
            }
            ChatActivity.this.allowContextBotPanel = !r0.chatActivityEnterView.isPopupShowing();
            int i = size + (ChatActivity.this.chatActivityEnterView.isPopupShowing() ? 65536 : 0);
            if (this.lastSize != i) {
                ChatActivity.this.chatActivityEnterViewAnimateFromTop = 0;
                ChatActivity.this.chatActivityEnterViewAnimateBeforeSending = false;
            }
            this.lastSize = i;
        }

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

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

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

        public void needStartRecordVideo(int state, boolean notify, int scheduleDate, int ttl, long effectId) {
            ChatActivity.this.checkInstantCameraView();
            InstantCameraView instantCameraView = ChatActivity.this.instantCameraView;
            if (instantCameraView != null) {
                if (state == 0) {
                    instantCameraView.showCamera(false);
                    ChatActivity.this.chatListView.stopScroll();
                    ChatActivity.this.chatAdapter.updateRowsSafe();
                } else if (state == 1 || state == 3 || state == 4) {
                    instantCameraView.send(state, notify, scheduleDate, ttl, effectId);
                } else if (state == 2 || state == 5) {
                    instantCameraView.cancel(state == 2);
                }
            }
        }

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

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

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

        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;
            if (mentionsContainerView != null) {
                mentionsContainerView.animate().alpha(ChatActivity.this.chatActivityEnterView.isStickersExpanded() ? 0.0f : 1.0f).setInterpolator(CubicBezierInterpolator.DEFAULT).start();
            }
            if (ChatActivity.this.suggestEmojiPanel != null) {
                ChatActivity.this.suggestEmojiPanel.setVisibility(0);
                ChatActivity.this.suggestEmojiPanel.animate().alpha(ChatActivity.this.chatActivityEnterView.isStickersExpanded() ? 0.0f : 1.0f).setInterpolator(CubicBezierInterpolator.DEFAULT).withEndAction(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.ChatActivityEnterViewDelegate.this.lambda$onStickersExpandedChange$3();
                    }
                }).start();
            }
        }

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

        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 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 void onSendLongClick() {
            if (ChatActivity.this.scheduledOrNoSoundHint != null) {
                ChatActivity.this.scheduledOrNoSoundHint.hide();
            }
            if (ChatActivity.this.scheduledHint != null) {
                ChatActivity.this.scheduledHint.hide();
            }
        }

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

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

        public void bottomPanelTranslationYChanged(float translation) {
            if (translation != 0.0f) {
                ChatActivity.this.wasManualScroll = true;
            }
            ChatActivity chatActivity = ChatActivity.this;
            chatActivity.bottomPanelTranslationY = chatActivity.chatActivityEnterView.panelAnimationInProgress() ? ChatActivity.this.chatActivityEnterView.getEmojiPadding() - translation : 0.0f;
            ChatActivity chatActivity2 = ChatActivity.this;
            chatActivity2.bottomPanelTranslationYReverse = chatActivity2.chatActivityEnterView.panelAnimationInProgress() ? translation : 0.0f;
            ChatActivity.this.chatActivityEnterView.setTranslationY(translation);
            ChatActivity.this.mentionContainer.setTranslationY(translation);
            ChatActivity chatActivity3 = ChatActivity.this;
            chatActivity3.contentView.setEmojiOffset(chatActivity3.chatActivityEnterView.panelAnimationInProgress(), ChatActivity.this.bottomPanelTranslationY);
            float topViewTranslation = translation + 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 void prepareMessageSending() {
            ChatActivity.this.waitingForSendingMessageLoad = true;
        }

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

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

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

        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 ReplyQuote getReplyQuote() {
            return ChatActivity.this.replyingQuote;
        }
    }

    public final void checkPlusAction(int option) {
        ArrayList<MessageObject> arrayList;
        BlurredFrameLayout blurredFrameLayout;
        TLRPC.Chat chat;
        MessageObject.GroupedMessages groupedMessages;
        TLRPC.User user;
        if (this.disableAction) {
            return;
        }
        boolean z = true;
        this.disableAction = true;
        MessageObject messageObject = this.selectedObject;
        boolean z2 = (messageObject.type == 0 || messageObject.isDice() || this.selectedObject.isAnimatedEmoji() || getMessageCaption(this.selectedObject, this.selectedObjectGroup) != null) && !getMessagesController().isChatNoForwards(this.currentChat);
        switch (option) {
            case 1:
                MessageObject messageObject2 = this.selectedObject;
                if (messageObject2.type == 0 || messageObject2.isDice() || this.selectedObject.isAnimatedEmoji() || getMessageCaption(this.selectedObject, this.selectedObjectGroup) != null) {
                    processSelectedOption(MessagesController.getGlobalMainSettings().getBoolean("translate_button", false) ? 29 : 62);
                    z = false;
                    break;
                }
                break;
            case 2:
                if (this.chatMode != 1 && (((arrayList = this.threadMessageObjects) == null || !arrayList.contains(this.selectedObject)) && !this.selectedObject.isSponsored() && (getMessageType(this.selectedObject) != 1 || this.selectedObject.getDialogId() != this.mergeDialogId))) {
                    MessageObject messageObject3 = this.selectedObject;
                    if (!(messageObject3.messageOwner.action instanceof TLRPC.TL_messageActionSecureValuesSent) && ((this.currentEncryptedChat != null || messageObject3.getId() >= 0) && (((blurredFrameLayout = this.bottomOverlayChat) == null || blurredFrameLayout.getVisibility() != 0) && ((chat = this.currentChat) == null || ((!ChatObject.isNotInChat(chat) || isThreadChat()) && ((!ChatObject.isChannel(this.currentChat) || ChatObject.canPost(this.currentChat) || this.currentChat.megagroup) && ChatObject.canSendMessages(this.currentChat))))))) {
                        showFieldPanelForReply(this.selectedObject);
                        z = false;
                        break;
                    }
                }
                break;
            case 3:
                if (z2) {
                    processSelectedOption(3);
                    z = false;
                    break;
                }
                break;
            case 4:
                if (!getMessagesController().isChatNoForwards(this.currentChat)) {
                    processSelectedOption(97);
                    z = false;
                    break;
                }
                break;
            case 5:
            case 6:
                if (!getMessagesController().isChatNoForwards(this.currentChat)) {
                    processSelectedOption((PlusSettings.doubleTapAction == 5 || option == 5) ? 111 : 2);
                    z = false;
                    break;
                }
                break;
            case 7:
                if (!getMessagesController().isChatNoForwards(this.currentChat)) {
                    processSelectedOption(98);
                    z = false;
                    break;
                }
                break;
            case 8:
                processSelectedOption(85);
                z = false;
                break;
            case 9:
                if (this.selectedObject.canDeleteMessage(this.chatMode == 1, this.currentChat)) {
                    processSelectedOption(1);
                    z = false;
                    break;
                }
                break;
            case 10:
                boolean z3 = (!this.selectedObject.canEditMessage(this.currentChat) || this.chatActivityEnterView.hasAudioToSend() || this.selectedObject.getDialogId() == this.mergeDialogId) ? false : true;
                if (z3 && (groupedMessages = this.selectedObjectGroup) != null) {
                    int size = groupedMessages.messages.size();
                    int i = 0;
                    for (int i2 = 0; i2 < size; i2++) {
                        MessageObject messageObject4 = (MessageObject) this.selectedObjectGroup.messages.get(i2);
                        if (i2 == 0 || !TextUtils.isEmpty(messageObject4.caption)) {
                            this.selectedObjectToEditCaption = messageObject4;
                            if (!TextUtils.isEmpty(messageObject4.caption)) {
                                i++;
                            }
                        }
                    }
                    z3 = i < 2;
                }
                if (z3) {
                    processSelectedOption(12);
                    z = false;
                    break;
                }
                break;
            case 11:
                if (this.chatMode != 1) {
                    MessageObject messageObject5 = this.selectedObject;
                    if (messageObject5.contentType == 0 && messageObject5.getId() > 0 && !this.selectedObject.isOut() && (this.currentChat != null || ((user = this.currentUser) != null && user.bot))) {
                        processSelectedOption(23);
                        z = false;
                        break;
                    }
                }
                break;
            case 12:
                MessageObject messageObject6 = this.selectedObject;
                if (messageObject6.contentType == 7 || messageObject6.mediaExists) {
                    processSelectedOption(92);
                    z = false;
                    break;
                }
                break;
            default:
                z = false;
                break;
        }
        if (z) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.lambda$checkPlusAction$7();
                }
            });
        }
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$checkPlusAction$8();
            }
        }, 500L);
    }

    public static void lambda$checkPlusAction$7() {
        PlusUtils.showToast(LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred));
    }

    public void lambda$checkPlusAction$8() {
        this.disableAction = false;
    }

    public void lambda$new$9() {
        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("ScheduledOrNoSoundHint", 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$10() {
        ChatActivityEnterView chatActivityEnterView;
        View sendButton;
        if (getParentActivity() == null || ((BaseFragment) this).fragmentView == null || (chatActivityEnterView = this.chatActivityEnterView) == null || this.forwardingPreviewView != null || (sendButton = 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("ScheduledHint", 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 ChatActivity(Bundle args) {
        super(args);
        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.hideDateDelay = 500;
        this.businessLink = null;
        this.scheduledMessagesCount = -1;
        this.reportType = -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.allowContextBotPanelSecond = true;
        this.paused = true;
        this.firstOpen = true;
        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.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 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);
            }

            @Override
            public int getColor(int key) {
                return ChatActivity.this.getThemedColor(key);
            }
        });
        this.skeletonMatrix = new Matrix();
        this.skeletonOutlinePaint = new Paint(1);
        this.skeletonOutlineMatrix = new Matrix();
        this.skeletonOutlinePaint.setStyle(Paint.Style.STROKE);
        this.skeletonOutlinePaint.setStrokeWidth(AndroidUtilities.dp(1.0f));
        this.startLoadFromMessageOffset = Integer.MAX_VALUE;
        this.startFromVideoTimestamp = -1;
        this.returnToMessageIdStack = new Stack<>();
        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.scrimPopupWindowHideDimOnDismiss = true;
        this.updateDeleteItemRunnable = new Runnable() {
            @Override
            public void run() {
                String formatPluralString;
                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));
                if (max < 86400) {
                    formatPluralString = AndroidUtilities.formatDuration(max, false);
                } else {
                    formatPluralString = LocaleController.formatPluralString("Days", Math.round(max / 86400.0f), new Object[0]);
                }
                ChatActivity.this.menuDeleteItem.setSubtext(LocaleController.formatString("AutoDeleteIn", R.string.AutoDeleteIn, new Object[]{formatPluralString}));
                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 id, int currentAccount, Object[] args2) {
                if (id == NotificationCenter.didReceiveNewMessages) {
                    long longValue = ((Long) args2[0]).longValue();
                    if (ChatActivity.this.firstLoading && longValue == ChatActivity.this.dialog_id) {
                        return true;
                    }
                }
                return false;
            }
        };
        this.fixedKeyboardHeight = -1;
        this.photoViewerProvider = new PhotoViewer.EmptyPhotoViewerProvider() {
            @Override
            public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index, boolean needPreview) {
                return ChatActivity.this.getPlaceForPhoto(messageObject, fileLocation, needPreview, false);
            }
        };
        this.provider_user_id = 0L;
        this.provider_chat_id = 0L;
        this.provider = new PhotoViewer.EmptyPhotoViewerProvider() {
            @Override
            public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index, boolean needPreview) {
                TLRPC.Chat chat;
                TLRPC.ChatPhoto chatPhoto;
                TLRPC.FileLocation fileLocation2;
                TLRPC.User user;
                TLRPC.UserProfilePhoto userProfilePhoto;
                if (fileLocation == null) {
                    return null;
                }
                if (ChatActivity.this.provider_user_id == 0 ? ChatActivity.this.provider_chat_id == 0 || (chat = MessagesController.getInstance(((BaseFragment) ChatActivity.this).currentAccount).getChat(Long.valueOf(ChatActivity.this.provider_chat_id))) == null || (chatPhoto = chat.photo) == null || (fileLocation2 = chatPhoto.photo_big) == null : (user = ChatActivity.this.getMessagesController().getUser(Long.valueOf(ChatActivity.this.provider_user_id))) == null || (userProfilePhoto = user.photo) == null || (fileLocation2 = userProfilePhoto.photo_big) == null) {
                    fileLocation2 = null;
                }
                if (fileLocation2 == null || fileLocation2.local_id != fileLocation.local_id || fileLocation2.volume_id != fileLocation.volume_id || fileLocation2.dc_id != fileLocation.dc_id) {
                    return null;
                }
                int[] iArr = new int[2];
                ChatActivity.this.avatarImage.getLocationInWindow(iArr);
                PhotoViewer.PlaceProviderObject placeProviderObject = new PhotoViewer.PlaceProviderObject();
                placeProviderObject.viewX = iArr[0];
                placeProviderObject.viewY = iArr[1] - (Build.VERSION.SDK_INT < 21 ? AndroidUtilities.statusBarHeight : 0);
                placeProviderObject.parentView = ChatActivity.this.avatarImage;
                placeProviderObject.imageReceiver = ChatActivity.this.avatarImage.getImageReceiver();
                if (ChatActivity.this.provider_user_id != 0) {
                    placeProviderObject.dialogId = ChatActivity.this.provider_user_id;
                } else if (ChatActivity.this.provider_chat_id != 0) {
                    placeProviderObject.dialogId = -ChatActivity.this.provider_chat_id;
                }
                placeProviderObject.thumb = placeProviderObject.imageReceiver.getBitmapSafe();
                placeProviderObject.size = -1L;
                placeProviderObject.radius = ChatActivity.this.avatarImage.getImageReceiver().getRoundRadius();
                placeProviderObject.scale = ChatActivity.this.avatarImage.getScaleX();
                return placeProviderObject;
            }

            @Override
            public void willHidePhotoViewer() {
                ChatActivity.this.avatarImage.getImageReceiver().setVisible(true, true);
            }
        };
        this.botContextProvider = new PhotoViewer.EmptyPhotoViewerProvider() {
            @Override
            public org.telegram.ui.PhotoViewer.PlaceProviderObject getPlaceForPhoto(org.telegram.messenger.MessageObject r5, org.telegram.tgnet.TLRPC.FileLocation r6, int 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):org.telegram.ui.PhotoViewer$PlaceProviderObject");
            }

            @Override
            public void sendButtonPressed(int index, VideoEditedInfo videoEditedInfo, boolean notify, int scheduleDate, boolean forceDocument) {
                if (index < 0 || index >= ChatActivity.this.botContextResults.size()) {
                    return;
                }
                ChatActivity chatActivity = ChatActivity.this;
                chatActivity.lambda$createView$41((TLRPC.BotInlineResult) chatActivity.botContextResults.get(index), notify, scheduleDate);
            }
        };
        new ArrayList();
        this.markedMessages = new ArrayList<>();
        this.actionModePadding = 44;
        this.onItemLongClickListener = new RecyclerListView.OnItemLongClickListenerExtended() {
            public void onLongClickRelease() {
                RecyclerListView.OnItemLongClickListenerExtended.-CC.$default$onLongClickRelease(this);
            }

            public void onMove(float f, float f2) {
                RecyclerListView.OnItemLongClickListenerExtended.-CC.$default$onMove(this, f, f2);
            }

            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");
            }
        };
        this.onItemClickListener = new AnonymousClass12();
        this.chatScrollHelperCallback = new ChatScrollCallback();
        this.showScheduledOrNoSoundRunnable = new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$new$9();
            }
        };
        this.showScheduledHintRunnable = new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$new$10();
            }
        };
        this.filledEditTextItemMenu = false;
        this.checkTranslationRunnable = new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$new$187();
            }
        };
        this.fromCache = true;
        this.chatDialogOffset = 0;
        this.updateAgain = false;
        this.preventReopenSearchWithText = false;
    }

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

    public void lambda$onFragmentCreate$11(MessagesStorage messagesStorage, long j, CountDownLatch countDownLatch) {
        this.currentChat = messagesStorage.getChat(j);
        countDownLatch.countDown();
    }

    public void lambda$onFragmentCreate$12(Boolean bool) {
        boolean booleanValue = bool.booleanValue();
        this.waitingForGetDifference = booleanValue;
        if (booleanValue) {
            return;
        }
        firstLoadMessages();
    }

    public void lambda$onFragmentCreate$13(MessagesStorage messagesStorage, long j, CountDownLatch countDownLatch) {
        this.currentUser = messagesStorage.getUser(j);
        countDownLatch.countDown();
    }

    public void lambda$onFragmentCreate$14(MessagesStorage messagesStorage, int i, CountDownLatch countDownLatch) {
        this.currentEncryptedChat = messagesStorage.getEncryptedChat(i);
        countDownLatch.countDown();
    }

    public void lambda$onFragmentCreate$15(MessagesStorage messagesStorage, CountDownLatch countDownLatch) {
        this.currentUser = messagesStorage.getUser(this.currentEncryptedChat.user_id);
        countDownLatch.countDown();
    }

    public void lambda$onFragmentCreate$16() {
        ArrayList arrayList = (ArrayList) PlusSettings.markedListMessages.get(this.dialog_id);
        if (arrayList == null || arrayList.size() < this.markedMessages.size()) {
            loadMarkedMessages();
        }
    }

    public void lambda$onFragmentCreate$17(long j) {
        getMediaDataController().loadBotInfo(j, j, true, ((BaseFragment) this).classGuid);
    }

    public void lambda$onFragmentCreate$20() {
        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("JoinByPeekChannelText", R.string.JoinByPeekChannelText));
            builder.setTitle(LocaleController.getString("JoinByPeekChannelTitle", R.string.JoinByPeekChannelTitle));
        } else {
            builder.setMessage(LocaleController.getString("JoinByPeekGroupText", R.string.JoinByPeekGroupText));
            builder.setTitle(LocaleController.getString("JoinByPeekGroupTitle", R.string.JoinByPeekGroupTitle));
        }
        builder.setPositiveButton(LocaleController.getString("JoinByPeekJoin", R.string.JoinByPeekJoin), new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                ChatActivity.this.lambda$onFragmentCreate$18(dialogInterface, i);
            }
        });
        builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                ChatActivity.this.lambda$onFragmentCreate$19(dialogInterface, i);
            }
        });
        showDialog(builder.create());
    }

    public void lambda$onFragmentCreate$18(DialogInterface dialogInterface, int i) {
        UnreadCounterTextView unreadCounterTextView = this.bottomOverlayChatText;
        if (unreadCounterTextView != null) {
            unreadCounterTextView.callOnClick();
        }
    }

    public void lambda$onFragmentCreate$19(DialogInterface dialogInterface, int i) {
        lambda$onBackPressed$358();
    }

    public void updateSearchingHashtag(String hashtag) {
        if (this.chatMode == 7 && !TextUtils.equals(this.searchingHashtag, hashtag)) {
            showMessagesSearchListView(true);
            this.searchingHashtag = hashtag;
            this.searchingQuery = hashtag;
            clearChatData(true);
            this.startMessageAppearTransitionMs = 0L;
            this.firstMessagesLoaded = false;
            HashtagSearchController.getInstance(((BaseFragment) this).currentAccount).clearSearchResults(this.searchType);
            this.messagesSearchAdapter.notifyDataSetChanged();
            updateSearchListEmptyView();
            this.hashtagSearchEmptyView.showProgress(true);
            firstLoadMessages();
        }
    }

    public final void firstLoadMessages() {
        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 i = ((BaseFragment) this).classGuid;
            int i2 = this.searchType;
            int i3 = this.lastLoadIndex;
            this.lastLoadIndex = i3 + 1;
            hashtagSearchController.searchHashtag(str, i, i2, i3);
        } else if (this.startLoadFromDate != 0) {
            MessagesController messagesController = getMessagesController();
            long j = this.dialog_id;
            long j2 = this.mergeDialogId;
            int i4 = this.startLoadFromDate;
            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, i4, true, 0, i5, 4, 0, i6, j3, i7, i8, this.isTopic);
        } else if (this.startLoadFromMessageId != 0 && (!isThreadChat() || this.startLoadFromMessageId == this.highlightMessageId || this.isTopic)) {
            int i9 = this.migrated_to;
            if (i9 != 0) {
                this.mergeDialogId = i9;
                MessagesController messagesController2 = getMessagesController();
                long j4 = this.mergeDialogId;
                boolean z = this.loadInfo;
                int i10 = this.initialMessagesSize;
                int i11 = this.startLoadFromMessageId;
                int i12 = ((BaseFragment) this).classGuid;
                int i13 = this.chatMode;
                long j5 = this.threadMessageId;
                int i14 = this.replyMaxReadId;
                int i15 = this.lastLoadIndex;
                this.lastLoadIndex = i15 + 1;
                messagesController2.loadMessages(j4, 0L, z, i10, i11, 0, true, 0, i12, 3, 0, i13, j5, i14, i15, this.isTopic);
            } else {
                MessagesController messagesController3 = getMessagesController();
                long j6 = this.dialog_id;
                long j7 = this.mergeDialogId;
                boolean z2 = this.loadInfo;
                int i16 = this.initialMessagesSize;
                int i17 = this.startLoadFromMessageId;
                int i18 = ((BaseFragment) this).classGuid;
                int i19 = this.chatMode;
                long j8 = this.threadMessageId;
                int i20 = this.replyMaxReadId;
                int i21 = this.lastLoadIndex;
                this.lastLoadIndex = i21 + 1;
                messagesController3.loadMessages(j6, j7, z2, i16, i17, 0, true, 0, i18, 3, 0, i19, j8, i20, i21, this.isTopic);
            }
        } else if (this.historyPreloaded) {
            this.lastLoadIndex++;
        } else {
            MessagesController messagesController4 = getMessagesController();
            long j9 = this.dialog_id;
            long j10 = this.mergeDialogId;
            boolean z3 = this.loadInfo;
            int i22 = this.initialMessagesSize;
            int i23 = this.startLoadFromMessageId;
            int i24 = ((BaseFragment) this).classGuid;
            int i25 = this.chatMode;
            long j11 = this.threadMessageId;
            int i26 = this.replyMaxReadId;
            int i27 = this.lastLoadIndex;
            this.lastLoadIndex = i27 + 1;
            messagesController4.loadMessages(j9, j10, z3, i22, i23, 0, true, 0, i24, 2, 0, i25, j11, i26, i27, this.isTopic);
        }
        int i28 = this.chatMode;
        if (i28 == 0 || (i28 == 3 && getSavedDialogId() == getUserConfig().getClientUserId())) {
            if (!isThreadChat() || this.isTopic) {
                this.waitingForLoad.add(Integer.valueOf(this.lastLoadIndex));
                MessagesController messagesController5 = getMessagesController();
                long j12 = this.dialog_id;
                long j13 = this.mergeDialogId;
                int i29 = ((BaseFragment) this).classGuid;
                long j14 = this.chatMode == 3 ? 0L : this.threadMessageId;
                int i30 = this.replyMaxReadId;
                int i31 = this.lastLoadIndex;
                this.lastLoadIndex = i31 + 1;
                messagesController5.loadMessages(j12, j13, false, 1, 0, 0, true, 0, i29, 2, 0, 1, j14, i30, i31, this.isTopic);
            }
        }
    }

    public final void fillInviterId(boolean load) {
        TLRPC.Chat chat = this.currentChat;
        if (chat == null || this.chatInfo == null || ChatObject.isNotInChat(chat) || this.currentChat.creator) {
            return;
        }
        TLRPC.ChatFull chatFull = this.chatInfo;
        long j = chatFull.inviterId;
        if (j != 0) {
            this.chatInviterId = j;
            return;
        }
        TLRPC.ChatParticipants chatParticipants = chatFull.participants;
        if (chatParticipants != null) {
            TLRPC.ChatParticipant chatParticipant = chatParticipants.self_participant;
            if (chatParticipant != null) {
                this.chatInviterId = chatParticipant.inviter_id;
                return;
            }
            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) {
                    this.chatInviterId = chatParticipant2.inviter_id;
                    return;
                }
            }
        }
        if (load && this.chatInviterId == 0) {
            getMessagesController().checkChatInviter(this.currentChat.id, false);
        }
    }

    public final 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 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) this).parentLayout.getFragmentStack().get(i);
            if (baseFragment != this && (baseFragment instanceof ChatActivity) && ((ChatActivity) baseFragment).dialog_id == this.dialog_id) {
                break;
            }
            i++;
        }
        return i - indexOf;
    }

    public void onBeginSlide() {
        super.onBeginSlide();
        ChatSelectionReactionMenuOverlay chatSelectionReactionMenuOverlay = this.selectionReactionsOverlay;
        if (chatSelectionReactionMenuOverlay == null || !chatSelectionReactionMenuOverlay.isVisible()) {
            return;
        }
        this.selectionReactionsOverlay.setHiddenByScroll(true);
    }

    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.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.didReceiveNewMessages);
        getNotificationCenter().removeObserver(this, NotificationCenter.closeChats);
        getNotificationCenter().removeObserver(this, NotificationCenter.messagesRead);
        getNotificationCenter().removeObserver(this, NotificationCenter.threadMessagesRead);
        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.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.factCheckLoaded);
        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();
        }
        getNotificationCenter().removeObserver(this, NotificationCenter.plusSettingsChanged);
        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;
        }
    }

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

        public ChatActivityTextSelectionHelper() {
        }

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

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

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

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

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

        @Override
        public boolean canShowQuote() {
            ChatActivity chatActivity;
            Cell cell;
            return (this.isFactCheck || (chatActivity = this.chatActivity) == null || chatActivity.getCurrentEncryptedChat() != null || this.chatActivity.textSelectionHelper.isDescription || (cell = this.selectedView) == 0 || ((ChatMessageCell) cell).getMessageObject() == null || ((ChatMessageCell) this.selectedView).getMessageObject().type == 23 || ((ChatMessageCell) this.selectedView).getMessageObject().isVoiceTranscriptionOpen() || ((ChatMessageCell) this.selectedView).getMessageObject().isInvoice() || this.chatActivity.getMessagesController().getTranslateController().isTranslatingDialog(this.chatActivity.dialog_id) || UserObject.isService(this.chatActivity.dialog_id)) ? false : true;
        }

        @Override
        public boolean canCopy() {
            Cell cell;
            ChatActivity chatActivity = this.chatActivity;
            return chatActivity == null || ((chatActivity.getDialogId() >= 0 || !this.chatActivity.getMessagesController().isChatNoForwards(-this.chatActivity.getDialogId())) && ((cell = this.selectedView) == 0 || ((ChatMessageCell) cell).getMessageObject() == null || ((ChatMessageCell) this.selectedView).getMessageObject().messageOwner == null || !((ChatMessageCell) this.selectedView).getMessageObject().messageOwner.noforwards));
        }

        @Override
        public void onQuoteClick(MessageObject messageObject, int start, int end, CharSequence text) {
            ChatActivity chatActivity;
            MessageObject.GroupedMessages group;
            if (messageObject == null || (chatActivity = this.chatActivity) == null) {
                return;
            }
            int min = Math.min(end, chatActivity.getMessagesController().quoteLengthMax + start);
            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, start, 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));
            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 android.view.View createView(final android.content.Context r43) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.createView(android.content.Context):android.view.View");
    }

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

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

        @Override
        public void onItemClick(final int id) {
            TLRPC.User user;
            TLRPC.ChatFull chatFull;
            ChatActivityEnterView chatActivityEnterView;
            TLRPC.User user2;
            if (id == -1) {
                if (((BaseFragment) ChatActivity.this).actionBar.isActionModeShowed()) {
                    ChatActivity.this.clearSelectionMode();
                    return;
                }
                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) || ChatActivity.this.checkIfEditingMessage(true)) {
                        return;
                    }
                    ChatActivity.this.lambda$onBackPressed$358();
                    return;
                }
            }
            if (id == 59) {
                if (ChatActivity.this.getUserConfig().getClientUserId() == ChatActivity.this.dialog_id) {
                    ChatActivity.this.getMessagesController().setSavedViewAs(true);
                    ChatActivity.this.avatarContainer.openProfile(false, true, true);
                    return;
                } else {
                    ChatActivity.this.getMessagesController().getTopicsController().toggleViewForumAsMessages(-ChatActivity.this.dialog_id, false);
                    TopicsFragment.prepareToSwitchAnimation(ChatActivity.this);
                    PlusSettings.removeFromTopicsAsMessagesList(ChatActivity.this.getDialogId());
                    return;
                }
            }
            if (id == 10) {
                SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
                long j = 0;
                for (int i = 1; i >= 0; i--) {
                    ArrayList arrayList = new ArrayList();
                    for (int i2 = 0; i2 < ChatActivity.this.selectedMessagesCanCopyIds[i].size(); i2++) {
                        arrayList.add(Integer.valueOf(ChatActivity.this.selectedMessagesCanCopyIds[i].keyAt(i2)));
                    }
                    if (ChatActivity.this.currentEncryptedChat == null) {
                        Collections.sort(arrayList);
                    } else {
                        Collections.sort(arrayList, Collections.reverseOrder());
                    }
                    for (int i3 = 0; i3 < arrayList.size(); i3++) {
                        MessageObject messageObject = (MessageObject) ChatActivity.this.selectedMessagesCanCopyIds[i].get(((Integer) arrayList.get(i3)).intValue());
                        if (spannableStringBuilder.length() != 0) {
                            spannableStringBuilder.append((CharSequence) "\n\n");
                        }
                        spannableStringBuilder.append(ChatActivity.this.getMessageContent(messageObject, j, arrayList.size() != 1 && ((user2 = ChatActivity.this.currentUser) == null || !user2.self)));
                        j = messageObject.getFromChatId();
                    }
                }
                if (spannableStringBuilder.length() != 0) {
                    AndroidUtilities.addToClipboard(spannableStringBuilder);
                    ChatActivity.this.createUndoView();
                    ChatActivity.this.undoView.showWithAction(0L, 58, (Runnable) null);
                }
                ChatActivity.this.clearSelectionMode();
                return;
            }
            if (id == 12) {
                if (ChatActivity.this.getParentActivity() == null) {
                    return;
                }
                ChatActivity.this.createDeleteMessagesAlert(null, null);
                return;
            }
            if (id == 11 || id == 111) {
                ChatActivity.QuoteForward = id == 111;
                ChatActivity.this.openForward(true);
                return;
            }
            if (id == 69) {
                ChatActivity.this.share();
                return;
            }
            if (id == 28) {
                if (ChatActivity.this.tagSelector == null) {
                    ChatActivity.this.showTagSelector();
                    return;
                } else {
                    ChatActivity.this.hideTagSelector();
                    return;
                }
            }
            if (id == 25) {
                final ArrayList arrayList2 = new ArrayList();
                for (int i4 = 1; i4 >= 0; i4--) {
                    for (int i5 = 0; i5 < ChatActivity.this.selectedMessagesIds[i4].size(); i5++) {
                        arrayList2.add((MessageObject) ChatActivity.this.selectedMessagesIds[i4].valueAt(i5));
                    }
                    ChatActivity.this.selectedMessagesIds[i4].clear();
                    ChatActivity.this.selectedMessagesCanCopyIds[i4].clear();
                    ChatActivity.this.selectedMessagesCanStarIds[i4].clear();
                }
                final boolean z = 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 i6) {
                        ChatActivity.AnonymousClass13.this.lambda$onItemClick$1(arrayList2, z, i6);
                    }
                });
                return;
            }
            if (id == 13) {
                if (ChatActivity.this.getParentActivity() == null) {
                    return;
                }
                ChatActivity chatActivity = ChatActivity.this;
                Activity parentActivity = chatActivity.getParentActivity();
                ChatActivity chatActivity2 = ChatActivity.this;
                chatActivity.showDialog(AlertsCreator.createTTLAlert(parentActivity, chatActivity2.currentEncryptedChat, chatActivity2.themeDelegate).create());
                return;
            }
            if (id == 15 || id == 16 || id == 26) {
                if (ChatActivity.this.getParentActivity() == null) {
                    return;
                }
                ChatActivity chatActivity3 = ChatActivity.this;
                TLRPC.ChatFull chatFull2 = chatActivity3.chatInfo;
                final boolean z2 = chatFull2 != null && chatFull2.can_delete_channel;
                if (id == 26 || (id == 15 && chatActivity3.currentEncryptedChat == null && (((user = chatActivity3.currentUser) != null && !UserObject.isUserSelf(user) && !UserObject.isDeleted(ChatActivity.this.currentUser)) || ((chatFull = ChatActivity.this.chatInfo) != null && chatFull.can_delete_channel)))) {
                    ChatActivity chatActivity4 = ChatActivity.this;
                    AlertsCreator.createClearDaysDialogAlert(chatActivity4, -1, chatActivity4.currentUser, chatActivity4.currentChat, z2, new AnonymousClass1(z2), ChatActivity.this.getResourceProvider());
                    return;
                } else {
                    ChatActivity chatActivity5 = ChatActivity.this;
                    AlertsCreator.createClearOrDeleteDialogAlert(chatActivity5, id == 15, chatActivity5.currentChat, chatActivity5.currentUser, chatActivity5.currentEncryptedChat != null, true, z2, new MessagesStorage.BooleanCallback() {
                        public final void run(boolean z3) {
                            ChatActivity.AnonymousClass13.this.lambda$onItemClick$2(id, z2, z3);
                        }
                    }, ChatActivity.this.themeDelegate);
                    return;
                }
            }
            if (id == 17) {
                ChatActivity chatActivity6 = ChatActivity.this;
                if (chatActivity6.currentUser == null || chatActivity6.getParentActivity() == null) {
                    return;
                }
                if (ChatActivity.this.addToContactsButton != null && ChatActivity.this.addToContactsButton.getTag() != null) {
                    ChatActivity chatActivity7 = ChatActivity.this;
                    chatActivity7.shareMyContact(((Integer) chatActivity7.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 (id == 18) {
                ChatActivity.this.toggleMute(false);
                return;
            }
            if (id == 24) {
                try {
                    ChatActivity chatActivity8 = ChatActivity.this;
                    if (chatActivity8.isTopic) {
                        chatActivity8.getMediaDataController().installShortcut(ChatActivity.this.getDialogId(), MediaDataController.SHORTCUT_TYPE_USER_OR_CHAT, ChatActivity.this.getTopicId());
                        return;
                    } else {
                        chatActivity8.getMediaDataController().installShortcut(ChatActivity.this.currentUser.id, MediaDataController.SHORTCUT_TYPE_USER_OR_CHAT);
                        return;
                    }
                } catch (Exception e) {
                    FileLog.e(e);
                    return;
                }
            }
            if (id == 29) {
                if (ChatObject.hasAdminRights(ChatActivity.this.currentChat)) {
                    BoostsActivity boostsActivity = new BoostsActivity(ChatActivity.this.dialog_id);
                    boostsActivity.setBoostsStatus(ChatActivity.this.boostsStatus);
                    ChatActivity.this.presentFragment(boostsActivity);
                    return;
                }
                ChatActivity.this.getNotificationCenter().postNotificationName(NotificationCenter.openBoostForUsersDialog, new Object[]{Long.valueOf(ChatActivity.this.dialog_id)});
                return;
            }
            if (id == 21) {
                Activity parentActivity2 = ChatActivity.this.getParentActivity();
                long j2 = ChatActivity.this.dialog_id;
                ChatActivity chatActivity9 = ChatActivity.this;
                AlertsCreator.createReportAlert(parentActivity2, j2, 0, 0, chatActivity9, chatActivity9.themeDelegate, (Runnable) null);
                return;
            }
            if (id == 22) {
                for (int i6 = 0; i6 < 2; i6++) {
                    for (int i7 = 0; i7 < ChatActivity.this.selectedMessagesCanStarIds[i6].size(); i7++) {
                        MessageObject messageObject2 = (MessageObject) ChatActivity.this.selectedMessagesCanStarIds[i6].valueAt(i7);
                        ChatActivity.this.getMediaDataController().addRecentSticker(2, messageObject2, messageObject2.getDocument(), (int) (System.currentTimeMillis() / 1000), !ChatActivity.this.hasUnfavedSelected);
                    }
                }
                ChatActivity.this.clearSelectionMode();
                return;
            }
            if (id == 23) {
                for (int i8 = 1; i8 >= 0; i8--) {
                    if (r9 == null && ChatActivity.this.selectedMessagesIds[i8].size() == 1) {
                        ArrayList arrayList3 = new ArrayList();
                        for (int i9 = 0; i9 < ChatActivity.this.selectedMessagesIds[i8].size(); i9++) {
                            arrayList3.add(Integer.valueOf(ChatActivity.this.selectedMessagesIds[i8].keyAt(i9)));
                        }
                        r9 = (MessageObject) ChatActivity.this.messagesDict[i8].get(((Integer) arrayList3.get(0)).intValue());
                    }
                    ChatActivity.this.selectedMessagesIds[i8].clear();
                    ChatActivity.this.selectedMessagesCanCopyIds[i8].clear();
                    ChatActivity.this.selectedMessagesCanStarIds[i8].clear();
                }
                ChatActivity.this.startEditingMessageObject(r9);
                ChatActivity.this.hideActionMode();
                ChatActivity.this.updatePinnedMessageView(true);
                ChatActivity.this.updateVisibleRows();
                return;
            }
            if (id == 64) {
                final QuickRepliesController.QuickReply findReply = QuickRepliesController.getInstance(((BaseFragment) ChatActivity.this).currentAccount).findReply(ChatActivity.this.getQuickReplyId());
                Context context = ChatActivity.this.getContext();
                int i10 = ((BaseFragment) ChatActivity.this).currentAccount;
                ChatActivity chatActivity10 = ChatActivity.this;
                QuickRepliesActivity.openRenameReplyAlert(context, i10, chatActivity10.quickReplyShortcut, findReply, chatActivity10.getResourceProvider(), false, new Utilities.Callback() {
                    public final void run(Object obj) {
                        ChatActivity.AnonymousClass13.this.lambda$onItemClick$3(findReply, (String) obj);
                    }
                });
                return;
            }
            if (id == 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$4(view);
                    }
                });
                ChatActivity.this.headerItem.toggleSubMenu(actionBarMenuSubItem, ChatActivity.this.attachItem.createView());
                return;
            }
            if (id == 30) {
                ChatActivity.this.getSendMessagesHelper().sendMessage(SendMessagesHelper.SendMessageParams.of("/help", ChatActivity.this.dialog_id, (MessageObject) null, (MessageObject) null, (TLRPC.WebPage) null, false, (ArrayList) null, (TLRPC.ReplyMarkup) null, (HashMap) null, true, 0, (MessageObject.SendAnimationData) null, false));
                return;
            }
            if (id == 31) {
                ChatActivity.this.getSendMessagesHelper().sendMessage(SendMessagesHelper.SendMessageParams.of("/settings", ChatActivity.this.dialog_id, (MessageObject) null, (MessageObject) null, (TLRPC.WebPage) null, false, (ArrayList) null, (TLRPC.ReplyMarkup) null, (HashMap) null, true, 0, (MessageObject.SendAnimationData) null, false));
                return;
            }
            if (id == 40) {
                ChatActivity chatActivity11 = ChatActivity.this;
                chatActivity11.lambda$openSearchWithText$363(chatActivity11.isSupportedTags() ? "" : null);
                return;
            }
            if (id == 62) {
                ChatActivity.this.getMessagesController().getTranslateController().setHideTranslateDialog(ChatActivity.this.getDialogId(), false, true);
                if (ChatActivity.this.getMessagesController().getTranslateController().toggleTranslatingDialog(ChatActivity.this.getDialogId(), true)) {
                    return;
                }
                ChatActivity.this.updateTopPanel(true);
                return;
            }
            if (id == 32 || id == 33) {
                ChatActivity chatActivity12 = ChatActivity.this;
                if (chatActivity12.currentUser == null || chatActivity12.getParentActivity() == null) {
                    return;
                }
                AlertDialog.Builder builder = new AlertDialog.Builder(ChatActivity.this.getParentActivity());
                builder.setTitle(UserObject.getUserName(ChatActivity.this.currentUser));
                ArrayList arrayList4 = new ArrayList();
                final ArrayList arrayList5 = new ArrayList();
                String str = ChatActivity.this.currentUser.phone;
                if (str != null && str.length() > 0) {
                    arrayList4.add(LocaleController.getString("PhoneMobile", R.string.PhoneMobile));
                    arrayList5.add(0);
                }
                arrayList4.add(LocaleController.getString("VoipInCallBranding", R.string.VoipInCallBranding));
                arrayList5.add(1);
                TLRPC.UserFull userFull = ChatActivity.this.userInfo;
                if (userFull != null && userFull.video_calls_available) {
                    arrayList4.add(LocaleController.getString("VoipInVideoCallBranding", R.string.VoipInVideoCallBranding));
                    arrayList5.add(2);
                }
                builder.setItems((CharSequence[]) arrayList4.toArray(new CharSequence[arrayList4.size()]), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i11) {
                        int intValue = ((Integer) arrayList5.get(i11)).intValue();
                        if (intValue == 0) {
                            try {
                                Intent intent = new Intent("android.intent.action.DIAL", Uri.parse("tel:+" + ChatActivity.this.currentUser.phone));
                                intent.addFlags(268435456);
                                ChatActivity.this.getParentActivity().startActivityForResult(intent, 500);
                                return;
                            } catch (Exception e2) {
                                FileLog.e("tmessages", e2);
                                return;
                            }
                        }
                        if (intValue >= 1) {
                            ChatActivity chatActivity13 = ChatActivity.this;
                            TLRPC.User user3 = chatActivity13.currentUser;
                            boolean z3 = false;
                            boolean z4 = intValue == 2;
                            TLRPC.UserFull userFull2 = chatActivity13.userInfo;
                            if (userFull2 != null && userFull2.video_calls_available) {
                                z3 = true;
                            }
                            VoIPHelper.startCall(user3, z4, z3, chatActivity13.getParentActivity(), ChatActivity.this.getMessagesController().getUserFull(ChatActivity.this.currentUser.id), ChatActivity.this.getAccountInstance());
                        }
                    }
                });
                ChatActivity.this.showDialog(builder.create());
                return;
            }
            if (id == 84) {
                if (ChatActivity.this.getParentActivity() == null) {
                    return;
                }
                if (((int) ChatActivity.this.dialog_id) < 0 && ((int) (ChatActivity.this.dialog_id >> 32)) != 1) {
                    AlertDialog.Builder builder2 = new AlertDialog.Builder(ChatActivity.this.getParentActivity());
                    builder2.setTitle(LocaleController.getString("AppName", R.string.AppName));
                    builder2.setMessage(LocaleController.getString("LeaveWithoutDeleteMsg", R.string.LeaveWithoutDeleteMsg));
                    builder2.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i11) {
                            ChatActivity.this.getMessagesController().deleteUserWithoutDeleteChat((int) (-ChatActivity.this.dialog_id), ChatActivity.this.getMessagesController().getUser(Long.valueOf(ChatActivity.this.getUserConfig().getClientUserId())), (TLRPC.ChatFull) null);
                            ChatActivity.this.lambda$onBackPressed$358();
                        }
                    });
                    builder2.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                    ChatActivity.this.showDialog(builder2.create());
                    return;
                }
                return;
            }
            if (id == 89) {
                if (!ChatActivity.this.canSelectMessages || ChatActivity.this.minSelectedMessageId <= 0 || ChatActivity.this.maxSelectedMessageId <= 0) {
                    return;
                }
                ChatActivity.this.selecting = true;
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public void run() {
                        MessageObject messageObject3;
                        int messageType;
                        long j3 = ChatActivity.this.minSelectedMessageId;
                        while (true) {
                            j3++;
                            if (j3 >= ChatActivity.this.maxSelectedMessageId) {
                                ((BaseFragment) ChatActivity.this).actionBar.getActionMode().getItem(89).setVisibility(8);
                                ChatActivity.this.updateActionModeTitle();
                                ChatActivity.this.updateVisibleRows();
                                ChatActivity chatActivity13 = ChatActivity.this;
                                chatActivity13.maxSelectedMessageId = -1L;
                                chatActivity13.minSelectedMessageId = -1L;
                                ChatActivity.this.canSelectMessages = false;
                                ChatActivity.this.selecting = false;
                                return;
                            }
                            int i11 = (int) j3;
                            if (ChatActivity.this.selectedMessagesIds[0].get(i11) == null && (messageObject3 = (MessageObject) ChatActivity.this.messagesDict[0].get(i11)) != null && (messageType = ChatActivity.this.getMessageType(messageObject3)) >= 2 && messageType != 20) {
                                ChatActivity.this.addToSelectedMessages(messageObject3, false);
                            }
                        }
                    }
                });
                return;
            }
            if (id == 83) {
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            ArrayList arrayList6 = new ArrayList();
                            int i11 = 1;
                            while (true) {
                                if (i11 < 0) {
                                    break;
                                }
                                ArrayList arrayList7 = new ArrayList();
                                for (int i12 = 0; i12 < ChatActivity.this.selectedMessagesIds[i11].size(); i12++) {
                                    arrayList7.add(Integer.valueOf(ChatActivity.this.selectedMessagesIds[i11].keyAt(i12)));
                                }
                                Collections.sort(arrayList7);
                                for (int i13 = 0; i13 < arrayList7.size(); i13++) {
                                    Integer num = (Integer) arrayList7.get(i13);
                                    MessageObject messageObject3 = (MessageObject) ChatActivity.this.selectedMessagesIds[i11].get(num.intValue());
                                    if (messageObject3 != null && num.intValue() > 0) {
                                        arrayList6.add(messageObject3);
                                    }
                                }
                                i11--;
                            }
                            if (Theme.plusSaveToCloudQuote) {
                                ChatActivity.this.getSendMessagesHelper().sendMessage(arrayList6, ChatActivity.this.getUserConfig().getClientUserId(), false, false, true, 0);
                            } else {
                                ChatActivity.this.getSendMessagesHelper().processForwardFromMyName(arrayList6, ChatActivity.this.getUserConfig().getClientUserId(), true, 0);
                            }
                            int size = arrayList6.size();
                            Toast.makeText(ChatActivity.this.getParentActivity(), size > 1 ? LocaleController.formatString("MessagesSaved", R.string.MessagesSaved, new Object[]{Integer.valueOf(size)}) : LocaleController.getString("MessageSaved", R.string.MessageSaved), 0).show();
                            for (int i14 = 1; i14 >= 0; i14--) {
                                ChatActivity.this.selectedMessagesIds[i14].clear();
                                ChatActivity.this.selectedMessagesCanCopyIds[i14].clear();
                            }
                            ChatActivity.this.cantDeleteMessagesCount = 0;
                            ((BaseFragment) ChatActivity.this).actionBar.hideActionMode();
                            ChatActivity.this.updatePinnedMessageView(true);
                            ChatActivity.this.updateVisibleRows();
                        } catch (Exception e2) {
                            FileLog.e("tmessages", e2);
                        }
                    }
                });
                return;
            }
            if (id == 85) {
                ChatActivity.this.openAddMember();
                return;
            }
            if (id == 90) {
                ChatActivity.this.presentFragment(new ChannelAdminLogActivity(ChatActivity.this.currentChat));
                return;
            }
            if (id == 118) {
                TLRPC.Dialog dialog = (TLRPC.Dialog) ChatActivity.this.getMessagesController().dialogs_dict.get(ChatActivity.this.dialog_id);
                if (dialog == null) {
                    return;
                }
                boolean contains = ChatActivity.this.getMessagesController().favsDialogs.contains(Long.valueOf(ChatActivity.this.dialog_id));
                MessagesController.DialogFilter favsFilter = ChatActivity.this.getMessagesController().getFavsFilter();
                if (contains) {
                    ChatActivity.this.getMessagesController().getDialogsByType(26, dialog.folder_id).remove(dialog);
                    if (favsFilter != null) {
                        int i11 = 0;
                        while (true) {
                            if (i11 >= favsFilter.alwaysShow.size()) {
                                break;
                            }
                            if (ChatActivity.this.dialog_id == ((Long) favsFilter.alwaysShow.get(i11)).longValue()) {
                                favsFilter.alwaysShow.remove(i11);
                                break;
                            }
                            i11++;
                        }
                    }
                } else {
                    ChatActivity.this.getMessagesController().getDialogsByType(26, dialog.folder_id).add(dialog);
                    if (favsFilter != null) {
                        favsFilter.alwaysShow.add(Long.valueOf(ChatActivity.this.dialog_id));
                    }
                }
                PlusRepository.getInstance(((BaseFragment) ChatActivity.this).currentAccount).insertOrUpdateFavorite(new DialogEntity(ChatActivity.this.getUserConfig().clientUserId, ChatActivity.this.dialog_id, !contains, ChatActivity.this.getMessagesController().hiddenDialogs.contains(Long.valueOf(DialogObject.isEncryptedDialog(ChatActivity.this.dialog_id) ? DialogObject.getEncryptedChatId(ChatActivity.this.dialog_id) : ChatActivity.this.dialog_id))));
                ChatActivity.this.updateFavoriteTitle(!contains);
                if (favsFilter != null) {
                    FilterCreateActivity.saveFilterToServer(favsFilter, favsFilter.flags, favsFilter.name, favsFilter.color, favsFilter.alwaysShow, favsFilter.neverShow, favsFilter.pinnedDialogs, false, false, true, false, false, ChatActivity.this, null);
                    return;
                } else {
                    PlusUtils.addLocalFilter(26, ChatActivity.this, false);
                    return;
                }
            }
            if (id == 112) {
                ChatActivity chatActivity13 = ChatActivity.this;
                PlusUtils.showAddToFolder(chatActivity13, chatActivity13.dialog_id);
                return;
            }
            if (id == 87) {
                TLRPC.Dialog dialog2 = (TLRPC.Dialog) ChatActivity.this.getMessagesController().dialogs_dict.get(ChatActivity.this.dialog_id);
                if (dialog2 == null) {
                    ChatActivity.this.loadMoreDialogs();
                    return;
                } else {
                    ChatActivity.this.hideDialog(dialog2);
                    return;
                }
            }
            if (id == 117) {
                ChatActivity.this.goToFirstMsg = true;
                ChatActivity.this.scrollToMessageId(1, 0, false, 0, true, 0);
                return;
            }
            if (id == 119) {
                if (ChatActivity.this.currentMarkedMsg != 0) {
                    int size = ChatActivity.this.markedMessages.size();
                    if (size > 1) {
                        int indexOf = ChatActivity.this.markedMessages.indexOf(Integer.valueOf(ChatActivity.this.currentMarkedMsg));
                        int i12 = indexOf - 1;
                        if (indexOf == 0) {
                            ChatActivity chatActivity14 = ChatActivity.this;
                            chatActivity14.currentMarkedMsg = ((Integer) chatActivity14.markedMessages.get(size - 1)).intValue();
                        } else if (size > i12) {
                            ChatActivity chatActivity15 = ChatActivity.this;
                            chatActivity15.currentMarkedMsg = ((Integer) chatActivity15.markedMessages.get(i12)).intValue();
                        }
                        MessagesController.getMarkSettings(((BaseFragment) ChatActivity.this).currentAccount).edit().putInt("mark_" + ChatActivity.this.dialog_id, ChatActivity.this.currentMarkedMsg).apply();
                        ChatActivity.this.showMarkedMessages();
                        return;
                    }
                    ChatActivity chatActivity16 = ChatActivity.this;
                    chatActivity16.scrollToMessageId(chatActivity16.currentMarkedMsg, 0, true, 0, true, 0);
                    return;
                }
                return;
            }
            if (id == 116) {
                if (ChatActivity.this.currentUser != null) {
                    Bundle bundle2 = new Bundle();
                    bundle2.putLong("user_id", ChatActivity.this.currentUser.id);
                    bundle2.putBoolean("my_profile", true);
                    ChatActivity.this.presentFragment(new ProfileActivity(bundle2));
                    return;
                }
                return;
            }
            if (id == 115) {
                SharedPreferences notificationsSettings = MessagesController.getNotificationsSettings(((BaseFragment) ChatActivity.this).currentAccount);
                if (notificationsSettings.getInt("pin_" + ChatActivity.this.dialog_id, 0) == 0 && !ChatActivity.this.pinnedMessageIds.isEmpty()) {
                    notificationsSettings.edit().putInt("pin_" + ChatActivity.this.dialog_id, ((Integer) ChatActivity.this.pinnedMessageIds.get(0)).intValue()).apply();
                } else {
                    notificationsSettings.edit().remove("pin_" + ChatActivity.this.dialog_id).apply();
                }
                ChatActivity.this.updatePinnedMessageView(true);
                return;
            }
            if (id == 114) {
                Theme.plusHideBottomLayoutInChannels = !Theme.plusHideBottomLayoutInChannels;
                ApplicationLoader.applicationContext.getSharedPreferences("plusconfig", 0).edit().putBoolean("hideBottomLayoutInChannels", Theme.plusHideBottomLayoutInChannels).apply();
                ChatActivity chatActivity17 = ChatActivity.this;
                chatActivity17.hideBottomMode = Theme.plusHideBottomLayoutInChannels;
                chatActivity17.updateBottomOverlay();
                ChatActivity.this.updateHideBottomTitle();
                if (((BaseFragment) ChatActivity.this).parentLayout != null) {
                    AndroidUtilities.runOnUIThread(new Runnable() {
                        @Override
                        public final void run() {
                            ChatActivity.AnonymousClass13.this.lambda$onItemClick$5();
                        }
                    });
                    return;
                }
                return;
            }
            if (id == 82) {
                ChatActivity.this.directShareOnClick();
                return;
            }
            if (id == 113) {
                ChatActivity chatActivity18 = ChatActivity.this;
                chatActivity18.showDialog(PlusUtils.showReportDetailsDialog(chatActivity18, (MessageObject) null));
                return;
            }
            if (id == 50) {
                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().makeSelectedBold();
                return;
            }
            if (id == 51) {
                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().makeSelectedItalic();
                return;
            }
            if (id == 57) {
                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().makeSelectedSpoiler();
                return;
            }
            if (id == 58) {
                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().makeSelectedQuote();
                return;
            }
            if (id == 52) {
                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().makeSelectedMono();
                return;
            }
            if (id == 55) {
                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().makeSelectedStrike();
                return;
            }
            if (id == 56) {
                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().makeSelectedUnderline();
                return;
            }
            if (id == 53) {
                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().makeSelectedUrl();
                return;
            }
            if (id == 54) {
                ChatActivityEnterView chatActivityEnterView10 = ChatActivity.this.chatActivityEnterView;
                if (chatActivityEnterView10 == null || chatActivityEnterView10.getEditField() == null) {
                    return;
                }
                ChatActivity.this.chatActivityEnterView.getEditField().setSelectionOverride(ChatActivity.this.editTextStart, ChatActivity.this.editTextEnd);
                ChatActivity.this.chatActivityEnterView.getEditField().makeSelectedRegular();
                return;
            }
            if (id == 27) {
                ChatActivity.this.showChatThemeBottomSheet();
                return;
            }
            if (id == 60) {
                TopicsController topicsController = ChatActivity.this.getMessagesController().getTopicsController();
                ChatActivity chatActivity19 = ChatActivity.this;
                long j3 = chatActivity19.currentChat.id;
                int i13 = chatActivity19.forumTopic.id;
                ChatActivity.this.forumTopic.closed = true;
                topicsController.toggleCloseTopic(j3, i13, true);
                ChatActivity.this.updateTopicButtons();
                ChatActivity.this.updateBottomOverlay();
                ChatActivity.this.updateTopPanel(true);
                return;
            }
            if (id == 61) {
                TopicsFragment.prepareToSwitchAnimation(ChatActivity.this);
                return;
            }
            if (id == 65) {
                AndroidUtilities.addToClipboard(ChatActivity.this.businessLink.link);
                BulletinFactory.of(LaunchActivity.getLastFragment()).createCopyLinkBulletin().show();
                return;
            }
            if (id == 66) {
                Runnable runnable = new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.AnonymousClass13.this.lambda$onItemClick$6();
                    }
                };
                if (ChatActivity.this.chatActivityEnterView.businessLinkHasChanges()) {
                    ChatActivity.this.showBusinessLinksDiscardAlert(runnable);
                    return;
                } else {
                    runnable.run();
                    return;
                }
            }
            if (id == 67) {
                Context context2 = ChatActivity.this.getContext();
                int i14 = ((BaseFragment) ChatActivity.this).currentAccount;
                ChatActivity chatActivity20 = ChatActivity.this;
                BusinessLinksActivity.openRenameAlert(context2, i14, chatActivity20.businessLink, ((BaseFragment) chatActivity20).resourceProvider, false);
                return;
            }
            if (id == 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 DialogInterface.OnClickListener() {
                    @Override
                    public final void onClick(DialogInterface dialogInterface, int i15) {
                        ChatActivity.AnonymousClass13.this.lambda$onItemClick$7(dialogInterface, i15);
                    }
                }).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;
            }
            if (id == 120) {
                ChatActivityEnterView chatActivityEnterView11 = ChatActivity.this.chatActivityEnterView;
                if (chatActivityEnterView11 != null) {
                    chatActivityEnterView11.getEditField().setSelectionOverride(ChatActivity.this.editTextStart, ChatActivity.this.editTextEnd);
                    ChatActivity.this.chatActivityEnterView.getEditField().makeSelectedMention(0);
                    return;
                }
                return;
            }
            if (id != 62 || (chatActivityEnterView = ChatActivity.this.chatActivityEnterView) == null) {
                return;
            }
            chatActivityEnterView.getEditField().setSelectionOverride(ChatActivity.this.editTextStart, ChatActivity.this.editTextEnd);
            ChatActivity.this.chatActivityEnterView.getEditField().translateSelection();
        }

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

        public void lambda$onItemClick$1(ArrayList arrayList, boolean z, int i) {
            if (i <= 0 || ChatActivity.this.getParentActivity() == null) {
                return;
            }
            if (((MessageObject) arrayList.get(0)).isPhoto() || ((MessageObject) arrayList.get(0)).isVideo()) {
                BulletinFactory.of(ChatActivity.this).createDownloadBulletin(((MessageObject) arrayList.get(0)).isPhoto() ? BulletinFactory.FileType.PHOTOS : BulletinFactory.FileType.VIDEOS, i, ChatActivity.this.themeDelegate).show();
            } else {
                BulletinFactory.of(ChatActivity.this).createDownloadBulletin(z ? BulletinFactory.FileType.AUDIOS : BulletinFactory.FileType.UNKNOWNS, i, ChatActivity.this.themeDelegate).show();
            }
        }

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

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

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

            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 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);
                } else {
                    ChatActivity.this.performHistoryClear(true, z);
                }
            }
        }

        public void lambda$onItemClick$2(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) {
                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$358();
                NotificationCenter notificationCenter2 = ChatActivity.this.getNotificationCenter();
                int i3 = NotificationCenter.needDeleteDialog;
                ChatActivity chatActivity2 = ChatActivity.this;
                notificationCenter2.postNotificationName(i3, new Object[]{Long.valueOf(ChatActivity.this.dialog_id), chatActivity2.currentUser, chatActivity2.currentChat, Boolean.valueOf(z2)});
                return;
            }
            ChatActivity.this.performHistoryClear(z2, z);
        }

        public void lambda$onItemClick$3(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$4(View view) {
            ChatActivity.this.headerItem.closeSubMenu();
            ChatAttachAlert chatAttachAlert = ChatActivity.this.chatAttachAlert;
            if (chatAttachAlert != null) {
                chatAttachAlert.setEditingMessageObject((MessageObject) null);
            }
            ChatActivity.this.openAttachMenu();
        }

        public void lambda$onItemClick$5() {
            ((BaseFragment) ChatActivity.this).parentLayout.rebuildLastFragmentViews();
        }

        public void lambda$onItemClick$6() {
            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$7(DialogInterface dialogInterface, int i) {
            ChatActivity.this.lambda$onBackPressed$358();
            ChatActivity.this.getNotificationCenter().postNotificationName(NotificationCenter.needDeleteBusinessLink, new Object[]{ChatActivity.this.businessLink});
        }
    }

    public class AnonymousClass14 extends LongPressListenerWithMovingGesture {
        public final View val$backButton;

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

        @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);
            }
        }

        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);
        }
    }

    public boolean lambda$createView$21(View view, MotionEvent motionEvent) {
        ChatThemeBottomSheet chatThemeBottomSheet = this.chatThemeBottomSheet;
        if (chatThemeBottomSheet == null) {
            return false;
        }
        chatThemeBottomSheet.close();
        return true;
    }

    public void lambda$createView$22(int i, View view) {
        jumpToDate(i);
    }

    public void lambda$createView$26(final TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tLObject instanceof TLRPC.messages_Messages) {
            if (!((TLRPC.messages_Messages) tLObject).messages.isEmpty()) {
                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$25(tLObject, tLObject2, tL_error2);
                    }
                });
                return;
            }
            ((BaseFragment) this).actionBar.setSubtitle(LocaleController.getString("NoMessagesForThisDay", R.string.NoMessagesForThisDay));
        }
    }

    public void lambda$createView$25(TLObject tLObject, TLObject tLObject2, TLRPC.TL_error tL_error) {
        final int i;
        if (tLObject2 instanceof TLRPC.messages_Messages) {
            TLRPC.messages_Messages messages_messages = (TLRPC.messages_Messages) tLObject2;
            if (!messages_messages.messages.isEmpty()) {
                i = ((TLRPC.messages_Messages) tLObject).offset_id_offset - messages_messages.offset_id_offset;
            } else {
                i = ((TLRPC.messages_Messages) tLObject).offset_id_offset;
            }
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$createView$24(i);
                }
            });
        }
    }

    public void lambda$createView$23(int i) {
        ((BaseFragment) this).actionBar.setSubtitle(LocaleController.formatPluralString("messages", i, new Object[0]));
    }

    public void lambda$createView$24(final int i) {
        if (i != 0) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$createView$23(i);
                }
            });
        } else {
            ((BaseFragment) this).actionBar.setSubtitle(LocaleController.getString("NoMessagesForThisDay", R.string.NoMessagesForThisDay));
        }
    }

    public void lambda$createView$28(View view) {
        if (MessagesController.getInstance(((BaseFragment) this).currentAccount).isDialogMuted(this.dialog_id, getTopicId())) {
            updateTitleIcons(true);
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$createView$27();
                }
            }, 150L);
            this.headerItem.toggleSubMenu();
            if (getParentActivity() != null) {
                BulletinFactory.createMuteBulletin(this, false, this.themeDelegate).show();
                return;
            }
            return;
        }
        this.muteItem.openSwipeBack();
    }

    public void lambda$createView$27() {
        toggleMute(true);
    }

    public class AnonymousClass18 extends RecyclerListViewInternal {
        public final ArrayList<ChatMessageCell> drawCaptionAfter;
        public final ArrayList<ChatMessageCell> drawNamesAfter;
        public final ArrayList<ChatMessageCell> drawReactionsAfter;
        public final ArrayList<ChatMessageCell> drawTimeAfter;
        public final ArrayList<MessageObject.GroupedMessages> drawingGroups;
        public float endTrackingX;
        public boolean ignoreLayout;
        public int lastH;
        public long lastTrackingAnimationTime;
        public int lastWidth;
        public Paint outlineActionBackgroundDarkenPaint;
        public Paint outlineActionBackgroundPaint;
        public Path path;
        public boolean slidingBeyondMax;
        public FloatValueHolder slidingDrawableVisibilityProgress;
        public SpringAnimation slidingDrawableVisibilitySpring;
        public FloatValueHolder slidingFillProgress;
        public SpringAnimation slidingFillProgressSpring;
        public FloatValueHolder slidingOuterRingProgress;
        public SpringAnimation slidingOuterRingSpring;
        public float springMultiplier;
        public int startedTrackingPointerId;
        public int startedTrackingX;
        public int startedTrackingY;
        public float trackAnimationProgress;
        public boolean wasTrackingVibrate;

        public AnonymousClass18(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.AnonymousClass18.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.AnonymousClass18.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.AnonymousClass18.this.lambda$$2(dynamicAnimation, f, f2);
                }
            });
            this.path = new Path();
            this.lastH = 0;
            this.outlineActionBackgroundPaint.setStyle(Paint.Style.STROKE);
            this.outlineActionBackgroundPaint.setStrokeCap(Paint.Cap.ROUND);
            this.outlineActionBackgroundPaint.setStrokeWidth(AndroidUtilities.dp(2.0f));
            this.outlineActionBackgroundDarkenPaint.setStyle(Paint.Style.STROKE);
            this.outlineActionBackgroundDarkenPaint.setStrokeCap(Paint.Cap.ROUND);
            this.outlineActionBackgroundDarkenPaint.setStrokeWidth(AndroidUtilities.dp(2.0f));
        }

        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 requestLayout() {
            if (this.ignoreLayout) {
                return;
            }
            super.requestLayout();
        }

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

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

        public void onMeasure(int widthSpec, int heightSpec) {
            super.onMeasure(widthSpec, heightSpec);
        }

        public void onLayout(boolean changed, int l, int t, int r, int b) {
            super.onLayout(changed, l, t, r, b);
            int i = r - l;
            if (this.lastWidth != i) {
                this.lastWidth = i;
                ChatActivity.this.hideHints(false);
            }
            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();
        }

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

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

        public boolean onInterceptTouchEvent(MotionEvent e) {
            ChatActivity.this.textSelectionHelper.checkSelectionCancel(e);
            if (isFastScrollAnimationRunning()) {
                return false;
            }
            boolean onInterceptTouchEvent = super.onInterceptTouchEvent(e);
            if (!((BaseFragment) ChatActivity.this).actionBar.isActionModeShowed() && ChatActivity.this.reportType < 0) {
                processTouchEvent(e);
            }
            return onInterceptTouchEvent;
        }

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

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

        public final void processTouchEvent(MotionEvent e) {
            TLRPC.Chat chat;
            if (e != null) {
                ChatActivity.this.wasManualScroll = true;
            }
            if (ChatActivity.this.isInPreviewMode()) {
                return;
            }
            if (e != null && e.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 != 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) || ((!PlusSettings.enableSwipeInChannels && ChatActivity.this.bottomOverlayChat != null && ChatActivity.this.bottomOverlayChat.getVisibility() == 0 && ((!ChatActivity.this.bottomOverlayChatWaitsReply || !canSendMessageToTopic) && !messageObject.wasJustSent)) || ((!PlusSettings.enableSwipeInChannels && (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 = e.getPointerId(0);
                        ChatActivity.this.maybeStartTrackingSlidingView = true;
                        this.startedTrackingX = (int) e.getX();
                        this.startedTrackingY = (int) e.getY();
                        return;
                    }
                }
                return;
            }
            if (ChatActivity.this.slidingView != null && e != null && e.getAction() == 2 && e.getPointerId(0) == this.startedTrackingPointerId) {
                int max = Math.max(AndroidUtilities.dp(-80.0f), Math.min(0, (int) (e.getX() - this.startedTrackingX)));
                if ((!ChatActivity.this.slidingView.getMessageObject().isOutOwner() && PlusSettings.swipeRightAction > 0) || (ChatActivity.this.slidingView.getMessageObject().isOutOwner() && PlusSettings.swipeRightActionOut > 0)) {
                    ChatActivity.this.swipeBackEnabled = false;
                    if (max >= 0) {
                        max = Math.min(AndroidUtilities.dp(80.0f), (int) (e.getX() - this.startedTrackingX));
                    }
                    ChatActivity.this.trackingX = max;
                }
                int abs = Math.abs(((int) e.getY()) - this.startedTrackingY);
                if (getScrollState() == 0 && ChatActivity.this.maybeStartTrackingSlidingView && !ChatActivity.this.startedTrackingSlidingView) {
                    float f = max;
                    if ((f <= (-AndroidUtilities.getPixelsInCM(0.4f, true)) || (!ChatActivity.this.swipeBackEnabled && f >= 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) e.getX();
                        if (getParent() != null) {
                            getParent().requestDisallowInterceptTouchEvent(true);
                            return;
                        }
                        return;
                    }
                }
                if (ChatActivity.this.startedTrackingSlidingView) {
                    if (Math.abs(max) >= AndroidUtilities.dp(50.0f)) {
                        if (!this.wasTrackingVibrate) {
                            try {
                                if (!Theme.plusDisableSwipeToReplyVibration && !PlusSettings.disableActionsVibrations) {
                                    performHapticFeedback(3, 2);
                                }
                            } catch (Exception unused) {
                            }
                            this.wasTrackingVibrate = true;
                        }
                    } else {
                        this.wasTrackingVibrate = false;
                    }
                    float f2 = max;
                    ChatActivity.this.slidingView.setSlidingOffset(f2);
                    MessageObject messageObject2 = ChatActivity.this.slidingView.getMessageObject();
                    if (messageObject2.isRoundVideo() || messageObject2.isVideo()) {
                        ChatActivity.this.updateTextureViewPosition(false, false);
                    }
                    setGroupTranslationX(ChatActivity.this.slidingView, f2);
                    invalidate();
                    return;
                }
                return;
            }
            if (ChatActivity.this.slidingView != null) {
                if (e != null) {
                    if (e.getPointerId(0) != this.startedTrackingPointerId) {
                        return;
                    }
                    if (e.getAction() != 3 && e.getAction() != 1 && e.getAction() != 6) {
                        return;
                    }
                }
                if (e != null && e.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);
                ChatActivity.this.swipeBackEnabled = true;
            }
        }

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

        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();
        }

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

        public void onChildPressed(View child, float x, float y, boolean pressed) {
            MessageObject.GroupedMessages currentMessagesGroup;
            super.onChildPressed(child, x, y, pressed);
            if (child instanceof ChatMessageCell) {
                ChatMessageCell chatMessageCell = (ChatMessageCell) child;
                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 != child && (childAt instanceof ChatMessageCell)) {
                        ChatMessageCell chatMessageCell2 = (ChatMessageCell) childAt;
                        if (chatMessageCell2.getCurrentMessagesGroup() == currentMessagesGroup) {
                            chatMessageCell2.setPressed(pressed);
                        }
                    }
                }
            }
        }

        public void onDraw(Canvas c) {
            float f;
            super/*androidx.recyclerview.widget.RecyclerView*/.onDraw(c);
            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(c);
            }
            if (ChatActivity.this.pullingDownOffset != 0.0f && !ChatActivity.this.isInPreviewMode()) {
                ChatActivity chatActivity = ChatActivity.this;
                if (!chatActivity.isInsideContainer && chatActivity.chatMode != 3) {
                    c.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;
                    }
                    c.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.this.pullingDownDrawable.updateDialog((TLRPC.Chat) ChatActivity.this.nextChannels.get(0));
                        } else {
                            ChatActivity chatActivity5 = ChatActivity.this;
                            if (chatActivity5.isTopic) {
                                chatActivity5.pullingDownDrawable.updateTopic();
                            } else {
                                chatActivity5.pullingDownDrawable.updateDialog();
                            }
                        }
                        ChatActivity.this.pullingDownDrawable.onAttach();
                    }
                    ChatActivity.this.pullingDownDrawable.setWidth(getMeasuredWidth());
                    ChatActivity.this.pullingDownDrawable.draw(c, ChatActivity.this.chatListView, Math.min(1.0f, ChatActivity.this.pullingDownOffset / AndroidUtilities.dp(110.0f)), 1.0f - ChatActivity.this.pullingDownAnimateProgress);
                    c.restore();
                    if (ChatActivity.this.pullingDownAnimateToActivity != null) {
                        c.saveLayerAlpha(0.0f, 0.0f, ChatActivity.this.pullingDownAnimateToActivity.chatListView.getMeasuredWidth(), ChatActivity.this.pullingDownAnimateToActivity.chatListView.getMeasuredHeight(), (int) (ChatActivity.this.pullingDownAnimateProgress * 255.0f), 31);
                        c.translate(0.0f, (getMeasuredHeight() - ChatActivity.this.pullingDownOffset) - f);
                        ChatActivity.this.pullingDownAnimateToActivity.chatListView.draw(c);
                        c.restore();
                        return;
                    }
                    return;
                }
            }
            if (ChatActivity.this.pullingDownDrawable != null) {
                ChatActivity.this.pullingDownDrawable.reset();
            }
        }

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

        public final 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;
            int dp = AndroidUtilities.dp(200.0f);
            chatActivity2.skeletonGradientWidth = dp;
            chatActivity.skeletonGradient = new LinearGradient(0.0f, 0.0f, dp, 0.0f, new int[]{alphaComponent, blendARGB, blendARGB, alphaComponent}, new float[]{0.0f, 0.4f, 0.6f, 1.0f}, Shader.TileMode.CLAMP);
            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}, Shader.TileMode.CLAMP);
            ChatActivity.this.skeletonOutlinePaint.setShader(ChatActivity.this.skeletonOutlineGradient);
        }

        public final 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.this.skeletonTotalTranslation = (int) (r0.skeletonTotalTranslation + ((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);
            }
        }

        public void dispatchDraw(Canvas canvas) {
            ChatActivity.this.drawLaterRoundProgressCell = null;
            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.drawingChatLisViewYoffset = 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 final 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 = this.drawTimeAfter.get(i);
                    canvas.save();
                    canvas.translate(chatMessageCell.getLeft() + chatMessageCell.getNonAnimationTranslationX(false), chatMessageCell.getY());
                    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 = this.drawNamesAfter.get(i2);
                    float left = chatMessageCell2.getLeft() + chatMessageCell2.getNonAnimationTranslationX(false);
                    float y = chatMessageCell2.getY();
                    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 = 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();
                    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 = 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();
                    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);
                        chatMessageCell4.setInvalidatesParent(false);
                    }
                    canvas.restore();
                }
                this.drawReactionsAfter.clear();
            }
        }

        public final void drawChatBackgroundElements(Canvas canvas) {
            int i;
            int i2;
            float f;
            int i3;
            boolean z;
            int i4;
            int i5;
            MessageObject.GroupedMessages currentMessagesGroup;
            boolean z2;
            int i6;
            ?? r13;
            Canvas canvas2 = canvas;
            int childCount = getChildCount();
            MessageObject.GroupedMessages groupedMessages = null;
            int i7 = 0;
            while (true) {
                i = 4;
                i2 = 8;
                f = 0.0f;
                i3 = 2;
                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 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 measuredHeight2 = 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());
                                                    measuredHeight2 = Math.max(measuredHeight2, ((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 = measuredHeight2 - y;
                                    }
                                    int i9 = i6 + y;
                                    canvas2.clipRect(0, y, getMeasuredWidth(), i9);
                                    Paint themedPaint = getThemedPaint("paintChatMessageBackgroundSelected");
                                    ThemeDelegate themeDelegate = ChatActivity.this.themeDelegate;
                                    if (themeDelegate != null && !themeDelegate.isDark && themedPaint != null) {
                                        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);
                                        }
                                    } else {
                                        backgroundDrawable.setCustomPaint((Paint) null);
                                        backgroundDrawable.setColor(getThemedColor(Theme.key_chat_selectedBackground));
                                    }
                                    backgroundDrawable.setBounds(0, y, getMeasuredWidth(), i9);
                                    backgroundDrawable.draw(canvas2);
                                    canvas.restore();
                                } else if (currentPosition == null) {
                                    Paint themedPaint2 = getThemedPaint("paintChatMessageBackgroundSelected");
                                    ThemeDelegate themeDelegate3 = ChatActivity.this.themeDelegate;
                                    if ((themeDelegate3 != null && themeDelegate3.isDark) || themedPaint2 == null) {
                                        themedPaint2 = Theme.chat_replyLinePaint;
                                        themedPaint2.setColor(getThemedColor(Theme.key_chat_selectedBackground));
                                    } else {
                                        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);
                                        }
                                    }
                                    Paint paint = themedPaint2;
                                    canvas.save();
                                    canvas2.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 && currentMessagesGroup2 == null && chatMessageCell.drawBackgroundInParent()) {
                            canvas.save();
                            canvas2.translate(chatMessageCell.getX(), chatMessageCell.getY());
                            if (chatMessageCell.getScaleX() != 1.0f) {
                                canvas2.scale(chatMessageCell.getScaleX(), chatMessageCell.getScaleY(), chatMessageCell.getPivotX(), chatMessageCell.getHeight() >> r13);
                            }
                            chatMessageCell.drawBackgroundInternal(canvas2, r13);
                            canvas.restore();
                        }
                    } else if (childAt instanceof ChatActionCell) {
                        ChatActionCell chatActionCell = (ChatActionCell) childAt;
                        if (chatActionCell.hasGradientService()) {
                            canvas.save();
                            canvas2.translate(chatActionCell.getX(), chatActionCell.getY());
                            canvas2.scale(chatActionCell.getScaleX(), chatActionCell.getScaleY(), chatActionCell.getMeasuredWidth() / 2.0f, chatActionCell.getMeasuredHeight() / 2.0f);
                            chatActionCell.drawBackground(canvas2, true);
                            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.getBackgroundDrawableTop();
                                int top4 = chatMessageCell3.getTop() + 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++;
                        i3 = 2;
                        f = 0.0f;
                    }
                    int i18 = 0;
                    while (i18 < this.drawingGroups.size()) {
                        MessageObject.GroupedMessages groupedMessages2 = 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();
                                canvas2.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;
                        canvas2 = canvas;
                        i10 = i4;
                        z3 = true;
                    }
                }
                i10++;
                canvas2 = canvas;
                i3 = 2;
                f = 0.0f;
                i2 = 8;
                z3 = true;
                i = 4;
            }
        }

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

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

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

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

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

    public class AnonymousClass19 extends ChatListItemAnimator {
        public Runnable finishRunnable;

        public AnonymousClass19(ChatActivity activity, RecyclerListView listView, Theme.ResourcesProvider resourcesProvider) {
            super(activity, listView, resourcesProvider);
        }

        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 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();
        }

        public 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.AnonymousClass19.this.lambda$onAllAnimationsDone$0();
                }
            };
            this.finishRunnable = runnable2;
            AndroidUtilities.runOnUIThread(runnable2);
        }

        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 endAnimations() {
            super.endAnimations();
            Runnable runnable = this.finishRunnable;
            if (runnable != null) {
                AndroidUtilities.cancelRunOnUIThread(runnable);
            }
            Runnable runnable2 = new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.AnonymousClass19.this.lambda$endAnimations$1();
                }
            };
            this.finishRunnable = runnable2;
            AndroidUtilities.runOnUIThread(runnable2);
        }

        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 class AnonymousClass20 extends GridLayoutManagerFixed {
        public boolean computingScroll;

        public boolean supportsPredictiveItemAnimations() {
            return true;
        }

        public AnonymousClass20(Context context, int spanCount, int orientation, boolean reverseLayout) {
            super(context, spanCount, orientation, reverseLayout);
        }

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

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

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

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

        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;
        }

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

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

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

        public boolean hasSiblingChild(int position) {
            int i;
            byte b;
            if (position >= ChatActivity.this.chatAdapter.messagesStartRow && position < ChatActivity.this.chatAdapter.messagesEndRow && (i = position - ChatActivity.this.chatAdapter.messagesStartRow) >= 0 && i < ChatActivity.this.chatAdapter.getMessages().size()) {
                MessageObject messageObject = ChatActivity.this.chatAdapter.getMessages().get(i);
                MessageObject.GroupedMessages validGroupedMessage = ChatActivity.this.getValidGroupedMessage(messageObject);
                if (validGroupedMessage != null) {
                    MessageObject.GroupedMessagePosition position2 = validGroupedMessage.getPosition(messageObject);
                    if (position2.minX != position2.maxX && (b = position2.minY) == position2.maxY && b != 0) {
                        int size = validGroupedMessage.posArray.size();
                        for (int i2 = 0; i2 < size; i2++) {
                            MessageObject.GroupedMessagePosition groupedMessagePosition = (MessageObject.GroupedMessagePosition) validGroupedMessage.posArray.get(i2);
                            if (groupedMessagePosition != position2) {
                                byte b2 = groupedMessagePosition.minY;
                                byte b3 = position2.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.AnonymousClass20.this.lambda$onLayoutChildren$0();
                    }
                });
            }
        }

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

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

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

        public AnonymousClass23() {
        }

        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            if (newState == 0) {
                if (ChatActivity.this.pollHintCell != null) {
                    ChatActivity.this.pollHintView.showForMessageCell(ChatActivity.this.pollHintCell, -1, ChatActivity.this.pollHintX, ChatActivity.this.pollHintY, true);
                    ChatActivity.this.pollHintCell = null;
                }
                ChatActivity.this.scrollingFloatingDate = false;
                ChatActivity.this.scrollingChatListView = false;
                ChatActivity.this.checkTextureViewPosition = false;
                ChatActivity.this.hideFloatingDateView(true);
                if (SharedConfig.getDevicePerformanceClass() == 0) {
                    ChatActivity.scrolling = true;
                    NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.startAllHeavyOperations, new Object[]{512});
                }
                NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.startSpoilers, new Object[0]);
                ChatActivity.this.chatListView.setOverScrollMode(0);
                ChatActivity.this.textSelectionHelper.stopScrolling();
                ChatActivity.this.updateVisibleRows();
                ChatActivity.this.scrollByTouch = false;
                return;
            }
            if (ChatActivity.this.groupEmojiPackHint != null && ChatActivity.this.groupEmojiPackHint.shown()) {
                ChatActivity.this.groupEmojiPackHint.hide();
            }
            if (ChatActivity.this.searchOtherButton != null && ChatActivity.this.searchOtherButton.getVisibility() == 0 && ChatActivity.this.isKeyboardVisible()) {
                AndroidUtilities.hideKeyboard(ChatActivity.this.getParentActivity().getCurrentFocus());
            }
            if (newState == 2) {
                ChatActivity.this.wasManualScroll = true;
                ChatActivity.this.scrollingChatListView = true;
            } else if (newState == 1) {
                if (ChatActivity.this.isKeyboardVisible() && PlusSettings.hideKeyboardOnScroll) {
                    ChatActivity.this.chatActivityEnterView.hidePopup(false);
                    if (ChatActivity.this.getParentActivity() != null) {
                        AndroidUtilities.hideKeyboard(ChatActivity.this.getParentActivity().getCurrentFocus());
                    }
                }
                ChatActivity.this.pollHintCell = null;
                ChatActivity.this.wasManualScroll = true;
                ChatActivity.this.scrollingFloatingDate = true;
                ChatActivity.this.checkTextureViewPosition = true;
                ChatActivity.this.scrollingChatListView = true;
            }
            if (SharedConfig.getDevicePerformanceClass() == 0) {
                ChatActivity.scrolling = false;
                NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.stopAllHeavyOperations, new Object[]{512});
            }
            NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.stopSpoilers, new Object[0]);
            if (ChatActivity.this.selectionReactionsOverlay == null || !ChatActivity.this.selectionReactionsOverlay.isVisible()) {
                return;
            }
            ChatActivity.this.selectionReactionsOverlay.setHiddenByScroll(true);
        }

        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            boolean z;
            ChatActivity.this.chatListView.invalidate();
            ChatActivityFragmentView chatActivityFragmentView = ChatActivity.this.contentView;
            if (chatActivityFragmentView != null) {
                chatActivityFragmentView.updateBlurContent();
            }
            if (ChatActivity.this.chatListThanosEffect != null) {
                ChatActivity.this.chatListThanosEffect.scroll(dx, dy);
            }
            this.scrollUp = dy < 0;
            int findFirstVisibleItemPosition = ChatActivity.this.chatLayoutManager.findFirstVisibleItemPosition();
            if (((dy != 0 && ChatActivity.this.scrollByTouch && recyclerView.getScrollState() == 2) || recyclerView.getScrollState() == 1) && ChatActivity.this.forceNextPinnedMessageId != 0) {
                if (!this.scrollUp || ChatActivity.this.forceScrollToFirst) {
                    ChatActivity.this.forceNextPinnedMessageId = 0;
                } else if (!ChatActivity.this.chatListView.isFastScrollAnimationRunning() && findFirstVisibleItemPosition != -1) {
                    int findLastVisibleItemPosition = ChatActivity.this.chatLayoutManager.findLastVisibleItemPosition();
                    MessageObject messageObject = null;
                    while (true) {
                        if (findLastVisibleItemPosition < findFirstVisibleItemPosition) {
                            z = false;
                            break;
                        }
                        View findViewByPosition = ChatActivity.this.chatLayoutManager.findViewByPosition(findLastVisibleItemPosition);
                        if (findViewByPosition instanceof ChatMessageCell) {
                            messageObject = ((ChatMessageCell) findViewByPosition).getMessageObject();
                        } else if (findViewByPosition instanceof ChatActionCell) {
                            messageObject = ((ChatActionCell) findViewByPosition).getMessageObject();
                        }
                        if (messageObject != null && ChatActivity.this.forceNextPinnedMessageId == messageObject.getId()) {
                            z = true;
                            break;
                        }
                        findLastVisibleItemPosition--;
                    }
                    if (!z && messageObject != null && messageObject.getId() < ChatActivity.this.forceNextPinnedMessageId) {
                        ChatActivity.this.forceNextPinnedMessageId = 0;
                    }
                }
            }
            if (recyclerView.getScrollState() == 1) {
                ChatActivity.this.forceScrollToFirst = false;
                if (!ChatActivity.this.wasManualScroll && dy != 0) {
                    ChatActivity.this.wasManualScroll = true;
                }
            }
            if (dy != 0) {
                ChatActivity.this.contentView.invalidateBlur();
                ChatActivity.this.hideHints(true);
            }
            if (dy != 0 && ChatActivity.this.scrollingFloatingDate && !ChatActivity.this.currentFloatingTopIsNotMessage) {
                ChatActivity chatActivity = ChatActivity.this;
                if (chatActivity.highlightMessageId != Integer.MAX_VALUE) {
                    chatActivity.removeSelectedMessageHighlight();
                    ChatActivity.this.updateVisibleRows();
                }
                ChatActivity.this.showFloatingDateView(true);
            }
            ChatActivity.this.checkScrollForLoad(true);
            if (findFirstVisibleItemPosition != -1) {
                ChatActivity.this.chatAdapter.getItemCount();
                if (findFirstVisibleItemPosition == 0 && ChatActivity.this.forwardEndReached[0]) {
                    if (dy >= 0) {
                        ChatActivity.this.canShowPagedownButton = false;
                        ChatActivity.this.updatePagedownButtonVisibility(true);
                    }
                } else if (dy > 0) {
                    if (ChatActivity.this.pagedownButton.getTag() == null) {
                        float f = this.totalDy + dy;
                        this.totalDy = f;
                        if (f > this.scrollValue) {
                            this.totalDy = 0.0f;
                            ChatActivity.this.canShowPagedownButton = true;
                            ChatActivity.this.updatePagedownButtonVisibility(true);
                            ChatActivity.this.pagedownButtonShowedByScroll = true;
                        }
                    }
                } else if (ChatActivity.this.pagedownButtonShowedByScroll && ChatActivity.this.pagedownButton.getTag() != null) {
                    float f2 = this.totalDy + dy;
                    this.totalDy = f2;
                    if (f2 < (-this.scrollValue)) {
                        ChatActivity.this.canShowPagedownButton = false;
                        ChatActivity.this.updatePagedownButtonVisibility(true);
                        this.totalDy = 0.0f;
                    }
                }
            }
            ChatActivity.this.invalidateMessagesVisiblePart();
            ChatActivity.this.textSelectionHelper.onParentScrolled();
            ChatActivity.this.emojiAnimationsOverlay.onScrolled(dy);
            ReactionsEffectOverlay.onScrolled(dy);
            ChatActivity.this.checkTranslation(false);
            if (ChatActivity.this.savedMessagesTagHint != null) {
                if (ChatActivity.this.savedMessagesTagHint.shown()) {
                    ChatActivity.this.savedMessagesTagHint.hide();
                } else if (!ChatActivity.this.savedMessagesTagHintShown) {
                    ChatActivity.this.lastScrollTime = System.currentTimeMillis();
                    final ChatActivity chatActivity2 = ChatActivity.this;
                    AndroidUtilities.cancelRunOnUIThread(new Runnable() {
                        @Override
                        public final void run() {
                            ChatActivity.m2521$$Nest$mcheckSavedMessagesTagHint(ChatActivity.this);
                        }
                    });
                    final ChatActivity chatActivity3 = ChatActivity.this;
                    AndroidUtilities.runOnUIThread(new Runnable() {
                        @Override
                        public final void run() {
                            ChatActivity.m2521$$Nest$mcheckSavedMessagesTagHint(ChatActivity.this);
                        }
                    }, 2000L);
                }
            }
            if (ChatActivity.this.botMessageHint != null && ChatActivity.this.botMessageHint.shown()) {
                ChatActivity.this.botMessageHint.hide();
            } else {
                final ChatActivity chatActivity4 = ChatActivity.this;
                AndroidUtilities.cancelRunOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.m2515$$Nest$mcheckBotMessageHint(ChatActivity.this);
                    }
                });
                final ChatActivity chatActivity5 = ChatActivity.this;
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.m2515$$Nest$mcheckBotMessageHint(ChatActivity.this);
                    }
                }, 2000L);
            }
            if (ChatActivity.this.factCheckHint != null) {
                ChatActivity.this.factCheckHint.hide();
            }
            ChatActivityEnterView chatActivityEnterView = ChatActivity.this.chatActivityEnterView;
            if (chatActivityEnterView != null) {
                chatActivityEnterView.hideHints();
            }
            if (dy != 0) {
                ChatActivity.this.updateFloatingDateViewPosition();
            }
        }
    }

    public void lambda$createView$29(View view) {
        if (this.floatingDateView.getAlpha() == 0.0f || ((BaseFragment) this).actionBar.isActionModeShowed() || this.reportType >= 0) {
            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$30(View view) {
        onPageDownClicked();
    }

    public boolean lambda$createView$31(View view) {
        onScrollDown(true);
        return true;
    }

    public void lambda$createView$32(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$33(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 class AnonymousClass29 implements View.OnClickListener {
        public AnonymousClass29() {
        }

        public final 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.AnonymousClass29.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.AnonymousClass29.this.lambda$loadLastUnreadMention$2(messagesStorage, tLObject, tL_error);
                }
            });
        }

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

        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.AnonymousClass29.this.lambda$loadLastUnreadMention$1(tLObject, tL_error, messagesStorage);
                }
            });
        }

        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()) {
                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);
                    return;
                } else {
                    ChatActivity.this.mentiondownButtonCounter.setText(String.format("%d", Integer.valueOf(ChatActivity.this.newMentionsCount)));
                    loadLastUnreadMention();
                    return;
                }
            }
            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);
        }

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

    public boolean lambda$createView$36(View view) {
        this.scrimPopupWindow = ReadAllMentionsMenu.show(1, getParentActivity(), getParentLayout(), this.contentView, view, getResourceProvider(), new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$createView$34();
            }
        });
        dimBehindView((View) this.mentiondownButton, true);
        this.scrimPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public final void onDismiss() {
                ChatActivity.this.lambda$createView$35();
            }
        });
        if (!PlusSettings.disableActionsVibrations) {
            view.performHapticFeedback(0, 2);
        }
        return true;
    }

    public void lambda$createView$34() {
        for (int i = 0; i < this.messages.size(); i++) {
            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$35() {
        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$37(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$42(final View view, int i) {
        AnimatedEmojiSpan animatedEmojiSpan;
        char c;
        BlurredFrameLayout blurredFrameLayout;
        BlurredFrameLayout blurredFrameLayout2;
        if (i == 0 || this.mentionContainer.getAdapter().isBannedInline()) {
            return;
        }
        int i2 = i - 1;
        final Object item = this.mentionContainer.getAdapter().getItem(i2);
        int resultStartPosition = this.mentionContainer.getAdapter().getResultStartPosition();
        int resultLength = this.mentionContainer.getAdapter().getResultLength();
        Paint.FontMetricsInt fontMetricsInt = null;
        if (item instanceof QuickRepliesController.QuickReply) {
            if (!getUserConfig().isPremium()) {
                showDialog(new PremiumFeatureBottomSheet(this, getContext(), ((BaseFragment) this).currentAccount, true, 31, false, null));
                return;
            }
            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) item).id;
            getConnectionsManager().sendRequest(tL_messages_sendQuickReplyMessages, (RequestDelegate) null);
            ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
            if (chatActivityEnterView != null) {
                chatActivityEnterView.setFieldText((CharSequence) null);
                return;
            }
            return;
        }
        if (item instanceof TLRPC.TL_document) {
            if (this.chatMode == 0 && checkSlowMode(view)) {
                return;
            }
            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(i2);
            final String findAnimatedEmojiEmoticon = MessageObject.findAnimatedEmojiEmoticon(tL_document);
            if (this.chatMode == 1) {
                AlertsCreator.createScheduleDatePickerDialog(getParentActivity(), this.dialog_id, new AlertsCreator.ScheduleDatePickerDelegate() {
                    public final void didSelectDate(boolean z, int i3) {
                        ChatActivity.this.lambda$createView$38(tL_document, findAnimatedEmojiEmoticon, itemParent, z, i3);
                    }
                }, this.themeDelegate);
            } else {
                if (PlusSettings.confirmBeforeSending) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                    builder.setTitle(LocaleController.getString("SendSticker", R.string.SendSticker));
                    builder.setMessage(LocaleController.getString("AreYouSure", R.string.AreYouSure));
                    builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
                        @Override
                        public final void onClick(DialogInterface dialogInterface, int i3) {
                            ChatActivity.this.lambda$createView$39(tL_document, findAnimatedEmojiEmoticon, view, itemParent, dialogInterface, i3);
                        }
                    });
                    builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                    showDialog(builder.create());
                    return;
                }
                getSendMessagesHelper().sendSticker(tL_document, findAnimatedEmojiEmoticon, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TL_stories.StoryItem) null, this.replyingQuote, sendAnimationData, true, 0, false, itemParent, this.quickReplyShortcut, getQuickReplyId());
            }
            hideFieldPanel(false);
            this.chatActivityEnterView.addStickerToRecent(tL_document);
            this.chatActivityEnterView.setFieldText("");
            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) {
            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) {
                this.chatActivityEnterView.replaceWithText(resultStartPosition, resultLength, "@" + UserObject.getPublicUsername(user) + " ", false);
                return;
            }
            SpannableString spannableString = new SpannableString(UserObject.getFirstName(user, false) + " ");
            spannableString.setSpan(new URLSpanUserMention("" + user.id, 3), 0, spannableString.length(), 33);
            this.chatActivityEnterView.replaceWithText(resultStartPosition, resultLength, spannableString, false);
            return;
        }
        if (item instanceof String) {
            if (this.mentionContainer.getAdapter().isBotCommands()) {
                if (this.chatMode == 1) {
                    AlertsCreator.createScheduleDatePickerDialog(getParentActivity(), this.dialog_id, new AlertsCreator.ScheduleDatePickerDelegate() {
                        public final void didSelectDate(boolean z, int i3) {
                            ChatActivity.this.lambda$createView$40(item, z, i3);
                        }
                    }, this.themeDelegate);
                    return;
                }
                if (checkSlowMode(view)) {
                    return;
                }
                SendMessagesHelper.SendMessageParams of = SendMessagesHelper.SendMessageParams.of((String) item, 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();
                getSendMessagesHelper().sendMessage(of);
                this.chatActivityEnterView.setFieldText("");
                hideFieldPanel(false);
                return;
            }
            this.chatActivityEnterView.replaceWithText(resultStartPosition, resultLength, item + " ", false);
            return;
        }
        if (item instanceof TLRPC.BotInlineResult) {
            if (this.chatActivityEnterView.getFieldText() != null) {
                if (this.chatMode == 1 || !checkSlowMode(view)) {
                    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 {
                            c = botInlineResult.send_message instanceof TLRPC.TL_botInlineMessageMediaInvoice ? (char) 2 : (char) 0;
                        }
                        if (c != 0) {
                            AlertDialog.Builder builder2 = new AlertDialog.Builder(getParentActivity(), this.themeDelegate);
                            builder2.setTitle(LocaleController.getString("SendMessageTitle", R.string.SendMessageTitle));
                            if (c == 1) {
                                builder2.setMessage(LocaleController.getString("GameCantSendSecretChat", R.string.GameCantSendSecretChat));
                            } else {
                                builder2.setMessage(LocaleController.getString("InvoiceCantSendSecretChat", R.string.InvoiceCantSendSecretChat));
                            }
                            builder2.setNegativeButton(LocaleController.getString("OK", R.string.OK), null);
                            showDialog(builder2.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<Object> arrayList = new ArrayList<>(this.mentionContainer.getAdapter().getSearchResultBotContext());
                        this.botContextResults = arrayList;
                        PhotoViewer.getInstance().setParentActivity(this, this.themeDelegate);
                        PhotoViewer.getInstance().openPhotoForSelect(arrayList, this.mentionContainer.getAdapter().getItemPosition(i2), 3, false, this.botContextProvider, this);
                        return;
                    }
                    if (this.chatMode == 1) {
                        AlertsCreator.createScheduleDatePickerDialog(getParentActivity(), this.dialog_id, new AlertsCreator.ScheduleDatePickerDelegate() {
                            public final void didSelectDate(boolean z, int i3) {
                                ChatActivity.this.lambda$createView$41(botInlineResult, z, i3);
                            }
                        }, this.themeDelegate);
                        return;
                    } else {
                        lambda$createView$41(botInlineResult, true, 0);
                        return;
                    }
                }
                return;
            }
            return;
        }
        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 str = ((MediaDataController.KeywordResult) item).emoji;
            this.chatActivityEnterView.addEmojiToRecent(str);
            if (str != null && str.startsWith("animated_")) {
                try {
                    try {
                        fontMetricsInt = this.chatActivityEnterView.getEditField().getPaint().getFontMetricsInt();
                    } catch (Exception e) {
                        FileLog.e(e, false);
                    }
                    long parseLong = Long.parseLong(str.substring(9));
                    TLRPC.Document findDocument = AnimatedEmojiDrawable.findDocument(((BaseFragment) this).currentAccount, parseLong);
                    SpannableString spannableString2 = new SpannableString(MessageObject.findAnimatedEmojiEmoticon(findDocument));
                    if (findDocument != null) {
                        animatedEmojiSpan = new AnimatedEmojiSpan(findDocument, fontMetricsInt);
                    } else {
                        animatedEmojiSpan = new AnimatedEmojiSpan(parseLong, fontMetricsInt);
                    }
                    spannableString2.setSpan(animatedEmojiSpan, 0, spannableString2.length(), 33);
                    this.chatActivityEnterView.replaceWithText(resultStartPosition, resultLength, spannableString2, false);
                } catch (Exception unused) {
                    this.chatActivityEnterView.replaceWithText(resultStartPosition, resultLength, str, true);
                }
            } else {
                this.chatActivityEnterView.replaceWithText(resultStartPosition, resultLength, str, true);
            }
            this.mentionContainer.updateVisibility(false);
        }
    }

    public void lambda$createView$38(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());
    }

    public void lambda$createView$39(TLRPC.TL_document tL_document, String str, View view, Object obj, DialogInterface dialogInterface, int i) {
        getSendMessagesHelper().sendSticker(tL_document, str, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TL_stories.StoryItem) null, this.replyingQuote, ((StickerCell) view).getSendAnimationData(), true, 0, false, obj, this.quickReplyShortcut, getQuickReplyId());
        hideFieldPanel(false);
        this.chatActivityEnterView.addStickerToRecent(tL_document);
        this.chatActivityEnterView.setFieldText("");
    }

    public void lambda$createView$40(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 boolean lambda$createView$44(android.view.View r10, int r11) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.lambda$createView$44(android.view.View, int):boolean");
    }

    public void lambda$createView$43(DialogInterface dialogInterface, int i) {
        this.mentionContainer.getAdapter().clearRecentHashtags();
    }

    public void lambda$createView$46(View view) {
        this.wasManualScroll = true;
        getMessagesController().getNextReactionMention(this.dialog_id, getTopicId(), this.reactionsMentionCount, new Consumer() {
            public final void accept(Object obj) {
                ChatActivity.this.lambda$createView$45((Integer) obj);
            }
        });
    }

    public void lambda$createView$45(Integer num) {
        if (num.intValue() == 0) {
            this.reactionsMentionCount = 0;
            updateReactionsMentionButton(true);
            getMessagesController().markReactionsAsRead(this.dialog_id, getTopicId());
        } else {
            updateReactionsMentionButton(true);
            scrollToMessageId(num.intValue(), 0, false, 0, true, 0);
        }
    }

    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();
            }
        });
        if (!PlusSettings.disableActionsVibrations) {
            view.performHapticFeedback(0, 2);
        }
        return false;
    }

    public void lambda$createView$47() {
        for (int i = 0; i < this.messages.size(); i++) {
            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 void lambda$createView$53(View view, int i) {
        if (this.chatMode == 7) {
            Object item = this.messagesSearchAdapter.getItem(i);
            if (item instanceof MessageObject) {
                openMessageInOriginalDialog((MessageObject) item);
                return;
            }
            return;
        }
        if (this.searchingReaction != null) {
            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;
        }
        getMediaDataController().jumpToSearchedMessage(((BaseFragment) this).classGuid, i);
        showMessagesSearchListView(false);
    }

    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$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$50(DialogInterface dialogInterface) {
        showPinnedProgress(false);
    }

    public boolean lambda$createView$54(View view, MotionEvent motionEvent) {
        if (motionEvent.getAction() == 0) {
            checkRecordLocked(false);
        }
        this.overlayView.getParent().requestDisallowInterceptTouchEvent(true);
        return true;
    }

    public class AnonymousClass42 extends ChatActivityEnterView {
        public int lastContentViewHeight;
        public int messageEditTextPredrawHeigth;
        public int messageEditTextPredrawScrollY;

        public AnonymousClass42(Activity context, SizeNotifierFrameLayout parent, ChatActivity fragment, final boolean isChat, Theme.ResourcesProvider resourcesProvider) {
            super(context, parent, fragment, isChat, resourcesProvider);
        }

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

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

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

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

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

        public void checkAnimation() {
            if (((BaseFragment) ChatActivity.this).actionBar.isActionModeShowed() || ChatActivity.this.reportType >= 0) {
                if (ChatActivity.this.messageEditTextAnimator != null) {
                    ChatActivity.this.messageEditTextAnimator.cancel();
                }
                if (ChatActivity.this.changeBoundAnimator != null) {
                    ChatActivity.this.changeBoundAnimator.cancel();
                }
                ChatActivity.this.chatActivityEnterViewAnimateFromTop = 0;
                ((ChatActivityEnterView) this).shouldAnimateEditTextWithBounds = false;
                return;
            }
            int backgroundTop = getBackgroundTop();
            if (ChatActivity.this.chatActivityEnterViewAnimateFromTop != 0 && backgroundTop != ChatActivity.this.chatActivityEnterViewAnimateFromTop && this.lastContentViewHeight == ChatActivity.this.contentView.getMeasuredHeight()) {
                int i = (((ChatActivityEnterView) this).animatedTop + ChatActivity.this.chatActivityEnterViewAnimateFromTop) - backgroundTop;
                ((ChatActivityEnterView) this).animatedTop = i;
                ((ChatActivityEnterView) this).messageEditTextContainer.invalidate();
                if (ChatActivity.this.changeBoundAnimator != null) {
                    ChatActivity.this.changeBoundAnimator.removeAllListeners();
                    ChatActivity.this.changeBoundAnimator.cancel();
                }
                float f = i;
                ChatActivity.this.chatListView.setTranslationY(f);
                View view = ((ChatActivityEnterView) this).topView;
                if (view != null && view.getVisibility() == 0) {
                    ((ChatActivityEnterView) this).topView.setTranslationY(((ChatActivityEnterView) this).animatedTop + ((1.0f - ((ChatActivityEnterView) this).topViewEnterProgress) * r0.getLayoutParams().height));
                    View view2 = ((ChatActivityEnterView) this).topLineView;
                    if (view2 != null) {
                        view2.setTranslationY(((ChatActivityEnterView) this).animatedTop);
                    }
                }
                MentionsContainerView mentionsContainerView = ChatActivity.this.mentionContainer;
                if (mentionsContainerView != null) {
                    mentionsContainerView.setTranslationY(f);
                }
                ChatActivity.this.changeBoundAnimator = ValueAnimator.ofFloat(f, 0.0f);
                ChatActivity.this.changeBoundAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                    @Override
                    public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                        ChatActivity.AnonymousClass42.this.lambda$checkAnimation$0(valueAnimator);
                    }
                });
                ChatActivity.this.changeBoundAnimator.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        ((ChatActivityEnterView) AnonymousClass42.this).animatedTop = 0;
                        if (((ChatActivityEnterView) AnonymousClass42.this).topView != null && ((ChatActivityEnterView) AnonymousClass42.this).topView.getVisibility() == 0) {
                            ((ChatActivityEnterView) AnonymousClass42.this).topView.setTranslationY(((ChatActivityEnterView) AnonymousClass42.this).animatedTop + ((1.0f - ((ChatActivityEnterView) AnonymousClass42.this).topViewEnterProgress) * ((ChatActivityEnterView) AnonymousClass42.this).topView.getLayoutParams().height));
                            if (((ChatActivityEnterView) AnonymousClass42.this).topLineView != null) {
                                ((ChatActivityEnterView) AnonymousClass42.this).topLineView.setTranslationY(((ChatActivityEnterView) AnonymousClass42.this).animatedTop);
                            }
                        } else {
                            ChatActivity.this.chatListView.setTranslationY(0.0f);
                            MentionsContainerView mentionsContainerView2 = ChatActivity.this.mentionContainer;
                            if (mentionsContainerView2 != null) {
                                mentionsContainerView2.setTranslationY(0.0f);
                            }
                        }
                        ChatActivity.this.changeBoundAnimator = null;
                    }
                });
                ChatActivity.this.changeBoundAnimator.setDuration(250L);
                ChatActivity.this.changeBoundAnimator.setInterpolator(ChatListItemAnimator.DEFAULT_INTERPOLATOR);
                if (!ChatActivity.this.waitingForSendingMessageLoad) {
                    ChatActivity.this.changeBoundAnimator.start();
                }
                ChatActivity.this.invalidateChatListViewTopPadding();
                ChatActivity.this.invalidateMessagesVisiblePart();
                ChatActivity.this.chatActivityEnterViewAnimateFromTop = 0;
            } else if (this.lastContentViewHeight != ChatActivity.this.contentView.getMeasuredHeight()) {
                ChatActivity.this.chatActivityEnterViewAnimateFromTop = 0;
            }
            if (((ChatActivityEnterView) this).shouldAnimateEditTextWithBounds) {
                float measuredHeight = (this.messageEditTextPredrawHeigth - ((ChatActivityEnterView) this).messageEditText.getMeasuredHeight()) + (this.messageEditTextPredrawScrollY - ((ChatActivityEnterView) this).messageEditText.getScrollY());
                EditTextCaption editTextCaption = ((ChatActivityEnterView) this).messageEditText;
                editTextCaption.setOffsetY(editTextCaption.getOffsetY() - measuredHeight);
                ValueAnimator ofFloat = ValueAnimator.ofFloat(((ChatActivityEnterView) this).messageEditText.getOffsetY(), 0.0f);
                ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                    @Override
                    public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                        ChatActivity.AnonymousClass42.this.lambda$checkAnimation$1(valueAnimator);
                    }
                });
                if (ChatActivity.this.messageEditTextAnimator != null) {
                    ChatActivity.this.messageEditTextAnimator.cancel();
                }
                ChatActivity.this.messageEditTextAnimator = ofFloat;
                ofFloat.setDuration(250L);
                ofFloat.setInterpolator(ChatListItemAnimator.DEFAULT_INTERPOLATOR);
                ofFloat.start();
                ((ChatActivityEnterView) this).shouldAnimateEditTextWithBounds = false;
            }
            this.lastContentViewHeight = ChatActivity.this.contentView.getMeasuredHeight();
            ChatActivity.this.chatActivityEnterViewAnimateBeforeSending = false;
        }

        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) {
                ((ChatActivityEnterView) this).topView.setTranslationY(((1.0f - ((ChatActivityEnterView) this).topViewEnterProgress) * r0.getLayoutParams().height) + floatValue);
                View view2 = ((ChatActivityEnterView) this).topLineView;
                if (view2 != null) {
                    view2.setTranslationY(floatValue);
                }
            } else {
                MentionsContainerView mentionsContainerView = ChatActivity.this.mentionContainer;
                if (mentionsContainerView != null) {
                    mentionsContainerView.setTranslationY(floatValue);
                }
                ChatActivity.this.chatListView.setTranslationY(floatValue);
                ChatActivity.this.invalidateChatListViewTopPadding();
                ChatActivity.this.invalidateMessagesVisiblePart();
            }
            ((ChatActivityEnterView) this).messageEditTextContainer.invalidate();
            invalidate();
        }

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

        public void onLineCountChanged(int oldLineCount, int newLineCount) {
            if (ChatActivity.this.chatActivityEnterView != null) {
                ((ChatActivityEnterView) this).shouldAnimateEditTextWithBounds = true;
                this.messageEditTextPredrawHeigth = ((ChatActivityEnterView) this).messageEditText.getMeasuredHeight();
                this.messageEditTextPredrawScrollY = ((ChatActivityEnterView) this).messageEditText.getScrollY();
                ChatActivity.this.contentView.invalidate();
                ChatActivity chatActivity = ChatActivity.this;
                chatActivity.chatActivityEnterViewAnimateFromTop = chatActivity.chatActivityEnterView.getBackgroundTop();
            }
        }
    }

    public void lambda$createView$56(View view) {
        MessageObject messageObject;
        int i = this.fieldPanelShown;
        if (i == 1 && (messageObject = this.editingMessageObject) != null) {
            if (messageObject.canEditMedia() && this.editingMessageObjectReqId == 0) {
                if (this.chatAttachAlert == null) {
                    createChatAttachView();
                }
                this.chatAttachAlert.setEditingMessageObject(this.editingMessageObject);
                openAttachMenu();
                return;
            }
            scrollToMessageId(this.editingMessageObject.getId(), 0, true, 0, true, 0);
            return;
        }
        if (this.messagePreviewParams != null) {
            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) {
                    ReplyQuote replyQuote = messagePreviewParams.quote;
                    SharedConfig.replyingOptionsHintHintShowed();
                    openForwardingPreview(0);
                    return;
                }
            }
            MessageObject messageObject2 = this.replyingMessageObject;
            if (messageObject2 != null) {
                scrollToMessageId(messageObject2.getId(), 0, true, 0, true, 0);
            }
        }
    }

    public boolean lambda$createView$57(View view) {
        MessageObject messageObject = this.replyingMessageObject;
        if (messageObject == null) {
            return true;
        }
        scrollToMessageId(messageObject.getId(), 0, true, 0, true, 0);
        return true;
    }

    public static void lambda$createView$58(Switch r0, boolean z) {
        PlusSettings.setDeleteCaption(!z);
    }

    public void lambda$createView$59(View view) {
        MessageObject messageObject;
        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);
            }
            fallbackFieldPanel();
            return;
        }
        if (i == 3) {
            openAnotherForward();
            return;
        }
        if (i == 4) {
            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();
            return;
        }
        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, true);
    }

    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, FrameLayout frameLayout, View view) {
        MessageObject messageObject = this.editingMessageObject;
        if (messageObject != null && messageObject.canEditMedia() && this.editingMessageObjectReqId == 0) {
            if (editViewButton.isEditButton()) {
                openEditingMessageInPhotoEditor();
            } else {
                frameLayout.callOnClick();
            }
        }
    }

    public void lambda$createView$62(View view) {
        this.bottomOverlayChatText.callOnClick();
    }

    public void lambda$createView$68(final Context context, View view) {
        String str;
        if (getParentActivity() == null || this.pullingDownOffset != 0.0f) {
            return;
        }
        int i = this.chatMode;
        if (i == 3) {
            Bundle bundle = new Bundle();
            long savedDialogId = getSavedDialogId();
            if (savedDialogId >= 0) {
                bundle.putLong("user_id", savedDialogId);
            } else {
                bundle.putLong("chat_id", -savedDialogId);
            }
            presentFragment(new ChatActivity(bundle));
            return;
        }
        if (this.reportType >= 0) {
            showDialog(new ReportAlert(getParentActivity(), this.reportType, getResourceProvider()) {
                public void onSend(int type, String message) {
                    ArrayList arrayList = new ArrayList();
                    for (int i2 = 0; i2 < ChatActivity.this.selectedMessagesIds[0].size(); i2++) {
                        arrayList.add(Integer.valueOf(ChatActivity.this.selectedMessagesIds[0].keyAt(i2)));
                    }
                    ChatActivity chatActivity = ChatActivity.this;
                    TLRPC.User user = chatActivity.currentUser;
                    AlertsCreator.sendReport(user != null ? MessagesController.getInputPeer(user) : MessagesController.getInputPeer(chatActivity.currentChat), ChatActivity.this.reportType, message, arrayList, 0);
                    ChatActivity.this.lambda$onBackPressed$358();
                    ChatActivity.this.chatActivityDelegate.onReport();
                }
            });
            return;
        }
        if (i == 2) {
            lambda$onBackPressed$358();
            this.chatActivityDelegate.onUnpin(true, this.bottomOverlayChatText.getTag() == null);
            return;
        }
        TLRPC.User user = this.currentUser;
        if (user != null && this.userBlocked) {
            if (user.bot) {
                final String str2 = this.botUser;
                this.botUser = null;
                getMessagesController().unblockPeer(this.currentUser.id, new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.this.lambda$createView$63(str2);
                    }
                });
                return;
            } else {
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity(), this.themeDelegate);
                builder.setMessage(LocaleController.getString("AreYouSureUnblockContact", R.string.AreYouSureUnblockContact));
                builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
                    @Override
                    public final void onClick(DialogInterface dialogInterface, int i2) {
                        ChatActivity.this.lambda$createView$64(dialogInterface, i2);
                    }
                });
                builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                showDialog(builder.create());
                return;
            }
        }
        if (UserObject.isReplyUser(user)) {
            toggleMute(true);
            return;
        }
        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$65();
                            }
                        }, new MessagesController.ErrorDelegate() {
                            public final boolean run(TLRPC.TL_error tL_error) {
                                boolean lambda$createView$66;
                                lambda$createView$66 = ChatActivity.this.lambda$createView$66(context, tL_error);
                                return lambda$createView$66;
                            }
                        });
                        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;
                }
                toggleMute(true);
                return;
            }
        }
        TLRPC.Chat chat2 = this.currentChat;
        if (chat2 != null && ChatObject.isLeftFromChat(chat2)) {
            showBottomOverlayProgress(true, true);
            getMessagesController().addUserToChat(this.currentChat.id, getUserConfig().getCurrentUser(), 0, (String) null, this, (Runnable) null);
            NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.closeSearchByActiveAction, new Object[0]);
        } else {
            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$67(z);
                }
            }, this.themeDelegate);
        }
    }

    public void lambda$createView$63(String str) {
        if (str != null && str.length() != 0) {
            getMessagesController().sendBotStart(this.currentUser, str);
        } 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));
        }
    }

    public void lambda$createView$64(DialogInterface dialogInterface, int i) {
        getMessagesController().unblockPeer(this.currentUser.id);
    }

    public void lambda$createView$65() {
        showBottomOverlayProgress(false, true);
    }

    public boolean lambda$createView$66(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$67(boolean z) {
        NotificationCenter notificationCenter = getNotificationCenter();
        int i = NotificationCenter.closeChats;
        notificationCenter.removeObserver(this, i);
        getNotificationCenter().postNotificationName(i, new Object[0]);
        lambda$onBackPressed$358();
        getNotificationCenter().postNotificationName(NotificationCenter.needDeleteDialog, new Object[]{Long.valueOf(this.dialog_id), this.currentUser, this.currentChat, Boolean.valueOf(z)});
    }

    public void lambda$createView$69(View view) {
        if (this.chatInfo == null) {
            return;
        }
        Bundle bundle = new Bundle();
        bundle.putLong("chat_id", this.chatInfo.linked_chat_id);
        if (getMessagesController().checkCanOpenChat(bundle, this)) {
            presentFragment(new ChatActivity(bundle));
        }
    }

    public void lambda$createView$70(View view) {
        createUndoView();
        this.undoView.showWithAction(this.dialog_id, 18, LocaleController.getString("BroadcastGroupInfo", R.string.BroadcastGroupInfo));
    }

    public boolean lambda$createView$71() {
        return this.currentEncryptedChat != null || getMessagesController().isChatNoForwards(this.currentChat);
    }

    public void lambda$createView$72(float[] fArr) {
        fArr[1] = this.chatListView.getBottom() - this.blurredViewBottomOffset;
        fArr[0] = (this.chatListView.getTop() + this.chatListViewPaddingTop) - AndroidUtilities.dp(4.0f);
    }

    public void lambda$createView$73() {
        HintView2 hintView2;
        BlurredFrameLayout blurredFrameLayout = this.searchContainer;
        if ((blurredFrameLayout == null || blurredFrameLayout.getVisibility() != 0) && (hintView2 = this.savedMessagesSearchHint) != null) {
            hintView2.show();
        }
    }

    public void onScrollDown(boolean clearStack) {
        this.wasManualScroll = true;
        this.textSelectionHelper.cancelTextSelectionRunnable();
        int i = this.createUnreadMessageAfterId;
        if (i != 0) {
            scrollToMessageId(i, 0, false, this.returnToLoadIndex, true, 0);
            return;
        }
        if (!clearStack && !this.returnToMessageIdStack.empty()) {
            scrollToMessageId(this.returnToMessageIdStack.pop().intValue(), 0, true, this.returnToLoadIndex, true, 0);
            return;
        }
        if (clearStack) {
            this.returnToMessageIdStack.clear();
        }
        scrollToLastMessage(true, false);
        if (this.pinnedMessageIds.isEmpty()) {
            return;
        }
        this.forceScrollToFirst = true;
        this.forceNextPinnedMessageId = this.pinnedMessageIds.get(0).intValue();
    }

    public final void insertOrUpdateHidden(TLRPC.Dialog dialog, boolean hidden, int folder) {
        if (dialog != null) {
            dialog.hidden = hidden;
            dialog.folder_id = folder;
            long j = dialog.id;
            if (DialogObject.isEncryptedDialog(j)) {
                if (!hidden) {
                    PlusRepository.getInstance(((BaseFragment) this).currentAccount).deleteHiddenDialog(new DialogEntity(getUserConfig().clientUserId, j, getMessagesController().favsDialogs.contains(Long.valueOf(j)), hidden));
                }
                j = DialogObject.getEncryptedChatId(j);
            }
            boolean contains = getMessagesController().favsDialogs.contains(Long.valueOf(j));
            DialogEntity dialogEntity = new DialogEntity(getUserConfig().clientUserId, j, contains, hidden);
            if (contains || hidden) {
                PlusRepository.getInstance(((BaseFragment) this).currentAccount).insertOrUpdateHidden(dialogEntity);
            } else {
                PlusRepository.getInstance(((BaseFragment) this).currentAccount).deleteHiddenDialog(dialogEntity);
            }
            if (MessagesController.getInstance(((BaseFragment) this).currentAccount).getUser(Long.valueOf(j)) != null) {
                getMediaDataController().loadHints(true, true);
            }
            getMessagesController().addDialogToFolder(j, folder, -1, 0L);
        }
    }

    public final void addDirectShareButton(Context context) {
        TextView textView = new TextView(context);
        this.directShareButton = textView;
        textView.setVisibility(8);
        this.directShareButton.setText(LocaleController.getString("DirectShare", R.string.DirectShare));
        this.directShareButton.setGravity(16);
        this.directShareButton.setTextSize(1, 15.0f);
        this.directShareButton.setPadding(AndroidUtilities.dp(14.0f), 0, AndroidUtilities.dp(21.0f), 0);
        this.directShareButton.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_actionBarActionModeDefaultSelector), 3));
        TextView textView2 = this.directShareButton;
        int i = Theme.key_actionBarActionModeDefaultIcon;
        textView2.setTextColor(Theme.getColor(i));
        this.directShareButton.setCompoundDrawablePadding(AndroidUtilities.dp(7.0f));
        this.directShareButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
        Drawable mutate = context.getResources().getDrawable(R.drawable.msg_share_2).mutate();
        mutate.setColorFilter(new PorterDuffColorFilter(Theme.getColor(i), PorterDuff.Mode.MULTIPLY));
        this.directShareButton.setCompoundDrawablesWithIntrinsicBounds(mutate, (Drawable) null, (Drawable) null, (Drawable) null);
        this.directShareButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ChatActivity.this.lambda$addDirectShareButton$74(view);
            }
        });
        this.bottomMessagesActionContainer.addView(this.directShareButton, LayoutHelper.createFrame(-2, -1, 51));
    }

    public void lambda$addDirectShareButton$74(View view) {
        directShareOnClick();
    }

    public final void addSqueduleDownloadButton(Context context) {
        ImageView imageView = new ImageView(context);
        this.scheduleDownloadButton = imageView;
        imageView.setVisibility(8);
        this.scheduleDownloadButton.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_actionBarActionModeDefaultSelector), 3));
        this.scheduleDownloadButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_actionBarActionModeDefaultIcon), PorterDuff.Mode.MULTIPLY));
        this.scheduleDownloadButton.setImageResource(R.drawable.msg_calendar2);
        this.scheduleDownloadButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ChatActivity.this.lambda$addSqueduleDownloadButton$75(view);
            }
        });
        this.scheduleDownloadButton.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public final boolean onLongClick(View view) {
                boolean lambda$addSqueduleDownloadButton$76;
                lambda$addSqueduleDownloadButton$76 = ChatActivity.this.lambda$addSqueduleDownloadButton$76(view);
                return lambda$addSqueduleDownloadButton$76;
            }
        });
        this.bottomMessagesActionContainer.addView(this.scheduleDownloadButton, LayoutHelper.createFrame(-2, -1, 49));
    }

    public void lambda$addSqueduleDownloadButton$75(View view) {
        squeduleDownloadOnClick(false);
    }

    public boolean lambda$addSqueduleDownloadButton$76(View view) {
        squeduleDownloadOnClick(true);
        return true;
    }

    public final void directShareOnClick() {
        String str;
        if (getMessagesController().isChatNoForwards(this.currentChat)) {
            openForward(false);
            return;
        }
        ArrayList arrayList = new ArrayList();
        for (int i = 1; i >= 0; i--) {
            ArrayList arrayList2 = new ArrayList();
            for (int i2 = 0; i2 < this.selectedMessagesIds[i].size(); i2++) {
                arrayList2.add(Integer.valueOf(this.selectedMessagesIds[i].keyAt(i2)));
            }
            Collections.sort(arrayList2);
            for (int i3 = 0; i3 < arrayList2.size(); i3++) {
                Integer num = (Integer) arrayList2.get(i3);
                MessageObject messageObject = this.selectedMessagesIds[i].get(num.intValue());
                if (messageObject != null && num.intValue() > 0) {
                    arrayList.add(messageObject);
                }
            }
        }
        MessageObject messageObject2 = null;
        for (int i4 = 1; i4 >= 0; i4--) {
            if (messageObject2 == null && this.selectedMessagesIds[i4].size() != 0) {
                messageObject2 = this.messagesDict[i4].get(this.selectedMessagesIds[i4].keyAt(0));
            }
            this.selectedMessagesIds[i4].clear();
            this.selectedMessagesCanCopyIds[i4].clear();
            this.selectedMessagesCanStarIds[i4].clear();
        }
        hideActionMode();
        updatePinnedMessageView(true);
        updateVisibleRows();
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView != null) {
            chatActivityEnterView.closeKeyboard();
        }
        ShareAlert shareAlert = new ShareAlert(getParentActivity(), arrayList, (String) null, ChatObject.isChannel(this.currentChat) && (str = this.currentChat.username) != null && str.length() > 0, (String) null, false);
        this.shareAlert = shareAlert;
        showDialog(shareAlert);
        this.shareAlert.setParentFragment(this);
    }

    public final void squeduleDownloadOnClick(final boolean longClick) {
        final ArrayList arrayList = new ArrayList();
        int i = 1;
        while (true) {
            if (i < 0) {
                break;
            }
            ArrayList arrayList2 = new ArrayList();
            for (int i2 = 0; i2 < this.selectedMessagesIds[i].size(); i2++) {
                arrayList2.add(Integer.valueOf(this.selectedMessagesIds[i].keyAt(i2)));
            }
            Collections.sort(arrayList2);
            for (int i3 = 0; i3 < arrayList2.size(); i3++) {
                Integer num = (Integer) arrayList2.get(i3);
                MessageObject messageObject = this.selectedMessagesIds[i].get(num.intValue());
                if (messageObject != null && num.intValue() > 0 && !messageObject.mediaExists && messageObject.getDocument() != null) {
                    arrayList.add(messageObject);
                }
            }
            i--;
        }
        MessageObject messageObject2 = null;
        for (int i4 = 1; i4 >= 0; i4--) {
            if (messageObject2 == null && this.selectedMessagesIds[i4].size() != 0) {
                messageObject2 = this.messagesDict[i4].get(this.selectedMessagesIds[i4].keyAt(0));
            }
            this.selectedMessagesIds[i4].clear();
            this.selectedMessagesCanCopyIds[i4].clear();
            this.selectedMessagesCanStarIds[i4].clear();
        }
        AlertsCreator.createScheduleDatePickerDialog(getParentActivity(), this.dialog_id, new AlertsCreator.ScheduleDatePickerDelegate() {
            public final void didSelectDate(boolean z, int i5) {
                ChatActivity.this.lambda$squeduleDownloadOnClick$77(arrayList, longClick, z, i5);
            }
        }, this.themeDelegate);
        hideActionMode();
        updatePinnedMessageView(true);
        updateVisibleRows();
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView != null) {
            chatActivityEnterView.closeKeyboard();
        }
    }

    public void lambda$squeduleDownloadOnClick$77(ArrayList arrayList, boolean z, boolean z2, int i) {
        getSendMessagesHelper().sendMessage(arrayList, getUserConfig().getClientUserId(), false, false, z || !PlusSettings.hideScheduledDownloadReminder, i);
        for (int i2 = 0; i2 < arrayList.size(); i2++) {
            MessageObject messageObject = (MessageObject) arrayList.get(i2);
            PlusSettings.getScheduledDownloadsIds().put(messageObject.getFileName(), messageObject.getDialogId() + "," + messageObject.getId());
        }
        PlusSettings.saveScheduledDownloadsIds();
    }

    public final void updateAvatarLayout() {
        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) this.avatarContainer.getLayoutParams();
        if (layoutParams == null) {
            return;
        }
        ActionBarMenu.LazyItem lazyItem = this.audioCallIconItem;
        int i = (lazyItem == null || lazyItem.getVisibility() != 0) ? 40 : 80;
        ActionBarMenuItem actionBarMenuItem = this.search2Item;
        if ((actionBarMenuItem != null && actionBarMenuItem.getVisibility() == 0) || this.showSearchAsIcon) {
            i += i > 40 ? 60 : 40;
        }
        layoutParams.rightMargin = AndroidUtilities.dp(i);
        this.avatarContainer.setLayoutParams(layoutParams);
    }

    public final void updateChatDialogsView(final boolean visible) {
        float f;
        ChatDialogsView chatDialogsView = this.chatDialogsView;
        boolean z = Theme.plusVerticalQuickBar;
        String str = z ? "translationX" : "translationY";
        float[] fArr = new float[1];
        if (visible) {
            f = z ? AndroidUtilities.dp(chatDialogsView.getListWidth()) : -AndroidUtilities.dp(chatDialogsView.getListHeight());
        } else {
            f = 0.0f;
        }
        fArr[0] = f;
        ObjectAnimator duration = ObjectAnimator.ofFloat(chatDialogsView, str, fArr).setDuration(200L);
        duration.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                ChatActivity.this.chatDialogsView.setBtnResId(visible ? Theme.plusVerticalQuickBar ? R.drawable.ic_bar_open : R.drawable.msg_go_down : Theme.plusVerticalQuickBar ? R.drawable.ic_bar_close : R.drawable.msg_go_up);
            }
        });
        duration.start();
    }

    public final 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);
    }

    public final void showBotMessageHint(final ChatMessageCell cell, boolean byClick) {
        if (getContext() == null || cell == null || cell.timeLayout == null || cell.getPrimaryMessageObject() == null || cell.getPrimaryMessageObject().messageOwner == null || cell.getPrimaryMessageObject().messageOwner.via_business_bot_id == 0) {
            return;
        }
        if (!byClick) {
            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 (!byClick) {
                return;
            }
            hintView2.setOnHiddenListener(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$showBotMessageHint$78(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$79(cell);
            }
        });
    }

    public void lambda$showBotMessageHint$78(HintView2 hintView2) {
        this.contentView.removeView(hintView2);
    }

    public void lambda$showBotMessageHint$79(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 final void hideHints() {
        HintView2 hintView2 = this.savedMessagesTagHint;
        if (hintView2 != null && hintView2.shown()) {
            this.savedMessagesTagHint.hide();
        }
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView != null) {
            chatActivityEnterView.hideHints();
        }
    }

    public void setTagFilter(ReactionsLayoutInBubble.VisibleReaction reaction) {
        SearchTagsList searchTagsList = this.actionBarSearchTags;
        if (searchTagsList != null) {
            searchTagsList.setChosen(reaction, true);
        }
        boolean z = (TextUtils.isEmpty(this.searchingQuery) && this.searchingReaction == null) ? false : true;
        this.searching = z;
        this.searchItemVisible = z;
        updateBottomOverlay();
        updateSearchUpDownButtonVisibility(true);
    }

    public void setSearchQuery(String text) {
        ActionBarMenuItem actionBarMenuItem = this.searchItem;
        if (actionBarMenuItem != null) {
            this.searchingQuery = text;
            actionBarMenuItem.setSearchFieldText(text, false);
        }
    }

    public void hitSearch() {
        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 clearSearch() {
        SearchItemListener searchItemListener = this.searchItemListener;
        if (searchItemListener != null) {
            searchItemListener.onSearchCollapse();
        }
        this.searching = false;
        this.searchItemVisible = false;
        updateBottomOverlay();
        updateSearchUpDownButtonVisibility(true);
    }

    public final void setFilterMessages(boolean filter) {
        setFilterMessages(filter, false, true);
    }

    public final void setFilterMessages(boolean filter, boolean ignoreMessageNotFound, boolean animated) {
        ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
        if (chatActivityAdapter == null || chatActivityAdapter.isFiltered == filter) {
            return;
        }
        chatActivityAdapter.isFiltered = filter;
        boolean z = true;
        createEmptyView(true);
        if (filter) {
            updateFilteredMessages(false);
        }
        if (!saveScrollOnFilterToggle(animated, ignoreMessageNotFound)) {
            this.chatAdapter.isFiltered = !filter;
        }
        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) {
            z = false;
        }
        showProgressView(z);
        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 final boolean saveScrollOnFilterToggle(boolean r26, boolean r27) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.saveScrollOnFilterToggle(boolean, boolean):boolean");
    }

    public final void putFilteredDate(int index, MessageObject baseMsg) {
        TLRPC.TL_message tL_message = new TLRPC.TL_message();
        ((TLRPC.Message) tL_message).message = LocaleController.formatDateChat(baseMsg.messageOwner.date);
        ((TLRPC.Message) tL_message).id = 0;
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(baseMsg.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 messageObject = new MessageObject(((BaseFragment) this).currentAccount, tL_message, false, false);
        messageObject.type = 10;
        messageObject.contentType = 1;
        messageObject.isDateObject = true;
        messageObject.stableId = getStableIdForDateObject(baseMsg.dateKeyInt);
        this.chatAdapter.filteredMessages.add(index, messageObject);
    }

    public final void createHint2MessageObject() {
        if (this.hint2MessageObject != null) {
            return;
        }
        TLRPC.TL_message tL_message = new TLRPC.TL_message();
        if (this.chatMode == 3) {
            ((TLRPC.Message) tL_message).message = LocaleController.getString(R.string.SavedMessagesProfileHint);
        } else {
            ((TLRPC.Message) tL_message).message = LocaleController.getString(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 final void updateFilteredMessages(boolean notify) {
        boolean z;
        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<ArrayList<MessageObject>> 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) {
            z = 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 = 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) {
                    messageObject.copyStableParams(messageObject2);
                } else {
                    messageObject2.copyStableParams(messageObject);
                }
            } 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()) {
                            z = false;
                            break;
                        } else if (((MessageObject) groupedMessages2.messages.get(i4)).getId() == messageObject2.getId()) {
                            break;
                        } else {
                            i4++;
                        }
                    }
                    if (!z) {
                        groupedMessages2.messages.add(messageObject2);
                    }
                }
            } 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$80;
                        lambda$updateFilteredMessages$80 = ChatActivity.lambda$updateFilteredMessages$80((MessageObject) obj, (MessageObject) obj2);
                        return lambda$updateFilteredMessages$80;
                    }
                });
                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 = 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 = 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$81;
                lambda$updateFilteredMessages$81 = ChatActivity.lambda$updateFilteredMessages$81((MessageObject) obj, (MessageObject) obj2);
                return lambda$updateFilteredMessages$81;
            }
        });
        MessageObject messageObject7 = null;
        int i10 = 0;
        while (i10 < this.chatAdapter.filteredMessages.size()) {
            MessageObject messageObject8 = 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<ArrayList<MessageObject>> 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 (notify) {
            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) {
                z = false;
            }
            showProgressView(z);
            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 static int lambda$updateFilteredMessages$80(MessageObject messageObject, MessageObject messageObject2) {
        return messageObject.getId() - messageObject2.getId();
    }

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

    public final void createBottomMessagesActionButtons() {
        if (this.replyButton != null || getContext() == null) {
            return;
        }
        if (!this.isInsideContainer) {
            TextView textView = new TextView(getContext());
            this.replyButton = textView;
            textView.setText(LocaleController.getString("Reply", 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$82(view);
                }
            });
            this.bottomMessagesActionContainer.addView(this.replyButton, LayoutHelper.createFrame(-2, -1, 51));
        }
        TextView textView3 = new TextView(getContext());
        this.forwardButton = textView3;
        textView3.setText(LocaleController.getString("Forward", 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$83(view);
            }
        });
        this.bottomMessagesActionContainer.addView(this.forwardButton, LayoutHelper.createFrame(-2, -1, 53));
    }

    public void lambda$createBottomMessagesActionButtons$82(View view) {
        int i;
        MessageObject messageObject = null;
        for (int i2 = 1; i2 >= 0; i2--) {
            if (messageObject == null && this.selectedMessagesIds[i2].size() != 0) {
                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))) {
            this.forceReply = true;
            showFieldPanelForReply(messageObject);
        }
        updatePinnedMessageView(true);
        updateVisibleRows();
        updateSelectedMessageReactions();
    }

    public void lambda$createBottomMessagesActionButtons$83(View view) {
        QuoteForward = true;
        openForward(false);
    }

    public final void checkInstantSearch() {
        TLRPC.Chat chat;
        long j = getArguments().getLong("search_from_user_id", 0L);
        getMediaDataController().setOnlyUserId(((BaseFragment) this).arguments.getLong("only_id", 0L), ((BaseFragment) this).arguments.getLong("only_id_media", 0L));
        if (j != 0) {
            TLRPC.User user = getMessagesController().getUser(Long.valueOf(j));
            if (user != null) {
                lambda$openSearchWithText$363("");
                ImageView imageView = this.searchUserButton;
                if (imageView != null) {
                    imageView.callOnClick();
                }
                searchUserMessages(user, null);
                return;
            }
            return;
        }
        long j2 = getArguments().getLong("search_from_chat_id", 0L);
        if (j2 == 0 || (chat = getMessagesController().getChat(Long.valueOf(j2))) == null) {
            return;
        }
        lambda$openSearchWithText$363("");
        ImageView imageView2 = this.searchUserButton;
        if (imageView2 != null) {
            imageView2.callOnClick();
        }
        searchUserMessages(null, chat);
    }

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

    public void lambda$createTopPanel$85(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$84(i);
            }
        }, this.themeDelegate);
    }

    public void lambda$createTopPanel$84(int i) {
        if (i == 0) {
            updateTopPanel(true);
        } else {
            lambda$onBackPressed$358();
        }
    }

    public void lambda$createTopPanel$88(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) {
            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$86(arrayList, i2);
                }

                @Override
                public void needAddBot(TLRPC.User user) {
                    GroupCreateActivity.ContactsAddActivityDelegate.CC.$default$needAddBot(this, user);
                }
            });
            inviteMembersBottomSheet.show();
            return;
        }
        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$87();
            }
        });
        presentFragment(contactAddActivity);
    }

    public void lambda$createTopPanel$86(ArrayList arrayList, int i) {
        getMessagesController().addUsersToChat(this.currentChat, this, arrayList, i, (Consumer) null, (Consumer) null, (Runnable) null);
        getMessagesController().hidePeerSettingsBar(this.dialog_id, this.currentUser, this.currentChat);
        updateTopPanel(true);
        updateInfoTopView(true);
    }

    public void lambda$createTopPanel$87() {
        if (this.undoView != null || getContext() == null) {
            return;
        }
        createUndoView();
        this.undoView.showWithAction(this.dialog_id, 8, this.currentUser);
    }

    public void lambda$createTopPanel$89(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$90(View view) {
        long j = this.dialog_id;
        if (this.currentEncryptedChat != null) {
            j = this.currentUser.id;
        }
        getMessagesController().hidePeerSettingsBar(j, this.currentUser, this.currentChat);
        updateTopPanel(true);
        updateInfoTopView(true);
    }

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

            public 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));
    }

    public final void createBizBotButton() {
        if (this.bizBotButton != null || getContext() == null) {
            return;
        }
        createTopPanel();
        if (this.topChatPanelView == null) {
            return;
        }
        BusinessBotButton businessBotButton = new BusinessBotButton(this, 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));
    }

    public final 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 final void createActionMode() {
        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$91;
                lambda$createActionMode$91 = ChatActivity.lambda$createActionMode$91(view, motionEvent);
                return lambda$createActionMode$91;
            }
        });
        createActionMode.addView((View) this.selectedMessagesCountTextView, (ViewGroup.LayoutParams) LayoutHelper.createLinear(0, -1, 1.0f, this.actionModePadding + 5, 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(this.actionModePadding), LocaleController.getString(R.string.SaveToMusic)));
            this.actionModeViews.add(createActionMode.addItemWithWidth(23, R.drawable.msg_edit, AndroidUtilities.dp(this.actionModePadding), 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(89, R.drawable.msg_select, AndroidUtilities.dp(this.actionModePadding)));
            this.actionModeViews.add(createActionMode.addItemWithWidth(82, R.drawable.msg_share, AndroidUtilities.dp(this.actionModePadding)));
            this.actionModeViews.add(createActionMode.addItemWithWidth(83, R.drawable.ic_cloud_upload, AndroidUtilities.dp(this.actionModePadding)));
            this.actionModeViews.add(createActionMode.addItemWithWidth(10, R.drawable.msg_copy, AndroidUtilities.dp(54.0f), LocaleController.getString(R.string.Copy)));
            this.actionModeViews.add(createActionMode.addItemWithWidth(111, R.drawable.msg_forward_quote, AndroidUtilities.dp(this.actionModePadding)));
            this.actionModeViews.add(createActionMode.addItemWithWidth(11, R.drawable.msg_forward, AndroidUtilities.dp(this.actionModePadding), LocaleController.getString(R.string.Forward)));
            this.actionModeViews.add(createActionMode.addItemWithWidth(69, R.drawable.msg_shareout, AndroidUtilities.dp(54.0f), LocaleController.getString(R.string.ShareFile)));
            this.actionModeViews.add(createActionMode.addItemWithWidth(12, R.drawable.msg_delete, AndroidUtilities.dp(54.0f), LocaleController.getString(R.string.Delete)));
        } else {
            this.actionModeViews.add(createActionMode.addItemWithWidth(23, R.drawable.msg_edit, AndroidUtilities.dp(this.actionModePadding), LocaleController.getString(R.string.Edit)));
            this.actionModeViews.add(createActionMode.addItemWithWidth(22, R.drawable.msg_fave, AndroidUtilities.dp(this.actionModePadding), LocaleController.getString(R.string.AddToFavorites)));
            this.actionModeViews.add(createActionMode.addItemWithWidth(10, R.drawable.msg_copy, AndroidUtilities.dp(this.actionModePadding), LocaleController.getString(R.string.Copy)));
            this.actionModeViews.add(createActionMode.addItemWithWidth(12, R.drawable.msg_delete, AndroidUtilities.dp(this.actionModePadding), 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() || PlusSettings.hideAddTagsActionModeButton) ? 8 : 0);
        createActionMode.setItemVisibility(69, 8);
    }

    public final 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$92(reactionsContainerLayout);
            }
        }).setDuration(180L).start();
    }

    public void lambda$hideTagSelector$92(ReactionsContainerLayout reactionsContainerLayout) {
        this.contentView.removeView(reactionsContainerLayout);
    }

    public final void showTagSelector() {
        if (getDialogId() == getUserConfig().getClientUserId() && getUserConfig().isPremium() && this.tagSelector == null) {
            ReactionsContainerLayout anonymousClass66 = new AnonymousClass66(3, this, getContext(), ((BaseFragment) this).currentAccount, this.themeDelegate);
            this.tagSelector = anonymousClass66;
            anonymousClass66.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 r24, org.telegram.ui.Components.Reactions.ReactionsLayoutInBubble.VisibleReaction r25, boolean r26, boolean r27) {
                    throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.AnonymousClass67.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));
        }
    }

    public class AnonymousClass66 extends ReactionsContainerLayout {
        public boolean firstLayout;
        public int[] loc;
        public ValueAnimator va;

        public AnonymousClass66(int type, BaseFragment fragment, Context context, int currentAccount, Theme.ResourcesProvider resourcesProvider) {
            super(type, fragment, context, currentAccount, resourcesProvider);
            this.loc = new int[2];
            this.firstLayout = true;
        }

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

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

        public void onLayout(boolean changed, int left, int top, int right, int bottom) {
            super/*android.widget.FrameLayout*/.onLayout(changed, left, top, right, bottom);
            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 z = LocaleController.isRTL;
                float f = width2 + (dp * (z ? -1 : 1));
                if (z) {
                    updateBubbleOffset(f - x, !this.firstLayout);
                } else {
                    updateBubbleOffset(f - width, !this.firstLayout);
                }
                this.firstLayout = false;
            }
        }
    }

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

            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 measureChildWithMargins(View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed) {
                if (child == ChatActivity.this.searchCountText) {
                    int i = 14;
                    if (ChatActivity.this.searchCalendarButton != null && ChatActivity.this.searchCalendarButton.getVisibility() != 8) {
                        i = 62;
                    }
                    if (ChatActivity.this.searchUserButton != null && ChatActivity.this.searchUserButton.getVisibility() != 8) {
                        i += 48;
                    }
                    ((ViewGroup.MarginLayoutParams) child.getLayoutParams()).leftMargin = AndroidUtilities.dp(i);
                }
                super/*android.widget.FrameLayout*/.measureChildWithMargins(child, parentWidthMeasureSpec, widthUsed, parentHeightMeasureSpec, heightUsed);
            }

            public void setVisibility(int visibility) {
                super/*android.widget.FrameLayout*/.setVisibility(visibility);
                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 && visibility == 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$93(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$94(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)) {
            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$95(view);
                }
            });
            this.searchUserButton.setContentDescription(LocaleController.getString("AccDescrSearchByUser", 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$96(view);
                }
            });
            this.searchCalendarButton.setContentDescription(LocaleController.getString("JumpToDate", R.string.JumpToDate));
        }
    }

    public void lambda$createSearchContainer$93(View view) {
        toggleMesagesSearchListView();
    }

    public void lambda$createSearchContainer$94(View view) {
        setFilterMessages(!this.chatAdapter.isFiltered);
    }

    public void lambda$createSearchContainer$95(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("SearchMembers", R.string.SearchMembers));
        this.searchItem.setSearchFieldCaption(LocaleController.getString("SearchFrom", R.string.SearchFrom));
        AndroidUtilities.showKeyboard(this.searchItem.getSearchField());
        this.searchItem.clearSearchText();
    }

    public void lambda$createSearchContainer$96(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 param) {
                ChatActivity.this.jumpToDate(param);
            }
        }, this.themeDelegate).create());
    }

    public void onPageDownClicked() {
        if (PlusSettings.enableReturnToMessageStack) {
            onScrollDown(false);
            return;
        }
        this.wasManualScroll = true;
        this.textSelectionHelper.cancelTextSelectionRunnable();
        Runnable runnable = new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$onPageDownClicked$98();
            }
        };
        int i = this.createUnreadMessageAfterId;
        if (i != 0) {
            scrollToMessageId(i, 0, false, this.returnToLoadIndex, true, 0, runnable);
            return;
        }
        int i2 = this.returnToMessageId;
        if (i2 > 0) {
            scrollToMessageId(i2, 0, true, this.returnToLoadIndex, true, 0, runnable);
            return;
        }
        scrollToLastMessage(false, true, runnable);
        if (this.pinnedMessageIds.isEmpty()) {
            return;
        }
        this.forceScrollToFirst = true;
        this.forceNextPinnedMessageId = this.pinnedMessageIds.get(0).intValue();
    }

    public void lambda$onPageDownClicked$98() {
        setPagedownLoading(true, true);
    }

    public final void playReactionAnimation(Integer num) {
        ChatMessageCell findMessageCell;
        if (((BaseFragment) this).fragmentView == null || (findMessageCell = findMessageCell(num.intValue(), false)) == null) {
            return;
        }
        TLRPC.MessagePeerReaction randomUnreadReaction = findMessageCell.getMessageObject().getRandomUnreadReaction();
        if (randomUnreadReaction != null && findMessageCell.reactionsLayoutInBubble.hasUnreadReactions) {
            ReactionsEffectOverlay.show(this, (ReactionsContainerLayout) null, findMessageCell, (View) null, 0.0f, 0.0f, ReactionsLayoutInBubble.VisibleReaction.fromTL(randomUnreadReaction.reaction), ((BaseFragment) this).currentAccount, !randomUnreadReaction.big ? 1 : 0);
            ReactionsEffectOverlay.startAnimation();
        }
        findMessageCell.markReactionsAsRead();
    }

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

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

    public final void setScrimView(View scrimView) {
        View view = this.scrimView;
        if (view == scrimView) {
            return;
        }
        if (view != null && (view instanceof ChatActionCell)) {
            ((ChatActionCell) view).setInvalidateWithParent(null);
        }
        this.scrimView = scrimView;
        if (scrimView instanceof ChatActionCell) {
            ((ChatActionCell) scrimView).setInvalidateWithParent(((BaseFragment) this).fragmentView);
        }
    }

    public void dimBehindView(boolean enable) {
        dimBehindView(enable ? 0.2f : 0.0f, true);
    }

    public final void checkInstantCameraView() {
        if (this.instantCameraView != null || getContext() == null) {
            return;
        }
        View view = new InstantCameraView(this, getContext(), this, this.themeDelegate) {
            public 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));
    }

    public final void dimBehindView(float value, boolean hidePagedownButtons) {
        ValueAnimator ofFloat;
        final boolean z = value > 0.0f;
        View view = this.scrimView;
        if (view instanceof ChatMessageCell) {
            ChatMessageCell chatMessageCell = (ChatMessageCell) view;
            chatMessageCell.setInvalidatesParent(z);
            if (z) {
                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();
        if (z) {
            this.scrimViewAlpha = 1.0f;
            ValueAnimator valueAnimator = this.scrimViewAlphaAnimator;
            if (valueAnimator != null) {
                valueAnimator.cancel();
            }
            ofFloat = ValueAnimator.ofFloat(0.0f, value);
            arrayList.add(ofFloat);
        } else {
            ofFloat = ValueAnimator.ofFloat(this.scrimPaintAlpha, 0.0f);
            arrayList.add(ofFloat);
        }
        ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public final void onAnimationUpdate(ValueAnimator valueAnimator2) {
                ChatActivity.this.lambda$dimBehindView$99(valueAnimator2);
            }
        });
        if (!z || hidePagedownButtons) {
            FrameLayout frameLayout = this.pagedownButton;
            if (frameLayout != null) {
                Property property = View.ALPHA;
                float[] fArr = new float[1];
                fArr[0] = z ? 0.0f : 1.0f;
                arrayList.add(ObjectAnimator.ofFloat(frameLayout, (Property<FrameLayout, Float>) property, fArr));
            }
            FrameLayout frameLayout2 = this.mentiondownButton;
            if (frameLayout2 != null) {
                Property property2 = View.ALPHA;
                float[] fArr2 = new float[1];
                fArr2[0] = z ? 0.0f : 1.0f;
                arrayList.add(ObjectAnimator.ofFloat(frameLayout2, (Property<FrameLayout, Float>) property2, fArr2));
            }
            FrameLayout frameLayout3 = this.reactionsMentiondownButton;
            if (frameLayout3 != null) {
                Property property3 = View.ALPHA;
                float[] fArr3 = new float[1];
                fArr3[0] = z ? 0.0f : 1.0f;
                arrayList.add(ObjectAnimator.ofFloat(frameLayout3, (Property<FrameLayout, Float>) property3, fArr3));
            }
        }
        this.scrimAnimatorSet.playTogether(arrayList);
        this.scrimAnimatorSet.setDuration(z ? 150L : 220L);
        this.scrimAnimatorSet.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                if (z) {
                    return;
                }
                ChatActivity.this.setScrimView(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 lambda$dimBehindView$99(ValueAnimator valueAnimator) {
        this.scrimPaintAlpha = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        View view = ((BaseFragment) this).fragmentView;
        if (view != null) {
            view.invalidate();
        }
    }

    public class PinnedMessageButton extends TextView {
        public PinnedMessageButton(final ChatActivity this$0, Context context) {
            super(context);
            setSingleLine(true);
            setLines(1);
            setMaxLines(1);
            setEllipsize(TextUtils.TruncateAt.END);
            setTextColor(this$0.getThemedColor(Theme.key_featuredStickers_buttonText));
            setBackground(Theme.AdaptiveRipple.filledRect(this$0.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
        public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            super.onMeasure(View.MeasureSpec.makeMeasureSpec(Math.min(View.MeasureSpec.getSize(widthMeasureSpec), (int) (AndroidUtilities.displaySize.x * 0.45f)), Integer.MIN_VALUE), heightMeasureSpec);
        }
    }

    public final void checkEditTextItemMenu() {
        ActionBarMenu.LazyItem lazyItem;
        if (this.filledEditTextItemMenu || (lazyItem = this.editTextItem) == null) {
            return;
        }
        ActionBarMenuItem createView = lazyItem.createView();
        createView.addSubItem(57, LocaleController.getString("Spoiler", R.string.Spoiler));
        if (this.chatMode == 0) {
            createView.addSubItem(58, LocaleController.getString("Quote", R.string.Quote));
        }
        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(LocaleController.getString("Bold", R.string.Bold));
        spannableStringBuilder.setSpan(new TypefaceSpan(AndroidUtilities.bold()), 0, spannableStringBuilder.length(), 33);
        createView.addSubItem(50, spannableStringBuilder);
        SpannableStringBuilder spannableStringBuilder2 = new SpannableStringBuilder(LocaleController.getString("Italic", 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("Mono", 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("Strike", 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("Underline", 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("CreateLink", R.string.CreateLink));
        createView.addSubItem(120, LocaleController.getString("CreateMention", R.string.CreateMention));
        createView.addSubItem(62, LocaleController.getString("Translate", R.string.Translate));
        createView.addSubItem(54, LocaleController.getString("Regular", R.string.Regular));
        this.filledEditTextItemMenu = true;
    }

    public final 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);
        }
    }

    public final void updateReactionsMentionButton(boolean animated) {
        if (this.reactionsMentiondownButtonCounter == null || getParentActivity() == null) {
            return;
        }
        int i = this.reactionsMentionCount;
        boolean z = i > 0 && this.chatMode == 0;
        this.reactionsMentiondownButtonCounter.setCount(i, animated);
        if (z && this.reactionsMentiondownButton.getTag() == null) {
            this.reactionsMentiondownButton.setTag(1);
            ValueAnimator valueAnimator = this.reactionsMentionButtonAnimation;
            if (valueAnimator != null) {
                valueAnimator.removeAllListeners();
                this.reactionsMentionButtonAnimation.cancel();
                this.reactionsMentionButtonAnimation = null;
            }
            if (animated) {
                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 valueAnimator2) {
                        ChatActivity.this.lambda$updateReactionsMentionButton$100(valueAnimator2);
                    }
                });
                this.reactionsMentionButtonAnimation.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        ChatActivity.this.reactionsMentionButtonEnterProgress = 1.0f;
                        ChatActivity.this.contentView.invalidate();
                    }
                });
                this.reactionsMentionButtonAnimation.setDuration(200L);
                this.reactionsMentionButtonAnimation.start();
                return;
            }
            this.reactionsMentiondownButton.setVisibility(0);
            this.reactionsMentionButtonEnterProgress = 1.0f;
            this.contentView.invalidate();
            return;
        }
        if (z || this.reactionsMentiondownButton.getTag() == null) {
            return;
        }
        this.reactionsMentiondownButton.setTag(null);
        ValueAnimator valueAnimator2 = this.reactionsMentionButtonAnimation;
        if (valueAnimator2 != null) {
            valueAnimator2.removeAllListeners();
            this.reactionsMentionButtonAnimation.cancel();
            this.reactionsMentionButtonAnimation = null;
        }
        if (animated) {
            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 valueAnimator3) {
                    ChatActivity.this.lambda$updateReactionsMentionButton$101(valueAnimator3);
                }
            });
            this.reactionsMentionButtonAnimation.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    ChatActivity.this.reactionsMentiondownButton.setVisibility(4);
                    ChatActivity.this.reactionsMentionButtonEnterProgress = 0.0f;
                    ChatActivity.this.contentView.invalidate();
                }
            });
            this.reactionsMentionButtonAnimation.setDuration(200L);
            this.reactionsMentionButtonAnimation.start();
            return;
        }
        this.reactionsMentiondownButton.setVisibility(4);
        this.reactionsMentionButtonEnterProgress = 0.0f;
        this.contentView.invalidate();
    }

    public void lambda$updateReactionsMentionButton$100(ValueAnimator valueAnimator) {
        this.reactionsMentionButtonEnterProgress = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        this.contentView.invalidate();
    }

    public void lambda$updateReactionsMentionButton$101(ValueAnimator valueAnimator) {
        this.reactionsMentionButtonEnterProgress = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        this.contentView.invalidate();
    }

    public void fallbackFieldPanel() {
        MessagePreviewParams.Messages messages;
        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 final void openForwardingPreview(int startTab) {
        TLRPC.TL_channels_sendAsPeers tL_channels_sendAsPeers;
        MessagePreviewParams messagePreviewParams = this.messagePreviewParams;
        if (messagePreviewParams == null || this.forwardingPreviewView != null) {
            return;
        }
        if (messagePreviewParams.linkMessage != null) {
            int i = ((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(i, webPage, fieldText, messageObject, this.replyingQuote, this.editingMessageObject);
        }
        if (this.messagePreviewParams.isEmpty()) {
            return;
        }
        this.keyboardWasVisible = this.chatActivityEnterView.isKeyboardVisible();
        if (!QuoteForward) {
            MessagePreviewParams messagePreviewParams2 = this.messagePreviewParams;
            messagePreviewParams2.hideForwardSendersName = true;
            if (messagePreviewParams2.hasCaption && PlusSettings.deleteSharedMediaCaption) {
                messagePreviewParams2.hideCaption = true;
            }
        }
        Context context = this.contentView.getContext();
        MessagePreviewParams messagePreviewParams3 = this.messagePreviewParams;
        TLRPC.User user = this.currentUser;
        TLRPC.Chat chat = this.currentChat;
        int i2 = ((BaseFragment) this).currentAccount;
        ThemeDelegate themeDelegate = this.themeDelegate;
        ReplyQuote replyQuote = this.replyingQuote;
        AnonymousClass74 anonymousClass74 = new AnonymousClass74(context, this, messagePreviewParams3, user, chat, i2, themeDelegate, startTab, replyQuote != null && replyQuote.outdated);
        this.forwardingPreviewView = anonymousClass74;
        this.messagePreviewParams.attach(anonymousClass74);
        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();
    }

    public class AnonymousClass74 extends MessagePreviewView {
        public AnonymousClass74(Context context, ChatActivity chatActivity, MessagePreviewParams params, TLRPC.User user, TLRPC.Chat chat, int currentAccount, MessagePreviewView.ResourcesDelegate resourcesProvider, int startTab, boolean showOutdatedQuote) {
            super(context, chatActivity, params, user, chat, currentAccount, resourcesProvider, startTab, showOutdatedQuote);
        }

        public 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();
        }

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

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

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

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

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

        public 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;
        }

        public void onDismiss(boolean canShowKeyboard) {
            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 && canShowKeyboard) {
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.AnonymousClass74.this.lambda$onDismiss$1();
                    }
                }, 50L);
                ChatActivity.this.keyboardWasVisible = false;
            }
            AndroidUtilities.requestAdjustResize(ChatActivity.this.getParentActivity(), ((BaseFragment) ChatActivity.this).classGuid);
        }

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

        public void selectAnotherChat(boolean r10) {
            throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.AnonymousClass74.selectAnotherChat(boolean):void");
        }
    }

    public final 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;
        }
        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<TLRPC.Chat> arrayList = this.nextChannels;
        if (arrayList != null && arrayList.size() > 1) {
            ArrayList<TLRPC.Chat> arrayList2 = this.nextChannels;
            chatActivity.setNextChannels(new ArrayList<>(arrayList2.subList(1, arrayList2.size())));
        }
        chatActivity.setPullingDownTransition(true);
        replacingChatActivity = true;
        presentFragment(chatActivity, true);
    }

    public void setNextChannels(ArrayList<TLRPC.Chat> channels) {
        this.nextChannels = channels;
    }

    public final 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);
    }

    public final void addToPulledDialogs(TLRPC.Chat chat, TLRPC.TL_forumTopic topic, long dialogId, int folderId, int filterId) {
        if (getParentLayout() == null) {
            return;
        }
        BackButtonMenu.addToPulledDialogs(this, getParentLayout().getFragmentStack().indexOf(this), chat, (TLRPC.User) null, topic, dialogId, folderId, filterId);
    }

    public final 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 final void setPullingDownTransition(boolean fromPullingDownTransition) {
        this.fromPullingDownTransition = fromPullingDownTransition;
    }

    public void setSwitchFromTopics(boolean switchFromTopics) {
        this.switchFromTopics = switchFromTopics;
    }

    public final void updateBulletinLayout() {
        Bulletin visibleBulletin = Bulletin.getVisibleBulletin();
        if (visibleBulletin == null || this.bulletinDelegate == null) {
            return;
        }
        visibleBulletin.updatePosition();
    }

    public final void openAddMember() {
        Bundle bundle = new Bundle();
        bundle.putBoolean("onlyUsers", true);
        bundle.putBoolean("destroyAfterSelect", true);
        bundle.putBoolean("returnAsResult", true);
        bundle.putBoolean("needForwardCount", !ChatObject.isChannel(this.currentChat));
        if (this.chat_id > 0) {
            TLRPC.Chat chat = this.currentChat;
            if (chat.creator) {
                bundle.putLong("chat_id", chat.id);
            }
            bundle.putString("selectAlertString", LocaleController.getString("AddToTheGroup", R.string.AddToTheGroup));
        }
        ContactsActivity contactsActivity = new ContactsActivity(bundle);
        contactsActivity.setDelegate(new ContactsActivity.ContactsActivityDelegate() {
            @Override
            public void didSelectContact(TLRPC.User user, String param, ContactsActivity activity) {
                ChatActivity.this.getMessagesController().addUserToChat(ChatActivity.this.chat_id, user, param != null ? Utilities.parseInt(param).intValue() : 0, (String) null, ChatActivity.this, (Runnable) null);
            }
        });
        TLRPC.ChatFull chatFull = this.chatInfo;
        if (chatFull != null && chatFull.participants != null) {
            LongSparseArray<TLRPC.User> 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);
            }
            contactsActivity.setIgnoreUsers(longSparseArray);
        }
        presentFragment(contactsActivity);
    }

    public final void updateFloatingDateViewPosition() {
        ChatDialogsView chatDialogsView = this.chatDialogsView;
        if (chatDialogsView != null && Theme.plusShowQuickBar && Theme.plusHideQuickBarOnScroll && chatDialogsView.isVisible()) {
            this.chatDialogsView.btnPressed();
        }
    }

    public final void updateBackgroundPlus() {
        GradientDrawable.Orientation orientation;
        int i = Theme.chatGradientBG;
        if (i == 0) {
            this.contentView.setBackgroundColor(Theme.chatSolidBGColor);
            return;
        }
        if (i == 2) {
            orientation = GradientDrawable.Orientation.LEFT_RIGHT;
        } else if (i == 3) {
            orientation = GradientDrawable.Orientation.TL_BR;
        } else if (i == 4) {
            orientation = GradientDrawable.Orientation.BL_TR;
        } else {
            orientation = GradientDrawable.Orientation.TOP_BOTTOM;
        }
        this.contentView.setBackgroundDrawable(new GradientDrawable(orientation, new int[]{Theme.chatSolidBGColor, Theme.chatGradientBGColor}));
    }

    public final 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);
        }
        getMediaDataController().setOnlyUserId(((BaseFragment) this).arguments.getLong("only_id", 0L), ((BaseFragment) this).arguments.getLong("only_id_media", 0L));
        this.searchingForUser = false;
        String string = LocaleController.getString("SearchFrom", 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 final void updateTranslateItemVisibility() {
        ActionBarMenuItem.Item item = this.translateItem;
        if (item == null) {
            return;
        }
        item.setVisibility((getMessagesController().getTranslateController().isTranslateDialogHidden(getDialogId()) && getMessagesController().getTranslateController().isDialogTranslatable(getDialogId())) ? 0 : 8);
    }

    public final void updateInfoTopView(boolean animated) {
        View.OnClickListener onClickListener;
        int i;
        String str;
        TLRPC.User user;
        if (this.contentView == null) {
            return;
        }
        SharedPreferences notificationsSettings = MessagesController.getNotificationsSettings(((BaseFragment) this).currentAccount);
        int i2 = notificationsSettings.getInt("dialog_bar_distance" + this.dialog_id, -1);
        this.distanceToPeer = i2;
        String str2 = null;
        if (i2 >= 0 && (user = this.currentUser) != null) {
            str2 = LocaleController.formatString("ChatDistanceToPeer", R.string.ChatDistanceToPeer, new Object[]{user.first_name, LocaleController.formatDistance(i2, 0)});
            onClickListener = new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    ChatActivity.this.lambda$updateInfoTopView$102(view);
                }
            };
        } else {
            if (this.currentChat != null && this.chatInviterId != 0) {
                StringBuilder sb = new StringBuilder();
                sb.append("dialog_bar_vis3");
                sb.append(this.dialog_id);
                boolean z = notificationsSettings.getInt(sb.toString(), 0) == 2;
                boolean z2 = notificationsSettings.getBoolean("dialog_bar_report" + this.dialog_id, false);
                boolean z3 = notificationsSettings.getBoolean("dialog_bar_block" + this.dialog_id, false);
                if (z && (z2 || z3)) {
                    final TLRPC.User user2 = getMessagesController().getUser(Long.valueOf(this.chatInviterId));
                    if (user2 != null) {
                        if (!ChatObject.isChannel(this.currentChat) || this.currentChat.megagroup) {
                            i = R.string.ActionUserInvitedToGroup;
                            str = "ActionUserInvitedToGroup";
                        } else {
                            i = R.string.ActionUserInvitedToChannel;
                            str = "ActionUserInvitedToChannel";
                        }
                        ?? replaceWithLink = MessageObject.replaceWithLink(LocaleController.getString(str, i), "un1", user2);
                        onClickListener = new View.OnClickListener() {
                            @Override
                            public final void onClick(View view) {
                                ChatActivity.this.lambda$updateInfoTopView$103(user2, view);
                            }
                        };
                        str2 = replaceWithLink;
                    }
                } else {
                    hideInfoView();
                }
            }
            onClickListener = null;
        }
        if (str2 != null) {
            Animator animator = this.infoTopViewAnimator;
            if (animator != null) {
                animator.cancel();
            }
            if (this.infoTopView == null) {
                ChatActionCell chatActionCell = new ChatActionCell(this.contentView.getContext(), false, this.themeDelegate);
                this.infoTopView = chatActionCell;
                chatActionCell.setCustomText(str2);
                this.infoTopView.setInvalidateColors(true);
                this.infoTopView.setOnClickListener(onClickListener);
                this.contentView.addView(this.infoTopView, LayoutHelper.createFrame(-2, -2.0f, 49, 0.0f, 0.0f, 0.0f, 0.0f));
            }
            if (animated) {
                if (this.infoTopView.getTag() == null) {
                    ValueAnimator ofFloat = ValueAnimator.ofFloat(0.0f, 1.0f);
                    this.infoTopView.setTag(1);
                    this.infoTopView.setAlpha(0.0f);
                    final ChatActionCell chatActionCell2 = this.infoTopView;
                    ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                        @Override
                        public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                            ChatActivity.this.lambda$updateInfoTopView$104(chatActionCell2, valueAnimator);
                        }
                    });
                    ofFloat.addListener(new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationEnd(Animator animation) {
                            ChatActivity.this.topViewOffset = AndroidUtilities.dp(30.0f);
                            ChatActivity.this.invalidateChatListViewTopPadding();
                        }
                    });
                    ofFloat.setDuration(150L);
                    this.infoTopViewAnimator = ofFloat;
                    ofFloat.start();
                    return;
                }
                return;
            }
            this.infoTopView.setTag(1);
            this.topViewOffset = AndroidUtilities.dp(30.0f);
            invalidateChatListViewTopPadding();
        }
    }

    public void lambda$updateInfoTopView$102(View view) {
        presentFragment(new PeopleNearbyActivity());
    }

    public void lambda$updateInfoTopView$103(TLRPC.User user, View view) {
        Bundle bundle = new Bundle();
        bundle.putLong("user_id", this.chatInviterId);
        if (UserObject.isUserSelf(user)) {
            bundle.putBoolean("my_profile", true);
        }
        presentFragment(new ProfileActivity(bundle));
    }

    public void lambda$updateInfoTopView$104(View view, ValueAnimator valueAnimator) {
        float floatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        this.topViewOffset = AndroidUtilities.dp(30.0f) * floatValue;
        invalidateChatListViewTopPadding();
        view.setAlpha(floatValue);
    }

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

            public void showWithAction(long did, int action, Object infoObject, Object infoObject2, Runnable actionRunnable, Runnable cancelRunnable) {
                setAdditionalTranslationY((ChatActivity.this.fragmentContextView == null || !ChatActivity.this.fragmentContextView.isCallTypeVisible()) ? 0.0f : AndroidUtilities.dp(ChatActivity.this.fragmentContextView.getStyleHeight()));
                super.showWithAction(did, action, infoObject, infoObject2, actionRunnable, cancelRunnable);
            }
        };
        this.topUndoView = view;
        this.contentView.addView(view, 17, LayoutHelper.createFrame(-1, -2.0f, 51, 8.0f, 8.0f, 8.0f, 0.0f));
    }

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

    public class AnonymousClass78 extends BlurredFrameLayout {
        public float lastY;
        public float startY;

        public AnonymousClass78(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.AnonymousClass78.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;
        }

        public boolean onTouchEvent(MotionEvent event) {
            this.lastY = event.getY();
            if (event.getAction() == 1) {
                ChatActivity.this.finishPreviewFragment();
            } else if (event.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(event);
        }

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

        public boolean drawChild(Canvas canvas, View child, long drawingTime) {
            if (child == ChatActivity.this.pinnedLineView) {
                canvas.save();
                canvas.clipRect(0, 0, getMeasuredWidth(), AndroidUtilities.dp(48.0f));
            }
            if (child == ChatActivity.this.pinnedMessageTextView[0] || child == ChatActivity.this.pinnedMessageTextView[1]) {
                canvas.save();
                canvas.clipRect(0, 0, getMeasuredWidth() - AndroidUtilities.dp(38.0f), getMeasuredHeight());
                boolean drawChild = super/*android.widget.FrameLayout*/.drawChild(canvas, child, drawingTime);
                canvas.restore();
                return drawChild;
            }
            boolean drawChild2 = super/*android.widget.FrameLayout*/.drawChild(canvas, child, drawingTime);
            if (child != ChatActivity.this.pinnedLineView) {
                return drawChild2;
            }
            canvas.restore();
            return drawChild2;
        }
    }

    public void lambda$createPinnedMessageView$105(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<Integer> arrayList = this.pinnedMessageIds;
                if (i2 == arrayList.get(arrayList.size() - 1).intValue()) {
                    i = 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$106(View view) {
        openPinnedMessagesList(false);
    }

    public void lambda$createPinnedMessageView$108(View view) {
        boolean z;
        TLRPC.UserFull userFull;
        if (getParentActivity() == null) {
            return;
        }
        TLRPC.Chat chat = this.currentChat;
        if (chat != null) {
            z = ChatObject.canPinMessages(chat);
        } else {
            z = (this.currentEncryptedChat != null || (userFull = this.userInfo) == null) ? false : userFull.can_pin_message;
        }
        if (z) {
            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity(), this.themeDelegate);
            builder.setTitle(LocaleController.getString("UnpinMessageAlertTitle", R.string.UnpinMessageAlertTitle));
            builder.setMessage(LocaleController.getString("UnpinMessageAlert", R.string.UnpinMessageAlert));
            builder.setPositiveButton(LocaleController.getString("UnpinMessage", R.string.UnpinMessage), new DialogInterface.OnClickListener() {
                @Override
                public final void onClick(DialogInterface dialogInterface, int i) {
                    ChatActivity.this.lambda$createPinnedMessageView$107(dialogInterface, i);
                }
            });
            builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
            showDialog(builder.create());
            return;
        }
        if (this.pinnedMessageIds.isEmpty()) {
            return;
        }
        MessagesController.getNotificationsSettings(((BaseFragment) this).currentAccount).edit().putInt("pin_" + this.dialog_id, this.pinnedMessageIds.get(0).intValue()).commit();
        updatePinnedMessageView(true);
    }

    public void lambda$createPinnedMessageView$107(DialogInterface dialogInterface, int i) {
        MessageObject messageObject = this.pinnedMessageObjects.get(Integer.valueOf(this.currentPinnedMessageId));
        if (messageObject == null) {
            messageObject = this.messagesDict[0].get(this.currentPinnedMessageId);
        }
        unpinMessage(messageObject);
    }

    public final 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);
        if (j2 > 0) {
            TLRPC.User user = getMessagesController().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 = getMessagesController().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("CancelForwarding", R.string.CancelForwarding), new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i2) {
                ChatActivity.this.lambda$openAnotherForward$109(dialogInterface, i2);
            }
        });
        builder.setNegativeButton(LocaleController.getString("ShowForwardingOptions", R.string.ShowForwardingOptions), new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i2) {
                ChatActivity.this.lambda$openAnotherForward$110(dialogInterface, 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 lambda$openAnotherForward$109(DialogInterface dialogInterface, int i) {
        MessagePreviewParams messagePreviewParams = this.messagePreviewParams;
        if (messagePreviewParams != null) {
            messagePreviewParams.updateForward((ArrayList) null, this.dialog_id);
        }
        fallbackFieldPanel();
    }

    public void lambda$openAnotherForward$110(DialogInterface dialogInterface, int i) {
        openForwardingPreview(1);
    }

    public final void openPinnedMessagesList(boolean preview) {
        INavigationLayout iNavigationLayout;
        if (getParentActivity() == null || (iNavigationLayout = ((BaseFragment) this).parentLayout) == null || iNavigationLayout.getLastFragment() != this || this.pinnedMessageIds.isEmpty()) {
            return;
        }
        if (((BaseFragment) this).inPreviewMode && PlusSettings.doNotClosePreviewOnRelease) {
            return;
        }
        Bundle bundle = new Bundle();
        TLRPC.Chat chat = this.currentChat;
        if (chat != null) {
            bundle.putLong("chat_id", chat.id);
        } else {
            bundle.putLong("user_id", this.currentUser.id);
        }
        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 = this.pinnedMessageIds.get(i);
            MessageObject messageObject = this.pinnedMessageObjects.get(num);
            MessageObject messageObject2 = 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 AnonymousClass81();
        if (preview) {
            presentFragmentAsPreview(chatActivity);
            checkShowBlur(true);
        } else {
            presentFragment(chatActivity, false);
        }
    }

    public class AnonymousClass81 implements ChatActivityDelegate {
        @Override
        public void onReport() {
            ChatActivityDelegate.CC.$default$onReport(this);
        }

        public AnonymousClass81() {
        }

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

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

        @Override
        public void onUnpin(boolean all, final boolean hide) {
            if (all) {
                final ArrayList arrayList = new ArrayList(ChatActivity.this.pinnedMessageIds);
                final ArrayList arrayList2 = new ArrayList(ChatActivity.this.pinnedMessageObjects.values());
                if (hide) {
                    SharedPreferences notificationsSettings = MessagesController.getNotificationsSettings(((BaseFragment) ChatActivity.this).currentAccount);
                    if (ChatActivity.this.pinnedMessageIds.isEmpty()) {
                        notificationsSettings.edit().remove("pin_" + ChatActivity.this.dialog_id).commit();
                    } else {
                        notificationsSettings.edit().putInt("pin_" + ChatActivity.this.dialog_id, ((Integer) ChatActivity.this.pinnedMessageIds.get(0)).intValue()).commit();
                    }
                    ChatActivity.this.updatePinnedMessageView(true);
                } else {
                    ChatActivity.this.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;
                ChatActivity chatActivity = ChatActivity.this;
                final int i = chatActivity.pinBullerinTag + 1;
                chatActivity.pinBullerinTag = i;
                final int pinnedMessagesCount = ChatActivity.this.getPinnedMessagesCount();
                ChatActivity chatActivity2 = ChatActivity.this;
                chatActivity2.pinBulletin = BulletinFactory.createUnpinAllMessagesBulletin(chatActivity2, pinnedMessagesCount, hide, new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.AnonymousClass81.this.lambda$onUnpin$0(hide, arrayList, arrayList2, pinnedMessagesCount, i);
                    }
                }, new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.AnonymousClass81.this.lambda$onUnpin$1(hide, i);
                    }
                }, ChatActivity.this.themeDelegate);
                return;
            }
            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);
        }

        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;
            }
        }
    }

    public final void checkShowBlur(boolean animated) {
        MessagePreviewView messagePreviewView;
        BluredView bluredView;
        BluredView bluredView2;
        INavigationLayout iNavigationLayout = ((BaseFragment) this).parentLayout;
        boolean z = !(iNavigationLayout == null || !iNavigationLayout.isInPreviewMode() || ((BaseFragment) this).parentLayout.hasIntegratedBlurInPreview() || ((BaseFragment) this).inPreviewMode) || ((messagePreviewView = this.forwardingPreviewView) != null && messagePreviewView.isShowing());
        if (!z || ((bluredView2 = this.blurredView) != null && bluredView2.getTag() != null)) {
            if (z || (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 alpha) {
                    super/*android.view.View*/.setAlpha(alpha);
                    View view4 = ((BaseFragment) ChatActivity.this).fragmentView;
                    if (view4 != null) {
                        view4.invalidate();
                    }
                }

                public void setVisibility(int visibility) {
                    super/*android.view.View*/.setVisibility(visibility);
                    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$111(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 animation) {
                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);
    }

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

    public int getPreviewHeight() {
        if (this.chatMode == 2 && this.messages.size() == 2) {
            return getHeightForMessage(this.messages.get(0), false) + AndroidUtilities.dp(80.0f) + ActionBar.getCurrentActionBarHeight();
        }
        return super.getPreviewHeight();
    }

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

    public final void showProgressView(boolean show) {
        if (this.progressView == null) {
            return;
        }
        if (!AndroidUtilities.isTablet() && !this.isComments && this.currentUser == null && getLiteModeChat()) {
            this.animateProgressViewTo = show;
            return;
        }
        if (this.fragmentOpened && SharedConfig.animationsEnabled()) {
            if (show == this.animateProgressViewTo) {
                return;
            }
            this.animateProgressViewTo = show;
            if (show) {
                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();
                this.progressView.animate().alpha(1.0f).scaleX(1.0f).scaleY(1.0f).setDuration(150L).start();
                return;
            }
            this.progressView.animate().setListener(null).cancel();
            this.progressView.animate().alpha(0.0f).scaleX(0.3f).scaleY(0.3f).setDuration(150L).setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    ChatActivity.this.progressView.setVisibility(4);
                }
            }).start();
            return;
        }
        this.animateProgressViewTo = show;
        this.progressView.setVisibility(show ? 0 : 4);
    }

    public final void hideInfoView() {
        if (this.distanceToPeer >= 0) {
            this.distanceToPeer = -1;
            MessagesController.getNotificationsSettings(((BaseFragment) this).currentAccount).edit().putInt("dialog_bar_distance" + this.dialog_id, -2).commit();
        }
        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$112(chatActionCell2, valueAnimator);
            }
        });
        ofFloat.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                ChatActivity.this.topViewOffset = 0.0f;
                if (animation == 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();
    }

    public void lambda$hideInfoView$112(View view, ValueAnimator valueAnimator) {
        float floatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        this.topViewOffset = AndroidUtilities.dp(30.0f) * floatValue;
        invalidateChatListViewTopPadding();
        invalidateMessagesVisiblePart();
        view.setAlpha(floatValue);
    }

    public final void updateChatListViewTopPadding() {
        float f;
        TranslateButton translateButton;
        int i;
        BlurredFrameLayout blurredFrameLayout;
        ChatActivityEnterView chatActivityEnterView;
        FrameLayout frameLayout;
        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.pinnedMessageView;
            float max3 = (blurredFrameLayout3 == null || blurredFrameLayout3.getVisibility() != 0) ? 0.0f : Math.max(0.0f, AndroidUtilities.dp(48.0f) + this.pinnedMessageEnterOffset);
            if (isThreadChat() && (!this.isTopic || pinnedOnlyStarterMessage())) {
                max3 = 0.0f;
            }
            if (this.actionBarSearchTags != null) {
                max3 = Math.max(max3, r5.getCurrentHeight());
            }
            if (this.hashtagSearchTabs != null) {
                max3 = Math.max(max3, r5.getCurrentHeight());
            }
            ChatActivityMemberRequestsDelegate chatActivityMemberRequestsDelegate = this.pendingRequestsDelegate;
            MessageObject messageObject = null;
            View view = chatActivityMemberRequestsDelegate != null ? chatActivityMemberRequestsDelegate.getView() : null;
            float max4 = (view == null || view.getVisibility() != 0) ? 0.0f : Math.max(0.0f, (view.getHeight() + this.pendingRequestsDelegate.getViewEnterOffset()) - AndroidUtilities.dp(4.0f));
            float f2 = this.chatListViewPaddingTop;
            if (this.showBio && (frameLayout = this.bioView) != null && frameLayout.getTag() == null) {
                max3 += AndroidUtilities.dp(48.0f);
                this.bioView.setTranslationY(this.contentPanTranslation + this.contentPaddingTop + max2);
            }
            float dp = AndroidUtilities.dp(4.0f) + this.contentPaddingTop;
            float f3 = max2 + max3 + max4;
            this.paddingTopHeight = f3;
            float f4 = dp + f3;
            this.chatListViewPaddingTop = f4;
            float f5 = f4 + this.blurredViewTopOffset;
            this.chatListViewPaddingTop = f5;
            this.chatListViewPaddingVisibleOffset = 0;
            this.chatListViewPaddingTop = f5 + this.contentPanTranslation + this.bottomPanelTranslationY;
            if (this.searchExpandProgress == 0.0f || this.chatActivityEnterView.getVisibility() != 0) {
                f = 0.0f;
            } else {
                float f6 = this.chatListViewPaddingTop;
                f = this.searchExpandProgress * (this.chatActivityEnterView.getMeasuredHeight() - AndroidUtilities.dp(51.0f));
                this.chatListViewPaddingTop = f6 - f;
            }
            if (this.bottomPanelTranslationY == 0.0f && !this.chatActivityEnterView.panelAnimationInProgress() && (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) {
                    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) {
                        this.chatListViewPaddingTop = heightWithTopView - this.chatListView.getTranslationY();
                    }
                }
            }
            ChatActionCell chatActionCell = this.infoTopView;
            if (chatActionCell != null) {
                chatActionCell.setTranslationY((this.chatListViewPaddingTop - AndroidUtilities.dp(30.0f)) + this.topViewOffset);
                float f7 = this.chatListViewPaddingTop;
                float f8 = this.topViewOffset;
                this.chatListViewPaddingTop = f7 + f8;
                this.chatListViewPaddingVisibleOffset = (int) (this.chatListViewPaddingVisibleOffset + f8);
            }
            ChatActionCell chatActionCell2 = this.floatingDateView;
            if (chatActionCell2 != null) {
                chatActionCell2.setTranslationY((((this.chatListView.getTranslationY() - f) + this.chatListViewPaddingTop) + this.floatingDateViewOffset) - AndroidUtilities.dp(4.0f));
            }
            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) {
                    int i2 = 0;
                    while (true) {
                        if (i2 >= this.chatListView.getChildCount()) {
                            i = 0;
                            break;
                        }
                        View childAt = this.chatListView.getChildAt(i2);
                        if (childAt instanceof ChatMessageCell) {
                            messageObject = ((ChatMessageCell) childAt).getMessageObject();
                            i = getScrollingOffsetForView(childAt);
                            break;
                        } else {
                            if (childAt instanceof ChatActionCell) {
                                messageObject = ((ChatActionCell) childAt).getMessageObject();
                                i = getScrollingOffsetForView(childAt);
                                break;
                            }
                            i2++;
                        }
                    }
                    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 f9 = this.chatListViewPaddingTop;
                            if (r3.getTop() > f9) {
                                this.chatListView.scrollBy(0, (int) (r3.getTop() - f9));
                            }
                        } 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;
        }
    }

    public final void invalidateChatListViewTopPadding() {
        int i;
        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);
        }
        float max = this.contentPanTranslation + this.contentPaddingTop + Math.max(0, i + ((int) Math.max(-i, this.topChatPanelViewOffset)));
        BlurredFrameLayout blurredFrameLayout2 = this.pinnedMessageView;
        if (blurredFrameLayout2 != null) {
            float f = max + this.pinnedMessageEnterOffset;
            blurredFrameLayout2.setTranslationY(f);
            max = f + AndroidUtilities.dp(48.0f);
        }
        ChatActivityMemberRequestsDelegate chatActivityMemberRequestsDelegate = this.pendingRequestsDelegate;
        View view = chatActivityMemberRequestsDelegate != null ? chatActivityMemberRequestsDelegate.getView() : null;
        if (view != null) {
            view.setTranslationY(max + this.pendingRequestsDelegate.getViewEnterOffset());
        }
        float f2 = 0.0f;
        float currentHeight = (this.actionBarSearchTags != null ? r0.getCurrentHeight() : 0.0f) + 0.0f + (this.hashtagSearchTabs != null ? r3.getCurrentHeight() : 0.0f);
        if (this.fragmentContextView != null) {
            FragmentContextView fragmentContextView = this.fragmentLocationContextView;
            float dp = (fragmentContextView == null || fragmentContextView.getVisibility() != 0) ? 0.0f : AndroidUtilities.dp(36.0f) + 0.0f;
            FragmentContextView fragmentContextView2 = this.fragmentContextView;
            fragmentContextView2.setTranslationY(this.contentPanTranslation + currentHeight + dp + fragmentContextView2.getTopPadding());
        }
        if (this.fragmentLocationContextView != null) {
            FragmentContextView fragmentContextView3 = this.fragmentContextView;
            if (fragmentContextView3 != null && fragmentContextView3.getVisibility() == 0) {
                f2 = 0.0f + AndroidUtilities.dp(this.fragmentContextView.getStyleHeight()) + this.fragmentContextView.getTopPadding();
            }
            FragmentContextView fragmentContextView4 = this.fragmentLocationContextView;
            fragmentContextView4.setTranslationY(this.contentPanTranslation + currentHeight + f2 + fragmentContextView4.getTopPadding());
        }
        BlurredFrameLayout blurredFrameLayout3 = this.topChatPanelView;
        if (blurredFrameLayout3 != null) {
            blurredFrameLayout3.setTranslationY(this.contentPanTranslation + currentHeight + this.contentPaddingTop + this.topChatPanelViewOffset);
        }
        FrameLayout frameLayout = this.alertView;
        if (frameLayout != null && frameLayout.getVisibility() == 0) {
            this.alertView.setTranslationY(((this.contentPanTranslation + currentHeight) + this.contentPaddingTop) - (AndroidUtilities.dp(50.0f) * (1.0f - this.alertViewEnterProgress)));
        }
        BlurredFrameLayout blurredFrameLayout4 = this.bottomOverlayChat;
        if (blurredFrameLayout4 != null) {
            blurredFrameLayout4.setTranslationY(this.bottomPanelTranslationYReverse);
        }
        BlurredFrameLayout blurredFrameLayout5 = this.bottomMessagesActionContainer;
        if (blurredFrameLayout5 != null) {
            blurredFrameLayout5.setTranslationY(this.bottomPanelTranslationYReverse);
        }
        UndoView undoView = this.undoView;
        if (undoView != null) {
            undoView.setAdditionalTranslationY(this.chatActivityEnterView.getHeightWithTopView() - this.chatActivityEnterView.getAnimatedTop());
        }
    }

    public final TextureView createTextureView(boolean add) {
        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 translationY) {
                        super.setTranslationY(translationY);
                        ChatActivity.this.contentView.invalidate();
                    }
                };
                this.videoPlayerContainer = frameLayout;
                frameLayout.setOutlineProvider(new ViewOutlineProvider(this) {
                    @Override
                    @TargetApi(21)
                    public void getOutline(View view, Outline outline) {
                        ImageReceiver imageReceiver = (ImageReceiver) view.getTag(R.id.parent_tag);
                        if (imageReceiver != null) {
                            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);
                            return;
                        }
                        int i3 = AndroidUtilities.roundPlayingMessageSize;
                        outline.setOval(0, 0, i3, i3);
                    }
                });
                this.videoPlayerContainer.setClipToOutline(true);
            } else {
                this.videoPlayerContainer = new FrameLayout(getParentActivity()) {
                    public RectF rect = new RectF();

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

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

                    @Override
                    public void setVisibility(int visibility) {
                        super.setVisibility(visibility);
                        if (visibility == 0) {
                            setLayerType(2, null);
                        }
                    }

                    @Override
                    public void dispatchDraw(Canvas canvas) {
                        super.dispatchDraw(canvas);
                        if (getTag() == null) {
                            canvas.drawPath(ChatActivity.this.aspectPath, ChatActivity.this.aspectPaint);
                        }
                    }
                };
                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 (add) {
                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) {
            SizeNotifierFrameLayout sizeNotifierFrameLayout = this.contentView;
            View view = this.videoPlayerContainer;
            int i = AndroidUtilities.roundPlayingMessageSize;
            sizeNotifierFrameLayout.addView(view, 1, new FrameLayout.LayoutParams(i, i));
        }
        this.videoPlayerContainer.setTag(null);
        this.aspectRatioFrameLayout.setDrawingReady(false);
        return this.videoTextureView;
    }

    public final 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 final 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 valueAt = this.selectedMessagesIds[i].valueAt(i2);
                    if (valueAt != null && (message = valueAt.messageOwner) != null && message.noforwards) {
                        return true;
                    }
                }
            } catch (Exception unused) {
            }
        }
        return false;
    }

    public final 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);
        float[] fArr = new float[2];
        fArr[0] = this.pagedownLoadingT;
        fArr[1] = z ? 1.0f : 0.0f;
        ValueAnimator ofFloat = ValueAnimator.ofFloat(fArr);
        this.pagedownAnimator = ofFloat;
        ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public final void onAnimationUpdate(ValueAnimator valueAnimator2) {
                ChatActivity.this.lambda$setPagedownLoading$113(zArr, z, valueAnimator2);
            }
        });
        this.pagedownAnimator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                if (z) {
                    ChatActivity.this.pagedownButtonArrow.setVisibility(8);
                    if (zArr[0]) {
                        return;
                    }
                    ChatActivity.this.pagedownButtonLoadingDrawable.reset();
                    ChatActivity.this.pagedownButtonLoading.setVisibility(0);
                    return;
                }
                ChatActivity.this.pagedownButtonLoading.setVisibility(8);
            }
        });
        this.pagedownAnimator.setInterpolator(CubicBezierInterpolator.EASE_OUT);
        this.pagedownAnimator.setDuration(260L);
        this.pagedownAnimator.start();
    }

    public void lambda$setPagedownLoading$113(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 final void share() {
        MessageObject messageObject = null;
        for (int i = 1; i >= 0; i--) {
            if (messageObject == null && this.selectedMessagesIds[i].size() != 0) {
                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");
                if (messageObject.isVideo() || messageObject.isRoundVideo()) {
                    intent.setType("video/mp4");
                } else {
                    intent.setType(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) {
                        intent.putExtra("android.intent.extra.STREAM", Uri.fromFile(pathToAttach));
                    }
                } else {
                    intent.putExtra("android.intent.extra.STREAM", Uri.fromFile(pathToAttach));
                }
                getParentActivity().startActivityForResult(Intent.createChooser(intent, LocaleController.getString("ShareFile", R.string.ShareFile)), 500);
            }
        }
        hideActionMode();
        updatePinnedMessageView(true);
        updateVisibleRows();
        updateSelectedMessageReactions();
    }

    public final void openForward(boolean fromActionBar) {
        String string;
        if (getMessagesController().isChatNoForwards(this.currentChat) || hasSelectedNoforwardsMessage()) {
            if (getMessagesController().isChatNoForwards(this.currentChat)) {
                if (ChatObject.isChannel(this.currentChat) && !this.currentChat.megagroup) {
                    string = LocaleController.getString("ForwardsRestrictedInfoChannel", R.string.ForwardsRestrictedInfoChannel);
                } else {
                    string = LocaleController.getString("ForwardsRestrictedInfoGroup", R.string.ForwardsRestrictedInfoGroup);
                }
            } else {
                string = LocaleController.getString("ForwardsRestrictedInfoBot", R.string.ForwardsRestrictedInfoBot);
            }
            if (fromActionBar) {
                if (this.fwdRestrictedTopHint == null) {
                    SizeNotifierFrameLayout sizeNotifierFrameLayout = ((BaseFragment) this).fragmentView;
                    int indexOfChild = sizeNotifierFrameLayout.indexOfChild(this.chatActivityEnterView);
                    if (indexOfChild == -1) {
                        return;
                    }
                    HintView hintView = new HintView(getParentActivity(), 7, true);
                    this.fwdRestrictedTopHint = hintView;
                    sizeNotifierFrameLayout.addView(hintView, 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);
                this.fwdRestrictedTopHint.showForView(((BaseFragment) this).actionBar.getActionMode().getItem(11), true);
                return;
            }
            if (this.fwdRestrictedBottomHint == null) {
                SizeNotifierFrameLayout sizeNotifierFrameLayout2 = ((BaseFragment) this).fragmentView;
                int indexOfChild2 = sizeNotifierFrameLayout2.indexOfChild(this.chatActivityEnterView);
                if (indexOfChild2 == -1) {
                    return;
                }
                HintView hintView2 = new HintView(getParentActivity(), 9);
                this.fwdRestrictedBottomHint = hintView2;
                sizeNotifierFrameLayout2.addView(hintView2, 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);
            this.fwdRestrictedBottomHint.showForView(this.forwardButton, true);
            return;
        }
        int i = 0;
        boolean z = false;
        for (int i2 = 0; i2 < 2; i2++) {
            for (int i3 = 0; i3 < this.selectedMessagesIds[i2].size(); i3++) {
                MessageObject valueAt = this.selectedMessagesIds[i2].valueAt(i3);
                if (valueAt.isPoll()) {
                    i = valueAt.isPublicPoll() ? 2 : 1;
                    if (i == 2) {
                        break;
                    }
                } else if (valueAt.isInvoice()) {
                    z = 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);
        if (!this.isComments) {
            bundle.putBoolean("quote", QuoteForward);
        }
        bundle.putInt("messagesCount", this.canForwardMessagesCount);
        bundle.putInt("hasPoll", i);
        bundle.putBoolean("hasInvoice", z);
        bundle.putBoolean("canSelectTopics", true);
        DialogsActivity dialogsActivity = new DialogsActivity(bundle);
        dialogsActivity.setDelegate(this);
        presentFragment(dialogsActivity);
    }

    public void showBottomOverlayProgress(final boolean show, boolean animated) {
        if (!show || this.bottomOverlayProgress.getTag() == null) {
            if (show || this.bottomOverlayProgress.getTag() != null) {
                AnimatorSet animatorSet = this.bottomOverlayAnimation;
                if (animatorSet != null) {
                    animatorSet.cancel();
                    this.bottomOverlayAnimation = null;
                }
                this.bottomOverlayProgress.setTag(show ? 1 : null);
                int i = 4;
                if (animated) {
                    AnimatorSet animatorSet2 = new AnimatorSet();
                    this.bottomOverlayAnimation = animatorSet2;
                    if (show) {
                        this.bottomOverlayProgress.setVisibility(0);
                        this.bottomOverlayAnimation.playTogether(ObjectAnimator.ofFloat(this.bottomOverlayChatText, (Property<UnreadCounterTextView, Float>) View.SCALE_X, 0.1f), ObjectAnimator.ofFloat(this.bottomOverlayChatText, (Property<UnreadCounterTextView, Float>) View.SCALE_Y, 0.1f), ObjectAnimator.ofFloat(this.bottomOverlayChatText, (Property<UnreadCounterTextView, Float>) View.ALPHA, 0.0f), ObjectAnimator.ofFloat(this.bottomOverlayChatText2, (Property<UnreadCounterTextView, Float>) View.SCALE_X, 0.1f), ObjectAnimator.ofFloat(this.bottomOverlayChatText2, (Property<UnreadCounterTextView, Float>) View.SCALE_Y, 0.1f), ObjectAnimator.ofFloat(this.bottomOverlayChatText2, (Property<UnreadCounterTextView, Float>) View.ALPHA, 0.0f), ObjectAnimator.ofFloat(this.bottomOverlayProgress, (Property<RadialProgressView, Float>) View.SCALE_X, 1.0f), ObjectAnimator.ofFloat(this.bottomOverlayProgress, (Property<RadialProgressView, Float>) View.SCALE_Y, 1.0f), ObjectAnimator.ofFloat(this.bottomOverlayProgress, (Property<RadialProgressView, Float>) View.ALPHA, 1.0f));
                        this.bottomOverlayAnimation.setStartDelay(200L);
                    } else {
                        LinkSpanDrawable.LinksTextView linksTextView = this.bottomOverlayLinks ? this.bottomOverlayLinksText : this.bottomOverlayChatText;
                        animatorSet2.playTogether(ObjectAnimator.ofFloat(this.bottomOverlayProgress, (Property<RadialProgressView, Float>) View.SCALE_X, 0.1f), ObjectAnimator.ofFloat(this.bottomOverlayProgress, (Property<RadialProgressView, Float>) View.SCALE_Y, 0.1f), ObjectAnimator.ofFloat(this.bottomOverlayProgress, (Property<RadialProgressView, Float>) View.ALPHA, 0.0f), ObjectAnimator.ofFloat(linksTextView, (Property<LinkSpanDrawable.LinksTextView, Float>) View.SCALE_X, 1.0f), ObjectAnimator.ofFloat(linksTextView, (Property<LinkSpanDrawable.LinksTextView, Float>) View.SCALE_Y, 1.0f), ObjectAnimator.ofFloat(linksTextView, (Property<LinkSpanDrawable.LinksTextView, Float>) View.ALPHA, 1.0f), ObjectAnimator.ofFloat(this.bottomOverlayChatText2, (Property<UnreadCounterTextView, Float>) View.SCALE_X, 1.0f), ObjectAnimator.ofFloat(this.bottomOverlayChatText2, (Property<UnreadCounterTextView, Float>) View.SCALE_Y, 1.0f), ObjectAnimator.ofFloat(this.bottomOverlayChatText2, (Property<UnreadCounterTextView, Float>) View.ALPHA, 1.0f));
                    }
                    this.bottomOverlayAnimation.addListener(new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationEnd(Animator animation) {
                            if (ChatActivity.this.bottomOverlayAnimation == null || !ChatActivity.this.bottomOverlayAnimation.equals(animation)) {
                                return;
                            }
                            if (!show) {
                                ChatActivity.this.bottomOverlayProgress.setVisibility(4);
                            } else {
                                (ChatActivity.this.bottomOverlayLinks ? ChatActivity.this.bottomOverlayLinksText : ChatActivity.this.bottomOverlayChatText).setVisibility(4);
                            }
                        }

                        @Override
                        public void onAnimationCancel(Animator animation) {
                            if (ChatActivity.this.bottomOverlayAnimation == null || !ChatActivity.this.bottomOverlayAnimation.equals(animation)) {
                                return;
                            }
                            ChatActivity.this.bottomOverlayAnimation = null;
                        }
                    });
                    this.bottomOverlayAnimation.setDuration(150L);
                    this.bottomOverlayAnimation.start();
                    return;
                }
                this.bottomOverlayProgress.setVisibility(show ? 0 : 4);
                this.bottomOverlayProgress.setScaleX(show ? 1.0f : 0.1f);
                this.bottomOverlayProgress.setScaleY(show ? 1.0f : 0.1f);
                this.bottomOverlayProgress.setAlpha(1.0f);
                this.bottomOverlayChatText.setVisibility((show || this.bottomOverlayLinks) ? 4 : 0);
                LinkSpanDrawable.LinksTextView linksTextView2 = this.bottomOverlayLinksText;
                if (!show && this.bottomOverlayLinks) {
                    i = 0;
                }
                linksTextView2.setVisibility(i);
                this.bottomOverlayChatText.setScaleX((show || this.bottomOverlayLinks) ? 0.1f : 1.0f);
                this.bottomOverlayLinksText.setScaleX((show || !this.bottomOverlayLinks) ? 0.1f : 1.0f);
                this.bottomOverlayChatText.setScaleY((show || this.bottomOverlayLinks) ? 0.1f : 1.0f);
                this.bottomOverlayLinksText.setScaleY((show || !this.bottomOverlayLinks) ? 0.1f : 1.0f);
                this.bottomOverlayChatText.setAlpha((show || this.bottomOverlayLinks) ? 0.0f : 1.0f);
                this.bottomOverlayLinksText.setAlpha((show || !this.bottomOverlayLinks) ? 0.0f : 1.0f);
                this.bottomOverlayChatText2.setScaleX(show ? 0.1f : 1.0f);
                this.bottomOverlayChatText2.setScaleY(show ? 0.1f : 1.0f);
                this.bottomOverlayChatText2.setAlpha(show ? 0.0f : 1.0f);
            }
        }
    }

    public final void lambda$createView$41(TLRPC.BotInlineResult result, boolean notify, int scheduleDate) {
        MentionsContainerView mentionsContainerView = this.mentionContainer;
        if (mentionsContainerView == null) {
            return;
        }
        long contextBotId = mentionsContainerView.getAdapter().getContextBotId();
        HashMap hashMap = new HashMap();
        hashMap.put("id", result.id);
        hashMap.put("query_id", "" + result.query_id);
        hashMap.put("bot", "" + contextBotId);
        hashMap.put("bot_name", this.mentionContainer.getAdapter().getContextBotName());
        SendMessagesHelper.prepareSendingBotContextResult(this, getAccountInstance(), result, hashMap, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TL_stories.StoryItem) null, this.replyingQuote, notify, scheduleDate, this.quickReplyShortcut, getQuickReplyId());
        this.chatActivityEnterView.setFieldText("");
        hideFieldPanel(false);
        getMediaDataController().increaseInlineRaiting(contextBotId);
    }

    public final 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) {
            URLSpanBotCommand.enabled = !UserObject.isReplyUser(user);
            return;
        }
        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) {
            if (!chatFull.bot_info.isEmpty() && (chat = this.currentChat) != null && chat.megagroup) {
                z = true;
            }
            URLSpanBotCommand.enabled = z;
        }
    }

    public final MessageObject.GroupedMessages getValidGroupedMessage(MessageObject message) {
        if (message.getGroupId() == 0) {
            return null;
        }
        MessageObject.GroupedMessages groupedMessages = (MessageObject.GroupedMessages) this.groupedMessagesMap.get(message.getGroupId());
        if (groupedMessages == null || (groupedMessages.messages.size() > 1 && groupedMessages.getPosition(message) != null)) {
            return groupedMessages;
        }
        return null;
    }

    public void jumpToDate(int date) {
        int i;
        TLRPC.Message message;
        if (this.messages.isEmpty()) {
            return;
        }
        MessageObject messageObject = this.messages.get(0);
        ArrayList<MessageObject> arrayList = this.messages;
        MessageObject messageObject2 = arrayList.get(arrayList.size() - 1);
        if ((messageObject.messageOwner.date >= date && messageObject2.messageOwner.date <= date) || (messageObject2.messageOwner.date >= date && this.endReached[0])) {
            for (int size = this.messages.size() - 1; size >= 0; size--) {
                MessageObject messageObject3 = this.messages.get(size);
                if (messageObject3.messageOwner.date >= date && messageObject3.getId() != 0) {
                    scrollToMessageId(messageObject3.getId(), 0, false, messageObject3.getDialogId() != this.mergeDialogId ? 0 : 1, 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) {
                i = -1;
                break;
            }
            ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
            if (findFirstVisibleItemPosition < chatActivityAdapter.messagesStartRow || findFirstVisibleItemPosition >= chatActivityAdapter.messagesEndRow || (message = this.messages.get(findFirstVisibleItemPosition - this.chatAdapter.messagesStartRow).messageOwner) == null) {
                findFirstVisibleItemPosition++;
            } else {
                int i2 = message.date < date ? 1 : 0;
                if (isSecretChat()) {
                    i2 ^= 1;
                }
                i = i2 ^ 1;
            }
        }
        this.chatScrollHelper.setScrollDirection(i);
        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 i3 = this.lastLoadIndex;
        this.postponedScrollToLastMessageQueryIndex = i3;
        this.fakePostponedScroll = false;
        this.waitingForLoad.add(Integer.valueOf(i3));
        this.postponedScrollMessageId = 0;
        this.postponedScrollIsCanceled = false;
        MessagesController messagesController = getMessagesController();
        long j = this.dialog_id;
        long j2 = this.mergeDialogId;
        int i4 = ((BaseFragment) this).classGuid;
        int i5 = this.chatMode;
        long j3 = this.threadMessageId;
        int i6 = this.replyMaxReadId;
        int i7 = this.lastLoadIndex;
        this.lastLoadIndex = i7 + 1;
        messagesController.loadMessages(j, j2, false, 30, 0, date, true, 0, i4, 4, 0, i5, j3, i6, i7, this.isTopic);
        this.floatingDateView.setAlpha(0.0f);
        this.floatingDateView.setTag(null);
    }

    public void processInlineBotWebView(final TLRPC.TL_inlineBotWebView object) {
        final Runnable runnable = new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$processInlineBotWebView$114(object);
            }
        };
        if (this.approved) {
            runnable.run();
        } else {
            WebAppDisclaimerAlert.show(getContext(), new com.google.android.exoplayer2.util.Consumer() {
                public final void accept(Object obj) {
                    ChatActivity.this.lambda$processInlineBotWebView$115(runnable, (Boolean) obj);
                }
            }, null);
        }
    }

    public void lambda$processInlineBotWebView$114(TLRPC.TL_inlineBotWebView tL_inlineBotWebView) {
        BotWebViewSheet botWebViewSheet = new BotWebViewSheet(getContext(), getResourceProvider());
        botWebViewSheet.setParentActivity(getParentActivity());
        int i = ((BaseFragment) this).currentAccount;
        TLRPC.User user = this.currentUser;
        botWebViewSheet.requestWebView(i, user != null ? user.id : this.currentChat.id, this.mentionContainer.getAdapter().getFoundContextBot().id, tL_inlineBotWebView.text, tL_inlineBotWebView.url, 1, 0, false, 1);
        showDialog(botWebViewSheet);
    }

    public void lambda$processInlineBotWebView$115(Runnable runnable, Boolean bool) {
        this.approved = true;
        runnable.run();
    }

    public void processInlineBotContextPM(TLRPC.TL_inlineBotSwitchPM object) {
        MentionsContainerView mentionsContainerView;
        TLRPC.User contextBotUser;
        if (object == 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, object.start_param);
            return;
        }
        Bundle bundle = new Bundle();
        bundle.putLong("user_id", contextBotUser.id);
        bundle.putString("inline_query", object.start_param);
        bundle.putLong("inline_return", this.dialog_id);
        if (getMessagesController().checkCanOpenChat(bundle, this)) {
            presentFragment(new ChatActivity(bundle));
        }
    }

    public final void createChatAttachView() {
        if (getParentActivity() == null || getContext() == null || this.chatAttachAlert != null) {
            return;
        }
        ChatAttachAlert chatAttachAlert = new ChatAttachAlert(getParentActivity(), this, false, 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 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 z, int i, long j, boolean z2) {
                ChatAttachAlert.ChatAttachViewDelegate.-CC.$default$sendAudio(this, arrayList, charSequence, z, i, j, z2);
            }

            public void didPressedButton(int button, boolean arg, boolean notify, int scheduleDate, long effectId, boolean invertMedia, boolean forceDocument) {
                ChatActivity chatActivity;
                ChatAttachAlert chatAttachAlert2;
                boolean z;
                String str;
                if (ChatActivity.this.getParentActivity() == null || (chatAttachAlert2 = (chatActivity = ChatActivity.this).chatAttachAlert) == null) {
                    return;
                }
                chatActivity.editingMessageObject = chatAttachAlert2.getEditingMessageObject();
                if (button == 8 || button == 7 || (button == 4 && !ChatActivity.this.chatAttachAlert.getPhotoLayout().getSelectedPhotos().isEmpty())) {
                    if (button != 8) {
                        ChatActivity.this.chatAttachAlert.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);
                        for (int i = 0; i < ceil; i++) {
                            int i2 = i * 10;
                            int min = Math.min(10, selectedPhotos.size() - i2);
                            ArrayList arrayList = new ArrayList();
                            for (int i3 = 0; i3 < min; i3++) {
                                int i4 = i2 + i3;
                                if (i4 < selectedPhotosOrder.size()) {
                                    MediaController.PhotoEntry photoEntry = (MediaController.PhotoEntry) selectedPhotos.get(selectedPhotosOrder.get(i4));
                                    SendMessagesHelper.SendingMediaInfo sendingMediaInfo = new SendMessagesHelper.SendingMediaInfo();
                                    boolean z2 = photoEntry.isVideo;
                                    if (!z2 && (str = ((MediaController.MediaEditState) photoEntry).imagePath) != null) {
                                        sendingMediaInfo.path = str;
                                    } else {
                                        String str2 = photoEntry.path;
                                        if (str2 != null) {
                                            sendingMediaInfo.path = str2;
                                        }
                                    }
                                    sendingMediaInfo.thumbPath = ((MediaController.MediaEditState) photoEntry).thumbPath;
                                    sendingMediaInfo.isVideo = z2;
                                    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;
                                    arrayList.add(sendingMediaInfo);
                                    photoEntry.reset();
                                }
                            }
                            if (i == 0) {
                                ChatActivity.this.fillEditingMediaWithCaption(((SendMessagesHelper.SendingMediaInfo) arrayList.get(0)).caption, ((SendMessagesHelper.SendingMediaInfo) arrayList.get(0)).entities);
                                z = ((SendMessagesHelper.SendingMediaInfo) arrayList.get(0)).updateStickersOrder;
                            } else {
                                z = false;
                            }
                            AccountInstance accountInstance = ChatActivity.this.getAccountInstance();
                            long j = ChatActivity.this.dialog_id;
                            MessageObject messageObject = ChatActivity.this.replyingMessageObject;
                            MessageObject threadMessage = ChatActivity.this.getThreadMessage();
                            ReplyQuote replyQuote = ChatActivity.this.replyingQuote;
                            boolean z3 = button == 4 || forceDocument;
                            ChatActivity chatActivity2 = ChatActivity.this;
                            MessageObject messageObject2 = chatActivity2.editingMessageObject;
                            int i5 = chatActivity2.chatMode;
                            ChatActivity chatActivity3 = ChatActivity.this;
                            SendMessagesHelper.prepareSendingMedia(accountInstance, arrayList, j, messageObject, threadMessage, (TL_stories.StoryItem) null, replyQuote, z3, arg, messageObject2, notify, scheduleDate, i5, z, (InputContentInfoCompat) null, chatActivity3.quickReplyShortcut, chatActivity3.getQuickReplyId(), effectId, invertMedia);
                        }
                        ChatActivity.this.afterMessageSend();
                        ChatActivity.this.chatActivityEnterView.setFieldText("");
                    }
                    if (scheduleDate != 0) {
                        if (ChatActivity.this.scheduledMessagesCount == -1) {
                            ChatActivity.this.scheduledMessagesCount = 0;
                        }
                        ChatActivity.this.scheduledMessagesCount += selectedPhotos.size();
                        ChatActivity.this.updateScheduledInterface(true);
                        return;
                    }
                    return;
                }
                ChatAttachAlert chatAttachAlert3 = ChatActivity.this.chatAttachAlert;
                if (chatAttachAlert3 != null) {
                    chatAttachAlert3.dismissWithButtonClick(button);
                }
                ChatActivity.this.processSelectedAttach(button);
            }

            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 onCameraOpened() {
                ChatActivity.this.chatActivityEnterView.closeKeyboard();
            }

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

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

    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 onEditTextDialogClose(boolean resetAdjust, boolean reset) {
        if (this.openKeyboardOnAttachMenuClose) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$onEditTextDialogClose$116();
                }
            }, 50L);
            if (reset) {
                this.openKeyboardOnAttachMenuClose = false;
            }
        }
        if (!resetAdjust || this.isInsideContainer) {
            return;
        }
        AndroidUtilities.requestAdjustResize(getParentActivity(), ((BaseFragment) this).classGuid);
    }

    public void lambda$onEditTextDialogClose$116() {
        this.chatActivityEnterView.openKeyboard();
    }

    public void lambda$openDiscussionMessageChat$378(Runnable runnable) {
        NotificationCenter.getInstance(((BaseFragment) this).currentAccount).doOnIdle(runnable);
    }

    public void performHistoryClear(final boolean revoke, boolean canDeleteHistory) {
        this.clearingHistory = 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$117(revoke);
            }
        }, new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$performHistoryClear$118();
            }
        });
        this.chatAdapter.notifyDataSetChanged();
    }

    public void lambda$performHistoryClear$117(boolean z) {
        if (!this.pinnedMessageIds.isEmpty()) {
            MessagesController.getNotificationsSettings(((BaseFragment) this).currentAccount).edit().putInt("pin_" + this.dialog_id, this.pinnedMessageIds.get(0).intValue()).commit();
            this.pinnedMessageIds.clear();
            this.pinnedMessageObjects.clear();
            this.currentPinnedMessageId = 0;
            this.loadedPinnedMessagesCount = 0;
            this.totalPinnedMessagesCount = 0;
            updatePinnedMessageView(true);
        }
        getMessagesController().deleteDialog(this.dialog_id, 1, z);
        this.clearingHistory = false;
        clearHistory(false, null);
        this.chatAdapter.notifyDataSetChanged();
    }

    public void lambda$performHistoryClear$118() {
        this.clearingHistory = false;
        this.chatAdapter.notifyDataSetChanged();
    }

    public long getDialogId() {
        return this.dialog_id;
    }

    public int getDialogFolderId() {
        return this.dialogFolderId;
    }

    public int getDialogFilterId() {
        return this.dialogFilterId;
    }

    public boolean openedWithLivestream() {
        return this.livestream;
    }

    public UndoView getUndoView() {
        createUndoView();
        return this.undoView;
    }

    public long getMergeDialogId() {
        return this.mergeDialogId;
    }

    public boolean hasReportSpam() {
        BlurredFrameLayout blurredFrameLayout = this.topChatPanelView;
        return (blurredFrameLayout == null || blurredFrameLayout.getTag() != null || this.reportSpamButton.getVisibility() == 8) ? false : true;
    }

    public boolean isReport() {
        return this.reportType >= 0;
    }

    public void setChatInvite(TLRPC.ChatInvite invite) {
        this.chatInvite = invite;
    }

    public void setBotUser(String value) {
        if (this.inlineReturn != 0) {
            getMessagesController().sendBotStart(this.currentUser, value);
            return;
        }
        this.sentBotStart = true;
        MessagesController messagesController = getMessagesController();
        TLRPC.User user = this.currentUser;
        this.botUser = value;
        messagesController.sendBotStart(user, value);
        updateBottomOverlay();
    }

    public final void afterMessageSend() {
        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 final void toggleMesagesSearchListView() {
        FrameLayout frameLayout = this.messagesSearchListContainer;
        if (frameLayout != null) {
            showMessagesSearchListView(frameLayout.getTag() == null);
        }
    }

    public final void showMessagesSearchListView(final boolean show) {
        FrameLayout frameLayout = this.messagesSearchListContainer;
        if (frameLayout != null) {
            if (!show || frameLayout.getTag() == null) {
                if (show || this.messagesSearchListContainer.getTag() != null) {
                    AnimatorSet animatorSet = this.messagesSearchListViewAnimation;
                    if (animatorSet != null) {
                        animatorSet.cancel();
                        this.messagesSearchListViewAnimation = null;
                    }
                    if (show) {
                        this.messagesSearchListContainer.setVisibility(0);
                    }
                    if (!show && 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<MessageObject> 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 z = false;
                            boolean z2 = false;
                            int i4 = -1;
                            for (int i5 = 0; i5 < messages.size(); i5++) {
                                if (messages.get(i5).messageOwner.id == i2) {
                                    int i6 = this.chatAdapter.messagesStartRow + i5;
                                    z = findFirstVisibleItemPosition <= i6 && findLastVisibleItemPosition >= i6;
                                    if (z) {
                                        break;
                                    }
                                }
                                if (messages.get(i5).messageOwner.id == i3) {
                                    int i7 = this.chatAdapter.messagesStartRow + i5;
                                    z2 = findFirstVisibleItemPosition <= i7 && findLastVisibleItemPosition >= i7;
                                    if (z2) {
                                        break;
                                    }
                                }
                                if (messages.get(i5).messageOwner.id == i) {
                                    i4 = i5;
                                }
                            }
                            if (!z && !z2 && i4 != -1) {
                                this.chatLayoutManager.scrollToPositionWithOffset(this.chatAdapter.messagesStartRow + i4, (this.chatListView.getHeight() - getHeightForMessage(messages.get(i4), true)) / 2);
                            }
                        }
                    }
                    this.messagesSearchListContainer.setTag(show ? 1 : null);
                    FrameLayout frameLayout2 = this.messagesSearchListContainer;
                    ChatSearchTabs chatSearchTabs = this.hashtagSearchTabs;
                    int height = (chatSearchTabs == null || !chatSearchTabs.shown()) ? 0 : this.hashtagSearchTabs.getHeight();
                    SearchTagsList searchTagsList = this.actionBarSearchTags;
                    frameLayout2.setPadding(0, height + ((searchTagsList == null || !searchTagsList.shown()) ? 0 : this.actionBarSearchTags.getHeight()), 0, 0);
                    AnimatorSet animatorSet2 = new AnimatorSet();
                    this.messagesSearchListViewAnimation = animatorSet2;
                    Animator[] animatorArr = new Animator[1];
                    FrameLayout frameLayout3 = this.messagesSearchListContainer;
                    Property property = View.ALPHA;
                    float[] fArr = new float[1];
                    fArr[0] = show ? 1.0f : 0.0f;
                    animatorArr[0] = ObjectAnimator.ofFloat(frameLayout3, (Property<FrameLayout, Float>) property, fArr);
                    animatorSet2.playTogether(animatorArr);
                    this.messagesSearchListViewAnimation.setInterpolator(CubicBezierInterpolator.EASE_IN);
                    this.messagesSearchListViewAnimation.setDuration(180L);
                    this.messagesSearchListViewAnimation.addListener(new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationEnd(Animator animation) {
                            if (animation.equals(ChatActivity.this.messagesSearchListViewAnimation)) {
                                ChatActivity.this.messagesSearchListViewAnimation = null;
                                if (show) {
                                    return;
                                }
                                ChatActivity.this.messagesSearchListContainer.setVisibility(8);
                            }
                        }

                        @Override
                        public void onAnimationCancel(Animator animation) {
                            if (animation.equals(ChatActivity.this.messagesSearchListViewAnimation)) {
                                ChatActivity.this.messagesSearchListViewAnimation = null;
                            }
                        }
                    });
                    this.messagesSearchListViewAnimation.start();
                    AnimatedTextView animatedTextView = this.searchExpandList;
                    if (animatedTextView != null) {
                        FrameLayout frameLayout4 = this.messagesSearchListContainer;
                        animatedTextView.setText(LocaleController.getString((frameLayout4 == null || frameLayout4.getTag() == null) ? R.string.SearchAsList : R.string.SearchAsChat), !LocaleController.isRTL);
                    }
                    hideHints();
                    updateSearchCountText();
                }
            }
        }
    }

    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 = 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 || getParentActivity().checkSelfPermission("android.permission.RECORD_AUDIO") == 0) {
            return false;
        }
        getParentActivity().requestPermissions(new String[]{"android.permission.RECORD_AUDIO"}, 3);
        return true;
    }

    public final void openScheduledMessages() {
        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) {
                bundle.putLong("chat_id", chat.id);
            } else {
                bundle.putLong("user_id", this.currentUser.id);
            }
        }
        bundle.putInt("chatMode", 1);
        ChatActivity chatActivity = new ChatActivity(bundle);
        if (this.isTopic) {
            ForumUtilities.applyTopic(chatActivity, MessagesStorage.TopicKey.of(getDialogId(), getTopicId()));
        }
        chatActivity.chatActivityDelegate = new ChatActivityDelegate() {
            @Override
            public void onReport() {
                ChatActivityDelegate.CC.$default$onReport(this);
            }

            @Override
            public void onUnpin(boolean z, boolean z2) {
                ChatActivityDelegate.CC.$default$onUnpin(this, z, z2);
            }

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

            @Override
            public void openHashtagSearch(String text) {
                ChatActivity.this.lambda$openHashtagSearch$364(text);
            }
        };
        presentFragment(chatActivity, false);
    }

    public void shareMyContact(final int type, final MessageObject messageObject) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity(), this.themeDelegate);
        builder.setTitle(LocaleController.getString("ShareYouPhoneNumberTitle", R.string.ShareYouPhoneNumberTitle));
        TLRPC.User user = this.currentUser;
        if (user != null) {
            if (user.bot) {
                builder.setMessage(LocaleController.getString("AreYouSureShareMyContactInfoBot", R.string.AreYouSureShareMyContactInfoBot));
            } else {
                int i = R.string.AreYouSureShareMyContactInfoUser;
                PhoneFormat phoneFormat = PhoneFormat.getInstance();
                TLRPC.User user2 = this.currentUser;
                builder.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("AreYouSureShareMyContactInfoUser", i, new Object[]{phoneFormat.format("+" + getUserConfig().getCurrentUser().phone), ContactsController.formatName(user2.first_name, user2.last_name)})));
            }
        } else {
            builder.setMessage(LocaleController.getString("AreYouSureShareMyContactInfo", R.string.AreYouSureShareMyContactInfo));
        }
        builder.setPositiveButton(LocaleController.getString("ShareContact", R.string.ShareContact), new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i2) {
                ChatActivity.this.lambda$shareMyContact$120(type, messageObject, dialogInterface, i2);
            }
        });
        builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
        showDialog(builder.create());
    }

    public void lambda$shareMyContact$120(int i, MessageObject messageObject, DialogInterface dialogInterface, 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$119(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$shareMyContact$119(TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error != null) {
            return;
        }
        getMessagesController().processUpdates((TLRPC.Updates) tLObject, false);
    }

    public final void showVoiceHint(boolean hide, boolean video) {
        ChatActivityEnterView chatActivityEnterView;
        int i;
        String str;
        if (getParentActivity() == null || ((BaseFragment) this).fragmentView == null) {
            return;
        }
        if ((hide && 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 hintView = new HintView(getParentActivity(), 9, this.themeDelegate);
            this.voiceHintTextView = hintView;
            sizeNotifierFrameLayout.addView(hintView, indexOfChild + 1, LayoutHelper.createFrame(-2, -2.0f, 51, 10.0f, 0.0f, 10.0f, 0.0f));
        }
        if (hide) {
            this.voiceHintTextView.hide();
            return;
        }
        if (this.chatActivityEnterView.hasRecordVideo()) {
            HintView hintView2 = this.voiceHintTextView;
            if (video) {
                i = R.string.HoldToVideo;
                str = "HoldToVideo";
            } else {
                i = R.string.HoldToAudio;
                str = "HoldToAudio";
            }
            hintView2.setText(LocaleController.getString(str, i));
        } else {
            this.voiceHintTextView.setText(LocaleController.getString("HoldToAudioOnly", R.string.HoldToAudioOnly));
        }
        this.voiceHintTextView.showForView(this.chatActivityEnterView.getAudioVideoButtonContainer(), 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("Slowmode", R.string.Slowmode)).setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("SlowModeHint", R.string.SlowModeHint, new Object[]{slowModeTimer}))).setPositiveButton(LocaleController.getString("OK", R.string.OK), null).show();
        return false;
    }

    public final void hideHints(boolean scroll) {
        if (!scroll) {
            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();
        }
    }

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

    public final void showSlowModeHint(View view, boolean show, CharSequence time) {
        HintView hintView;
        if (getParentActivity() == null || ((BaseFragment) this).fragmentView == null) {
            return;
        }
        if (show || ((hintView = this.slowModeHint) != null && hintView.getVisibility() == 0)) {
            this.slowModeHint.setText(AndroidUtilities.replaceTags(LocaleController.formatString("SlowModeHint", R.string.SlowModeHint, new Object[]{time})));
            if (show) {
                this.slowModeHint.showForView(view, true);
            }
        }
    }

    public void showTimerHint() {
        String formatPluralString;
        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;
        if (i > 86400) {
            formatPluralString = LocaleController.formatPluralString("Days", i / 86400, new Object[0]);
        } else if (i >= 3600) {
            formatPluralString = LocaleController.formatPluralString("Hours", i / 3600, new Object[0]);
        } else if (i >= 60) {
            formatPluralString = LocaleController.formatPluralString("Minutes", i / 60, new Object[0]);
        } else {
            formatPluralString = LocaleController.formatPluralString("Seconds", i, new Object[0]);
        }
        this.timerHintView.setText(LocaleController.formatString("AutoDeleteSetInfo", R.string.AutoDeleteSetInfo, new Object[]{formatPluralString}));
        this.timerHintView.showForView(this.avatarContainer.getTimeItem(), true);
    }

    public final 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);
    }

    public final 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 final void showMediaBannedHint() {
        SizeNotifierFrameLayout sizeNotifierFrameLayout;
        int indexOfChild;
        if (getParentActivity() != null) {
            if ((this.currentChat == null && this.userInfo == null) || ((BaseFragment) this).fragmentView == null) {
                return;
            }
            HintView hintView = this.mediaBanTooltip;
            if ((hintView == null || hintView.getVisibility() != 0) && (indexOfChild = (sizeNotifierFrameLayout = ((BaseFragment) this).fragmentView).indexOfChild(this.chatActivityEnterView)) != -1) {
                try {
                    if (!PlusSettings.disableActionsVibrations) {
                        ((BaseFragment) this).fragmentView.performHapticFeedback(3, 2);
                    }
                } catch (Exception e) {
                    FileLog.e(e);
                }
                if (this.mediaBanTooltip == null) {
                    HintView hintView2 = new HintView(getParentActivity(), 9, this.themeDelegate);
                    this.mediaBanTooltip = hintView2;
                    hintView2.setVisibility(8);
                    sizeNotifierFrameLayout.addView(this.mediaBanTooltip, indexOfChild + 1, LayoutHelper.createFrame(-2, -2.0f, 51, 10.0f, 0.0f, 10.0f, 0.0f));
                }
                TLRPC.UserFull userFull = this.userInfo;
                if (userFull != null && userFull.voice_messages_forbidden) {
                    this.mediaBanTooltip.setText(AndroidUtilities.replaceTags(LocaleController.formatString(this.chatActivityEnterView.isInVideoMode() ? R.string.VideoMessagesRestrictedByPrivacy : R.string.VoiceMessagesRestrictedByPrivacy, new Object[]{this.currentUser.first_name})));
                } else if (!ChatObject.canSendVoice(this.currentChat) && !ChatObject.canSendRoundVideo(this.currentChat)) {
                    if (checkCanRemoveRestrictionsByBoosts()) {
                        return;
                    }
                    if (this.chatActivityEnterView.isInVideoMode()) {
                        this.mediaBanTooltip.setText(ChatObject.getRestrictedErrorText(this.currentChat, 21));
                    } else {
                        this.mediaBanTooltip.setText(ChatObject.getRestrictedErrorText(this.currentChat, 20));
                    }
                } else if (ChatObject.isActionBannedByDefault(this.currentChat, 20)) {
                    this.mediaBanTooltip.setText(LocaleController.getString("GlobalAttachVoiceRestricted", R.string.GlobalAttachVoiceRestricted));
                } else if (ChatObject.isActionBannedByDefault(this.currentChat, 21)) {
                    this.mediaBanTooltip.setText(LocaleController.getString("GlobalAttachRoundRestricted", R.string.GlobalAttachRoundRestricted));
                } else if (ChatObject.isActionBannedByDefault(this.currentChat, 7)) {
                    this.mediaBanTooltip.setText(LocaleController.getString("GlobalAttachMediaRestricted", R.string.GlobalAttachMediaRestricted));
                } else {
                    TLRPC.TL_chatBannedRights tL_chatBannedRights = this.currentChat.banned_rights;
                    if (tL_chatBannedRights == null) {
                        return;
                    }
                    if (AndroidUtilities.isBannedForever(tL_chatBannedRights)) {
                        this.mediaBanTooltip.setText(LocaleController.getString("AttachMediaRestrictedForever", R.string.AttachMediaRestrictedForever));
                    } else {
                        this.mediaBanTooltip.setText(LocaleController.formatString("AttachMediaRestricted", R.string.AttachMediaRestricted, new Object[]{LocaleController.formatDateForBan(this.currentChat.banned_rights.until_date)}));
                    }
                }
                View sendButton = this.chatActivityEnterView.getSendButton();
                View audioVideoButtonContainer = this.chatActivityEnterView.getAudioVideoButtonContainer();
                if (sendButton.getAlpha() < audioVideoButtonContainer.getAlpha()) {
                    sendButton = audioVideoButtonContainer;
                }
                this.mediaBanTooltip.showForView(sendButton, true);
            }
        }
    }

    public final 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;
                }
            }
        }
    }

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

    public final 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 final void showForwardHint(ChatMessageCell cell) {
        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(cell, true);
    }

    public final void showTextSelectionHint(MessageObject messageObject) {
        CharSequence charSequence;
        if (getParentActivity() == null || getMessagesController().isChatNoForwards(messageObject.getChatId())) {
            return;
        }
        TLRPC.Message message = messageObject.messageOwner;
        if (message == null || !message.noforwards) {
            boolean z = false;
            ArrayList arrayList = messageObject.textLayoutBlocks;
            if (arrayList != null && !arrayList.isEmpty()) {
                charSequence = messageObject.messageText;
                if (messageObject.textLayoutBlocks.size() > 1) {
                    z = true;
                }
            } else {
                charSequence = messageObject.caption;
            }
            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) {
                    public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
                        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
                        updatePosition();
                    }

                    public void onDraw(Canvas canvas) {
                        super.onDraw(canvas);
                        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 final 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("TapHereGifs", 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();
                animatorSet.playTogether(ObjectAnimator.ofFloat(this.gifHintTextView, (Property<HintView, Float>) View.ALPHA, 0.0f, 1.0f), ObjectAnimator.ofFloat(this.emojiButtonRed, (Property<View, Float>) View.ALPHA, 0.0f, 1.0f));
                animatorSet.addListener(new AnonymousClass97());
                animatorSet.setDuration(300L);
                animatorSet.start();
                View emojiButton = this.chatActivityEnterView.getEmojiButton();
                if (emojiButton != null) {
                    this.gifHintTextView.showForView(emojiButton, true);
                }
                return true;
            }
        }
        return false;
    }

    public class AnonymousClass97 extends AnimatorListenerAdapter {
        public AnonymousClass97() {
        }

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

        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 animation) {
                    if (ChatActivity.this.gifHintTextView != null) {
                        ChatActivity.this.gifHintTextView.setVisibility(8);
                    }
                }
            });
            animatorSet.setDuration(300L);
            animatorSet.start();
        }
    }

    public final void openAttachMenu() {
        if (getParentActivity() != null) {
            ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
            if (chatActivityEnterView == null || TextUtils.isEmpty(chatActivityEnterView.getSlowModeTimer())) {
                createChatAttachView();
                this.chatAttachAlert.getPhotoLayout().loadGalleryPhotos();
                int i = Build.VERSION.SDK_INT;
                if (i == 21 || i == 22) {
                    this.chatActivityEnterView.closeKeyboard();
                }
                TLRPC.Chat chat = this.currentChat;
                if (chat != null && !ChatObject.hasAdminRights(chat) && this.currentChat.slowmode_enabled) {
                    this.chatAttachAlert.setMaxSelectedPhotos(10, true);
                } else {
                    this.chatAttachAlert.setMaxSelectedPhotos(-1, true);
                }
                this.chatAttachAlert.enableDefaultMode();
                this.chatAttachAlert.init();
                this.chatAttachAlert.getCommentTextView().setText(this.chatActivityEnterView.getFieldText());
                ChatAttachAlert chatAttachAlert = this.chatAttachAlert;
                chatAttachAlert.parentThemeDelegate = this.themeDelegate;
                showDialog(chatAttachAlert);
            }
        }
    }

    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 final void showFloatingDateView(boolean scroll) {
        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 animation) {
                    if (animation.equals(ChatActivity.this.floatingDateAnimation)) {
                        ChatActivity.this.floatingDateAnimation = null;
                    }
                    if (ChatActivity.this.chatDialogsView == null || !Theme.plusShowQuickBar || Theme.plusVerticalQuickBar || !Theme.plusCenterQuickBarBtn) {
                        return;
                    }
                    ChatActivity.this.chatDialogsView.setAlpha(1.0f);
                }
            });
            this.floatingDateAnimation.start();
            ChatDialogsView chatDialogsView = this.chatDialogsView;
            if (chatDialogsView != null && Theme.plusShowQuickBar && !Theme.plusVerticalQuickBar && Theme.plusCenterQuickBarBtn && chatDialogsView.getAlpha() != 0.0f) {
                this.chatDialogsView.setAlpha(0.0f);
            }
        }
        if (scroll) {
            return;
        }
        invalidateMessagesVisiblePart();
        this.hideDateDelay = 1000;
    }

    public final void hideFloatingDateView(boolean animated) {
        if (this.floatingDateView.getTag() == null || this.currentFloatingDateOnScreen) {
            return;
        }
        if (!this.scrollingFloatingDate || this.currentFloatingTopIsNotMessage) {
            this.floatingDateView.setTag(null);
            if (animated) {
                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 animation) {
                        if (animation.equals(ChatActivity.this.floatingDateAnimation)) {
                            ChatActivity.this.floatingDateAnimation = null;
                        }
                        if (ChatActivity.this.chatDialogsView == null || !Theme.plusShowQuickBar || Theme.plusVerticalQuickBar || !Theme.plusCenterQuickBarBtn) {
                            return;
                        }
                        ChatActivity.this.chatDialogsView.setAlpha(1.0f);
                    }
                });
                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 onRemoveFromParent() {
        this.removingFromParent = true;
        MessageObject playingMessageObject = MediaController.getInstance().getPlayingMessageObject();
        if (playingMessageObject != null && playingMessageObject.isVideo()) {
            MediaController.getInstance().cleanupPlayer(true, true);
        } else {
            MediaController.getInstance().setTextureView(this.videoTextureView, (AspectRatioFrameLayout) null, (FrameLayout) null, false);
        }
    }

    public void setIgnoreAttachOnPause(boolean value) {
        this.ignoreAttachOnPause = value;
    }

    public ChatActivityEnterView getChatActivityEnterViewForStickers() {
        TLRPC.Chat chat;
        if (this.bottomOverlayChat.getVisibility() == 0 || !((chat = this.currentChat) == null || ChatObject.canSendStickers(chat))) {
            return null;
        }
        return this.chatActivityEnterView;
    }

    public ChatActivityEnterView getChatActivityEnterView() {
        return this.chatActivityEnterView;
    }

    public boolean isKeyboardVisible() {
        return this.contentView.getKeyboardHeight() > AndroidUtilities.dp(20.0f);
    }

    public final void checkScrollForLoad(boolean scroll) {
        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 = scroll ? 25 : 5;
        if (this.chatMode == 7) {
            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);
            return;
        }
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$checkScrollForLoad$121(itemCount, i2, i3, i5);
            }
        });
    }

    public void lambda$checkScrollForLoad$121(int i, int i2, int i3, int i4) {
        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 messagesController = getMessagesController();
                    long j = this.dialog_id;
                    long j2 = this.mergeDialogId;
                    int i5 = this.maxMessageId[0];
                    boolean z = !this.cacheEndReached[0];
                    int i6 = this.minDate[0];
                    int i7 = ((BaseFragment) this).classGuid;
                    int i8 = this.chatMode;
                    long j3 = this.threadMessageId;
                    int i9 = this.replyMaxReadId;
                    int i10 = this.lastLoadIndex;
                    this.lastLoadIndex = i10 + 1;
                    messagesController.loadMessages(j, j2, false, 50, i5, 0, z, i6, i7, 0, 0, i8, j3, i9, i10, this.isTopic);
                } else {
                    MessagesController messagesController2 = getMessagesController();
                    long j4 = this.dialog_id;
                    long j5 = this.mergeDialogId;
                    boolean z2 = !this.cacheEndReached[0];
                    int i11 = this.minDate[0];
                    int i12 = ((BaseFragment) this).classGuid;
                    int i13 = this.chatMode;
                    long j6 = this.threadMessageId;
                    int i14 = this.replyMaxReadId;
                    int i15 = this.lastLoadIndex;
                    this.lastLoadIndex = i15 + 1;
                    messagesController2.loadMessages(j4, j5, false, 50, 0, 0, z2, i11, i12, 0, 0, i13, j6, i14, i15, this.isTopic);
                }
            } else if (this.mergeDialogId != 0 && !zArr[1]) {
                this.loading = true;
                this.waitingForLoad.add(Integer.valueOf(this.lastLoadIndex));
                MessagesController messagesController3 = getMessagesController();
                long j7 = this.mergeDialogId;
                int i16 = this.maxMessageId[1];
                boolean z3 = !this.cacheEndReached[1];
                int i17 = this.minDate[1];
                int i18 = ((BaseFragment) this).classGuid;
                int i19 = this.chatMode;
                long j8 = this.threadMessageId;
                int i20 = this.replyMaxReadId;
                int i21 = this.lastLoadIndex;
                this.lastLoadIndex = i21 + 1;
                messagesController3.loadMessages(j7, 0L, false, 50, i16, 0, z3, i17, i18, 0, 0, i19, j8, i20, i21, 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 messagesController4 = getMessagesController();
            long j9 = this.mergeDialogId;
            int i22 = this.minMessageId[1];
            int i23 = this.maxDate[1];
            int i24 = ((BaseFragment) this).classGuid;
            int i25 = this.chatMode;
            long j10 = this.threadMessageId;
            int i26 = this.replyMaxReadId;
            int i27 = this.lastLoadIndex;
            this.lastLoadIndex = i27 + 1;
            messagesController4.loadMessages(j9, 0L, false, 50, i22, 0, true, i23, i24, 1, 0, i25, j10, i26, i27, this.isTopic);
            this.loadingForward = true;
            return;
        }
        if (this.forwardEndReached[0]) {
            return;
        }
        this.waitingForLoad.add(Integer.valueOf(this.lastLoadIndex));
        MessagesController messagesController5 = getMessagesController();
        long j11 = this.dialog_id;
        long j12 = this.mergeDialogId;
        int i28 = this.minMessageId[0];
        int i29 = this.maxDate[0];
        int i30 = ((BaseFragment) this).classGuid;
        int i31 = this.chatMode;
        long j13 = this.threadMessageId;
        int i32 = this.replyMaxReadId;
        int i33 = this.lastLoadIndex;
        this.lastLoadIndex = i33 + 1;
        messagesController5.loadMessages(j11, j12, false, 50, i28, 0, true, i29, i30, 1, 0, i31, j13, i32, i33, this.isTopic);
        this.loadingForward = true;
    }

    public final void processSelectedAttach(int which) {
        TLRPC.TL_chatBannedRights tL_chatBannedRights;
        if (which == 0) {
            int i = Build.VERSION.SDK_INT;
            if (i >= 23 && getParentActivity().checkSelfPermission("android.permission.CAMERA") != 0) {
                getParentActivity().requestPermissions(new String[]{"android.permission.CAMERA"}, 19);
                return;
            }
            try {
                Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
                File generatePicturePath = AndroidUtilities.generatePicturePath();
                if (generatePicturePath != null) {
                    if (i >= 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;
            } catch (Exception e) {
                FileLog.e(e);
                return;
            }
        }
        if (which == 1) {
            Activity parentActivity = getParentActivity();
            int i2 = Build.VERSION.SDK_INT;
            if (i2 >= 33) {
                if (parentActivity.checkSelfPermission("android.permission.READ_MEDIA_IMAGES") != 0) {
                    try {
                        getParentActivity().requestPermissions(new String[]{"android.permission.READ_MEDIA_IMAGES", "android.permission.READ_MEDIA_VIDEO"}, 4);
                        return;
                    } catch (Throwable unused) {
                        return;
                    }
                }
            } else if (i2 >= 23 && parentActivity.checkSelfPermission("android.permission.READ_EXTERNAL_STORAGE") != 0) {
                try {
                    getParentActivity().requestPermissions(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) {
                photoAlbumPickerActivity.setMaxSelectedPhotos(10, true);
            } else {
                MessageObject messageObject = this.editingMessageObject;
                photoAlbumPickerActivity.setMaxSelectedPhotos(messageObject != null ? 1 : 0, messageObject == null);
            }
            photoAlbumPickerActivity.setDelegate(new PhotoAlbumPickerActivity.PhotoAlbumPickerActivityDelegate() {
                @Override
                public void didSelectPhotos(ArrayList<SendMessagesHelper.SendingMediaInfo> photos, boolean notify, int scheduleDate) {
                }

                @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 e2) {
                        FileLog.e(e2);
                    }
                }
            });
            presentFragment(photoAlbumPickerActivity);
            return;
        }
        if (which == 2) {
            int i3 = Build.VERSION.SDK_INT;
            if (i3 >= 23 && getParentActivity().checkSelfPermission("android.permission.CAMERA") != 0) {
                try {
                    getParentActivity().requestPermissions(new String[]{"android.permission.CAMERA"}, 20);
                    return;
                } catch (Throwable unused3) {
                    return;
                }
            }
            try {
                Intent intent2 = new Intent("android.media.action.VIDEO_CAPTURE");
                File generateVideoPath = AndroidUtilities.generateVideoPath();
                if (generateVideoPath != null) {
                    if (i3 >= 24) {
                        intent2.putExtra("output", FileProvider.getUriForFile(getParentActivity(), ApplicationLoader.getApplicationId() + ".provider", generateVideoPath));
                        intent2.addFlags(2);
                        intent2.addFlags(1);
                    } else if (i3 >= 18) {
                        intent2.putExtra("output", Uri.fromFile(generateVideoPath));
                    }
                    intent2.putExtra("android.intent.extra.sizeLimit", 2097152000L);
                    this.currentPicturePath = generateVideoPath.getAbsolutePath();
                }
                startActivityForResult(intent2, 2);
            } catch (Exception e2) {
                FileLog.e(e2);
            }
        }
    }

    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 openPollCreate(Boolean quiz) {
        PollCreateActivity pollCreateActivity = new PollCreateActivity(this, quiz);
        pollCreateActivity.setDelegate(new PollCreateActivity.PollCreateActivityDelegate() {
            @Override
            public final void sendPoll(TLRPC.TL_messageMediaPoll tL_messageMediaPoll, HashMap hashMap, boolean z, int i) {
                ChatActivity.this.lambda$openPollCreate$122(tL_messageMediaPoll, hashMap, z, i);
            }
        });
        presentFragment(pollCreateActivity);
    }

    public void lambda$openPollCreate$122(TLRPC.TL_messageMediaPoll tL_messageMediaPoll, HashMap hashMap, boolean z, int i) {
        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();
            getSendMessagesHelper().sendMessage(of);
            afterMessageSend();
        }
    }

    public void didSelectFiles(ArrayList<String> files, String caption, ArrayList<MessageObject> fmessages, boolean notify, int scheduleDate, long effectId, boolean invertMedia) {
        String str;
        fillEditingMediaWithCaption(caption, null);
        if (checkSlowModeAlert()) {
            if (fmessages.isEmpty() || TextUtils.isEmpty(caption)) {
                str = caption;
            } else {
                SendMessagesHelper.SendMessageParams of = SendMessagesHelper.SendMessageParams.of(caption, 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 = invertMedia;
                SendMessagesHelper.getInstance(((BaseFragment) this).currentAccount).sendMessage(of);
                str = null;
            }
            getSendMessagesHelper().sendMessage(fmessages, this.dialog_id, false, false, true, 0);
            SendMessagesHelper.prepareSendingDocuments(getAccountInstance(), files, files, (ArrayList) null, str, (String) null, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TL_stories.StoryItem) null, this.replyingQuote, this.editingMessageObject, notify, scheduleDate, (InputContentInfoCompat) null, this.quickReplyShortcut, getQuickReplyId(), effectId, invertMedia);
            afterMessageSend();
        }
    }

    public void didSelectPhotos(ArrayList<SendMessagesHelper.SendingMediaInfo> photos, boolean notify, int scheduleDate) {
        fillEditingMediaWithCaption(photos.get(0).caption, photos.get(0).entities);
        SendMessagesHelper.prepareSendingMedia(getAccountInstance(), photos, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TL_stories.StoryItem) null, this.replyingQuote, true, false, this.editingMessageObject, notify, scheduleDate, this.chatMode, photos.get(0).updateStickersOrder, (InputContentInfoCompat) null, this.quickReplyShortcut, getQuickReplyId(), 0L, false);
        afterMessageSend();
        if (scheduleDate != 0) {
            if (this.scheduledMessagesCount == -1) {
                this.scheduledMessagesCount = 0;
            }
            this.scheduledMessagesCount += photos.size();
            updateScheduledInterface(true);
        }
    }

    public void didSelectSearchPhotos(ArrayList<SendMessagesHelper.SendingMediaInfo> photos, boolean notify, int scheduleDate) {
        boolean z;
        int i;
        ChatActivity chatActivity = this;
        if (!photos.isEmpty() && checkSlowModeAlert()) {
            int i2 = 0;
            while (true) {
                if (i2 >= photos.size()) {
                    z = false;
                    break;
                }
                SendMessagesHelper.SendingMediaInfo sendingMediaInfo = photos.get(i2);
                if (sendingMediaInfo.inlineResult == null && sendingMediaInfo.videoEditedInfo == null) {
                    z = true;
                    break;
                }
                i2++;
            }
            if (!z && !TextUtils.isEmpty(photos.get(0).caption)) {
                SendMessagesHelper.SendMessageParams of = SendMessagesHelper.SendMessageParams.of(photos.get(0).caption, chatActivity.dialog_id, chatActivity.replyingMessageObject, getThreadMessage(), (TLRPC.WebPage) null, false, photos.get(0).entities, (TLRPC.ReplyMarkup) null, (HashMap) null, notify, scheduleDate, (MessageObject.SendAnimationData) null, false);
                of.quick_reply_shortcut = chatActivity.quickReplyShortcut;
                of.quick_reply_shortcut_id = getQuickReplyId();
                SendMessagesHelper.getInstance(((BaseFragment) chatActivity).currentAccount).sendMessage(of);
            }
            int i3 = 0;
            while (i3 < photos.size()) {
                SendMessagesHelper.SendingMediaInfo sendingMediaInfo2 = photos.get(i3);
                if (sendingMediaInfo2.inlineResult == null || sendingMediaInfo2.videoEditedInfo != null) {
                    i = i3;
                } else {
                    int i4 = i3;
                    SendMessagesHelper.prepareSendingBotContextResult(this, getAccountInstance(), sendingMediaInfo2.inlineResult, sendingMediaInfo2.params, chatActivity.dialog_id, chatActivity.replyingMessageObject, getThreadMessage(), (TL_stories.StoryItem) null, chatActivity.replyingQuote, notify, scheduleDate, chatActivity.quickReplyShortcut, getQuickReplyId());
                    photos.remove(i4);
                    i = i4 - 1;
                }
                i3 = i + 1;
                chatActivity = this;
            }
            if (photos.isEmpty()) {
                return;
            }
            fillEditingMediaWithCaption(photos.get(0).caption, photos.get(0).entities);
            SendMessagesHelper.prepareSendingMedia(getAccountInstance(), photos, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TL_stories.StoryItem) null, this.replyingQuote, false, true, this.editingMessageObject, notify, scheduleDate, this.chatMode, photos.get(0).updateStickersOrder, (InputContentInfoCompat) null, this.quickReplyShortcut, getQuickReplyId(), 0L, false);
            afterMessageSend();
            if (scheduleDate != 0) {
                if (this.scheduledMessagesCount == -1) {
                    this.scheduledMessagesCount = 0;
                }
                this.scheduledMessagesCount += photos.size();
                updateScheduledInterface(true);
            }
        }
    }

    public void startDocumentSelectActivity() {
        try {
            Intent intent = new Intent("android.intent.action.GET_CONTENT");
            if (Build.VERSION.SDK_INT >= 18) {
                intent.putExtra("android.intent.extra.ALLOW_MULTIPLE", true);
            }
            intent.setType("*/*");
            startActivityForResult(intent, 21);
        } catch (Exception e) {
            FileLog.e(e);
        }
    }

    public boolean dismissDialogOnPause(Dialog dialog) {
        return (dialog == this.chatAttachAlert || dialog == this.chatThemeBottomSheet || (dialog instanceof BotWebViewSheet) || !super.dismissDialogOnPause(dialog)) ? false : true;
    }

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

    public final 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 void checkEditLinkRemoved(final 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 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 lambda$searchLinks$129(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<CharSequence> 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(arrayList.get(i), 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$124();
                    }
                });
                return;
            }
            charSequence2 = charSequence;
        }
        if (arrayList == null) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$searchLinks$123();
                }
            });
            return;
        }
        charSequence2 = TextUtils.join(" ", arrayList);
        if (arrayList != null && !arrayList.isEmpty()) {
            arrayList.get(0).toString();
        }
        if (this.currentEncryptedChat != null && messagesController.secretWebpagePreview == 2) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$searchLinks$126(messagesController, charSequence, z);
                }
            });
            return;
        }
        final TLRPC.TL_messages_getWebPagePreview tL_messages_getWebPagePreview = new TLRPC.TL_messages_getWebPagePreview();
        if (charSequence2 instanceof String) {
            tL_messages_getWebPagePreview.message = (String) charSequence2;
        } else {
            tL_messages_getWebPagePreview.message = charSequence2.toString();
        }
        TLRPC.WebPage webPage = this.foundWebPage;
        if (webPage == null || !tL_messages_getWebPagePreview.message.equals(webPage.displayedText)) {
            final int i2 = this.waitingForWebpageId + 1;
            this.waitingForWebpageId = i2;
            requestLinkPreviewCached(tL_messages_getWebPagePreview, new Utilities.Callback2() {
                public final void run(Object obj, Object obj2) {
                    ChatActivity.this.lambda$searchLinks$128(i2, tL_messages_getWebPagePreview, (Boolean) obj, (TLRPC.WebPage) obj2);
                }
            });
        }
    }

    public void lambda$searchLinks$123() {
        this.foundWebPage = null;
        fallbackFieldPanel();
    }

    public void lambda$searchLinks$124() {
        this.foundWebPage = null;
        fallbackFieldPanel();
    }

    public void lambda$searchLinks$126(final MessagesController messagesController, final CharSequence charSequence, final boolean z) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity(), this.themeDelegate);
        builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
        builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                ChatActivity.this.lambda$searchLinks$125(messagesController, charSequence, z, dialogInterface, i);
            }
        });
        builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
        builder.setMessage(LocaleController.getString("SecretLinkPreviewAlert", R.string.SecretLinkPreviewAlert));
        showDialog(builder.create());
        messagesController.secretWebpagePreview = 0;
        MessagesController.getGlobalMainSettings().edit().putInt("secretWebpage2", messagesController.secretWebpagePreview).commit();
    }

    public void lambda$searchLinks$125(MessagesController messagesController, CharSequence charSequence, boolean z, DialogInterface dialogInterface, int i) {
        messagesController.secretWebpagePreview = 1;
        MessagesController.getGlobalMainSettings().edit().putInt("secretWebpage2", getMessagesController().secretWebpagePreview).commit();
        this.foundUrls = null;
        searchLinks(charSequence, z);
    }

    public void lambda$searchLinks$128(final int i, final TLRPC.TL_messages_getWebPagePreview tL_messages_getWebPagePreview, final Boolean bool, final TLRPC.WebPage webPage) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$searchLinks$127(i, bool, webPage, tL_messages_getWebPagePreview);
            }
        });
    }

    public void lambda$searchLinks$127(int i, Boolean bool, TLRPC.WebPage webPage, TLRPC.TL_messages_getWebPagePreview tL_messages_getWebPagePreview) {
        if (this.waitingForWebpageId != i) {
            return;
        }
        if (bool.booleanValue()) {
            this.foundWebPage = webPage;
            String str = tL_messages_getWebPagePreview.message;
            webPage.display_url = str;
            if (!(webPage instanceof TLRPC.TL_webPage) && !(webPage instanceof TLRPC.TL_webPagePending)) {
                if (webPage != null) {
                    this.foundWebPage = null;
                    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);
                    }
                    fallbackFieldPanel();
                    return;
                }
                return;
            }
            if (webPage instanceof TLRPC.TL_webPagePending) {
                this.pendingLinkSearchString = str;
            }
            if (this.currentEncryptedChat != null && (webPage instanceof TLRPC.TL_webPagePending)) {
                webPage.url = str;
            }
            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);
            }
            showFieldPanelForWebPage(true, this.foundWebPage, false);
            return;
        }
        this.foundWebPage = null;
        fallbackFieldPanel();
    }

    public final void requestLinkPreviewCached(final TLRPC.TL_messages_getWebPagePreview req, final Utilities.Callback2<Boolean, TLRPC.WebPage> done) {
        if (this.lastLinkPreviewResults == null) {
            this.lastLinkPreviewResults = new HashMap<>();
        }
        TLRPC.WebPage webPage = this.lastLinkPreviewResults.get(req.message);
        if (webPage != null) {
            done.run(Boolean.TRUE, webPage);
        } else {
            requestLinkPreview(req, new Utilities.Callback2() {
                public final void run(Object obj, Object obj2) {
                    ChatActivity.this.lambda$requestLinkPreviewCached$130(req, done, (Boolean) obj, (TLRPC.WebPage) obj2);
                }
            });
        }
    }

    public void lambda$requestLinkPreviewCached$130(TLRPC.TL_messages_getWebPagePreview tL_messages_getWebPagePreview, Utilities.Callback2 callback2, Boolean bool, TLRPC.WebPage webPage) {
        if (bool.booleanValue() && !(webPage instanceof TLRPC.TL_webPagePending)) {
            Iterator<String> it = this.lastLinkPreviewResults.keySet().iterator();
            while (it.hasNext() && this.lastLinkPreviewResults.size() > 5) {
                it.next();
                it.remove();
            }
            this.lastLinkPreviewResults.put(tL_messages_getWebPagePreview.message, webPage);
        }
        callback2.run(bool, webPage);
    }

    public final void requestLinkPreview(TLRPC.TL_messages_getWebPagePreview req, final Utilities.Callback2<Boolean, TLRPC.WebPage> done) {
        cancelSearchLinks();
        this.linkSearchRequestId = getConnectionsManager().sendRequest(req, new RequestDelegate() {
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                ChatActivity.this.lambda$requestLinkPreview$136(done, tLObject, tL_error);
            }
        });
        getConnectionsManager().bindRequestToGuid(this.linkSearchRequestId, ((BaseFragment) this).classGuid);
    }

    public void lambda$requestLinkPreview$136(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$135(tLObject, callback2);
            }
        });
    }

    public void lambda$requestLinkPreview$135(TLObject tLObject, final Utilities.Callback2 callback2) {
        final TLRPC.TL_webPageAttributeStory tL_webPageAttributeStory;
        this.linkSearchRequestId = 0;
        if (tLObject instanceof TLRPC.TL_messageMediaWebPage) {
            final TLRPC.TL_messageMediaWebPage tL_messageMediaWebPage = (TLRPC.TL_messageMediaWebPage) tLObject;
            TLRPC.WebPage webPage = ((TLRPC.MessageMedia) tL_messageMediaWebPage).webpage;
            if (webPage == null || !"telegram_story".equals(webPage.type)) {
                callback2.run(Boolean.valueOf(((TLRPC.MessageMedia) tL_messageMediaWebPage).webpage != null), ((TLRPC.MessageMedia) tL_messageMediaWebPage).webpage);
                return;
            }
            if (((TLRPC.MessageMedia) tL_messageMediaWebPage).webpage.attributes != null) {
                for (int i = 0; i < ((TLRPC.MessageMedia) tL_messageMediaWebPage).webpage.attributes.size(); i++) {
                    if (((TLRPC.MessageMedia) tL_messageMediaWebPage).webpage.attributes.get(i) instanceof TLRPC.TL_webPageAttributeStory) {
                        tL_webPageAttributeStory = (TLRPC.TL_webPageAttributeStory) ((TLRPC.MessageMedia) tL_messageMediaWebPage).webpage.attributes.get(i);
                        break;
                    }
                }
            }
            tL_webPageAttributeStory = null;
            if (tL_webPageAttributeStory == null) {
                callback2.run(Boolean.FALSE, (Object) null);
                return;
            } else if (tL_webPageAttributeStory.storyItem != null) {
                callback2.run(Boolean.TRUE, ((TLRPC.MessageMedia) tL_messageMediaWebPage).webpage);
                return;
            } else {
                getMessagesStorage().getStorageQueue().postRunnable(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.this.lambda$requestLinkPreview$134(tL_messageMediaWebPage, tL_webPageAttributeStory, callback2);
                    }
                });
                return;
            }
        }
        callback2.run(Boolean.FALSE, (Object) null);
    }

    public void lambda$requestLinkPreview$134(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$133(longSparseArray, callback2);
                }
            }, ((BaseFragment) this).classGuid, false);
        } catch (Exception unused) {
        }
    }

    public static void lambda$requestLinkPreview$133(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$131(callback2, webPage2);
                        }
                    });
                    return;
                }
            }
        }
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.lambda$requestLinkPreview$132(callback2);
            }
        });
    }

    public static void lambda$requestLinkPreview$131(Utilities.Callback2 callback2, TLRPC.WebPage webPage) {
        callback2.run(Boolean.TRUE, webPage);
    }

    public static void lambda$requestLinkPreview$132(Utilities.Callback2 callback2) {
        callback2.run(Boolean.FALSE, (Object) null);
    }

    public final void forwardMessages(ArrayList<MessageObject> arrayList, boolean fromMyName, boolean hideCaption, boolean notify, int scheduleDate) {
        forwardMessages(arrayList, fromMyName, hideCaption, notify, scheduleDate, 0L);
    }

    public final void forwardMessages(ArrayList<MessageObject> arrayList, boolean fromMyName, boolean hideCaption, boolean notify, int scheduleDate, long did) {
        if (arrayList == null || arrayList.isEmpty() || !checkSlowModeAlert()) {
            return;
        }
        if ((scheduleDate != 0) == (this.chatMode == 1)) {
            this.waitingForSendingMessageLoad = true;
        }
        int sendMessage = getSendMessagesHelper().sendMessage(arrayList, this.dialog_id, this.quote ? false : fromMyName, (!QuoteForward && PlusSettings.deleteSharedMediaCaption && this.captionSwitch.getVisibility() == 0) ? true : hideCaption, notify, scheduleDate, getThreadMessage());
        AlertsCreator.showSendMediaAlert(sendMessage, this, this.themeDelegate);
        if (sendMessage != 0) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$forwardMessages$137();
                }
            });
        }
    }

    public void lambda$forwardMessages$137() {
        this.waitingForSendingMessageLoad = false;
        hideFieldPanel(true);
    }

    public boolean shouldShowImport() {
        return this.openImport;
    }

    public void setOpenImport() {
        this.openImport = true;
    }

    public final 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) {
            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 messageObject2 = this.botButtons;
                    this.botReplyButtons = messageObject2;
                    this.chatActivityEnterView.setButtons(messageObject2);
                    showFieldPanelForReply(this.botButtons);
                    return;
                }
                return;
            }
            return;
        }
        MessageObject messageObject3 = this.replyingMessageObject;
        if (messageObject3 != null && this.botReplyButtons == messageObject3) {
            this.botReplyButtons = null;
            hideFieldPanel(true);
        }
        this.chatActivityEnterView.setButtons(this.botButtons);
    }

    public static class ReplyQuote {
        public int end;
        public ArrayList<TLRPC.MessageEntity> entities;
        public MessageObject message;
        public boolean outdated;
        public int start;
        public String text;

        public ReplyQuote(long peerId, MessageObject message, int start, int end) {
            this.message = message;
            this.start = start;
            this.end = end;
            update();
        }

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

        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 start, int end) {
            if (messageObject == null) {
                return null;
            }
            return new ReplyQuote(messageObject.getDialogId(), messageObject, start, end);
        }

        public final boolean update() {
            TLRPC.Message message;
            String str;
            int i;
            TLRPC.TL_messageEntityBold tL_messageEntityCustomEmoji;
            MessageObject messageObject = this.message;
            if (messageObject == null || (message = messageObject.messageOwner) == null || (str = message.message) == null) {
                FileLog.e("ReplyQuote: message is null");
                return false;
            }
            int i2 = this.end;
            if (i2 < this.start || i2 > str.length() || this.start > this.message.messageOwner.message.length() || (i = this.start) < 0 || this.end < 0) {
                FileLog.e("ReplyQuote: start/end are invalid (" + this.start + ", " + this.end + ", len=" + this.message.messageOwner.message.length() + ")");
                return false;
            }
            String str2 = this.message.messageOwner.message;
            int max = Math.max(0, i);
            while (max < this.end && Character.isWhitespace(str2.charAt(max))) {
                max++;
            }
            int min = Math.min(this.end, str2.length());
            while (min > max && Character.isWhitespace(str2.charAt(min - 1))) {
                min--;
            }
            if (max == min) {
                FileLog.e("ReplyQuote: message is full of whitespace");
                return false;
            }
            this.text = this.message.messageOwner.message.substring(max, min);
            ArrayList<TLRPC.MessageEntity> arrayList = this.entities;
            if (arrayList != null) {
                arrayList.clear();
            }
            ArrayList arrayList2 = this.message.messageOwner.entities;
            if (arrayList2 == null || arrayList2.isEmpty()) {
                return true;
            }
            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);
                    }
                }
            }
            return true;
        }

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

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

        public ArrayList<TLRPC.MessageEntity> getEntities() {
            return this.entities;
        }
    }

    public void hideFieldPanel(boolean animated) {
        showFieldPanel(false, null, null, null, null, true, 0, null, false, animated);
    }

    public void hideFieldPanel(boolean notify, int scheduleDate, boolean animated) {
        showFieldPanel(false, null, null, null, null, notify, scheduleDate, null, false, animated);
    }

    public void showFieldPanelForWebPage(boolean show, TLRPC.WebPage webPage, boolean cancel) {
        boolean z;
        boolean z2;
        if (PlusSettings.disableLinkPreview) {
            z = false;
            z2 = true;
        } else {
            z = show;
            z2 = cancel;
        }
        showFieldPanel(z, null, null, null, webPage, true, 0, null, z2, true);
    }

    public void showFieldPanelForForward(boolean show, ArrayList<MessageObject> messageObjectsToForward) {
        showFieldPanel(show, null, null, messageObjectsToForward, null, true, 0, null, false, true);
    }

    public void showFieldPanelForReply(MessageObject messageObjectToReply) {
        TLRPC.Chat chat;
        ChatMessageCell chatMessageCell = this.slidingView;
        if (chatMessageCell != null && messageObjectToReply == chatMessageCell.getMessageObject() && !this.forceReply) {
            int i = (PlusSettings.swipeLeftActionOut == PlusSettings.swipeLeftAction || !messageObjectToReply.isOutOwner()) ? PlusSettings.swipeLeftAction : PlusSettings.swipeLeftActionOut;
            if (this.trackingX > 0) {
                int i2 = (PlusSettings.swipeRightActionOut == PlusSettings.swipeRightAction || !messageObjectToReply.isOutOwner()) ? PlusSettings.swipeRightAction : PlusSettings.swipeRightActionOut;
                i = i2 > 0 ? i2 - 1 : 0;
            }
            if (i != 0) {
                this.selectedObject = messageObjectToReply;
                this.selectedObjectGroup = this.slidingView.getCurrentMessagesGroup();
                if (i > 1) {
                    i++;
                }
                checkPlusAction(i);
                return;
            }
            if (ChatObject.isChannel(this.currentChat) && !ChatObject.canPost(this.currentChat) && (chat = this.currentChat) != null && !chat.megagroup && PlusSettings.enableSwipeInChannels) {
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.lambda$showFieldPanelForReply$138();
                    }
                });
                return;
            }
        }
        showFieldPanel(true, messageObjectToReply, null, null, null, true, 0, null, false, true);
    }

    public static void lambda$showFieldPanelForReply$138() {
        PlusUtils.showToast(LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred));
    }

    public void showFieldPanelForReplyQuote(MessageObject messageObjectToReply, ReplyQuote quote) {
        showFieldPanel(true, messageObjectToReply, null, null, null, true, 0, quote, false, true);
    }

    public void showFieldPanelForEdit(boolean show, MessageObject messageObjectToEdit) {
        showFieldPanel(show, null, messageObjectToEdit, null, null, true, 0, null, false, true);
    }

    public void showFieldPanel(boolean r33, org.telegram.messenger.MessageObject r34, org.telegram.messenger.MessageObject r35, java.util.ArrayList<org.telegram.messenger.MessageObject> r36, org.telegram.tgnet.TLRPC.WebPage r37, boolean r38, int r39, org.telegram.ui.ChatActivity.ReplyQuote r40, boolean r41, boolean r42) {
        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, boolean):void");
    }

    public void lambda$showFieldPanel$139() {
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView != null) {
            chatActivityEnterView.openKeyboard();
        }
    }

    public void lambda$showFieldPanel$140() {
        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();
            this.replyObjectHintTextView.animate().alpha(1.0f).scaleX(1.0f).scaleY(1.0f).setDuration(150L).start();
        } else {
            this.replyObjectTextView.animate().alpha(1.0f).scaleX(1.0f).scaleY(1.0f).setDuration(150L).start();
            this.replyObjectHintTextView.animate().alpha(0.0f).scaleX(0.98f).scaleY(0.98f).setDuration(150L).start();
        }
        AndroidUtilities.runOnUIThread(this.tapForForwardingOptionsHitRunnable, 6000L);
    }

    public final void moveScrollToLastMessage(boolean skipSponsored) {
        if (this.chatListView == null || this.messages.isEmpty() || this.pinchToZoomHelper.isInOverlayMode()) {
            return;
        }
        this.chatLayoutManager.scrollToPositionWithOffset(skipSponsored ? getSponsoredMessagesCount() + 0 : 0, 0);
        this.chatListView.stopScroll();
    }

    public final Runnable sendSecretMessageRead(final MessageObject messageObject, boolean readNow) {
        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 (readNow) {
            boolean z = 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, z);
            }
            return null;
        }
        return new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$sendSecretMessageRead$141(messageObject);
            }
        };
    }

    public void lambda$sendSecretMessageRead$141(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 final 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<MessageObject> arrayList = new ArrayList<>();
            arrayList.add(messageObject);
            updateMessages(arrayList, true);
        }
        return new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$sendSecretMediaDelete$142(createDeleteShowOnceTask, messageObject);
            }
        };
    }

    public void lambda$sendSecretMediaDelete$142(long j, MessageObject messageObject) {
        getMessagesController().doDeleteShowOnceTask(j, this.dialog_id, messageObject.getId());
    }

    public final void clearChatData(boolean full) {
        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 (full) {
            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);
    }

    public void scrollToLastMessage(boolean skipSponsored, boolean top) {
        scrollToLastMessage(skipSponsored, top, null);
    }

    public void scrollToLastMessage(boolean skipSponsored, final boolean top, Runnable inCaseLoading) {
        ArrayList<MessageObject> 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) {
            setPagedownLoading(false, true);
            if (this.chatLayoutManager.findFirstCompletelyVisibleItemPosition() == 0) {
                this.canShowPagedownButton = false;
                updatePagedownButtonVisibility(true);
                removeSelectedMessageHighlight();
                updateVisibleRows();
                return;
            }
            this.chatAdapter.updateRowsSafe();
            this.chatScrollHelperCallback.scrollTo = null;
            if (skipSponsored) {
                while (i2 < this.messages.size() && this.messages.get(i2).isSponsored()) {
                    i2++;
                }
            }
            if (top && (arrayList = this.messages) != null && arrayList.size() > 0 && this.messages.get(i2) != null) {
                long groupId = this.messages.get(i2).getGroupId();
                while (groupId != 0 && (i = i2 + 1) < this.messages.size() && groupId == this.messages.get(i).getGroupId()) {
                    i2 = i;
                }
            }
            ArrayList<MessageObject> arrayList2 = this.messages;
            if (arrayList2 != null && arrayList2.size() > 0) {
                i2 = Math.min(i2, this.messages.size() - 1);
            }
            new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$scrollToLastMessage$143(i2, top);
                }
            }.run();
            return;
        }
        AlertDialog alertDialog = this.progressDialog;
        if (alertDialog != null) {
            alertDialog.dismiss();
        }
        updatePinnedListButton(false);
        if (inCaseLoading != null) {
            inCaseLoading.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$145();
            }
        }, 0L);
    }

    public void lambda$scrollToLastMessage$143(int i, boolean z) {
        RecyclerAnimationScrollHelper recyclerAnimationScrollHelper = this.chatScrollHelper;
        this.chatScrollHelperCallback.position = i;
        this.chatScrollHelperCallback.offset = 0;
        boolean z2 = !z;
        this.chatScrollHelperCallback.bottom = z2;
        recyclerAnimationScrollHelper.scrollToPosition(i, 0, z2, true);
    }

    public void lambda$scrollToLastMessage$145() {
        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 updateTextureViewPosition(boolean needVisibleUpdate, boolean needScroll) {
        boolean z;
        MessageObject playingMessageObject;
        if (((BaseFragment) this).fragmentView == null || this.paused) {
            return;
        }
        int childCount = this.chatListView.getChildCount();
        int i = 0;
        while (true) {
            if (i >= childCount) {
                z = 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() + 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);
                        int i2 = layoutParams.width;
                        int i3 = AndroidUtilities.roundPlayingMessageSize;
                        if (i2 != i3 || layoutParams.height != i3) {
                            layoutParams.height = i3;
                            layoutParams.width = i3;
                            this.aspectRatioFrameLayout.setResizeMode(0);
                            this.videoPlayerContainer.setLayoutParams(layoutParams);
                        }
                        float f = (AndroidUtilities.roundPlayingMessageSize + (AndroidUtilities.roundMessageInset * 2)) / AndroidUtilities.roundPlayingMessageSize;
                        float imageWidth = chatMessageCell.getPhotoImage().getImageWidth() / AndroidUtilities.roundPlayingMessageSize;
                        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(f);
                        this.videoTextureView.setScaleY(f);
                    } 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();
                    z = true;
                }
            }
            i++;
        }
        if (!needVisibleUpdate || this.videoPlayerContainer == null || (playingMessageObject = MediaController.getInstance().getPlayingMessageObject()) == null || playingMessageObject.eventId != 0) {
            return;
        }
        if (!z) {
            if (this.checkTextureViewPosition && playingMessageObject.isVideo()) {
                MediaController.getInstance().cleanupPlayer(true, true);
                return;
            }
            this.videoPlayerContainer.setTranslationY((-AndroidUtilities.roundPlayingMessageSize) - 100);
            ((BaseFragment) this).fragmentView.invalidate();
            if (playingMessageObject.isRoundVideo() || playingMessageObject.isVideo()) {
                if (this.checkTextureViewPosition || PipRoundVideoView.getInstance() != null) {
                    MediaController.getInstance().setCurrentVideoVisible(false);
                    return;
                } else {
                    if (needScroll) {
                        scrollToMessageId(playingMessageObject.getId(), 0, false, 0, true, 0);
                        return;
                    }
                    return;
                }
            }
            return;
        }
        MediaController.getInstance().setCurrentVideoVisible(true);
        if (playingMessageObject.isRoundVideo() || this.scrollToVideo) {
            return;
        }
        this.chatListView.invalidate();
    }

    public void invalidateMessagesVisiblePart() {
        this.invalidateMessagesVisiblePart = true;
        View view = ((BaseFragment) this).fragmentView;
        if (view != null) {
            view.invalidate();
        }
    }

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

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

    public void lambda$updateMessagesVisiblePart$146(MessageObject messageObject) {
        if (messageObject.isVideo()) {
            openPhotoViewerForMessage(null, messageObject);
        } else {
            MediaController.getInstance().playMessage(messageObject);
        }
    }

    public void lambda$updateMessagesVisiblePart$147() {
        updatePinnedMessageView(this.openAnimationStartTime != 0 && SystemClock.elapsedRealtime() >= this.openAnimationStartTime + 150);
    }

    public void lambda$updateMessagesVisiblePart$149(boolean z) {
        lambda$updateMessagesVisiblePart$148(z, 0);
    }

    public final 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 int getServiceHeight(View view) {
        return this.contentView.getBackgroundSizeY();
    }

    public final boolean pinnedOnlyStarterMessage() {
        return this.pinnedMessageIds.size() == 1 && this.topicStarterMessageObject != null && this.pinnedMessageIds.get(0).intValue() == this.topicStarterMessageObject.getId();
    }

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

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

    public final void toggleMute(boolean instant) {
        if (getMessagesController().isDialogMuted(this.dialog_id, getTopicId())) {
            getNotificationsController().muteDialog(this.dialog_id, getTopicId(), false);
            if (instant) {
                return;
            }
            BulletinFactory.createMuteBulletin(this, false, this.themeDelegate).show();
            return;
        }
        if (instant) {
            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 final int getScrollOffsetForMessage(MessageObject object) {
        return getScrollOffsetForMessage(getHeightForMessage(object, !TextUtils.isEmpty(this.highlightMessageQuote))) - scrollOffsetForQuote(object);
    }

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

    public final int scrollOffsetForQuote(MessageObject object) {
        ArrayList arrayList;
        CharSequence charSequence;
        int i;
        ChatMessageCell chatMessageCell;
        MessageObject.TextLayoutBlocks textLayoutBlocks;
        int findQuoteStart;
        float lineTop;
        MessageObject.TextLayoutBlocks textLayoutBlocks2;
        MessageObject messageObject;
        if (TextUtils.isEmpty(this.highlightMessageQuote) || object == null) {
            ChatMessageCell chatMessageCell2 = this.dummyMessageCell;
            if (chatMessageCell2 != null) {
                chatMessageCell2.computedGroupCaptionY = 0;
                chatMessageCell2.computedCaptionLayout = null;
            }
            return 0;
        }
        if (object.getGroupId() != 0) {
            MessageObject.GroupedMessages group = getGroup(object.getGroupId());
            ChatMessageCell chatMessageCell3 = this.dummyMessageCell;
            if (chatMessageCell3 == null || (textLayoutBlocks2 = chatMessageCell3.computedCaptionLayout) == null || group == null || (messageObject = group.captionMessage) == null) {
                if (chatMessageCell3 != null) {
                    chatMessageCell3.computedGroupCaptionY = 0;
                    chatMessageCell3.computedCaptionLayout = null;
                }
                return 0;
            }
            i = chatMessageCell3.computedGroupCaptionY;
            charSequence = messageObject.caption;
            arrayList = textLayoutBlocks2.textLayoutBlocks;
        } else if (!TextUtils.isEmpty(object.caption) && (chatMessageCell = this.dummyMessageCell) != null && (textLayoutBlocks = chatMessageCell.captionLayout) != null) {
            i = (int) chatMessageCell.captionY;
            charSequence = object.caption;
            arrayList = textLayoutBlocks.textLayoutBlocks;
        } else {
            CharSequence charSequence2 = object.messageText;
            arrayList = object.textLayoutBlocks;
            ChatMessageCell chatMessageCell4 = this.dummyMessageCell;
            if (chatMessageCell4 == null || !chatMessageCell4.linkPreviewAbove) {
                charSequence = charSequence2;
                i = 0;
            } else {
                i = chatMessageCell4.linkPreviewHeight + AndroidUtilities.dp(10.0f) + 0;
                charSequence = charSequence2;
            }
        }
        ChatMessageCell chatMessageCell5 = this.dummyMessageCell;
        if (chatMessageCell5 != null) {
            chatMessageCell5.computedGroupCaptionY = 0;
            chatMessageCell5.computedCaptionLayout = null;
        }
        if (arrayList == null || charSequence == null || (findQuoteStart = MessageObject.findQuoteStart(charSequence.toString(), this.highlightMessageQuote, this.highlightMessageQuoteOffset)) < 0) {
            return 0;
        }
        for (int i2 = 0; i2 < arrayList.size(); i2++) {
            MessageObject.TextLayoutBlock textLayoutBlock = (MessageObject.TextLayoutBlock) arrayList.get(i2);
            String charSequence3 = textLayoutBlock.textLayout.getText().toString();
            int i3 = textLayoutBlock.charactersOffset;
            if (findQuoteStart > i3) {
                if (findQuoteStart - i3 > charSequence3.length() - 1) {
                    lineTop = i + ((int) (textLayoutBlock.textYOffset(arrayList) + textLayoutBlock.padTop + textLayoutBlock.height));
                } else {
                    lineTop = r5.getLineTop(r5.getLineForOffset(findQuoteStart - textLayoutBlock.charactersOffset)) + i + textLayoutBlock.textYOffset(arrayList) + textLayoutBlock.padTop;
                }
                if (lineTop > AndroidUtilities.displaySize.y * (isKeyboardVisible() ? 0.7f : 0.5f)) {
                    return (int) (lineTop - (AndroidUtilities.displaySize.y * (isKeyboardVisible() ? 0.7f : 0.5f)));
                }
                return 0;
            }
        }
        return 0;
    }

    public final int getHeightForMessage(MessageObject object, boolean withGroupCaption) {
        boolean z = 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) {
            z = true;
        }
        chatMessageCell.isMegagroup = z;
        return this.dummyMessageCell.computeHeight(object, (MessageObject.GroupedMessages) this.groupedMessagesMap.get(object.getGroupId()), withGroupCaption);
    }

    public final 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$150();
            }
        };
        this.unselectRunnable = runnable2;
        AndroidUtilities.runOnUIThread(runnable2, this.highlightMessageQuote != null ? 2500L : 1000L);
    }

    public void lambda$startMessageUnselect$150() {
        this.highlightMessageId = Integer.MAX_VALUE;
        this.highlightMessageQuoteFirst = false;
        this.highlightMessageQuote = null;
        this.highlightMessageQuoteOffset = -1;
        this.showNoQuoteAlert = false;
        updateVisibleRows();
        this.unselectRunnable = null;
    }

    public final void removeSelectedMessageHighlight() {
        if (this.highlightMessageQuote != null) {
            return;
        }
        Runnable runnable = this.unselectRunnable;
        if (runnable != null) {
            AndroidUtilities.cancelRunOnUIThread(runnable);
            this.unselectRunnable = null;
        }
        this.highlightMessageId = Integer.MAX_VALUE;
        this.highlightMessageQuoteFirst = false;
        this.highlightMessageQuote = null;
    }

    public final void resetProgressDialogLoading() {
        this.progressDialogLinkSpan = null;
        this.progressDialogAtMessageId = 0;
        this.progressDialogAtMessageType = -1;
        this.progressDialogBotButtonUrl = null;
        this.progressDialogCurrent = null;
        setPagedownLoading(false, true);
    }

    public void scrollToMessageId(int id, int fromMessageId, boolean select, int loadIndex, boolean forceScroll, int forcePinnedMessageId) {
        scrollToMessageId(id, fromMessageId, select, loadIndex, forceScroll, forcePinnedMessageId, 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 lambda$scrollToMessageId$151() {
        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$152(DialogInterface dialogInterface) {
        showPinnedProgress(false);
    }

    public final void showPinnedProgress(boolean show) {
        if (show) {
            if (this.updatePinnedProgressRunnable == null) {
                Runnable runnable = new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.this.lambda$showPinnedProgress$153();
                    }
                };
                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 lambda$showPinnedProgress$153() {
        this.pinnedProgressIsShowing = true;
        updatePinnedListButton(true);
    }

    public final void updatePagedownButtonVisibility(boolean animated) {
        if (this.pagedownButton == null) {
            return;
        }
        if ((!this.canShowPagedownButton || this.textSelectionHelper.isInSelectionMode() || this.chatActivityEnterView.isRecordingAudioVideo() || this.isInsideContainer || (this.searching && !getMediaDataController().searchResultMessages.isEmpty())) ? false : true) {
            if (animated && (this.openAnimationStartTime == 0 || SystemClock.elapsedRealtime() < this.openAnimationStartTime + 150)) {
                animated = false;
            }
            this.pagedownButtonShowedByScroll = false;
            if (this.pagedownButton.getTag() == null) {
                ValueAnimator valueAnimator = this.pagedownButtonAnimation;
                if (valueAnimator != null) {
                    valueAnimator.removeAllListeners();
                    this.pagedownButtonAnimation.cancel();
                    this.pagedownButtonAnimation = null;
                }
                this.pagedownButton.setTag(1);
                if (animated) {
                    this.pagedownButton.setVisibility(0);
                    ValueAnimator ofFloat = ValueAnimator.ofFloat(this.pagedownButtonEnterProgress, 1.0f);
                    this.pagedownButtonAnimation = ofFloat;
                    ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                        @Override
                        public final void onAnimationUpdate(ValueAnimator valueAnimator2) {
                            ChatActivity.this.lambda$updatePagedownButtonVisibility$154(valueAnimator2);
                        }
                    });
                    this.pagedownButtonAnimation.addListener(new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationEnd(Animator animation) {
                            ChatActivity.this.pagedownButtonEnterProgress = 1.0f;
                            ChatActivity.this.contentView.invalidate();
                        }
                    });
                    this.pagedownButtonAnimation.setDuration(200L);
                    this.pagedownButtonAnimation.start();
                    return;
                }
                this.pagedownButtonEnterProgress = 1.0f;
                this.contentView.invalidate();
                this.pagedownButton.setVisibility(0);
                return;
            }
            return;
        }
        this.returnToMessageId = 0;
        this.returnToMessageIdStack.clear();
        this.newUnreadMessageCount = 0;
        if (this.pagedownButton.getTag() != null) {
            this.pagedownButton.setTag(null);
            ValueAnimator valueAnimator2 = this.pagedownButtonAnimation;
            if (valueAnimator2 != null) {
                valueAnimator2.removeAllListeners();
                this.pagedownButtonAnimation.cancel();
                this.pagedownButtonAnimation = null;
            }
            if (animated) {
                this.pagedownButton.setVisibility(0);
                ValueAnimator ofFloat2 = ValueAnimator.ofFloat(this.pagedownButtonEnterProgress, 0.0f);
                this.pagedownButtonAnimation = ofFloat2;
                ofFloat2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                    @Override
                    public final void onAnimationUpdate(ValueAnimator valueAnimator3) {
                        ChatActivity.this.lambda$updatePagedownButtonVisibility$155(valueAnimator3);
                    }
                });
                this.pagedownButtonAnimation.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        ChatActivity.this.pagedownButtonEnterProgress = 0.0f;
                        ChatActivity.this.pagedownButton.setVisibility(4);
                        ChatActivity.this.contentView.invalidate();
                    }
                });
                this.pagedownButtonAnimation.setDuration(200L);
                this.pagedownButtonAnimation.start();
                return;
            }
            this.pagedownButtonEnterProgress = 0.0f;
            this.pagedownButton.setVisibility(4);
        }
    }

    public void lambda$updatePagedownButtonVisibility$154(ValueAnimator valueAnimator) {
        this.pagedownButtonEnterProgress = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        this.contentView.invalidate();
    }

    public void lambda$updatePagedownButtonVisibility$155(ValueAnimator valueAnimator) {
        this.pagedownButtonEnterProgress = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        this.contentView.invalidate();
    }

    public final void updateSearchUpDownButtonVisibility(boolean animated) {
        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())) {
            if (this.searchUpButton.getTag() == null) {
                ValueAnimator valueAnimator = this.searchUpButtonAnimation;
                if (valueAnimator != null) {
                    valueAnimator.removeAllListeners();
                    this.searchUpButtonAnimation.cancel();
                    this.searchUpButtonAnimation = null;
                }
                if (animated) {
                    this.searchUpButton.setVisibility(0);
                    this.searchDownButton.setVisibility(0);
                    this.searchUpButton.setTag(1);
                    ValueAnimator ofFloat = ValueAnimator.ofFloat(this.searchUpDownEnterProgress, 1.0f);
                    this.searchUpButtonAnimation = ofFloat;
                    ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                        @Override
                        public final void onAnimationUpdate(ValueAnimator valueAnimator2) {
                            ChatActivity.this.lambda$updateSearchUpDownButtonVisibility$156(valueAnimator2);
                        }
                    });
                    this.searchUpButtonAnimation.addListener(new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationEnd(Animator animation) {
                            ChatActivity.this.searchUpDownEnterProgress = 1.0f;
                            ChatActivity.this.contentView.invalidate();
                        }
                    });
                    this.searchUpButtonAnimation.setDuration(200L);
                    this.searchUpButtonAnimation.start();
                    return;
                }
                this.searchUpDownEnterProgress = 1.0f;
                this.contentView.invalidate();
                return;
            }
            return;
        }
        this.returnToMessageId = 0;
        if (this.searchUpButton.getTag() != null) {
            this.searchUpButton.setTag(null);
            ValueAnimator valueAnimator2 = this.searchUpButtonAnimation;
            if (valueAnimator2 != null) {
                valueAnimator2.removeAllListeners();
                this.searchUpButtonAnimation.cancel();
                this.searchUpButtonAnimation = null;
            }
            if (animated) {
                ValueAnimator ofFloat2 = ValueAnimator.ofFloat(this.searchUpDownEnterProgress, 0.0f);
                this.searchUpButtonAnimation = ofFloat2;
                ofFloat2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                    @Override
                    public final void onAnimationUpdate(ValueAnimator valueAnimator3) {
                        ChatActivity.this.lambda$updateSearchUpDownButtonVisibility$157(valueAnimator3);
                    }
                });
                this.searchUpButtonAnimation.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        ChatActivity.this.searchUpDownEnterProgress = 0.0f;
                        ChatActivity.this.searchUpButton.setVisibility(4);
                        ChatActivity.this.searchDownButton.setVisibility(4);
                        ChatActivity.this.contentView.invalidate();
                    }
                });
                this.searchUpButtonAnimation.setDuration(200L);
                this.searchUpButtonAnimation.start();
                return;
            }
            this.searchUpDownEnterProgress = 0.0f;
            this.searchUpButton.setVisibility(4);
            this.searchDownButton.setVisibility(4);
        }
    }

    public void lambda$updateSearchUpDownButtonVisibility$156(ValueAnimator valueAnimator) {
        this.searchUpDownEnterProgress = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        this.contentView.invalidate();
    }

    public void lambda$updateSearchUpDownButtonVisibility$157(ValueAnimator valueAnimator) {
        this.searchUpDownEnterProgress = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        this.contentView.invalidate();
    }

    public final void showMentionDownButton(boolean show, boolean animated) {
        FrameLayout frameLayout = this.mentiondownButton;
        if (frameLayout == null) {
            return;
        }
        if (show) {
            if (frameLayout.getTag() == null) {
                ValueAnimator valueAnimator = this.mentiondownButtonAnimation;
                if (valueAnimator != null) {
                    valueAnimator.removeAllListeners();
                    this.mentiondownButtonAnimation.cancel();
                    this.mentiondownButtonAnimation = null;
                }
                if (animated) {
                    this.mentiondownButton.setVisibility(0);
                    this.mentiondownButton.setTag(1);
                    ValueAnimator ofFloat = ValueAnimator.ofFloat(this.mentionsButtonEnterProgress, 1.0f);
                    this.mentiondownButtonAnimation = ofFloat;
                    ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                        @Override
                        public final void onAnimationUpdate(ValueAnimator valueAnimator2) {
                            ChatActivity.this.lambda$showMentionDownButton$158(valueAnimator2);
                        }
                    });
                    this.mentiondownButtonAnimation.addListener(new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationEnd(Animator animation) {
                            ChatActivity.this.mentionsButtonEnterProgress = 1.0f;
                            ChatActivity.this.contentView.invalidate();
                        }
                    });
                    this.mentiondownButtonAnimation.setDuration(200L);
                    this.mentiondownButtonAnimation.start();
                    return;
                }
                this.mentionsButtonEnterProgress = 1.0f;
                this.contentView.invalidate();
                return;
            }
            return;
        }
        this.returnToMessageId = 0;
        this.returnToMessageIdStack.clear();
        if (this.mentiondownButton.getTag() != null) {
            this.mentiondownButton.setTag(null);
            ValueAnimator valueAnimator2 = this.mentiondownButtonAnimation;
            if (valueAnimator2 != null) {
                valueAnimator2.removeAllListeners();
                this.mentiondownButtonAnimation.cancel();
                this.mentiondownButtonAnimation = null;
            }
            if (animated) {
                ValueAnimator ofFloat2 = ValueAnimator.ofFloat(this.mentionsButtonEnterProgress, 0.0f);
                this.mentiondownButtonAnimation = ofFloat2;
                ofFloat2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                    @Override
                    public final void onAnimationUpdate(ValueAnimator valueAnimator3) {
                        ChatActivity.this.lambda$showMentionDownButton$159(valueAnimator3);
                    }
                });
                this.mentiondownButtonAnimation.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        ChatActivity.this.mentionsButtonEnterProgress = 0.0f;
                        ChatActivity.this.mentiondownButton.setVisibility(4);
                        ChatActivity.this.contentView.invalidate();
                    }
                });
                this.mentiondownButtonAnimation.setDuration(200L);
                this.mentiondownButtonAnimation.start();
                return;
            }
            this.mentionsButtonEnterProgress = 0.0f;
            this.mentiondownButton.setVisibility(4);
        }
    }

    public void lambda$showMentionDownButton$158(ValueAnimator valueAnimator) {
        this.mentionsButtonEnterProgress = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        this.contentView.invalidate();
    }

    public void lambda$showMentionDownButton$159(ValueAnimator valueAnimator) {
        this.mentionsButtonEnterProgress = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        this.contentView.invalidate();
    }

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

        public boolean invalidateOptimized() {
            return true;
        }

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

        public ChatActivityFragmentView(Context context, INavigationLayout parentLayout) {
            super(context, parentLayout);
            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, ChatActivity.this) {
                @Override
                public void onTransitionStart(boolean keyboardVisible, int contentHeight) {
                    ChatActivity.this.wasManualScroll = true;
                    ChatActivityEnterView chatActivityEnterView = ChatActivity.this.chatActivityEnterView;
                    if (chatActivityEnterView != null) {
                        chatActivityEnterView.onAdjustPanTransitionStart(keyboardVisible, contentHeight);
                    }
                    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
                public 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
                public void onPanTranslationUpdate(float y, float progress, boolean keyboardVisible) {
                    if (ChatActivity.this.getParentLayout() == null || !ChatActivity.this.getParentLayout().isPreviewOpenAnimationInProgress()) {
                        ChatActivity.this.contentPanTranslation = y;
                        ChatActivity.this.contentPanTranslationT = progress;
                        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(y);
                            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(y);
                            }
                            if (ChatActivity.this.savedMessagesHint != null) {
                                ChatActivity.this.savedMessagesHint.setTranslationY(y);
                            }
                            SearchTagsList searchTagsList = ChatActivity.this.actionBarSearchTags;
                            if (searchTagsList != null) {
                                searchTagsList.setTranslationY(y);
                            }
                            ChatSearchTabs chatSearchTabs = ChatActivity.this.hashtagSearchTabs;
                            if (chatSearchTabs != null) {
                                chatSearchTabs.setTranslationY(y);
                            }
                            if (ChatActivity.this.emptyViewContainer != null) {
                                ChatActivity.this.emptyViewContainer.setTranslationY(y / 2.0f);
                            }
                            if (ChatActivity.this.hashtagHistoryView != null) {
                                ChatActivity.this.hashtagHistoryView.setTranslationY(y);
                                ChatActivity.this.hashtagHistoryView.emptyView.setTranslationY((-y) / 2.0f);
                            }
                            if (ChatActivity.this.messagesSearchListContainer != null) {
                                ChatActivity.this.messagesSearchListContainer.setTranslationY(y);
                            }
                            if (ChatActivity.this.hashtagSearchEmptyView != null) {
                                ChatActivity.this.hashtagSearchEmptyView.setTranslationY((-y) / 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(y);
                                    }
                                    if (chatActivity.hashtagSearchEmptyView != null) {
                                        chatActivity.hashtagSearchEmptyView.setTranslationY((-y) / 2.0f);
                                    }
                                }
                            }
                            ChatActivity.this.progressView.setTranslationY(y / 2.0f);
                            int i = (int) y;
                            ChatActivity.this.contentView.setBackgroundTranslation(i);
                            InstantCameraView instantCameraView = ChatActivity.this.instantCameraView;
                            if (instantCameraView != null) {
                                instantCameraView.onPanTranslationUpdate(y);
                            }
                            if (ChatActivity.this.blurredView != null) {
                                ChatActivity.this.blurredView.drawable.onPanTranslationUpdate(y);
                            }
                            ChatActivity.this.setFragmentPanTranslationOffset(i);
                            ChatActivity.this.invalidateChatListViewTopPadding();
                            ChatActivity.this.invalidateMessagesVisiblePart();
                        } else {
                            ChatActivityFragmentView.this.setNonNoveTranslation(y);
                        }
                        ChatActivity.this.chatListView.invalidate();
                        ChatActivity.this.updateBulletinLayout();
                        ChatActivityEnterView chatActivityEnterView = ChatActivity.this.chatActivityEnterView;
                        if (chatActivityEnterView != null) {
                            chatActivityEnterView.onAdjustPanTransitionUpdate(y, progress, keyboardVisible);
                        }
                        MentionsContainerView mentionsContainerView = ChatActivity.this.mentionContainer;
                        if (mentionsContainerView != null) {
                            mentionsContainerView.onPanTransitionUpdate(y);
                        }
                        if (AndroidUtilities.isTablet() && (ChatActivity.this.getParentActivity() instanceof LaunchActivity)) {
                            BaseFragment lastFragment = ((LaunchActivity) ChatActivity.this.getParentActivity()).getActionBarLayout().getLastFragment();
                            if (lastFragment instanceof DialogsActivity) {
                                ((DialogsActivity) lastFragment).setPanTranslationOffset(y);
                            }
                        }
                        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(y);
                        }
                    }
                }

                @Override
                public boolean heightAnimationEnabled() {
                    ChatAttachAlert chatAttachAlert;
                    INavigationLayout parentLayout2 = ChatActivity.this.getParentLayout();
                    ChatActivity chatActivity = ChatActivity.this;
                    if (chatActivity.isInsideContainer || ((BaseFragment) chatActivity).inPreviewMode || ((BaseFragment) ChatActivity.this).inBubbleMode || AndroidUtilities.isInMultiwindow || parentLayout2 == null || ChatActivity.this.fixedKeyboardHeight > 0 || System.currentTimeMillis() - ChatActivity.this.activityResumeTime < 250) {
                        return false;
                    }
                    if ((ChatActivity.this != parentLayout2.getLastFragment() || !parentLayout2.isTransitionAnimationInProgress()) && !parentLayout2.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
                public int startOffset() {
                    if (ChatActivityFragmentView.this.getKeyboardHeight() > AndroidUtilities.dp(20.0f) || !ChatActivity.this.chatActivityEnterView.isPopupShowing()) {
                        return 0;
                    }
                    return ChatActivity.this.chatActivityEnterView.getEmojiPadding();
                }
            };
        }

        public void drawList(Canvas blurCanvas, boolean top, ArrayList<SizeNotifierFrameLayout.IViewWithInvalidateCallback> views) {
            float dp = (ChatActivity.this.chatListViewPaddingTop - r0.chatListViewPaddingVisibleOffset) - AndroidUtilities.dp(4.0f);
            for (int i = 0; i < ChatActivity.this.chatListView.getChildCount(); i++) {
                View childAt = ChatActivity.this.chatListView.getChildAt(i);
                if (childAt instanceof BaseCell) {
                    ((BaseCell) childAt).setCaching(top, false);
                }
            }
            for (int i2 = 0; i2 < ChatActivity.this.chatListView.getChildCount(); i2++) {
                SizeNotifierFrameLayout.IViewWithInvalidateCallback childAt2 = ChatActivity.this.chatListView.getChildAt(i2);
                if ((!top || childAt2.getY() <= AndroidUtilities.dp(40.0f) + dp) && (top || childAt2.getY() + childAt2.getMeasuredHeight() >= AndroidUtilities.dp(203.0f))) {
                    blurCanvas.save();
                    if (top) {
                        blurCanvas.translate(ChatActivity.this.chatListView.getX() + childAt2.getX(), (ChatActivity.this.chatListView.getY() + childAt2.getY()) - ChatActivity.this.contentPanTranslation);
                    } else {
                        blurCanvas.translate(ChatActivity.this.chatListView.getX() + childAt2.getX(), ChatActivity.this.chatListView.getTop() + childAt2.getY());
                    }
                    if (childAt2 instanceof ChatMessageCell) {
                        ChatMessageCell chatMessageCell = (ChatMessageCell) childAt2;
                        if (chatMessageCell.drawBackgroundInParent()) {
                            chatMessageCell.drawBackgroundInternal(blurCanvas, true);
                        }
                        if (views != null) {
                            views.add(chatMessageCell);
                        }
                        chatMessageCell.setCaching(top, true);
                        chatMessageCell.drawCached(blurCanvas);
                    } else if (childAt2 instanceof ChatActionCell) {
                        ChatActionCell chatActionCell = (ChatActionCell) childAt2;
                        chatActionCell.setCaching(top, true);
                        chatActionCell.drawCached(blurCanvas);
                        chatActionCell.drawOutboundsContent(blurCanvas);
                        if (views != null) {
                            views.add(chatActionCell);
                        }
                    } else {
                        childAt2.draw(blurCanvas);
                        if (views != null && (childAt2 instanceof SizeNotifierFrameLayout.IViewWithInvalidateCallback)) {
                            views.add(childAt2);
                        }
                    }
                    blurCanvas.restore();
                }
            }
            if (ChatActivity.this.searchViewPager != null) {
                for (int i3 = 0; i3 < ChatActivity.this.searchViewPager.getChildCount(); i3++) {
                    View childAt3 = ChatActivity.this.searchViewPager.getChildAt(i3);
                    if (childAt3 instanceof ChatActivityContainer) {
                        ChatActivityFragmentView chatActivityFragmentView = ((ChatActivityContainer) childAt3).chatActivity.contentView;
                        blurCanvas.save();
                        blurCanvas.translate(childAt3.getTranslationX(), ChatActivity.this.searchViewPager.getTop());
                        chatActivityFragmentView.drawList(blurCanvas, top, views);
                        blurCanvas.restore();
                    }
                }
            }
        }

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

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

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

        public void onAttachedToWindow() {
            super.onAttachedToWindow();
            ChatActivity chatActivity = ChatActivity.this;
            if (!chatActivity.isInsideContainer) {
                if (((BaseFragment) chatActivity).parentLayout != null && ((BaseFragment) ChatActivity.this).parentLayout.isSheet()) {
                    ((SizeNotifierFrameLayout) this).adjustPanLayoutHelper.setResizableView((FrameLayout) ((BaseFragment) ChatActivity.this).parentLayout.getView().getParent().getParent().getParent().getParent());
                }
            } else {
                ((SizeNotifierFrameLayout) this).adjustPanLayoutHelper.setResizableView(chatActivity.contentView);
            }
            ((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();
        }

        public 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);
                }
            });
        }

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

        public 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);
        }

        public 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");
        }

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

        public final void drawChildElement(Canvas canvas, float listTop, ChatMessageCell cell, int type) {
            canvas.save();
            float left = ChatActivity.this.chatListView.getLeft() + cell.getLeft();
            float y = ChatActivity.this.chatListView.getY() + cell.getY();
            float alpha = cell.shouldDrawAlphaLayer() ? cell.getAlpha() : 1.0f;
            canvas.clipRect(ChatActivity.this.chatListView.getLeft(), listTop, ChatActivity.this.chatListView.getRight(), (ChatActivity.this.chatListView.getY() + ChatActivity.this.chatListView.getMeasuredHeight()) - ChatActivity.this.blurredViewBottomOffset);
            canvas.translate(left, y);
            cell.setInvalidatesParent(true);
            if (type == 0) {
                cell.drawTime(canvas, alpha, true);
            } else if (type == 1) {
                cell.drawNamesLayout(canvas, alpha);
            } else if (type == 2) {
                cell.drawCaptionLayout(canvas, cell.getCurrentPosition() != null && (cell.getCurrentPosition().flags & 1) == 0, alpha);
            } else {
                if (!(cell.getCurrentPosition() != null && (cell.getCurrentPosition().flags & 1) == 0)) {
                    cell.drawReactionsLayout(canvas, alpha);
                }
            }
            cell.setInvalidatesParent(false);
            canvas.restore();
        }

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

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

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

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

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

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

        public void setNonNoveTranslation(float y) {
            ChatActivity.this.contentView.setTranslationY(y);
            ((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);
            }
            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();
        }

        public void setPadding(int left, int top, int right, int bottom) {
            ChatActivity.this.contentPaddingTop = top;
            ChatActivity.this.invalidateChatListViewTopPadding();
            ChatActivity.this.invalidateMessagesVisiblePart();
        }

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

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

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

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

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

    public final void updateSecretStatus() {
        ChatActivityEnterView chatActivityEnterView;
        if (this.bottomOverlay == null) {
            return;
        }
        this.bottomOverlayText.setBackground(null);
        this.bottomOverlayText.setOnClickListener(null);
        boolean z = true;
        if (this.chatMode == 3 && getSavedDialogId() == 2666000) {
            this.bottomOverlayText.setText(LocaleController.getString(R.string.AuthorHiddenDescription));
            this.bottomOverlay.setVisibility(0);
            AnimatorSet animatorSet = this.mentionListAnimation;
            if (animatorSet != null) {
                animatorSet.cancel();
                this.mentionListAnimation = null;
            }
            this.mentionContainer.setVisibility(8);
            this.mentionContainer.setTag(null);
            updateMessageListAccessibilityVisibility();
            SuggestEmojiView suggestEmojiView = this.suggestEmojiPanel;
            if (suggestEmojiView != null) {
                suggestEmojiView.forceClose();
            }
        } else {
            TLRPC.Chat chat = this.currentChat;
            if (chat != null && !ChatObject.canSendMessages(chat) && !ChatObject.canSendAnyMedia(this.currentChat)) {
                TLRPC.Chat chat2 = this.currentChat;
                if (!chat2.gigagroup && (!ChatObject.isChannel(chat2) || this.currentChat.megagroup)) {
                    TLRPC.Chat chat3 = this.currentChat;
                    TLRPC.TL_chatBannedRights tL_chatBannedRights = chat3.default_banned_rights;
                    if (tL_chatBannedRights != null && tL_chatBannedRights.send_messages) {
                        if (ChatObject.isPossibleRemoveChatRestrictionsByBoosts(chat3)) {
                            Drawable mutate = ContextCompat.getDrawable(getContext(), R.drawable.filled_limit_boost).mutate();
                            int i = Theme.key_featuredStickers_addButton;
                            DrawableCompat.setTint(mutate, getThemedColor(i));
                            mutate.setBounds(0, 0, AndroidUtilities.dp(14.0f), AndroidUtilities.dp(14.0f));
                            CombinedDrawable combinedDrawable = new CombinedDrawable((Drawable) null, mutate, AndroidUtilities.dp(-6.0f), AndroidUtilities.dp(-6.0f));
                            combinedDrawable.setIconSize(AndroidUtilities.dp(14.0f), AndroidUtilities.dp(14.0f));
                            combinedDrawable.setCustomSize(AndroidUtilities.dp(14.0f), AndroidUtilities.dp(14.0f));
                            SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder("d " + LocaleController.getString(R.string.BoostingBoostToSendMessages));
                            spannableStringBuilder.setSpan(new ForegroundColorSpan(getThemedColor(i)), 0, spannableStringBuilder.length(), 33);
                            spannableStringBuilder.setSpan(new TypefaceSpan(AndroidUtilities.bold()), 0, spannableStringBuilder.length(), 33);
                            spannableStringBuilder.setSpan(new ImageSpan((Drawable) combinedDrawable, 1), 0, 1, 33);
                            this.bottomOverlayText.setBackground(Theme.createSelectorWithBackgroundDrawable(Theme.getColor(Theme.key_windowBackgroundWhite), Theme.getColor(Theme.key_listSelector)));
                            this.bottomOverlayText.setText(spannableStringBuilder);
                            this.bottomOverlayText.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public final void onClick(View view) {
                                    ChatActivity.this.lambda$updateSecretStatus$160(view);
                                }
                            });
                        } else {
                            this.bottomOverlayText.setText(LocaleController.getString("GlobalSendMessageRestricted", R.string.GlobalSendMessageRestricted));
                        }
                    } else if (AndroidUtilities.isBannedForever(chat3.banned_rights)) {
                        this.bottomOverlayText.setText(LocaleController.getString("SendMessageRestrictedForever", R.string.SendMessageRestrictedForever));
                    } else {
                        this.bottomOverlayText.setText(LocaleController.formatString("SendMessageRestricted", R.string.SendMessageRestricted, new Object[]{LocaleController.formatDateForBan(this.currentChat.banned_rights.until_date)}));
                    }
                    this.bottomOverlay.setVisibility(0);
                    AnimatorSet animatorSet2 = this.mentionListAnimation;
                    if (animatorSet2 != null) {
                        animatorSet2.cancel();
                        this.mentionListAnimation = null;
                    }
                    this.mentionContainer.setVisibility(8);
                    this.mentionContainer.setTag(null);
                    updateMessageListAccessibilityVisibility();
                    SuggestEmojiView suggestEmojiView2 = this.suggestEmojiPanel;
                    if (suggestEmojiView2 != null) {
                        suggestEmojiView2.forceClose();
                    }
                }
            }
            createEmptyView(false);
            TLRPC.EncryptedChat encryptedChat = this.currentEncryptedChat;
            if (encryptedChat == null || this.bigEmptyView == null) {
                this.bottomOverlay.setVisibility(4);
                if (this.suggestEmojiPanel == null || (chatActivityEnterView = this.chatActivityEnterView) == null || !chatActivityEnterView.hasText()) {
                    return;
                }
                this.suggestEmojiPanel.fireUpdate();
                return;
            }
            if (encryptedChat instanceof TLRPC.TL_encryptedChatRequested) {
                this.bottomOverlayText.setText(LocaleController.getString("EncryptionProcessing", R.string.EncryptionProcessing));
                this.bottomOverlay.setVisibility(0);
                this.chatActivityEnterView.setVisibility(4);
            } else if (encryptedChat instanceof TLRPC.TL_encryptedChatWaiting) {
                this.bottomOverlayText.setText(AndroidUtilities.replaceTags(LocaleController.formatString("AwaitingEncryption", R.string.AwaitingEncryption, new Object[]{"<b>" + this.currentUser.first_name + "</b>"})));
                this.bottomOverlay.setVisibility(0);
                this.chatActivityEnterView.setVisibility(4);
            } else if (encryptedChat instanceof TLRPC.TL_encryptedChatDiscarded) {
                this.bottomOverlayText.setText(LocaleController.getString("EncryptionRejected", R.string.EncryptionRejected));
                this.bottomOverlay.setVisibility(0);
                this.chatActivityEnterView.setVisibility(4);
                this.chatActivityEnterView.setFieldText("");
                getMediaDataController().cleanDraft(this.dialog_id, this.threadMessageId, false);
            } else {
                if (encryptedChat instanceof TLRPC.TL_encryptedChat) {
                    this.bottomOverlay.setVisibility(4);
                    if (!((BaseFragment) this).inPreviewMode && !this.isInsideContainer && this.chatMode != 3) {
                        this.chatActivityEnterView.setVisibility(0);
                    }
                }
                z = false;
            }
            checkRaiseSensors();
            checkActionBarMenu(false);
        }
        if (((BaseFragment) this).inPreviewMode || this.hideBottomMode) {
            this.bottomOverlay.setVisibility(4);
        }
        if (z) {
            this.chatActivityEnterView.hidePopup(false);
            if (getParentActivity() != null) {
                AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
            }
        }
    }

    public void lambda$updateSecretStatus$160(View view) {
        LimitReachedBottomSheet.openBoostsForRemoveRestrictions(this, this.boostsStatus, this.canApplyBoosts, this.dialog_id, false);
    }

    public void onRequestPermissionsResultFragment(int requestCode, String[] permissions, int[] grantResults) {
        ChatAttachAlert chatAttachAlert;
        ChatAttachAlert chatAttachAlert2;
        boolean z;
        ChatAttachAlert chatAttachAlert3;
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView != null) {
            chatActivityEnterView.onRequestPermissionsResultFragment(requestCode, permissions, grantResults);
        }
        MentionsContainerView mentionsContainerView = this.mentionContainer;
        if (mentionsContainerView != null && mentionsContainerView.getAdapter() != null) {
            this.mentionContainer.getAdapter().onRequestPermissionsResultFragment(requestCode, permissions, grantResults);
        }
        if (requestCode == 4) {
            ChatAttachAlert chatAttachAlert4 = this.chatAttachAlert;
            if (chatAttachAlert4 != null) {
                chatAttachAlert4.getPhotoLayout().checkStorage();
            }
            ChatThemeBottomSheet chatThemeBottomSheet = this.chatThemeBottomSheet;
            if (chatThemeBottomSheet == null || (chatAttachAlert3 = chatThemeBottomSheet.chatAttachAlert) == null) {
                return;
            }
            chatAttachAlert3.getPhotoLayout().checkStorage();
            return;
        }
        if ((requestCode == 5 || requestCode == 30) && (chatAttachAlert = this.chatAttachAlert) != null) {
            chatAttachAlert.onRequestPermissionsResultFragment(requestCode, permissions, grantResults);
            return;
        }
        if ((requestCode == 17 || requestCode == 18) && (chatAttachAlert2 = this.chatAttachAlert) != null) {
            chatAttachAlert2.getPhotoLayout().checkCamera(grantResults.length > 0 && grantResults[0] == 0);
            this.chatAttachAlert.getPhotoLayout().checkStorage();
            return;
        }
        if (requestCode == 21) {
            if (getParentActivity() == null || grantResults == null || grantResults.length == 0 || grantResults[0] == 0) {
                return;
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity(), this.themeDelegate);
            builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
            builder.setMessage(LocaleController.getString("PermissionNoAudioVideoWithHint", R.string.PermissionNoAudioVideoWithHint));
            builder.setNegativeButton(LocaleController.getString("PermissionOpenSettings", R.string.PermissionOpenSettings), new DialogInterface.OnClickListener() {
                @Override
                public final void onClick(DialogInterface dialogInterface, int i) {
                    ChatActivity.this.lambda$onRequestPermissionsResultFragment$161(dialogInterface, i);
                }
            });
            builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
            builder.show();
            return;
        }
        if (requestCode == 19 && grantResults != null && grantResults.length > 0 && grantResults[0] == 0) {
            processSelectedAttach(0);
            return;
        }
        if (requestCode == 20 && grantResults != null && grantResults.length > 0 && grantResults[0] == 0) {
            processSelectedAttach(2);
            return;
        }
        if (((requestCode == 101 || requestCode == 102) && this.currentUser != null) || (requestCode == 103 && this.currentChat != null)) {
            int i = 0;
            while (true) {
                if (i >= grantResults.length) {
                    z = true;
                    break;
                } else {
                    if (grantResults[i] != 0) {
                        z = false;
                        break;
                    }
                    i++;
                }
            }
            if (grantResults.length <= 0 || !z) {
                VoIPHelper.permissionDenied(getParentActivity(), (Runnable) null, requestCode);
                return;
            }
            if (requestCode == 103) {
                VoIPHelper.startCall(this.currentChat, (TLRPC.InputPeer) null, (String) null, this.createGroupCall, getParentActivity(), this, getAccountInstance());
                return;
            }
            TLRPC.User user = this.currentUser;
            boolean z2 = requestCode == 102;
            TLRPC.UserFull userFull = this.userInfo;
            VoIPHelper.startCall(user, z2, userFull != null && userFull.video_calls_available, getParentActivity(), getMessagesController().getUserFull(this.currentUser.id), getAccountInstance());
        }
    }

    public void lambda$onRequestPermissionsResultFragment$161(DialogInterface dialogInterface, 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 final void checkActionBarMenu(boolean r8) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.checkActionBarMenu(boolean):void");
    }

    public final int getMessageType(MessageObject messageObject) {
        String str;
        String str2;
        if (messageObject == null) {
            return -1;
        }
        boolean z = false;
        if (this.currentEncryptedChat == null) {
            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 i = messageObject.type;
            if (i == 6) {
                return -1;
            }
            if (i == 10 || i == 11 || i == 21 || messageObject.isWallpaperAction()) {
                return messageObject.getId() == 0 ? -1 : 1;
            }
            if (messageObject.isVoice()) {
                return 2;
            }
            if (messageObject.isSticker() || messageObject.isAnimatedSticker()) {
                TLRPC.InputStickerSet inputStickerSet = messageObject.getInputStickerSet();
                return inputStickerSet instanceof TLRPC.TL_inputStickerSetID ? !getMediaDataController().isStickerPackInstalled(inputStickerSet.id) ? 7 : 9 : (!(inputStickerSet instanceof TLRPC.TL_inputStickerSetShortName) || getMediaDataController().isStickerPackInstalled(inputStickerSet.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;
        }
        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 i2 = messageObject.type;
        if (i2 == 10 || i2 == 11) {
            return (messageObject.getId() == 0 || messageObject.isSending()) ? -1 : 1;
        }
        if (messageObject.isVoice()) {
            return 2;
        }
        if (!messageObject.isAnimatedEmoji() && (messageObject.isSticker() || messageObject.isAnimatedSticker())) {
            TLRPC.InputStickerSet inputStickerSet2 = messageObject.getInputStickerSet();
            if ((inputStickerSet2 instanceof TLRPC.TL_inputStickerSetShortName) && !getMediaDataController().isStickerPackInstalled(inputStickerSet2.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;
    }

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

    public final void addToSelectedMessages(MessageObject messageObject, boolean outside, boolean last) {
        ActionBarMenuItem actionBarMenuItem;
        int i;
        int i2;
        ActionBarMenuItem actionBarMenuItem2;
        int i3;
        int i4;
        ActionBarMenuItem actionBarMenuItem3;
        ActionBarMenuItem actionBarMenuItem4;
        ActionBarMenuItem actionBarMenuItem5;
        ActionBarMenuItem actionBarMenuItem6;
        boolean z;
        int i5;
        ActionBarMenuItem actionBarMenuItem7;
        ActionBarMenuItem actionBarMenuItem8;
        ActionBarMenuItem actionBarMenuItem9;
        ActionBarMenuItem actionBarMenuItem10;
        int i6;
        int i7;
        BlurredFrameLayout blurredFrameLayout;
        int i8;
        ActionBarMenuItem actionBarMenuItem11;
        int i9;
        TLRPC.Chat chat;
        int i10;
        int i11;
        int i12;
        int i13;
        int i14;
        String str;
        char c;
        TLRPC.Message message;
        TLRPC.Message message2;
        int i15 = this.cantForwardMessagesCount;
        if (messageObject != null) {
            ArrayList<MessageObject> arrayList = this.threadMessageObjects;
            if (arrayList != null && arrayList.contains(messageObject) && !isThreadChat()) {
                return;
            }
            char c2 = messageObject.getDialogId() == this.dialog_id ? (char) 0 : (char) 1;
            if (outside && messageObject.getGroupId() != 0) {
                MessageObject.GroupedMessages groupedMessages = (MessageObject.GroupedMessages) this.groupedMessagesMap.get(messageObject.getGroupId());
                if (groupedMessages != null) {
                    boolean z2 = false;
                    int i16 = 0;
                    for (int i17 = 0; i17 < groupedMessages.messages.size(); i17++) {
                        if (this.selectedMessagesIds[c2].indexOfKey(((MessageObject) groupedMessages.messages.get(i17)).getId()) < 0) {
                            i16 = i17;
                            z2 = true;
                        }
                    }
                    int i18 = 0;
                    while (i18 < groupedMessages.messages.size()) {
                        MessageObject messageObject2 = (MessageObject) groupedMessages.messages.get(i18);
                        if (z2) {
                            if (this.selectedMessagesIds[c2].indexOfKey(messageObject2.getId()) < 0) {
                                addToSelectedMessages(messageObject2, false, i18 == i16);
                            }
                        } else {
                            addToSelectedMessages(messageObject2, false, i18 == groupedMessages.messages.size() - 1);
                        }
                        if (!TextUtils.isEmpty(messageObject2.caption)) {
                            showTextSelectionHint(messageObject);
                        }
                        i18++;
                    }
                    return;
                }
                return;
            }
            if (this.selectedMessagesIds[c2].indexOfKey(messageObject.getId()) >= 0) {
                this.selectedMessagesIds[c2].remove(messageObject.getId());
                if (this.reportType < 0) {
                    if ((messageObject.type == 0 || messageObject.isAnimatedEmoji() || messageObject.caption != null) && ((message2 = messageObject.messageOwner) == null || !message2.noforwards)) {
                        this.selectedMessagesCanCopyIds[c2].remove(messageObject.getId());
                    }
                    if (!messageObject.isAnimatedEmoji() && ((messageObject.isSticker() || messageObject.isAnimatedSticker()) && MessageObject.isStickerHasSet(messageObject.getDocument()))) {
                        this.selectedMessagesCanStarIds[c2].remove(messageObject.getId());
                    }
                    if (messageObject.canEditMessage(this.currentChat)) {
                        this.canEditMessagesCount--;
                    }
                    if (!messageObject.canDeleteMessage(this.chatMode == 1, this.currentChat)) {
                        this.cantDeleteMessagesCount--;
                    }
                    boolean isChatNoForwards = getMessagesController().isChatNoForwards(this.currentChat);
                    if (this.chatMode == 1 || !messageObject.canForwardMessage() || isChatNoForwards) {
                        this.cantForwardMessagesCount--;
                    } else {
                        this.canForwardMessagesCount--;
                    }
                    if (messageObject.isMusic() && !isChatNoForwards) {
                        this.canSaveMusicCount--;
                    } else if (messageObject.isDocument() && !isChatNoForwards) {
                        this.canSaveDocumentsCount--;
                    } else if ((messageObject.isPhoto() || messageObject.isVideo()) && !isChatNoForwards) {
                        this.canSaveMediaCount--;
                    } else {
                        this.cantSaveMessagesCount--;
                    }
                    if (messageObject.mediaExists) {
                        this.canSqueduleCount--;
                    }
                }
            } else {
                if (this.selectedMessagesIds[0].size() + this.selectedMessagesIds[1].size() >= (BuildVars.BETA_2 ? 1000 : 100)) {
                    AndroidUtilities.shakeView(this.selectedMessagesCountTextView);
                    Vibrator vibrator = (Vibrator) ApplicationLoader.applicationContext.getSystemService("vibrator");
                    if (vibrator != null && !PlusSettings.disableActionsVibrations) {
                        vibrator.vibrate(200L);
                    }
                    Activity parentActivity = getParentActivity();
                    StringBuilder sb = new StringBuilder();
                    sb.append(BuildVars.BETA_2 ? 1000 : 100);
                    sb.append(" messages selected");
                    PlusUtils.showToast(parentActivity, sb.toString());
                    return;
                }
                this.selectedMessagesIds[c2].put(messageObject.getId(), messageObject);
                if (this.reportType < 0) {
                    if ((messageObject.type == 0 || messageObject.isAnimatedEmoji() || messageObject.caption != null) && ((message = messageObject.messageOwner) == null || !message.noforwards)) {
                        this.selectedMessagesCanCopyIds[c2].put(messageObject.getId(), messageObject);
                    }
                    if (!messageObject.isAnimatedEmoji() && ((messageObject.isSticker() || messageObject.isAnimatedSticker()) && MessageObject.isStickerHasSet(messageObject.getDocument()))) {
                        this.selectedMessagesCanStarIds[c2].put(messageObject.getId(), messageObject);
                    }
                    if (messageObject.canEditMessage(this.currentChat)) {
                        this.canEditMessagesCount++;
                    }
                    if (!messageObject.canDeleteMessage(this.chatMode == 1, this.currentChat)) {
                        this.cantDeleteMessagesCount++;
                    }
                    boolean isChatNoForwards2 = getMessagesController().isChatNoForwards(this.currentChat);
                    if (this.chatMode == 1 || !messageObject.canForwardMessage() || isChatNoForwards2) {
                        this.cantForwardMessagesCount++;
                    } else {
                        this.canForwardMessagesCount++;
                    }
                    if (messageObject.isMusic() && !isChatNoForwards2) {
                        this.canSaveMusicCount++;
                    } else if (messageObject.isDocument() && !messageObject.isRoundOnce() && !messageObject.isVoiceOnce() && !isChatNoForwards2) {
                        this.canSaveDocumentsCount++;
                    } else if ((messageObject.isPhoto() || messageObject.isVideo()) && !isChatNoForwards2) {
                        this.canSaveMediaCount++;
                    } else {
                        this.cantSaveMessagesCount++;
                    }
                    if (outside) {
                        showTextSelectionHint(messageObject);
                    }
                    if (messageObject.getDocument() != null && !TextUtils.isEmpty(messageObject.getFileName()) && !messageObject.mediaExists) {
                        this.canSqueduleCount++;
                    }
                }
            }
        }
        AnimatorSet animatorSet = this.forwardButtonAnimation;
        if (animatorSet != null) {
            animatorSet.cancel();
            this.forwardButtonAnimation = null;
        }
        if (last && ((BaseFragment) this).actionBar.isActionModeShowed() && this.reportType < 0) {
            int size = this.selectedMessagesIds[0].size() + this.selectedMessagesIds[1].size();
            if (size == 0) {
                hideActionMode();
                updatePinnedMessageView(true);
                this.maxSelectedMessageId = -1L;
                this.minSelectedMessageId = -1L;
            } else {
                createActionMode();
                ActionBarMenuItem item = ((BaseFragment) this).actionBar.createActionMode().getItem(25);
                ActionBarMenuItem item2 = ((BaseFragment) this).actionBar.createActionMode().getItem(10);
                ActionBarMenuItem item3 = ((BaseFragment) this).actionBar.createActionMode().getItem(22);
                final ActionBarMenuItem item4 = ((BaseFragment) this).actionBar.createActionMode().getItem(23);
                ActionBarMenuItem item5 = ((BaseFragment) this).actionBar.createActionMode().getItem(19);
                ActionBarMenuItem item6 = ((BaseFragment) this).actionBar.createActionMode().getItem(11);
                ActionBarMenuItem item7 = ((BaseFragment) this).actionBar.createActionMode().getItem(12);
                ActionBarMenuItem item8 = ((BaseFragment) this).actionBar.createActionMode().getItem(28);
                ActionBarMenuItem item9 = ((BaseFragment) this).actionBar.createActionMode().getItem(69);
                createBottomMessagesActionButtons();
                boolean z3 = getMessagesController().isChatNoForwards(this.currentChat) || hasSelectedNoforwardsMessage();
                float f = 0.5f;
                if ((i15 == 0 && this.cantForwardMessagesCount != 0) || (i15 != 0 && this.cantForwardMessagesCount == 0)) {
                    this.forwardButtonAnimation = new AnimatorSet();
                    ArrayList arrayList2 = new ArrayList();
                    if (item6 != null) {
                        item6.setEnabled(this.cantForwardMessagesCount == 0 || z3);
                        Property property = View.ALPHA;
                        float[] fArr = new float[1];
                        fArr[0] = this.cantForwardMessagesCount == 0 ? 1.0f : 0.5f;
                        arrayList2.add(ObjectAnimator.ofFloat(item6, (Property<ActionBarMenuItem, Float>) property, fArr));
                        if (z3 && item6.getBackground() != null) {
                            item6.setBackground(null);
                        } else if (item6.getBackground() == null) {
                            item6.setBackground(Theme.createSelectorDrawable(getThemedColor(Theme.key_actionBarActionModeDefaultSelector), 5));
                        }
                    }
                    TextView textView = this.forwardButton;
                    if (textView != null) {
                        textView.setEnabled(this.cantForwardMessagesCount == 0 || z3);
                        if (z3 && this.forwardButton.getBackground() != null) {
                            this.forwardButton.setBackground(null);
                        } else if (this.forwardButton.getBackground() == null) {
                            this.forwardButton.setBackground(Theme.createSelectorDrawable(getThemedColor(Theme.key_actionBarActionModeDefaultSelector), 3));
                        }
                        TextView textView2 = this.forwardButton;
                        Property property2 = View.ALPHA;
                        actionBarMenuItem = item5;
                        float[] fArr2 = new float[1];
                        if (this.cantForwardMessagesCount == 0) {
                            c = 0;
                            f = 1.0f;
                        } else {
                            c = 0;
                        }
                        fArr2[c] = f;
                        arrayList2.add(ObjectAnimator.ofFloat(textView2, (Property<TextView, Float>) property2, fArr2));
                    } else {
                        actionBarMenuItem = item5;
                    }
                    this.forwardButtonAnimation.playTogether(arrayList2);
                    this.forwardButtonAnimation.setDuration(100L);
                    this.forwardButtonAnimation.addListener(new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationEnd(Animator animation) {
                            ChatActivity.this.forwardButtonAnimation = null;
                        }
                    });
                    this.forwardButtonAnimation.start();
                } else {
                    actionBarMenuItem = item5;
                    if (item6 != null) {
                        item6.setEnabled(this.cantForwardMessagesCount == 0 || z3);
                        item6.setAlpha(this.cantForwardMessagesCount == 0 ? 1.0f : 0.5f);
                        if (z3) {
                            if (this.forwardButton != null && item6.getBackground() != null) {
                                this.forwardButton.setBackground(null);
                            }
                        } else if (item6.getBackground() == null) {
                            item6.setBackground(Theme.createSelectorDrawable(getThemedColor(Theme.key_actionBarActionModeDefaultSelector), 3));
                        }
                    }
                    TextView textView3 = this.forwardButton;
                    if (textView3 != null) {
                        textView3.setEnabled(this.cantForwardMessagesCount == 0 || z3);
                        if (z3) {
                            if (this.forwardButton.getBackground() != null) {
                                this.forwardButton.setBackground(null);
                            }
                        } else if (this.forwardButton.getBackground() == null) {
                            this.forwardButton.setBackground(Theme.createSelectorDrawable(getThemedColor(Theme.key_actionBarActionModeDefaultSelector), 3));
                        }
                        this.forwardButton.setAlpha(this.cantForwardMessagesCount == 0 ? 1.0f : 0.5f);
                    }
                }
                if (item != null) {
                    int i19 = this.canSaveMusicCount;
                    item.setVisibility((((i19 <= 0 || this.canSaveDocumentsCount != 0) && (i19 != 0 || this.canSaveDocumentsCount <= 0)) || this.cantSaveMessagesCount != 0 || PlusSettings.hideSaveToActionModeButton) ? 8 : 0);
                    if (this.canSaveMusicCount > 0) {
                        i14 = R.string.SaveToMusic;
                        str = "SaveToMusic";
                    } else {
                        i14 = R.string.SaveToDownloads;
                        str = "SaveToDownloads";
                    }
                    item.setContentDescription(LocaleController.getString(str, i14));
                    if (item.getVisibility() != 0 && this.canSaveMediaCount > 0 && this.cantSaveMessagesCount == 0 && !PlusSettings.hideSaveToActionModeButton) {
                        item.setVisibility(0);
                        item.setContentDescription(LocaleController.getString("SaveToGallery", R.string.SaveToGallery));
                    }
                }
                ActionBarMenuItem item10 = ((BaseFragment) this).actionBar.createActionMode().getItem(83);
                ActionBarMenuItem item11 = ((BaseFragment) this).actionBar.createActionMode().getItem(89);
                if (item2 != null) {
                    i2 = item2.getVisibility();
                    item2.setVisibility((z3 || this.selectedMessagesCanCopyIds[0].size() + this.selectedMessagesCanCopyIds[1].size() == 0) ? 8 : 0);
                    i = item2.getVisibility();
                } else {
                    i = 8;
                    i2 = 8;
                }
                if (item3 != null) {
                    int visibility = item3.getVisibility();
                    if (getMediaDataController().canAddStickerToFavorites()) {
                        i12 = visibility;
                        actionBarMenuItem2 = item10;
                        if (this.selectedMessagesCanStarIds[0].size() + this.selectedMessagesCanStarIds[1].size() == size) {
                            i13 = 0;
                            item3.setVisibility(i13);
                            i4 = item3.getVisibility();
                            i3 = i12;
                        }
                    } else {
                        i12 = visibility;
                        actionBarMenuItem2 = item10;
                    }
                    i13 = 8;
                    item3.setVisibility(i13);
                    i4 = item3.getVisibility();
                    i3 = i12;
                } else {
                    actionBarMenuItem2 = item10;
                    i3 = 8;
                    i4 = 8;
                }
                if (item7 != null) {
                    item7.setVisibility(this.cantDeleteMessagesCount == 0 ? 0 : 8);
                }
                this.hasUnfavedSelected = false;
                int i20 = 0;
                while (true) {
                    actionBarMenuItem3 = item;
                    if (i20 >= 2) {
                        actionBarMenuItem4 = item6;
                        break;
                    }
                    int i21 = 0;
                    while (true) {
                        if (i21 >= this.selectedMessagesCanStarIds[i20].size()) {
                            actionBarMenuItem4 = item6;
                            break;
                        }
                        MessageObject valueAt = this.selectedMessagesCanStarIds[i20].valueAt(i21);
                        actionBarMenuItem4 = item6;
                        if (valueAt != null && !getMediaDataController().isStickerInFavorites(valueAt.getDocument())) {
                            this.hasUnfavedSelected = true;
                            break;
                        } else {
                            i21++;
                            item6 = actionBarMenuItem4;
                        }
                    }
                    if (this.hasUnfavedSelected) {
                        break;
                    }
                    i20++;
                    item = actionBarMenuItem3;
                    item6 = actionBarMenuItem4;
                }
                if (item3 != null) {
                    item3.setIcon(this.hasUnfavedSelected ? R.drawable.msg_fave : R.drawable.msg_unfave);
                }
                final int i22 = (this.canEditMessagesCount == 1 && size == 1 && !PlusSettings.hideEditActionModeButton) ? 0 : 8;
                createBottomMessagesActionButtons();
                if (this.replyButton != null) {
                    BlurredFrameLayout blurredFrameLayout2 = this.bottomOverlayChat;
                    boolean z4 = (blurredFrameLayout2 == null || blurredFrameLayout2.getVisibility() != 0 || this.bottomOverlayChatWaitsReply) && ((chat = this.currentChat) == null || ((!ChatObject.isNotInChat(chat) || isThreadChat()) && ((!ChatObject.isChannel(this.currentChat) || ChatObject.canPost(this.currentChat) || this.currentChat.megagroup) && ChatObject.canSendMessages(this.currentChat))));
                    if (this.chatMode != 1 && z4 && (this.selectedMessagesIds[0].size() == 0 || this.selectedMessagesIds[1].size() == 0)) {
                        if (size == 1) {
                            char c3 = 0;
                            int size2 = this.selectedMessagesIds[0].size();
                            int i23 = 0;
                            while (true) {
                                if (i23 >= size2) {
                                    i11 = 0;
                                    break;
                                }
                                int i24 = size2;
                                MessageObject valueAt2 = this.selectedMessagesIds[c3].valueAt(i23);
                                if (ChatObject.isForum(this.currentChat) && !canSendMessageToTopic(valueAt2)) {
                                    i11 = 8;
                                    break;
                                } else {
                                    i23++;
                                    size2 = i24;
                                    c3 = 0;
                                }
                            }
                            i10 = i11;
                        } else {
                            int i25 = 0;
                            int i26 = 0;
                            long j = 0;
                            for (int i27 = 2; i25 < i27; i27 = 2) {
                                int size3 = this.selectedMessagesIds[i25].size();
                                int i28 = i26;
                                int i29 = 0;
                                while (i29 < size3) {
                                    int i30 = size3;
                                    MessageObject valueAt3 = this.selectedMessagesIds[i25].valueAt(i29);
                                    long groupId = valueAt3.getGroupId();
                                    if (groupId == 0 || !(j == 0 || j == groupId)) {
                                        actionBarMenuItem7 = item3;
                                    } else {
                                        actionBarMenuItem7 = item3;
                                        if (!ChatObject.isForum(this.currentChat) || canSendMessageToTopic(valueAt3)) {
                                            i29++;
                                            size3 = i30;
                                            j = groupId;
                                            item3 = actionBarMenuItem7;
                                        }
                                    }
                                    i26 = 8;
                                    break;
                                }
                                actionBarMenuItem7 = item3;
                                i26 = i28;
                                if (i26 == 8) {
                                    i10 = i26;
                                    break;
                                } else {
                                    i25++;
                                    item3 = actionBarMenuItem7;
                                }
                            }
                            i10 = i26;
                        }
                        actionBarMenuItem7 = item3;
                    } else {
                        actionBarMenuItem7 = item3;
                        i10 = 8;
                    }
                    if (this.threadMessageObjects != null && i10 == 0) {
                        char c4 = 0;
                        int size4 = this.selectedMessagesIds[0].size();
                        int i31 = 0;
                        while (i31 < size4) {
                            if (this.threadMessageObjects.contains(this.selectedMessagesIds[c4].valueAt(i31))) {
                                i10 = 8;
                            }
                            i31++;
                            c4 = 0;
                        }
                    }
                    final int i32 = i10;
                    if (this.replyButton.getVisibility() != i32) {
                        AnimatorSet animatorSet2 = this.replyButtonAnimation;
                        if (animatorSet2 != null) {
                            animatorSet2.cancel();
                        }
                        AnimatorSet animatorSet3 = new AnimatorSet();
                        this.replyButtonAnimation = animatorSet3;
                        if (i32 == 0) {
                            this.replyButton.setVisibility(i32);
                            actionBarMenuItem5 = item8;
                            actionBarMenuItem6 = item9;
                            z = z3;
                            this.replyButtonAnimation.playTogether(ObjectAnimator.ofFloat(this.replyButton, (Property<TextView, Float>) View.ALPHA, 1.0f), ObjectAnimator.ofFloat(this.replyButton, (Property<TextView, Float>) View.SCALE_Y, 1.0f));
                        } else {
                            actionBarMenuItem5 = item8;
                            actionBarMenuItem6 = item9;
                            z = z3;
                            animatorSet3.playTogether(ObjectAnimator.ofFloat(this.replyButton, (Property<TextView, Float>) View.ALPHA, 0.0f), ObjectAnimator.ofFloat(this.replyButton, (Property<TextView, Float>) View.SCALE_Y, 0.0f));
                        }
                        this.replyButtonAnimation.setDuration(100L);
                        this.replyButtonAnimation.addListener(new AnimatorListenerAdapter() {
                            @Override
                            public void onAnimationEnd(Animator animation) {
                                if (ChatActivity.this.replyButtonAnimation == null || !ChatActivity.this.replyButtonAnimation.equals(animation) || ChatActivity.this.replyButton == null || i32 != 8) {
                                    return;
                                }
                                ChatActivity.this.replyButton.setVisibility(8);
                            }

                            @Override
                            public void onAnimationCancel(Animator animation) {
                                if (ChatActivity.this.replyButtonAnimation == null || !ChatActivity.this.replyButtonAnimation.equals(animation)) {
                                    return;
                                }
                                ChatActivity.this.replyButtonAnimation = null;
                            }
                        });
                        this.replyButtonAnimation.start();
                    } else {
                        actionBarMenuItem5 = item8;
                        actionBarMenuItem6 = item9;
                        z = z3;
                    }
                    this.directShareButton.setVisibility((size <= 1 || i32 == 0 || getMessagesController().isChatNoForwards(this.currentChat)) ? 8 : 0);
                    if (!this.selecting) {
                        this.canSelectMessages = false;
                        if (item11 != null) {
                            if (size > 1) {
                                int i33 = 0;
                                long j2 = 0;
                                for (int i34 = 2; i33 < i34; i34 = 2) {
                                    int size5 = this.selectedMessagesIds[i33].size();
                                    long j3 = j2;
                                    int i35 = 0;
                                    while (i35 < size5) {
                                        MessageObject valueAt4 = this.selectedMessagesIds[i33].valueAt(i35);
                                        long groupId2 = valueAt4.getGroupId();
                                        int i36 = i33;
                                        long id = valueAt4.getId();
                                        long abs = Math.abs(j3 - (id != 0 ? id : groupId2));
                                        int i37 = size5;
                                        int i38 = i3;
                                        long j4 = this.minSelectedMessageId;
                                        if (j4 <= 0) {
                                            j4 = j3;
                                        }
                                        this.minSelectedMessageId = Math.min(id, j4);
                                        long j5 = this.maxSelectedMessageId;
                                        if (j5 <= 0) {
                                            j5 = j3;
                                        }
                                        this.maxSelectedMessageId = Math.max(id, j5);
                                        if (abs > 1 && j3 > 0 && !PlusSettings.hideSelectMessagesActionModeButton) {
                                            item11.setVisibility(0);
                                            if (this.minSelectedMessageId > 0 && this.maxSelectedMessageId > 0) {
                                                this.canSelectMessages = true;
                                            }
                                        } else if (!this.canSelectMessages) {
                                            item11.setVisibility(8);
                                        }
                                        j3 = id != 0 ? id : groupId2;
                                        i35++;
                                        i3 = i38;
                                        i33 = i36;
                                        size5 = i37;
                                    }
                                    i33++;
                                    j2 = j3;
                                }
                            } else {
                                i5 = i3;
                                item11.setVisibility(8);
                            }
                        }
                    }
                    i5 = i3;
                } else {
                    actionBarMenuItem5 = item8;
                    actionBarMenuItem6 = item9;
                    z = z3;
                    i5 = i3;
                    actionBarMenuItem7 = item3;
                }
                if (item4 != null) {
                    if (i2 != i || i5 != i4) {
                        if (i22 == 0) {
                            item4.setAlpha(1.0f);
                            item4.setScaleX(1.0f);
                        } else {
                            item4.setAlpha(0.0f);
                            item4.setScaleX(0.0f);
                        }
                        item4.setVisibility(i22);
                    } else if (item4.getVisibility() != i22) {
                        AnimatorSet animatorSet4 = this.editButtonAnimation;
                        if (animatorSet4 != null) {
                            animatorSet4.cancel();
                        }
                        this.editButtonAnimation = new AnimatorSet();
                        item4.setPivotX(AndroidUtilities.dp(this.actionModePadding));
                        item4.setPivotX(AndroidUtilities.dp(this.actionModePadding));
                        if (i22 == 0) {
                            item4.setVisibility(i22);
                            this.editButtonAnimation.playTogether(ObjectAnimator.ofFloat(item4, (Property<ActionBarMenuItem, Float>) View.ALPHA, 1.0f), ObjectAnimator.ofFloat(item4, (Property<ActionBarMenuItem, Float>) View.SCALE_X, 1.0f));
                        } else {
                            this.editButtonAnimation.playTogether(ObjectAnimator.ofFloat(item4, (Property<ActionBarMenuItem, Float>) View.ALPHA, 0.0f), ObjectAnimator.ofFloat(item4, (Property<ActionBarMenuItem, Float>) View.SCALE_X, 0.0f));
                        }
                        this.editButtonAnimation.setDuration(100L);
                        this.editButtonAnimation.addListener(new AnimatorListenerAdapter() {
                            @Override
                            public void onAnimationEnd(Animator animation) {
                                if (ChatActivity.this.editButtonAnimation != null && ChatActivity.this.editButtonAnimation.equals(animation) && i22 == 8) {
                                    item4.setVisibility(8);
                                }
                            }

                            @Override
                            public void onAnimationCancel(Animator animation) {
                                if (ChatActivity.this.editButtonAnimation == null || !ChatActivity.this.editButtonAnimation.equals(animation)) {
                                    return;
                                }
                                ChatActivity.this.editButtonAnimation = null;
                            }
                        });
                        this.editButtonAnimation.start();
                    }
                }
                if (actionBarMenuItem6 != null) {
                    boolean z5 = size == 1 && !z;
                    if (z5) {
                        boolean z6 = false;
                        for (int i39 = 0; i39 < 2; i39++) {
                            for (int i40 = 0; i40 < this.selectedMessagesIds[i39].size(); i40++) {
                                MessageObject valueAt5 = this.selectedMessagesIds[i39].valueAt(i40);
                                if (valueAt5 != null && !valueAt5.isVoiceOnce() && !valueAt5.isRoundOnce() && !valueAt5.messageOwner.noforwards && (valueAt5.isVoice() || valueAt5.isRoundVideo())) {
                                    z6 = true;
                                }
                            }
                        }
                        z5 = z6;
                    }
                    actionBarMenuItem8 = actionBarMenuItem6;
                    actionBarMenuItem8.setVisibility(z5 ? 0 : 8);
                } else {
                    actionBarMenuItem8 = actionBarMenuItem6;
                }
                if (actionBarMenuItem5 != null) {
                    if (getUserConfig().isPremium()) {
                        if (((item4 == null || item4.getVisibility() != 0) ? 0 : 1) + ((actionBarMenuItem4 == null || actionBarMenuItem4.getVisibility() != 0) ? 0 : 1) + ((actionBarMenuItem3 == null || actionBarMenuItem3.getVisibility() != 0) ? 0 : 1) + ((item2 == null || item2.getVisibility() != 0) ? 0 : 1) + ((item7 == null || item7.getVisibility() != 0) ? 0 : 1) + ((actionBarMenuItem7 == null || actionBarMenuItem7.getVisibility() != 0) ? 0 : 1) + ((actionBarMenuItem8 == null || actionBarMenuItem8.getVisibility() != 0) ? 0 : 1) < 4) {
                            actionBarMenuItem11 = actionBarMenuItem5;
                            i9 = 0;
                            actionBarMenuItem11.setVisibility(i9);
                        }
                    }
                    actionBarMenuItem11 = actionBarMenuItem5;
                    i9 = 8;
                    actionBarMenuItem11.setVisibility(i9);
                }
                this.scheduleDownloadButton.setVisibility((this.scheduledDownloadsMode || (i8 = this.canSqueduleCount) < 1 || i8 < this.selectedMessagesIds[0].size()) ? 8 : 0);
                if (actionBarMenuItem2 != null) {
                    ActionBarMenuItem item12 = ((BaseFragment) this).actionBar.createActionMode().getItem(82);
                    if (item12 != null) {
                        item12.setVisibility((getMessagesController().isChatNoForwards(this.currentChat) || PlusSettings.hideDirectShareActionModeButton) ? 8 : 0);
                        if ((item12.getVisibility() != 0 || (((blurredFrameLayout = this.searchContainer) != null && blurredFrameLayout.getVisibility() == 0) || !(item11 == null || item11.getVisibility() == 0))) && !getMessagesController().isChatNoForwards(this.currentChat)) {
                            actionBarMenuItem10 = actionBarMenuItem2;
                            i7 = 0;
                        } else {
                            actionBarMenuItem10 = actionBarMenuItem2;
                            i7 = 8;
                        }
                        actionBarMenuItem10.setVisibility(i7);
                    } else {
                        actionBarMenuItem10 = actionBarMenuItem2;
                    }
                    if (this.selectedMessagesIds[0].size() <= 1) {
                        actionBarMenuItem10.setVisibility(((item2.getVisibility() == 0 && actionBarMenuItem != null && actionBarMenuItem.getVisibility() == 0) || getMessagesController().isChatNoForwards(this.currentChat)) ? 8 : 0);
                    }
                    if (PlusSettings.hideBackupActionModeButton || (item4 != null && item4.getVisibility() == 0 && this.selectedMessagesIds[0].size() <= 1 && AndroidUtilities.displaySize.x < 1000)) {
                        actionBarMenuItem10.setVisibility(8);
                    }
                    if (actionBarMenuItem3.getVisibility() == 0) {
                        if (item12.getVisibility() == 0 && this.selectedMessagesIds[0].size() > 1) {
                            this.directShareButton.getVisibility();
                        }
                        if (item2.getVisibility() == 0 && ((i22 == 0 || item4.getVisibility() == 0) && item12.getVisibility() == 0)) {
                            actionBarMenuItem9 = item2;
                            actionBarMenuItem9.setVisibility(8);
                        } else {
                            actionBarMenuItem9 = item2;
                        }
                        if (actionBarMenuItem10.getVisibility() == 0 && actionBarMenuItem9.getVisibility() == 0 && item11.getVisibility() == 0 && this.selectedMessagesIds[0].size() > 1 && AndroidUtilities.displaySize.x < 1000) {
                            actionBarMenuItem10.setVisibility(8);
                        }
                    } else {
                        actionBarMenuItem9 = item2;
                    }
                    if (actionBarMenuItem10.getVisibility() == 0 && getDialogId() == getUserConfig().getClientUserId() && ((i6 = this.chatMode) == 0 || i6 == 3)) {
                        actionBarMenuItem10.setVisibility(8);
                    }
                } else {
                    actionBarMenuItem9 = item2;
                }
                if (this.selectedMessagesIds[0].size() <= 1 && actionBarMenuItem != null && actionBarMenuItem.getVisibility() == 0 && ((item4 != null && item4.getVisibility() == 0 && actionBarMenuItem9.getVisibility() == 0) || actionBarMenuItem7.getVisibility() == 0)) {
                    actionBarMenuItem.setVisibility(8);
                }
                try {
                    if (PlusSettings.hideForwardWithoutQuotingActionModeButton) {
                        ((BaseFragment) this).actionBar.createActionMode().getItem(11).setVisibility(8);
                    }
                    if (PlusSettings.hideForwardActionModeButton) {
                        ((BaseFragment) this).actionBar.createActionMode().getItem(111).setVisibility(8);
                    }
                    if (PlusSettings.hideCopyActionModeButton) {
                        ((BaseFragment) this).actionBar.createActionMode().getItem(10).setVisibility(8);
                    }
                    if (PlusSettings.hideDeleteActionModeButton) {
                        ((BaseFragment) this).actionBar.createActionMode().getItem(12).setVisibility(8);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        updateSelectedMessageReactions();
    }

    public final 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 valueAt = this.selectedMessagesIds[i].valueAt(i2);
                    if (valueAt.hasValidGroupId()) {
                        MessageObject.GroupedMessages validGroupedMessage = getValidGroupedMessage(valueAt);
                        MessageObject.GroupedMessagePosition position = validGroupedMessage != null ? validGroupedMessage.getPosition(valueAt) : null;
                        if (position != null) {
                            if (!position.last) {
                            }
                        }
                    }
                    arrayList.add(valueAt);
                }
            }
            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$162();
                    }
                }, 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<MessageObject> sparseArray = this.selectedMessagesIds[0];
            for (int i3 = 0; i3 < sparseArray.size(); i3++) {
                arrayList2.add(sparseArray.valueAt(i3));
            }
            SparseArray<MessageObject> sparseArray2 = this.selectedMessagesIds[1];
            for (int i4 = 0; i4 < sparseArray2.size(); i4++) {
                arrayList2.add(sparseArray2.valueAt(i4));
            }
            this.selectionReactionsOverlay.setSelectedMessages(arrayList2);
        }
    }

    public void lambda$updateSelectedMessageReactions$162() {
        ReactionsContainerLayout reactionsContainerLayout = this.tagSelector;
        if (reactionsContainerLayout != null) {
            reactionsContainerLayout.requestLayout();
        }
    }

    public final void processRowSelect(View view, boolean outside, float touchX, float touchY) {
        MessageObject messageObject;
        if (view instanceof ChatMessageCell) {
            ChatMessageCell chatMessageCell = (ChatMessageCell) view;
            messageObject = chatMessageCell.getMessageObject();
            chatMessageCell.setLastTouchCoords(touchX, touchY);
        } 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 || messageObject.type != 27) {
                if (messageObject == null || !messageObject.isWallpaperAction()) {
                    addToSelectedMessages(messageObject, outside);
                    updateActionModeTitle();
                    updateVisibleRows();
                }
            }
        }
    }

    public final void updateActionModeTitle() {
        if (this.reportType < 0) {
            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("ReportMessages", 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 updateTitle(boolean animated) {
        TLRPC.Chat chat;
        if (this.avatarContainer == null) {
            return;
        }
        int i = this.chatMode;
        if (i == 5) {
            if ("hello".equalsIgnoreCase(this.quickReplyShortcut)) {
                this.avatarContainer.setTitle(LocaleController.getString(R.string.BusinessGreet));
            } else if ("away".equalsIgnoreCase(this.quickReplyShortcut)) {
                this.avatarContainer.setTitle(LocaleController.getString(R.string.BusinessAway));
            } else {
                this.avatarContainer.setTitle(this.quickReplyShortcut);
            }
        } else if (i == 6) {
            if (!TextUtils.isEmpty(this.businessLink.title)) {
                this.avatarContainer.setTitle(this.businessLink.title);
            } else {
                this.avatarContainer.setTitle(LocaleController.getString(R.string.BusinessLink));
            }
        } else if (i == 3) {
            long j = this.threadMessageId;
            TLRPC.User user = null;
            if (j > 0) {
                user = getMessagesController().getUser(Long.valueOf(j));
                chat = null;
            } else {
                chat = getMessagesController().getChat(Long.valueOf(-j));
            }
            if (UserObject.isReplyUser(user)) {
                this.avatarContainer.setTitle(LocaleController.getString("RepliesTitle", R.string.RepliesTitle));
            } else if (UserObject.isAnonymous(user)) {
                this.avatarContainer.setTitle(LocaleController.getString(R.string.AnonymousForward));
            } else if (UserObject.isUserSelf(user)) {
                this.avatarContainer.setTitle(LocaleController.getString(R.string.MyNotes));
            } else if (user != null) {
                this.avatarContainer.setTitle(UserObject.getUserName(user));
            } else if (chat != null) {
                this.avatarContainer.setTitle(chat.title);
            } else {
                this.avatarContainer.setTitle("");
            }
        } else if (isThreadChat()) {
            if (this.isTopic) {
                updateTopicHeader();
            } else if (this.isComments) {
                if (this.threadMessageObject.hasReplies()) {
                    this.avatarContainer.setTitle(LocaleController.formatPluralString("Comments", this.threadMessageObject.getRepliesCount(), new Object[0]));
                } else {
                    this.avatarContainer.setTitle(LocaleController.getString("CommentsTitle", R.string.CommentsTitle));
                }
            } else {
                this.avatarContainer.setTitle(LocaleController.formatPluralString("Replies", this.threadMessageObject.getRepliesCount(), new Object[0]));
            }
        } else if (UserObject.isReplyUser(this.currentUser)) {
            this.avatarContainer.setTitle(LocaleController.getString("RepliesTitle", R.string.RepliesTitle));
        } else if (UserObject.isAnonymous(this.currentUser)) {
            this.avatarContainer.setTitle(LocaleController.getString(R.string.AnonymousForward));
        } else {
            int i2 = this.chatMode;
            if (i2 == 1) {
                if (UserObject.isUserSelf(this.currentUser)) {
                    this.avatarContainer.setTitle(LocaleController.getString("Reminders", R.string.Reminders));
                    if (this.scheduledDownloadsMode) {
                        this.avatarContainer.setTitle(LocaleController.getString("ScheduledDownloads", R.string.ScheduledDownloads));
                        this.avatarContainer.getAvatarImageView().setVisibility(8);
                    }
                } else {
                    this.avatarContainer.setTitle(LocaleController.getString("ScheduledMessages", R.string.ScheduledMessages));
                }
            } else if (i2 == 2) {
                this.avatarContainer.setTitle(LocaleController.formatPluralString("PinnedMessagesCount", getPinnedMessagesCount(), new Object[0]));
            } else {
                TLRPC.Chat chat2 = this.currentChat;
                if (chat2 != null) {
                    this.avatarContainer.setTitle(chat2.title, chat2.scam, chat2.fake, chat2.verified, false, chat2.emoji_status, animated);
                } else {
                    TLRPC.User user2 = this.currentUser;
                    if (user2 != null) {
                        if (user2.self) {
                            this.avatarContainer.setTitle(LocaleController.getString("SavedMessages", R.string.SavedMessages));
                        } else if (!MessagesController.isSupportUser(user2) && getContactsController().contactsDict.get(Long.valueOf(this.currentUser.id)) == null && (getContactsController().contactsDict.size() != 0 || !getContactsController().isLoadingContacts())) {
                            if (!TextUtils.isEmpty(this.currentUser.phone)) {
                                ChatAvatarContainer chatAvatarContainer = this.avatarContainer;
                                String format = PhoneFormat.getInstance().format("+" + this.currentUser.phone);
                                TLRPC.User user3 = this.currentUser;
                                chatAvatarContainer.setTitle(format, user3.scam, user3.fake, user3.verified, getMessagesController().isPremiumUser(this.currentUser), this.currentUser.emoji_status, animated);
                            } else {
                                ChatAvatarContainer chatAvatarContainer2 = this.avatarContainer;
                                String userName = UserObject.getUserName(this.currentUser);
                                TLRPC.User user4 = this.currentUser;
                                chatAvatarContainer2.setTitle(userName, user4.scam, user4.fake, user4.verified, getMessagesController().isPremiumUser(this.currentUser), this.currentUser.emoji_status, animated);
                            }
                        } else {
                            ChatAvatarContainer chatAvatarContainer3 = this.avatarContainer;
                            String userName2 = UserObject.getUserName(this.currentUser);
                            TLRPC.User user5 = this.currentUser;
                            chatAvatarContainer3.setTitle(userName2, user5.scam, user5.fake, user5.verified, getMessagesController().isPremiumUser(this.currentUser), this.currentUser.emoji_status, animated);
                        }
                    }
                }
            }
        }
        setParentActivityTitle(this.avatarContainer.getTitleTextView().getText());
    }

    public final 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 final int getPinnedMessagesCount() {
        return Math.max(this.loadedPinnedMessagesCount, this.totalPinnedMessagesCount);
    }

    public final 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);
        }
    }

    public final 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++) {
                TLRPC.BotInfo botInfo = (TLRPC.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);
        }
        if (z) {
            this.headerItem.showSubItem(31);
        } else {
            this.headerItem.hideSubItem(31);
        }
    }

    public final void updateTitleIcons() {
        updateTitleIcons(false);
    }

    public final void updateTitleIcons(boolean forceToggleMuted) {
        ActionBarMenuItem.Item item;
        if (this.avatarContainer == null || this.chatMode != 0) {
            return;
        }
        boolean isDialogMuted = getMessagesController().isDialogMuted(this.dialog_id, getTopicId());
        if (forceToggleMuted) {
            isDialogMuted = !isDialogMuted;
        }
        this.avatarContainer.setTitleIcons(this.currentEncryptedChat != null ? getThemedDrawable("drawableLockIcon") : null, (UserObject.isReplyUser(this.currentUser) || (isThreadChat() && !this.isTopic) || !isDialogMuted) ? null : getThemedDrawable("drawableMuteIcon"));
        if (!forceToggleMuted && (item = this.muteItem) != null) {
            if (isDialogMuted) {
                item.setRightIconVisibility(8);
                this.muteItem.setText(LocaleController.getString("Unmute", R.string.Unmute));
                this.muteItem.setIcon(R.drawable.msg_mute);
            } else {
                item.setRightIconVisibility(0);
                if (getMessagesController().isDialogNotificationsSoundEnabled(this.dialog_id, getTopicId())) {
                    this.muteItem.setText(LocaleController.getString("Mute", R.string.Mute));
                    this.muteItem.setIcon(R.drawable.msg_unmute);
                } else {
                    this.muteItem.setText(LocaleController.getString("Mute", R.string.Mute));
                    this.muteItem.setIcon(R.drawable.msg_silent);
                }
            }
        }
        ChatNotificationsPopupWrapper chatNotificationsPopupWrapper = this.chatNotificationsPopupWrapper;
        if (chatNotificationsPopupWrapper != null) {
            chatNotificationsPopupWrapper.update(this.dialog_id, getTopicId(), (HashSet) null);
        }
    }

    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 void openVideoEditor(String videoPath, String caption) {
        if (getParentActivity() != null) {
            final Bitmap createVideoThumbnail = SendMessagesHelper.createVideoThumbnail(videoPath, 1);
            PhotoViewer.getInstance().setParentActivity(this, this.themeDelegate);
            final ArrayList<Object> arrayList = new ArrayList<>();
            MediaController.PhotoEntry photoEntry = new MediaController.PhotoEntry(0, 0, 0L, videoPath, 0, true, 0, 0, 0L);
            ((MediaController.MediaEditState) photoEntry).caption = caption;
            arrayList.add(photoEntry);
            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 index) {
                    return new ImageReceiver.BitmapHolder(createVideoThumbnail, (String) null, 0);
                }

                @Override
                public void sendButtonPressed(int index, VideoEditedInfo videoEditedInfo, boolean notify, int scheduleDate, boolean forceDocument) {
                    ChatActivity.this.sendMedia((MediaController.PhotoEntry) arrayList.get(0), videoEditedInfo, notify, scheduleDate, forceDocument);
                }
            }, this);
            return;
        }
        fillEditingMediaWithCaption(caption, null);
        SendMessagesHelper.prepareSendingVideo(getAccountInstance(), videoPath, (VideoEditedInfo) 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);
        afterMessageSend();
    }

    public String getRealPathFromURI(Uri contentURI) {
        String str;
        Cursor query = getParentActivity().getContentResolver().query(contentURI, null, null, null, null);
        if (query == null) {
            return contentURI.getPath();
        }
        query.moveToFirst();
        try {
            str = query.getString(query.getColumnIndex("_data"));
        } catch (Exception unused) {
            str = "";
        }
        query.close();
        return str;
    }

    public boolean openImageEditor(ArrayList<SendMessagesHelper.SendingMediaInfo> photoPathsArray, long did, String imagePath, CharSequence caption) {
        int i;
        final ArrayList arrayList = new ArrayList();
        CharSequence charSequence = caption;
        int i2 = 0;
        while (true) {
            String str = null;
            if (i2 >= photoPathsArray.size()) {
                break;
            }
            SendMessagesHelper.SendingMediaInfo sendingMediaInfo = photoPathsArray.get(i2);
            if (i2 == 0) {
                charSequence = sendingMediaInfo.caption;
            }
            CharSequence charSequence2 = charSequence;
            String str2 = sendingMediaInfo.path;
            if (str2 != null) {
                str = str2;
            } 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();
                    str = generatePicturePath.getAbsolutePath();
                } catch (Exception unused) {
                }
            }
            if (str != null) {
                try {
                    int attributeInt = new ExifInterface(str).getAttributeInt("Orientation", 1);
                    i = attributeInt != 3 ? attributeInt != 6 ? attributeInt != 8 ? 0 : 270 : 90 : 180;
                } catch (Exception e) {
                    FileLog.e(e);
                    i = 0;
                }
                MediaController.PhotoEntry photoEntry = new MediaController.PhotoEntry(0, 0, 0L, str, i, sendingMediaInfo.isVideo, 0, 0, 0L);
                if (i2 == photoPathsArray.size() - 1 && charSequence2 != null) {
                    ((MediaController.MediaEditState) photoEntry).caption = charSequence2;
                }
                arrayList.add(photoEntry);
            }
            i2++;
            charSequence = charSequence2;
        }
        if (arrayList.isEmpty()) {
            return false;
        }
        Uri uri = photoPathsArray.get(0).uri;
        if (imagePath == null && getRealPathFromURI(uri) == null) {
            AndroidUtilities.getTempFilePath(uri);
        }
        if (getParentActivity() != null) {
            try {
                final Bitmap bitmap = MediaStore.Images.Media.getBitmap(ApplicationLoader.applicationContext.getContentResolver(), uri);
                final boolean[] zArr = new boolean[arrayList.size()];
                Arrays.fill(zArr, true);
                PhotoViewer.getInstance().setParentActivity(getParentActivity(), this.themeDelegate);
                PhotoViewer.getInstance().openPhotoForSelect(new ArrayList<>(arrayList), arrayList.size() - 1, 2, false, new PhotoViewer.EmptyPhotoViewerProvider() {
                    @Override
                    public boolean canScrollAway() {
                        return false;
                    }

                    @Override
                    public ImageReceiver.BitmapHolder getThumbForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) {
                        return new ImageReceiver.BitmapHolder(bitmap, (String) null, 0);
                    }

                    @Override
                    public void sendButtonPressed(int index, VideoEditedInfo videoEditedInfo, boolean notify, int scheduleDate, boolean forceDocument) {
                        for (int size = arrayList.size() - 1; size >= 0; size--) {
                            if (!zArr[size]) {
                                arrayList.remove(size);
                            }
                        }
                        ChatActivity.this.sendPhotosGroup(arrayList, notify, scheduleDate, forceDocument);
                    }
                }, this);
                return true;
            } catch (FileNotFoundException e2) {
                e2.printStackTrace();
                return false;
            } catch (IOException e3) {
                e3.printStackTrace();
                return false;
            }
        }
        fillEditingMediaWithCaption(charSequence, null);
        SendMessagesHelper.prepareSendingMedia(getAccountInstance(), photoPathsArray, did, (MessageObject) null, getThreadMessage(), (TL_stories.StoryItem) null, this.replyingQuote, false, false, (MessageObject) null, true, 0, 0, false, (InputContentInfoCompat) null, this.quickReplyShortcut, getQuickReplyId(), 0L, false);
        afterMessageSend();
        return false;
    }

    public final void sendPhotosGroup(ArrayList<MediaController.PhotoEntry> entries, boolean notify, int scheduleDate, boolean forceDocument) {
        String str;
        if (!entries.isEmpty()) {
            ArrayList arrayList = new ArrayList();
            Iterator<MediaController.PhotoEntry> it = entries.iterator();
            while (it.hasNext()) {
                MediaController.PhotoEntry next = it.next();
                SendMessagesHelper.SendingMediaInfo sendingMediaInfo = new SendMessagesHelper.SendingMediaInfo();
                boolean z = next.isVideo;
                if (!z && (str = ((MediaController.MediaEditState) next).imagePath) != null) {
                    sendingMediaInfo.path = str;
                } else {
                    String str2 = next.path;
                    if (str2 != null) {
                        sendingMediaInfo.path = str2;
                    }
                }
                sendingMediaInfo.thumbPath = ((MediaController.MediaEditState) next).thumbPath;
                sendingMediaInfo.isVideo = z;
                CharSequence charSequence = ((MediaController.MediaEditState) next).caption;
                sendingMediaInfo.caption = charSequence != null ? charSequence.toString() : null;
                sendingMediaInfo.entities = ((MediaController.MediaEditState) next).entities;
                sendingMediaInfo.masks = ((MediaController.MediaEditState) next).stickers;
                sendingMediaInfo.ttl = ((MediaController.MediaEditState) next).ttl;
                sendingMediaInfo.videoEditedInfo = ((MediaController.MediaEditState) next).editedInfo;
                sendingMediaInfo.canDeleteAfter = next.canDeleteAfter;
                arrayList.add(sendingMediaInfo);
                next.reset();
            }
            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, forceDocument, true, (MessageObject) null, notify, scheduleDate, this.chatMode, ((SendMessagesHelper.SendingMediaInfo) arrayList.get(0)).updateStickersOrder, (InputContentInfoCompat) null, this.quickReplyShortcut, getQuickReplyId(), 0L, false);
            afterMessageSend();
            ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
            if (chatActivityEnterView != null) {
                chatActivityEnterView.setFieldText("");
            }
        }
        if (scheduleDate != 0) {
            if (this.scheduledMessagesCount == -1) {
                this.scheduledMessagesCount = 0;
            }
            this.scheduledMessagesCount += entries.size();
            updateScheduledInterface(true);
        }
    }

    public final void openEditingMessageInPhotoEditor() {
        MessageObject messageObject = this.editingMessageObject;
        if (messageObject != null && messageObject.canEditMedia() && this.editingMessageObjectReqId == 0) {
            if (this.editingMessageObject.isPhoto() || this.editingMessageObject.isVideo()) {
                final MessageObject messageObject2 = this.editingMessageObject;
                File file = null;
                if (!TextUtils.isEmpty(messageObject2.messageOwner.attachPath)) {
                    File file2 = new File(messageObject2.messageOwner.attachPath);
                    if (file2.exists()) {
                        file = file2;
                    }
                }
                if (file == null) {
                    file = FileLoader.getInstance(((BaseFragment) this).currentAccount).getPathToMessage(messageObject2.messageOwner);
                }
                if (file.exists()) {
                    PhotoViewer.getInstance().setParentActivity(this, this.themeDelegate);
                    ArrayList<Object> arrayList = new ArrayList<>();
                    final MediaController.PhotoEntry photoEntry = new MediaController.PhotoEntry(0, 0, 0L, file.getAbsolutePath(), 0, messageObject2.isVideo(), 0, 0, 0L);
                    ((MediaController.MediaEditState) photoEntry).caption = this.chatActivityEnterView.getFieldText();
                    arrayList.add(photoEntry);
                    PhotoViewer.getInstance().openPhotoForSelect(arrayList, 0, 2, false, new PhotoViewer.EmptyPhotoViewerProvider() {
                        @Override
                        public boolean allowSendingSubmenu() {
                            return false;
                        }

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

                        @Override
                        public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject3, TLRPC.FileLocation fileLocation, int index, boolean needPreview) {
                            return ChatActivity.this.getPlaceForPhoto(messageObject2, null, needPreview, true);
                        }

                        @Override
                        public void sendButtonPressed(int index, VideoEditedInfo videoEditedInfo, boolean notify, int scheduleDate, boolean forceDocument) {
                            ChatActivity chatActivity = ChatActivity.this;
                            if (chatActivity.editingMessageObject != messageObject2) {
                                return;
                            }
                            MediaController.PhotoEntry photoEntry2 = photoEntry;
                            if (((MediaController.MediaEditState) photoEntry2).isCropped || ((MediaController.MediaEditState) photoEntry2).isPainted || ((MediaController.MediaEditState) photoEntry2).isFiltered || videoEditedInfo != null) {
                                chatActivity.sendMedia(photoEntry2, videoEditedInfo, notify, scheduleDate, forceDocument);
                            } else {
                                chatActivity.chatActivityEnterView.doneEditingMessage();
                            }
                        }

                        @Override
                        public MessageObject getEditingMessageObject() {
                            MessageObject messageObject3 = ChatActivity.this.editingMessageObject;
                            MessageObject messageObject4 = messageObject2;
                            if (messageObject3 == messageObject4) {
                                return messageObject4;
                            }
                            return null;
                        }

                        @Override
                        public void onApplyCaption(CharSequence caption) {
                            ChatActivity.this.chatActivityEnterView.setFieldText(caption, true);
                        }

                        @Override
                        public boolean closeKeyboard() {
                            ChatActivity chatActivity = ChatActivity.this;
                            if (chatActivity.chatActivityEnterView == null || !chatActivity.isKeyboardVisible()) {
                                return false;
                            }
                            ChatActivity.this.chatActivityEnterView.closeKeyboard();
                            return true;
                        }
                    }, this);
                }
            }
        }
    }

    public final PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, boolean needPreview, boolean onlyIfVisible) {
        ChatActionCell chatActionCell;
        MessageObject messageObject2;
        ImageReceiver imageReceiver;
        ImageReceiver photoImage;
        TLRPC.Message message;
        TLRPC.MessageAction messageAction;
        TLRPC.Photo photo;
        ArrayList arrayList;
        TLRPC.FileLocation fileLocation2;
        TLRPC.Chat chat;
        ChatMessageCell chatMessageCell;
        MessageObject messageObject3;
        int childCount = this.chatListView.getChildCount();
        for (int i = 0; i < childCount; i++) {
            View childAt = this.chatListView.getChildAt(i);
            if (childAt instanceof ChatMessageCell) {
                if (messageObject != null && (messageObject3 = (chatMessageCell = (ChatMessageCell) childAt).getMessageObject()) != null && messageObject3.getId() == messageObject.getId()) {
                    photoImage = chatMessageCell.getPhotoImage();
                }
                photoImage = null;
            } else {
                if ((childAt instanceof ChatActionCell) && (messageObject2 = (chatActionCell = (ChatActionCell) childAt).getMessageObject()) != null) {
                    if (messageObject != null) {
                        if (messageObject2.getId() == messageObject.getId()) {
                            photoImage = chatActionCell.getPhotoImage();
                        }
                    } else if (fileLocation != null && messageObject2.photoThumbs != null) {
                        int i2 = 0;
                        while (true) {
                            if (i2 >= messageObject2.photoThumbs.size()) {
                                imageReceiver = null;
                                break;
                            }
                            TLRPC.FileLocation fileLocation3 = ((TLRPC.PhotoSize) messageObject2.photoThumbs.get(i2)).location;
                            if (fileLocation3 != null && fileLocation3.local_id == fileLocation.local_id) {
                                imageReceiver = chatActionCell.getPhotoImage();
                                break;
                            }
                            i2++;
                        }
                        photoImage = (imageReceiver != null || (message = messageObject2.messageOwner) == null || (messageAction = message.action) == null || (photo = messageAction.photo) == null || (arrayList = photo.video_sizes) == null || arrayList.isEmpty() || (fileLocation2 = ((TLRPC.VideoSize) messageObject2.messageOwner.action.photo.video_sizes.get(0)).location) == null || fileLocation2.volume_id != fileLocation.volume_id || fileLocation2.local_id != fileLocation.local_id) ? imageReceiver : chatActionCell.getPhotoImage();
                    }
                }
                photoImage = null;
            }
            if (photoImage != null) {
                if (onlyIfVisible && childAt.getY() + photoImage.getImageY2() < this.chatListViewPaddingTop - AndroidUtilities.dp(4.0f)) {
                    return null;
                }
                int[] iArr = new int[2];
                childAt.getLocationInWindow(iArr);
                PhotoViewer.PlaceProviderObject placeProviderObject = new PhotoViewer.PlaceProviderObject();
                placeProviderObject.viewX = iArr[0];
                placeProviderObject.viewY = iArr[1] - (Build.VERSION.SDK_INT < 21 ? AndroidUtilities.statusBarHeight : 0);
                placeProviderObject.parentView = this.chatListView;
                placeProviderObject.animatingImageView = null;
                placeProviderObject.imageReceiver = photoImage;
                if (needPreview) {
                    placeProviderObject.thumb = photoImage.getBitmapSafe();
                }
                placeProviderObject.radius = photoImage.getRoundRadius(true);
                if ((childAt instanceof ChatActionCell) && (chat = this.currentChat) != null) {
                    placeProviderObject.dialogId = -chat.id;
                }
                placeProviderObject.clipTopAddition = (int) ((this.chatListViewPaddingTop - this.chatListViewPaddingVisibleOffset) - AndroidUtilities.dp(4.0f));
                placeProviderObject.clipBottomAddition = this.blurredViewBottomOffset;
                return placeProviderObject;
            }
        }
        return null;
    }

    public final void showAttachmentError() {
        if (getParentActivity() == null) {
            return;
        }
        BulletinFactory.of(this).createErrorBulletin(LocaleController.getString("UnsupportedAttachment", R.string.UnsupportedAttachment), this.themeDelegate).show();
    }

    public final void fillEditingMediaWithCaption(CharSequence caption, ArrayList<TLRPC.MessageEntity> entities) {
        if (this.editingMessageObject == null) {
            return;
        }
        if (!TextUtils.isEmpty(caption)) {
            MessageObject messageObject = this.editingMessageObject;
            messageObject.editingMessage = caption;
            messageObject.editingMessageEntities = entities;
            return;
        }
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView != null) {
            this.editingMessageObject.editingMessage = chatActivityEnterView.getFieldText();
            MessageObject messageObject2 = this.editingMessageObject;
            if (messageObject2.editingMessage != null || TextUtils.isEmpty(messageObject2.messageOwner.message)) {
                return;
            }
            this.editingMessageObject.editingMessage = "";
        }
    }

    public final void sendUriAsDocument(android.net.Uri r29) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.sendUriAsDocument(android.net.Uri):void");
    }

    public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
        String str;
        if (resultCode == -1) {
            if (requestCode == 0 || requestCode == 2) {
                createChatAttachView();
                ChatAttachAlert chatAttachAlert = this.chatAttachAlert;
                if (chatAttachAlert != null) {
                    chatAttachAlert.getPhotoLayout().onActivityResultFragment(requestCode, data, this.currentPicturePath);
                }
                this.currentPicturePath = null;
                return;
            }
            if (requestCode != 1) {
                if (requestCode == 21) {
                    if (data == null) {
                        showAttachmentError();
                        return;
                    }
                    if (data.getData() != null) {
                        sendUriAsDocument(data.getData());
                    } else if (data.getClipData() != null) {
                        ClipData clipData = data.getClipData();
                        for (int i = 0; i < clipData.getItemCount(); i++) {
                            sendUriAsDocument(clipData.getItemAt(i).getUri());
                        }
                    } else {
                        showAttachmentError();
                    }
                    ChatAttachAlert chatAttachAlert2 = this.chatAttachAlert;
                    if (chatAttachAlert2 != null) {
                        chatAttachAlert2.dismiss();
                    }
                    afterMessageSend();
                    return;
                }
                return;
            }
            if (data == null || data.getData() == null) {
                showAttachmentError();
                return;
            }
            final Uri data2 = data.getData();
            if (data2.toString().contains("video")) {
                try {
                    str = AndroidUtilities.getPath(data2);
                } catch (Exception e) {
                    FileLog.e(e);
                    str = null;
                }
                if (str == null) {
                    showAttachmentError();
                }
                if (this.paused) {
                    this.startVideoEdit = str;
                } else {
                    openVideoEditor(str, null);
                }
            } else if (this.editingMessageObject == null && this.chatMode == 1) {
                AlertsCreator.createScheduleDatePickerDialog(getParentActivity(), this.dialog_id, new AlertsCreator.ScheduleDatePickerDelegate() {
                    public final void didSelectDate(boolean z, int i2) {
                        ChatActivity.this.lambda$onActivityResultFragment$163(data2, z, i2);
                    }
                }, this.themeDelegate);
            } else {
                fillEditingMediaWithCaption(null, null);
                SendMessagesHelper.prepareSendingPhoto(getAccountInstance(), (String) null, data2, this.dialog_id, this.replyingMessageObject, getThreadMessage(), this.replyingQuote, (CharSequence) null, (ArrayList) null, (ArrayList) null, (InputContentInfoCompat) null, 0, this.editingMessageObject, true, 0, this.chatMode, this.quickReplyShortcut, getQuickReplyId());
            }
            afterMessageSend();
        }
    }

    public void lambda$onActivityResultFragment$163(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 saveSelfArgs(Bundle args) {
        String str = this.currentPicturePath;
        if (str != null) {
            args.putString("path", str);
        }
    }

    public void restoreSelfArgs(Bundle args) {
        this.currentPicturePath = args.getString("path");
    }

    public final 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 final void checkDispatchHideSkeletons(boolean animate) {
        if (this.startMessageAppearTransitionMs == 0) {
            if (animate && !this.messageSkeletons.isEmpty()) {
                this.startMessageAppearTransitionMs = System.currentTimeMillis();
            } else {
                this.startMessageAppearTransitionMs = 1L;
            }
            isSkeletonVisible();
            RecyclerListView recyclerListView = this.chatListView;
            if (recyclerListView != null) {
                recyclerListView.invalidate();
            }
        }
    }

    public final void removeUnreadPlane(boolean scrollToEnd) {
        MessageObject messageObject = this.unreadMessageObject;
        if (messageObject != null) {
            if (scrollToEnd) {
                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;
        }
    }

    public void didReceivedNotification(int r64, int r65, final java.lang.Object... r66) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.didReceivedNotification(int, int, java.lang.Object[]):void");
    }

    public void lambda$didReceivedNotification$164() {
        getNotificationCenter().onAnimationFinish(this.transitionAnimationIndex);
    }

    public void lambda$didReceivedNotification$165() {
        createEmptyView(false);
        if (!((BaseFragment) this).fragmentBeginToShow) {
            this.chatListView.setAnimateEmptyView(false, 0);
            this.chatListView.setEmptyView(this.emptyViewContainer);
            this.chatListView.setAnimateEmptyView(true, 1);
            return;
        }
        this.chatListView.setEmptyView(this.emptyViewContainer);
    }

    public void lambda$didReceivedNotification$166() {
        resumeDelayedFragmentAnimation();
        AndroidUtilities.cancelRunOnUIThread(this.fragmentTransitionRunnable);
        this.fragmentTransitionRunnable.run();
        getNotificationCenter().runDelayedNotifications();
    }

    public void lambda$didReceivedNotification$167(Object[] objArr, StickersAlert stickersAlert, boolean z, TLRPC.StickerSet stickerSet, DialogInterface dialogInterface) {
        if (objArr.length <= 2 || !(objArr[2] instanceof TLRPC.Document)) {
            return;
        }
        TLRPC.Document document = (TLRPC.Document) objArr[2];
        if (objArr.length > 3 && (objArr[3] instanceof String)) {
            document.localThumbPath = (String) objArr[3];
        }
        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$168(MessageObject messageObject, int i) {
        this.delayedReadRunnable = null;
        messageObject.messageOwner.replies.read_max_id = i;
    }

    public void lambda$didReceivedNotification$169() {
        BulletinFactory.of(this).createSimpleBulletin(R.raw.chats_infotip, LocaleController.getString(R.string.BoostingRemoveRestrictionsSuccessTitle), LocaleController.getString(R.string.BoostingRemoveRestrictionsSuccessSubTitle)).show();
    }

    public void lambda$didReceivedNotification$171(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 com.google.android.exoplayer2.util.Consumer() {
            public final void accept(Object obj) {
                ChatActivity.this.lambda$didReceivedNotification$170((ChannelBoostsController.CanApplyBoost) obj);
            }
        });
    }

    public void lambda$didReceivedNotification$170(ChannelBoostsController.CanApplyBoost canApplyBoost) {
        this.canApplyBoosts = canApplyBoost;
    }

    public void lambda$didReceivedNotification$172(Object[] objArr, long j) {
        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 = (TLRPC.MessageExtendedMedia) objArr[2];
            messageObject.forceUpdate = true;
            messageObject.setType();
            updateMessageAnimated(messageObject, false);
        }
    }

    public void lambda$didReceivedNotification$173(Object[] objArr, long j) {
        MessageObject messageObject;
        int intValue = ((Integer) objArr[1]).intValue();
        LongSparseArray<MessageObject> 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 = 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 void lambda$didReceivedNotification$175() {
        AndroidUtilities.forEachViews(this.chatListView, new com.google.android.exoplayer2.util.Consumer() {
            public final void accept(Object obj) {
                ChatActivity.lambda$didReceivedNotification$174((View) obj);
            }
        });
        this.chatAdapter.notifyDataSetChanged(true);
    }

    public static void lambda$didReceivedNotification$174(View view) {
        MessageObject messageObject;
        if (!(view instanceof ChatMessageCell) || (messageObject = ((ChatMessageCell) view).getMessageObject()) == null) {
            return;
        }
        messageObject.forceUpdate = true;
        messageObject.reactionsChanged = true;
    }

    public void lambda$didReceivedNotification$176() {
        updateMessagesVisiblePart(false);
    }

    public void lambda$didReceivedNotification$177(ArrayList arrayList, int i) {
        replaceMessageObjects(arrayList, i, false);
    }

    public static int lambda$didReceivedNotification$178(Integer num, Integer num2) {
        return num2.compareTo(num);
    }

    public void lambda$didReceivedNotification$179() {
        checkScrollForLoad(false);
    }

    public static void lambda$didReceivedNotification$180(Theme.ThemeAccent themeAccent, Theme.ThemeInfo themeInfo, boolean z) {
        if (themeAccent != null) {
            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);
                return;
            }
            return;
        }
        NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.needSetDayNightTheme, new Object[]{themeInfo, Boolean.FALSE, null, -1});
    }

    public void lambda$didReceivedNotification$181(int i) {
        playReactionAnimation(Integer.valueOf(i));
    }

    public static Boolean lambda$didReceivedNotification$182(MessageObject messageObject) {
        return Boolean.valueOf((messageObject == null || messageObject.getFactCheck() == null) ? false : true);
    }

    public static Boolean lambda$didReceivedNotification$183(MessageObject messageObject) {
        return Boolean.valueOf((messageObject == null || messageObject.getEffect() == null) ? false : 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 DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                ChatActivity.this.lambda$showQuoteMessageUpdate$184(dialogInterface, i);
            }
        }).setNegativeButton(LocaleController.getString(R.string.Cancel), new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                ChatActivity.this.lambda$showQuoteMessageUpdate$185(dialogInterface, i);
            }
        }).setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public final void onDismiss(DialogInterface dialogInterface) {
                ChatActivity.this.lambda$showQuoteMessageUpdate$186(dialogInterface);
            }
        }).show();
    }

    public void lambda$showQuoteMessageUpdate$184(DialogInterface dialogInterface, int i) {
        MessagePreviewParams messagePreviewParams = this.messagePreviewParams;
        if (messagePreviewParams == null || messagePreviewParams.quote == null) {
            return;
        }
        openForwardingPreview(0);
    }

    public void lambda$showQuoteMessageUpdate$185(DialogInterface dialogInterface, int i) {
        hideFieldPanel(true);
    }

    public void lambda$showQuoteMessageUpdate$186(DialogInterface dialogInterface) {
        this.quoteMessageUpdateAlert = null;
    }

    public final int getScrollingOffsetForView(View v) {
        return (this.chatListView.getMeasuredHeight() - v.getBottom()) - this.chatListView.getPaddingBottom();
    }

    public final boolean updateMessageTranslation(org.telegram.messenger.MessageObject r18) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.updateMessageTranslation(org.telegram.messenger.MessageObject):boolean");
    }

    public final boolean updateMessagesReplyTranslation(java.util.ArrayList<java.lang.Integer> r12, org.telegram.messenger.MessageObject r13) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.updateMessagesReplyTranslation(java.util.ArrayList, org.telegram.messenger.MessageObject):boolean");
    }

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

    public void lambda$new$187() {
        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 = this.messages.get(i5);
                    MessageObject.GroupedMessages groupedMessages = (MessageObject.GroupedMessages) this.groupedMessagesMap.get(messageObject.getGroupId());
                    if (groupedMessages != null) {
                        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 id3 = messageObject2.getId();
                                    getMessagesController().getTranslateController().checkTranslation(messageObject2, id3 >= i + (-7) && id3 <= i2 + 7);
                                }
                            }
                            arrayList.add(Long.valueOf(groupedMessages.groupId));
                        }
                    } else {
                        int id4 = messageObject.getId();
                        getMessagesController().getTranslateController().checkTranslation(messageObject, id4 >= i + (-7) && id4 <= i2 + 7);
                    }
                }
            }
        }
        if (this.currentPinnedMessageId > 0 && this.pinnedMessageObjects != null) {
            getMessagesController().getTranslateController().checkTranslation(this.pinnedMessageObjects.get(Integer.valueOf(this.currentPinnedMessageId)), true);
        }
        updateTranslateItemVisibility();
    }

    public final void loadMoreDialogs() {
        getNotificationCenter().addObserver(this, NotificationCenter.dialogsNeedReload);
        this.needDialogsLoad = true;
        this.fromCache = !getMessagesController().isDialogsEndReached(0);
        AlertDialog alertDialog = new AlertDialog(getParentActivity(), 3);
        this.progressDialog = alertDialog;
        alertDialog.setCanceledOnTouchOutside(false);
        this.progressDialog.setCancelable(true);
        this.progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
            @Override
            public final void onCancel(DialogInterface dialogInterface) {
                ChatActivity.this.lambda$loadMoreDialogs$191(dialogInterface);
            }
        });
        this.progressDialog.show();
        getMessagesController().loadDialogs(0, -1, 100, true);
    }

    public void lambda$loadMoreDialogs$191(DialogInterface dialogInterface) {
        this.progressCancelled = true;
        dismissProgress();
    }

    public final void dismissProgress() {
        if (this.dismissProgressRunnable != null) {
            this.dismissProgressRunnable = null;
        }
        AlertDialog alertDialog = this.progressDialog;
        if (alertDialog != null) {
            alertDialog.dismiss();
            this.progressDialog = null;
        }
    }

    public final void hideDialog(TLRPC.Dialog dialog) {
        boolean contains = getMessagesController().hiddenDialogs.contains(Long.valueOf(DialogObject.isEncryptedDialog(this.dialog_id) ? DialogObject.getEncryptedChatId(this.dialog_id) : this.dialog_id));
        if (contains) {
            insertOrUpdateHidden(dialog, false, 0);
        } else {
            insertOrUpdateHidden(dialog, true, 2);
            if (MessagesController.getGlobalMainSettings().getBoolean("firstTimeHidding", true)) {
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.this.lambda$hideDialog$192();
                    }
                });
            }
        }
        updateUnhideTitle(!contains);
    }

    public void lambda$hideDialog$192() {
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
        builder.setTitle(LocaleController.getString("HiddenChats", R.string.HiddenChats));
        builder.setMessage(LocaleController.getString("HiddenChatsInfo", R.string.HiddenChatsInfo));
        builder.setPositiveButton(LocaleController.getString("OK", R.string.OK).toUpperCase(), null);
        builder.show();
        showDialog(builder.create());
        MessagesController.getGlobalMainSettings().edit().putBoolean("firstTimeHidding", false).apply();
        SharedPreferences.Editor edit = ApplicationLoader.applicationContext.getSharedPreferences("plusconfig", 0).edit();
        PlusSettings.showHiddenDialogsIcon = true;
        edit.putBoolean("showHiddenDialogsIcon", true);
        PlusSettings.enableHiddenDialogs = true;
        edit.putBoolean("enableHiddenDialogs", true);
        edit.apply();
        NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.plusSettingsChanged, new Object[]{1});
    }

    public final 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$193();
            }
        }, true, this.themeDelegate);
    }

    public void lambda$checkSecretMessageForLocation$193() {
        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 final void loadSendAsPeers(boolean animatedUpdate) {
        TLRPC.Chat chat;
        if (this.sendAsPeersObj != null || (chat = this.currentChat) == null || !ChatObject.canSendAsPeers(chat) || this.chatActivityEnterView == null) {
            return;
        }
        TLRPC.TL_channels_sendAsPeers sendAsPeers = getMessagesController().getSendAsPeers(this.dialog_id);
        this.sendAsPeersObj = sendAsPeers;
        if (sendAsPeers != null) {
            this.chatActivityEnterView.updateSendAsButton(animatedUpdate);
        }
    }

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

    public final void removeFromSponsored(MessageObject message) {
        MessagesController.SponsoredMessagesInfo sponsoredMessages = getMessagesController().getSponsoredMessages(this.dialog_id);
        if (sponsoredMessages != null) {
            sponsoredMessages.messages.remove(message);
        }
    }

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

    public final 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 valueAt = this.waitingForReplies.valueAt(i2);
            if (valueAt.replyMessageObject != null) {
                if (arrayList == null) {
                    arrayList = new ArrayList();
                }
                arrayList.add(Integer.valueOf(this.waitingForReplies.keyAt(i2)));
                if (!(valueAt.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage) && (messageFwdHeader = valueAt.replyMessageObject.messageOwner.fwd_from) != null && MessageObject.getPeerId(messageFwdHeader.saved_from_peer) == this.dialog_id && (i = valueAt.replyMessageObject.messageOwner.fwd_from.channel_post) != 0 && (messageObject = this.messagesDict[0].get(i)) != null && (messageReplies = messageObject.messageOwner.replies) != null) {
                    messageReplies.replies++;
                    messageObject.animateComments = true;
                    TLRPC.Message message = valueAt.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 (!valueAt.isOut()) {
                        messageObject.messageOwner.replies.max_id = valueAt.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());
            }
        }
    }

    public final void clearHistory(boolean overwrite, TLRPC.TL_updates_channelDifferenceTooLong differenceTooLong) {
        TLRPC.User user;
        if (overwrite) {
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("clear history by overwrite firstLoading=" + this.firstLoading + " minMessage=" + this.minMessageId[0] + " topMessage=" + ((TLRPC.updates_ChannelDifference) differenceTooLong).dialog.top_message);
            }
            TLRPC.Dialog dialog = ((TLRPC.updates_ChannelDifference) differenceTooLong).dialog;
            int i = dialog.top_message;
            int[] iArr = this.minMessageId;
            if (i > iArr[0]) {
                this.createUnreadMessageAfterId = Math.max(iArr[0] + 1, dialog.read_inbox_max_id);
            }
            this.forwardEndReached[0] = false;
            this.hideForwardEndReached = false;
            ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
            if (chatActivityAdapter != null && chatActivityAdapter.loadingDownRow < 0) {
                this.chatAdapter.notifyItemInserted(0);
            }
            TLRPC.Dialog dialog2 = ((TLRPC.updates_ChannelDifference) differenceTooLong).dialog;
            int i2 = dialog2.unread_count;
            this.newUnreadMessageCount = i2;
            this.newMentionsCount = dialog2.unread_mentions_count;
            if (this.prevSetUnreadCount != i2) {
                CounterView counterView = this.pagedownButtonCounter;
                if (counterView != null) {
                    counterView.setCount(i2, this.openAnimationEnded);
                }
                this.prevSetUnreadCount = this.newUnreadMessageCount;
                updatePagedownButtonVisibility(true);
            }
            int i3 = this.newMentionsCount;
            int i4 = ((TLRPC.updates_ChannelDifference) differenceTooLong).dialog.unread_mentions_count;
            if (i3 != i4) {
                this.newMentionsCount = i4;
                if (i4 <= 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(i4)));
                    }
                    showMentionDownButton(true, true);
                }
            }
            checkScrollForLoad(false);
            return;
        }
        this.messages.clear();
        this.waitingForLoad.clear();
        this.messagesByDays.clear();
        this.messagesByDaysSorted.clear();
        this.groupedMessagesMap.clear();
        this.threadMessageAdded = false;
        for (int i5 = 1; i5 >= 0; i5--) {
            this.messagesDict[i5].clear();
            if (this.currentEncryptedChat == null) {
                this.maxMessageId[i5] = Integer.MAX_VALUE;
                this.minMessageId[i5] = Integer.MIN_VALUE;
            } else {
                this.maxMessageId[i5] = Integer.MIN_VALUE;
                this.minMessageId[i5] = Integer.MAX_VALUE;
            }
            this.maxDate[i5] = Integer.MIN_VALUE;
            this.minDate[i5] = 0;
            this.selectedMessagesIds[i5].clear();
            this.selectedMessagesCanCopyIds[i5].clear();
            this.selectedMessagesCanStarIds[i5].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 chatActivityAdapter2 = this.chatAdapter;
        if (chatActivityAdapter2 != null) {
            chatActivityAdapter2.notifyDataSetChanged(false);
        }
        if (this.currentEncryptedChat == null && (user = this.currentUser) != null && user.bot && this.botUser == null) {
            this.botUser = "";
            updateBottomOverlay();
        }
    }

    public boolean processSwitchButton(TLRPC.TL_keyboardButtonSwitchInline button) {
        if (this.inlineReturn == 0 || ((TLRPC.KeyboardButton) button).same_peer || ((BaseFragment) this).parentLayout == null) {
            return false;
        }
        String str = "@" + this.currentUser.username + " " + ((TLRPC.KeyboardButton) button).query;
        if (this.inlineReturn == this.dialog_id) {
            this.inlineReturn = 0L;
            this.chatActivityEnterView.setFieldText(str);
        } else {
            getMediaDataController().saveDraft(this.inlineReturn, 0, str, (ArrayList) null, (TLRPC.Message) null, false);
            if (((BaseFragment) this).parentLayout.getFragmentStack().size() > 1) {
                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$358();
                } else {
                    Bundle bundle = new Bundle();
                    if (DialogObject.isEncryptedDialog(this.inlineReturn)) {
                        bundle.putInt("enc_id", DialogObject.getEncryptedChatId(this.inlineReturn));
                    } else if (DialogObject.isUserDialog(this.inlineReturn)) {
                        bundle.putLong("user_id", this.inlineReturn);
                    } else {
                        bundle.putLong("chat_id", -this.inlineReturn);
                    }
                    addToPulledDialogsMyself();
                    presentFragment(new ChatActivity(bundle), Theme.plusAlwaysBackToMain);
                }
            }
        }
        return true;
    }

    public final 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$196();
                }
            }, 1000L);
        }
    }

    public void lambda$showGigagroupConvertAlert$196() {
        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 currentTime = getConnectionsManager().getCurrentTime();
            if (Math.abs(currentTime - i) < 604800 || ((BaseFragment) this).visibleDialog != null || getParentActivity() == null) {
                return;
            }
            notificationsSettings.edit().putInt("group_convert_time", currentTime).commit();
            showDialog(AlertsCreator.createGigagroupConvertAlert(getParentActivity(), new DialogInterface.OnClickListener() {
                @Override
                public final void onClick(DialogInterface dialogInterface, int i2) {
                    ChatActivity.this.lambda$showGigagroupConvertAlert$194(dialogInterface, i2);
                }
            }, new DialogInterface.OnClickListener() {
                @Override
                public final void onClick(DialogInterface dialogInterface, int i2) {
                    ChatActivity.this.lambda$showGigagroupConvertAlert$195(dialogInterface, i2);
                }
            }).create());
        }
    }

    public class AnonymousClass115 extends GigagroupConvertAlert {
        public AnonymousClass115(final Context context, BaseFragment parentFragment) {
            super(context, parentFragment);
        }

        public 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.AnonymousClass115.this.lambda$onCovert$0(z);
                }
            });
        }

        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);
            }
        }

        public 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");
        }
    }

    public void lambda$showGigagroupConvertAlert$194(DialogInterface dialogInterface, int i) {
        showDialog(new AnonymousClass115(getParentActivity(), this));
    }

    public void lambda$showGigagroupConvertAlert$195(DialogInterface dialogInterface, int i) {
        createUndoView();
        UndoView undoView = this.undoView;
        if (undoView == null) {
            return;
        }
        undoView.showWithAction(0L, 75, (Runnable) null);
    }

    public final void addReplyMessageOwner(MessageObject obj, Integer oldId) {
        MessageObject messageObject = obj.replyMessageObject;
        if (messageObject == null) {
            return;
        }
        int id = messageObject.getId();
        ArrayList<Integer> arrayList = this.replyMessageOwners.get(id);
        if (arrayList == null) {
            arrayList = new ArrayList<>();
            this.replyMessageOwners.put(id, arrayList);
        }
        int id2 = obj.getId();
        if (!arrayList.contains(Integer.valueOf(id2))) {
            arrayList.add(Integer.valueOf(id2));
        }
        if (oldId.intValue() != 0) {
            arrayList.remove(oldId);
        }
    }

    public final void updateReplyMessageOwners(int id, MessageObject update) {
        ArrayList<Integer> arrayList = this.replyMessageOwners.get(id);
        if (arrayList == null) {
            return;
        }
        MessageObject messageObject = update == null ? new MessageObject(((BaseFragment) this).currentAccount, new TLRPC.TL_messageEmpty(), false, false) : null;
        int size = arrayList.size();
        for (int i = 0; i < size; i++) {
            MessageObject messageObject2 = this.messagesDict[0].get(arrayList.get(i).intValue());
            if (messageObject2 != null) {
                if (update == null) {
                    messageObject2.replyMessageObject = messageObject;
                } else {
                    messageObject2.replyMessageObject = update;
                }
                ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
                if (chatActivityAdapter != null) {
                    chatActivityAdapter.updateRowWithMessageObject(messageObject2, true, false);
                }
            }
        }
        if (update == null) {
            this.replyMessageOwners.remove(id);
        }
    }

    public final 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();
    }

    public final void processNewMessages(java.util.ArrayList<org.telegram.messenger.MessageObject> r33) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.processNewMessages(java.util.ArrayList):void");
    }

    public void lambda$processNewMessages$197(int i) {
        scrollToMessageId(i, 0, false, 0, true, 0);
    }

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

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

    public final void processDeletedMessages(java.util.ArrayList<java.lang.Integer> r44, long r45, boolean r47) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.processDeletedMessages(java.util.ArrayList, long, boolean):void");
    }

    public final void replaceMessageObjects(ArrayList<MessageObject> messageObjects, int loadIndex, boolean remove) {
        ChatActivityAdapter chatActivityAdapter;
        int i;
        MessageObject.GroupedMessages groupedMessages;
        int indexOf;
        ArrayList arrayList;
        MessageObject messageObject;
        TL_stories.StoryItem storyItem;
        TL_stories.StoryItem storyItem2 = null;
        LongSparseArray longSparseArray = null;
        int i2 = 0;
        while (i2 < messageObjects.size()) {
            MessageObject messageObject2 = messageObjects.get(i2);
            if (this.pinnedMessageObjects.get(Integer.valueOf(messageObject2.getId())) != null) {
                this.pinnedMessageObjects.put(Integer.valueOf(messageObject2.getId()), messageObject2);
            }
            MessageObject messageObject3 = this.messagesDict[loadIndex].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 (loadIndex == 0 && this.repliesMessagesDict.indexOfKey(messageObject2.getId()) >= 0) {
                this.repliesMessagesDict.put(messageObject2.getId(), messageObject2);
            }
            if (messageObject3 != null && (!remove || messageObject3.messageOwner.date == messageObject2.messageOwner.date)) {
                if (remove) {
                    messageObjects.remove(i2);
                    i2--;
                }
                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);
                        }
                    }
                    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 i3 = 0;
                            while (true) {
                                if (i3 >= ((TLRPC.MessageMedia) media).webpage.attributes.size()) {
                                    storyItem = storyItem2;
                                    break;
                                }
                                TLRPC.TL_webPageAttributeStory tL_webPageAttributeStory = (TLRPC.WebPageAttribute) ((TLRPC.MessageMedia) media).webpage.attributes.get(i3);
                                if (tL_webPageAttributeStory instanceof TLRPC.TL_webPageAttributeStory) {
                                    storyItem = tL_webPageAttributeStory.storyItem;
                                    break;
                                }
                                i3++;
                            }
                            if (storyItem != null) {
                                TLRPC.TL_messageMediaWebPage media2 = MessageObject.getMedia(messageObject2.messageOwner);
                                int i4 = 0;
                                while (true) {
                                    if (i4 >= ((TLRPC.MessageMedia) media2).webpage.attributes.size()) {
                                        break;
                                    }
                                    TLRPC.TL_webPageAttributeStory tL_webPageAttributeStory2 = (TLRPC.WebPageAttribute) ((TLRPC.MessageMedia) media2).webpage.attributes.get(i4);
                                    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 {
                                        i4++;
                                    }
                                }
                            }
                        }
                    }
                    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[loadIndex].put(messageObject3.getId(), messageObject2);
                } else {
                    this.messagesDict[loadIndex].remove(messageObject3.getId());
                }
                int indexOf2 = this.messages.indexOf(messageObject3);
                if (indexOf2 >= 0) {
                    ArrayList<MessageObject> arrayList2 = this.messagesByDays.get(messageObject3.dateKey);
                    int indexOf3 = arrayList2 != null ? arrayList2.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() && ((arrayList = messageObject2.photoThumbs) == null || arrayList.isEmpty())) {
                            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 arrayList3 = groupedMessages2.messages;
                                ArrayList arrayList4 = groupedMessages.messages;
                                int i5 = indexOf + 1;
                                arrayList3.addAll(arrayList4.subList(i5, arrayList4.size()));
                                for (int i6 = 0; i6 < groupedMessages2.messages.size(); i6++) {
                                    ((MessageObject) groupedMessages2.messages.get(i6)).localGroupId = groupedMessages2.groupId;
                                    groupedMessages.messages.remove(i5);
                                }
                                longSparseArray.put(groupedMessages2.groupId, groupedMessages2);
                                this.groupedMessagesMap.put(groupedMessages2.groupId, groupedMessages2);
                            }
                            groupedMessages.messages.remove(indexOf);
                            messageObject3 = messageObject;
                        } else {
                            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);
                        }
                    }
                    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) {
                            arrayList2.set(indexOf3, messageObject2);
                        }
                    } else {
                        this.messages.remove(indexOf2);
                        ChatActivityAdapter chatActivityAdapter3 = this.chatAdapter;
                        if (chatActivityAdapter3 != null && !chatActivityAdapter3.isFiltered) {
                            chatActivityAdapter3.notifyItemRemoved(chatActivityAdapter3.messagesStartRow + indexOf2);
                        }
                        if (indexOf3 >= 0) {
                            arrayList2.remove(indexOf3);
                            if (arrayList2.isEmpty()) {
                                this.messagesByDays.remove(messageObject3.dateKey);
                                this.messagesByDaysSorted.remove(messageObject3.dateKeyInt);
                                this.messages.remove(indexOf2);
                                int i7 = this.chatAdapter.loadingUpRow;
                                int i8 = this.chatAdapter.loadingDownRow;
                                ChatActivityAdapter chatActivityAdapter4 = this.chatAdapter;
                                if (!chatActivityAdapter4.isFiltered) {
                                    chatActivityAdapter4.notifyItemRemoved(chatActivityAdapter4.messagesStartRow + indexOf2);
                                    if (this.messages.isEmpty()) {
                                        if (i7 >= 0) {
                                            i = 0;
                                            this.chatAdapter.notifyItemRemoved(0);
                                        } else {
                                            i = 0;
                                        }
                                        if (i8 >= 0) {
                                            this.chatAdapter.notifyItemRemoved(i);
                                        }
                                        updateReplyMessageOwners(messageObject3.getId(), messageObject2);
                                    }
                                }
                            }
                        }
                    }
                }
                updateReplyMessageOwners(messageObject3.getId(), messageObject2);
            }
            i2++;
            storyItem2 = null;
        }
        if (longSparseArray != null) {
            for (int i9 = 0; i9 < longSparseArray.size(); i9++) {
                MessageObject.GroupedMessages groupedMessages3 = (MessageObject.GroupedMessages) longSparseArray.valueAt(i9);
                if (groupedMessages3.messages.isEmpty()) {
                    this.groupedMessagesMap.remove(groupedMessages3.groupId);
                } else {
                    groupedMessages3.calculate();
                    ArrayList arrayList5 = groupedMessages3.messages;
                    int indexOf4 = this.messages.indexOf((MessageObject) arrayList5.get(arrayList5.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();
    }

    public final void migrateToNewChat(final MessageObject obj) {
        INavigationLayout iNavigationLayout = ((BaseFragment) this).parentLayout;
        if (iNavigationLayout == null) {
            return;
        }
        final long j = obj.messageOwner.action.channel_id;
        final BaseFragment baseFragment = iNavigationLayout.getFragmentStack().size() > 0 ? ((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) {
            int size = iNavigationLayout2.getFragmentStack().size() - 1;
            while (indexOf < size) {
                BaseFragment baseFragment2 = iNavigationLayout2.getFragmentStack().get(indexOf);
                if (baseFragment2 instanceof ChatActivity) {
                    Bundle bundle = new Bundle();
                    bundle.putLong("chat_id", j);
                    iNavigationLayout2.addFragmentToStack(new ChatActivity(bundle), indexOf);
                    baseFragment2.removeSelfFromStack();
                } else if (baseFragment2 instanceof ProfileActivity) {
                    Bundle bundle2 = new Bundle();
                    bundle2.putLong("chat_id", j);
                    iNavigationLayout2.addFragmentToStack(new ProfileActivity(bundle2), indexOf);
                    baseFragment2.removeSelfFromStack();
                } else if (baseFragment2 instanceof ChatEditActivity) {
                    Bundle bundle3 = new Bundle();
                    bundle3.putLong("chat_id", j);
                    iNavigationLayout2.addFragmentToStack(new ChatEditActivity(bundle3), indexOf);
                    baseFragment2.removeSelfFromStack();
                } else if (baseFragment2 instanceof ChatUsersActivity) {
                    if (!((ChatUsersActivity) baseFragment2).hasSelectType()) {
                        Bundle arguments = baseFragment2.getArguments();
                        arguments.putLong("chat_id", j);
                        iNavigationLayout2.addFragmentToStack(new ChatUsersActivity(arguments), indexOf);
                    }
                    baseFragment2.removeSelfFromStack();
                }
                indexOf++;
            }
        } else {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$migrateToNewChat$198(baseFragment, obj, iNavigationLayout2);
                }
            });
        }
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$migrateToNewChat$199(j);
            }
        }, 1000L);
    }

    public void lambda$migrateToNewChat$198(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$199(long j) {
        getMessagesController().loadFullChat(j, 0, true);
    }

    public final void addToPolls(MessageObject obj, MessageObject old) {
        long pollId = obj.getPollId();
        if (pollId != 0) {
            ArrayList arrayList = (ArrayList) this.polls.get(pollId);
            if (arrayList == null) {
                arrayList = new ArrayList();
                this.polls.put(pollId, arrayList);
            }
            arrayList.add(obj);
            if (old != null) {
                arrayList.remove(old);
            }
        }
    }

    public final void showInfoHint(MessageObject messageObject, CharSequence text, final int type) {
        BulletinFactory.of(this).createSimpleBulletin(R.raw.chats_infotip, text, 9999).setDuration(Math.max(4000, Math.min(((text == null ? 0 : text.length()) / 50) * 1600, 10000))).setOnHideListener(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$showInfoHint$200(type);
            }
        }).show(true);
        this.hintMessageObject = messageObject;
        this.hintMessageType = type;
    }

    public void lambda$showInfoHint$200(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 final void showPollSolution(MessageObject messageObject, TLRPC.PollResults results) {
        CharSequence charSequence;
        if (results == null || TextUtils.isEmpty(results.solution)) {
            return;
        }
        if (!results.solution_entities.isEmpty()) {
            charSequence = MessageObject.replaceAnimatedEmoji(Emoji.replaceEmoji(new SpannableStringBuilder(results.solution), Theme.chat_msgBotButtonPaint.getFontMetricsInt(), AndroidUtilities.dp(13.0f), false), results.solution_entities, Theme.chat_msgBotButtonPaint.getFontMetricsInt());
            MessageObject.addEntitiesToText(charSequence, results.solution_entities, false, true, true, false);
        } else {
            charSequence = results.solution;
        }
        showInfoHint(messageObject, charSequence, 0);
    }

    public final void updateSearchButtons(int mask, int num, int count) {
        FrameLayout frameLayout = this.searchUpButton;
        if (frameLayout != null) {
            frameLayout.setEnabled(((this.reversed ? 2 : 1) & mask) != 0);
            this.searchUpButtonArrow.setAlpha(this.searchUpButton.isEnabled() ? 1.0f : 0.5f);
        }
        FrameLayout frameLayout2 = this.searchDownButton;
        if (frameLayout2 != null) {
            frameLayout2.setEnabled((mask & (this.reversed ? 1 : 2)) != 0);
            this.searchDownButtonArrow.setAlpha(this.searchDownButton.isEnabled() ? 1.0f : 0.5f);
        }
        this.searchLastCount = count;
        this.searchLastIndex = num;
        updateSearchCountText();
        AnimatedTextView animatedTextView = this.searchExpandList;
        if (animatedTextView != null) {
            animatedTextView.setClickable(count > 0);
            this.searchExpandList.animate().alpha(count <= 0 ? 0.5f : 1.0f).start();
        }
    }

    public final void updateSearchCountText() {
        AnimatedTextView animatedTextView = this.searchCountText;
        if (animatedTextView != null) {
            boolean z = !LocaleController.isRTL;
            int i = this.searchLastCount;
            if (i < 0) {
                animatedTextView.setText("", z);
            } else if (i == 0) {
                animatedTextView.setText(LocaleController.getString(R.string.NoResult), z);
            } else if (this.searchingFiltered) {
                animatedTextView.setText(LocaleController.formatPluralString("TaggedMessages", i, new Object[0]), z);
            } else if (this.chatMode == 7 || this.messagesSearchListContainer.getTag() != null) {
                AnimatedTextView animatedTextView2 = this.searchCountText;
                int i2 = this.searchLastCount;
                animatedTextView2.setText(LocaleController.formatPluralString("SearchMessagesResultCount", i2, new Object[]{LocaleController.formatNumber(i2, ' ')}), z);
            } else {
                this.searchCountText.setText(LocaleController.formatString(R.string.Of, new Object[]{Integer.valueOf(this.searchLastIndex + 1), Integer.valueOf(this.searchLastCount)}), z);
            }
        }
        getArguments().getLong("search_from_user_id", 0L);
        getArguments().getLong("search_from_chat_id", 0L);
    }

    public boolean needDelayOpenAnimation() {
        if (this.chatMode != 1 && getParentLayout() != null && getParentLayout().getFragmentStack().size() > 1) {
            BaseFragment baseFragment = getParentLayout().getFragmentStack().get(getParentLayout().getFragmentStack().size() - 2);
            if ((baseFragment instanceof ChatActivity) && ((ChatActivity) baseFragment).isKeyboardVisible()) {
                return false;
            }
        }
        return this.firstLoading;
    }

    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);
        }
    }

    public final void checkSavedMessagesHint() {
        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;
            MessagesController.getGlobalMainSettings().edit().putInt("savedhint", MessagesController.getGlobalMainSettings().getInt("savedhint", 0) + 1).putInt("savedsearchhint", MessagesController.getGlobalMainSettings().getInt("savedsearchhint", 0) + 1).apply();
        } else {
            if (this.savedMessagesSearchHint != null && MessagesController.getGlobalMainSettings().getInt("savedsearchhint", 0) < 1) {
                this.savedMessagesSearchHint.show();
                this.savedMessagesHintShown = true;
                MessagesController.getGlobalMainSettings().edit().putInt("savedsearchhint", MessagesController.getGlobalMainSettings().getInt("savedsearchhint", 0) + 1).apply();
                return;
            }
            checkSavedMessagesTagHint();
        }
    }

    public final void checkSavedMessagesTagHint() {
        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];
            ChatMessageCell chatMessageCell = null;
            int childCount = this.chatListView.getChildCount() - 1;
            while (true) {
                if (childCount < 0) {
                    break;
                }
                View childAt = this.chatListView.getChildAt(childCount);
                if (childAt instanceof ChatMessageCell) {
                    ChatMessageCell chatMessageCell2 = (ChatMessageCell) childAt;
                    if (chatMessageCell2.areTags() && !chatMessageCell2.reactionsLayoutInBubble.reactionButtons.isEmpty()) {
                        chatMessageCell2.getLocationInWindow(iArr);
                        float f = iArr[1] + chatMessageCell2.reactionsLayoutInBubble.y;
                        if (f >= AndroidUtilities.dp(240.0f) && f <= (AndroidUtilities.displaySize.y - AndroidUtilities.dp(25.0f)) - AndroidUtilities.navigationBarHeight) {
                            chatMessageCell = chatMessageCell2;
                            break;
                        }
                    }
                }
                childCount--;
            }
            if (chatMessageCell != null) {
                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();
                return;
            }
            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);
        }
    }

    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 = 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 saveKeyboardPositionBeforeTransition() {
        Runnable runnable = this.cancelFixedPositionRunnable;
        if (runnable != null) {
            AndroidUtilities.cancelRunOnUIThread(runnable);
        }
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView != null && this.contentView != null && chatActivityEnterView.getAdjustPanLayoutHelper() != null && !this.chatActivityEnterView.getAdjustPanLayoutHelper().animationInProgress()) {
            this.fixedKeyboardHeight = this.contentView.getKeyboardHeight();
        } else {
            this.fixedKeyboardHeight = -1;
        }
    }

    public void removeKeyboardPositionBeforeTransition() {
        if (this.fixedKeyboardHeight > 0) {
            Runnable runnable = new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$removeKeyboardPositionBeforeTransition$201();
                }
            };
            this.cancelFixedPositionRunnable = runnable;
            AndroidUtilities.runOnUIThread(runnable, 200L);
        }
    }

    public void lambda$removeKeyboardPositionBeforeTransition$201() {
        this.cancelFixedPositionRunnable = null;
        this.fixedKeyboardHeight = -1;
        View view = ((BaseFragment) this).fragmentView;
        if (view != null) {
            view.requestLayout();
        }
    }

    public void onTransitionAnimationStart(boolean isOpen, boolean backward) {
        int[] iArr;
        super.onTransitionAnimationStart(isOpen, backward);
        System.currentTimeMillis();
        if (isOpen) {
            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 (!backward) {
                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 onTransitionAnimationEnd(boolean r17, boolean r18) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.onTransitionAnimationEnd(boolean, boolean):void");
    }

    public final 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 || MessagesController.getGlobalMainSettings().getBoolean("groupEmojiPackHintShown", false)) {
            return;
        }
        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$202();
            }
        }, 300L);
    }

    public void lambda$checkGroupEmojiPackHint$202() {
        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 boolean groupEmojiPackHintWasVisible() {
        boolean z;
        HintView2 hintView2 = this.groupEmojiPackHint;
        if (hintView2 != null) {
            z = true;
            if (hintView2.shown()) {
                this.groupEmojiPackHint.hide();
            }
        } else {
            z = false;
        }
        this.groupEmojiPackHint = null;
        return z;
    }

    public void openAttachBotLayout(String botUsername) {
        TLRPC.TL_contacts_resolveUsername tL_contacts_resolveUsername = new TLRPC.TL_contacts_resolveUsername();
        tL_contacts_resolveUsername.username = botUsername;
        getConnectionsManager().sendRequest(tL_contacts_resolveUsername, new RequestDelegate() {
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                ChatActivity.this.lambda$openAttachBotLayout$213(tLObject, tL_error);
            }
        });
    }

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

    public void lambda$openAttachBotLayout$212(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$211(user, tLObject2, tL_error);
                    }
                });
            }
        }
    }

    public void lambda$openAttachBotLayout$211(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$210(tLObject, user);
            }
        });
    }

    public void lambda$openAttachBotLayout$210(TLObject tLObject, final TLRPC.User user) {
        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())) {
                TLRPC.User user2 = this.currentUser;
                if (user2 != null && user2.bot && user.id == tL_attachMenuBot.bot_id) {
                    BulletinFactory.of(this).createErrorBulletin(LocaleController.getString(R.string.BotCantOpenAttachMenuSameBot)).show();
                    return;
                }
                if (user2 != null && user2.bot && user.id != tL_attachMenuBot.bot_id) {
                    BulletinFactory.of(this).createErrorBulletin(LocaleController.getString(R.string.BotCantOpenAttachMenuBot)).show();
                    return;
                }
                if (user2 != null && !user2.bot) {
                    BulletinFactory.of(this).createErrorBulletin(LocaleController.getString(R.string.BotCantOpenAttachMenuUser)).show();
                    return;
                }
                TLRPC.Chat chat = this.currentChat;
                if (chat != null && !ChatObject.isChannelAndNotMegaGroup(chat)) {
                    BulletinFactory.of(this).createErrorBulletin(LocaleController.getString(R.string.BotCantOpenAttachMenuGroup)).show();
                    return;
                }
                TLRPC.Chat chat2 = this.currentChat;
                if (chat2 == null || !ChatObject.isChannelAndNotMegaGroup(chat2)) {
                    return;
                }
                BulletinFactory.of(this).createErrorBulletin(LocaleController.getString(R.string.BotCantOpenAttachMenuChannel)).show();
                return;
            }
            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 com.google.android.exoplayer2.util.Consumer() {
                    public final void accept(Object obj) {
                        ChatActivity.this.lambda$openAttachBotLayout$205(user, tL_attachMenuBot, (Boolean) obj);
                    }
                }, 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 DialogInterface.OnClickListener() {
                @Override
                public final void onClick(DialogInterface dialogInterface, int i) {
                    ChatActivity.this.lambda$openAttachBotLayout$208(user, atomicBoolean, tL_attachMenuBot, dialogInterface, i);
                }
            }).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("OpenUrlOption2", 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$209(CheckBoxCell.this, atomicBoolean, view);
                    }
                });
                negativeButton.setCustomViewOffset(6);
                negativeButton.setView(checkBoxCell);
            }
            negativeButton.show();
        }
    }

    public void lambda$openAttachBotLayout$205(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$204(tL_attachMenuBot, user, tLObject, tL_error);
            }
        }, 66);
    }

    public void lambda$openAttachBotLayout$204(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$203(tL_attachMenuBot, tL_error, user);
            }
        });
    }

    public void lambda$openAttachBotLayout$203(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$208(final TLRPC.User user, AtomicBoolean atomicBoolean, final TLRPC.TL_attachMenuBot tL_attachMenuBot, DialogInterface dialogInterface, 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$207(tL_attachMenuBot, user, tLObject, tL_error);
            }
        }, 66);
    }

    public void lambda$openAttachBotLayout$207(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$206(tL_error, tL_attachMenuBot, user);
            }
        });
    }

    public void lambda$openAttachBotLayout$206(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 static void lambda$openAttachBotLayout$209(CheckBoxCell checkBoxCell, AtomicBoolean atomicBoolean, View view) {
        boolean z = !checkBoxCell.isChecked();
        checkBoxCell.setChecked(z, true);
        atomicBoolean.set(z);
    }

    public void openAttachBotLayout(long botId, String startCommand, boolean justAdded) {
        openAttachMenu();
        createChatAttachView();
        this.chatAttachAlert.showBotLayout(botId, startCommand, justAdded, false);
    }

    public 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) {
            BaseFragment baseFragment = ((BaseFragment) this).parentLayout.getFragmentStack().get(((BaseFragment) this).parentLayout.getFragmentStack().size() - 1);
            removeSelfFromStack();
            baseFragment.finishFragment();
            return;
        }
        lambda$onBackPressed$358();
    }

    public boolean extendActionMode(android.view.Menu r4) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.extendActionMode(android.view.Menu):boolean");
    }

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

    public final void updateScheduledInterface(boolean animated) {
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView != null) {
            chatActivityEnterView.updateScheduleButton(animated);
        }
    }

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

    public void lambda$updateBottomOverlay$214() {
        ChatGreetingsView.showPremiumSheet(getContext(), ((BaseFragment) this).currentAccount, this.dialog_id, this.themeDelegate);
    }

    public void lambda$updateBottomOverlay$215(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$216(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$217() {
        this.chatActivityEnterView.openKeyboard();
    }

    public final boolean shouldDisplaySwipeToLeftToReplyInForum() {
        return isForumInViewAsMessagesMode() && this.replyingMessageObject == null && !canSendMessageToGeneralTopic();
    }

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

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

    public final boolean canSendMessageToTopic(TLRPC.TL_forumTopic topic) {
        return topic != null && (!topic.closed || ChatObject.canManageTopic(((BaseFragment) this).currentAccount, this.currentChat, topic));
    }

    public void updateReplyMessageHeader(boolean notify) {
        String string;
        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()) {
                    this.avatarContainer.setTitle(LocaleController.formatPluralString("Comments", this.threadMessageObject.getRepliesCount(), new Object[0]));
                } else {
                    this.avatarContainer.setTitle(LocaleController.getString("CommentsTitle", R.string.CommentsTitle));
                }
            } else {
                MessageObject messageObject2 = this.threadMessageObject;
                if (messageObject2 != null) {
                    chatAvatarContainer.setTitle(LocaleController.formatPluralString("Replies", messageObject2.getRepliesCount(), new Object[0]));
                }
            }
        }
        if (this.replyMessageHeaderObject == null) {
            return;
        }
        if (this.threadMessageObject.getRepliesCount() == 0) {
            if (this.isComments) {
                string = LocaleController.getString("NoComments", R.string.NoComments);
            } else {
                string = LocaleController.getString("NoReplies", R.string.NoReplies);
            }
        } else {
            string = LocaleController.getString("DiscussionStarted", R.string.DiscussionStarted);
        }
        MessageObject messageObject3 = this.replyMessageHeaderObject;
        messageObject3.messageOwner.message = string;
        messageObject3.messageText = string;
        if (notify) {
            this.chatAdapter.updateRowWithMessageObject(messageObject3, true, false);
        }
    }

    public final 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();
    }

    public final 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));
        int i = 9;
        BlurredFrameLayout blurredFrameLayout = this.topChatPanelView;
        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);
        this.alertNameTextView.setEllipsize(TextUtils.TruncateAt.END);
        this.alertNameTextView.setMaxLines(1);
        this.alertView.addView(this.alertNameTextView, LayoutHelper.createFrame(-2, -2.0f, 51, 8.0f, 5.0f, 8.0f, 0.0f));
        TextView textView2 = new TextView(getContext());
        this.alertTextView = textView2;
        textView2.setTextSize(1, 14.0f);
        this.alertTextView.setTextColor(getThemedColor(Theme.key_chat_topPanelMessage));
        this.alertTextView.setSingleLine(true);
        this.alertTextView.setEllipsize(TextUtils.TruncateAt.END);
        this.alertTextView.setMaxLines(1);
        this.alertView.addView(this.alertTextView, LayoutHelper.createFrame(-2, -2.0f, 51, 8.0f, 23.0f, 8.0f, 0.0f));
    }

    public void showAlert(String name, String message) {
        createAlertView();
        FrameLayout frameLayout = this.alertView;
        if (frameLayout == null || name == null || message == 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$218(valueAnimator);
                }
            });
            this.alertViewAnimator.playTogether(ofFloat);
            this.alertViewAnimator.setDuration(200L);
            this.alertViewAnimator.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    if (ChatActivity.this.alertViewAnimator == null || !ChatActivity.this.alertViewAnimator.equals(animation)) {
                        return;
                    }
                    ChatActivity.this.alertViewEnterProgress = 1.0f;
                    ChatActivity.this.invalidateChatListViewTopPadding();
                    ChatActivity.this.alertViewAnimator = null;
                }

                @Override
                public void onAnimationCancel(Animator animation) {
                    if (ChatActivity.this.alertViewAnimator == null || !ChatActivity.this.alertViewAnimator.equals(animation)) {
                        return;
                    }
                    ChatActivity.this.alertViewAnimator = null;
                }
            });
            this.alertViewAnimator.start();
        }
        this.alertNameTextView.setText(name);
        this.alertTextView.setText(Emoji.replaceEmoji(message.replace('\n', ' '), this.alertTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14.0f), false));
        Runnable runnable = this.hideAlertViewRunnable;
        if (runnable != null) {
            AndroidUtilities.cancelRunOnUIThread(runnable);
        }
        AnonymousClass120 anonymousClass120 = new AnonymousClass120();
        this.hideAlertViewRunnable = anonymousClass120;
        AndroidUtilities.runOnUIThread(anonymousClass120, 3000L);
    }

    public void lambda$showAlert$218(ValueAnimator valueAnimator) {
        this.alertViewEnterProgress = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        invalidateChatListViewTopPadding();
    }

    public class AnonymousClass120 implements Runnable {
        public AnonymousClass120() {
        }

        @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.AnonymousClass120.this.lambda$run$0(valueAnimator);
                    }
                });
                ChatActivity.this.alertViewAnimator.playTogether(ofFloat);
                ChatActivity.this.alertViewAnimator.setDuration(200L);
                ChatActivity.this.alertViewAnimator.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        if (ChatActivity.this.alertViewAnimator == null || !ChatActivity.this.alertViewAnimator.equals(animation)) {
                            return;
                        }
                        ChatActivity.this.alertView.setVisibility(8);
                        ChatActivity.this.alertViewEnterProgress = 0.0f;
                        ChatActivity.this.invalidateChatListViewTopPadding();
                        ChatActivity.this.alertViewAnimator = null;
                    }

                    @Override
                    public void onAnimationCancel(Animator animation) {
                        if (ChatActivity.this.alertViewAnimator == null || !ChatActivity.this.alertViewAnimator.equals(animation)) {
                            return;
                        }
                        ChatActivity.this.alertViewAnimator = null;
                    }
                });
                ChatActivity.this.alertViewAnimator.start();
            }
        }

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

    public final boolean hidePinnedMessageView(boolean animated) {
        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;
            }
            if (animatorSetArr[i] != null) {
                animatorSetArr[i].cancel();
                this.pinnedNextAnimation[i] = null;
            }
            i++;
        }
        this.setPinnedTextTranslationX = false;
        this.pinnedMessageView.setTag(1);
        AnimatorSet animatorSet = this.pinnedMessageViewAnimator;
        if (animatorSet != null) {
            animatorSet.cancel();
            this.pinnedMessageViewAnimator = null;
        }
        if (animated) {
            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$219(valueAnimator);
                }
            });
            this.pinnedMessageViewAnimator.playTogether(ofFloat);
            this.pinnedMessageViewAnimator.setDuration(200L);
            this.pinnedMessageViewAnimator.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    if (ChatActivity.this.pinnedMessageViewAnimator == null || !ChatActivity.this.pinnedMessageViewAnimator.equals(animation)) {
                        return;
                    }
                    if (ChatActivity.this.pinnedMessageView != null) {
                        ChatActivity.this.pinnedMessageView.setVisibility(8);
                    }
                    ChatActivity.this.pinnedMessageViewAnimator = null;
                }

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

    public void lambda$hidePinnedMessageView$219(ValueAnimator valueAnimator) {
        this.pinnedMessageEnterOffset = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        invalidateChatListViewTopPadding();
        invalidateMessagesVisiblePart();
        this.chatListView.invalidate();
    }

    public final void updatePinnedMessageView(boolean animated) {
        lambda$updateMessagesVisiblePart$148(animated, 0);
    }

    public final void updatePinnedListButton(boolean animated) {
        if ((!isThreadChat() || this.isTopic) && this.pinnedListButton != null) {
            boolean z = !this.fragmentOpened ? false : animated;
            boolean z2 = this.pinnedMessageIds.size() > 1 && !this.pinnedMessageButtonShown;
            boolean z3 = this.pinnedListButton.getTag() != null;
            boolean z4 = this.pinnedProgress.getTag() != null;
            boolean z5 = this.closePinned.getTag() != null;
            final boolean z6 = (z2 || this.pinnedProgressIsShowing || this.pinnedMessageButtonShown) ? false : true;
            final boolean z7 = (!z2 || this.pinnedProgressIsShowing || this.pinnedMessageButtonShown) ? false : true;
            final boolean z8 = this.pinnedProgressIsShowing && !this.pinnedMessageButtonShown;
            if (z3 != z2 || z4 != z8 || z5 != z6) {
                AnimatorSet animatorSet = this.pinnedListAnimator;
                if (animatorSet != null) {
                    animatorSet.cancel();
                    this.pinnedListAnimator = null;
                }
                if (z) {
                    if (z2) {
                        this.pinnedListButton.setVisibility(0);
                    } else if (z6) {
                        this.closePinned.setVisibility(0);
                    }
                    if (z8) {
                        this.pinnedProgress.setVisibility(0);
                        this.pinnedProgress.setAlpha(0.0f);
                        this.pinnedProgress.setScaleX(0.4f);
                        this.pinnedProgress.setScaleY(0.4f);
                    }
                    AnimatorSet animatorSet2 = new AnimatorSet();
                    this.pinnedListAnimator = animatorSet2;
                    Animator[] animatorArr = new Animator[9];
                    ImageView imageView = this.pinnedListButton;
                    Property property = View.ALPHA;
                    float[] fArr = new float[1];
                    fArr[0] = z7 ? 1.0f : 0.0f;
                    animatorArr[0] = ObjectAnimator.ofFloat(imageView, (Property<ImageView, Float>) property, fArr);
                    ImageView imageView2 = this.pinnedListButton;
                    Property property2 = View.SCALE_X;
                    float[] fArr2 = new float[1];
                    fArr2[0] = z7 ? 1.0f : 0.4f;
                    animatorArr[1] = ObjectAnimator.ofFloat(imageView2, (Property<ImageView, Float>) property2, fArr2);
                    ImageView imageView3 = this.pinnedListButton;
                    Property property3 = View.SCALE_Y;
                    float[] fArr3 = new float[1];
                    fArr3[0] = z7 ? 1.0f : 0.4f;
                    animatorArr[2] = ObjectAnimator.ofFloat(imageView3, (Property<ImageView, Float>) property3, fArr3);
                    ImageView imageView4 = this.closePinned;
                    Property property4 = View.ALPHA;
                    float[] fArr4 = new float[1];
                    fArr4[0] = z6 ? 1.0f : 0.0f;
                    animatorArr[3] = ObjectAnimator.ofFloat(imageView4, (Property<ImageView, Float>) property4, fArr4);
                    ImageView imageView5 = this.closePinned;
                    Property property5 = View.SCALE_X;
                    float[] fArr5 = new float[1];
                    fArr5[0] = z6 ? 1.0f : 0.4f;
                    animatorArr[4] = ObjectAnimator.ofFloat(imageView5, (Property<ImageView, Float>) property5, fArr5);
                    ImageView imageView6 = this.closePinned;
                    Property property6 = View.SCALE_Y;
                    float[] fArr6 = new float[1];
                    fArr6[0] = z6 ? 1.0f : 0.4f;
                    animatorArr[5] = ObjectAnimator.ofFloat(imageView6, (Property<ImageView, Float>) property6, fArr6);
                    RadialProgressView radialProgressView = this.pinnedProgress;
                    Property property7 = View.ALPHA;
                    float[] fArr7 = new float[1];
                    fArr7[0] = !z8 ? 0.0f : 1.0f;
                    animatorArr[6] = ObjectAnimator.ofFloat(radialProgressView, (Property<RadialProgressView, Float>) property7, fArr7);
                    RadialProgressView radialProgressView2 = this.pinnedProgress;
                    Property property8 = View.SCALE_X;
                    float[] fArr8 = new float[1];
                    fArr8[0] = !z8 ? 0.4f : 1.0f;
                    animatorArr[7] = ObjectAnimator.ofFloat(radialProgressView2, (Property<RadialProgressView, Float>) property8, fArr8);
                    RadialProgressView radialProgressView3 = this.pinnedProgress;
                    Property property9 = View.SCALE_Y;
                    float[] fArr9 = new float[1];
                    fArr9[0] = !z8 ? 0.4f : 1.0f;
                    animatorArr[8] = ObjectAnimator.ofFloat(radialProgressView3, (Property<RadialProgressView, Float>) property9, fArr9);
                    animatorSet2.playTogether(animatorArr);
                    this.pinnedListAnimator.setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT);
                    this.pinnedListAnimator.setDuration(360L);
                    this.pinnedListAnimator.addListener(new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationEnd(Animator animation) {
                            ChatActivity.this.pinnedListAnimator = null;
                            ChatActivity.this.closePinned.setVisibility(z6 ? 0 : 4);
                            ChatActivity.this.pinnedListButton.setVisibility(z7 ? 0 : 4);
                            ChatActivity.this.pinnedProgress.setVisibility(z8 ? 0 : 4);
                        }
                    });
                    this.pinnedListAnimator.start();
                } else {
                    this.closePinned.setAlpha(z6 ? 1.0f : 0.0f);
                    this.closePinned.setScaleX(z6 ? 1.0f : 0.4f);
                    this.closePinned.setScaleY(z6 ? 1.0f : 0.4f);
                    this.closePinned.setVisibility(z6 ? 0 : 4);
                    this.pinnedListButton.setAlpha(z7 ? 1.0f : 0.0f);
                    this.pinnedListButton.setScaleX(z7 ? 1.0f : 0.4f);
                    this.pinnedListButton.setScaleY(z7 ? 1.0f : 0.4f);
                    this.pinnedListButton.setVisibility(z7 ? 0 : 4);
                    this.pinnedProgress.setAlpha(z8 ? 1.0f : 0.0f);
                    this.pinnedProgress.setScaleX(z8 ? 1.0f : 0.4f);
                    this.pinnedProgress.setScaleY(z8 ? 1.0f : 0.4f);
                    this.pinnedProgress.setVisibility(z8 ? 0 : 8);
                }
                this.closePinned.setTag(z6 ? 1 : null);
                this.pinnedListButton.setTag(z2 ? 1 : null);
                this.pinnedProgress.setTag(z8 ? 1 : null);
            }
            if (this.pinnedLineView != null) {
                if (isThreadChat() && !this.isTopic) {
                    this.pinnedLineView.set(0, 1, false);
                } else {
                    this.pinnedLineView.set((this.pinnedMessageIds.size() - 1) - Collections.binarySearch(this.pinnedMessageIds, Integer.valueOf(this.currentPinnedMessageId), Comparator.-CC.reverseOrder()), this.pinnedMessageIds.size(), z);
                }
            }
        }
    }

    public final TLRPC.KeyboardButton pinnedButton(MessageObject message) {
        TLRPC.Message message2;
        TLRPC.ReplyMarkup replyMarkup;
        ArrayList arrayList;
        if (message == null || (message2 = message.messageOwner) == null || (replyMarkup = message2.reply_markup) == null || (arrayList = replyMarkup.rows) == null || arrayList.size() != 1 || message.messageOwner.reply_markup.rows.get(0) == null || ((TLRPC.TL_keyboardButtonRow) message.messageOwner.reply_markup.rows.get(0)).buttons == null || ((TLRPC.TL_keyboardButtonRow) message.messageOwner.reply_markup.rows.get(0)).buttons.size() != 1) {
            return null;
        }
        return (TLRPC.KeyboardButton) ((TLRPC.TL_keyboardButtonRow) message.messageOwner.reply_markup.rows.get(0)).buttons.get(0);
    }

    public final void lambda$updateMessagesVisiblePart$148(boolean r34, int r35) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.lambda$updateMessagesVisiblePart$148(boolean, int):void");
    }

    public void lambda$updatePinnedMessageView$220(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$221(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);
        try {
            if (!PlusSettings.disableActionsVibrations) {
                pinnedMessageButton.performHapticFeedback(0, 1);
            }
        } catch (Exception unused) {
        }
        return true;
    }

    public final void updateBio() {
        if (this.currentUser == null) {
            return;
        }
        updateBio(getMessagesController().getUserFull(this.currentUser.id));
    }

    public final void updateBio(TLRPC.UserFull userFull) {
        BlurredFrameLayout blurredFrameLayout = this.pinnedMessageView;
        if (blurredFrameLayout == null || blurredFrameLayout.getTag() != null) {
            BlurredFrameLayout blurredFrameLayout2 = this.topChatPanelView;
            if ((blurredFrameLayout2 != null && blurredFrameLayout2.getTag() == null) || this.currentUser.bot || this.bioTextView == null || userFull == null || TextUtils.isEmpty(userFull.about)) {
                return;
            }
            if (this.bioView.getTag() != null) {
                this.bioView.setTag(null);
            }
            updateChatDialogsViewPadding(48);
            this.bioView.setVisibility(0);
            this.bioTextView.setText(userFull.about);
            checkListViewPaddings();
        }
    }

    public class TrackingWidthSimpleTextView extends SimpleTextView {
        public boolean trackWidth;

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

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

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

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

    public final void updateChatDialogsViewPadding(final int top) {
        if (Theme.plusShowQuickBar) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$updateChatDialogsViewPadding$222(top);
                }
            });
        }
    }

    public void lambda$updateChatDialogsViewPadding$222(int i) {
        try {
            this.chatDialogsView.setPadding(0, AndroidUtilities.dp(i), 0, AndroidUtilities.dp((((this.chatDialogsView.getBottom() - this.chatActivityEnterView.getTop()) / AndroidUtilities.density) - (this.hideBottomMode ? 48 : 0)) - 1.0f));
        } catch (Exception e) {
            FileLog.e("tmessages", e);
        }
    }

    public final void updateTopPanel(boolean r39) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.updateTopPanel(boolean):void");
    }

    public void lambda$updateTopPanel$223(ValueAnimator valueAnimator) {
        this.topChatPanelViewOffset = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        invalidateChatListViewTopPadding();
        invalidateMessagesVisiblePart();
    }

    public void lambda$updateTopPanel$224(ValueAnimator valueAnimator) {
        this.topChatPanelViewOffset = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        invalidateChatListViewTopPadding();
        invalidateMessagesVisiblePart();
    }

    public final long getPinnedMessageId() {
        if (isThreadChat() && this.threadMessageVisible) {
            return 0L;
        }
        if (isThreadChat() && !this.isTopic) {
            if (this.threadMessageVisible) {
                return 0L;
            }
            return this.threadMessageId;
        }
        if (this.currentPinnedMessageId == 0 || this.pinnedMessageIds.isEmpty()) {
            return 0L;
        }
        return this.currentPinnedMessageId;
    }

    public final void updatePinMenuOption() {
        if (this.pinItem == null) {
            return;
        }
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$updatePinMenuOption$226();
            }
        }, 500L);
    }

    public void lambda$updatePinMenuOption$226() {
        if (getPinnedMessageId() != 0) {
            final int i = MessagesController.getNotificationsSettings(((BaseFragment) this).currentAccount).getInt("pin_" + this.dialog_id, 0);
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$updatePinMenuOption$225(i);
                }
            }, 300L);
            return;
        }
        this.headerItem.hideSubItem(115);
    }

    public void lambda$updatePinMenuOption$225(int i) {
        int i2;
        String str;
        ActionBarMenuSubItem actionBarMenuSubItem = this.pinItem;
        if (i == 0) {
            i2 = R.string.HidePinnedMessage;
            str = "HidePinnedMessage";
        } else {
            i2 = R.string.ShowPinnedMessage;
            str = "ShowPinnedMessage";
        }
        actionBarMenuSubItem.setTextAndIcon(LocaleController.getString(str, i2), i == 0 ? R.drawable.msg_archive : R.drawable.msg_unarchive);
    }

    public final void updateFavoriteTitle(final boolean isFav) {
        if (this.favoritesItem == null) {
            return;
        }
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$updateFavoriteTitle$227(isFav);
            }
        }, 500L);
    }

    public void lambda$updateFavoriteTitle$227(boolean z) {
        int i;
        String str;
        ActionBarMenuSubItem actionBarMenuSubItem = this.favoritesItem;
        if (z) {
            i = R.string.DeleteFromFavorites;
            str = "DeleteFromFavorites";
        } else {
            i = R.string.AddToFavorites;
            str = "AddToFavorites";
        }
        actionBarMenuSubItem.setTextAndIcon(LocaleController.getString(str, i), z ? R.drawable.msg_unfave : R.drawable.msg_fave);
    }

    public final void updateUnhideTitle(final boolean isHidden) {
        if (this.unhideChatItem == null) {
            return;
        }
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public void run() {
                int i;
                String str;
                ActionBarMenuSubItem actionBarMenuSubItem = ChatActivity.this.unhideChatItem;
                if (isHidden) {
                    i = R.string.UnhideChat;
                    str = "UnhideChat";
                } else {
                    i = R.string.HideChat;
                    str = "HideChat";
                }
                actionBarMenuSubItem.setTextAndIcon(LocaleController.getString(str, i), isHidden ? R.drawable.show : R.drawable.hide);
                if (PlusSettings.enableHiddenDialogs) {
                    return;
                }
                ChatActivity.this.unhideChatItem.setVisibility(8);
            }
        }, 500L);
    }

    public final void showMarkedMessages() {
        TextView textView;
        TLObject user;
        TLObject chat;
        DialogCell.CustomDialog customDialog;
        final BottomSheet.Builder builder = new BottomSheet.Builder(getParentActivity());
        builder.setApplyTopPadding(false);
        builder.setApplyBottomPadding(false);
        ScrollView scrollView = new ScrollView(getParentActivity());
        boolean z = true;
        scrollView.setFillViewport(true);
        int i = Theme.key_windowBackgroundGray;
        scrollView.setTag(Integer.valueOf(i));
        scrollView.setBackgroundColor(Theme.usePlusTheme ? Theme.prefShadowColor : Theme.getColor(i));
        LinearLayout linearLayout = new LinearLayout(getParentActivity());
        linearLayout.setOrientation(1);
        scrollView.addView(linearLayout, new FrameLayout.LayoutParams(-1, -2));
        this.dismissDialog = true;
        int size = this.markedMessages.size();
        ArrayList arrayList = (ArrayList) PlusSettings.markedListMessages.get(this.dialog_id);
        if (arrayList != null && !arrayList.isEmpty()) {
            int i2 = 0;
            while (i2 < size) {
                int intValue = this.markedMessages.size() > i2 ? this.markedMessages.get(i2).intValue() : 0;
                TLRPC.Message message = arrayList.size() > i2 ? (TLRPC.Message) arrayList.get(i2) : null;
                String str = "";
                if (message != null) {
                    MessageObject messageObject = new MessageObject(((BaseFragment) this).currentAccount, message, z, z);
                    DialogCell dialogCell = new DialogCell(null, getParentActivity(), false, true, ((BaseFragment) this).currentAccount, this.themeDelegate);
                    dialogCell.useSeparator = z;
                    dialogCell.setTag(Integer.valueOf(messageObject.messageOwner.id));
                    long peerId = MessageObject.getPeerId(messageObject.messageOwner.from_id);
                    dialogCell.setDialog(peerId, messageObject, messageObject.messageOwner.date, false, false);
                    if (peerId != 0) {
                        try {
                            user = getMessagesController().getUser(Long.valueOf(peerId));
                            chat = getMessagesController().getChat(Long.valueOf(peerId));
                            customDialog = new DialogCell.CustomDialog();
                            if (user != null) {
                                str = UserObject.getUserName(user);
                            } else if (chat != null) {
                                str = ((TLRPC.Chat) chat).title;
                            }
                            customDialog.name = str;
                            String charSequence = (getMessageCaption(messageObject, getValidGroupedMessage(messageObject)) != null ? getMessageCaption(messageObject, getValidGroupedMessage(messageObject)) : getMessageContent(messageObject, 0L, false)).toString();
                            if (TextUtils.isEmpty(charSequence)) {
                                charSequence = PlusUtils.getTextByMessageType(message);
                            }
                            customDialog.message = charSequence;
                            customDialog.id = message.id;
                        } catch (Exception e) {
                            e = e;
                        }
                        try {
                            customDialog.unread_count = 0;
                            customDialog.pinned = false;
                            customDialog.muted = false;
                            customDialog.type = 0;
                            customDialog.date = message.date;
                            customDialog.verified = false;
                            customDialog.isMedia = false;
                            customDialog.sent = -1;
                            dialogCell.setDialog(customDialog);
                            if (user == null) {
                                user = chat;
                            }
                            dialogCell.setUserAvatar(user);
                        } catch (Exception e2) {
                            e = e2;
                            e.printStackTrace();
                            textView = dialogCell;
                            z = true;
                            linearLayout.addView(textView, LayoutHelper.createLinear(-1, -2));
                            textView.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public final void onClick(View view) {
                                    ChatActivity.this.lambda$showMarkedMessages$228(builder, view);
                                }
                            });
                            textView.setOnLongClickListener(new View.OnLongClickListener() {
                                @Override
                                public final boolean onLongClick(View view) {
                                    boolean lambda$showMarkedMessages$230;
                                    lambda$showMarkedMessages$230 = ChatActivity.this.lambda$showMarkedMessages$230(builder, view);
                                    return lambda$showMarkedMessages$230;
                                }
                            });
                            i2++;
                        }
                    }
                    textView = dialogCell;
                    z = true;
                } else {
                    textView = new TextView(getParentActivity());
                    textView.setTextSize(1, 20.0f);
                    textView.setMaxLines(2);
                    textView.setEllipsize(TextUtils.TruncateAt.END);
                    textView.setPadding(AndroidUtilities.dp(15.0f), AndroidUtilities.dp(20.0f), AndroidUtilities.dp(8.0f), AndroidUtilities.dp(20.0f));
                    textView.setLineSpacing(AndroidUtilities.dp(2.0f), 1.0f);
                    textView.setTextColor(Theme.dialogs_namePaint[1].getColor());
                    textView.setText(intValue + "");
                    textView.setTag(Integer.valueOf(intValue));
                    z = true;
                    if (!this.updateAgain) {
                        loadMarkedMessages(true);
                    }
                }
                linearLayout.addView(textView, LayoutHelper.createLinear(-1, -2));
                textView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public final void onClick(View view) {
                        ChatActivity.this.lambda$showMarkedMessages$228(builder, view);
                    }
                });
                textView.setOnLongClickListener(new View.OnLongClickListener() {
                    @Override
                    public final boolean onLongClick(View view) {
                        boolean lambda$showMarkedMessages$230;
                        lambda$showMarkedMessages$230 = ChatActivity.this.lambda$showMarkedMessages$230(builder, view);
                        return lambda$showMarkedMessages$230;
                    }
                });
                i2++;
            }
            builder.setCustomView(scrollView);
            BottomSheet create = builder.create();
            create.setDelegate(new BottomSheet.BottomSheetDelegateInterface() {
                @Override
                public void onOpenAnimationEnd() {
                }

                @Override
                public boolean canDismiss() {
                    return ChatActivity.this.dismissDialog;
                }
            });
            showDialog(create);
            return;
        }
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$showMarkedMessages$231();
            }
        });
    }

    public void lambda$showMarkedMessages$228(BottomSheet.Builder builder, View view) {
        builder.getDismissRunnable().run();
        markedMessageSelected(((Integer) view.getTag()).intValue());
        if (view instanceof TextView) {
            loadMarkedMessages();
        }
    }

    public boolean lambda$showMarkedMessages$230(final BottomSheet.Builder builder, View view) {
        this.dismissDialog = false;
        final int intValue = ((Integer) view.getTag()).intValue();
        AlertDialog.Builder builder2 = new AlertDialog.Builder(getParentActivity(), this.themeDelegate);
        builder2.setTitle(LocaleController.getString("AppName", R.string.AppName));
        builder2.setMessage(LocaleController.getString("CacheClear", R.string.CacheClear));
        builder2.setPositiveButton(LocaleController.getString("OK", R.string.OK).toUpperCase(), new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                ChatActivity.this.lambda$showMarkedMessages$229(intValue, builder, dialogInterface, i);
            }
        });
        builder2.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
        builder2.setNeutralButton(LocaleController.getString("All", R.string.All), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                ChatActivity.this.clearAllMarkedMessages();
                builder.getDismissRunnable().run();
            }
        });
        showDialog(builder2.create());
        this.dismissDialog = true;
        return true;
    }

    public void lambda$showMarkedMessages$229(int i, BottomSheet.Builder builder, DialogInterface dialogInterface, int i2) {
        addRemoveMarked(i);
        builder.getDismissRunnable().run();
        loadMarkedMessages(true, 200);
    }

    public void lambda$showMarkedMessages$231() {
        Toast.makeText(getParentActivity(), LocaleController.formatString("CacheEmpty", R.string.CacheEmpty, new Object[0]), 0).show();
    }

    public final void markedMessageSelected(int msgId) {
        this.currentMarkedMsg = msgId;
        int size = this.markedMessages.size();
        scrollToMessageId(this.currentMarkedMsg, 0, true, 0, true, 0);
        int indexOf = this.markedMessages.indexOf(Integer.valueOf(this.currentMarkedMsg));
        int i = indexOf - 1;
        if (indexOf == 0) {
            this.currentMarkedMsg = this.markedMessages.get(size - 1).intValue();
        } else if (size > i) {
            this.currentMarkedMsg = this.markedMessages.get(i).intValue();
        }
        MessagesController.getMarkSettings(((BaseFragment) this).currentAccount).edit().putInt("mark_" + this.dialog_id, this.currentMarkedMsg).apply();
    }

    public final void loadMarkedMessages() {
        loadMarkedMessages(false, 1000);
    }

    public final void loadMarkedMessages(boolean show) {
        loadMarkedMessages(show, 1000);
    }

    public final void loadMarkedMessages(final boolean show, final int delay) {
        if (this.markedMessages.size() > 1) {
            this.updateAgain = true;
            this.loading = true;
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$loadMarkedMessages$233(show, delay);
                }
            }, delay);
        }
    }

    public void lambda$loadMarkedMessages$233(final boolean z, final int i) {
        getMessagesStorage().updateMarkedMessages(this.dialog_id, this.markedMessages, new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$loadMarkedMessages$232(z, i);
            }
        });
    }

    public void lambda$loadMarkedMessages$232(boolean z, int i) {
        ArrayList arrayList = (ArrayList) PlusSettings.markedListMessages.get(this.dialog_id);
        if (!z || arrayList == null || arrayList.size() < this.markedMessages.size()) {
            return;
        }
        if (!arrayList.contains(null) || i < 1000) {
            showMarkedMessages();
        }
    }

    public final void clearAllMarkedMessages() {
        this.currentMarkedMsg = 0;
        this.markedMessages.clear();
        MessagesController.getMarkSettings(((BaseFragment) this).currentAccount).edit().remove("mark_" + this.dialog_id).apply();
        PlusSettings.clearMarkedMessages(this.dialog_id);
        updateGoToMarkMsgVisibility(false);
        updateVisibleRows();
    }

    public final void addRemoveMarked(int msgId) {
        boolean contains = this.markedMessages.contains(Integer.valueOf(msgId));
        if (contains) {
            this.currentMarkedMsg = 0;
            this.markedMessages.remove(Integer.valueOf(msgId));
            int size = this.markedMessages.size();
            if (size > 0) {
                this.currentMarkedMsg = this.markedMessages.get(size - 1).intValue();
                contains = false;
            }
        } else if (this.markedMessages.size() >= 20) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.lambda$addRemoveMarked$234();
                }
            });
            return;
        } else {
            this.markedMessages.add(Integer.valueOf(msgId));
            this.currentMarkedMsg = msgId;
        }
        MessagesController.getMarkSettings(((BaseFragment) this).currentAccount).edit().putInt("mark_" + this.dialog_id, this.currentMarkedMsg).apply();
        PlusSettings.saveMarkedMessages(this.markedMessages, this.dialog_id);
        getMessagesStorage().updateMarkedMessages(this.dialog_id, this.markedMessages, (Runnable) null);
        updateGoToMarkMsgVisibility(contains ^ true);
        updateVisibleRows();
    }

    public static void lambda$addRemoveMarked$234() {
        PlusUtils.showToast(LocaleController.getString("LinkLimitReached", R.string.LinkLimitReached));
    }

    public final void updateGoToMarkMsgVisibility(final boolean show) {
        if (this.headerItem == null) {
            return;
        }
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$updateGoToMarkMsgVisibility$235(show);
            }
        }, 200L);
    }

    public void lambda$updateGoToMarkMsgVisibility$235(boolean z) {
        if (z) {
            this.headerItem.showSubItem(119);
        } else {
            this.headerItem.hideSubItem(119);
        }
    }

    public final void updateHideBottomTitle() {
        if (this.hideBottomItem == null) {
            return;
        }
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public void run() {
                int i;
                String str;
                ActionBarMenuSubItem actionBarMenuSubItem = ChatActivity.this.hideBottomItem;
                if (Theme.plusHideBottomLayoutInChannels) {
                    i = R.string.ShowBottomLayout;
                    str = "ShowBottomLayout";
                } else {
                    i = R.string.HideBottomLayout;
                    str = "HideBottomLayout";
                }
                String string = LocaleController.getString(str, i);
                boolean z = Theme.plusHideBottomLayoutInChannels;
                actionBarMenuSubItem.setTextAndIcon(string, R.drawable.empty);
            }
        }, 500L);
    }

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

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

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

    public void dismissCurrentDialog() {
        Dialog dialog = this.chatAttachAlert;
        if (dialog != null && ((BaseFragment) this).visibleDialog == dialog) {
            dialog.getPhotoLayout().closeCamera(false);
            this.chatAttachAlert.dismissInternal();
            this.chatAttachAlert.getPhotoLayout().hideCamera(true);
            return;
        }
        super.dismissCurrentDialog();
    }

    public void setInPreviewMode(boolean value) {
        MessageObject messageObject;
        TLRPC.Message message;
        super.setInPreviewMode(value);
        boolean z = true;
        if (this.currentUser != null && this.audioCallIconItem != null) {
            TLRPC.UserFull userFull = getMessagesController().getUserFull(this.currentUser.id);
            if (userFull != null && userFull.phone_calls_available) {
                this.showAudioCallAsIcon = !((BaseFragment) this).inPreviewMode && Theme.plusChatShowCallButton;
                this.audioCallIconItem.setVisibility(0);
            } else {
                this.showAudioCallAsIcon = false;
                this.audioCallIconItem.setVisibility(8);
            }
        }
        ChatAvatarContainer chatAvatarContainer = this.avatarContainer;
        if (chatAvatarContainer != null) {
            chatAvatarContainer.setOccupyStatusBar(!value);
            this.avatarContainer.setTitleExpand(this.showAudioCallAsIcon);
            this.avatarContainer.setLayoutParams(LayoutHelper.createFrame(-2, -1.0f, 51, value ? this.chatMode == 2 ? 10 : 0 : 56.0f, 0.0f, 40.0f, 0.0f));
            if (!value) {
                updateAvatarLayout();
            }
        }
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView != null) {
            chatActivityEnterView.setVisibility(!value ? 0 : 4);
        }
        ActionBar actionBar = ((BaseFragment) this).actionBar;
        if (actionBar != null) {
            actionBar.setBackButtonDrawable(!value ? new BackDrawable(false) : null);
            ActionBarMenuItem actionBarMenuItem = this.headerItem;
            if (actionBarMenuItem != null) {
                actionBarMenuItem.setAlpha(!value ? 1.0f : 0.0f);
            }
            ActionBarMenu.LazyItem lazyItem = this.attachItem;
            if (lazyItem != null) {
                lazyItem.setAlpha(value ? 0.0f : 1.0f);
            }
        }
        RecyclerListView recyclerListView = this.chatListView;
        if (recyclerListView != null) {
            int childCount = recyclerListView.getChildCount();
            for (int i = 0; i < childCount; i++) {
                View childAt = this.chatListView.getChildAt(i);
                boolean z2 = childAt instanceof ChatMessageCell;
                if (z2) {
                    messageObject = ((ChatMessageCell) childAt).getMessageObject();
                } else {
                    messageObject = 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 i2 = this.newMentionsCount - 1;
                        this.newMentionsCount = i2;
                        if (i2 <= 0) {
                            this.newMentionsCount = 0;
                            this.hasAllMentionsLocal = true;
                            showMentionDownButton(false, true);
                        } else {
                            this.mentiondownButtonCounter.setText(String.format(Locale.US, "%d", Integer.valueOf(i2)));
                        }
                        getMessagesController().markMentionMessageAsRead(messageObject.getId(), ChatObject.isChannel(this.currentChat) ? this.currentChat.id : 0L, this.dialog_id);
                        messageObject.setContentIsRead();
                    }
                    if (z2) {
                        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((value || this.isInsideContainer) ? false : true);
        }
        FragmentContextView fragmentContextView2 = this.fragmentLocationContextView;
        if (fragmentContextView2 != null) {
            fragmentContextView2.setEnabled((value || this.isInsideContainer) ? false : true);
        }
        BlurredFrameLayout blurredFrameLayout = this.pinnedMessageView;
        if (blurredFrameLayout != null) {
            if (isInPreviewMode() && !PlusSettings.doNotClosePreviewOnRelease) {
                z = false;
            }
            blurredFrameLayout.setEnabled(z);
        }
    }

    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$237(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 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);
            }

            public int getBottomOffset(int tag) {
                int i = 0;
                if (tag == 1) {
                    return 0;
                }
                ChatActivityEnterView chatActivityEnterView2 = ChatActivity.this.chatActivityEnterView;
                if (chatActivityEnterView2 != null && chatActivityEnterView2.getVisibility() == 0) {
                    if ((ChatActivity.this.contentView.getKeyboardHeight() < AndroidUtilities.dp(20.0f) && ChatActivity.this.chatActivityEnterView.isPopupShowing()) || ChatActivity.this.chatActivityEnterView.panelAnimationInProgress()) {
                        i = ChatActivity.this.chatActivityEnterView.getEmojiPadding() + ChatActivity.this.chatActivityEnterView.getHeight();
                    } else {
                        i = ChatActivity.this.chatActivityEnterView.getHeight();
                    }
                } else if (!ChatActivity.this.isInsideContainer) {
                    i = AndroidUtilities.dp(51.0f);
                }
                if (ChatActivity.this.chatActivityEnterView.panelAnimationInProgress()) {
                    i = (int) (i + (ChatActivity.this.bottomPanelTranslationY - ChatActivity.this.chatActivityEnterView.getEmojiPadding()));
                }
                return ((int) (i + ChatActivity.this.contentPanTranslation)) - AndroidUtilities.dp(1.5f);
            }

            public int getTopOffset(int tag) {
                return (((BaseFragment) ChatActivity.this).actionBar != null ? ((BaseFragment) ChatActivity.this).actionBar.getMeasuredHeight() + ((BaseFragment) ChatActivity.this).actionBar.getTop() : 0) + Math.max(0, ChatActivity.this.contentPaddingTop);
            }
        };
        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, 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) {
                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);
                }
            } else {
                moveScrollToLastMessage(false);
            }
            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) {
            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$238();
                }
            });
        }
        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();
        }
        updateMarkedMsg();
        if (Theme.usePlusTheme) {
            updateTheme();
        }
        this.flagSecure.attach();
    }

    public void lambda$onResume$237(DialogInterface dialogInterface) {
        FragmentContextView fragmentContextView = this.fragmentContextView;
        if (fragmentContextView != null) {
            fragmentContextView.checkImport(false);
        }
    }

    public void lambda$onResume$238() {
        openVideoEditor(this.startVideoEdit, null);
        this.startVideoEdit = null;
    }

    public final void updateMarkedMsg() {
        try {
            int i = MessagesController.getMarkSettings(((BaseFragment) this).currentAccount).getInt("mark_" + this.dialog_id, 0);
            if (i == 0 || this.currentMarkedMsg == i) {
                return;
            }
            this.currentMarkedMsg = i;
            if (this.markedMessages.contains(Integer.valueOf(i))) {
                return;
            }
            this.markedMessages.add(Integer.valueOf(i));
            PlusSettings.saveMarkedMessages(this.markedMessages, this.dialog_id);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public final void updateTheme() {
        GradientDrawable.Orientation orientation;
        try {
            SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("theme", 0);
            ((BaseFragment) this).actionBar.setBackgroundColor(Theme.chatHeaderColor);
            int i = sharedPreferences.getInt("chatHeaderGradient", 0);
            if (i > 0) {
                if (i == 2) {
                    orientation = GradientDrawable.Orientation.LEFT_RIGHT;
                } else if (i == 3) {
                    orientation = GradientDrawable.Orientation.TL_BR;
                } else if (i == 4) {
                    orientation = GradientDrawable.Orientation.BL_TR;
                } else {
                    orientation = GradientDrawable.Orientation.TOP_BOTTOM;
                }
                ((BaseFragment) this).actionBar.setBackgroundDrawable(new GradientDrawable(orientation, new int[]{Theme.chatHeaderColor, sharedPreferences.getInt("chatHeaderGradientColor", Theme.defColor)}));
            }
            int i2 = sharedPreferences.getInt("chatNameColor", -1);
            this.avatarContainer.setTitleColor(i2);
            this.avatarContainer.setTitleSize(sharedPreferences.getInt("chatNameSize", 18));
            this.avatarContainer.setSubtitleSize(Theme.chatStatusSize);
            ActionBarMenuItem actionBarMenuItem = this.searchItem;
            if (actionBarMenuItem != null) {
                actionBarMenuItem.getSearchField().setTextColor(Theme.chatHeaderIconsColor);
            }
            BlurredFrameLayout blurredFrameLayout = this.topChatPanelView;
            if (blurredFrameLayout != null) {
                blurredFrameLayout.setBackgroundColor(Theme.chatHeaderColor);
            }
            TextView textView = this.reportSpamButton;
            if (textView != null) {
                textView.setTextColor(i2);
            }
            TextView textView2 = this.addToContactsButton;
            if (textView2 != null) {
                textView2.setTextColor(i2);
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
    }

    public float getPullingDownOffset() {
        return this.pullingDownOffset;
    }

    public void checkAdjustResize() {
        if (this.isInsideContainer) {
            return;
        }
        if (this.reportType >= 0) {
            AndroidUtilities.requestAdjustNothing(getParentActivity(), ((BaseFragment) this).classGuid);
        } else {
            AndroidUtilities.requestAdjustResize(getParentActivity(), ((BaseFragment) this).classGuid);
        }
    }

    public void lambda$onBackPressed$358() {
        super.finishFragment();
        ActionBarPopupWindow actionBarPopupWindow = this.scrimPopupWindow;
        if (actionBarPopupWindow != null) {
            actionBarPopupWindow.setPauseNotifications(false);
            closeMenu();
        }
    }

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

    public void setResolvedChatLink(TLRPC.TL_account_resolvedBusinessChatLinks resolvedChatLink) {
        this.resolvedChatLink = resolvedChatLink;
    }

    public void applyChatLinkMessageMaybe() {
        ArrayList arrayList;
        ArrayList arrayList2;
        if (this.chatActivityEnterView == null || this.chatMode != 0 || this.resolvedChatLink == null) {
            return;
        }
        if (!UserConfig.getInstance(((BaseFragment) this).currentAccount).isPremium() && UserConfig.getInstance(((BaseFragment) this).currentAccount).getClientUserId() != this.dialog_id && (arrayList2 = this.resolvedChatLink.entities) != null) {
            arrayList = (ArrayList) Collection.-EL.stream(arrayList2).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$239;
                    lambda$applyChatLinkMessageMaybe$239 = ChatActivity.this.lambda$applyChatLinkMessageMaybe$239((TLRPC.MessageEntity) obj);
                    return lambda$applyChatLinkMessageMaybe$239;
                }
            }).collect(Collectors.toCollection(MessagesController$.ExternalSyntheticLambda310.INSTANCE));
        } else {
            arrayList = this.resolvedChatLink.entities;
        }
        CharSequence applyMessageEntities = ChatActivityEnterView.applyMessageEntities(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 boolean lambda$applyChatLinkMessageMaybe$239(TLRPC.MessageEntity messageEntity) {
        TLRPC.ChatFull chatFull;
        TLRPC.TL_messages_stickerSet groupStickerSetById;
        ArrayList arrayList;
        ArrayList arrayList2;
        ArrayList arrayList3;
        if (!(messageEntity instanceof TLRPC.TL_messageEntityCustomEmoji)) {
            return true;
        }
        TLRPC.TL_messageEntityCustomEmoji tL_messageEntityCustomEmoji = (TLRPC.TL_messageEntityCustomEmoji) messageEntity;
        long j = tL_messageEntityCustomEmoji.document_id;
        TLRPC.Document document = tL_messageEntityCustomEmoji.document;
        if (document == null) {
            document = AnimatedEmojiDrawable.findDocument(((BaseFragment) this).currentAccount, j);
        }
        if (document == null) {
            Iterator it = MediaDataController.getInstance(((BaseFragment) this).currentAccount).getStickerSets(5).iterator();
            while (it.hasNext()) {
                TLRPC.TL_messages_stickerSet tL_messages_stickerSet = (TLRPC.TL_messages_stickerSet) it.next();
                if (tL_messages_stickerSet != null && (arrayList3 = ((TLRPC.messages_StickerSet) tL_messages_stickerSet).documents) != null && !arrayList3.isEmpty()) {
                    Iterator it2 = ((TLRPC.messages_StickerSet) tL_messages_stickerSet).documents.iterator();
                    while (true) {
                        if (!it2.hasNext()) {
                            break;
                        }
                        TLRPC.Document document2 = (TLRPC.Document) it2.next();
                        if (document2.id == j) {
                            document = document2;
                            break;
                        }
                    }
                }
            }
        }
        if (document == null) {
            Iterator it3 = MediaDataController.getInstance(((BaseFragment) this).currentAccount).getFeaturedEmojiSets().iterator();
            while (it3.hasNext()) {
                TLRPC.TL_stickerSetFullCovered tL_stickerSetFullCovered = (TLRPC.StickerSetCovered) it3.next();
                if (tL_stickerSetFullCovered != null && (arrayList2 = ((TLRPC.StickerSetCovered) tL_stickerSetFullCovered).covers) != null && !arrayList2.isEmpty()) {
                    Iterator it4 = ((TLRPC.StickerSetCovered) tL_stickerSetFullCovered).covers.iterator();
                    while (true) {
                        if (!it4.hasNext()) {
                            break;
                        }
                        TLRPC.Document document3 = (TLRPC.Document) it4.next();
                        if (document3.id == j) {
                            document = document3;
                            break;
                        }
                    }
                }
                if (document != null) {
                    break;
                }
                ArrayList arrayList4 = null;
                if (tL_stickerSetFullCovered instanceof TLRPC.TL_stickerSetFullCovered) {
                    arrayList4 = tL_stickerSetFullCovered.documents;
                } else if ((tL_stickerSetFullCovered instanceof TLRPC.TL_stickerSetNoCovered) && ((TLRPC.StickerSetCovered) tL_stickerSetFullCovered).set != null) {
                    TLRPC.TL_inputStickerSetID tL_inputStickerSetID = new TLRPC.TL_inputStickerSetID();
                    ((TLRPC.InputStickerSet) tL_inputStickerSetID).id = ((TLRPC.StickerSetCovered) tL_stickerSetFullCovered).set.id;
                    TLRPC.TL_messages_stickerSet stickerSet = MediaDataController.getInstance(((BaseFragment) this).currentAccount).getStickerSet(tL_inputStickerSetID, true);
                    if (stickerSet != null && (arrayList = ((TLRPC.messages_StickerSet) stickerSet).documents) != null) {
                        arrayList4 = arrayList;
                    }
                }
                if (arrayList4 != null && !arrayList4.isEmpty()) {
                    Iterator it5 = arrayList4.iterator();
                    while (true) {
                        if (!it5.hasNext()) {
                            break;
                        }
                        TLRPC.Document document4 = (TLRPC.Document) it5.next();
                        if (document4.id == j) {
                            document = document4;
                            break;
                        }
                    }
                }
                if (document != null) {
                    break;
                }
            }
        }
        if (document != null && (chatFull = MessagesController.getInstance(((BaseFragment) this).currentAccount).getChatFull(-this.dialog_id)) != null && chatFull.emojiset != null && (groupStickerSetById = MediaDataController.getInstance(((BaseFragment) this).currentAccount).getGroupStickerSetById(chatFull.emojiset)) != null) {
            Iterator it6 = ((TLRPC.messages_StickerSet) groupStickerSetById).documents.iterator();
            while (it6.hasNext()) {
                if (((TLRPC.Document) it6.next()).id == j) {
                    return true;
                }
            }
        }
        return document != null && MessageObject.isFreeEmoji(document);
    }

    public void applyDraftMaybe(boolean canClear) {
        TLRPC.DraftMessage draft;
        Long l;
        ?? r8;
        long j;
        Paint.FontMetricsInt fontMetricsInt;
        AnimatedEmojiSpan animatedEmojiSpan;
        TLRPC.TL_forumTopic findTopic;
        MessageObject messageObject;
        TLRPC.InputReplyTo inputReplyTo;
        TLRPC.DraftMessage draftMessage;
        Long l2;
        if (this.chatActivityEnterView != null) {
            int i = this.chatMode;
            if (i == 0 || (i == 3 && getUserConfig().getClientUserId() == getSavedDialogId())) {
                if (isForumInViewAsMessagesMode()) {
                    Pair oneThreadDraft = getMediaDataController().getOneThreadDraft(this.dialog_id);
                    if (oneThreadDraft != null) {
                        l2 = (Long) oneThreadDraft.first;
                        draftMessage = (TLRPC.DraftMessage) oneThreadDraft.second;
                    } else {
                        draftMessage = null;
                        l2 = null;
                    }
                    l = l2;
                    draft = draftMessage;
                } 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());
                TLRPC.Message draftMessage2 = (draft == null || (inputReplyTo = draft.reply_to) == null || inputReplyTo.reply_to_msg_id == 0) ? null : getMediaDataController().getDraftMessage(this.dialog_id, l != null ? l.longValue() : this.threadMessageId);
                if (this.chatActivityEnterView.getFieldText() == null || (this.chatMode == 0 && getUserConfig().getClientUserId() == getDialogId() && draft != null && this.appliedDraftDate < draft.date)) {
                    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()) {
                            r8 = SpannableStringBuilder.valueOf(draft.message);
                            MediaDataController.sortEntities(draft.entities);
                            for (int i2 = 0; i2 < draft.entities.size(); i2++) {
                                TLRPC.TL_messageEntityCustomEmoji tL_messageEntityCustomEmoji = (TLRPC.MessageEntity) draft.entities.get(i2);
                                boolean z = tL_messageEntityCustomEmoji instanceof TLRPC.TL_inputMessageEntityMentionName;
                                if (z || (tL_messageEntityCustomEmoji instanceof TLRPC.TL_messageEntityMentionName)) {
                                    if (z) {
                                        j = ((TLRPC.TL_inputMessageEntityMentionName) tL_messageEntityCustomEmoji).user_id.user_id;
                                    } else {
                                        j = ((TLRPC.TL_messageEntityMentionName) tL_messageEntityCustomEmoji).user_id;
                                    }
                                    if (((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).offset + ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).length < r8.length() && r8.charAt(((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).offset + ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).length) == ' ') {
                                        ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).length++;
                                    }
                                    URLSpanUserMention uRLSpanUserMention = new URLSpanUserMention("" + j, 3);
                                    int i3 = ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).offset;
                                    r8.setSpan(uRLSpanUserMention, i3, ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).length + i3, 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 textStyleSpan = new TextStyleSpan(textStyleRun);
                                    int i4 = ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).offset;
                                    MediaDataController.addStyleToText(textStyleSpan, i4, ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).length + i4, (Spannable) r8, true);
                                } else if (tL_messageEntityCustomEmoji instanceof TLRPC.TL_messageEntityBold) {
                                    TextStyleSpan.TextStyleRun textStyleRun2 = new TextStyleSpan.TextStyleRun();
                                    textStyleRun2.flags |= 1;
                                    TextStyleSpan textStyleSpan2 = new TextStyleSpan(textStyleRun2);
                                    int i5 = ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).offset;
                                    MediaDataController.addStyleToText(textStyleSpan2, i5, ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).length + i5, (Spannable) r8, true);
                                } else if (tL_messageEntityCustomEmoji instanceof TLRPC.TL_messageEntityItalic) {
                                    TextStyleSpan.TextStyleRun textStyleRun3 = new TextStyleSpan.TextStyleRun();
                                    textStyleRun3.flags |= 2;
                                    TextStyleSpan textStyleSpan3 = new TextStyleSpan(textStyleRun3);
                                    int i6 = ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).offset;
                                    MediaDataController.addStyleToText(textStyleSpan3, i6, ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).length + i6, (Spannable) r8, true);
                                } else if (tL_messageEntityCustomEmoji instanceof TLRPC.TL_messageEntityStrike) {
                                    TextStyleSpan.TextStyleRun textStyleRun4 = new TextStyleSpan.TextStyleRun();
                                    textStyleRun4.flags |= 8;
                                    TextStyleSpan textStyleSpan4 = new TextStyleSpan(textStyleRun4);
                                    int i7 = ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).offset;
                                    MediaDataController.addStyleToText(textStyleSpan4, i7, ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).length + i7, (Spannable) r8, true);
                                } else if (tL_messageEntityCustomEmoji instanceof TLRPC.TL_messageEntityUnderline) {
                                    TextStyleSpan.TextStyleRun textStyleRun5 = new TextStyleSpan.TextStyleRun();
                                    textStyleRun5.flags |= 16;
                                    TextStyleSpan textStyleSpan5 = new TextStyleSpan(textStyleRun5);
                                    int i8 = ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).offset;
                                    MediaDataController.addStyleToText(textStyleSpan5, i8, ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).length + i8, (Spannable) r8, true);
                                } else if (tL_messageEntityCustomEmoji instanceof TLRPC.TL_messageEntityTextUrl) {
                                    URLSpanReplacement uRLSpanReplacement = new URLSpanReplacement(((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).url);
                                    int i9 = ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).offset;
                                    r8.setSpan(uRLSpanReplacement, i9, ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).length + i9, 33);
                                } else if (tL_messageEntityCustomEmoji instanceof TLRPC.TL_messageEntitySpoiler) {
                                    TextStyleSpan.TextStyleRun textStyleRun6 = new TextStyleSpan.TextStyleRun();
                                    textStyleRun6.flags |= 256;
                                    TextStyleSpan textStyleSpan6 = new TextStyleSpan(textStyleRun6);
                                    int i10 = ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).offset;
                                    MediaDataController.addStyleToText(textStyleSpan6, i10, ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).length + i10, (Spannable) r8, true);
                                } else if (tL_messageEntityCustomEmoji instanceof TLRPC.TL_messageEntityBlockquote) {
                                    int i11 = ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).offset;
                                    QuoteSpan.putQuoteToEditable((Editable) r8, i11, ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).length + i11, ((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;
                                    if (tL_messageEntityCustomEmoji2.document != null) {
                                        animatedEmojiSpan = new AnimatedEmojiSpan(tL_messageEntityCustomEmoji2.document, fontMetricsInt);
                                    } else {
                                        animatedEmojiSpan = new AnimatedEmojiSpan(tL_messageEntityCustomEmoji2.document_id, fontMetricsInt);
                                    }
                                    int i12 = ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).offset;
                                    r8.setSpan(animatedEmojiSpan, i12, ((TLRPC.MessageEntity) tL_messageEntityCustomEmoji).length + i12, 33);
                                }
                            }
                        } else {
                            r8 = draft.message;
                        }
                        this.chatActivityEnterView.setFieldText((CharSequence) r8, 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$240();
                                }
                            }, 700L);
                        }
                    }
                } else if (canClear && draft == null) {
                    this.chatActivityEnterView.setFieldText("");
                    hideFieldPanel(true);
                }
                MessageObject messageObject2 = this.replyingMessageObject;
                if (messageObject2 == null || this.threadMessageObject == messageObject2) {
                    if (draftMessage2 != null && ((messageObject = this.threadMessageObject) == null || messageObject.getId() != draftMessage2.id)) {
                        MessageObject messageObject3 = new MessageObject(((BaseFragment) this).currentAccount, draftMessage2, getMessagesController().getUsers(), false, false);
                        this.replyingMessageObject = messageObject3;
                        TLRPC.InputReplyTo inputReplyTo2 = draft.reply_to;
                        if (inputReplyTo2 != null) {
                            int i13 = inputReplyTo2.flags;
                            if ((i13 & 4) != 0) {
                                this.replyingQuote = ReplyQuote.from(messageObject3, inputReplyTo2.quote_text, (i13 & 16) != 0 ? inputReplyTo2.quote_offset : -1);
                            }
                        }
                        checkNewMessagesOnQuoteEdit(false);
                        ReplyQuote replyQuote = this.replyingQuote;
                        if (replyQuote != null) {
                            showFieldPanelForReplyQuote(this.replyingMessageObject, replyQuote);
                        } else {
                            showFieldPanelForReply(this.replyingMessageObject);
                        }
                        updateBottomOverlay();
                        return;
                    }
                    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 void lambda$applyDraftMaybe$240() {
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView != null) {
            chatActivityEnterView.setFieldFocused(true);
            this.chatActivityEnterView.openKeyboard();
        }
    }

    public final void checkNewMessagesOnQuoteEdit(boolean update) {
        if (this.replyingMessageObject == null) {
            return;
        }
        for (int i = 0; i < this.messages.size(); i++) {
            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 (update) {
                    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 final void updateInformationForScreenshotDetector() {
        if (this.currentUser == null) {
            return;
        }
        if (this.currentEncryptedChat != null) {
            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);
            return;
        }
        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());
    }

    public final boolean fixLayoutInternal() {
        boolean z;
        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) {
            ((BaseFragment) this).actionBar.setBackButtonDrawable(new BackDrawable(false));
        } else {
            ActionBar 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;
            }
            actionBar.setBackButtonDrawable(new BackDrawable(z));
        }
        return false;
    }

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

    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 void onConfigurationChanged(Configuration newConfig) {
        MessageObject playingMessageObject;
        fixLayout();
        Dialog dialog = ((BaseFragment) this).visibleDialog;
        if (dialog instanceof DatePickerDialog) {
            dialog.dismiss();
        }
        closeMenu();
        if (AndroidUtilities.isTablet()) {
            return;
        }
        if (newConfig.orientation == 2) {
            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();
            return;
        }
        if (PhotoViewer.hasInstance() && PhotoViewer.getInstance().isOpenedFullScreenVideo()) {
            PhotoViewer.getInstance().injectVideoPlayerToMediaController();
            PhotoViewer.getInstance().closePhoto(false, true);
        }
    }

    public final void createDeleteMessagesAlert(final MessageObject finalSelectedObject, final MessageObject.GroupedMessages finalSelectedGroup) {
        createDeleteMessagesAlert(finalSelectedObject, finalSelectedGroup, false);
    }

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

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

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

    public final 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.canSaveMediaCount = 0;
        this.canSqueduleCount = 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 final boolean createMenu(View v, boolean single, boolean listView, float x, float y, boolean longpress) {
        return createMenu(v, single, listView, x, y, true, longpress);
    }

    public final CharSequence getMessageCaption(MessageObject messageObject, MessageObject.GroupedMessages group) {
        return getMessageCaption(messageObject, group, null);
    }

    public final CharSequence getMessageCaption(MessageObject messageObject, MessageObject.GroupedMessages group, int[] msgId) {
        if (messageObject == null) {
            return null;
        }
        String restrictionReason = MessagesController.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 (group == null) {
            return null;
        }
        int size = group.messages.size();
        CharSequence charSequence2 = null;
        for (int i = 0; i < size; i++) {
            MessageObject messageObject2 = (MessageObject) group.messages.get(i);
            CharSequence charSequence3 = messageObject2.caption;
            if (charSequence3 != null) {
                if (charSequence2 != null) {
                    return null;
                }
                if (msgId != null) {
                    msgId[0] = messageObject2.getId();
                }
                charSequence2 = charSequence3;
            }
        }
        return charSequence2;
    }

    @android.annotation.SuppressLint({"ClickableViewAccessibility"})
    public final boolean createMenu(final android.view.View r58, boolean r59, boolean r60, float r61, float r62, boolean r63, boolean r64) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.createMenu(android.view.View, boolean, boolean, float, float, boolean, boolean):boolean");
    }

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

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

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

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

    public static void lambda$createMenu$248(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$247(horizontalScrollView, scrollX, x, childAt, reactionTabHolderView, valueAnimator);
            }
        });
        duration.start();
    }

    public static void lambda$createMenu$247(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 class AnonymousClass138 extends PagerAdapter {
        public final SparseIntArray val$cachedHeights;
        public final SparseArray val$cachedViews;
        public final List val$counters;
        public final int val$finalCount;
        public final int[] val$foregroundIndex;
        public final int val$head;
        public final MessageObject val$message;
        public final ViewPager val$pager;
        public final ActionBarPopupWindow.ActionBarPopupWindowLayout val$popupLayout;
        public final ReactedHeaderView val$reactedView;
        public final boolean val$showAllReactionsTab;
        public final int val$size;

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

        public AnonymousClass138(final int val$size, final SparseArray val$cachedViews, final boolean val$showAllReactionsTab, final List val$counters, final MessageObject val$message, final ReactedHeaderView val$reactedView, final SparseIntArray val$cachedHeights, final int val$head, final ViewPager val$pager, final ActionBarPopupWindow.ActionBarPopupWindowLayout val$popupLayout, final int[] val$foregroundIndex, final int val$finalCount) {
            this.val$size = val$size;
            this.val$cachedViews = val$cachedViews;
            this.val$showAllReactionsTab = val$showAllReactionsTab;
            this.val$counters = val$counters;
            this.val$message = val$message;
            this.val$reactedView = val$reactedView;
            this.val$cachedHeights = val$cachedHeights;
            this.val$head = val$head;
            this.val$pager = val$pager;
            this.val$popupLayout = val$popupLayout;
            this.val$foregroundIndex = val$foregroundIndex;
            this.val$finalCount = val$finalCount;
        }

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

        public Object instantiateItem(ViewGroup container, final int position) {
            View view = (View) this.val$cachedViews.get(position);
            if (view != null) {
                container.addView(view);
                return view;
            }
            int i = this.val$showAllReactionsTab ? position - 1 : position;
            TLRPC.ReactionCount reactionCount = i >= 0 ? (TLRPC.ReactionCount) this.val$counters.get(i) : null;
            Context context = container.getContext();
            ChatActivity chatActivity = ChatActivity.this;
            ReactedUsersListView onCustomEmojiSelectedListener = new ReactedUsersListView(context, chatActivity.themeDelegate, ((BaseFragment) chatActivity).currentAccount, this.val$message, reactionCount, false).setSeenUsers(this.val$reactedView.getSeenUsers()).setOnCustomEmojiSelectedListener(new ReactedUsersListView.OnCustomEmojiSelectedListener() {
                public final void showCustomEmojiAlert(ReactedUsersListView reactedUsersListView, ArrayList arrayList) {
                    ChatActivity.AnonymousClass138.this.lambda$instantiateItem$0(reactedUsersListView, arrayList);
                }
            });
            final MessageObject messageObject = this.val$message;
            ReactedUsersListView onProfileSelectedListener = onCustomEmojiSelectedListener.setOnProfileSelectedListener(new ReactedUsersListView.OnProfileSelectedListener() {
                public final void onProfileSelected(ReactedUsersListView reactedUsersListView, long j, TLRPC.MessagePeerReaction messagePeerReaction) {
                    ChatActivity.AnonymousClass138.this.lambda$instantiateItem$1(messageObject, reactedUsersListView, j, messagePeerReaction);
                }
            });
            final SparseIntArray sparseIntArray = this.val$cachedHeights;
            final int i2 = 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 i3) {
                    ChatActivity.AnonymousClass138.lambda$instantiateItem$2(sparseIntArray, position, i2, viewPager, actionBarPopupWindowLayout, iArr, reactedUsersListView, i3);
                }
            });
            if (i < 0) {
                onHeightChangedListener.setPredictiveCount(this.val$finalCount);
                this.val$reactedView.setSeenCallback(new ChatActivity$$ExternalSyntheticLambda161(onHeightChangedListener));
            }
            container.addView(onHeightChangedListener);
            this.val$cachedViews.put(position, onHeightChangedListener);
            return onHeightChangedListener;
        }

        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) {
            Bundle bundle = new Bundle();
            if (j > 0) {
                bundle.putLong("user_id", j);
            } else {
                bundle.putLong("chat_id", -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 container, int position, Object object) {
            container.removeView((View) object);
        }
    }

    public void lambda$createMenu$249(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$250(MessageObject messageObject, ReactedUsersListView reactedUsersListView, long j, TLRPC.MessagePeerReaction messagePeerReaction) {
        Bundle bundle = new Bundle();
        if (j > 0) {
            bundle.putLong("user_id", j);
        } else {
            bundle.putLong("chat_id", -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$251(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$252(ReactedUsersListView reactedUsersListView, ActionBarPopupWindow.ActionBarPopupWindowLayout actionBarPopupWindowLayout, int[] iArr, View view) {
        if (reactedUsersListView == null || reactedUsersListView.isLoaded) {
            actionBarPopupWindowLayout.getSwipeBack().openForeground(iArr[0]);
        }
    }

    public void lambda$createMenu$253(MessageSeenView messageSeenView, View view, int i) {
        TLRPC.User user = (TLObject) messageSeenView.users.get(i);
        if (user == null) {
            return;
        }
        closeMenu(true);
        Bundle bundle = new Bundle();
        if (user instanceof TLRPC.User) {
            bundle.putLong("user_id", user.id);
        } else if (user instanceof TLRPC.Chat) {
            bundle.putLong("chat_id", ((TLRPC.Chat) user).id);
        }
        presentFragment(new ProfileActivity(bundle));
    }

    public void lambda$createMenu$254() {
        closeMenu(true);
    }

    public void lambda$createMenu$255(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() {
                public boolean clicked;

                @Override
                public void run() {
                    if (this.clicked) {
                        return;
                    }
                    this.clicked = true;
                    ChatActivity.this.presentFragment(new NotificationsSettingsActivity());
                }
            });
        }
        closeMenu(true);
    }

    public void lambda$createMenu$256(View view) {
        closeMenu();
    }

    public void lambda$createMenu$261(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$258(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$260(runnable, jArr, tLObject, tL_error);
            }
        });
        AndroidUtilities.runOnUIThread(runnable, 150L);
    }

    public static void lambda$createMenu$258(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$257(drawable, valueAnimator);
            }
        });
        ofFloat.setDuration(150L);
        ofFloat.setInterpolator(CubicBezierInterpolator.DEFAULT);
        ofFloat.start();
    }

    public static void lambda$createMenu$257(CrossfadeDrawable crossfadeDrawable, ValueAnimator valueAnimator) {
        crossfadeDrawable.setProgress(((Float) valueAnimator.getAnimatedValue()).floatValue());
    }

    public void lambda$createMenu$260(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$259();
            }
        }, jArr[0] > 0 ? Math.max(0L, 300 - (SystemClock.elapsedRealtime() - jArr[0])) : 0L);
    }

    public void lambda$createMenu$259() {
        closeMenu();
        BulletinFactory.of(this).createSimpleBulletin(R.raw.chats_infotip, LocaleController.getString("TranscriptionReportSent", R.string.TranscriptionReportSent)).show();
    }

    public static void lambda$createMenu$262(boolean[] zArr, Runnable runnable, View view) {
        zArr[0] = true;
        runnable.run();
    }

    public static void lambda$createMenu$263(boolean[] zArr, Runnable runnable, View view) {
        zArr[0] = false;
        runnable.run();
    }

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

    public void lambda$createMenu$265(View view) {
        MessageObject messageObject = this.selectedObject;
        if (messageObject == null) {
            return;
        }
        logSponsoredClicked(messageObject);
        Browser.openUrl(getContext(), this.selectedObject.sponsoredUrl, true, false);
    }

    public boolean lambda$createMenu$266(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$267(View view) {
        if (AndroidUtilities.addToClipboard(this.selectedObject.sponsoredInfo)) {
            BulletinFactory.of(Bulletin.BulletinWindow.make(getParentActivity()), this.themeDelegate).createCopyBulletin(LocaleController.getString("TextCopied", R.string.TextCopied)).show();
        }
    }

    public void lambda$createMenu$268(View view) {
        if (AndroidUtilities.addToClipboard(this.selectedObject.sponsoredAdditionalInfo)) {
            BulletinFactory.of(Bulletin.BulletinWindow.make(getParentActivity()), this.themeDelegate).createCopyBulletin(LocaleController.getString("TextCopied", R.string.TextCopied)).show();
        }
    }

    public void lambda$createMenu$269(ActionBarPopupWindow.ActionBarPopupWindowLayout actionBarPopupWindowLayout, int i, View view) {
        if (this.contentView == null || getParentActivity() == null) {
            return;
        }
        actionBarPopupWindowLayout.getSwipeBack().openForeground(i);
    }

    public void lambda$createMenu$270(View view) {
        if (this.contentView == null || getParentActivity() == null) {
            return;
        }
        BottomSheet.Builder builder = new BottomSheet.Builder(this.contentView.getContext());
        builder.setCustomView(new SponsoredMessageInfoView(getParentActivity(), this.themeDelegate));
        builder.show();
    }

    public void lambda$createMenu$271(int i, ArrayList arrayList, View view) {
        if (this.selectedObject == null || i >= arrayList.size()) {
            return;
        }
        processSelectedOption(((Integer) arrayList.get(i)).intValue());
    }

    public Boolean lambda$createMenu$272(View view, URLSpan uRLSpan) {
        didPressMessageUrl(uRLSpan, false, this.selectedObject, view instanceof ChatMessageCell ? (ChatMessageCell) view : null);
        return Boolean.TRUE;
    }

    public void lambda$createMenu$274(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$273();
            }
        }).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$273() {
        dimBehindView(false);
    }

    public void lambda$createMenu$275(String[] strArr, String str, String str2, boolean z, ActionBarMenuSubItem actionBarMenuSubItem, AtomicBoolean atomicBoolean, AtomicReference atomicReference, String str3) {
        TLRPC.Chat chat;
        strArr[0] = str3;
        if (strArr[0] != null && ((!strArr[0].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$276(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$278(int r15, java.util.ArrayList r16, java.lang.String[] r17, java.lang.String r18, java.lang.String r19, org.telegram.tgnet.TLRPC.InputPeer r20, int[] r21, java.lang.CharSequence r22, boolean r23, org.telegram.messenger.Utilities.CallbackReturn r24, android.view.View r25) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.lambda$createMenu$278(int, java.util.ArrayList, java.lang.String[], java.lang.String, java.lang.String, org.telegram.tgnet.TLRPC$InputPeer, int[], java.lang.CharSequence, boolean, org.telegram.messenger.Utilities$CallbackReturn, android.view.View):void");
    }

    public void lambda$createMenu$277() {
        dimBehindView(false);
    }

    public static void lambda$createMenu$279(AtomicReference atomicReference) {
        if (atomicReference.get() != null) {
            ((Runnable) atomicReference.getAndSet(null)).run();
        }
    }

    public void lambda$createMenu$281(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$280();
            }
        }).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$280() {
        dimBehindView(false);
    }

    public boolean lambda$createMenu$285(final int i, final ArrayList arrayList, View view) {
        ActionBarPopupWindow actionBarPopupWindow;
        boolean z = false;
        if (this.selectedObject != null && i < arrayList.size()) {
            if (getMessagesController().isChatNoForwards(this.currentChat)) {
                return false;
            }
            if (getParentActivity() == null) {
                this.selectedObject = null;
                return false;
            }
            if (((Integer) arrayList.get(i)).intValue() == 62) {
                TranslateBottomSheet.show(getParentActivity(), this.selectedObject.messageOwner.message);
            } else if (((Integer) arrayList.get(i)).intValue() == 130) {
                AlertsCreator.createScheduleDatePickerDialog(getParentActivity(), this.dialog_id, new AlertsCreator.ScheduleDatePickerDelegate() {
                    public final void didSelectDate(boolean z2, int i2) {
                        ChatActivity.this.lambda$createMenu$282(z2, i2);
                    }
                }, this.themeDelegate);
            } else if (((Integer) arrayList.get(i)).intValue() == 3) {
                processSelectedOption(93);
            } else if (((Integer) arrayList.get(i)).intValue() == 121) {
                copyLink();
            } else {
                if (((Integer) arrayList.get(i)).intValue() == 2 || ((Integer) arrayList.get(i)).intValue() == 111) {
                    TLRPC.TL_channels_exportMessageLink tL_channels_exportMessageLink = new TLRPC.TL_channels_exportMessageLink();
                    tL_channels_exportMessageLink.id = this.selectedObject.getId();
                    tL_channels_exportMessageLink.channel = MessagesController.getInputChannel(this.currentChat);
                    getConnectionsManager().sendRequest(tL_channels_exportMessageLink, new RequestDelegate() {
                        public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                            ChatActivity.this.lambda$createMenu$284(arrayList, i, tLObject, tL_error);
                        }
                    });
                }
                if (z && (actionBarPopupWindow = this.scrimPopupWindow) != null) {
                    actionBarPopupWindow.dismiss();
                }
            }
            z = true;
            if (z) {
                actionBarPopupWindow.dismiss();
            }
        }
        return z;
    }

    public void lambda$createMenu$282(boolean z, int i) {
        ArrayList arrayList = new ArrayList();
        arrayList.add(this.selectedObject);
        getSendMessagesHelper().sendMessage(arrayList, getUserConfig().getClientUserId(), false, false, true, i);
        PlusSettings.getScheduledDownloadsIds().put(this.selectedObject.getFileName(), this.selectedObject.getDialogId() + "," + this.selectedObject.getId());
        PlusSettings.saveScheduledDownloadsIds();
    }

    public void lambda$createMenu$284(final ArrayList arrayList, final int i, final TLObject tLObject, final TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$createMenu$283(tLObject, tL_error, arrayList, i);
            }
        });
    }

    public void lambda$createMenu$283(TLObject tLObject, TLRPC.TL_error tL_error, ArrayList arrayList, int i) {
        if (tLObject != null) {
            this.forwardLink = ((TLRPC.TL_exportedMessageLink) tLObject).link;
        }
        if (tL_error != null) {
            PlusUtils.showToast(LocaleController.getString("Unavailable", R.string.Unavailable));
        }
        processSelectedOption(((Integer) arrayList.get(i)).intValue());
    }

    public void lambda$createMenu$287() {
        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$286(dialogInterface);
            }
        });
        premiumFeatureBottomSheet.show();
    }

    public void lambda$createMenu$286(DialogInterface dialogInterface) {
        dimBehindView(false);
    }

    public void lambda$createMenu$288(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$290(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$289();
            }
        }, 420L);
    }

    public void lambda$createMenu$289() {
        ActionBarMenuSubItem[] actionBarMenuSubItemArr = this.scrimPopupWindowItems;
        if (actionBarMenuSubItemArr == null || actionBarMenuSubItemArr.length <= 0 || actionBarMenuSubItemArr[0] == null) {
            return;
        }
        actionBarMenuSubItemArr[0].requestFocus();
        this.scrimPopupWindowItems[0].performAccessibilityAction(64, null);
        this.scrimPopupWindowItems[0].sendAccessibilityEvent(8);
    }

    public final void createEmptyView(boolean recreate) {
        TLRPC.TL_businessIntro tL_businessIntro;
        String string;
        TLRPC.TL_businessIntro tL_businessIntro2;
        TLRPC.User user;
        TLRPC.Chat chat;
        if ((this.emptyViewContainer == null || recreate) && getContext() != null) {
            FrameLayout frameLayout = this.emptyViewContainer;
            if (frameLayout == null) {
                FrameLayout frameLayout2 = new FrameLayout(getContext());
                this.emptyViewContainer = frameLayout2;
                frameLayout2.setVisibility(4);
                this.contentView.addView(this.emptyViewContainer, 3, LayoutHelper.createFrame(-1, -2, 17));
            } else {
                frameLayout.removeAllViews();
            }
            int i = getArguments().getInt("nearby_distance", -1);
            if (this.chatAdapter.isFiltered) {
                TextView textView = new TextView(getContext());
                this.emptyView = textView;
                textView.setText(LocaleController.getString(R.string.NoFilteredMessages));
                this.emptyView.setTextSize(1, 14.0f);
                this.emptyView.setGravity(17);
                this.emptyView.setTextColor(getThemedColor(Theme.key_chat_serviceText));
                this.emptyView.setBackground(Theme.createServiceDrawable(AndroidUtilities.dp(6.0f), this.emptyView, this.contentView, getThemedPaint("paintChatActionBackground")));
                this.emptyView.setTypeface(AndroidUtilities.bold());
                this.emptyView.setPadding(AndroidUtilities.dp(10.0f), AndroidUtilities.dp(2.0f), AndroidUtilities.dp(10.0f), AndroidUtilities.dp(3.0f));
                this.emptyViewContainer.addView(this.emptyView, new FrameLayout.LayoutParams(-2, -2, 17));
                return;
            }
            int i2 = this.chatMode;
            if (i2 == 5) {
                QuickRepliesEmptyView quickRepliesEmptyView = new QuickRepliesEmptyView(getContext(), this.chatMode, this.dialog_id, this.threadMessageId, this.quickReplyShortcut, getResourceProvider());
                this.quickRepliesEmptyView = quickRepliesEmptyView;
                quickRepliesEmptyView.setBackground(Theme.createServiceDrawable(AndroidUtilities.dp(16.0f), this.quickRepliesEmptyView, this.contentView, getThemedPaint("paintChatActionBackground")));
                this.emptyViewContainer.addView(this.quickRepliesEmptyView, LayoutHelper.createFrame(-2, -2, 17));
                return;
            }
            if (i2 == 6) {
                BusinessLinksEmptyView businessLinksEmptyView = new BusinessLinksEmptyView(getContext(), this, this.businessLink, getResourceProvider());
                this.businessLinksEmptyView = businessLinksEmptyView;
                businessLinksEmptyView.setBackground(Theme.createServiceDrawable(AndroidUtilities.dp(16.0f), this.businessLinksEmptyView, this.contentView, getThemedPaint("paintChatActionBackground")));
                this.emptyViewContainer.addView(this.businessLinksEmptyView, LayoutHelper.createFrame(-2, -2, 17));
                return;
            }
            boolean z = false;
            if (((i >= 0 || this.preloadedGreetingsSticker != null) && this.currentUser != null && !this.userBlocked) || (this.userInfo != null && getDialogId() != getUserConfig().getClientUserId() && this.userInfo.contact_require_premium && !getUserConfig().isPremium())) {
                ChatGreetingsView chatGreetingsView = new ChatGreetingsView(getContext(), this.currentUser, i, ((BaseFragment) this).currentAccount, this.preloadedGreetingsSticker, this.themeDelegate) {
                    public void onLayout(boolean changed, int l, int t, int r, int b) {
                        super/*android.widget.LinearLayout*/.onLayout(changed, l, t, r, b);
                        setVisiblePart(getY() + ChatActivity.this.emptyViewContent.getY(), ChatActivity.this.getServiceHeight(this));
                    }
                };
                this.greetingsViewContainer = chatGreetingsView;
                if (this.userInfo != null && getDialogId() != getUserConfig().getClientUserId() && this.userInfo.contact_require_premium && !getUserConfig().isPremium()) {
                    z = true;
                }
                chatGreetingsView.setPremiumLock(z, this.dialog_id);
                this.greetingsViewContainer.setListener(new ChatGreetingsView.Listener() {
                    public final void onGreetings(TLRPC.Document document) {
                        ChatActivity.this.lambda$createEmptyView$291(document);
                    }
                });
                LinearLayout linearLayout = new LinearLayout(getContext());
                this.emptyViewContent = linearLayout;
                linearLayout.setOrientation(1);
                this.emptyViewContent.setGravity(17);
                this.emptyViewContent.addView((View) this.greetingsViewContainer, (ViewGroup.LayoutParams) LayoutHelper.createFrame(-2, -2, 17));
                this.emptyViewContainer.addView(this.emptyViewContent, LayoutHelper.createFrame(-1, -2, 17));
                TLRPC.UserFull userFull = this.userInfo;
                if (userFull != null && (tL_businessIntro = userFull.business_intro) != null) {
                    this.greetingsViewContainer.setPreview(tL_businessIntro.title, tL_businessIntro.description);
                    this.greetingsViewContainer.setSticker(this.userInfo.business_intro.sticker);
                }
                updateGreetInfo();
                return;
            }
            if (this.currentEncryptedChat == null) {
                if (this.isTopic && this.chatMode == 0) {
                    this.emptyViewContainer.addView(new CreateTopicEmptyView(getContext(), this.contentView, this.themeDelegate), new FrameLayout.LayoutParams(-2, -2, 17));
                    return;
                }
                if (!isThreadChat() && this.chatMode == 0 && (((user = this.currentUser) != null && user.self) || ((chat = this.currentChat) != null && chat.creator && !ChatObject.isChannelAndNotMegaGroup(chat)))) {
                    View chatBigEmptyView = new ChatBigEmptyView(getContext(), this.contentView, this.currentChat == null ? 2 : 1, this.themeDelegate);
                    this.bigEmptyView = chatBigEmptyView;
                    this.emptyViewContainer.addView(chatBigEmptyView, new FrameLayout.LayoutParams(-2, -2, 17));
                    if (this.currentChat != null) {
                        this.bigEmptyView.setStatusText(AndroidUtilities.replaceTags(LocaleController.getString("GroupEmptyTitle1", R.string.GroupEmptyTitle1)));
                        return;
                    }
                    return;
                }
                if (isThreadChat() && this.chatMode == 0) {
                    if (this.isComments) {
                        string = LocaleController.getString(R.string.NoComments);
                    } else {
                        string = LocaleController.getString(R.string.NoReplies);
                    }
                } else if (this.chatMode == 1) {
                    string = LocaleController.getString(R.string.NoScheduledMessages);
                } else {
                    TLRPC.User user2 = this.currentUser;
                    if (user2 != null) {
                        long j = user2.id;
                        if (j != 777000 && j != 429000 && j != 4244000 && MessagesController.isSupportUser(user2)) {
                            string = LocaleController.getString(R.string.GotAQuestion);
                        }
                    }
                    TLRPC.User user3 = this.currentUser;
                    string = (user3 == null || user3.self || user3.deleted || this.userBlocked) ? LocaleController.getString(R.string.NoMessages) : null;
                }
                if (string == null) {
                    ChatGreetingsView chatGreetingsView2 = new ChatGreetingsView(getContext(), this.currentUser, i, ((BaseFragment) this).currentAccount, this.preloadedGreetingsSticker, this.themeDelegate) {
                        public void onLayout(boolean changed, int l, int t, int r, int b) {
                            super/*android.widget.LinearLayout*/.onLayout(changed, l, t, r, b);
                            setVisiblePart(getY() + ChatActivity.this.emptyViewContent.getY(), ChatActivity.this.getServiceHeight(this));
                        }
                    };
                    this.greetingsViewContainer = chatGreetingsView2;
                    if (this.userInfo != null && getDialogId() != getUserConfig().getClientUserId() && this.userInfo.contact_require_premium && !getUserConfig().isPremium()) {
                        z = true;
                    }
                    chatGreetingsView2.setPremiumLock(z, this.dialog_id);
                    this.greetingsViewContainer.setListener(new ChatGreetingsView.Listener() {
                        public final void onGreetings(TLRPC.Document document) {
                            ChatActivity.this.lambda$createEmptyView$292(document);
                        }
                    });
                    TLRPC.UserFull userFull2 = this.userInfo;
                    if (userFull2 != null && (tL_businessIntro2 = userFull2.business_intro) != null) {
                        this.greetingsViewContainer.setPreview(tL_businessIntro2.title, tL_businessIntro2.description);
                        this.greetingsViewContainer.setSticker(this.userInfo.business_intro.sticker);
                    }
                    LinearLayout linearLayout2 = new LinearLayout(getContext());
                    this.emptyViewContent = linearLayout2;
                    linearLayout2.setOrientation(1);
                    this.emptyViewContent.setGravity(17);
                    this.emptyViewContent.addView((View) this.greetingsViewContainer, (ViewGroup.LayoutParams) LayoutHelper.createFrame(-2, -2, 17));
                    this.emptyViewContainer.addView(this.emptyViewContent, LayoutHelper.createFrame(-1, -2, 17));
                    updateGreetInfo();
                    return;
                }
                TextView textView2 = new TextView(getContext());
                this.emptyView = textView2;
                textView2.setText(string);
                this.emptyView.setTextSize(1, 14.0f);
                this.emptyView.setGravity(17);
                this.emptyView.setTextColor(getThemedColor(Theme.key_chat_serviceText));
                this.emptyView.setBackground(Theme.createServiceDrawable(AndroidUtilities.dp(6.0f), this.emptyView, this.contentView, getThemedPaint("paintChatActionBackground")));
                this.emptyView.setTypeface(AndroidUtilities.bold());
                this.emptyView.setPadding(AndroidUtilities.dp(10.0f), AndroidUtilities.dp(2.0f), AndroidUtilities.dp(10.0f), AndroidUtilities.dp(3.0f));
                this.emptyViewContainer.addView(this.emptyView, new FrameLayout.LayoutParams(-2, -2, 17));
                return;
            }
            this.bigEmptyView = new ChatBigEmptyView(getContext(), this.contentView, 0, this.themeDelegate);
            if (this.currentEncryptedChat.admin_id == getUserConfig().getClientUserId()) {
                this.bigEmptyView.setStatusText(LocaleController.formatString("EncryptedPlaceholderTitleOutgoing", R.string.EncryptedPlaceholderTitleOutgoing, new Object[]{UserObject.getFirstName(this.currentUser)}));
            } else {
                this.bigEmptyView.setStatusText(LocaleController.formatString("EncryptedPlaceholderTitleIncoming", R.string.EncryptedPlaceholderTitleIncoming, new Object[]{UserObject.getFirstName(this.currentUser)}));
            }
            this.emptyViewContainer.addView((View) this.bigEmptyView, (ViewGroup.LayoutParams) new FrameLayout.LayoutParams(-2, -2, 17));
        }
    }

    public void lambda$createEmptyView$291(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());
    }

    public void lambda$createEmptyView$292(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());
    }

    public void closeMenu() {
        closeMenu(true);
    }

    public final void closeMenu(boolean hideDim) {
        this.scrimPopupWindowHideDimOnDismiss = hideDim;
        ActionBarPopupWindow actionBarPopupWindow = this.scrimPopupWindow;
        if (actionBarPopupWindow != null) {
            actionBarPopupWindow.dismiss();
        }
        if (hideDim) {
            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$293(valueAnimator2);
            }
        });
        this.scrimViewAlphaAnimator.setDuration(150L);
        this.scrimViewAlphaAnimator.start();
    }

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

    public final void updateGreetInfo() {
        TLRPC.UserFull userFull;
        showGreetInfo((getDialogId() == getUserConfig().getClientUserId() || (userFull = this.userInfo) == null || userFull.business_intro == null || (userFull != null && userFull.contact_require_premium && !getUserConfig().isPremium())) ? false : true);
    }

    public final void showGreetInfo(boolean show) {
        TLRPC.TL_businessIntro tL_businessIntro;
        if (this.emptyViewContent == null) {
            return;
        }
        boolean z = false;
        if (show && this.greetingsInfo == null) {
            ChatActionCell chatActionCell = new ChatActionCell(getContext(), z, getResourceProvider()) {
                @Override
                public void onLayout(boolean changed, int l, int t, int r, int b) {
                    super.onLayout(changed, l, t, r, b);
                    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$294(view);
                }
            });
        }
        ChatActionCell chatActionCell2 = this.greetingsInfo;
        if (chatActionCell2 == null) {
            return;
        }
        if (!show) {
            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 && (!show || this.greetingsInfo.getParent() != this.emptyViewContent)) {
            ((ViewGroup) this.greetingsInfo.getParent()).removeView(this.greetingsInfo);
        }
        if (show) {
            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 lambda$showGreetInfo$294(View view) {
        showDialog(new PremiumFeatureBottomSheet(this, 28, true));
    }

    public final void showMultipleReactionsPromo(ChatMessageCell cell, ReactionsLayoutInBubble.VisibleReaction visibleReaction, int currentChosenReactions) {
        TLRPC.Document findDocument;
        if (SharedConfig.multipleReactionsPromoShowed || cell == null || cell.getMessageObject() == null || visibleReaction == null || getUserConfig().isPremium() || currentChosenReactions != 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 selectReaction(org.telegram.messenger.MessageObject r21, org.telegram.ui.Components.ReactionsContainerLayout r22, android.view.View r23, float r24, float r25, org.telegram.ui.Components.Reactions.ReactionsLayoutInBubble.VisibleReaction r26, boolean r27, boolean r28, boolean r29, boolean r30) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.selectReaction(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 class AnonymousClass155 implements Runnable {
        public final boolean val$added;
        public final int val$finalMessageIdForCell;
        public final boolean val$fromDoubleTap;
        public final MessageObject val$primaryMessage;
        public final ReactionsContainerLayout val$reactionsLayout;
        public final ReactionsLayoutInBubble.VisibleReaction val$visibleReaction;
        public final boolean val$withoutAnimation;
        public final float val$x;
        public final float val$y;

        public AnonymousClass155(final boolean val$withoutAnimation, final boolean val$fromDoubleTap, final int val$finalMessageIdForCell, final boolean val$added, final ReactionsContainerLayout val$reactionsLayout, final float val$x, final float val$y, final ReactionsLayoutInBubble.VisibleReaction val$visibleReaction, final MessageObject val$primaryMessage) {
            this.val$withoutAnimation = val$withoutAnimation;
            this.val$fromDoubleTap = val$fromDoubleTap;
            this.val$finalMessageIdForCell = val$finalMessageIdForCell;
            this.val$added = val$added;
            this.val$reactionsLayout = val$reactionsLayout;
            this.val$x = val$x;
            this.val$y = val$y;
            this.val$visibleReaction = val$visibleReaction;
            this.val$primaryMessage = val$primaryMessage;
        }

        @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$378(new Runnable() {
                        @Override
                        public final void run() {
                            ChatActivity.AnonymousClass155.this.lambda$run$1(i, z, reactionsContainerLayout, f, f2, visibleReaction);
                        }
                    });
                } else {
                    final MessageObject messageObject = this.val$primaryMessage;
                    chatActivity.lambda$openDiscussionMessageChat$378(new Runnable() {
                        @Override
                        public final void run() {
                            ChatActivity.AnonymousClass155.this.lambda$run$2(messageObject);
                        }
                    });
                }
                ChatActivity.this.closeMenu();
            }
        }

        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.AnonymousClass155.this.lambda$run$0(i, z, reactionsContainerLayout, f, f2, visibleReaction);
                }
            }, 50L);
        }

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

        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();
        }
    }

    @SuppressLint({"NotifyDataSetChanged"})
    public final void updateMessageAnimated(final MessageObject message, final boolean updateReactions) {
        if (this.chatAdapter == null) {
            return;
        }
        getNotificationCenter().doOnIdle(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$updateMessageAnimated$295(message, updateReactions);
            }
        });
    }

    @SuppressLint({"NotifyDataSetChanged"})
    public final void lambda$updateMessageAnimated$295(MessageObject message, boolean updateReactions) {
        if (this.chatAdapter == null || ((BaseFragment) this).fragmentView == null) {
            return;
        }
        MessageObject.GroupedMessages groupedMessages = (MessageObject.GroupedMessages) this.groupedMessagesMap.get(message.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 (updateReactions) {
                    ((MessageObject) groupedMessages.messages.get(i)).reactionsChanged = true;
                }
            }
            this.chatAdapter.notifyDataSetChanged(true);
            return;
        }
        MessageObject messageObject = this.messagesDict[0].get(message.getId());
        if (updateReactions) {
            message.forceUpdate = true;
            message.reactionsChanged = true;
        }
        if (this.chatAdapter.isFiltered) {
            LongSparseArray<MessageObject> longSparseArray = this.filteredMessagesDict;
            MessageObject messageObject2 = longSparseArray != null ? (MessageObject) longSparseArray.get(message.getId()) : null;
            int indexOf = this.chatAdapter.filteredMessages.indexOf(messageObject2);
            if (messageObject2 != null && updateReactions) {
                messageObject2.forceUpdate = true;
                messageObject2.reactionsChanged = true;
            }
            if (indexOf >= 0) {
                ChatActivityAdapter chatActivityAdapter = this.chatAdapter;
                chatActivityAdapter.notifyItemChanged(chatActivityAdapter.messagesStartRow + indexOf);
                return;
            }
            return;
        }
        int indexOf2 = this.messages.indexOf(messageObject);
        if (indexOf2 >= 0) {
            ChatActivityAdapter chatActivityAdapter2 = this.chatAdapter;
            chatActivityAdapter2.notifyItemChanged(chatActivityAdapter2.messagesStartRow + indexOf2);
        }
    }

    public ChatMessageCell findMessageCell(int id, boolean visibleForUser) {
        RecyclerListView recyclerListView = this.chatListView;
        if (recyclerListView == null) {
            return null;
        }
        int childCount = recyclerListView.getChildCount();
        for (int i = 0; i < childCount; i++) {
            View childAt = this.chatListView.getChildAt(i);
            if ((this.chatListView.getChildAt(i) instanceof ChatMessageCell) && ((ChatMessageCell) this.chatListView.getChildAt(i)).getMessageObject().getId() == id) {
                if (visibleForUser) {
                    if (childAt.getY() + childAt.getMeasuredHeight() < (this.chatListViewPaddingTop - this.chatListViewPaddingVisibleOffset) - AndroidUtilities.dp(4.0f) || childAt.getY() > this.chatListView.getMeasuredHeight() - this.blurredViewBottomOffset) {
                        return null;
                    }
                }
                return (ChatMessageCell) this.chatListView.getChildAt(i);
            }
        }
        return null;
    }

    public final void startEditingMessageObject(MessageObject messageObject) {
        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();
        checkEditTimer();
        this.chatActivityEnterView.setAllowStickersAndGifs(true, false, false, true);
        updatePinnedMessageView(true);
        updateVisibleRows();
        if (!messageObject.scheduled && !messageObject.isQuickReply()) {
            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$297(tLObject, tL_error);
                }
            });
            return;
        }
        this.chatActivityEnterView.showEditDoneProgress(false, true);
    }

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

    public void lambda$startEditingMessageObject$296(TLObject tLObject) {
        this.editingMessageObjectReqId = 0;
        if (tLObject != null || getUserConfig().getCurrentUser().bot || getParentActivity() == null) {
            return;
        }
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity(), this.themeDelegate);
        builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
        builder.setMessage(LocaleController.getString(R.string.EditMessageError));
        builder.setPositiveButton(LocaleController.getString("OK", 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 setupStickerVibrationAndSound(ChatMessageCell cell) {
        MessagesController.EmojiSound emojiSound;
        MessageObject messageObject = cell.getMessageObject();
        TLRPC.Document document = messageObject.getDocument();
        boolean isAnimatedEmoji = messageObject.isAnimatedEmoji();
        if (!isAnimatedEmoji) {
            if (!MessageObject.isAnimatedStickerDocument(document, this.currentEncryptedChat == null || messageObject.isOut()) || SharedConfig.loopStickers()) {
                return;
            }
        }
        RLottieDrawable lottieAnimation = cell.getPhotoImage().getLottieAnimation();
        if (lottieAnimation == null || !isAnimatedEmoji) {
            return;
        }
        String unwrapEmoji = EmojiAnimationsOverlay.unwrapEmoji(messageObject.getStickerEmoji());
        if (EmojiData.isHeartEmoji(unwrapEmoji)) {
            HashMap hashMap = new HashMap();
            hashMap.put(1, 1);
            hashMap.put(13, 0);
            hashMap.put(59, 1);
            hashMap.put(71, 0);
            hashMap.put(128, 1);
            hashMap.put(140, 0);
            lottieAnimation.setVibrationPattern(hashMap);
        } else if (EmojiData.isPeachEmoji(unwrapEmoji)) {
            HashMap hashMap2 = new HashMap();
            hashMap2.put(34, 1);
            lottieAnimation.setVibrationPattern(hashMap2);
        } else if (EmojiData.isCofinEmoji(unwrapEmoji)) {
            HashMap hashMap3 = new HashMap();
            hashMap3.put(24, 0);
            hashMap3.put(36, 0);
            lottieAnimation.setVibrationPattern(hashMap3);
        }
        if (messageObject.isAnimatedAnimatedEmoji()) {
            lottieAnimation.resetVibrationAfterRestart(true);
        }
        if (lottieAnimation.isRunning() || unwrapEmoji == null || (emojiSound = (MessagesController.EmojiSound) getMessagesController().emojiSounds.get(unwrapEmoji.replace("️", ""))) == null) {
            return;
        }
        getMediaController().playEmojiSound(getAccountInstance(), unwrapEmoji, emojiSound, false);
    }

    public void restartSticker(ChatMessageCell cell) {
        MessageObject messageObject = cell.getMessageObject();
        TLRPC.Document document = messageObject.getDocument();
        if (!messageObject.isAnimatedAnimatedEmoji()) {
            setupStickerVibrationAndSound(cell);
        }
        if (!messageObject.isAnimatedEmoji()) {
            if (!MessageObject.isAnimatedStickerDocument(document, this.currentEncryptedChat == null || messageObject.isOut()) || SharedConfig.loopStickers()) {
                return;
            }
        }
        RLottieDrawable lottieAnimation = cell.getPhotoImage().getLottieAnimation();
        if (lottieAnimation != null) {
            lottieAnimation.restart();
        }
    }

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

    public final 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$298(arrayList2, arrayList, i);
            }
        }, new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$unpinMessage$299(messageObject);
            }
        }, this.themeDelegate).show();
    }

    public void lambda$unpinMessage$298(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$299(MessageObject messageObject) {
        getMessagesController().pinMessage(this.currentChat, this.currentUser, messageObject.getId(), true, false, false);
        this.pinBulletin = null;
    }

    public void openReportChat(int type) {
        Bundle bundle = new Bundle();
        if (DialogObject.isUserDialog(this.dialog_id)) {
            bundle.putLong("user_id", this.dialog_id);
        } else {
            bundle.putLong("chat_id", -this.dialog_id);
        }
        bundle.putInt("report", type);
        ChatActivity chatActivity = new ChatActivity(bundle);
        presentFragment(chatActivity);
        chatActivity.chatActivityDelegate = new ChatActivityDelegate() {
            @Override
            public void onUnpin(boolean z, boolean z2) {
                ChatActivityDelegate.CC.$default$onUnpin(this, z, z2);
            }

            @Override
            public void openHashtagSearch(String str) {
                ChatActivityDelegate.CC.$default$openHashtagSearch(this, str);
            }

            @Override
            public void openReplyMessage(int i) {
                ChatActivityDelegate.CC.$default$openReplyMessage(this, i);
            }

            @Override
            public void onReport() {
                ChatActivity.this.createUndoView();
                if (ChatActivity.this.undoView == null) {
                    return;
                }
                ChatActivity.this.undoView.showWithAction(0L, 74, (Runnable) null);
            }
        };
    }

    public final void openReplyPrivately(String text) {
        long fromChatId = this.selectedObject.getFromChatId();
        ArrayList<MessageObject> arrayList = new ArrayList<>();
        arrayList.add(this.selectedObject);
        Bundle bundle = new Bundle();
        bundle.putLong("user_id", fromChatId);
        ChatActivity chatActivity = new ChatActivity(bundle);
        chatActivity.setQuoteMessage(true);
        presentFragment(chatActivity, false);
        chatActivity.showFieldPanelForForward(true, arrayList);
        if (text != null) {
            chatActivity.getChatActivityEnterView().setFieldText(text);
        }
    }

    public final void copyLink() {
        TLRPC.TL_channels_exportMessageLink tL_channels_exportMessageLink = new TLRPC.TL_channels_exportMessageLink();
        tL_channels_exportMessageLink.id = this.selectedObject.getId();
        tL_channels_exportMessageLink.channel = MessagesController.getInputChannel(this.currentChat);
        getConnectionsManager().sendRequest(tL_channels_exportMessageLink, new RequestDelegate() {
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                ChatActivity.this.lambda$copyLink$301(tLObject, tL_error);
            }
        });
    }

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

    public void lambda$copyLink$300(TLObject tLObject, TLRPC.TL_error tL_error) {
        String str = tLObject != null ? ((TLRPC.TL_exportedMessageLink) tLObject).link : null;
        if (tL_error != null) {
            PlusUtils.showToast(LocaleController.getString("Unavailable", R.string.Unavailable));
        }
        openReplyPrivately(str);
    }

    public final void saveMessageToGallery(MessageObject messageObject) {
        String str = messageObject.messageOwner.attachPath;
        if (!TextUtils.isEmpty(str) && !new File(str).exists()) {
            str = null;
        }
        if (TextUtils.isEmpty(str)) {
            str = FileLoader.getInstance(((BaseFragment) this).currentAccount).getPathToMessage(messageObject.messageOwner).toString();
        }
        MediaController.saveFile(str, getParentActivity(), messageObject.isVideo() ? 1 : 0, (String) null, (String) null);
    }

    public final void processSelectedOption(int r24) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.processSelectedOption(int):void");
    }

    public void lambda$processSelectedOption$302(DialogInterface dialogInterface) {
        dimBehindView(false);
    }

    public void lambda$processSelectedOption$303(DialogInterface dialogInterface) {
        dimBehindView(false);
    }

    public void lambda$processSelectedOption$304() {
        dimBehindView(false);
    }

    public void lambda$processSelectedOption$305(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$306(boolean z, boolean z2, boolean z3, Uri uri) {
        BulletinFactory.FileType fileType;
        if (getParentActivity() == null) {
            return;
        }
        if (z) {
            fileType = BulletinFactory.FileType.PHOTO_TO_DOWNLOADS;
        } else if (z2) {
            fileType = BulletinFactory.FileType.VIDEO_TO_DOWNLOADS;
        } else if (z3) {
            fileType = BulletinFactory.FileType.GIF_TO_DOWNLOADS;
        } else {
            fileType = BulletinFactory.FileType.UNKNOWN;
        }
        BulletinFactory.of(this).createDownloadBulletin(fileType, this.themeDelegate).show();
    }

    public void lambda$processSelectedOption$307(DialogInterface dialogInterface) {
        dimBehindView(false);
    }

    public static void lambda$processSelectedOption$308(boolean[] zArr, View view) {
        zArr[1] = !zArr[1];
        ((CheckBoxCell) view).setChecked(zArr[1], true);
    }

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

    public void lambda$processSelectedOption$311(int i, boolean[] zArr, DialogInterface dialogInterface, 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$310(layout);
            }
        }, 550L);
    }

    public static void lambda$processSelectedOption$310(View view) {
        if (PlusSettings.disableActionsVibrations) {
            return;
        }
        view.performHapticFeedback(3, 2);
    }

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

    public void lambda$processSelectedOption$312(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) || PlusSettings.hideMsgDeletedHint) {
                    return;
                }
                BulletinFactory.of(this).createCopyLinkBulletin(!isThreadChat() && tL_exportedMessageLink.link.contains("/c/"), this.themeDelegate).show();
            } catch (Exception e) {
                FileLog.e(e);
            }
        }
    }

    public void lambda$processSelectedOption$314() {
        dimBehindView(false);
    }

    public void lambda$processSelectedOption$315() {
        dimBehindView(false);
    }

    public static void lambda$processSelectedOption$316(AlertDialog[] alertDialogArr) {
        try {
            alertDialogArr[0].dismiss();
        } catch (Throwable unused) {
        }
        alertDialogArr[0] = null;
    }

    public void lambda$processSelectedOption$318(AlertDialog[] alertDialogArr, final int i) {
        if (alertDialogArr[0] == null) {
            return;
        }
        alertDialogArr[0].setOnCancelListener(new DialogInterface.OnCancelListener() {
            @Override
            public final void onCancel(DialogInterface dialogInterface) {
                ChatActivity.this.lambda$processSelectedOption$317(i, dialogInterface);
            }
        });
        showDialog(alertDialogArr[0]);
    }

    public void lambda$processSelectedOption$317(int i, DialogInterface dialogInterface) {
        getConnectionsManager().cancelRequest(i, true);
    }

    public void lambda$processSelectedOption$319(DialogInterface dialogInterface) {
        dimBehindView(false);
    }

    public void lambda$processSelectedOption$325(MessageObject messageObject, DialogInterface dialogInterface, 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$322(alertDialogArr, tL_messages_editMessage, tLObject, tL_error);
            }
        });
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$processSelectedOption$324(alertDialogArr, sendRequest);
            }
        }, 500L);
    }

    public void lambda$processSelectedOption$322(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$320(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$321(tL_error, tL_messages_editMessage);
                }
            });
        }
    }

    public static void lambda$processSelectedOption$320(AlertDialog[] alertDialogArr) {
        try {
            alertDialogArr[0].dismiss();
        } catch (Throwable unused) {
        }
        alertDialogArr[0] = null;
    }

    public void lambda$processSelectedOption$321(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$324(AlertDialog[] alertDialogArr, final int i) {
        if (alertDialogArr[0] == null) {
            return;
        }
        alertDialogArr[0].setOnCancelListener(new DialogInterface.OnCancelListener() {
            @Override
            public final void onCancel(DialogInterface dialogInterface) {
                ChatActivity.this.lambda$processSelectedOption$323(i, dialogInterface);
            }
        });
        showDialog(alertDialogArr[0]);
    }

    public void lambda$processSelectedOption$323(int i, DialogInterface dialogInterface) {
        getConnectionsManager().cancelRequest(i, true);
    }

    public void lambda$processSelectedOption$326() {
        dimBehindView(false);
    }

    public Boolean lambda$processSelectedOption$327(URLSpan uRLSpan) {
        didPressMessageUrl(uRLSpan, false, this.selectedObject, null);
        return Boolean.TRUE;
    }

    public void lambda$processSelectedOption$329(java.lang.String[] r15, java.lang.String r16, java.lang.String r17, org.telegram.tgnet.TLRPC.InputPeer r18, int r19, java.lang.CharSequence r20, org.telegram.messenger.Utilities.CallbackReturn r21, java.util.concurrent.atomic.AtomicBoolean r22, java.util.concurrent.atomic.AtomicReference r23, java.lang.String r24) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.lambda$processSelectedOption$329(java.lang.String[], java.lang.String, java.lang.String, org.telegram.tgnet.TLRPC$InputPeer, int, java.lang.CharSequence, org.telegram.messenger.Utilities$CallbackReturn, java.util.concurrent.atomic.AtomicBoolean, java.util.concurrent.atomic.AtomicReference, java.lang.String):void");
    }

    public void lambda$processSelectedOption$328() {
        dimBehindView(false);
    }

    public static void lambda$processSelectedOption$330(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$processSelectedOption$331() {
        dimBehindView(false);
    }

    public void lambda$processSelectedOption$334(final TLRPC.User user, View view) {
        try {
            final String userName = UserObject.getUserName(user);
            String str = user.username;
            if (str != null && !str.isEmpty()) {
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                builder.setItems(new CharSequence[]{userName, "@" + user.username}, new DialogInterface.OnClickListener() {
                    @Override
                    public final void onClick(DialogInterface dialogInterface, int i) {
                        ChatActivity.this.lambda$processSelectedOption$333(userName, user, dialogInterface, i);
                    }
                });
                showDialog(builder.create());
            } else {
                ((ClipboardManager) ApplicationLoader.applicationContext.getSystemService("clipboard")).setPrimaryClip(ClipData.newPlainText("label", UserObject.getUserName(user)));
                Toast.makeText(getParentActivity(), LocaleController.formatString("Copied", R.string.Copied, new Object[]{userName}), 0).show();
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
    }

    public void lambda$processSelectedOption$333(String str, TLRPC.User user, DialogInterface dialogInterface, int i) {
        if (i != 0) {
            str = "@" + user.username;
        }
        ((ClipboardManager) ApplicationLoader.applicationContext.getSystemService("clipboard")).setPrimaryClip(ClipData.newPlainText("label", str));
        Toast.makeText(getParentActivity(), LocaleController.formatString("Copied", R.string.Copied, new Object[]{str}), 0).show();
    }

    public static void lambda$processSelectedOption$336(final TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.lambda$processSelectedOption$335(tLObject);
            }
        });
    }

    public static void lambda$processSelectedOption$335(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 (tL_exportedMessageLink.link.contains("/c/")) {
                    Toast.makeText(ApplicationLoader.applicationContext, LocaleController.getString("LinkCopiedPrivate", R.string.LinkCopiedPrivate), 0).show();
                } else {
                    Toast.makeText(ApplicationLoader.applicationContext, LocaleController.getString("LinkCopied", R.string.LinkCopied), 0).show();
                }
            } catch (Exception e) {
                FileLog.e(e);
            }
        }
    }

    public static void lambda$processSelectedOption$338(final TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.lambda$processSelectedOption$337(tLObject);
            }
        });
    }

    public static void lambda$processSelectedOption$337(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 (tL_exportedMessageLink.link.contains("/c/")) {
                    Toast.makeText(ApplicationLoader.applicationContext, LocaleController.getString("LinkCopiedPrivate", R.string.LinkCopiedPrivate), 0).show();
                } else {
                    Toast.makeText(ApplicationLoader.applicationContext, LocaleController.getString("LinkCopied", R.string.LinkCopied), 0).show();
                }
            } catch (Exception e) {
                FileLog.e(e);
            }
        }
    }

    public static void lambda$processSelectedOption$339() {
        PlusUtils.showToast(LocaleController.getString("LinkLimitReached", R.string.LinkLimitReached));
    }

    public void lambda$processSelectedOption$342(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$340(tL_messages_sendScheduledMessages);
                }
            });
        } else if (tL_error.text != null) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$processSelectedOption$341(tL_error);
                }
            });
        }
    }

    public void lambda$processSelectedOption$340(TLRPC.TL_messages_sendScheduledMessages tL_messages_sendScheduledMessages) {
        NotificationCenter notificationCenter = NotificationCenter.getInstance(((BaseFragment) this).currentAccount);
        int i = NotificationCenter.messagesDeleted;
        Object[] objArr = new Object[4];
        objArr[0] = tL_messages_sendScheduledMessages.id;
        long clientUserId = getUserConfig().getClientUserId();
        long j = this.dialog_id;
        objArr[1] = Long.valueOf(clientUserId == j ? 0L : -j);
        Boolean bool = Boolean.TRUE;
        objArr[2] = bool;
        objArr[3] = bool;
        notificationCenter.postNotificationName(i, objArr);
    }

    public void lambda$processSelectedOption$341(TLRPC.TL_error tL_error) {
        if (tL_error.text.startsWith("SLOWMODE_WAIT_")) {
            AlertsCreator.showSimpleToast(this, LocaleController.getString("SlowmodeSendError", R.string.SlowmodeSendError));
        } else if (tL_error.text.equals("CHAT_SEND_MEDIA_FORBIDDEN")) {
            AlertsCreator.showSimpleToast(this, LocaleController.getString("AttachMediaRestrictedForever", R.string.AttachMediaRestrictedForever));
        } else {
            AlertsCreator.showSimpleToast(this, tL_error.text);
        }
    }

    public void lambda$processSelectedOption$343(MessageObject.GroupedMessages groupedMessages, MessageObject messageObject, boolean z, int i) {
        if (groupedMessages != null && !groupedMessages.messages.isEmpty()) {
            SendMessagesHelper.getInstance(((BaseFragment) this).currentAccount).editMessage((MessageObject) groupedMessages.messages.get(0), (String) null, false, this, (ArrayList) null, i);
        } else {
            SendMessagesHelper.getInstance(((BaseFragment) this).currentAccount).editMessage(messageObject, (String) null, false, this, (ArrayList) null, i);
        }
    }

    public void lambda$processSelectedOption$344(DialogInterface dialogInterface) {
        dimBehindView(false);
    }

    public void lambda$processSelectedOption$351(final MessageObject messageObject, final TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tLObject != null) {
            if (tLObject instanceof TLRPC.TL_channels_sponsoredMessageReportResultChooseOption) {
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.this.lambda$processSelectedOption$345(tLObject, messageObject);
                    }
                });
                return;
            } else if (tLObject instanceof TLRPC.TL_channels_sponsoredMessageReportResultReported) {
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.this.lambda$processSelectedOption$347(messageObject);
                    }
                }, 200L);
                return;
            } else {
                if (tLObject instanceof TLRPC.TL_channels_sponsoredMessageReportResultAdsHidden) {
                    AndroidUtilities.runOnUIThread(new Runnable() {
                        @Override
                        public final void run() {
                            ChatActivity.this.lambda$processSelectedOption$348(messageObject);
                        }
                    }, 200L);
                    return;
                }
                return;
            }
        }
        if (tL_error == null || !"AD_EXPIRED".equalsIgnoreCase(tL_error.text)) {
            return;
        }
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$processSelectedOption$350(messageObject);
            }
        }, 200L);
    }

    public void lambda$processSelectedOption$345(TLObject tLObject, MessageObject messageObject) {
        new ReportAdBottomSheet(this.contentView.getContext(), ((BaseFragment) this).resourceProvider, messageObject, this.currentChat).setReportChooseOption((TLRPC.TL_channels_sponsoredMessageReportResultChooseOption) tLObject).setListener(new AnonymousClass162(messageObject)).show();
    }

    public class AnonymousClass162 implements ReportAdBottomSheet.Listener {
        public final MessageObject val$message;

        public AnonymousClass162(final MessageObject val$message) {
            this.val$message = val$message;
        }

        @Override
        public void onReported() {
            final MessageObject messageObject = this.val$message;
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.AnonymousClass162.this.lambda$onReported$1(messageObject);
                }
            }, 200L);
        }

        public void lambda$onReported$1(MessageObject messageObject) {
            BulletinFactory.of(ChatActivity.this).createAdReportedBulletin(AndroidUtilities.replaceSingleTag(LocaleController.getString("AdReported", R.string.AdReported), -1, 2, new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.AnonymousClass162.this.lambda$onReported$0();
                }
            }, ((BaseFragment) ChatActivity.this).resourceProvider)).show();
            ChatActivity.this.removeFromSponsored(messageObject);
            ChatActivity.this.removeMessageWithThanos(messageObject);
        }

        public void lambda$onReported$0() {
            Browser.openUrl(ChatActivity.this.getContext(), "https://promote.telegram.org/guidelines");
        }

        @Override
        public void onHidden() {
            final MessageObject messageObject = this.val$message;
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.AnonymousClass162.this.lambda$onHidden$2(messageObject);
                }
            }, 200L);
        }

        public void lambda$onHidden$2(MessageObject messageObject) {
            BulletinFactory.of(ChatActivity.this).createAdReportedBulletin(LocaleController.getString("AdHidden", R.string.AdHidden)).show();
            ChatActivity.this.removeFromSponsored(messageObject);
            ChatActivity.this.removeMessageWithThanos(messageObject);
        }

        @Override
        public void onPremiumRequired() {
            ChatActivity.this.showDialog(new PremiumFeatureBottomSheet(ChatActivity.this, 3, true));
        }
    }

    public void lambda$processSelectedOption$347(MessageObject messageObject) {
        BulletinFactory.of(this).createAdReportedBulletin(AndroidUtilities.replaceSingleTag(LocaleController.getString("AdReported", R.string.AdReported), -1, 2, new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$processSelectedOption$346();
            }
        }, ((BaseFragment) this).resourceProvider)).show();
        removeFromSponsored(messageObject);
        removeMessageWithThanos(messageObject);
    }

    public void lambda$processSelectedOption$346() {
        Browser.openUrl(getContext(), "https://promote.telegram.org/guidelines");
    }

    public void lambda$processSelectedOption$348(MessageObject messageObject) {
        BulletinFactory.of(this).createAdReportedBulletin(LocaleController.getString(R.string.AdHidden)).show();
        getMessagesController().disableAds(false);
        removeFromSponsored(messageObject);
        removeMessageWithThanos(messageObject);
    }

    public void lambda$processSelectedOption$350(MessageObject messageObject) {
        BulletinFactory.of(this).createAdReportedBulletin(AndroidUtilities.replaceSingleTag(LocaleController.getString("AdReported", R.string.AdReported), -1, 2, new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$processSelectedOption$349();
            }
        }, ((BaseFragment) this).resourceProvider)).show();
        removeFromSponsored(messageObject);
        removeMessageWithThanos(messageObject);
    }

    public void lambda$processSelectedOption$349() {
        Browser.openUrl(getContext(), "https://promote.telegram.org/guidelines");
    }

    public void lambda$processSelectedOption$352(MessageObject messageObject, boolean z, int i) {
        ArrayList arrayList = new ArrayList();
        arrayList.add(messageObject);
        getSendMessagesHelper().sendMessage(arrayList, getUserConfig().getClientUserId(), false, false, !PlusSettings.hideScheduledDownloadReminder, i);
        PlusSettings.getScheduledDownloadsIds().put(messageObject.getFileName(), messageObject.getDialogId() + "," + messageObject.getId());
        PlusSettings.saveScheduledDownloadsIds();
    }

    public final java.lang.CharSequence getTranslatableText() {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.getTranslatableText():java.lang.CharSequence");
    }

    public final void translateFromCell(ChatMessageCell finalMessageCell, MessageObject messageObject, MessageObject.GroupedMessages messageObjectGroup) {
        String charSequence = getTranslatableText().toString();
        String string = LocaleController.getString("Translation", R.string.Translation);
        if (!TextUtils.isEmpty(this.tText)) {
            string = this.tText;
        }
        boolean z = messageObject.isPoll() && messageObject.hasReactions();
        Matcher matcher = Pattern.compile("\u200c\u200c\\n\\n" + string + "\\n.*\u200c\u200c", 32).matcher(charSequence);
        if (!matcher.find()) {
            BaseTranslationEngine.translate(charSequence, new AnonymousClass163(finalMessageCell, charSequence, z));
        } else if (finalMessageCell != null) {
            PlusUtils.setMessageContent(messageObject, finalMessageCell, charSequence.replace(matcher.group(), ""));
            this.chatAdapter.updateRowWithMessageObject(messageObject, true, false);
        }
    }

    public class AnonymousClass163 implements BaseTranslationEngine.TranslateCallBack {
        public String fromLang;
        public String toLang;
        public final ChatMessageCell val$finalMessageCell;
        public final String val$original;
        public final boolean val$pollAndReactions;

        public AnonymousClass163(final ChatMessageCell val$finalMessageCell, final String val$original, final boolean val$pollAndReactions) {
            this.val$finalMessageCell = val$finalMessageCell;
            this.val$original = val$original;
            this.val$pollAndReactions = val$pollAndReactions;
        }

        public void onSuccess(String translation, String fl, String tl) {
            this.fromLang = fl;
            this.toLang = tl;
            onSuccess(translation);
        }

        public void onSuccess(String translation) {
            if (this.val$finalMessageCell != null) {
                String string = LocaleController.getString("Translation", R.string.Translation);
                if (!TextUtils.isEmpty(this.fromLang)) {
                    string = string + " " + this.fromLang + "-" + this.toLang;
                    ChatActivity.this.tText = string;
                }
                MessageObject messageObject = this.val$finalMessageCell.getMessageObject();
                ChatMessageCell chatMessageCell = this.val$finalMessageCell;
                StringBuilder sb = new StringBuilder();
                sb.append(messageObject.isPoll() ? "" : this.val$original);
                sb.append("\u200c\u200c\n\n");
                sb.append(string);
                sb.append("\n");
                sb.append(translation);
                sb.append("\u200c\u200c");
                sb.append(this.val$pollAndReactions ? "\n\n\n" : "");
                PlusUtils.setMessageContent(messageObject, chatMessageCell, sb.toString());
                ChatActivity.this.chatAdapter.updateRowWithMessageObject(messageObject, true, false);
            }
        }

        public void onError(Exception error) {
            String str;
            if (ChatActivity.this.getParentActivity() == null) {
                return;
            }
            boolean isNetworkOnline = ApplicationLoader.isNetworkOnline();
            AlertDialog.Builder builder = new AlertDialog.Builder(ChatActivity.this.getParentActivity());
            StringBuilder sb = new StringBuilder();
            sb.append(LocaleController.getString("TranslateFailed", R.string.TranslateFailed));
            String str2 = "";
            if (error != null) {
                StringBuilder sb2 = new StringBuilder();
                sb2.append("\n\n");
                sb2.append(error.getMessage() != null ? error.getMessage() : error.getClass());
                str = sb2.toString();
            } else {
                str = "";
            }
            sb.append(str);
            if (!isNetworkOnline) {
                str2 = "\n\n" + LocaleController.getString("Offline", R.string.Offline);
            }
            sb.append(str2);
            builder.setMessage(sb.toString());
            if (isNetworkOnline) {
                builder.setNeutralButton(LocaleController.getString("TranslationProvider", R.string.TranslationProvider), new DialogInterface.OnClickListener() {
                    @Override
                    public final void onClick(DialogInterface dialogInterface, int i) {
                        ChatActivity.AnonymousClass163.this.lambda$onError$0(dialogInterface, i);
                    }
                });
                builder.setPositiveButton(LocaleController.getString("Retry", R.string.Retry), new DialogInterface.OnClickListener() {
                    @Override
                    public final void onClick(DialogInterface dialogInterface, int i) {
                        ChatActivity.AnonymousClass163.this.lambda$onError$1(dialogInterface, i);
                    }
                });
            }
            builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
            ChatActivity.this.showDialog(builder.create());
        }

        public void lambda$onError$0(DialogInterface dialogInterface, int i) {
            PlusUtils.showProviderSelector(ChatActivity.this.getParentActivity(), new PlusUtils.TranslateCallBack() {
                public void onChanged(String str) {
                    PlusUtils.TranslateCallBack.-CC.$default$onChanged(this, str);
                }

                public void onSuccess(String translation) {
                }

                public void onProviderChanged(int provider) {
                    ChatActivity.this.processSelectedOption(62);
                }
            });
        }

        public void lambda$onError$1(DialogInterface dialogInterface, int i) {
            ChatActivity.this.processSelectedOption(62);
        }
    }

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

    public final void deleteFromCache(final MessageObject messageObject) {
        final int i;
        String str;
        int i2;
        String str2;
        String str3;
        try {
            File pathToMessage = FileLoader.getInstance(((BaseFragment) this).currentAccount).getPathToMessage(messageObject.messageOwner);
            if (!pathToMessage.exists() && (str3 = messageObject.messageOwner.attachPath) != null && str3.length() > 0) {
                pathToMessage = new File(str3);
            }
            final ArrayList<File> arrayList = new ArrayList<>();
            TLRPC.Message message = messageObject.messageOwner;
            TLRPC.MessageMedia messageMedia = message.media;
            if (messageMedia instanceof TLRPC.TL_messageMediaPhoto) {
                i = 2;
                int size = messageMedia.photo.sizes.size();
                for (int i3 = 0; i3 < size; i3++) {
                    File pathToAttach = FileLoader.getInstance(((BaseFragment) this).currentAccount).getPathToAttach((TLRPC.PhotoSize) message.media.photo.sizes.get(i3));
                    if (pathToAttach != null && pathToAttach.toString().length() > 0) {
                        arrayList.add(pathToAttach);
                    }
                }
            } else {
                if (messageMedia instanceof TLRPC.TL_messageMediaDocument) {
                    File pathToAttach2 = FileLoader.getInstance(((BaseFragment) this).currentAccount).getPathToAttach(message.media.document);
                    if (pathToAttach2 != null && pathToAttach2.toString().length() > 0) {
                        arrayList.add(pathToAttach2);
                    }
                    int size2 = message.media.document.thumbs.size();
                    for (int i4 = 0; i4 < size2; i4++) {
                        File pathToAttach3 = FileLoader.getInstance(((BaseFragment) this).currentAccount).getPathToAttach((TLRPC.PhotoSize) message.media.document.thumbs.get(i4));
                        if (pathToAttach3 != null && pathToAttach3.toString().length() > 0) {
                            arrayList.add(pathToAttach3);
                        }
                    }
                }
                i = 0;
            }
            if (pathToMessage.exists() && !arrayList.contains(pathToMessage)) {
                arrayList.add(pathToMessage);
            } else if (!arrayList.isEmpty() && arrayList.get(0).exists()) {
                pathToMessage = arrayList.get(0);
            }
            long j = messageObject.getDocument() != null ? messageObject.getDocument().size : 0L;
            if (j <= 0) {
                pathToMessage = FileLoader.getInstance(((BaseFragment) this).currentAccount).getPathToMessage(messageObject.messageOwner);
                if (!pathToMessage.exists() && (str2 = messageObject.messageOwner.attachPath) != null && str2.length() > 0) {
                    pathToMessage = new File(str2);
                }
                if (pathToMessage.exists()) {
                    j = (int) pathToMessage.length();
                }
            }
            if (j > 0) {
                final String formatFileSize = AndroidUtilities.formatFileSize(j);
                if (PlusSettings.doNotShowDialogOnCacheDeleting) {
                    deleteFilesCache(arrayList, i, messageObject, formatFileSize);
                    return;
                }
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                builder.setTitle(LocaleController.getString("ClearHistoryCache", R.string.ClearHistoryCache));
                String str4 = pathToMessage.getName() + "\n\n" + LocaleController.formatString("ClearCacheFile", R.string.ClearCacheFile, new Object[]{formatFileSize});
                boolean canDownloadMedia = getDownloadController().canDownloadMedia(this.selectedObject);
                if (canDownloadMedia) {
                    StringBuilder sb = new StringBuilder();
                    sb.append(str4);
                    sb.append("\n\n");
                    sb.append(LocaleController.getString("AutoDownloadMedia", R.string.AutoDownloadMedia));
                    sb.append(": ");
                    if (canDownloadMedia) {
                        str = "Yes";
                        i2 = R.string.Yes;
                    } else {
                        str = "No";
                        i2 = R.string.No;
                    }
                    sb.append(LocaleController.getString(str, i2));
                    str4 = sb.toString();
                }
                builder.setMessage(str4);
                builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
                    @Override
                    public final void onClick(DialogInterface dialogInterface, int i5) {
                        ChatActivity.this.lambda$deleteFromCache$353(arrayList, i, messageObject, formatFileSize, dialogInterface, i5);
                    }
                });
                showDialog(builder.create());
                return;
            }
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$deleteFromCache$354();
                }
            });
        } catch (Exception e) {
            FileLog.e(e);
        }
    }

    public void lambda$deleteFromCache$353(ArrayList arrayList, int i, MessageObject messageObject, String str, DialogInterface dialogInterface, int i2) {
        deleteFilesCache(arrayList, i, messageObject, str);
    }

    public void lambda$deleteFromCache$354() {
        Toast.makeText(getParentActivity(), LocaleController.formatString("CacheEmpty", R.string.CacheEmpty, new Object[0]), 0).show();
    }

    public final void deleteFilesCache(ArrayList<File> files, int type, MessageObject messageObject, final String size) {
        getFileLoader().deleteFiles(files, type);
        if (FileLoader.getInstance(((BaseFragment) this).currentAccount).getPathToMessage(messageObject.messageOwner).exists()) {
            FileLoader.getInstance(((BaseFragment) this).currentAccount).getPathToMessage(messageObject.messageOwner).delete();
        }
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$deleteFilesCache$355(size);
            }
        });
        messageObject.checkMediaExistance();
        messageObject.forceUpdate = true;
        this.chatAdapter.updateRowWithMessageObject(messageObject, false, false);
    }

    public void lambda$deleteFilesCache$355(String str) {
        Toast.makeText(getParentActivity(), LocaleController.formatString("Cleared", R.string.Cleared, new Object[]{str}), 0).show();
    }

    @Override
    public boolean didSelectDialogs(DialogsActivity dialogsFragment, ArrayList<MessagesStorage.TopicKey> dids, CharSequence message, boolean param, TopicsFragment topicsFragment, boolean edit) {
        return didSelectDialogs(dialogsFragment, dids, message, param, topicsFragment);
    }

    @Override
    public boolean didSelectDialogs(DialogsActivity fragment, ArrayList<MessagesStorage.TopicKey> dids, CharSequence message, boolean param, TopicsFragment topicsFragment) {
        long j;
        int i;
        ArrayList<MessageObject> arrayList;
        ChatActivityEnterView chatActivityEnterView;
        ChatActivityEnterView chatActivityEnterView2;
        MessageObject messageObject;
        if (((this.messagePreviewParams == null && (!fragment.isQuote || this.replyingMessageObject == null)) || (fragment.isQuote && this.replyingMessageObject == null)) && this.forwardingMessage == null && this.selectedMessagesIds[0].size() == 0 && this.selectedMessagesIds[1].size() == 0) {
            return false;
        }
        boolean z = fragment == null || fragment.notify;
        int i2 = fragment != null ? fragment.scheduleDate : 0;
        ArrayList<MessageObject> arrayList2 = new ArrayList<>();
        MessageObject messageObject2 = this.forwardingMessage;
        if (messageObject2 != null) {
            MessageObject.GroupedMessages groupedMessages = this.forwardingMessageGroup;
            if (groupedMessages != null) {
                arrayList2.addAll(groupedMessages.messages);
            } else {
                arrayList2.add(messageObject2);
            }
        } else {
            for (int i3 = 1; i3 >= 0; i3--) {
                ArrayList arrayList3 = new ArrayList();
                for (int i4 = 0; i4 < this.selectedMessagesIds[i3].size(); i4++) {
                    arrayList3.add(Integer.valueOf(this.selectedMessagesIds[i3].keyAt(i4)));
                }
                Collections.sort(arrayList3);
                for (int i5 = 0; i5 < arrayList3.size(); i5++) {
                    MessageObject messageObject3 = this.selectedMessagesIds[i3].get(((Integer) arrayList3.get(i5)).intValue());
                    if (messageObject3 != null) {
                        arrayList2.add(messageObject3);
                    }
                }
            }
        }
        for (int i6 = 0; i6 < dids.size(); i6++) {
            TLRPC.Chat chat = getMessagesController().getChat(Long.valueOf(-dids.get(i6).dialogId));
            if (chat != null) {
                for (int i7 = 0; i7 < arrayList2.size(); i7++) {
                    int canSendMessageToChat = SendMessagesHelper.canSendMessageToChat(chat, arrayList2.get(i7));
                    if (canSendMessageToChat != 0) {
                        AlertsCreator.showSendMediaAlert(canSendMessageToChat, fragment, (Theme.ResourcesProvider) null);
                        return false;
                    }
                }
            }
        }
        if (this.forwardingMessage != null) {
            this.forwardingMessage = null;
            this.forwardingMessageGroup = null;
        } else {
            for (int i8 = 1; i8 >= 0; i8--) {
                this.selectedMessagesCanCopyIds[i8].clear();
                this.selectedMessagesCanStarIds[i8].clear();
                this.selectedMessagesIds[i8].clear();
            }
            hideActionMode();
            updatePinnedMessageView(true);
            updateVisibleRows();
        }
        if (dids.size() > 1 || dids.get(0).dialogId == getUserConfig().getClientUserId() || message != null) {
            this.messagePreviewParams = null;
            hideFieldPanel(false);
            int i9 = 0;
            while (i9 < dids.size()) {
                long j2 = dids.get(i9).dialogId;
                if (message != null) {
                    j = j2;
                    i = i9;
                    arrayList = arrayList2;
                    SendMessagesHelper.SendMessageParams of = SendMessagesHelper.SendMessageParams.of(message.toString(), j2, (MessageObject) null, (MessageObject) null, (TLRPC.WebPage) null, true, (ArrayList) null, (TLRPC.ReplyMarkup) null, (HashMap) null, z, i2, (MessageObject.SendAnimationData) null, false);
                    of.quick_reply_shortcut = this.quickReplyShortcut;
                    of.quick_reply_shortcut_id = getQuickReplyId();
                    getSendMessagesHelper().sendMessage(of);
                } else {
                    j = j2;
                    i = i9;
                    arrayList = arrayList2;
                }
                getSendMessagesHelper().sendMessage(arrayList, j, !QuoteForward, PlusSettings.deleteSharedMediaCaption, z, i2);
                i9 = i + 1;
                arrayList2 = arrayList;
            }
            ArrayList<MessageObject> arrayList4 = arrayList2;
            fragment.finishFragment();
            createUndoView();
            if (this.undoView != null) {
                if (dids.size() == 1) {
                    if (!BulletinFactory.of(this).showForwardedBulletinWithTag(dids.get(0).dialogId, arrayList4.size())) {
                        this.undoView.showWithAction(dids.get(0).dialogId, 53, Integer.valueOf(arrayList4.size()));
                    }
                } else {
                    this.undoView.showWithAction(0L, 53, Integer.valueOf(arrayList4.size()), Integer.valueOf(dids.size()), (Runnable) null, (Runnable) null);
                }
            }
        } else {
            MessagesStorage.TopicKey topicKey = dids.get(0);
            long j3 = topicKey.dialogId;
            if (j3 != this.dialog_id || getTopicId() != topicKey.topicId || this.chatMode == 2) {
                Bundle bundle = new Bundle();
                bundle.putBoolean("scrollToTopOnResume", this.scrollToTopOnResume);
                if (DialogObject.isEncryptedDialog(j3)) {
                    bundle.putInt("enc_id", DialogObject.getEncryptedChatId(j3));
                } else {
                    if (DialogObject.isUserDialog(j3)) {
                        bundle.putLong("user_id", j3);
                    } else {
                        bundle.putLong("chat_id", -j3);
                    }
                    if (!getMessagesController().checkCanOpenChat(bundle, fragment)) {
                        return true;
                    }
                }
                bundle.putBoolean("historyPreloaded", false);
                addToPulledDialogsMyself();
                ChatActivity chatActivity = new ChatActivity(bundle);
                if (topicKey.topicId != 0) {
                    ForumUtilities.applyTopic(chatActivity, topicKey);
                    if (fragment != null) {
                        fragment.removeSelfFromStack();
                    }
                }
                if (presentFragment(chatActivity, true)) {
                    if (fragment.isQuote && this.replyingMessageObject != null) {
                        ChatActivityEnterView chatActivityEnterView3 = this.chatActivityEnterView;
                        if (chatActivityEnterView3 != null && (chatActivityEnterView = chatActivity.chatActivityEnterView) != null) {
                            chatActivityEnterView.setFieldText(chatActivityEnterView3.getFieldText());
                        }
                        MessageObject.GroupedMessages groupedMessages2 = this.replyingQuoteGroup;
                        if (groupedMessages2 != null) {
                            chatActivity.replyingQuoteGroup = groupedMessages2;
                        } else {
                            MessageObject messageObject4 = this.replyingMessageObject;
                            if (messageObject4 != null) {
                                chatActivity.replyingQuoteGroup = getGroup(messageObject4.getGroupId());
                            }
                        }
                        MessageObject messageObject5 = this.replyingTopMessage;
                        if (messageObject5 != null) {
                            chatActivity.replyingTopMessage = messageObject5;
                        } else {
                            MessageObject messageObject6 = this.threadMessageObject;
                            if (messageObject6 != null) {
                                chatActivity.replyingTopMessage = messageObject6;
                            }
                        }
                        chatActivity.showFieldPanelForReplyQuote(this.replyingMessageObject, this.replyingQuote);
                    } else {
                        chatActivity.showFieldPanelForForward(true, arrayList2);
                        if (this.forwardLink != null) {
                            chatActivity.getChatActivityEnterView().setFieldText(this.forwardLink);
                            this.forwardLink = null;
                        }
                    }
                    if (!AndroidUtilities.isTablet()) {
                        removeSelfFromStack();
                    }
                } else {
                    fragment.finishFragment();
                }
            } else {
                ArrayList arrayList5 = new ArrayList(getParentLayout().getFragmentStack());
                if (!arrayList5.isEmpty() && arrayList5.get(arrayList5.size() - 1) == fragment) {
                    fragment.finishFragment();
                } else {
                    int indexOf = arrayList5.indexOf(fragment);
                    if (indexOf > 0) {
                        while (indexOf < arrayList5.size()) {
                            if (indexOf == arrayList5.size() - 1) {
                                ((BaseFragment) arrayList5.get(indexOf)).finishFragment();
                            } else {
                                fragment.removeSelfFromStack();
                            }
                            indexOf++;
                        }
                    }
                }
                moveScrollToLastMessage(false);
                if (fragment.isQuote && (messageObject = this.replyingMessageObject) != null) {
                    showFieldPanelForReplyQuote(messageObject, this.replyingQuote);
                } else {
                    showFieldPanelForForward(true, arrayList2);
                }
                if (AndroidUtilities.isTablet()) {
                    hideActionMode();
                    updatePinnedMessageView(true);
                }
                updateVisibleRows();
                if (this.keyboardWasVisible && (chatActivityEnterView2 = this.chatActivityEnterView) != null) {
                    chatActivityEnterView2.openKeyboardInternal();
                    this.chatActivityEnterView.freezeEmojiView(false);
                    this.keyboardWasVisible = false;
                }
            }
        }
        return true;
    }

    public boolean checkRecordLocked(final boolean forceCloseOnDiscard) {
        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("DiscardVideoMessageTitle", R.string.DiscardVideoMessageTitle));
            builder.setMessage(LocaleController.getString("DiscardVideoMessageDescription", R.string.DiscardVideoMessageDescription));
        } else {
            builder.setTitle(LocaleController.getString("DiscardVoiceMessageTitle", R.string.DiscardVoiceMessageTitle));
            builder.setMessage(LocaleController.getString("DiscardVoiceMessageDescription", R.string.DiscardVoiceMessageDescription));
        }
        builder.setPositiveButton(LocaleController.getString("DiscardVoiceMessageAction", R.string.DiscardVoiceMessageAction), new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                ChatActivity.this.lambda$checkRecordLocked$357(forceCloseOnDiscard, dialogInterface, i);
            }
        });
        builder.setNegativeButton(LocaleController.getString("Continue", R.string.Continue), null);
        showDialog(builder.create());
        return true;
    }

    public void lambda$checkRecordLocked$357(boolean z, DialogInterface dialogInterface, int i) {
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView != null) {
            if (z) {
                lambda$onBackPressed$358();
            } else {
                chatActivityEnterView.cancelRecordingAudioVideo();
            }
        }
    }

    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 (closeStoryViewer()) {
            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()) || checkIfEditingMessage(false)) {
            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$358();
            }
        });
        return false;
    }

    public final 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 DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                ChatActivity.this.lambda$showQuickRepliesRemoveAlert$359(dialogInterface, i);
            }
        }).setNegativeButton(LocaleController.getString(R.string.Cancel), null).create());
    }

    public void lambda$showQuickRepliesRemoveAlert$359(DialogInterface dialogInterface, int i) {
        lambda$onBackPressed$358();
    }

    public final void showBusinessLinksDiscardAlert(final Runnable onDiscard) {
        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 DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                onDiscard.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 boolean checkIfEditingMessage(final boolean forceCloseOnDiscard) {
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView == null || chatActivityEnterView.getEditingMessageObject() == null) {
            return false;
        }
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity(), this.themeDelegate);
        builder.setTitle(LocaleController.getString("AccDescrCancelEdit", R.string.AccDescrCancelEdit));
        builder.setNeutralButton(LocaleController.getString("DiscardVoiceMessageAction", R.string.DiscardVoiceMessageAction), new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                ChatActivity.this.lambda$checkIfEditingMessage$361(forceCloseOnDiscard, dialogInterface, i);
            }
        });
        builder.setPositiveButton(LocaleController.getString("ApplyChanges", R.string.ApplyChanges), new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                ChatActivity.this.lambda$checkIfEditingMessage$362(forceCloseOnDiscard, dialogInterface, i);
            }
        });
        builder.setNegativeButton(LocaleController.getString("Continue", R.string.Continue), null);
        showDialog(builder.create());
        return true;
    }

    public void lambda$checkIfEditingMessage$361(boolean z, DialogInterface dialogInterface, int i) {
        if (this.chatActivityEnterView == null || !z) {
            return;
        }
        lambda$onBackPressed$358();
    }

    public void lambda$checkIfEditingMessage$362(boolean z, DialogInterface dialogInterface, int i) {
        ChatActivityEnterView chatActivityEnterView = this.chatActivityEnterView;
        if (chatActivityEnterView != null) {
            chatActivityEnterView.doneEditingMessage();
            if (z) {
                lambda$onBackPressed$358();
            }
        }
    }

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

    public void clearSelectionMode(boolean suppressUpdateMessageObject) {
        for (int i = 1; i >= 0; i--) {
            this.selectedMessagesIds[i].clear();
            this.selectedMessagesCanCopyIds[i].clear();
            this.selectedMessagesCanStarIds[i].clear();
        }
        hideActionMode();
        updatePinnedMessageView(true);
        updateVisibleRows(suppressUpdateMessageObject);
        updateSelectedMessageReactions();
    }

    public void onListItemAnimatorTick() {
        invalidateMessagesVisiblePart();
        if (this.scrimView != null) {
            ((BaseFragment) this).fragmentView.invalidate();
        }
    }

    public void setSavedDialog(long savedDialogId) {
        this.threadMessageId = savedDialogId;
    }

    public void setQuickReplyId(long topicId) {
        this.threadMessageId = topicId;
        TLRPC.TL_message tL_message = new TLRPC.TL_message();
        ((TLRPC.Message) tL_message).id = (int) topicId;
        new MessageObject(((BaseFragment) this).currentAccount, tL_message, false, false);
    }

    public void setThreadMessages(ArrayList<MessageObject> messageObjects, TLRPC.Chat originalChat, int originalMessage, int maxInboxReadId, int maxOutboxReadId, TLRPC.TL_forumTopic forumTopic) {
        this.forumTopic = forumTopic;
        this.threadMessageObjects = messageObjects;
        MessageObject messageObject = messageObjects.get(messageObjects.size() - 1);
        this.threadMessageObject = messageObject;
        this.replyingMessageObject = messageObject;
        this.threadMaxInboxReadId = maxInboxReadId;
        this.threadMaxOutboxReadId = maxOutboxReadId;
        this.replyMaxReadId = Math.max(1, maxInboxReadId);
        this.threadMessageId = this.threadMessageObject.getId();
        this.replyOriginalMessageId = originalMessage;
        this.replyOriginalChat = originalChat;
        boolean z = 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 final void updatePinnedTopicStarterMessage() {
        TLRPC.Message message;
        TLRPC.TL_forumTopic tL_forumTopic;
        MessageObject messageObject = (this.isTopic && !this.pinnedMessageObjects.isEmpty() && this.pinnedMessageIds.size() == 1 && ((long) this.pinnedMessageIds.get(0).intValue()) == getTopicId() + 1) ? 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 setHighlightMessageId(int id) {
        this.highlightMessageId = id;
    }

    public void setHighlightQuote(int id, String quote, int quote_offset) {
        this.highlightMessageId = id;
        this.highlightMessageQuoteFirst = true;
        this.highlightMessageQuote = quote;
        this.highlightMessageQuoteOffset = quote_offset;
        this.showNoQuoteAlert = true;
    }

    public void showNoQuoteFound() {
        BulletinFactory.of(this).createSimpleBulletin(R.raw.error, LocaleController.getString(R.string.QuoteNotFound)).show(true);
    }

    public boolean isThreadChat() {
        return this.threadMessageObject != null;
    }

    public boolean isReplyChatComment() {
        return this.threadMessageObject != null && this.isComments;
    }

    public final void updateVisibleRows() {
        updateVisibleRows(false);
    }

    public final void updateVisibleRows(boolean suppressUpdateMessageObject) {
        int i;
        int i2;
        boolean z;
        boolean z2;
        String str;
        String str2;
        RecyclerListView recyclerListView = this.chatListView;
        if (recyclerListView == null) {
            return;
        }
        boolean z3 = false;
        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();
        }
        TLRPC.ChatFull chatFull = this.chatInfo;
        long j = chatFull != null ? chatFull.linked_chat_id : 0L;
        int i4 = 0;
        while (i4 < childCount2) {
            View childAt2 = this.chatListView.getChildAt(i4);
            if (childAt2 instanceof ChatMessageCell) {
                ChatMessageCell chatMessageCell = (ChatMessageCell) childAt2;
                MessageObject messageObject3 = chatMessageCell.getMessageObject();
                if (((BaseFragment) this).actionBar.isActionModeShowed() || this.reportType >= 0) {
                    this.highlightMessageQuoteFirst = z3;
                    this.highlightMessageQuote = null;
                    ArrayList<MessageObject> arrayList = this.threadMessageObjects;
                    chatMessageCell.setCheckBoxVisible(arrayList == null || !arrayList.contains(messageObject3), true);
                    int i5 = messageObject3.getDialogId() == this.dialog_id ? 0 : 1;
                    if (this.selectedMessagesIds[i5].indexOfKey(messageObject3.getId()) >= 0) {
                        setCellSelectionBackground(messageObject3, chatMessageCell, i5, true);
                        z = true;
                    } else {
                        chatMessageCell.setDrawSelectionBackground(z3);
                        chatMessageCell.setChecked(z3, z3, true);
                        z = false;
                    }
                    z2 = true;
                } else {
                    chatMessageCell.setDrawSelectionBackground(z3);
                    chatMessageCell.setCheckBoxVisible(z3, true);
                    chatMessageCell.setChecked(z3, z3, true);
                    z = false;
                    z2 = false;
                }
                if ((!chatMessageCell.getMessageObject().deleted || chatMessageCell.linkedChatId != j) && !suppressUpdateMessageObject) {
                    chatMessageCell.setIsUpdating(true);
                    TLRPC.ChatFull chatFull2 = this.chatInfo;
                    chatMessageCell.linkedChatId = chatFull2 != null ? chatFull2.linked_chat_id : 0L;
                    chatMessageCell.setMessageObject(chatMessageCell.getMessageObject(), chatMessageCell.getCurrentMessagesGroup(), chatMessageCell.isPinnedBottom(), chatMessageCell.isPinnedTop());
                    chatMessageCell.setIsUpdating(false);
                }
                if (chatMessageCell != this.scrimView) {
                    chatMessageCell.setCheckPressed(!z2, z2 && z);
                }
                chatMessageCell.setHighlighted((this.highlightMessageId == Integer.MAX_VALUE || messageObject3 == null || messageObject3.getId() != this.highlightMessageId) ? false : true);
                if (this.highlightMessageId != Integer.MAX_VALUE) {
                    startMessageUnselect();
                }
                if (chatMessageCell.isHighlighted() && (str2 = this.highlightMessageQuote) != null) {
                    if (!chatMessageCell.setHighlightedText(str2, true, this.highlightMessageQuoteOffset, this.highlightMessageQuoteFirst) && this.showNoQuoteAlert) {
                        showNoQuoteFound();
                    }
                    this.highlightMessageQuoteFirst = false;
                    this.showNoQuoteAlert = false;
                } else if (this.chatMode == 7 && this.searchingHashtag != null && (str = this.searchingQuery) != null) {
                    chatMessageCell.setHighlightedText(str);
                } else {
                    if (this.searchItem != null && this.searchItemVisible) {
                        if (getMediaDataController().isMessageFound(messageObject3.getId(), messageObject3.getDialogId() == this.mergeDialogId) && getMediaDataController().getLastSearchQuery() != null) {
                            chatMessageCell.setHighlightedText(getMediaDataController().getLastSearchQuery());
                        }
                    }
                    chatMessageCell.setHighlightedText(null);
                }
                chatMessageCell.setSpoilersSuppressed(this.chatListView.getScrollState() != 0);
            } else if (childAt2 instanceof ChatActionCell) {
                ChatActionCell chatActionCell = (ChatActionCell) childAt2;
                if (!suppressUpdateMessageObject) {
                    chatActionCell.setMessageObject(chatActionCell.getMessageObject());
                }
                chatActionCell.setSpoilersSuppressed(this.chatListView.getScrollState() != 0);
            }
            i4++;
            z3 = false;
        }
        if (i != -1) {
            this.chatLayoutManager.scrollToPositionWithOffset(i, i2);
        }
    }

    public final void updateVisibleRows(Utilities.CallbackReturn<MessageObject, Boolean> condition) {
        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();
        }
        TLRPC.ChatFull chatFull = this.chatInfo;
        if (chatFull != null) {
            long j = chatFull.linked_chat_id;
        }
        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) condition.run(messageObject3)).booleanValue()) {
                    messageObject3.forceUpdate = true;
                    chatMessageCell.setMessageObject(messageObject3, chatMessageCell.getCurrentMessagesGroup(), chatMessageCell.isPinnedBottom(), chatMessageCell.isPinnedTop());
                    this.chatAdapter.updateRowAtPosition(this.chatListView.getChildAdapterPosition(chatMessageCell));
                }
            }
        }
        if (i != -1) {
            this.chatLayoutManager.scrollToPositionWithOffset(i, i2);
        }
    }

    public final 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) {
                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);
            } else {
                this.chatActivityEnterView.onEditTimeExpired();
                this.replyObjectTextView.setText(LocaleController.formatString("TimeToEditExpired", R.string.TimeToEditExpired, new Object[0]));
            }
        }
    }

    public void updateVisibleCellsStatus() {
        RecyclerListView recyclerListView = this.chatListView;
        if (recyclerListView == null) {
            return;
        }
        int childCount = recyclerListView.getChildCount();
        boolean z = false;
        for (int i = 0; i < childCount; i++) {
            View childAt = this.chatListView.getChildAt(i);
            if (childAt instanceof ChatMessageCell) {
                ChatMessageCell chatMessageCell = (ChatMessageCell) childAt;
                chatMessageCell.updateStatus();
                if (chatMessageCell.statusChanged) {
                    z = true;
                }
            }
        }
        if (z) {
            invalidateMessagesVisiblePart();
        }
    }

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

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

    public void lambda$openSearchWithText$363(final String text) {
        boolean z;
        ActionBarMenuItem actionBarMenuItem;
        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$363(text);
                }
            }, 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 || this.chatMode == 3) && (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;
            ActionBarMenuItem actionBarMenuItem4 = this.search2Item;
            if (actionBarMenuItem4 != null) {
                actionBarMenuItem4.setVisibility(8);
            }
            updateSearchButtons(0, 0, -1);
            updateBottomOverlay();
        }
        if ((this.threadMessageId == 0 || this.isTopic || this.chatMode == 3) && !UserObject.isReplyUser(this.currentUser)) {
            boolean z2 = text == null;
            this.openSearchKeyboard = z2;
            ActionBarMenuItem actionBarMenuItem5 = this.searchItem;
            if (actionBarMenuItem5 != null) {
                actionBarMenuItem5.openSearch(z2);
            }
        }
        ActionBarMenuItem actionBarMenuItem6 = this.searchItem;
        if (actionBarMenuItem6 != null) {
            actionBarMenuItem6.setSearchFieldText(text, false);
        }
        MediaDataController mediaDataController = getMediaDataController();
        String str = text == null ? "" : text;
        this.searchingQuery = str;
        mediaDataController.searchMessagesInChat(str, this.dialog_id, this.mergeDialogId, ((BaseFragment) this).classGuid, 0, this.threadMessageId, false, this.searchingUserMessages, this.searchingChatMessages, !TextUtils.isEmpty(text), this.searchingReaction);
        updatePinnedMessageView(true);
    }

    public void lambda$openHashtagSearch$364(final String hashtag) {
        boolean z;
        FrameLayout frameLayout;
        SpannableString spannableString;
        ActionBarMenuItem actionBarMenuItem;
        if (hashtag.isEmpty()) {
            return;
        }
        if (hashtag.startsWith("#") || hashtag.startsWith("$")) {
            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$openHashtagSearch$364(hashtag);
                    }
                }, 200L);
                return;
            }
            this.searchingHashtag = hashtag;
            this.searchingQuery = hashtag;
            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 || this.chatMode == 3) && (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 (ChatObject.isChannelAndNotMegaGroup(this.currentChat) && ChatObject.isPublic(this.currentChat) && this.searchingHashtag != null) {
                this.defaultSearchPage = 2;
            } else {
                this.defaultSearchPage = 0;
            }
            this.openSearchKeyboard = false;
            ActionBarMenuItem actionBarMenuItem4 = this.searchItem;
            if (actionBarMenuItem4 != null) {
                this.preventReopenSearchWithText = true;
                actionBarMenuItem4.openSearch(false);
                this.preventReopenSearchWithText = false;
            }
            if (this.searchItem != null) {
                if (hashtag.startsWith("$")) {
                    spannableString = new SpannableString("$");
                } else {
                    spannableString = new SpannableString("#");
                }
                spannableString.setSpan(new ForegroundColorSpan(getThemedColor(Theme.key_windowBackgroundWhiteGrayText)), 0, 1, 33);
                this.searchItem.setSearchFieldCaption(spannableString);
                this.searchItem.setSearchFieldText(hashtag.substring(1), 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);
            if (this.hashtagSearchTabs != null) {
                if (this.showBio && (frameLayout = this.bioView) != null) {
                    frameLayout.setVisibility(8);
                    this.bioView.setTag(1);
                    updateChatDialogsViewPadding(48);
                }
                this.hashtagSearchTabs.show(true);
                this.messagesSearchListContainer.setPadding(0, this.hashtagSearchTabs.getLayoutParams().height, 0, 0);
                updateSearchListEmptyView();
            }
            HashtagSearchController.getInstance(((BaseFragment) this).currentAccount).clearSearchResults();
            HashtagSearchController.getInstance(((BaseFragment) this).currentAccount).putToHistory(this.searchingHashtag);
            this.hashtagHistoryView.update();
            View currentView = this.searchViewPager.getCurrentView();
            HashtagSearchController.getInstance(((BaseFragment) this).currentAccount).clearSearchResults();
            if (currentView instanceof ChatActivityContainer) {
                ((ChatActivityContainer) currentView).chatActivity.updateSearchingHashtag(this.searchingHashtag);
            }
        }
    }

    public final void lambda$openSearchWithUser$365(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$365(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 final 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);
        }
    }

    @Override
    public void didSelectLocation(TLRPC.MessageMedia location, int locationType, boolean notify, int scheduleDate) {
        SendMessagesHelper.SendMessageParams of = SendMessagesHelper.SendMessageParams.of(location, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TLRPC.ReplyMarkup) null, (HashMap) null, notify, scheduleDate);
        of.quick_reply_shortcut = this.quickReplyShortcut;
        of.quick_reply_shortcut_id = getQuickReplyId();
        getSendMessagesHelper().sendMessage(of);
        if (this.chatMode == 0) {
            moveScrollToLastMessage(false);
        }
        if (locationType == 0 || locationType == 1) {
            afterMessageSend();
        }
        if (this.paused) {
            this.scrollToTopOnResume = true;
        }
    }

    public boolean isEditingMessageMedia() {
        ChatAttachAlert chatAttachAlert = this.chatAttachAlert;
        return (chatAttachAlert == null || chatAttachAlert.getEditingMessageObject() == null) ? false : true;
    }

    public boolean isSecretChat() {
        return this.currentEncryptedChat != null;
    }

    public boolean canScheduleMessage() {
        if (this.chatMode == 5) {
            return false;
        }
        if ((getMessagesController().isForum(getDialogId()) && !this.isTopic) || this.currentEncryptedChat != null) {
            return false;
        }
        BlurredFrameLayout blurredFrameLayout = this.bottomOverlayChat;
        if (blurredFrameLayout == null || blurredFrameLayout.getVisibility() != 0) {
            return !isThreadChat() || (this.isTopic && PlusSettings.allowScheduleMessagesInTopics);
        }
        return false;
    }

    public boolean canSendMessage() {
        BlurredFrameLayout blurredFrameLayout;
        return this.currentEncryptedChat == null && ((blurredFrameLayout = this.bottomOverlayChat) == null || blurredFrameLayout.getVisibility() != 0);
    }

    public boolean isInScheduleMode() {
        return this.chatMode == 1;
    }

    public int getChatMode() {
        return this.chatMode;
    }

    public MessageObject getThreadMessage() {
        return this.threadMessageObject;
    }

    public MessageObject getReplyMessage() {
        return this.replyingMessageObject;
    }

    public MessageObject getReplyTopMessage() {
        return this.replyingTopMessage;
    }

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

    public long getThreadId() {
        return this.threadMessageId;
    }

    public long getInlineReturn() {
        return this.inlineReturn;
    }

    public TLRPC.User getCurrentUser() {
        return this.currentUser;
    }

    public TLRPC.Chat getCurrentChat() {
        return this.currentChat;
    }

    public TLRPC.EncryptedChat getCurrentEncryptedChat() {
        return this.currentEncryptedChat;
    }

    public TLRPC.ChatFull getCurrentChatInfo() {
        return this.chatInfo;
    }

    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 TLRPC.UserFull getCurrentUserInfo() {
        return this.userInfo;
    }

    public void sendAudio(ArrayList<MessageObject> audios, CharSequence caption, boolean notify, int scheduleDate, long effectId, boolean invertMedia) {
        if (checkSlowModeAlert()) {
            fillEditingMediaWithCaption(caption, null);
            SendMessagesHelper.prepareSendingAudioDocuments(getAccountInstance(), audios, caption != null ? caption : null, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TL_stories.StoryItem) null, notify, scheduleDate, this.editingMessageObject, this.quickReplyShortcut, getQuickReplyId(), effectId, invertMedia);
            afterMessageSend();
        }
    }

    public void sendContact(TLRPC.User user, boolean notify, int scheduleDate, long effectId, boolean invertMedia) {
        if (checkSlowModeAlert()) {
            SendMessagesHelper.SendMessageParams of = SendMessagesHelper.SendMessageParams.of(user, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TLRPC.ReplyMarkup) null, (HashMap) null, notify, scheduleDate);
            of.quick_reply_shortcut = this.quickReplyShortcut;
            of.quick_reply_shortcut_id = getQuickReplyId();
            of.effect_id = effectId;
            of.invert_media = invertMedia;
            getSendMessagesHelper().sendMessage(of);
            afterMessageSend();
        }
    }

    public void sendContacts(ArrayList<TLRPC.User> users, String caption, boolean notify, int scheduleDate, long effectId, boolean invertMedia) {
        long j;
        if (checkSlowModeAlert()) {
            if (TextUtils.isEmpty(caption)) {
                j = effectId;
            } else {
                SendMessagesHelper.SendMessageParams of = SendMessagesHelper.SendMessageParams.of(caption, 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 = effectId;
                of.invert_media = invertMedia;
                SendMessagesHelper.getInstance(((BaseFragment) this).currentAccount).sendMessage(of);
                j = 0;
            }
            Iterator<TLRPC.User> it = users.iterator();
            while (it.hasNext()) {
                SendMessagesHelper.SendMessageParams of2 = SendMessagesHelper.SendMessageParams.of(it.next(), this.dialog_id, (MessageObject) null, (MessageObject) null, (TLRPC.ReplyMarkup) null, (HashMap) null, notify, scheduleDate);
                of2.quick_reply_shortcut = this.quickReplyShortcut;
                of2.quick_reply_shortcut_id = getQuickReplyId();
                of2.effect_id = j;
                of2.invert_media = invertMedia;
                getSendMessagesHelper().sendMessage(of2);
                j = 0;
            }
            afterMessageSend();
        }
    }

    public final void showRestartDialog() {
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
        builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
        builder.setMessage(LocaleController.getString("AppWillRestart", R.string.AppWillRestart));
        builder.setPositiveButton(LocaleController.getString("OK", R.string.OK).toUpperCase(), new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                Utilities.restartApp();
            }
        });
        builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
            @Override
            public final void onCancel(DialogInterface dialogInterface) {
                Utilities.restartApp();
            }
        });
        showDialog(builder.create());
    }

    public int getCurrentClassGuid() {
        return ((BaseFragment) this).classGuid;
    }

    public void sendPoll(TLRPC.TL_messageMediaPoll poll, HashMap<String, String> params, boolean notify, int scheduleDate) {
        if (checkSlowModeAlert()) {
            SendMessagesHelper.SendMessageParams of = SendMessagesHelper.SendMessageParams.of(poll, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TLRPC.ReplyMarkup) null, params, notify, scheduleDate);
            of.quick_reply_shortcut = this.quickReplyShortcut;
            of.quick_reply_shortcut_id = getQuickReplyId();
            getSendMessagesHelper().sendMessage(of);
            afterMessageSend();
        }
    }

    public long getOnlyId() {
        return this.onlyId;
    }

    public long getOnlyIdMedia() {
        return this.onlyIdMedia;
    }

    public void sendMedia(MediaController.PhotoEntry photoEntry, VideoEditedInfo videoEditedInfo, boolean notify, int scheduleDate, boolean forceDocument) {
        if (photoEntry == null) {
            return;
        }
        if (videoEditedInfo != null && videoEditedInfo.roundVideo) {
            Runnable runnable = new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$sendMedia$368();
                }
            };
            this.closeInstantCameraAnimation = runnable;
            AndroidUtilities.runOnUIThread(runnable, 3000L);
        }
        fillEditingMediaWithCaption(((MediaController.MediaEditState) photoEntry).caption, ((MediaController.MediaEditState) photoEntry).entities);
        if (photoEntry.isVideo) {
            SendMessagesHelper.prepareSendingVideo(getAccountInstance(), photoEntry.path, videoEditedInfo, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TL_stories.StoryItem) null, this.replyingQuote, ((MediaController.MediaEditState) photoEntry).entities, ((MediaController.MediaEditState) photoEntry).ttl, this.editingMessageObject, notify, scheduleDate, forceDocument, photoEntry.hasSpoiler, ((MediaController.MediaEditState) photoEntry).caption, this.quickReplyShortcut, getQuickReplyId(), ((MediaController.MediaEditState) photoEntry).effectId);
        } else if (((MediaController.MediaEditState) photoEntry).imagePath != null) {
            SendMessagesHelper.prepareSendingPhoto(getAccountInstance(), ((MediaController.MediaEditState) photoEntry).imagePath, ((MediaController.MediaEditState) photoEntry).thumbPath, (Uri) null, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TL_stories.StoryItem) null, this.replyingQuote, ((MediaController.MediaEditState) photoEntry).entities, ((MediaController.MediaEditState) photoEntry).stickers, (InputContentInfoCompat) null, ((MediaController.MediaEditState) photoEntry).ttl, this.editingMessageObject, videoEditedInfo, notify, scheduleDate, 0, forceDocument, ((MediaController.MediaEditState) photoEntry).caption, this.quickReplyShortcut, getQuickReplyId(), ((MediaController.MediaEditState) photoEntry).effectId);
        } else if (photoEntry.path != null) {
            SendMessagesHelper.prepareSendingPhoto(getAccountInstance(), photoEntry.path, ((MediaController.MediaEditState) photoEntry).thumbPath, (Uri) null, this.dialog_id, this.replyingMessageObject, getThreadMessage(), (TL_stories.StoryItem) null, this.replyingQuote, ((MediaController.MediaEditState) photoEntry).entities, ((MediaController.MediaEditState) photoEntry).stickers, (InputContentInfoCompat) null, ((MediaController.MediaEditState) photoEntry).ttl, this.editingMessageObject, videoEditedInfo, notify, scheduleDate, 0, forceDocument, ((MediaController.MediaEditState) photoEntry).caption, this.quickReplyShortcut, getQuickReplyId(), ((MediaController.MediaEditState) photoEntry).effectId);
        }
        afterMessageSend();
    }

    public void lambda$sendMedia$368() {
        this.closeInstantCameraAnimation = null;
        runCloseInstantCameraAnimation();
    }

    public final void runCloseInstantCameraAnimation() {
        InstantCameraView instantCameraView = this.instantCameraView;
        if (instantCameraView == null) {
            return;
        }
        instantCameraView.cancelBlur();
        InstantCameraView.InstantViewCameraContainer cameraContainer = this.instantCameraView.getCameraContainer();
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(ObjectAnimator.ofFloat(cameraContainer, (Property<InstantCameraView.InstantViewCameraContainer, Float>) View.SCALE_X, 0.5f), ObjectAnimator.ofFloat(cameraContainer, (Property<InstantCameraView.InstantViewCameraContainer, Float>) View.SCALE_Y, 0.5f), ObjectAnimator.ofFloat(cameraContainer, (Property<InstantCameraView.InstantViewCameraContainer, Float>) View.ALPHA, 0.0f), ObjectAnimator.ofFloat(this.instantCameraView.getSwitchButtonView(), (Property<View, Float>) View.ALPHA, 0.0f), ObjectAnimator.ofInt(this.instantCameraView.getPaint(), (Property<Paint, Integer>) AnimationProperties.PAINT_ALPHA, 0), ObjectAnimator.ofFloat(this.instantCameraView.getMuteImageView(), (Property<View, Float>) View.ALPHA, 0.0f));
        animatorSet.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                InstantCameraView instantCameraView2 = ChatActivity.this.instantCameraView;
                if (instantCameraView2 != null) {
                    instantCameraView2.setIsMessageTransition(false);
                    ChatActivity.this.instantCameraView.hideCamera(true);
                    ChatActivity.this.instantCameraView.setVisibility(4);
                }
            }
        });
        animatorSet.start();
    }

    public void sendAnimatedEmoji(TLRPC.Document emoji, boolean notify, int scheduleDate) {
        String findAnimatedEmojiEmoticon;
        if (emoji == null || (findAnimatedEmojiEmoticon = MessageObject.findAnimatedEmojiEmoticon(emoji, (String) null)) == null) {
            return;
        }
        ArrayList arrayList = new ArrayList();
        TLRPC.TL_messageEntityCustomEmoji tL_messageEntityCustomEmoji = new TLRPC.TL_messageEntityCustomEmoji();
        tL_messageEntityCustomEmoji.document = emoji;
        tL_messageEntityCustomEmoji.document_id = emoji.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, notify, scheduleDate, (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 showOpenGameAlert(final TLRPC.TL_game game, final MessageObject messageObject, final String urlStr, boolean ask, final long uid) {
        String str;
        TLRPC.User user = getMessagesController().getUser(Long.valueOf(uid));
        str = "";
        if (ask) {
            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity(), this.themeDelegate);
            builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
            builder.setMessage(LocaleController.formatString("BotPermissionGameAlert", R.string.BotPermissionGameAlert, new Object[]{user != null ? ContactsController.formatName(user.first_name, user.last_name) : ""}));
            builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
                @Override
                public final void onClick(DialogInterface dialogInterface, int i) {
                    ChatActivity.this.lambda$showOpenGameAlert$369(game, messageObject, urlStr, uid, dialogInterface, i);
                }
            });
            builder.setNegativeButton(LocaleController.getString("Cancel", 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(urlStr, (user == null || TextUtils.isEmpty(publicUsername)) ? "" : publicUsername, game.title, game.short_name, messageObject));
            }
        } else {
            Activity parentActivity = getParentActivity();
            String str2 = game.short_name;
            if (user != null && publicUsername != null) {
                str = publicUsername;
            }
            WebviewActivity.openGameInBrowser(urlStr, messageObject, parentActivity, str2, str);
        }
        AndroidUtilities.playingAGame = Theme.plusHideNotificationsIfPlaying;
    }

    public void lambda$showOpenGameAlert$369(TLRPC.TL_game tL_game, MessageObject messageObject, String str, long j, DialogInterface dialogInterface, int i) {
        showOpenGameAlert(tL_game, messageObject, str, false, j);
        MessagesController.getNotificationsSettings(((BaseFragment) this).currentAccount).edit().putBoolean("askgame_" + j, false).commit();
    }

    public final 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");
    }

    public void lambda$processLoadedDiscussionMessage$373(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.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$371(zArr, i2, chatActivity);
                }
            };
            if (messages_messages != null) {
                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 AnonymousClass167(classGuid, runnable, chatActivity), NotificationCenter.messagesDidLoad);
                final int i6 = i4;
                Utilities.stageQueue.postRunnable(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.this.lambda$processLoadedDiscussionMessage$372(messages_messages, dialogId, i, i3, classGuid, i6, arrayList);
                    }
                });
                return;
            }
            runnable.run();
            return;
        }
        this.commentLoadingMessageId = 0;
        this.hideCommentLoading = false;
        this.chatListView.invalidateViews();
        if (messageObject2 != null) {
            openOriginalReplyChat(messageObject2);
        } else if (getParentActivity() != null) {
            BulletinFactory.of(this).createErrorBulletin(LocaleController.getString("ChannelPostDeleted", R.string.ChannelPostDeleted), this.themeDelegate).show();
        }
    }

    public void lambda$processLoadedDiscussionMessage$371(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$370();
            }
        }, 200L);
        presentFragment(chatActivity);
        if (!isKeyboardVisible() || chatActivity.hideKeyboardOnShow() || (chatActivityEnterView = chatActivity.chatActivityEnterView) == null || chatActivityEnterView.getEditField() == null) {
            return;
        }
        chatActivity.chatActivityEnterView.getEditField().requestFocus();
    }

    public void lambda$processLoadedDiscussionMessage$370() {
        this.commentLoadingMessageId = 0;
        this.hideCommentLoading = false;
        this.chatListView.invalidateViews();
    }

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

        public AnonymousClass167(final int val$commentsClassGuid, final Runnable val$openCommentsChat, final ChatActivity val$chatActivity) {
            this.val$commentsClassGuid = val$commentsClassGuid;
            this.val$openCommentsChat = val$openCommentsChat;
            this.val$chatActivity = val$chatActivity;
        }

        public void didReceivedNotification(final int id, final int account, final Object... args) {
            int i = NotificationCenter.messagesDidLoad;
            if (id == i && ((Integer) args[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(id, account, args);
                    }
                }, 50L);
                NotificationCenter.getInstance(((BaseFragment) ChatActivity.this).currentAccount).removeObserver(this, i);
            }
        }
    }

    public void lambda$processLoadedDiscussionMessage$372(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, (MessageLoaderLogger) null);
    }

    public final void openDiscussionMessageChat(long chatId, final MessageObject originalMessage, int messageId, final long linkedChatId, final int maxReadId, final int highlightMsgId, final MessageObject fallbackMessage) {
        int i = messageId;
        final TLRPC.Chat chat = getMessagesController().getChat(Long.valueOf(chatId));
        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 = i;
        if (BuildVars.LOGS_ENABLED) {
            FileLog.d("getDiscussionMessage chat = " + chat.id + " msg_id = " + i);
        }
        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 (fallbackMessage != null) {
            i = fallbackMessage.getId();
        }
        this.commentLoadingMessageId = i;
        this.hideCommentLoading = false;
        this.commentLoadingStartedAt = System.currentTimeMillis();
        RecyclerListView recyclerListView2 = this.chatListView;
        if (recyclerListView2 != null) {
            recyclerListView2.invalidateViews();
        }
        final int i2 = this.commentLoadingGuid + 1;
        this.commentLoadingGuid = i2;
        this.commentRequestId = getConnectionsManager().sendRequest(tL_messages_getDiscussionMessage, new RequestDelegate() {
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                ChatActivity.this.lambda$openDiscussionMessageChat$379(i2, maxReadId, linkedChatId, highlightMsgId, fallbackMessage, tL_messages_getDiscussionMessage, chat, originalMessage, tLObject, tL_error);
            }
        });
        getConnectionsManager().bindRequestToGuid(this.commentRequestId, ((BaseFragment) this).classGuid);
    }

    public void lambda$openDiscussionMessageChat$379(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$377(i, i2, j, tLObject, i3, messageObject, tL_messages_getDiscussionMessage, chat, messageObject2);
            }
        };
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$openDiscussionMessageChat$378(runnable);
            }
        });
    }

    public void lambda$openDiscussionMessageChat$377(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) {
        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 i4 = 0; i4 < this.savedDiscussionMessage.messages.size(); i4++) {
                TLRPC.Message message = (TLRPC.Message) this.savedDiscussionMessage.messages.get(i4);
                if (!(message instanceof TLRPC.TL_messageEmpty)) {
                    arrayList.add(message);
                }
            }
        }
        if (arrayList.size() > 0) {
            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;
                tL_messages_getReplies.add_offset = (-30) / 2;
            } else {
                tL_messages_getReplies.offset_id = i2 == 0 ? 1 : i2;
                tL_messages_getReplies.add_offset = (-30) + 10;
            }
            final int i5 = 1 + this.commentMessagesLoadingGuid;
            this.commentMessagesLoadingGuid = i5;
            this.commentMessagesRequestId = getConnectionsManager().sendRequest(tL_messages_getReplies, new RequestDelegate() {
                public final void run(TLObject tLObject2, TLRPC.TL_error tL_error) {
                    ChatActivity.this.lambda$openDiscussionMessageChat$376(i5, i2, messageObject, tL_messages_getDiscussionMessage, chat, i3, messageObject2, tLObject2, tL_error);
                }
            });
            return;
        }
        this.savedNoHistory = true;
        processLoadedDiscussionMessage(this.savedNoDiscussion, this.savedDiscussionMessage, true, this.savedHistory, i2, messageObject, tL_messages_getDiscussionMessage, chat, i3, messageObject2);
    }

    public void lambda$openDiscussionMessageChat$375(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$378(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$openDiscussionMessageChat$374(i, tLObject, tL_error, i2, messageObject, tL_messages_getDiscussionMessage, chat, i3, messageObject2);
            }
        });
    }

    public void lambda$openDiscussionMessageChat$376(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$375(i, tLObject, tL_error, i2, messageObject, tL_messages_getDiscussionMessage, chat, i3, messageObject2);
            }
        });
    }

    public void lambda$openDiscussionMessageChat$374(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("ChannelCantOpenBannedByAdmin", 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 final void openMessageInOriginalDialog(MessageObject messageObject) {
        Bundle bundle = new Bundle();
        TLRPC.Peer peer = messageObject.messageOwner.peer_id;
        long j = peer.channel_id;
        if (j != 0) {
            bundle.putLong("chat_id", j);
        } else {
            long j2 = peer.chat_id;
            if (j2 != 0) {
                bundle.putLong("chat_id", j2);
            } else {
                long j3 = peer.user_id;
                if (j3 != 0) {
                    bundle.putLong("user_id", j3);
                }
            }
        }
        bundle.putInt("message_id", messageObject.getRealId());
        bundle.putBoolean("need_remove_previous_same_chat_activity", false);
        if (getMessagesController().checkCanOpenChat(bundle, this)) {
            presentFragment(DialogsActivity.highlightFoundQuote(new ChatActivity(bundle), messageObject));
        }
    }

    public final void openOriginalReplyChat(MessageObject messageObject) {
        if (UserObject.isUserSelf(this.currentUser)) {
            TLRPC.MessageFwdHeader messageFwdHeader = messageObject.messageOwner.fwd_from;
            if (messageFwdHeader.saved_from_peer.user_id == this.currentUser.id) {
                scrollToMessageId(messageFwdHeader.saved_from_msg_id, messageObject.getId(), true, 0, true, 0);
                return;
            }
        }
        Bundle bundle = new Bundle();
        TLRPC.MessageFwdHeader messageFwdHeader2 = messageObject.messageOwner.fwd_from;
        if (messageFwdHeader2 != null) {
            TLRPC.Peer peer = messageFwdHeader2.saved_from_peer;
            long j = peer.channel_id;
            if (j != 0) {
                bundle.putLong("chat_id", j);
            } else {
                long j2 = peer.chat_id;
                if (j2 != 0) {
                    bundle.putLong("chat_id", j2);
                } else {
                    long j3 = peer.user_id;
                    if (j3 != 0) {
                        bundle.putLong("user_id", j3);
                    }
                }
            }
            bundle.putInt("message_id", messageObject.messageOwner.fwd_from.saved_from_msg_id);
        } else {
            long dialogId = messageObject.getDialogId();
            if (DialogObject.isUserDialog(dialogId)) {
                bundle.putLong("user_id", dialogId);
            } else {
                bundle.putLong("chat_id", -dialogId);
            }
            bundle.putInt("message_id", messageObject.getReplyMsgId());
        }
        if (getMessagesController().checkCanOpenChat(bundle, this)) {
            presentFragment(new ChatActivity(bundle));
        }
    }

    public void showRequestUrlAlert(final TLRPC.TL_urlAuthResultRequest request, final TLRPC.TL_messages_requestUrlAuth buttonReq, final String url, final boolean ask) {
        if (getParentActivity() == null) {
            return;
        }
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity(), this.themeDelegate);
        builder.setTitle(LocaleController.getString("OpenUrlTitle", R.string.OpenUrlTitle));
        String string = LocaleController.getString("OpenUrlAlert2", R.string.OpenUrlAlert2);
        int indexOf = string.indexOf("%");
        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(String.format(string, url));
        if (indexOf >= 0) {
            spannableStringBuilder.setSpan(new URLSpan(url), indexOf, url.length() + indexOf, 33);
        }
        builder.setMessage(spannableStringBuilder);
        builder.setMessageTextViewClickable(false);
        builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
        int i = 2;
        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 < (request.request_write_access ? 2 : 1)) {
                checkBoxCellArr[i2] = new CheckBoxCell(getParentActivity(), 5, this.themeDelegate);
                checkBoxCellArr[i2].setBackgroundDrawable(Theme.getSelectorDrawable(false));
                checkBoxCellArr[i2].setMultiline(true);
                checkBoxCellArr[i2].setTag(Integer.valueOf(i2));
                if (i2 == 0) {
                    int i3 = R.string.OpenUrlOption1;
                    Object[] objArr = new Object[i];
                    objArr[0] = request.domain;
                    objArr[1] = ContactsController.formatName(currentUser.first_name, currentUser.last_name);
                    SpannableStringBuilder replaceTags = AndroidUtilities.replaceTags(LocaleController.formatString("OpenUrlOption1", i3, objArr));
                    int indexOf2 = TextUtils.indexOf(replaceTags, request.domain);
                    if (indexOf2 >= 0) {
                        replaceTags.setSpan(new URLSpan(""), indexOf2, request.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(request.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$380(checkBoxCellArr, view);
                    }
                });
                i2++;
                i = 2;
            } else {
                builder.setView(linearLayout);
                builder.setPositiveButton(LocaleController.getString("Open", R.string.Open), new DialogInterface.OnClickListener() {
                    @Override
                    public final void onClick(DialogInterface dialogInterface, int i4) {
                        ChatActivity.this.lambda$showRequestUrlAlert$385(checkBoxCellArr, url, buttonReq, request, ask, dialogInterface, i4);
                    }
                });
                showDialog(builder.create());
                return;
            }
        }
    }

    public static void lambda$showRequestUrlAlert$380(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$385(CheckBoxCell[] checkBoxCellArr, final String str, final TLRPC.TL_messages_requestUrlAuth tL_messages_requestUrlAuth, TLRPC.TL_urlAuthResultRequest tL_urlAuthResultRequest, final boolean z, DialogInterface dialogInterface, int i) {
        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;
            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;
            tL_messages_acceptUrlAuth.flags |= 2;
        }
        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$382(str, tL_messages_requestUrlAuth, z, tLObject, tL_error);
            }
        });
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$showRequestUrlAlert$384(alertDialogArr, sendRequest);
            }
        }, 500L);
    }

    public void lambda$showRequestUrlAlert$382(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$381(tLObject, str, tL_messages_requestUrlAuth, z);
            }
        });
    }

    public void lambda$showRequestUrlAlert$381(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$384(AlertDialog[] alertDialogArr, final int i) {
        if (alertDialogArr[0] == null) {
            return;
        }
        alertDialogArr[0].setOnCancelListener(new DialogInterface.OnCancelListener() {
            @Override
            public final void onCancel(DialogInterface dialogInterface) {
                ChatActivity.this.lambda$showRequestUrlAlert$383(i, dialogInterface);
            }
        });
        showDialog(alertDialogArr[0]);
    }

    public void lambda$showRequestUrlAlert$383(int i, DialogInterface dialogInterface) {
        getConnectionsManager().cancelRequest(i, true);
    }

    public final 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 final 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 openVCard(TLRPC.User user, String phone, String vcard, String first_name, String last_name) {
        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", vcard);
            bundle.putString("vcard_phone", phone);
            bundle.putString("vcard_first_name", first_name);
            bundle.putString("vcard_last_name", last_name);
            presentFragment(new ProfileActivity(bundle));
            return;
        }
        try {
            if (TextUtils.isEmpty(vcard)) {
                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(vcard);
                bufferedWriter.close();
                file = file2;
            }
            showDialog(new PhonebookShareAlert(this, (ContactsController.Contact) null, user, (Uri) null, file, PhoneFormat.stripExceptNumbers(phone), first_name, last_name, this.themeDelegate));
        } catch (Exception e) {
            FileLog.e(e);
        }
    }

    public final void setCellSelectionBackground(MessageObject message, ChatMessageCell messageCell, int idx, boolean animated) {
        boolean z;
        MessageObject.GroupedMessages validGroupedMessage = getValidGroupedMessage(message);
        if (validGroupedMessage != null) {
            int i = 0;
            while (true) {
                if (i >= validGroupedMessage.messages.size()) {
                    z = false;
                    break;
                } else {
                    if (this.selectedMessagesIds[idx].indexOfKey(((MessageObject) validGroupedMessage.messages.get(i)).getId()) < 0) {
                        z = true;
                        break;
                    }
                    i++;
                }
            }
            if (!z) {
                validGroupedMessage = null;
            }
        }
        messageCell.setDrawSelectionBackground(validGroupedMessage == null);
        messageCell.setChecked(true, validGroupedMessage == null, animated);
    }

    public final 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) {
        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):void");
    }

    public void lambda$openClickableLink$386(java.lang.String r7, android.text.style.CharacterStyle r8, org.telegram.messenger.MessageObject r9, org.telegram.ui.Cells.ChatMessageCell r10, int r11, android.content.DialogInterface r12, int r13) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.lambda$openClickableLink$386(java.lang.String, android.text.style.CharacterStyle, org.telegram.messenger.MessageObject, org.telegram.ui.Cells.ChatMessageCell, int, android.content.DialogInterface, int):void");
    }

    public static void lambda$openClickableLink$387(ChatMessageCell chatMessageCell, DialogInterface dialogInterface) {
        if (chatMessageCell != null) {
            chatMessageCell.resetPressedLink(-1);
        }
    }

    public void shakeContent() {
        AndroidUtilities.shakeViewSpring(getChatListView(), 5.0f);
        if (!PlusSettings.disableActionsVibrations) {
            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 final Browser.Progress makeProgressForLink(ChatMessageCell cell, CharacterStyle span) {
        Browser.Progress progress = this.progressDialogCurrent;
        AnonymousClass168 anonymousClass168 = null;
        if (progress != null) {
            progress.cancel(true);
            this.progressDialogCurrent = null;
        }
        if (span != null && cell != null && cell.getMessageObject() != null) {
            anonymousClass168 = new AnonymousClass168(cell, span);
        }
        this.progressDialogCurrent = anonymousClass168;
        return anonymousClass168;
    }

    public class AnonymousClass168 extends Browser.Progress {
        public final ChatMessageCell val$cell;
        public final CharacterStyle val$span;

        public AnonymousClass168(final ChatMessageCell val$cell, final CharacterStyle val$span) {
            this.val$cell = val$cell;
            this.val$span = val$span;
        }

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

        public void end(boolean replaced) {
            if (replaced) {
                return;
            }
            final ChatMessageCell chatMessageCell = this.val$cell;
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.AnonymousClass168.this.lambda$end$0(chatMessageCell);
                }
            }, 240L);
        }

        public void lambda$end$0(ChatMessageCell chatMessageCell) {
            if (ChatActivity.this.progressDialogAtMessageId == chatMessageCell.getMessageObject().getId()) {
                ChatActivity.this.resetProgressDialogLoading();
            }
        }
    }

    public final Browser.Progress makeProgressForBotButton(ChatMessageCell cell, String url) {
        Browser.Progress progress = this.progressDialogCurrent;
        AnonymousClass169 anonymousClass169 = null;
        if (progress != null) {
            progress.cancel(true);
            this.progressDialogCurrent = null;
        }
        if (url != null && cell != null && cell.getMessageObject() != null) {
            anonymousClass169 = new AnonymousClass169(cell, url);
        }
        this.progressDialogCurrent = anonymousClass169;
        return anonymousClass169;
    }

    public class AnonymousClass169 extends Browser.Progress {
        public final ChatMessageCell val$cell;
        public final String val$url;

        public AnonymousClass169(final ChatMessageCell val$cell, final String val$url) {
            this.val$cell = val$cell;
            this.val$url = val$url;
        }

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

        public void end(boolean replaced) {
            if (replaced) {
                return;
            }
            final ChatMessageCell chatMessageCell = this.val$cell;
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.AnonymousClass169.this.lambda$end$0(chatMessageCell);
                }
            }, 240L);
        }

        public void lambda$end$0(ChatMessageCell chatMessageCell) {
            if (ChatActivity.this.progressDialogAtMessageId == chatMessageCell.getMessageObject().getId()) {
                ChatActivity.this.resetProgressDialogLoading();
            }
        }
    }

    public final void processExternalUrl(int r13, java.lang.String r14, android.text.style.CharacterStyle r15, org.telegram.ui.Cells.ChatMessageCell r16, boolean r17) {
        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):void");
    }

    public final void logSponsoredClicked(MessageObject messageObject) {
        if (messageObject == null || !messageObject.isSponsored()) {
            return;
        }
        TLRPC.TL_channels_clickSponsoredMessage tL_channels_clickSponsoredMessage = new TLRPC.TL_channels_clickSponsoredMessage();
        tL_channels_clickSponsoredMessage.random_id = messageObject.sponsoredId;
        tL_channels_clickSponsoredMessage.channel = getMessagesController().getInputChannel(-getDialogId());
        getConnectionsManager().sendRequest(tL_channels_clickSponsoredMessage, (RequestDelegate) null);
    }

    public final void didPressMessageUrl(final android.text.style.CharacterStyle r19, boolean r20, final org.telegram.messenger.MessageObject r21, final org.telegram.ui.Cells.ChatMessageCell r22) {
        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");
    }

    public void lambda$didPressMessageUrl$388(java.lang.String r8, android.text.style.CharacterStyle r9, org.telegram.messenger.MessageObject r10, org.telegram.ui.Cells.ChatMessageCell r11, int r12, java.lang.String r13, android.content.DialogInterface r14, int r15) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.lambda$didPressMessageUrl$388(java.lang.String, android.text.style.CharacterStyle, org.telegram.messenger.MessageObject, org.telegram.ui.Cells.ChatMessageCell, int, java.lang.String, android.content.DialogInterface, int):void");
    }

    public void lambda$didPressMessageUrl$390(MessageObject messageObject, String str, CharacterStyle characterStyle, ChatMessageCell chatMessageCell, DialogInterface dialogInterface, int i) {
        if (i == 0) {
            logSponsoredClicked(messageObject);
            processExternalUrl(1, str, characterStyle, chatMessageCell, false);
            return;
        }
        boolean z = true;
        if (i != 1) {
            if (i == 2) {
                ShareAlert shareAlert = new ShareAlert(getParentActivity(), (ArrayList) null, str, false, (String) null, false);
                this.shareAlert = shareAlert;
                showDialog(shareAlert);
                this.shareAlert.setParentFragment(this);
                return;
            }
            return;
        }
        boolean z2 = false;
        if (str.startsWith("mailto:")) {
            str = str.substring(7);
        } else if (str.startsWith("tel:")) {
            str = str.substring(4);
            z = false;
            z2 = true;
        } else {
            z = false;
        }
        AndroidUtilities.addToClipboard(str);
        createUndoView();
        UndoView undoView = this.undoView;
        if (undoView == null) {
            return;
        }
        if (z) {
            undoView.showWithAction(0L, 80, (Runnable) null);
        } else if (z2) {
            undoView.showWithAction(0L, 60, (Runnable) null);
        } else {
            undoView.showWithAction(0L, 59, (Runnable) null);
        }
    }

    public static void lambda$didPressMessageUrl$391(ChatMessageCell chatMessageCell, DialogInterface dialogInterface) {
        if (chatMessageCell != null) {
            chatMessageCell.resetPressedLink(-1);
        }
    }

    public void openPhotoViewerForMessage(ChatMessageCell cell, MessageObject message) {
        ChatMessageCell chatMessageCell;
        AnimatedFileDrawable animation;
        Bitmap animatedBitmap;
        if (cell == null) {
            int childCount = this.chatListView.getChildCount();
            for (int i = 0; i < childCount; i++) {
                View childAt = this.chatListView.getChildAt(i);
                if (childAt instanceof ChatMessageCell) {
                    chatMessageCell = (ChatMessageCell) childAt;
                    if (chatMessageCell.getMessageObject().equals(message)) {
                        break;
                    }
                }
            }
        }
        chatMessageCell = cell;
        if (message.isVideo()) {
            sendSecretMessageRead(message, true);
        }
        PhotoViewer.getInstance().setParentActivity(this, this.themeDelegate);
        MessageObject playingMessageObject = MediaController.getInstance().getPlayingMessageObject();
        if (chatMessageCell != null && playingMessageObject != null && playingMessageObject.isVideo()) {
            getFileLoader().setLoadingVideoForPlayer(playingMessageObject.getDocument(), false);
            if (playingMessageObject.equals(message) && (animation = chatMessageCell.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(message));
        }
        if (this.chatMode == 1 && (message.isVideo() || message.type == 1)) {
            PhotoViewer.getInstance().setParentChatActivity(this);
            ArrayList<MessageObject> arrayList = new ArrayList<>();
            int size = this.messages.size();
            for (int i2 = 0; i2 < size; i2++) {
                MessageObject messageObject = this.messages.get(i2);
                if (messageObject.isVideo() || messageObject.type == 1) {
                    arrayList.add(0, messageObject);
                }
            }
            PhotoViewer.getInstance().openPhoto(arrayList, arrayList.indexOf(message), this.dialog_id, 0L, getTopicId(), this.photoViewerProvider);
        } else {
            PhotoViewer photoViewer = PhotoViewer.getInstance();
            int i3 = message.type;
            photoViewer.openPhoto(message, this, i3 != 0 ? this.dialog_id : 0L, i3 != 0 ? this.mergeDialogId : 0L, i3 != 0 ? getTopicId() : 0L, this.photoViewerProvider);
        }
        hideHints(false);
        MediaController.getInstance().resetGoingToShowMessageObject();
    }

    public final void updateMessageListAccessibilityVisibility() {
        ActionBarPopupWindow actionBarPopupWindow;
        if (this.currentEncryptedChat == null && Build.VERSION.SDK_INT >= 19) {
            RecyclerListView recyclerListView = this.chatListView;
            MentionsContainerView mentionsContainerView = this.mentionContainer;
            recyclerListView.setImportantForAccessibility(((mentionsContainerView == null || !mentionsContainerView.isOpen()) && ((actionBarPopupWindow = this.scrimPopupWindow) == null || !actionBarPopupWindow.isShowing())) ? 0 : 4);
        }
    }

    public final void markSponsoredAsRead(MessageObject object) {
        if (!object.isSponsored() || object.viewsReloaded) {
            return;
        }
        object.viewsReloaded = true;
        TLRPC.TL_channels_viewSponsoredMessage tL_channels_viewSponsoredMessage = new TLRPC.TL_channels_viewSponsoredMessage();
        tL_channels_viewSponsoredMessage.channel = MessagesController.getInputChannel(this.currentChat);
        tL_channels_viewSponsoredMessage.random_id = object.sponsoredId;
        getConnectionsManager().sendRequest(tL_channels_viewSponsoredMessage, new RequestDelegate() {
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                ChatActivity.lambda$markSponsoredAsRead$392(tLObject, tL_error);
            }
        });
        getMessagesController().markSponsoredAsRead(this.dialog_id, object);
    }

    public boolean canBeginSlide() {
        return !(this.chatMode == 5 && (this.messages.isEmpty() || this.threadMessageId == 0)) && this.swipeBackEnabled && this.chatActivityEnterView.swipeToBackEnabled() && this.pullingDownOffset == 0.0f;
    }

    public boolean isSwipeBackEnabled(MotionEvent event) {
        if ((this.chatMode == 5 && (this.messages.isEmpty() || this.threadMessageId == 0)) || !this.swipeBackEnabled) {
            return false;
        }
        MessagePreviewView messagePreviewView = this.forwardingPreviewView;
        return messagePreviewView == null || !messagePreviewView.isShowing();
    }

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

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

        public ArrayList<MessageObject> getMessages() {
            if (this.isFrozen) {
                return this.frozenMessages;
            }
            if (this.isFiltered) {
                return this.filteredMessages;
            }
            return ChatActivity.this.messages;
        }

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

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

        public final void updateRowsInternal() {
            ArrayList<MessageObject> arrayList;
            TLRPC.User user;
            TLRPC.User user2;
            this.rowCount = 0;
            if (this.isFrozen) {
                arrayList = this.frozenMessages;
            } else if (this.isFiltered) {
                arrayList = this.filteredMessages;
            } else {
                arrayList = ChatActivity.this.messages;
            }
            if (ChatActivity.this.chatMode == 3 && ChatActivity.this.isInsideContainer) {
                int i = this.rowCount;
                this.rowCount = i + 1;
                this.hintRow = i;
            } else {
                this.hintRow = -5;
            }
            if (!arrayList.isEmpty() || ChatActivity.this.onlyId != 0 || ChatActivity.this.onlyIdMedia != 0) {
                if (!this.isFiltered && ((!ChatActivity.this.forwardEndReached[0] || (ChatActivity.this.mergeDialogId != 0 && !ChatActivity.this.forwardEndReached[1])) && !ChatActivity.this.hideForwardEndReached)) {
                    int i2 = this.rowCount;
                    this.rowCount = i2 + 1;
                    this.loadingDownRow = i2;
                } else {
                    this.loadingDownRow = -5;
                }
                int i3 = this.rowCount;
                this.messagesStartRow = i3;
                int size = i3 + arrayList.size();
                this.rowCount = size;
                this.messagesEndRow = size;
                if ((UserObject.isReplyUser(ChatActivity.this.currentUser) || ((user = ChatActivity.this.currentUser) != null && user.bot && !MessagesController.isSupportUser(user) && ChatActivity.this.chatMode == 0)) && ChatActivity.this.endReached[0]) {
                    int i4 = this.rowCount;
                    this.rowCount = i4 + 1;
                    this.botInfoRow = i4;
                } else {
                    this.botInfoRow = -5;
                }
                if (ChatActivity.this.chatMode == 5 && !QuickRepliesController.isSpecial(ChatActivity.this.quickReplyShortcut)) {
                    int i5 = this.rowCount;
                    this.rowCount = i5 + 1;
                    this.hintRow = i5;
                }
                if (!this.isFiltered ? (!ChatActivity.this.endReached[0] || (ChatActivity.this.mergeDialogId != 0 && !ChatActivity.this.endReached[1])) && (AndroidUtilities.isTablet() || ChatActivity.this.isComments || ChatActivity.this.currentUser != null) : !this.filteredEndReached) {
                    int i6 = this.rowCount;
                    this.rowCount = i6 + 1;
                    this.loadingUpRow = i6;
                } else {
                    this.loadingUpRow = -5;
                }
            } else {
                this.loadingUpRow = -5;
                this.loadingDownRow = -5;
                this.messagesStartRow = -5;
                this.messagesEndRow = -5;
                if (UserObject.isReplyUser(ChatActivity.this.currentUser) || ((user2 = ChatActivity.this.currentUser) != null && user2.bot && !MessagesController.isSupportUser(user2) && ChatActivity.this.chatMode == 0)) {
                    int i7 = this.rowCount;
                    this.rowCount = i7 + 1;
                    this.botInfoRow = i7;
                } else {
                    this.botInfoRow = -5;
                }
            }
            if (!ChatActivity.this.loading && ChatActivity.this.scheduledDownloadsMode && arrayList.isEmpty()) {
                PlusSettings.clearScheduledDownloadsIds();
            }
        }

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

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

        public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
            View view;
            View view2 = null;
            boolean z = false;
            boolean z2 = true;
            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, this.mContext, z2, ChatActivity.this.themeDelegate) {
                    @Override
                    public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
                        super.onInitializeAccessibilityNodeInfo(info);
                        info.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);
            }
            view2.setLayoutParams(new RecyclerView.LayoutParams(-1, -2));
            return new RecyclerListView.Holder(view2);
        }

        public class AnonymousClass2 implements ChatActionCell.ChatActionCellDelegate {
            @Override
            public boolean canDrawOutboundsContent() {
                return false;
            }

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

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

            public AnonymousClass2() {
            }

            @Override
            public void didOpenPremiumGift(ChatActionCell cell, TLRPC.TL_premiumGiftOption giftOption, String slug, boolean animateConfetti) {
                if (slug != null) {
                    initGiftProgressDialog(cell);
                    PremiumPreviewGiftLinkBottomSheet.show(slug, giftOption, ChatActivity.this.getCurrentUser(), 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(giftOption), ChatActivity.this.themeDelegate).setAnimateConfetti(animateConfetti).setOutboundGift(cell.getMessageObject().isOut()));
                }
            }

            @Override
            public void didOpenPremiumGiftChannel(ChatActionCell cell, String slug, boolean animateConfetti) {
                initGiftProgressDialog(cell);
                GiftInfoBottomSheet.show(getBaseFragment(), slug, ChatActivity.this.progressDialogCurrent);
            }

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

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

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

                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();
                }

                public void end(boolean replaced) {
                    if (replaced) {
                        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 lambda$end$0(ChatActionCell chatActionCell) {
                    ChatActivity.this.resetProgressDialogLoading();
                    chatActionCell.getMessageObject().flickerLoading = false;
                    chatActionCell.invalidate();
                }
            }

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

            @Override
            public void didClickButton(ChatActionCell cell) {
                MessageObject messageObject;
                if (cell != null && (messageObject = cell.getMessageObject()) != null && messageObject.type == 22 && !cell.getMessageObject().isOutOwner() && cell.getMessageObject().isWallpaperForBoth() && cell.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 DialogInterface.OnClickListener() {
                        @Override
                        public final void onClick(DialogInterface dialogInterface, int i) {
                            ChatActivity.ChatActivityAdapter.AnonymousClass2.this.lambda$didClickButton$0(dialogInterface, 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));
                    }
                }
            }

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

            @Override
            public void didClickImage(ChatActionCell cell) {
                TLRPC.VideoSize videoSize;
                String str;
                MessageObject messageObject = cell.getMessageObject();
                PhotoViewer photoViewer = PhotoViewer.getInstance();
                ChatActivity chatActivity = ChatActivity.this;
                photoViewer.setParentActivity(chatActivity, chatActivity.themeDelegate);
                TLRPC.PhotoSize closestPhotoSizeWithSize = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 640);
                if (cell.getMessageObject().type == 24) {
                    StoryViewer orCreateStoryViewer = ChatActivity.this.getOrCreateStoryViewer();
                    ChatActivity chatActivity2 = ChatActivity.this;
                    orCreateStoryViewer.openFor(chatActivity2, chatActivity2.chatListView, cell);
                    return;
                }
                if (cell.getMessageObject().type == 22) {
                    MessagesController messagesController = MessagesController.getInstance(((BaseFragment) ChatActivity.this).currentAccount);
                    if (cell.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 (cell.hasButton()) {
                        ThemePreviewActivity.showFor(ChatActivity.this, messageObject);
                        return;
                    } else {
                        ChatActivity.this.showChatThemeBottomSheet();
                        return;
                    }
                }
                ArrayList arrayList = messageObject.messageOwner.action.photo.video_sizes;
                TLRPC.VideoSize videoSize2 = null;
                if (arrayList == null || arrayList.isEmpty()) {
                    videoSize = null;
                } else {
                    videoSize2 = FileLoader.getClosestVideoSizeWithSize(messageObject.messageOwner.action.photo.video_sizes, 1000);
                    videoSize = FileLoader.getEmojiMarkup(messageObject.messageOwner.action.photo.video_sizes);
                }
                if (cell.getMessageObject().type != 21 || messageObject.isOutOwner()) {
                    if (videoSize2 != null) {
                        PhotoViewer.getInstance().openPhoto(videoSize2.location, ImageLocation.getForPhoto(videoSize2, messageObject.messageOwner.action.photo), ChatActivity.this.photoViewerProvider);
                        if (cell.getMessageObject().type == 21) {
                            PhotoViewer.getInstance().setTitle(LocaleController.getString("SuggestedVideo", R.string.SuggestedVideo));
                            return;
                        }
                        return;
                    }
                    if (closestPhotoSizeWithSize != null) {
                        PhotoViewer.getInstance().openPhoto(closestPhotoSizeWithSize.location, ImageLocation.getForPhoto(closestPhotoSizeWithSize, messageObject.messageOwner.action.photo), ChatActivity.this.photoViewerProvider);
                        if (cell.getMessageObject().type == 21) {
                            PhotoViewer.getInstance().setTitle(LocaleController.getString("SuggestedPhoto", R.string.SuggestedPhoto));
                            return;
                        }
                        return;
                    }
                    PhotoViewer.getInstance().openPhoto(messageObject, (ChatActivity) null, 0L, 0L, 0L, ChatActivity.this.photoViewerProvider);
                    return;
                }
                if (messageObject.settingAvatar) {
                    return;
                }
                if (videoSize != null) {
                    PhotoUtilities.showAvatartConstructorForUpdateUserPhoto(ChatActivity.this, videoSize);
                    return;
                }
                ArrayList<Object> arrayList2 = new ArrayList<>();
                ImageLocation.getForPhoto(videoSize2, messageObject.messageOwner.action.photo);
                FileLoader fileLoader = ChatActivity.this.getFileLoader();
                File pathToAttach = videoSize2 == null ? fileLoader.getPathToAttach(messageObject.messageOwner.action.photo) : fileLoader.getPathToAttach(videoSize2);
                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 = videoSize2 != null;
                arrayList2.add(photoEntry);
                PhotoViewer.getInstance().openPhotoForSelect(arrayList2, 0, 1, false, new C00102(messageObject, photoEntry), null);
                if (photoEntry.isVideo) {
                    PhotoViewer.getInstance().setTitle(LocaleController.getString(R.string.SuggestedVideo));
                } else {
                    PhotoViewer.getInstance().setTitle(LocaleController.getString(R.string.SuggestedPhoto));
                }
                ImageUpdater.AvatarFor avatarFor = new ImageUpdater.AvatarFor(ChatActivity.this.getUserConfig().getCurrentUser(), 1);
                avatarFor.isVideo = videoSize2 != null;
                avatarFor.fromObject = ChatActivity.this.getMessagesController().getUser(Long.valueOf(ChatActivity.this.dialog_id));
                PhotoViewer.getInstance().setAvatarFor(avatarFor);
            }

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

                public C00102(final MessageObject val$message, final MediaController.PhotoEntry val$entry) {
                    this.val$message = val$message;
                    this.val$entry = val$entry;
                }

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

                @Override
                public void sendButtonPressed(int index, VideoEditedInfo videoEditedInfo, boolean notify, int scheduleDate, boolean forceDocument) {
                    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.C00102.this.lambda$sendButtonPressed$3(messageObject2, tLObject, tL_error);
                        }
                    });
                }

                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.C00102.this.lambda$sendButtonPressed$2(tLObject, messageObject);
                        }
                    });
                }

                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("ApplyAvatarHintTitle", R.string.ApplyAvatarHintTitle)), AndroidUtilities.replaceSingleTag(LocaleController.getString("ApplyAvatarHint", R.string.ApplyAvatarHint), new Runnable() {
                                @Override
                                public final void run() {
                                    ChatActivity.ChatActivityAdapter.AnonymousClass2.C00102.this.lambda$sendButtonPressed$1();
                                }
                            }), (BulletinFactory.UndoObject) null).show();
                        }
                    }
                    messageObject.settingAvatar = false;
                }

                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));
                }
            }

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

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

            @Override
            public boolean didLongPress(ChatActionCell cell, float x, float y) {
                if (((BaseFragment) ChatActivity.this).inPreviewMode) {
                    return false;
                }
                return ChatActivity.this.createMenu(cell, false, false, x, y, true);
            }

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

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

            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$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.chatActivityEnterView.setCommand((MessageObject) null, str, false, false);
                    if (ChatActivity.this.chatActivityEnterView.getFieldText() == null) {
                        ChatActivity.this.hideFieldPanel(false);
                        return;
                    }
                    return;
                }
                ChatActivity.this.processExternalUrl(0, str, null, null, false);
            }
        }

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

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

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

            @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.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();
                animatorSet.playTogether(ObjectAnimator.ofFloat(cameraContainer, (Property<InstantCameraView.InstantViewCameraContainer, Float>) View.SCALE_X, f), ObjectAnimator.ofFloat(cameraContainer, (Property<InstantCameraView.InstantViewCameraContainer, Float>) View.SCALE_Y, f), ObjectAnimator.ofFloat(cameraContainer, (Property<InstantCameraView.InstantViewCameraContainer, Float>) View.TRANSLATION_Y, iArr[1] - cameraRect.y), ObjectAnimator.ofFloat(ChatActivity.this.instantCameraView.getSwitchButtonView(), (Property<View, Float>) View.ALPHA, 0.0f), ObjectAnimator.ofInt(ChatActivity.this.instantCameraView.getPaint(), (Property<Paint, Integer>) AnimationProperties.PAINT_ALPHA, 0), ObjectAnimator.ofFloat(ChatActivity.this.instantCameraView.getMuteImageView(), (Property<View, Float>) View.ALPHA, 0.0f));
                animatorSet.setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT);
                ObjectAnimator ofFloat = ObjectAnimator.ofFloat(cameraContainer, (Property<InstantCameraView.InstantViewCameraContainer, Float>) View.TRANSLATION_X, iArr[0] - cameraRect.x);
                ofFloat.setInterpolator(CubicBezierInterpolator.DEFAULT);
                animatorSet2.playTogether(ofFloat, animatorSet);
                animatorSet2.setDuration(300L);
                InstantCameraView instantCameraView = ChatActivity.this.instantCameraView;
                if (instantCameraView != null) {
                    instantCameraView.setIsMessageTransition(true);
                }
                animatorSet2.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        AnonymousClass3.this.val$messageCell.setAlpha(1.0f);
                        AnonymousClass3.this.val$messageCell.getTransitionParams().ignoreAlpha = false;
                        AnimationProperties.FloatProperty<ChatMessageCell> floatProperty = new AnimationProperties.FloatProperty<ChatMessageCell>(this, "alpha") {
                            public void setValue(ChatMessageCell object, float value) {
                                object.setTimeAlpha(value);
                            }

                            public Float get(ChatMessageCell object) {
                                return Float.valueOf(object.getTimeAlpha());
                            }
                        };
                        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 animation2) {
                                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 int getItemViewType(int position) {
            ArrayList<MessageObject> arrayList;
            if (ChatActivity.this.clearingHistory && position == this.botInfoEmptyRow) {
                return 3;
            }
            if (position == this.hintRow) {
                return 1;
            }
            int i = this.messagesStartRow;
            if (position < i || position >= this.messagesEndRow) {
                return position == this.botInfoRow ? 3 : 4;
            }
            if (this.isFrozen) {
                arrayList = this.frozenMessages;
            } else if (this.isFiltered) {
                arrayList = this.filteredMessages;
            } else {
                arrayList = ChatActivity.this.messages;
            }
            return arrayList.get(position - i).contentType;
        }

        public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) {
            ArrayList<MessageObject> arrayList;
            TLRPC.Message message;
            boolean z;
            boolean z2;
            ChatActivity chatActivity;
            String str;
            String stickerEmoji;
            MessagesController.EmojiSound emojiSound;
            View view = holder.itemView;
            if ((view instanceof ChatMessageCell) || (view instanceof ChatActionCell)) {
                ChatActivity.this.invalidateMessagesVisiblePart();
            }
            View view2 = holder.itemView;
            if (view2 instanceof ChatMessageCell) {
                ChatMessageCell chatMessageCell = (ChatMessageCell) view2;
                MessageObject messageObject = chatMessageCell.getMessageObject();
                chatMessageCell.showHintButton(true, false, -1);
                if (ChatActivity.this.hintMessageObject != null && ChatActivity.this.hintMessageObject.equals(messageObject)) {
                    chatMessageCell.showHintButton(false, false, ChatActivity.this.hintMessageType);
                }
                if (messageObject.isAnimatedEmoji() && (stickerEmoji = messageObject.getStickerEmoji()) != null && (emojiSound = (MessagesController.EmojiSound) ChatActivity.this.getMessagesController().emojiSounds.get(stickerEmoji.replace("️", ""))) != null) {
                    ChatActivity.this.getMediaController().playEmojiSound(ChatActivity.this.getAccountInstance(), stickerEmoji, emojiSound, true);
                }
                if (messageObject.updateTranslation(false)) {
                    chatMessageCell.setMessageObject(messageObject, chatMessageCell.getCurrentMessagesGroup(), chatMessageCell.isPinnedBottom(), chatMessageCell.isPinnedTop());
                } else {
                    MessageObject.GroupedMessages currentMessagesGroup = chatMessageCell.getCurrentMessagesGroup();
                    if (currentMessagesGroup != null) {
                        for (int i = 0; i < currentMessagesGroup.messages.size(); i++) {
                            ((MessageObject) currentMessagesGroup.messages.get(i)).updateTranslation();
                        }
                    }
                }
                if (((BaseFragment) ChatActivity.this).actionBar.isActionModeShowed() || ChatActivity.this.reportType >= 0) {
                    ChatActivity chatActivity2 = ChatActivity.this;
                    chatActivity2.highlightMessageQuoteFirst = false;
                    chatActivity2.highlightMessageQuote = null;
                    chatMessageCell.setCheckBoxVisible(chatActivity2.threadMessageObjects == null || !ChatActivity.this.threadMessageObjects.contains(messageObject), false);
                    int i2 = messageObject.getDialogId() == ChatActivity.this.dialog_id ? 0 : 1;
                    if (ChatActivity.this.selectedMessagesIds[i2].indexOfKey(messageObject.getId()) >= 0) {
                        ChatActivity.this.setCellSelectionBackground(messageObject, chatMessageCell, i2, false);
                        z = true;
                    } else {
                        chatMessageCell.setDrawSelectionBackground(false);
                        chatMessageCell.setChecked(false, false, false);
                        z = false;
                    }
                    z2 = true;
                } else {
                    chatMessageCell.setDrawSelectionBackground(false);
                    chatMessageCell.setChecked(false, false, false);
                    chatMessageCell.setCheckBoxVisible(false, false);
                    z = false;
                    z2 = false;
                }
                chatMessageCell.setCheckPressed(!z2, z2 && z);
                if (ChatActivity.this.chatMode == 7 && ChatActivity.this.searchingHashtag != null && ChatActivity.this.searchingQuery != null) {
                    chatMessageCell.setHighlightedText(ChatActivity.this.searchingQuery);
                } else {
                    if (ChatActivity.this.searchContainer != null && ChatActivity.this.searchContainer.getVisibility() == 0) {
                        if (ChatActivity.this.getMediaDataController().isMessageFound(messageObject.getId(), messageObject.getDialogId() == ChatActivity.this.mergeDialogId) && ChatActivity.this.getMediaDataController().getLastSearchQuery() != null) {
                            chatMessageCell.setHighlightedText(ChatActivity.this.getMediaDataController().getLastSearchQuery());
                        }
                    }
                    chatMessageCell.setHighlightedText(null);
                }
                if (!((BaseFragment) ChatActivity.this).inPreviewMode || !chatMessageCell.isHighlighted()) {
                    chatMessageCell.setHighlighted(ChatActivity.this.highlightMessageId != Integer.MAX_VALUE && (chatMessageCell.getMessageObject().getId() == ChatActivity.this.highlightMessageId || (chatMessageCell.getCurrentMessagesGroup() != null && chatMessageCell.getCurrentMessagesGroup().contains(ChatActivity.this.highlightMessageId))));
                    if (chatMessageCell.isHighlighted() && (str = (chatActivity = ChatActivity.this).highlightMessageQuote) != null) {
                        if (!chatMessageCell.setHighlightedText(str, true, chatActivity.highlightMessageQuoteOffset, chatActivity.highlightMessageQuoteFirst)) {
                            ChatActivity chatActivity3 = ChatActivity.this;
                            if (chatActivity3.showNoQuoteAlert) {
                                chatActivity3.showNoQuoteFound();
                            }
                        }
                        ChatActivity chatActivity4 = ChatActivity.this;
                        chatActivity4.showNoQuoteAlert = false;
                        chatActivity4.highlightMessageQuoteFirst = false;
                    }
                    ChatActivity chatActivity5 = ChatActivity.this;
                    if (chatActivity5.highlightMessageId != Integer.MAX_VALUE) {
                        chatActivity5.startMessageUnselect();
                    }
                }
            }
            int adapterPosition = holder.getAdapterPosition();
            int i3 = this.messagesStartRow;
            if (adapterPosition < i3 || adapterPosition >= this.messagesEndRow) {
                return;
            }
            if (this.isFrozen) {
                arrayList = this.frozenMessages;
            } else if (this.isFiltered) {
                arrayList = this.filteredMessages;
            } else {
                arrayList = ChatActivity.this.messages;
            }
            MessageObject messageObject2 = arrayList.get(adapterPosition - i3);
            View view3 = holder.itemView;
            if (messageObject2 == null || (message = messageObject2.messageOwner) == null || !message.media_unread || !message.mentioned) {
                return;
            }
            if (!((BaseFragment) ChatActivity.this).inPreviewMode && ChatActivity.this.chatMode == 0 && !messageObject2.isVoice() && !messageObject2.isRoundVideo()) {
                ChatActivity.this.newMentionsCount--;
                if (ChatActivity.this.newMentionsCount <= 0) {
                    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)));
                }
                ChatActivity.this.getMessagesController().markMentionMessageAsRead(messageObject2.getId(), ChatObject.isChannel(ChatActivity.this.currentChat) ? ChatActivity.this.currentChat.id : 0L, ChatActivity.this.dialog_id);
                messageObject2.setContentIsRead();
            }
            if (view3 instanceof ChatMessageCell) {
                ChatMessageCell chatMessageCell2 = (ChatMessageCell) view3;
                if (((BaseFragment) ChatActivity.this).inPreviewMode) {
                    chatMessageCell2.setHighlighted(true);
                } else {
                    chatMessageCell2.setHighlightedAnimated();
                }
            }
        }

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

        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 View updateRowWithMessageObject(MessageObject messageObject, boolean allowInPlace, boolean replace) {
            ArrayList<MessageObject> arrayList;
            if (allowInPlace) {
                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());
                            return chatMessageCell;
                        }
                    }
                }
            }
            if (this.isFrozen) {
                arrayList = this.frozenMessages;
            } else if (this.isFiltered) {
                arrayList = this.filteredMessages;
            } else {
                arrayList = ChatActivity.this.messages;
            }
            int indexOf = arrayList.indexOf(messageObject);
            if (indexOf == -1) {
                return null;
            }
            if (replace) {
                int i2 = ChatActivity.lastStableId;
                ChatActivity.lastStableId = i2 + 1;
                messageObject.stableId = i2;
                notifyDataSetChanged(true);
            } else {
                updateRowAtPosition(indexOf + this.messagesStartRow);
            }
            return null;
        }

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

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

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

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

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

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

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

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

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

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

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

        public SearchItemListener() {
        }

        @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 void onSearchFilterCleared(FiltersView.MediaFilterData filterData) {
            super.onSearchFilterCleared(filterData);
            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 onSearchCollapse() {
            int i;
            String str;
            TLRPC.Chat chat;
            ChatActivity.this.searching = false;
            ChatActivity.this.updatePagedownButtonVisibility(true);
            ChatActivity.this.updateSearchUpDownButtonVisibility(true);
            if (ChatActivity.this.searchCalendarButton != null) {
                ChatActivity.this.searchCalendarButton.setVisibility(0);
            }
            if (ChatActivity.this.searchUserButton != null) {
                ChatActivity.this.searchUserButton.setVisibility(0);
            }
            if (ChatActivity.this.searchingForUser) {
                ChatActivity.this.mentionContainer.getAdapter().lambda$searchUsernameOrHashtag$7(null, 0, null, false, true);
                ChatActivity.this.searchingForUser = false;
            }
            ChatActivity.this.mentionContainer.setReversed(false);
            ChatActivity.this.mentionContainer.getAdapter().setSearchingMentions(false);
            ChatActivity.this.searchingUserMessages = null;
            ChatActivity.this.searchingChatMessages = null;
            ChatActivity.this.searchingHashtag = null;
            ChatActivity chatActivity = ChatActivity.this;
            ActionBarMenuItem actionBarMenuItem = chatActivity.searchItem;
            if (chatActivity.isSupportedTags()) {
                i = R.string.SavedTagSearchHint;
                str = "SavedTagSearchHint";
            } else {
                i = R.string.Search;
                str = "Search";
            }
            actionBarMenuItem.setSearchFieldHint(LocaleController.getString(str, i));
            ChatActivity.this.searchItem.setSearchFieldCaption(null);
            AndroidUtilities.updateViewVisibilityAnimated(ChatActivity.this.avatarContainer, true, 0.95f, true);
            if (ChatActivity.this.editTextItem != null && ChatActivity.this.editTextItem.getTag() != null) {
                if (ChatActivity.this.headerItem != null) {
                    ChatActivity.this.headerItem.setVisibility(8);
                }
                if (ChatActivity.this.editTextItem != null) {
                    ChatActivity.this.editTextItem.setVisibility(0);
                    ChatActivity.this.checkEditTextItemMenu();
                }
                if (ChatActivity.this.attachItem != null) {
                    ChatActivity.this.attachItem.setVisibility(8);
                }
                if (ChatActivity.this.searchIconItem != null && ChatActivity.this.showSearchAsIcon) {
                    ChatActivity.this.searchIconItem.setVisibility(8);
                }
                if (ChatActivity.this.audioCallIconItem != null && ChatActivity.this.showAudioCallAsIcon) {
                    ChatActivity.this.audioCallIconItem.setVisibility(8);
                }
            } else if (ChatActivity.this.chatActivityEnterView.hasText() && TextUtils.isEmpty(ChatActivity.this.chatActivityEnterView.getSlowModeTimer()) && ((chat = ChatActivity.this.currentChat) == null || ChatObject.canSendPlain(chat))) {
                if (ChatActivity.this.headerItem != null) {
                    ChatActivity.this.headerItem.setVisibility(8);
                }
                if (ChatActivity.this.editTextItem != null) {
                    ChatActivity.this.editTextItem.setVisibility(8);
                }
                if (ChatActivity.this.attachItem != null) {
                    ChatActivity.this.attachItem.setVisibility(0);
                }
                if (ChatActivity.this.searchIconItem != null && ChatActivity.this.showSearchAsIcon) {
                    ChatActivity.this.searchIconItem.setVisibility(8);
                }
                if (ChatActivity.this.audioCallIconItem != null && ChatActivity.this.showAudioCallAsIcon) {
                    ChatActivity.this.audioCallIconItem.setVisibility(8);
                }
            } else {
                if (ChatActivity.this.headerItem != null) {
                    ChatActivity.this.headerItem.setVisibility(0);
                }
                if (ChatActivity.this.audioCallIconItem != null && ChatActivity.this.showAudioCallAsIcon) {
                    ChatActivity.this.audioCallIconItem.setVisibility(0);
                }
                if (ChatActivity.this.searchIconItem != null && ChatActivity.this.showSearchAsIcon) {
                    ChatActivity.this.searchIconItem.setVisibility(0);
                }
                if (ChatActivity.this.editTextItem != null) {
                    ChatActivity.this.editTextItem.setVisibility(8);
                }
                if (ChatActivity.this.attachItem != null) {
                    ChatActivity.this.attachItem.setVisibility(8);
                }
            }
            if (ChatActivity.this.searchViewPager != null) {
                if (ChatActivity.this.hashtagSearchTabs.tabs.getCurrentPosition() != 0) {
                    ChatActivity.this.hashtagSearchTabs.tabs.scrollToTab(0, 0);
                    ChatActivity.this.requestClearSearchPages = true;
                } else {
                    ChatActivity.this.searchViewPager.clearViews();
                }
            }
            if (ChatActivity.this.chatMode == 3 || ((ChatActivity.this.threadMessageId == 0 && !UserObject.isReplyUser(ChatActivity.this.currentUser)) || (ChatActivity.this.threadMessageObject != null && ChatActivity.this.threadMessageObject.getRepliesCount() < 10))) {
                ChatActivity.this.searchItem.setVisibility(8);
            }
            ChatActivity.this.searchItemVisible = false;
            ChatActivity.this.getMediaDataController().clearFoundMessageObjects();
            HashtagSearchController.getInstance(((BaseFragment) ChatActivity.this).currentAccount).clearSearchResults();
            if (ChatActivity.this.messagesSearchAdapter != null) {
                ChatActivity.this.messagesSearchAdapter.notifyDataSetChanged();
            }
            ChatActivity.this.removeSelectedMessageHighlight();
            ChatActivity.this.updateBottomOverlay();
            ChatActivity.this.updatePinnedMessageView(true);
            ChatActivity.this.updateVisibleRows();
            ValueAnimator ofFloat = ValueAnimator.ofFloat(this.searchAnimationProgress, 0.0f);
            ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                    ChatActivity.SearchItemListener.this.lambda$onSearchCollapse$0(valueAnimator);
                }
            });
            ofFloat.setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT);
            ofFloat.setDuration(320L);
            ofFloat.start();
            ChatActivity.this.messagesSearchListContainer.setAlpha(0.0f);
            ChatActivity.this.messagesSearchListContainer.setVisibility(8);
            ChatActivity.this.messagesSearchListContainer.setTag(null);
            ChatActivity.this.updateSearchListEmptyView();
            ChatActivity chatActivity2 = ChatActivity.this;
            chatActivity2.searchingReaction = null;
            chatActivity2.updateSearchUpDownButtonVisibility(true);
            ChatActivity.this.updatePagedownButtonVisibility(true);
            SearchTagsList searchTagsList = ChatActivity.this.actionBarSearchTags;
            if (searchTagsList != null) {
                searchTagsList.clear();
                ChatActivity.this.actionBarSearchTags.show(false);
            }
            ChatSearchTabs chatSearchTabs = ChatActivity.this.hashtagSearchTabs;
            if (chatSearchTabs != null) {
                chatSearchTabs.show(false);
            }
            ChatActivity.this.updateBio();
            ChatActivity.this.setFilterMessages(false);
            ChatActivity.this.hashtagHistoryView.show(false);
        }

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

        @Override
        public void onSearchExpand() {
            ChatSearchTabs chatSearchTabs;
            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$363(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) {
                searchTagsList.show(!chatActivity3.isInsideContainer && searchTagsList.hasFilters() && ChatActivity.this.searchingHashtag == null);
            }
            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);
        }

        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 setSearchAnimationProgress(float progress) {
            this.searchAnimationProgress = progress;
            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 void onSearchPressed(EditText editText) {
            ChatActivity chatActivity = ChatActivity.this;
            chatActivity.searchWas = true;
            chatActivity.updateSearchButtons(0, 0, -1);
            ChatActivity.this.searchingQuery = editText.getText().toString();
            if (ChatActivity.this.searchingHashtag != null) {
                if (TextUtils.isEmpty(ChatActivity.this.searchingQuery)) {
                    return;
                }
                if (ChatActivity.this.searchingHashtag.startsWith("$")) {
                    ChatActivity.this.searchingHashtag = "$" + ChatActivity.this.searchingQuery;
                } else {
                    ChatActivity.this.searchingHashtag = "#" + ChatActivity.this.searchingQuery;
                }
                ChatActivity chatActivity2 = ChatActivity.this;
                chatActivity2.searchingQuery = chatActivity2.searchingHashtag;
                HashtagSearchController.getInstance(((BaseFragment) ChatActivity.this).currentAccount).putToHistory(ChatActivity.this.searchingHashtag);
                ChatActivity.this.hashtagHistoryView.update();
                View currentView = ChatActivity.this.searchViewPager.getCurrentView();
                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);
            }
            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("SearchFrom", 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();
                }
            }
        }

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

        @Override
        public void onCaptionCleared() {
            int i;
            String str;
            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;
            ActionBarMenuItem actionBarMenuItem = chatActivity.searchItem;
            if (chatActivity.isSupportedTags()) {
                i = R.string.SavedTagSearchHint;
                str = "SavedTagSearchHint";
            } else {
                i = R.string.Search;
                str = "Search";
            }
            actionBarMenuItem.setSearchFieldHint(LocaleController.getString(str, i));
            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 boolean forceShowClear() {
            return ChatActivity.this.searchingForUser;
        }

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

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

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

    public class ChatMessageCellDelegate implements ChatMessageCell.ChatMessageCellDelegate {
        public boolean longPress;

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

        @Override
        public boolean disableThemeModifications() {
            return ChatMessageCell.ChatMessageCellDelegate.CC.$default$disableThemeModifications(this);
        }

        public ChatMessageCellDelegate() {
        }

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

        @Override
        public void didPressHint(ChatMessageCell cell, int type) {
            if (type == 0) {
                ChatActivity.this.showPollSolution(cell.getMessageObject(), cell.getMessageObject().messageOwner.media.results);
            } else if (type == 1) {
                MessageObject messageObject = cell.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("PsaMessageInfoDefault", R.string.PsaMessageInfoDefault);
                }
                SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(string);
                MessageObject.addLinks(false, spannableStringBuilder);
                MessageObject.GroupedMessages currentMessagesGroup = cell.getCurrentMessagesGroup();
                if (currentMessagesGroup != null) {
                    int size = currentMessagesGroup.posArray.size();
                    int i = 0;
                    while (true) {
                        if (i >= size) {
                            break;
                        }
                        if ((((MessageObject.GroupedMessagePosition) currentMessagesGroup.posArray.get(i)).flags & 1) != 0) {
                            MessageObject messageObject2 = (MessageObject) currentMessagesGroup.messages.get(i);
                            if (messageObject2 != messageObject) {
                                int childCount = ChatActivity.this.chatListView.getChildCount();
                                for (int i2 = 0; i2 < childCount; i2++) {
                                    View childAt = ChatActivity.this.chatListView.getChildAt(i2);
                                    if (childAt instanceof ChatMessageCell) {
                                        ChatMessageCell chatMessageCell = (ChatMessageCell) childAt;
                                        if (messageObject2.equals(chatMessageCell.getMessageObject())) {
                                            cell = chatMessageCell;
                                        }
                                    }
                                }
                                messageObject = messageObject2;
                            }
                        } else {
                            i++;
                        }
                    }
                }
                ChatActivity.this.showInfoHint(messageObject, spannableStringBuilder, 1);
            }
            cell.showHintButton(false, true, type);
        }

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

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

        @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");
        }

        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();
        }

        @Override
        public void didPressFactCheck(ChatMessageCell cell) {
            MessageObject primaryMessageObject;
            int i;
            int i2;
            if (cell == null || (primaryMessageObject = cell.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 (((ChatMessageCell) childAt).getCurrentMessagesGroup() == null) {
                                i2 = ChatActivity.this.getScrollingOffsetForView(childAt);
                                break;
                            }
                        } else if (childAt instanceof ChatActionCell) {
                            i2 = ChatActivity.this.getScrollingOffsetForView(childAt);
                            break;
                        }
                    }
                }
            }
            i = -1;
            i2 = 0;
            ChatActivity.this.lambda$updateMessageAnimated$295(primaryMessageObject, false);
            if (ChatActivity.this.factCheckHint != null) {
                ChatActivity.this.factCheckHint.hide();
            }
            if (i < 0 || cell.getCurrentMessagesGroup() != null) {
                return;
            }
            ChatActivity.this.chatLayoutManager.scrollToPositionWithOffset(i, i2);
        }

        @Override
        public void forceUpdate(ChatMessageCell cell, boolean anchorScroll) {
            MessageObject primaryMessageObject;
            int i;
            int i2;
            if (cell == null || (primaryMessageObject = cell.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 (((ChatMessageCell) childAt).getCurrentMessagesGroup() == null) {
                                i2 = ChatActivity.this.getScrollingOffsetForView(childAt);
                                break;
                            }
                        } else if (childAt instanceof ChatActionCell) {
                            i2 = ChatActivity.this.getScrollingOffsetForView(childAt);
                            break;
                        }
                    }
                }
            }
            i = -1;
            i2 = 0;
            ChatActivity.this.lambda$updateMessageAnimated$295(primaryMessageObject, false);
            if (anchorScroll && i >= 0 && cell.getCurrentMessagesGroup() == null) {
                ChatActivity.this.chatLayoutManager.scrollToPositionWithOffset(i, i2);
            }
        }

        @Override
        public boolean didLongPressSideButton(ChatMessageCell cell) {
            this.longPress = true;
            didPressSideButton(cell);
            this.longPress = false;
            return true;
        }

        @Override
        public void didPressSideButton(ChatMessageCell cell) {
            TLRPC.Message message;
            TLRPC.MessageReplyHeader messageReplyHeader;
            int i;
            TLRPC.MessageFwdHeader messageFwdHeader;
            MessageObject.GroupedMessages groupedMessages;
            if (ChatActivity.this.getParentActivity() == null) {
                return;
            }
            ChatActivityEnterView chatActivityEnterView = ChatActivity.this.chatActivityEnterView;
            if (chatActivityEnterView != null) {
                chatActivityEnterView.closeKeyboard();
            }
            MessageObject messageObject = cell.getMessageObject();
            if (ChatActivity.this.chatMode == 2) {
                ChatActivity.this.chatActivityDelegate.openReplyMessage(messageObject.getId());
                ChatActivity.this.lambda$onBackPressed$358();
                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 = messageObject.messageOwner.fwd_from) != null && messageFwdHeader.saved_from_peer != null))) {
                if (UserObject.isReplyUser(ChatActivity.this.currentUser) && (messageReplyHeader = (message = messageObject.messageOwner).reply_to) != 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 if (ChatActivity.this.chatMode == 7 && ChatActivity.this.searchType == 2) {
                    ChatActivity.this.openMessageInOriginalDialog(messageObject);
                    return;
                } else {
                    ChatActivity.this.openOriginalReplyChat(messageObject);
                    return;
                }
            }
            if (ChatActivity.this.directShareReplies) {
                ChatActivity.this.showFieldPanelForReply(cell.getMessageObject());
                return;
            }
            int i2 = this.longPress ? PlusSettings.directShareButtonLongClickAction : PlusSettings.directShareButtonAction;
            if (i2 != 0) {
                ChatActivity.this.selectedObject = cell.getMessageObject();
                ChatActivity.this.selectedObjectGroup = cell.getCurrentMessagesGroup();
                ChatActivity.this.checkPlusAction(PlusSettings.getDirectShareAction(i2));
                return;
            }
            ArrayList arrayList = null;
            if (messageObject.getGroupId() != 0 && (groupedMessages = (MessageObject.GroupedMessages) ChatActivity.this.groupedMessagesMap.get(messageObject.getGroupId())) != null) {
                arrayList = groupedMessages.messages;
            }
            if (arrayList == null) {
                arrayList = new ArrayList();
                arrayList.add(messageObject);
            }
            ArrayList arrayList2 = arrayList;
            boolean z = ChatActivity.this.getMessagesController().storiesEnabled() && StoryEntry.canRepostMessage(messageObject);
            ChatActivity chatActivity = ChatActivity.this;
            Context context = ChatActivity.this.getContext();
            ChatActivity chatActivity2 = ChatActivity.this;
            ShareAlert anonymousClass1 = new AnonymousClass1(context, chatActivity2, arrayList2, null, null, ChatObject.isChannel(chatActivity2.currentChat), null, null, false, false, z, ChatActivity.this.themeDelegate, z, messageObject);
            chatActivity.shareAlert = anonymousClass1;
            chatActivity.showDialog(anonymousClass1);
            ChatActivity.this.shareAlert.setParentFragment(ChatActivity.this);
            ((BaseFragment) ChatActivity.this).fragmentView.requestLayout();
        }

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

            public AnonymousClass1(final Context context, ChatActivity fragment, ArrayList messages, final String text, final String text2, boolean channel, final String copyLink, final String copyLink2, boolean fullScreen, boolean forCall, boolean includeStory, Theme.ResourcesProvider resourcesProvider, final boolean val$includeStory, final MessageObject val$messageObject) {
                super(context, fragment, messages, text, text2, channel, copyLink, copyLink2, fullScreen, forCall, includeStory, resourcesProvider);
                this.val$includeStory = val$includeStory;
                this.val$messageObject = val$messageObject;
                ((ShareAlert) this).includeStoryFromMessage = val$includeStory;
            }

            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();
                }
            }

            public void onShareStory(final View cell) {
                StoryRecorder.SourceView fromShareCell = cell instanceof ShareDialogCell ? StoryRecorder.SourceView.fromShareCell((ShareDialogCell) cell) : 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(), 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, cell, (Long) obj, (Runnable) obj2, (Boolean) obj3, (Long) obj4);
                    }
                });
                storyRecorder.openRepost(fromShareCell, StoryEntry.repostMessage(arrayList));
            }

            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();
                    storyRecorder.replaceSourceView((StoryRecorder.SourceView) null);
                } else {
                    if ((view instanceof ShareDialogCell) && view.isAttachedToWindow()) {
                        sourceView = StoryRecorder.SourceView.fromShareCell((ShareDialogCell) view);
                    }
                    storyRecorder.replaceSourceView(sourceView);
                }
                AndroidUtilities.runOnUIThread(runnable);
            }

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

            public void onSend(LongSparseArray<TLRPC.Dialog> dids, int count, TLRPC.TL_forumTopic topic) {
                ChatActivity.this.createUndoView();
                if (ChatActivity.this.undoView == null) {
                    return;
                }
                if (dids.size() != 1) {
                    ChatActivity.this.undoView.showWithAction(0L, 53, Integer.valueOf(count), Integer.valueOf(dids.size()), (Runnable) null, (Runnable) null);
                } else {
                    if (((TLRPC.Dialog) dids.valueAt(0)).id == ChatActivity.this.getUserConfig().getClientUserId() && BulletinFactory.of(ChatActivity.this).showForwardedBulletinWithTag(((TLRPC.Dialog) dids.valueAt(0)).id, count)) {
                        return;
                    }
                    ChatActivity.this.undoView.showWithAction(((TLRPC.Dialog) dids.valueAt(0)).id, 53, Integer.valueOf(count), topic, (Runnable) null, (Runnable) null);
                }
            }
        }

        @Override
        public boolean needPlayMessage(ChatMessageCell chatMessageCell, MessageObject messageObject, boolean z) {
            if (messageObject.isVoiceOnce() || messageObject.isRoundOnce()) {
                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;
            }
            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;
        }

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

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

        @Override
        public void didPressChannelAvatar(ChatMessageCell cell, TLRPC.Chat chat, int postId, float touchX, float touchY) {
            if (chat == null) {
                return;
            }
            if (((BaseFragment) ChatActivity.this).actionBar.isActionModeShowed() || ChatActivity.this.reportType >= 0) {
                ChatActivity.this.processRowSelect(cell, true, touchX, touchY);
            } else {
                openChat(cell, chat, postId);
            }
        }

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

        @Override
        public void didPressOther(ChatMessageCell cell, float otherX, float otherY) {
            MessageObject messageObject = cell.getMessageObject();
            if (messageObject.type == 16) {
                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;
            }
            ChatActivity.this.createMenu(cell, true, false, otherX, otherY, messageObject.isMusic(), false);
        }

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

        @Override
        public void didPressSponsoredInfo(ChatMessageCell cell, float x, float y) {
            ChatActivity.this.createMenu(cell, true, false, x, y, false, false);
        }

        @Override
        public void didPressUserStatus(ChatMessageCell cell, TLRPC.User user, TLRPC.Document document) {
            ImageLocation forDocument;
            if (cell == null) {
                return;
            }
            ChatActivity chatActivity = ChatActivity.this;
            ?? premiumPreviewBottomSheet = new PremiumPreviewBottomSheet(chatActivity, ((BaseFragment) chatActivity).currentAccount, user, ChatActivity.this.themeDelegate);
            cell.getLocationOnScreen(new int[2]);
            premiumPreviewBottomSheet.startEnterFromX = cell.getNameStatusX();
            premiumPreviewBottomSheet.startEnterFromY = cell.getNameStatusY();
            premiumPreviewBottomSheet.startEnterFromScale = cell.getScaleX();
            premiumPreviewBottomSheet.startEnterFromX1 = cell.getLeft();
            premiumPreviewBottomSheet.startEnterFromY1 = cell.getTop();
            premiumPreviewBottomSheet.startEnterFromView = cell;
            int colorId = UserObject.getColorId(user);
            if (colorId >= 7) {
                MessagesController.PeerColors peerColors = MessagesController.getInstance(((BaseFragment) ChatActivity.this).currentAccount).peerColors;
                MessagesController.PeerColor color = peerColors != null ? peerColors.getColor(colorId) : null;
                premiumPreviewBottomSheet.accentColor = color != null ? Integer.valueOf(color.getColor1()) : null;
            } else {
                premiumPreviewBottomSheet.accentColor = Integer.valueOf(ChatActivity.this.getThemedColor(Theme.keys_avatar_nameInMessage[colorId]));
            }
            AnimatedEmojiDrawable.SwapAnimatedEmojiDrawable swapAnimatedEmojiDrawable = cell.currentNameStatusDrawable;
            if (swapAnimatedEmojiDrawable != null && (swapAnimatedEmojiDrawable.getDrawable() instanceof AnimatedEmojiDrawable)) {
                premiumPreviewBottomSheet.startEnterFromScale *= 0.95f;
                if (document != null) {
                    BackupImageView backupImageView = new BackupImageView(ChatActivity.this.getContext());
                    String str = "160_160";
                    SvgHelper.SvgDrawable svgThumb = DocumentObject.getSvgThumb(document.thumbs, Theme.key_windowBackgroundWhiteGrayIcon, 0.2f);
                    TLRPC.PhotoSize closestPhotoSizeWithSize = FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 90);
                    if ("video/webm".equals(document.mime_type)) {
                        forDocument = ImageLocation.getForDocument(document);
                        str = "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);
                    }
                    String str2 = str;
                    backupImageView.setLayerNum(7);
                    backupImageView.setRoundRadius(AndroidUtilities.dp(4.0f));
                    backupImageView.setImage(forDocument, 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);
                    } else {
                        premiumPreviewBottomSheet.statusStickerSet = MessageObject.getInputStickerSet(document);
                    }
                    premiumPreviewBottomSheet.overrideTitleIcon = backupImageView;
                    premiumPreviewBottomSheet.isEmojiStatus = true;
                }
            }
            ChatActivity.this.showDialog((Dialog) premiumPreviewBottomSheet);
        }

        @Override
        public void didPressUserAvatar(ChatMessageCell cell, TLRPC.User user, float touchX, float touchY) {
            boolean z = true;
            if (((BaseFragment) ChatActivity.this).actionBar.isActionModeShowed() || ChatActivity.this.reportType >= 0) {
                ChatActivity.this.processRowSelect(cell, true, touchX, touchY);
                return;
            }
            if (ChatActivity.this.isInPreviewMode()) {
                return;
            }
            if (PlusSettings.tapAvatarAction > 0) {
                PlusSettings.tapOn = true;
                int i = PlusSettings.tapAvatarAction;
                if (i == 1) {
                    AvatarPreviewer.forceOpen = true;
                    didLongPressUserAvatar(cell, user, touchX, touchY);
                } else if (i == 2) {
                    AvatarPreviewer.forceOpen = false;
                    didLongPressUserAvatar(cell, user, touchX, touchY);
                } else if (i == 3) {
                    ChatActivity.this.avatarImage = new BackupImageView(ChatActivity.this.getContext());
                    ChatActivity.this.provider_user_id = user.id;
                    TLRPC.UserProfilePhoto userProfilePhoto = user.photo;
                    if (userProfilePhoto != null && userProfilePhoto.photo_big != null) {
                        PhotoViewer.getInstance().setParentActivity(ChatActivity.this.getParentActivity(), ChatActivity.this.themeDelegate);
                        PhotoViewer.getInstance().openPhoto(user.photo.photo_big, ChatActivity.this.provider);
                    } else {
                        PlusUtils.showToast(ChatActivity.this.getParentActivity(), LocaleController.getString("CacheEmpty", R.string.CacheEmpty));
                    }
                }
                PlusSettings.tapOn = false;
                return;
            }
            if (cell != null && cell.getMessageObject() != null && cell.getMessageObject().isSponsored()) {
                didPressInstantButton(cell, 10);
                return;
            }
            if (!ChatObject.isForum(ChatActivity.this.currentChat) && !ChatActivity.this.isThreadChat()) {
                z = false;
            }
            openProfile(user, z);
        }

        @Override
        public boolean didLongPressUserAvatar(final org.telegram.ui.Cells.ChatMessageCell r22, final org.telegram.tgnet.TLRPC.User r23, float r24, float r25) {
            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");
        }

        public class AnonymousClass2 implements View.OnLongClickListener {
            public final AvatarPreviewer.MenuItem[] val$menuItems;
            public final TLRPC.User val$user;

            public AnonymousClass2(final AvatarPreviewer.MenuItem[] val$menuItems, final TLRPC.User val$user) {
                this.val$menuItems = val$menuItems;
                this.val$user = val$user;
            }

            @Override
            public boolean onLongClick(View v) {
                if (this.val$menuItems[((Integer) v.getTag()).intValue()] != AvatarPreviewer.MenuItem.MENTION) {
                    return false;
                }
                int length = ChatActivity.this.chatActivityEnterView.getFieldText() == null ? 0 : ChatActivity.this.chatActivityEnterView.getFieldText().length();
                SpannableString spannableString = new SpannableString(UserObject.getFirstName(this.val$user, false) + " ");
                spannableString.setSpan(new URLSpanUserMention("" + this.val$user.id, 3), 0, spannableString.length(), 33);
                ChatActivity.this.chatActivityEnterView.replaceWithText(length, 0, spannableString, false);
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.ChatMessageCellDelegate.AnonymousClass2.this.lambda$onLongClick$0();
                    }
                }, 200L);
                return true;
            }

            public void lambda$onLongClick$0() {
                ChatActivity.this.chatActivityEnterView.openKeyboard();
            }
        }

        public void lambda$didLongPressUserAvatar$4(final TLRPC.User user, final TLRPC.ChatParticipant chatParticipant, final TLRPC.ChannelParticipant channelParticipant, final boolean z, String str, ChatMessageCell chatMessageCell, AvatarPreviewer.MenuItem menuItem) {
            int i = AnonymousClass180.$SwitchMap$org$telegram$ui$AvatarPreviewer$MenuItem[menuItem.ordinal()];
            if (i != 1) {
                switch (i) {
                    case 4:
                        ChatActivity.this.showUserMsgs(user.id);
                        break;
                    case 5:
                        ChatActivity.this.showUserMedia(user.id);
                        break;
                    case 6:
                        appendMention(user);
                        break;
                    case 7:
                    case 8:
                        ChatActivity.this.openRightsEdit(0, user, chatParticipant, channelParticipant != null ? channelParticipant.admin_rights : null, channelParticipant != null ? channelParticipant.banned_rights : null, channelParticipant != null ? channelParticipant.rank : "", z);
                        break;
                    case 9:
                        if (!(channelParticipant instanceof TLRPC.TL_channelParticipantAdmin) && !(chatParticipant instanceof TLRPC.TL_chatParticipantAdmin)) {
                            if (channelParticipant != null) {
                                ChatActivity.this.openRightsEdit(1, user, chatParticipant, channelParticipant.admin_rights, channelParticipant.banned_rights, channelParticipant.rank, z);
                                break;
                            } else {
                                ChatActivity.this.openRightsEdit(1, user, chatParticipant, null, null, "", z);
                                break;
                            }
                        } else {
                            AlertDialog.Builder builder = new AlertDialog.Builder(ChatActivity.this.getParentActivity());
                            builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
                            builder.setMessage(LocaleController.formatString("AdminWillBeRemoved", R.string.AdminWillBeRemoved, new Object[]{ContactsController.formatName(user.first_name, user.last_name)}));
                            final int i2 = 1;
                            builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
                                @Override
                                public final void onClick(DialogInterface dialogInterface, int i3) {
                                    ChatActivity.ChatMessageCellDelegate.this.lambda$didLongPressUserAvatar$2(channelParticipant, i2, user, chatParticipant, z, dialogInterface, i3);
                                }
                            });
                            builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                            ChatActivity.this.showDialog(builder.create());
                            break;
                        }
                    case 10:
                        AlertDialog.Builder builder2 = new AlertDialog.Builder(ChatActivity.this.getParentActivity());
                        builder2.setTitle(str);
                        builder2.setMessage(LocaleController.formatString("KickFromGroup", R.string.KickFromGroup, new Object[]{ContactsController.formatName(user.first_name, user.last_name)}));
                        builder2.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
                            @Override
                            public final void onClick(DialogInterface dialogInterface, int i3) {
                                ChatActivity.ChatMessageCellDelegate.this.lambda$didLongPressUserAvatar$3(user, dialogInterface, i3);
                            }
                        });
                        builder2.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                        ChatActivity.this.showDialog(builder2.create());
                        break;
                    case 11:
                        openDialog(chatMessageCell, user);
                        break;
                    case 12:
                        ChatActivity.this.lambda$openSearchWithUser$365(user);
                        break;
                }
            }
            openProfile(user);
        }

        public void lambda$didLongPressUserAvatar$2(TLRPC.ChannelParticipant channelParticipant, int i, TLRPC.User user, TLRPC.ChatParticipant chatParticipant, boolean z, DialogInterface dialogInterface, int i2) {
            if (channelParticipant != null) {
                ChatActivity.this.openRightsEdit(i, user, chatParticipant, channelParticipant.admin_rights, channelParticipant.banned_rights, channelParticipant.rank, z);
            } else {
                ChatActivity.this.openRightsEdit(i, user, chatParticipant, null, null, "", z);
            }
        }

        public void lambda$didLongPressUserAvatar$3(TLRPC.User user, DialogInterface dialogInterface, int i) {
            ChatActivity.this.kickUser(user);
        }

        public final void appendMention(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$5();
                    }
                }, 200L);
            }
        }

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

        public final void appendMention(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(' ');
                }
                if (chat.username != null) {
                    spannableStringBuilder.append((CharSequence) "@").append((CharSequence) chat.username).append((CharSequence) " ");
                } else {
                    SpannableString spannableString = new SpannableString(chat.title + " ");
                    spannableString.setSpan(new URLSpanUserMention("" + chat.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$6();
                    }
                }, 200L);
            }
        }

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

        @Override
        public boolean didLongPressChannelAvatar(final ChatMessageCell cell, final TLRPC.Chat chat, int postId, float touchX, float touchY) {
            AvatarPreviewer.Data of;
            if (!isAvatarPreviewerEnabled()) {
                return false;
            }
            AvatarPreviewer.MenuItem[] menuItemArr = {AvatarPreviewer.MenuItem.OPEN_PROFILE};
            ChatActivity chatActivity = ChatActivity.this;
            TLRPC.Chat chat2 = chatActivity.currentChat;
            if (chat2 == null || chat2.id != chat.id || chatActivity.isThreadChat() || (!chat.broadcast && ChatActivity.this.currentChat.id == chat.id)) {
                AvatarPreviewer.MenuItem[] menuItemArr2 = (AvatarPreviewer.MenuItem[]) Arrays.copyOf(menuItemArr, 2);
                menuItemArr2[1] = chat.broadcast ? AvatarPreviewer.MenuItem.OPEN_CHANNEL : AvatarPreviewer.MenuItem.OPEN_GROUP;
                ChatActivity chatActivity2 = ChatActivity.this;
                int i = (chatActivity2.currentChat == null || (chatActivity2.bottomOverlayChat != null && ChatActivity.this.bottomOverlayChat.getVisibility() == 0) || (ChatActivity.this.bottomOverlay != null && ChatActivity.this.bottomOverlay.getVisibility() == 0)) ? 0 : 1;
                menuItemArr = (AvatarPreviewer.MenuItem[]) Arrays.copyOf(menuItemArr2, i + 4 + 0);
                menuItemArr[2] = AvatarPreviewer.MenuItem.SHOW_MESSAGES;
                menuItemArr[3] = AvatarPreviewer.MenuItem.SHOW_MEDIA;
                if (i != 0) {
                    menuItemArr[4] = AvatarPreviewer.MenuItem.MENTION;
                }
            }
            TLRPC.ChatFull chatFull = ChatActivity.this.getMessagesController().getChatFull(chat.id);
            if (chatFull == null) {
                of = AvatarPreviewer.Data.of(chat, ((BaseFragment) ChatActivity.this).classGuid, menuItemArr);
            } else {
                of = AvatarPreviewer.Data.of(chat, chatFull, menuItemArr);
            }
            AvatarPreviewer avatarPreviewer = AvatarPreviewer.getInstance();
            ChatActivity chatActivity3 = ChatActivity.this;
            avatarPreviewer.show((ViewGroup) ((BaseFragment) chatActivity3).fragmentView, chatActivity3.themeDelegate, of, new AvatarPreviewer.Callback() {
                @Override
                public final void onMenuClick(AvatarPreviewer.MenuItem menuItem) {
                    ChatActivity.ChatMessageCellDelegate.this.lambda$didLongPressChannelAvatar$7(chat, cell, menuItem);
                }
            });
            return true;
        }

        public void lambda$didLongPressChannelAvatar$7(TLRPC.Chat chat, ChatMessageCell chatMessageCell, AvatarPreviewer.MenuItem menuItem) {
            switch (AnonymousClass180.$SwitchMap$org$telegram$ui$AvatarPreviewer$MenuItem[menuItem.ordinal()]) {
                case 1:
                    openProfile(chat);
                    break;
                case 2:
                case 3:
                    openChat(chatMessageCell, chat, 0);
                    break;
                case 4:
                    ChatActivity.this.showUserMsgs(chat.id);
                    break;
                case 5:
                    ChatActivity.this.showUserMedia(chat.id);
                    break;
                case 6:
                    appendMention(chat);
                    break;
            }
        }

        public final void openProfile(TLRPC.User user) {
            openProfile(user, false);
        }

        public final void openProfile(TLRPC.User user, boolean expandPhoto) {
            if (user != null) {
                TLRPC.UserProfilePhoto userProfilePhoto = user.photo;
                int i = 0;
                if (userProfilePhoto == null || (userProfilePhoto instanceof TLRPC.TL_userProfilePhotoEmpty)) {
                    expandPhoto = false;
                }
                Bundle bundle = new Bundle();
                bundle.putLong("user_id", user.id);
                bundle.putBoolean("expandPhoto", expandPhoto);
                if (UserObject.isUserSelf(user)) {
                    bundle.putBoolean("my_profile", true);
                }
                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);
            }
        }

        public final void openProfile(TLRPC.Chat chat) {
            openProfile(chat, false);
        }

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

        public final void openDialog(ChatMessageCell cell, TLRPC.User user) {
            if (user != null) {
                Bundle bundle = new Bundle();
                bundle.putLong("user_id", user.id);
                if (ChatActivity.this.getMessagesController().checkCanOpenChat(bundle, ChatActivity.this, cell.getMessageObject())) {
                    if (MessagesController.getInstance(((BaseFragment) ChatActivity.this).currentAccount).hiddenDialogs.contains(Long.valueOf(user.id)) && !PlusSettings.openHiddenDialogsWithoutPasscode && !PlusSettings.insideHidden && SharedConfig.hiddenPasscodeHash.length() > 0) {
                        NotificationCenter.getInstance(UserConfig.selectedAccount).postNotificationName(NotificationCenter.closeChats, new Object[]{0L});
                        bundle.putLong("hidden_dialog", user.id);
                        ChatActivity.this.presentFragment(new DialogsActivity(bundle), true, true);
                        return;
                    }
                    ChatActivity.this.presentFragment(new ChatActivity(bundle));
                }
            }
        }

        public final void openChat(ChatMessageCell cell, TLRPC.Chat chat, int postId) {
            ChatActivity chatActivity = ChatActivity.this;
            TLRPC.Chat chat2 = chatActivity.currentChat;
            if (chat2 != null && chat.id == chat2.id) {
                if (chatActivity.avatarContainer != null && postId == 0) {
                    ChatActivity.this.avatarContainer.openProfile(false);
                    return;
                } else {
                    ChatActivity.this.scrollToMessageId(postId, cell.getMessageObject().getId(), true, 0, false, 0);
                    return;
                }
            }
            if (chat2 == null || chat.id != chat2.id || chatActivity.isThreadChat()) {
                Bundle bundle = new Bundle();
                bundle.putLong("chat_id", chat.id);
                if (postId != 0) {
                    bundle.putInt("message_id", postId);
                }
                if (ChatActivity.this.getMessagesController().checkCanOpenChat(bundle, ChatActivity.this, cell.getMessageObject())) {
                    ChatActivity.this.presentFragment(new ChatActivity(bundle));
                }
            }
        }

        public final boolean isAvatarPreviewerEnabled() {
            ChatActivity chatActivity = ChatActivity.this;
            return (chatActivity.currentUser == null && chatActivity.currentChat == null) ? false : true;
        }

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

        @Override
        public void needShowPremiumBulletin(int type) {
            String replaceSingleTag;
            try {
                if (type == 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$8();
                        }
                    });
                    ChatActivity.this.topUndoView.performHapticFeedback(3, 2);
                } else {
                    if (type != 1) {
                        if (type == 2 || type == 3) {
                            String formatDateTime = LocaleController.formatDateTime(ChatActivity.this.getMessagesController().transcribeAudioTrialCooldownUntil, true);
                            BulletinFactory of = BulletinFactory.of(ChatActivity.this);
                            int i = R.raw.transcribe;
                            SpannableStringBuilder append = new SpannableStringBuilder().append((CharSequence) AndroidUtilities.replaceTags(LocaleController.formatPluralString("TranscriptionTrialEnd", ChatActivity.this.getMessagesController().transcribeAudioTrialWeeklyNumber, new Object[0]))).append((CharSequence) " ");
                            if (type == 2) {
                                replaceSingleTag = AndroidUtilities.replaceSingleTag(LocaleController.getString(R.string.TranscriptionTrialEndBuy), new Runnable() {
                                    @Override
                                    public final void run() {
                                        ChatActivity.ChatMessageCellDelegate.this.lambda$needShowPremiumBulletin$9();
                                    }
                                });
                            } else {
                                replaceSingleTag = ChatActivity.this.getMessagesController().transcribeAudioTrialCooldownUntil <= 0 ? "" : AndroidUtilities.replaceSingleTag(LocaleController.formatString(R.string.TranscriptionTrialEndWaitOrBuy, new Object[]{formatDateTime}), new Runnable() {
                                    @Override
                                    public final void run() {
                                        ChatActivity.ChatMessageCellDelegate.this.lambda$needShowPremiumBulletin$10();
                                    }
                                });
                            }
                            of.createSimpleBulletin(i, append.append(replaceSingleTag), 6, 7000).show(true);
                            BotWebViewVibrationEffect.APP_ERROR.vibrate();
                            return;
                        }
                        return;
                    }
                    BulletinFactory.of(ChatActivity.this).createSimpleBulletin(R.raw.transcribe, ChatActivity.this.getMessagesController().transcribeAudioTrialCooldownUntil > 0 ? AndroidUtilities.replaceTags(LocaleController.formatPluralString("TranscriptionTrialLeftUntil", TranscribeButton.getTranscribeTrialCount(((BaseFragment) ChatActivity.this).currentAccount), new Object[]{LocaleController.formatDateTime(ChatActivity.this.getMessagesController().transcribeAudioTrialCooldownUntil, true)})) : AndroidUtilities.replaceTags(LocaleController.formatPluralString("TranscriptionTrialLeft", TranscribeButton.getTranscribeTrialCount(((BaseFragment) ChatActivity.this).currentAccount), new Object[0])), 6).show(true);
                    ((BaseFragment) ChatActivity.this).fragmentView.performHapticFeedback(3, 2);
                }
            } catch (Exception unused) {
            }
        }

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

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

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

        @Override
        public void didLongPressBotButton(ChatMessageCell cell, TLRPC.KeyboardButton button) {
            String str;
            if (ChatActivity.this.getParentActivity() == null || (str = button.url) == null) {
                ChatActivity.this.createMenu(cell, false, false, 0.0f, 0.0f, false);
            } else {
                ChatActivity.this.showCopyOpenShareDialog(str, true);
            }
        }

        @Override
        public void didPressReaction(final org.telegram.ui.Cells.ChatMessageCell r20, final org.telegram.tgnet.TLRPC.ReactionCount r21, boolean r22) {
            throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.ChatMessageCellDelegate.didPressReaction(org.telegram.ui.Cells.ChatMessageCell, org.telegram.tgnet.TLRPC$ReactionCount, boolean):void");
        }

        public void lambda$didPressReaction$11(TLRPC.ReactionCount reactionCount, View view) {
            ChatActivity.this.closeMenu();
            SearchTagsList.openRenameTagAlert(ChatActivity.this.getContext(), ((BaseFragment) ChatActivity.this).currentAccount, reactionCount.reaction, ChatActivity.this.themeDelegate, false);
        }

        public void lambda$didPressReaction$12(TLRPC.ReactionCount reactionCount, View view) {
            ChatActivity.this.closeMenu();
            ChatActivity.this.lambda$openSearchWithText$363("");
            SearchTagsList searchTagsList = ChatActivity.this.actionBarSearchTags;
            if (searchTagsList != null) {
                searchTagsList.setChosen(ReactionsLayoutInBubble.VisibleReaction.fromTL(reactionCount.reaction), true);
            }
        }

        public void lambda$didPressReaction$13(ChatMessageCell chatMessageCell, TLRPC.ReactionCount reactionCount, View view) {
            pressedReaction(chatMessageCell, reactionCount);
        }

        public void lambda$didPressReaction$14(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$didPressReaction$15(ChatMessageCell chatMessageCell, ReactedUsersListView reactedUsersListView, long j, TLRPC.MessagePeerReaction messagePeerReaction) {
            Bundle bundle = new Bundle();
            if (j > 0) {
                bundle.putLong("user_id", j);
            } else {
                bundle.putLong("chat_id", -j);
            }
            bundle.putInt("report_reaction_message_id", chatMessageCell.getMessageObject().getId());
            bundle.putLong("report_reaction_from_dialog_id", ChatActivity.this.dialog_id);
            ChatActivity.this.presentFragment(new ProfileActivity(bundle));
            ChatActivity.this.closeMenu();
        }

        public final void pressedReaction(ChatMessageCell cell, TLRPC.ReactionCount reaction) {
            TLRPC.Message message;
            ReactionsLayoutInBubble.VisibleReaction fromTL = ReactionsLayoutInBubble.VisibleReaction.fromTL(reaction.reaction);
            MessageObject primaryMessageObject = cell.getPrimaryMessageObject();
            ChatActivity.this.selectReaction(cell.getPrimaryMessageObject(), null, null, 0.0f, 0.0f, fromTL, false, false, false, false);
            if ((primaryMessageObject != null) & (primaryMessageObject.messageOwner != null)) {
                if (ChatActivity.this.chatAdapter.isFiltered) {
                    MessageObject messageObject = (MessageObject) ChatActivity.this.messagesDict[0].get(primaryMessageObject.getId());
                    if (messageObject != null && (message = messageObject.messageOwner) != null) {
                        message.reactions = primaryMessageObject.messageOwner.reactions;
                    }
                } else if (!ChatActivity.this.chatAdapter.isFiltered) {
                    ChatActivity chatActivity = ChatActivity.this;
                    if (chatActivity.searchingReaction != null) {
                        chatActivity.updateFilteredMessages(false);
                    }
                }
            }
            if (!ChatActivity.this.chatAdapter.isFiltered || cell.getPrimaryMessageObject().hasReaction(ChatActivity.this.searchingReaction)) {
                return;
            }
            MessageObject primaryMessageObject2 = cell.getPrimaryMessageObject();
            MessageObject.GroupedMessages validGroupedMessage = ChatActivity.this.getValidGroupedMessage(primaryMessageObject2);
            if (validGroupedMessage != null) {
                for (int i = 0; i < validGroupedMessage.messages.size(); i++) {
                    ChatActivity.this.getMediaDataController().removeMessageFromResults(((MessageObject) validGroupedMessage.messages.get(i)).getId());
                }
            } else {
                ChatActivity.this.getMediaDataController().removeMessageFromResults(primaryMessageObject2.getId());
            }
            if (ChatActivity.this.messagesSearchAdapter != null) {
                ChatActivity.this.messagesSearchAdapter.notifyDataSetChanged();
            }
            ChatActivity.this.updateFilteredMessages(true);
        }

        @Override
        public void didPressVoteButtons(ChatMessageCell cell, ArrayList<TLRPC.PollAnswer> buttons, int showCount, int x, int y) {
            int i;
            int i2;
            int i3;
            int i4;
            if (showCount >= 0 || buttons.isEmpty()) {
                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 (!buttons.isEmpty() || showCount >= 0) {
                    i = x;
                    i2 = y;
                } else {
                    ArrayList<ChatMessageCell.PollButton> pollButtons = cell.getPollButtons();
                    int size = pollButtons.size();
                    int i5 = 0;
                    float f = 0.0f;
                    while (true) {
                        if (i5 >= size) {
                            i3 = x;
                            i4 = y;
                            break;
                        }
                        ChatMessageCell.PollButton pollButton = pollButtons.get(i5);
                        float y2 = (cell.getY() + pollButton.y) - AndroidUtilities.dp(4.0f);
                        ChatActivity chatActivity3 = ChatActivity.this;
                        float f2 = y2 - chatActivity3.chatListViewPaddingTop;
                        chatActivity3.pollHintX = pollButton.x + AndroidUtilities.dp(13.3f);
                        ChatActivity.this.pollHintY = (pollButton.y - AndroidUtilities.dp(6.0f)) + y;
                        if (f2 > 0.0f) {
                            i3 = ChatActivity.this.pollHintX;
                            i4 = ChatActivity.this.pollHintY;
                            f = 0.0f;
                            break;
                        }
                        i5++;
                        f = f2;
                    }
                    if (f != 0.0f) {
                        ChatActivity.this.chatListView.smoothScrollBy(0, (int) f);
                        ChatActivity.this.pollHintCell = cell;
                        return;
                    } else {
                        i = i3;
                        i2 = i4;
                    }
                }
                ChatActivity.this.pollHintView.showForMessageCell(cell, Integer.valueOf(showCount), i, i2, true);
                return;
            }
            ChatActivity.this.getSendMessagesHelper().sendVote(cell.getMessageObject(), buttons, (Runnable) null);
        }

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

        @Override
        public void didLongPress(ChatMessageCell cell, float x, float y) {
            TLRPC.WebPage webPage;
            String str;
            if (ChatActivity.this.isInPreviewMode()) {
                return;
            }
            TLRPC.MessageMedia messageMedia = cell.getMessageObject().messageOwner.media;
            if (messageMedia != null && (webPage = messageMedia.webpage) != null && (str = webPage.url) != null && str.contains("/addtheme/")) {
                try {
                    String replace = Uri.parse(str).getPath().substring(10).replace("/", "");
                    if (!TextUtils.isEmpty(replace)) {
                        ChatActivity.this.showCopyOpenShareDialog(str, true, replace);
                        return;
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            ChatActivity.this.createMenu(cell, false, false, x, y, false);
            ChatActivity chatActivity = ChatActivity.this;
            chatActivity.startMultiselect(chatActivity.chatListView.getChildAdapterPosition(cell));
        }

        public void didLongPressUrl(MessageObject messageObject, final CharacterStyle url) {
            if (url == null || ChatActivity.this.getParentActivity() == null) {
                return;
            }
            if (PlusSettings.copyLinkOnLongClick) {
                AndroidUtilities.addToClipboard(((URLSpan) url).getURL());
                ChatActivity.this.createUndoView();
                ChatActivity.this.undoView.showWithAction(0L, 59, (Runnable) null);
                return;
            }
            ChatActivity.this.showCopyOpenShareDialog(((URLSpan) url).getURL(), true);
        }

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

        @Override
        public boolean didLongPressAvatar(ChatMessageCell cell, TLRPC.User user, float touchX, float touchY) {
            if (((BaseFragment) ChatActivity.this).actionBar.isActionModeShowed()) {
                ChatActivity.this.processRowSelect(cell, true, touchX, touchY);
                return true;
            }
            if (ChatActivity.this.isInPreviewMode()) {
                return true;
            }
            if (user != null) {
                return ChatActivity.this.createAvatarClickMenu(cell.getMessageObject().messageOwner.from_id.user_id, user);
            }
            return false;
        }

        @Override
        public boolean canPerformActions() {
            return ((BaseFragment) ChatActivity.this).actionBar != null && !((BaseFragment) ChatActivity.this).actionBar.isActionModeShowed() && ChatActivity.this.reportType < 0 && (!((BaseFragment) ChatActivity.this).inPreviewMode || PlusSettings.doNotClosePreviewOnRelease);
        }

        @Override
        public void didPressUrl(ChatMessageCell cell, final CharacterStyle url, boolean longPress) {
            if (longPress && (url instanceof URLSpan) && !(url instanceof URLSpanBotCommand)) {
                didLongPressUrl(cell.getMessageObject(), url);
            } else {
                ChatActivity.this.didPressMessageUrl(url, longPress, cell.getMessageObject(), cell);
            }
        }

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

        @Override
        public void didPressMoreChannelRecommendations(ChatMessageCell cell) {
            if (ChatActivity.this.getUserConfig().isPremium()) {
                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()));
                return;
            }
            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$16();
                }
            })).show();
        }

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

        @Override
        public void didPressChannelRecommendation(final ChatMessageCell cell, final TLRPC.Chat chat, boolean longPress) {
            if (ChatActivity.this.getContext() == null || chat == null) {
                return;
            }
            if (((BaseFragment) ChatActivity.this).parentLayout == null || !((BaseFragment) ChatActivity.this).parentLayout.isInPreviewMode()) {
                Bundle bundle = new Bundle();
                bundle.putLong("chat_id", chat.id);
                if (longPress) {
                    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$17(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$19(chat, cell, view);
                        }
                    });
                    actionBarPopupWindowLayout.addView(actionBarMenuSubItem2);
                    ChatActivity chatActivity = new ChatActivity(bundle);
                    chatActivity.allowExpandPreviewByClick = true;
                    ChatActivity.this.presentFragmentAsPreviewWithMenu(chatActivity, actionBarPopupWindowLayout);
                    ChatActivity.this.checkShowBlur(true);
                    return;
                }
                ChatActivity.this.presentFragment(new ChatActivity(bundle));
            }
        }

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

        public void lambda$didPressChannelRecommendation$19(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$18(chat);
                }
            });
        }

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

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

        @Override
        public boolean didPressAnimatedEmoji(ChatMessageCell cell, AnimatedEmojiSpan span) {
            Bulletin createContainsEmojiBulletin;
            if (!ChatActivity.this.getMessagesController().premiumFeaturesBlocked() && span != null && !span.standard) {
                long documentId = span.getDocumentId();
                TLRPC.Document document = span.document;
                if (document == null) {
                    document = AnimatedEmojiDrawable.findDocument(((BaseFragment) ChatActivity.this).currentAccount, documentId);
                }
                if (document != null && (createContainsEmojiBulletin = BulletinFactory.of(ChatActivity.this).createContainsEmojiBulletin(document, 0, new Utilities.Callback() {
                    public final void run(Object obj) {
                        ChatActivity.ChatMessageCellDelegate.this.lambda$didPressAnimatedEmoji$20((TLRPC.InputStickerSet) obj);
                    }
                })) != null) {
                    createContainsEmojiBulletin.show();
                    return true;
                }
            }
            return false;
        }

        public void lambda$didPressAnimatedEmoji$20(TLRPC.InputStickerSet inputStickerSet) {
            ArrayList arrayList = new ArrayList(1);
            arrayList.add(inputStickerSet);
            ChatActivity chatActivity = ChatActivity.this;
            EmojiPacksAlert emojiPacksAlert = new EmojiPacksAlert(chatActivity, chatActivity.getParentActivity(), ChatActivity.this.themeDelegate, arrayList);
            emojiPacksAlert.setCalcMandatoryInsets(ChatActivity.this.isKeyboardVisible());
            ChatActivity.this.showDialog(emojiPacksAlert);
        }

        @Override
        public void didPressTopicButton(ChatMessageCell cell) {
            TLRPC.TL_forumTopic findTopic;
            MessageObject messageObject = cell.getMessageObject();
            if (messageObject != null) {
                long topicId = MessageObject.getTopicId(messageObject.currentAccount, messageObject.messageOwner, true);
                if (topicId == 0 || (findTopic = ChatActivity.this.getMessagesController().getTopicsController().findTopic(ChatActivity.this.currentChat.id, topicId)) == null) {
                    return;
                }
                ChatActivity chatActivity = ChatActivity.this;
                ForumUtilities.openTopic(chatActivity, chatActivity.currentChat.id, findTopic, messageObject.getId());
            }
        }

        @Override
        public boolean shouldShowTopicButton(ChatMessageCell cell) {
            return ChatObject.isForum(ChatActivity.this.currentChat) && !ChatActivity.this.isTopic;
        }

        @Override
        public void didPressDialogButton(ChatMessageCell cell) {
            ChatActivity.this.openMessageInOriginalDialog(cell.getMessageObject());
        }

        @Override
        public boolean shouldShowDialogButton(ChatMessageCell cell) {
            return ChatActivity.this.chatMode == 7 && ChatActivity.this.searchType == 1;
        }

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

        @Override
        public void needOpenWebView(MessageObject message, String url, String title, String description, String originalUrl, int w, int h) {
            try {
                ChatActivity chatActivity = ChatActivity.this;
                EmbedBottomSheet.show(chatActivity, message, chatActivity.photoViewerProvider, title, description, originalUrl, url, w, h, ChatActivity.this.isKeyboardVisible());
            } catch (Throwable th) {
                FileLog.e(th);
            }
        }

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

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

            public AnonymousClass6(final ChatMessageCell val$cell) {
                this.val$cell = val$cell;
            }

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

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

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

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

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

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

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

        public void lambda$didPressReplyMessage$22(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$21(messageObject);
                }
            });
        }

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

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

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

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

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

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

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

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

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

        @Override
        public void didPressImage(org.telegram.ui.Cells.ChatMessageCell r13, float r14, float r15) {
            throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.ChatMessageCellDelegate.didPressImage(org.telegram.ui.Cells.ChatMessageCell, float, float):void");
        }

        public void lambda$didPressImage$23(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);
            }
        }

        @Override
        public void didPressInstantButton(ChatMessageCell chatMessageCell, int i) {
            TLRPC.MessageMedia messageMedia;
            TLRPC.TL_webPageAttributeStory tL_webPageAttributeStory;
            TL_stories.StoryItem storyItem;
            TLRPC.Message message;
            TLRPC.MessageMedia messageMedia2;
            Browser.Progress user;
            String string;
            TLRPC.WebPage webPage;
            if (ChatActivity.this.isInPreviewMode()) {
                return;
            }
            MessageObject messageObject = chatMessageCell.getMessageObject();
            if (i == 19) {
                if (ChatActivity.this.progressDialogCurrent != null) {
                    ChatActivity.this.progressDialogCurrent.cancel(true);
                }
                ChatActivity.this.progressDialogCurrent = chatMessageCell.getMessageObject() != null ? new AnonymousClass10(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 AnonymousClass11(chatMessageCell) : null;
                        LaunchActivity.instance.checkAppUpdate(true, ChatActivity.this.progressDialogCurrent);
                        return;
                    }
                    return;
                }
                if (BuildVars.isHuaweiStoreApp()) {
                    Browser.openUrl(ChatActivity.this.getContext(), BuildVars.HUAWEI_STORE_URL);
                    return;
                } else {
                    Browser.openUrl(ChatActivity.this.getContext(), BuildVars.PLAYSTORE_APP_URL);
                    return;
                }
            }
            if (i == 8) {
                PollVotesAlert.showForPoll(ChatActivity.this, messageObject);
                return;
            }
            if (i == 0) {
                TLRPC.MessageMedia messageMedia3 = messageObject.messageOwner.media;
                if (messageMedia3 == null || (webPage = messageMedia3.webpage) == null || webPage.cached_page == null) {
                    return;
                }
                ArticleViewer.getInstance().setParentActivity(ChatActivity.this.getParentActivity(), ChatActivity.this);
                ArticleViewer.getInstance().open(messageObject);
                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)) {
                        string = messageObject.vCardData.toString();
                    } else if (!TextUtils.isEmpty(((TLRPC.User) user).phone)) {
                        string = PhoneFormat.getInstance().format("+" + ((TLRPC.User) user).phone);
                    } else {
                        String str = MessageObject.getMedia(messageObject.messageOwner).phone_number;
                        if (!TextUtils.isEmpty(str)) {
                            string = PhoneFormat.getInstance().format(str);
                        } else {
                            string = LocaleController.getString("NumberUnknown", R.string.NumberUnknown);
                        }
                    }
                    Bundle bundle2 = new Bundle();
                    bundle2.putLong("user_id", ((TLRPC.User) user).id);
                    bundle2.putString("phone", string);
                    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;
                TLRPC.WebPage webPage2 = (message2 == null || (messageMedia = message2.media) == null) ? null : messageMedia.webpage;
                if (webPage2 == null || webPage2.url == null) {
                    return;
                }
                Matcher matcher = Pattern.compile("^https?\\:\\/\\/t\\.me\\/add(?:emoji|stickers)\\/(.+)$").matcher(webPage2.url);
                if (ChatActivity.this.progressDialogCurrent != null) {
                    ChatActivity.this.progressDialogCurrent.cancel(true);
                }
                ChatActivity.this.progressDialogCurrent = chatMessageCell.getMessageObject() != null ? new AnonymousClass12(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$25(z, tLObject, tL_error);
                            }
                        });
                        ChatActivity.this.progressDialogCurrent.onCancel(new Runnable() {
                            @Override
                            public final void run() {
                                ChatActivity.ChatMessageCellDelegate.this.lambda$didPressInstantButton$26(sendRequest);
                            }
                        });
                        return;
                    }
                }
                Browser.openUrl(ChatActivity.this.getParentActivity(), Uri.parse(webPage2.url), true, true, false, ChatActivity.this.progressDialogCurrent);
                return;
            }
            if (messageObject.isSponsored()) {
                ChatActivity.this.logSponsoredClicked(messageObject);
                new Bundle();
                if (messageObject.sponsoredUrl != null) {
                    if (ChatActivity.this.progressDialogCurrent != null) {
                        ChatActivity.this.progressDialogCurrent.cancel(true);
                    }
                    ChatActivity.this.progressDialogCurrent = chatMessageCell.getMessageObject() != null ? new AnonymousClass13(chatMessageCell) : null;
                    Browser.openUrl(ChatActivity.this.getContext(), Uri.parse(messageObject.sponsoredUrl), true, false, false, ChatActivity.this.progressDialogCurrent);
                    return;
                }
                return;
            }
            TLRPC.WebPage storyMentionWebpage = messageObject.getStoryMentionWebpage();
            if (storyMentionWebpage == null && (message = messageObject.messageOwner) != null && (messageMedia2 = message.media) != null) {
                storyMentionWebpage = messageMedia2.webpage;
            }
            if (storyMentionWebpage == null) {
                return;
            }
            if (storyMentionWebpage.attributes != null) {
                for (int i2 = 0; i2 < storyMentionWebpage.attributes.size(); i2++) {
                    if ((storyMentionWebpage.attributes.get(i2) instanceof TLRPC.TL_webPageAttributeStory) && (storyItem = (tL_webPageAttributeStory = (TLRPC.TL_webPageAttributeStory) storyMentionWebpage.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(storyMentionWebpage.url, chatMessageCell, null, messageObject.getId(), 2)) {
                return;
            }
            if (ChatActivity.this.progressDialogCurrent != null) {
                ChatActivity.this.progressDialogCurrent.cancel(true);
            }
            ChatActivity.this.progressDialogCurrent = chatMessageCell.getMessageObject() != null ? new AnonymousClass14(chatMessageCell) : null;
            Browser.openUrl(ChatActivity.this.getParentActivity(), Uri.parse(storyMentionWebpage.url), true, true, false, ChatActivity.this.progressDialogCurrent);
        }

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

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

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

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

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

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

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

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

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

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

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

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

        public void lambda$didPressInstantButton$25(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$24(tLObject, z);
                }
            });
        }

        public void lambda$didPressInstantButton$24(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) {
                ArrayList arrayList = new ArrayList(1);
                arrayList.add(tL_inputStickerSetID);
                ChatActivity chatActivity = ChatActivity.this;
                EmojiPacksAlert emojiPacksAlert = new EmojiPacksAlert(chatActivity, chatActivity.getParentActivity(), ChatActivity.this.themeDelegate, arrayList);
                emojiPacksAlert.setCalcMandatoryInsets(ChatActivity.this.isKeyboardVisible());
                ChatActivity.this.showDialog(emojiPacksAlert);
                return;
            }
            Activity parentActivity = ChatActivity.this.getParentActivity();
            ChatActivity chatActivity2 = ChatActivity.this;
            StickersAlert stickersAlert = new StickersAlert(parentActivity, chatActivity2, tL_inputStickerSetID, (TLRPC.TL_messages_stickerSet) null, chatActivity2.chatActivityEnterView, chatActivity2.themeDelegate);
            stickersAlert.setCalcMandatoryInsets(ChatActivity.this.isKeyboardVisible());
            ChatActivity.this.showDialog(stickersAlert);
        }

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

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

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

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

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

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

            public AnonymousClass14(final ChatMessageCell val$cell) {
                this.val$cell = val$cell;
            }

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

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

        @Override
        public void didPressGiveawayChatButton(ChatMessageCell cell, int pressedPos) {
            if (cell.getMessageObject().messageOwner.media instanceof TLRPC.TL_messageMediaGiveaway) {
                long j = -((Long) cell.getMessageObject().messageOwner.media.channels.get(pressedPos)).longValue();
                if (ChatActivity.this.dialog_id != j) {
                    ChatActivity.this.presentFragment(ChatActivity.of(j));
                } else {
                    AndroidUtilities.shakeViewSpring(ChatActivity.this.getChatListView(), 5.0f);
                    BotWebViewVibrationEffect.APP_ERROR.vibrate();
                }
            }
            if (cell.getMessageObject().messageOwner.media instanceof TLRPC.TL_messageMediaGiveawayResults) {
                ChatActivity.this.presentFragment(ProfileActivity.of(((Long) cell.getMessageObject().messageOwner.media.winners.get(pressedPos)).longValue()));
            }
        }

        @Override
        public void didPressCommentButton(ChatMessageCell cell) {
            MessageObject messageObject;
            long j;
            int i;
            MessageObject.GroupedMessages currentMessagesGroup = cell.getCurrentMessagesGroup();
            if (currentMessagesGroup != null && !currentMessagesGroup.messages.isEmpty()) {
                messageObject = (MessageObject) currentMessagesGroup.messages.get(0);
            } else {
                messageObject = cell.getMessageObject();
            }
            MessageObject messageObject2 = messageObject;
            TLRPC.MessageReplies messageReplies = messageObject2.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, messageObject2, messageObject2.getId(), j, i, 0, null);
        }

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

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

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

        @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 onDiceFinished() {
            if (ChatActivity.this.fireworksOverlay.isStarted()) {
                return;
            }
            ChatActivity.this.fireworksOverlay.start();
            if (PlusSettings.disableActionsVibrations) {
                return;
            }
            ChatActivity.this.fireworksOverlay.performHapticFeedback(3, 2);
        }

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

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

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

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

        @Override
        public boolean onAccessibilityAction(int action, Bundle arguments) {
            if (action != 16 && action != R.id.acc_action_small_button && action != 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 boolean doNotShowLoadingReply(MessageObject msg) {
            return ((msg != null && msg.getDialogId() == 1271266957) || (ChatActivity.this.chatAdapter != null && ChatActivity.this.chatAdapter.isFiltered)) && ChatActivity.this.chatMode != 7;
        }

        @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, ((BaseFragment) chatActivity2).resourceProvider);
        }
    }

    public static class AnonymousClass180 {
        public 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.OPEN_GROUP.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                $SwitchMap$org$telegram$ui$AvatarPreviewer$MenuItem[AvatarPreviewer.MenuItem.OPEN_CHANNEL.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                $SwitchMap$org$telegram$ui$AvatarPreviewer$MenuItem[AvatarPreviewer.MenuItem.SHOW_MESSAGES.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            try {
                $SwitchMap$org$telegram$ui$AvatarPreviewer$MenuItem[AvatarPreviewer.MenuItem.SHOW_MEDIA.ordinal()] = 5;
            } catch (NoSuchFieldError unused5) {
            }
            try {
                $SwitchMap$org$telegram$ui$AvatarPreviewer$MenuItem[AvatarPreviewer.MenuItem.MENTION.ordinal()] = 6;
            } catch (NoSuchFieldError unused6) {
            }
            try {
                $SwitchMap$org$telegram$ui$AvatarPreviewer$MenuItem[AvatarPreviewer.MenuItem.EDIT_ADMIN.ordinal()] = 7;
            } catch (NoSuchFieldError unused7) {
            }
            try {
                $SwitchMap$org$telegram$ui$AvatarPreviewer$MenuItem[AvatarPreviewer.MenuItem.PROMOTE_ADMIN.ordinal()] = 8;
            } catch (NoSuchFieldError unused8) {
            }
            try {
                $SwitchMap$org$telegram$ui$AvatarPreviewer$MenuItem[AvatarPreviewer.MenuItem.PERMISSIONS.ordinal()] = 9;
            } catch (NoSuchFieldError unused9) {
            }
            try {
                $SwitchMap$org$telegram$ui$AvatarPreviewer$MenuItem[AvatarPreviewer.MenuItem.KICK.ordinal()] = 10;
            } catch (NoSuchFieldError unused10) {
            }
            try {
                $SwitchMap$org$telegram$ui$AvatarPreviewer$MenuItem[AvatarPreviewer.MenuItem.SEND_MESSAGE.ordinal()] = 11;
            } catch (NoSuchFieldError unused11) {
            }
            try {
                $SwitchMap$org$telegram$ui$AvatarPreviewer$MenuItem[AvatarPreviewer.MenuItem.SEARCH_MESSAGES.ordinal()] = 12;
            } catch (NoSuchFieldError unused12) {
            }
        }
    }

    public final boolean createAvatarClickMenu(final long fromId, final TLRPC.User user) {
        final TLRPC.ChannelParticipant channelParticipant;
        final TLRPC.ChatParticipant chatParticipant;
        boolean z;
        boolean z2;
        boolean z3;
        boolean z4;
        boolean z5;
        int i;
        String str;
        if (getParentActivity() == null) {
            return false;
        }
        String firstName = UserObject.getFirstName(user);
        if (user.username != null) {
            firstName = firstName + "\n@" + user.username;
        }
        final String str2 = firstName;
        ArrayList arrayList = new ArrayList();
        ArrayList arrayList2 = new ArrayList();
        final ArrayList arrayList3 = new ArrayList();
        TLRPC.ChatFull chatFull = this.chatInfo;
        if (chatFull != null && chatFull.participants != null) {
            TLRPC.ChatParticipant chatParticipant2 = null;
            int i2 = 0;
            while (true) {
                if (i2 >= this.chatInfo.participants.participants.size()) {
                    chatParticipant = chatParticipant2;
                    z = false;
                    z3 = false;
                    z4 = false;
                    channelParticipant = null;
                    z2 = false;
                    break;
                }
                chatParticipant2 = (TLRPC.ChatParticipant) this.chatInfo.participants.participants.get(i2);
                if (chatParticipant2.user_id != user.id) {
                    i2++;
                } else if (ChatObject.isChannel(this.currentChat)) {
                    TLRPC.ChannelParticipant channelParticipant2 = ((TLRPC.TL_chatChannelParticipant) chatParticipant2).channelParticipant;
                    z2 = ChatObject.canAddAdmins(this.currentChat);
                    z4 = channelParticipant2 instanceof TLRPC.TL_channelParticipantAdmin;
                    z3 = ChatObject.canBlockUsers(this.currentChat) && (!((channelParticipant2 instanceof TLRPC.TL_channelParticipantAdmin) || (channelParticipant2 instanceof TLRPC.TL_channelParticipantCreator)) || channelParticipant2.can_edit);
                    chatParticipant = chatParticipant2;
                    channelParticipant = channelParticipant2;
                    z = z3;
                } else {
                    TLRPC.Chat chat = this.currentChat;
                    boolean z6 = chat.creator || ((chatParticipant2 instanceof TLRPC.TL_chatParticipant) && (ChatObject.canBlockUsers(chat) || chatParticipant2.inviter_id == getUserConfig().getClientUserId()));
                    z4 = chatParticipant2 instanceof TLRPC.TL_chatParticipantAdmin;
                    z3 = this.currentChat.creator;
                    z = z6;
                    chatParticipant = chatParticipant2;
                    channelParticipant = null;
                    z2 = z3;
                }
            }
        } else {
            channelParticipant = null;
            chatParticipant = null;
            z = false;
            z2 = false;
            z3 = false;
            z4 = false;
        }
        if (this.onlyId == 0 && this.onlyIdMedia == 0) {
            arrayList.add(LocaleController.getString("ShowUserMessages", R.string.ShowUserMessages));
            arrayList2.add(Integer.valueOf(R.drawable.msg_msgbubble2));
            arrayList3.add(3);
            arrayList.add(LocaleController.getString("ShowUserMedia", R.string.ShowUserMedia));
            arrayList2.add(Integer.valueOf(R.drawable.files_gallery));
            arrayList3.add(4);
        }
        if (z2) {
            if (z4) {
                i = R.string.EditAdminRights;
                str = "EditAdminRights";
            } else {
                i = R.string.SetAsAdmin;
                str = "SetAsAdmin";
            }
            arrayList.add(LocaleController.getString(str, i));
            arrayList2.add(Integer.valueOf(R.drawable.actions_addadmin));
            arrayList3.add(0);
        }
        if (z3) {
            arrayList.add(LocaleController.getString("ChangePermissions", R.string.ChangePermissions));
            arrayList2.add(Integer.valueOf(R.drawable.actions_permissions));
            arrayList3.add(1);
        }
        if (z) {
            arrayList.add(LocaleController.getString("KickFromGroup", R.string.KickFromGroup));
            arrayList2.add(Integer.valueOf(R.drawable.actions_remove_user));
            arrayList3.add(2);
            z5 = true;
        } else {
            z5 = false;
        }
        arrayList.add(LocaleController.getString("Mention", R.string.Mention));
        arrayList2.add(Integer.valueOf(R.drawable.msg_mention));
        arrayList3.add(5);
        if (arrayList.isEmpty()) {
            return false;
        }
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
        builder.setTitle(str2);
        builder.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public final boolean onLongClick(View view) {
                boolean lambda$createAvatarClickMenu$394;
                lambda$createAvatarClickMenu$394 = ChatActivity.this.lambda$createAvatarClickMenu$394(arrayList3, user, view);
                return lambda$createAvatarClickMenu$394;
            }
        });
        boolean z7 = z5;
        final boolean z8 = z4;
        builder.setItems((CharSequence[]) arrayList.toArray(new CharSequence[0]), AndroidUtilities.toIntArray(arrayList2), new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i3) {
                ChatActivity.this.lambda$createAvatarClickMenu$397(arrayList3, str2, user, fromId, channelParticipant, chatParticipant, z8, dialogInterface, i3);
            }
        });
        AlertDialog create = builder.create();
        showDialog(create);
        if (!z7) {
            return true;
        }
        create.setItemColor(arrayList3.indexOf(2), Theme.getColor(Theme.key_text_RedBold), Theme.getColor(Theme.key_text_RedRegular));
        return true;
    }

    public boolean lambda$createAvatarClickMenu$394(ArrayList arrayList, TLRPC.User user, View view) {
        if (((Integer) arrayList.get(((Integer) view.getTag()).intValue())).intValue() != 5) {
            return false;
        }
        SpannableString spannableString = new SpannableString(UserObject.getFirstName(user, false) + " ");
        spannableString.setSpan(new URLSpanUserMention("" + user.id, 3), 0, spannableString.length(), 33);
        this.chatActivityEnterView.setFieldText(spannableString);
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$createAvatarClickMenu$393();
            }
        }, 200L);
        return true;
    }

    public void lambda$createAvatarClickMenu$393() {
        this.chatActivityEnterView.openKeyboard();
    }

    public void lambda$createAvatarClickMenu$397(java.util.ArrayList r15, java.lang.String r16, final org.telegram.tgnet.TLRPC.User r17, long r18, final org.telegram.tgnet.TLRPC.ChannelParticipant r20, final org.telegram.tgnet.TLRPC.ChatParticipant r21, final boolean r22, android.content.DialogInterface r23, int r24) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.lambda$createAvatarClickMenu$397(java.util.ArrayList, java.lang.String, org.telegram.tgnet.TLRPC$User, long, org.telegram.tgnet.TLRPC$ChannelParticipant, org.telegram.tgnet.TLRPC$ChatParticipant, boolean, android.content.DialogInterface, int):void");
    }

    public void lambda$createAvatarClickMenu$395(TLRPC.User user, DialogInterface dialogInterface, int i) {
        kickUser(user);
    }

    public void lambda$createAvatarClickMenu$396(int i, TLRPC.User user, TLRPC.ChatParticipant chatParticipant, TLRPC.ChannelParticipant channelParticipant, boolean z, DialogInterface dialogInterface, int i2) {
        openRightsEdit(i, user, chatParticipant, channelParticipant != null ? channelParticipant.admin_rights : null, channelParticipant != null ? channelParticipant.banned_rights : null, channelParticipant != null ? channelParticipant.rank : "", z);
    }

    public final void kickUser(final TLRPC.User user) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
        builder.setMessage(LocaleController.getString("KickFromGroup", R.string.KickFromGroup) + '\n' + LocaleController.getString("AreYouSure", R.string.AreYouSure));
        builder.setTitle(UserObject.getFirstName(user));
        builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                try {
                    ChatActivity.this.getMessagesController().deleteParticipantFromChat(ChatActivity.this.chat_id, user);
                    TLRPC.ChatFull chatFull = ChatActivity.this.chatInfo;
                    boolean z = false;
                    if (chatFull != null && chatFull.participants != null) {
                        int i2 = 0;
                        while (true) {
                            if (i2 >= ChatActivity.this.chatInfo.participants.participants.size()) {
                                break;
                            }
                            if (((TLRPC.ChatParticipant) ChatActivity.this.chatInfo.participants.participants.get(i2)).user_id == user.id) {
                                ChatActivity.this.chatInfo.participants.participants.remove(i2);
                                z = true;
                                break;
                            }
                            i2++;
                        }
                    }
                    if (z) {
                        ChatActivity.this.chatAdapter.notifyDataSetChanged();
                    }
                } catch (Exception e) {
                    FileLog.e("tmessages", e);
                }
            }
        });
        builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
        showDialog(builder.create());
    }

    public final void showUserMsgs(long id) {
        Bundle bundle = new Bundle();
        if (DialogObject.isUserDialog(this.dialog_id)) {
            bundle.putLong("user_id", this.dialog_id);
        } else {
            bundle.putLong("chat_id", -this.dialog_id);
        }
        if (!PlusSettings.useOldShowUserMessagesMethod) {
            bundle.putLong(DialogObject.isUserDialog(id) ? "search_from_user_id" : "search_from_chat_id", id);
        }
        bundle.putLong("only_id", id);
        long j = this.onlyIdMedia;
        if (j > 0) {
            bundle.putLong("only_id_media", j);
        }
        presentFragment(new ChatActivity(bundle));
    }

    public final void showUserMedia(long id) {
        Bundle bundle = new Bundle();
        if (DialogObject.isUserDialog(this.dialog_id)) {
            bundle.putLong("user_id", this.dialog_id);
        } else {
            bundle.putLong("chat_id", -this.dialog_id);
        }
        boolean z = PlusSettings.useOldShowUserMessagesMethod;
        long j = this.onlyId;
        if (j > 0) {
            bundle.putLong("only_id", j);
        }
        bundle.putLong("only_id_media", id);
        presentFragment(new ChatActivity(bundle));
    }

    public final void openUserProfile(long uid) {
        if (isInPreviewMode()) {
            return;
        }
        if (uid < 0) {
            Bundle bundle = new Bundle();
            bundle.putLong("chat_id", -uid);
            if (getMessagesController().checkCanOpenChat(bundle, this)) {
                presentFragment(new ChatActivity(bundle));
                return;
            }
            return;
        }
        if (uid != getUserConfig().getClientUserId()) {
            Bundle bundle2 = new Bundle();
            bundle2.putLong("user_id", uid);
            if (this.currentEncryptedChat != null && uid == this.currentUser.id) {
                bundle2.putLong("dialog_id", this.dialog_id);
            }
            if (UserObject.isUserSelf(this.currentUser)) {
                bundle2.putBoolean("my_profile", true);
            }
            ProfileActivity profileActivity = new ProfileActivity(bundle2);
            TLRPC.User user = this.currentUser;
            profileActivity.setPlayProfileAnimation((user == null || user.id != uid) ? 0 : 1);
            presentFragment(profileActivity);
        }
    }

    public final boolean openLinkInternally(String urlFinal, ChatMessageCell cell, CharacterStyle span, int fromMessageId) {
        return openLinkInternally(urlFinal, cell, span, fromMessageId, 1);
    }

    public final boolean openLinkInternally(String urlFinal, final ChatMessageCell cell, final CharacterStyle span, final int fromMessageId, final int fromMessageProgressType) {
        TLRPC.TL_forumTopic findTopic;
        int parseInt;
        int i;
        if (this.currentChat != null && urlFinal != null) {
            Runnable runnable = (cell == null || (span == null && fromMessageProgressType == 1)) ? null : new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$openLinkInternally$398(fromMessageId, fromMessageProgressType, span, cell);
                }
            };
            if (urlFinal.startsWith("tg:privatepost") || urlFinal.startsWith("tg://privatepost")) {
                Uri parse = Uri.parse(urlFinal.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$358();
                        } else {
                            scrollToMessageId(intValue, fromMessageId, true, 0, false, 0, runnable);
                        }
                    }
                    return true;
                }
            } else if (ChatObject.getPublicUsername(this.currentChat) != null) {
                try {
                    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(urlFinal);
                    if (matcher.find(2) && matcher.find(3) && ChatObject.hasPublicLink(this.currentChat, matcher.group(2))) {
                        Uri parse2 = Uri.parse(urlFinal);
                        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) {
                                i = Integer.parseInt(matcher.group(3));
                                parseInt = Integer.parseInt(matcher.group(4));
                            } else {
                                parseInt = Integer.parseInt(matcher.group(3));
                                i = 0;
                            }
                            if (ChatObject.isForum(this.currentChat) && i != getTopicId()) {
                                return false;
                            }
                            this.showScrollToMessageError = true;
                            if (this.chatMode == 2) {
                                this.chatActivityDelegate.openReplyMessage(parseInt);
                                lambda$onBackPressed$358();
                            } else {
                                int timestampFromLink = LaunchActivity.getTimestampFromLink(parse2);
                                this.startFromVideoTimestamp = timestampFromLink;
                                if (timestampFromLink >= 0) {
                                    this.startFromVideoMessageId = parseInt;
                                }
                                scrollToMessageId(parseInt, fromMessageId, true, 0, false, 0, runnable);
                            }
                            return true;
                        }
                        return false;
                    }
                    if (!urlFinal.startsWith("tg:resolve") && !urlFinal.startsWith("tg://resolve")) {
                        Matcher matcher2 = voiceChatUrlPattern.matcher(urlFinal);
                        try {
                            if (matcher2.find(2) && matcher2.find(3) && ChatObject.hasPublicLink(this.currentChat, matcher2.group(2))) {
                                String queryParameter = Uri.parse(urlFinal).getQueryParameter("voicechat");
                                if (!TextUtils.isEmpty(queryParameter)) {
                                    this.voiceChatHash = queryParameter;
                                    checkGroupCallJoin(true);
                                    return true;
                                }
                            }
                        } catch (Exception e) {
                            FileLog.e(e);
                        }
                    }
                    Uri parse3 = Uri.parse(urlFinal.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$358();
                        } else {
                            scrollToMessageId(intValue5, fromMessageId, true, 0, false, 0, runnable);
                        }
                        return true;
                    }
                    return false;
                } catch (Exception e2) {
                    FileLog.e(e2);
                }
            } else {
                try {
                    if (privateMsgUrlPattern == null) {
                        privateMsgUrlPattern = Pattern.compile("(https://)?t.me/c/([0-9]+)/([0-9]+)/?([0-9]+)?");
                    }
                    Matcher matcher3 = privateMsgUrlPattern.matcher(urlFinal);
                    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(urlFinal);
                            int intValue8 = Utilities.parseInt(parse4.getQueryParameter("thread")).intValue();
                            int intValue9 = Utilities.parseInt(parse4.getQueryParameter("topic")).intValue();
                            int intValue10 = Utilities.parseInt(parse4.getQueryParameter("comment")).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$358();
                                } else {
                                    scrollToMessageId(parseInt2, fromMessageId, true, 0, false, 0, runnable);
                                }
                                return true;
                            }
                            return false;
                        }
                    }
                } catch (Exception e3) {
                    FileLog.e(e3);
                }
            }
        }
        return false;
    }

    public void lambda$openLinkInternally$398(int i, int i2, CharacterStyle characterStyle, ChatMessageCell chatMessageCell) {
        this.progressDialogAtMessageId = i;
        this.progressDialogAtMessageType = i2;
        this.progressDialogLinkSpan = characterStyle;
        chatMessageCell.invalidate();
    }

    public void setInMenuMode(boolean value) {
        super.setInMenuMode(value);
        ActionBar actionBar = ((BaseFragment) this).actionBar;
        if (actionBar != null) {
            actionBar.createMenu().setVisibility(((BaseFragment) this).inMenuMode ? 8 : 0);
        }
    }

    public void setPreloadedSticker(TLRPC.Document preloadedSticker, boolean historyEmpty) {
        this.preloadedGreetingsSticker = preloadedSticker;
        this.forceHistoryEmpty = historyEmpty;
    }

    public void forceEmptyHistory() {
        this.forceHistoryEmpty = true;
    }

    public void setQuoteMessage(boolean quote) {
        QuoteForward = quote;
    }

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

        public ChatScrollCallback() {
        }

        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 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 lambda$onEndAnimation$0() {
            ChatActivity.this.getNotificationCenter().onAnimationFinish(ChatActivity.this.scrollCallbackAnimationIndex);
        }

        public void recycleView(View view) {
            if (view instanceof ChatMessageCell) {
                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) view);
            }
        }
    }

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

    public SimpleTextView getReplyNameTextView() {
        return this.replyNameTextView;
    }

    public SimpleTextView getReplyObjectTextView() {
        return this.replyObjectTextView;
    }

    public final void appendMention(TLRPC.User user) {
        if (this.chatActivityEnterView != null) {
            SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
            CharSequence fieldText = this.chatActivityEnterView.getFieldText();
            if (fieldText != null) {
                spannableStringBuilder.append(fieldText);
            }
            if (spannableStringBuilder.length() > 0 && spannableStringBuilder.charAt(spannableStringBuilder.length() - 1) != ' ') {
                spannableStringBuilder.append(' ');
            }
            if (user.username != null) {
                spannableStringBuilder.append((CharSequence) "@").append((CharSequence) user.username).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);
            }
            this.chatActivityEnterView.setFieldText(spannableStringBuilder);
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$appendMention$399();
                }
            }, 200L);
        }
    }

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

    public final void restoreSettings(org.telegram.messenger.MessageObject r6) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.restoreSettings(org.telegram.messenger.MessageObject):void");
    }

    public void lambda$restoreSettings$400() {
        Toast.makeText(getParentActivity(), "NULL", 0).show();
    }

    public class AnonymousClass173 implements PlusUtils.restoreAsyncTask.RestoreAsyncTaskDelegate {
        public AnonymousClass173() {
        }

        public void onRestart() {
            ChatActivity.this.showRestartDialog();
        }

        public void onError(final String error) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.AnonymousClass173.this.lambda$onError$0(error);
                }
            });
        }

        public void lambda$onError$0(String str) {
            Toast.makeText(ChatActivity.this.getParentActivity(), str, 0).show();
        }
    }

    public void lambda$restoreSettings$401(File file, DialogInterface dialogInterface, int i) {
        new PlusUtils.restoreAsyncTask(new AnonymousClass173()).execute(file);
    }

    public final void showCopyOpenShareDialog(final String urlFinal, boolean showShare) {
        String str;
        if (urlFinal.contains("/addtheme/")) {
            try {
                str = Uri.parse(urlFinal).getPath().substring(10).replace("/", "");
            } catch (Exception e) {
                e.printStackTrace();
            }
            showCopyOpenShareDialog(urlFinal, showShare, str);
        }
        str = null;
        showCopyOpenShareDialog(urlFinal, showShare, str);
    }

    public final void showCopyOpenShareDialog(final String urlFinal, boolean showShare, final String theme) {
        if (getParentActivity() == null) {
            return;
        }
        final boolean z = true;
        ArrayList arrayList = new ArrayList();
        arrayList.add(LocaleController.getString("Open", R.string.Open));
        arrayList.add(LocaleController.getString("Copy", R.string.Copy));
        if (showShare) {
            arrayList.add(LocaleController.getString("ShareFile", R.string.ShareFile));
        }
        if (!TextUtils.isEmpty(theme)) {
            arrayList.add(LocaleController.getString("ExportTheme", R.string.ExportTheme));
        }
        CharSequence[] charSequenceArr = (CharSequence[]) arrayList.toArray(new CharSequence[arrayList.size()]);
        BottomSheet.Builder builder = new BottomSheet.Builder(getParentActivity());
        builder.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                try {
                    int intValue = ((Integer) v.getTag()).intValue();
                    String replace = urlFinal.replace("http://", "").replace("https://", "");
                    if (intValue == 1) {
                        AndroidUtilities.addToClipboard(replace);
                        ChatActivity.this.createUndoView();
                        ChatActivity.this.undoView.showWithAction(0L, 59, (Runnable) null);
                        return true;
                    }
                    if (intValue != 2) {
                        return false;
                    }
                    ChatActivity chatActivity = ChatActivity.this;
                    ShareAlert shareAlert = new ShareAlert(ChatActivity.this.getParentActivity(), (ArrayList) null, replace, false, (String) null, false);
                    chatActivity.shareAlert = shareAlert;
                    chatActivity.showDialog(shareAlert);
                    ChatActivity.this.shareAlert.setParentFragment(ChatActivity.this);
                    return true;
                } catch (Exception e) {
                    e.printStackTrace();
                    return false;
                }
            }
        });
        int intValue = urlFinal.startsWith("video?") ? Utilities.parseInt(urlFinal).intValue() : -1;
        if (intValue >= 0) {
            builder.setTitle(AndroidUtilities.formatDuration(intValue, false));
        } else {
            builder.setTitle(urlFinal);
        }
        builder.setItems(charSequenceArr, new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                ChatActivity.this.lambda$showCopyOpenShareDialog$402(urlFinal, z, theme, dialogInterface, i);
            }
        });
        showDialog(builder.create());
    }

    public void lambda$showCopyOpenShareDialog$402(java.lang.String r8, boolean r9, java.lang.String r10, android.content.DialogInterface r11, int r12) {
        throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChatActivity.lambda$showCopyOpenShareDialog$402(java.lang.String, boolean, java.lang.String, android.content.DialogInterface, int):void");
    }

    public final void openRightsEdit(final int action, TLRPC.User user, final TLRPC.ChatParticipant participant, TLRPC.TL_chatAdminRights adminRights, TLRPC.TL_chatBannedRights bannedRights, String rank, final boolean editingAdmin) {
        final boolean[] zArr = new boolean[1];
        long j = user.id;
        TLRPC.Chat chat = this.currentChat;
        ChatRightsEditActivity chatRightsEditActivity = new ChatRightsEditActivity(j, chat.id, adminRights, chat.default_banned_rights, bannedRights, rank, action, true, false, null);
        chatRightsEditActivity.setDelegate(new ChatRightsEditActivity.ChatRightsEditActivityDelegate() {
            @Override
            public void didSetRights(int rights, TLRPC.TL_chatAdminRights rightsAdmin, TLRPC.TL_chatBannedRights rightsBanned, String rank2) {
                TLRPC.ChatFull chatFull;
                boolean z;
                TLRPC.TL_chatParticipantAdmin tL_chatParticipant;
                int i = action;
                boolean z2 = true;
                if (i != 0) {
                    if (i == 1 && rights == 0) {
                        ChatActivity chatActivity = ChatActivity.this;
                        if (!chatActivity.currentChat.megagroup || (chatFull = chatActivity.chatInfo) == null || chatFull.participants == null) {
                            return;
                        }
                        int i2 = 0;
                        while (true) {
                            if (i2 >= ChatActivity.this.chatInfo.participants.participants.size()) {
                                z = false;
                                break;
                            } else {
                                if (MessageObject.getPeerId(((TLRPC.TL_chatChannelParticipant) ChatActivity.this.chatInfo.participants.participants.get(i2)).channelParticipant.peer) == participant.user_id) {
                                    TLRPC.ChatFull chatFull2 = ChatActivity.this.chatInfo;
                                    chatFull2.participants_count--;
                                    chatFull2.participants.participants.remove(i2);
                                    z = true;
                                    break;
                                }
                                i2++;
                            }
                        }
                        TLRPC.ChatFull chatFull3 = ChatActivity.this.chatInfo;
                        if (chatFull3 != null && chatFull3.participants != null) {
                            for (int i3 = 0; i3 < ChatActivity.this.chatInfo.participants.participants.size(); i3++) {
                                if (((TLRPC.ChatParticipant) ChatActivity.this.chatInfo.participants.participants.get(i3)).user_id == participant.user_id) {
                                    ChatActivity.this.chatInfo.participants.participants.remove(i3);
                                    break;
                                }
                            }
                        }
                        z2 = z;
                        if (z2) {
                            ChatActivity.this.updateVisibleRows();
                            ChatActivity.this.chatAdapter.notifyDataSetChanged();
                            return;
                        }
                        return;
                    }
                    return;
                }
                TLRPC.TL_chatChannelParticipant tL_chatChannelParticipant = participant;
                if (tL_chatChannelParticipant instanceof TLRPC.TL_chatChannelParticipant) {
                    TLRPC.TL_chatChannelParticipant tL_chatChannelParticipant2 = tL_chatChannelParticipant;
                    if (rights == 1) {
                        TLRPC.TL_channelParticipantAdmin tL_channelParticipantAdmin = new TLRPC.TL_channelParticipantAdmin();
                        tL_chatChannelParticipant2.channelParticipant = tL_channelParticipantAdmin;
                        ((TLRPC.ChannelParticipant) tL_channelParticipantAdmin).flags |= 4;
                    } else {
                        tL_chatChannelParticipant2.channelParticipant = new TLRPC.TL_channelParticipant();
                    }
                    tL_chatChannelParticipant2.channelParticipant.inviter_id = ChatActivity.this.getUserConfig().getClientUserId();
                    tL_chatChannelParticipant2.channelParticipant.peer = new TLRPC.TL_peerUser();
                    TLRPC.ChannelParticipant channelParticipant = tL_chatChannelParticipant2.channelParticipant;
                    TLRPC.Peer peer = channelParticipant.peer;
                    TLRPC.ChatParticipant chatParticipant = participant;
                    peer.user_id = chatParticipant.user_id;
                    channelParticipant.date = chatParticipant.date;
                    channelParticipant.banned_rights = rightsBanned;
                    channelParticipant.admin_rights = rightsAdmin;
                    channelParticipant.rank = rank2;
                } else if (tL_chatChannelParticipant != null) {
                    if (rights == 1) {
                        tL_chatParticipant = new TLRPC.TL_chatParticipantAdmin();
                    } else {
                        tL_chatParticipant = new TLRPC.TL_chatParticipant();
                    }
                    TLRPC.ChatParticipant chatParticipant2 = participant;
                    ((TLRPC.ChatParticipant) tL_chatParticipant).user_id = chatParticipant2.user_id;
                    ((TLRPC.ChatParticipant) tL_chatParticipant).date = chatParticipant2.date;
                    ((TLRPC.ChatParticipant) tL_chatParticipant).inviter_id = chatParticipant2.inviter_id;
                    int indexOf = ChatActivity.this.chatInfo.participants.participants.indexOf(chatParticipant2);
                    if (indexOf >= 0) {
                        ChatActivity.this.chatInfo.participants.participants.set(indexOf, tL_chatParticipant);
                    }
                }
                if (rights != 1 || editingAdmin) {
                    return;
                }
                zArr[0] = true;
            }

            @Override
            public void didChangeOwner(TLRPC.User user2) {
                ChatActivity.this.createUndoView();
                if (ChatActivity.this.undoView == null) {
                    return;
                }
                UndoView undoView = ChatActivity.this.undoView;
                TLRPC.Chat chat2 = ChatActivity.this.currentChat;
                undoView.showWithAction(-chat2.id, chat2.megagroup ? 10 : 9, user2);
            }
        });
        presentFragment(chatRightsEditActivity);
    }

    public ArrayList<ThemeDescription> getThemeDescriptions() {
        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$403();
            }

            @Override
            public void onAnimationProgress(float f) {
                ThemeDescription.ThemeDescriptionDelegate.CC.$default$onAnimationProgress(this, f);
            }
        };
        ArrayList<ThemeDescription> 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 (this.reportType < 0) {
            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));
            arrayList.add(new ThemeDescription(((BaseFragment) this).actionBar, ThemeDescription.FLAG_AB_SUBTITLECOLOR, null, null, null, null, Theme.key_actionBarDefaultSubtitle));
        } else {
            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));
            arrayList.add(new ThemeDescription(((BaseFragment) this).actionBar, ThemeDescription.FLAG_AB_SUBTITLECOLOR, null, null, null, null, i2));
        }
        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_IMAGECOLOR | ThemeDescription.FLAG_AB_SUBMENUITEM, 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("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));
            TextPaint[] textPaintArr = Theme.dialogs_namePaint;
            arrayList.add(new ThemeDescription((View) this.messagesSearchListView, 0, new Class[]{DialogCell.class}, (String[]) null, new Paint[]{textPaintArr[0], textPaintArr[1], Theme.dialogs_searchNamePaint}, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_chats_name));
            TextPaint[] textPaintArr2 = Theme.dialogs_nameEncryptedPaint;
            arrayList.add(new ThemeDescription((View) this.messagesSearchListView, 0, new Class[]{DialogCell.class}, (String[]) null, new Paint[]{textPaintArr2[0], textPaintArr2[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, 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, 0, new Class[]{ChatActivityEnterView.class}, new String[]{"doneButtonProgress"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_contextProgressInner1));
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, 0, new Class[]{ChatActivityEnterView.class}, new String[]{"doneButtonProgress"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_contextProgressOuter1));
        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[]{"seekBarWaveform"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_chat_recordedVoiceProgress));
        arrayList.add(new ThemeDescription((View) this.chatActivityEnterView, 0, new Class[]{ChatActivityEnterView.class}, new String[]{"seekBarWaveform"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_chat_recordedVoiceProgressInner));
        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(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.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));
        UnreadCounterTextView unreadCounterTextView3 = this.bottomOverlayChatText;
        int i48 = Theme.key_chat_messagePanelBackground;
        arrayList.add(new ThemeDescription(unreadCounterTextView3, 0, null, null, null, null, i48));
        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));
        arrayList.add(new ThemeDescription(this.bottomOverlayChatText2, 0, null, null, null, null, i46));
        arrayList.add(new ThemeDescription(this.bottomOverlayChatText2, 0, null, null, null, null, i47));
        arrayList.add(new ThemeDescription(this.bottomOverlayChatText2, 0, null, null, null, null, i48));
        ChatBigEmptyView chatBigEmptyView = this.bigEmptyView;
        int i49 = ThemeDescription.FLAG_TEXTCOLOR;
        int i50 = Theme.key_chat_serviceText;
        arrayList.add(new ThemeDescription(chatBigEmptyView, i49, null, null, null, null, i50));
        arrayList.add(new ThemeDescription(this.emptyView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, i50));
        arrayList.add(new ThemeDescription(this.progressBar, ThemeDescription.FLAG_PROGRESSBAR, null, null, null, null, i50));
        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 i51 = ThemeDescription.FLAG_SERVICEBACKGROUND;
        int i52 = Theme.key_chat_serviceBackground;
        arrayList.add(new ThemeDescription(view, i51, null, null, null, null, i52));
        arrayList.add(new ThemeDescription(this.emptyView, ThemeDescription.FLAG_SERVICEBACKGROUND, null, null, null, null, i52));
        arrayList.add(new ThemeDescription(this.bigEmptyView, ThemeDescription.FLAG_SERVICEBACKGROUND, null, null, null, null, i52));
        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 i53 = 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, i53));
            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, i53));
            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 i54 = ThemeDescription.FLAG_BACKGROUNDFILTER;
        int i55 = Theme.key_chat_gifSaveHintBackground;
        arrayList.add(new ThemeDescription(hintView, i54, null, null, null, null, i55));
        HintView hintView2 = this.gifHintTextView;
        int i56 = ThemeDescription.FLAG_TEXTCOLOR;
        int i57 = Theme.key_chat_gifSaveHintText;
        arrayList.add(new ThemeDescription(hintView2, i56, null, null, null, null, i57));
        arrayList.add(new ThemeDescription((View) this.noSoundHintView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{HintView.class}, new String[]{"textView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i57));
        arrayList.add(new ThemeDescription((View) this.noSoundHintView, ThemeDescription.FLAG_IMAGECOLOR, new Class[]{HintView.class}, new String[]{"imageView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i57));
        arrayList.add(new ThemeDescription((View) this.noSoundHintView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{HintView.class}, new String[]{"arrowImageView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i55));
        arrayList.add(new ThemeDescription((View) this.forwardHintView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{HintView.class}, new String[]{"textView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i57));
        arrayList.add(new ThemeDescription((View) this.forwardHintView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{HintView.class}, new String[]{"arrowImageView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i55));
        arrayList.add(new ThemeDescription(this.pagedownButtonCounter, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, i47));
        CounterView counterView = this.pagedownButtonCounter;
        int i58 = ThemeDescription.FLAG_TEXTCOLOR;
        int i59 = Theme.key_chat_goDownButtonCounter;
        arrayList.add(new ThemeDescription(counterView, i58, null, null, null, null, i59));
        ImageView imageView4 = this.pagedownButtonImage;
        int i60 = ThemeDescription.FLAG_BACKGROUNDFILTER;
        int i61 = Theme.key_chat_goDownButton;
        arrayList.add(new ThemeDescription(imageView4, i60, null, null, null, null, i61));
        ImageView imageView5 = this.pagedownButtonImage;
        int i62 = ThemeDescription.FLAG_IMAGECOLOR;
        int i63 = Theme.key_chat_goDownButtonIcon;
        arrayList.add(new ThemeDescription(imageView5, i62, null, null, null, null, i63));
        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, i59));
        arrayList.add(new ThemeDescription(this.mentiondownButtonImage, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, i61));
        arrayList.add(new ThemeDescription(this.mentiondownButtonImage, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, i63));
        arrayList.add(new ThemeDescription(this.floatingDateView, 0, null, null, null, null, i50));
        arrayList.add(new ThemeDescription(this.floatingDateView, 0, null, null, null, null, i52));
        arrayList.add(new ThemeDescription(this.infoTopView, 0, null, null, null, null, i50));
        arrayList.add(new ThemeDescription(this.infoTopView, 0, null, null, null, null, i52));
        int i64 = Theme.key_chat_attachIcon;
        arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDescriptionDelegate, i64));
        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, i64));
        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, i64));
        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, i64));
        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, i64));
        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, i64));
        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 i65 = Theme.key_chat_inReactionButtonTextSelected;
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, i65));
        arrayList.add(new ThemeDescription(null, 0, null, null, null, null, i65));
        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<ThemeDescription> it = arrayList.iterator();
        while (it.hasNext()) {
            it.next().resourcesProvider = this.themeDelegate;
        }
        return arrayList;
    }

    public void lambda$getThemeDescriptions$403() {
        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));
            if (Theme.usePlusTheme && Theme.chatSolidBGColorCheck) {
                updateBackgroundPlus();
            }
            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);
        }
        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();
        }
    }

    public ChatAvatarContainer getAvatarContainer() {
        return this.avatarContainer;
    }

    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 AnimatorSet onCustomTransitionAnimation(boolean isOpen, Runnable callback) {
        ValueAnimator ofFloat;
        if (isOpen && this.fromPullingDownTransition && getParentLayout() != null && getParentLayout().getFragmentStack().size() > 1) {
            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 : r7.getMeasuredHeight()) - max);
                final boolean z = chatActivity.fragmentContextView.getMeasuredHeight() != this.fragmentContextView.getMeasuredHeight();
                ofFloat2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                    @Override
                    public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                        ChatActivity.this.lambda$onCustomTransitionAnimation$404(chatActivity, z, valueAnimator);
                    }
                });
                updateChatListViewTopPadding();
                AnimatorSet animatorSet = new AnimatorSet();
                this.fragmentTransition = animatorSet;
                animatorSet.addListener(new AnonymousClass177(chatActivity, callback));
                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 = getParentLayout().getFragmentStack().get(getParentLayout().getFragmentStack().size() - 2);
        if (!(baseFragment2 instanceof TopicsFragment)) {
            return null;
        }
        float[] fArr = {1.0f, 0.0f};
        if (isOpen) {
            
            fArr[0] = 0.0f;
            fArr[1] = 1.0f;
            ofFloat = ValueAnimator.ofFloat(fArr);
        } else {
            ofFloat = ValueAnimator.ofFloat(fArr);
        }
        baseFragment2.getFragmentView().getWidth();
        this.switchingFromTopicsProgress = isOpen ? 0.0f : 1.0f;
        ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                ChatActivity.this.switchingFromTopicsProgress = ((Float) animation.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 AnonymousClass179(isOpen, callback));
        this.fragmentTransition.setDuration(150L);
        this.fragmentTransition.playTogether(ofFloat);
        if (isOpen) {
            AndroidUtilities.runOnUIThread(this.fragmentTransitionRunnable, 200L);
        } else {
            this.fragmentTransition.start();
        }
        return this.fragmentTransition;
    }

    public void lambda$onCustomTransitionAnimation$404(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);
        }
    }

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

        public AnonymousClass177(final ChatActivity val$previousChat, final Runnable val$callback) {
            this.val$previousChat = val$previousChat;
            this.val$callback = val$callback;
        }

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

        @Override
        public void onAnimationEnd(Animator animation) {
            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.AnonymousClass177.this.lambda$onAnimationEnd$0();
                }
            }, 32L);
            super.onAnimationEnd(animation);
            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);
            }
        }

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

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

        public AnonymousClass179(final boolean val$isOpen, final Runnable val$callback) {
            this.val$isOpen = val$isOpen;
            this.val$callback = val$callback;
        }

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

        @Override
        public void onAnimationEnd(Animator animation) {
            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.AnonymousClass179.this.lambda$onAnimationEnd$0();
                }
            }, 32L);
            this.val$callback.run();
        }

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

    public final void setTransitionToChatActivity(ChatActivity chatActivity) {
        this.pullingDownAnimateToActivity = chatActivity;
    }

    public final void setTransitionToChatProgress(float p) {
        this.pullingDownAnimateProgress = p;
        View view = ((BaseFragment) this).fragmentView;
        if (view != null) {
            view.invalidate();
        }
        RecyclerListView recyclerListView = this.chatListView;
        if (recyclerListView != null) {
            recyclerListView.invalidate();
        }
    }

    public final void showChatThemeBottomSheet() {
        TLRPC.Chat chat = this.currentChat;
        if (chat != null) {
            if (ChatObject.isMegagroup(chat)) {
                if (ChatObject.hasAdminRights(this.currentChat)) {
                    presentFragment(new GroupColorActivity(getDialogId()).setOnApplied(this));
                    return;
                }
                return;
            } else {
                if (ChatObject.canChangeChatInfo(this.currentChat)) {
                    presentFragment(new ChannelColorActivity(getDialogId()).setOnApplied(this));
                    return;
                }
                return;
            }
        }
        this.chatThemeBottomSheet = new ChatThemeBottomSheet(this, this.themeDelegate);
        this.chatListView.setOnInterceptTouchListener(new RecyclerListView.OnInterceptTouchListener() {
            public final boolean onInterceptTouchEvent(MotionEvent motionEvent) {
                boolean lambda$showChatThemeBottomSheet$405;
                lambda$showChatThemeBottomSheet$405 = ChatActivity.lambda$showChatThemeBottomSheet$405(motionEvent);
                return lambda$showChatThemeBottomSheet$405;
            }
        });
        setChildrenEnabled(this.contentView, false);
        showDialog(this.chatThemeBottomSheet, new DialogInterface.OnDismissListener() {
            @Override
            public final void onDismiss(DialogInterface dialogInterface) {
                ChatActivity.this.lambda$showChatThemeBottomSheet$406(dialogInterface);
            }
        });
    }

    public void lambda$showChatThemeBottomSheet$406(DialogInterface dialogInterface) {
        this.chatThemeBottomSheet = null;
        this.chatListView.setOnInterceptTouchListener((RecyclerListView.OnInterceptTouchListener) null);
        setChildrenEnabled(this.contentView, true);
        ChatThemeController.getInstance(((BaseFragment) this).currentAccount).clearWallpaperThumbImages();
    }

    public final void setChildrenEnabled(View view, boolean isEnabled) {
        if (view instanceof ViewGroup) {
            ViewGroup viewGroup = (ViewGroup) view;
            for (int i = 0; i < viewGroup.getChildCount(); i++) {
                setChildrenEnabled(viewGroup.getChildAt(i), isEnabled);
            }
        }
        if (view == this.chatListView || view == this.contentView) {
            return;
        }
        view.setEnabled(isEnabled);
    }

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

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

    public final void setChatThemeEmoticon(final String emoticon) {
        if (this.themeDelegate == null || this.parentThemeDelegate != null) {
            return;
        }
        ChatThemeController chatThemeController = ChatThemeController.getInstance(((BaseFragment) this).currentAccount);
        chatThemeController.setDialogTheme(this.dialog_id, emoticon, false);
        if (!TextUtils.isEmpty(emoticon)) {
            chatThemeController.requestChatTheme(emoticon, new ResultCallback() {
                public final void onComplete(Object obj) {
                    ChatActivity.this.lambda$setChatThemeEmoticon$408((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);
    }

    public void lambda$setChatThemeEmoticon$408(EmojiThemes emojiThemes) {
        ThemeDelegate themeDelegate = this.themeDelegate;
        themeDelegate.setCurrentTheme(emojiThemes, themeDelegate.wallpaper, this.openAnimationStartTime != 0, null);
    }

    public Drawable getThemedDrawable(String drawableKey) {
        Drawable drawable = this.themeDelegate.getDrawable(drawableKey);
        return drawable != null ? drawable : super.getThemedDrawable(drawableKey);
    }

    public Paint getThemedPaint(String paintKey) {
        Paint paint = this.themeDelegate.getPaint(paintKey);
        return paint != null ? paint : Theme.getThemePaint(paintKey);
    }

    public float getChatListViewPadding() {
        return this.chatListViewPaddingTop;
    }

    public FragmentContextView getFragmentContextView() {
        return this.fragmentContextView;
    }

    public Theme.ResourcesProvider getResourceProvider() {
        return this.themeDelegate;
    }

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

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

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

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

        public ThemeDelegate() {
            boolean z = false;
            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);
                    z = true;
                }
            }
            if (!z && ThemeEditorView.getInstance() == null) {
                Theme.refreshThemeColors(true, true);
            } else {
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.ThemeDelegate.lambda$new$0();
                    }
                });
            }
        }

        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 List<EmojiThemes> getCachedThemes() {
            return this.cachedThemes;
        }

        public void setCachedThemes(List<EmojiThemes> cachedThemes) {
            this.cachedThemes = cachedThemes;
        }

        @Override
        public int getColor(int key) {
            int indexOfKey;
            int indexOfKey2;
            SparseIntArray sparseIntArray = this.animatingColors;
            if (sparseIntArray != null && (indexOfKey2 = sparseIntArray.indexOfKey(key)) >= 0) {
                return this.animatingColors.valueAt(indexOfKey2);
            }
            if (this.chatTheme == null) {
                return Theme.getColor(key);
            }
            int indexOfKey3 = this.currentColors.indexOfKey(key);
            if (indexOfKey3 >= 0) {
                return this.currentColors.valueAt(indexOfKey3);
            }
            int fallbackKey = Theme.getFallbackKey(key);
            if (fallbackKey >= 0 && (indexOfKey = this.currentColors.indexOfKey(fallbackKey)) >= 0) {
                return this.currentColors.valueAt(indexOfKey);
            }
            return Theme.getColor(key);
        }

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

        public int getCurrentColor(int key, boolean ignoreAnimation) {
            int indexOfKey;
            SparseIntArray sparseIntArray;
            int indexOfKey2;
            if (this.chatTheme == null && this.backgroundDrawable == null) {
                return Theme.getColor(key);
            }
            if (!ignoreAnimation && (sparseIntArray = this.animatingColors) != null && (indexOfKey2 = sparseIntArray.indexOfKey(key)) >= 0) {
                return this.animatingColors.valueAt(indexOfKey2);
            }
            SparseIntArray sparseIntArray2 = this.currentColors;
            if (sparseIntArray2 != null && (indexOfKey = sparseIntArray2.indexOfKey(key)) >= 0) {
                return this.currentColors.valueAt(indexOfKey);
            }
            return Theme.getColor(key);
        }

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

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

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

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

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

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

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

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

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

        public void setCurrentTheme(final EmojiThemes chatTheme, TLRPC.WallPaper newWallpaper, boolean animated, Boolean forceDark) {
            setCurrentTheme(chatTheme, newWallpaper, animated, forceDark, false);
        }

        public void setCurrentTheme(final EmojiThemes chatTheme, final TLRPC.WallPaper newWallpaper, final boolean animated, Boolean forceDark, boolean force) {
            if (((BaseFragment) ChatActivity.this).parentLayout == null || ChatActivity.this.parentThemeDelegate != null) {
                return;
            }
            boolean booleanValue = forceDark != null ? forceDark.booleanValue() : this.isDark;
            String emoticon = chatTheme != null ? chatTheme.getEmoticon() : null;
            EmojiThemes emojiThemes = this.chatTheme;
            String emoticon2 = emojiThemes != null ? emojiThemes.getEmoticon() : null;
            TLRPC.WallPaper wallPaper = this.wallpaper;
            if (!force) {
                if (!isThemeChangeAvailable(false)) {
                    return;
                }
                if (TextUtils.equals(emoticon2, emoticon) && this.isDark == booleanValue && ChatThemeController.equals(newWallpaper, wallPaper)) {
                    return;
                }
            }
            this.isDark = booleanValue;
            Theme.ThemeInfo currentNightTheme = booleanValue ? Theme.getCurrentNightTheme() : Theme.getCurrentTheme();
            INavigationLayout.ThemeAnimationSettings themeAnimationSettings = new INavigationLayout.ThemeAnimationSettings(currentNightTheme, currentNightTheme.currentAccentId, currentNightTheme.isDark(), !animated);
            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 (chatTheme != null || newWallpaper != null) {
                int i = 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(chatTheme, newWallpaper, animated);
                }
            };
            if (animated) {
                themeAnimationSettings.animationProgress = new INavigationLayout.ThemeAnimationSettings.onAnimationProgress() {
                    @Override
                    public void setProgress(float p) {
                        ChatActivity.this.chatListView.invalidate();
                        ThemeDelegate themeDelegate = ThemeDelegate.this;
                        themeDelegate.animatingMessageDrawable.crossfadeProgress = p;
                        themeDelegate.animatingMessageMediaDrawable.crossfadeProgress = p;
                        themeDelegate.updateServiceMessageColor(p);
                    }
                };
                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();
            }
        }

        public void lambda$setCurrentTheme$1(EmojiThemes emojiThemes, TLRPC.WallPaper wallPaper, boolean z) {
            setupChatTheme(emojiThemes, wallPaper, z, true);
            initServiceMessageColors(this.backgroundDrawable);
            ChatActivity.this.contentView.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 final 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) {
                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);
            }
            if (emojiThemes != null) {
                this.currentColors = emojiThemes.createColors(((BaseFragment) ChatActivity.this).currentAccount, this.isDark ? 1 : 0);
            } else {
                this.currentColors = new SparseIntArray();
            }
            if (!TextUtils.isEmpty(ChatThemeController.getWallpaperEmoticon(this.wallpaper))) {
                this.backgroundDrawable = PreviewView.getBackgroundDrawable(this.backgroundDrawable, ((BaseFragment) ChatActivity.this).currentAccount, this.wallpaper, this.isDark);
            } else if (wallPaper != null) {
                this.backgroundDrawable = ChatBackgroundDrawable.getOrCreate(this.backgroundDrawable, wallPaper, this.isDark);
            } else {
                this.backgroundDrawable = 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(this) {
                        @Override
                        public void onAnimationEnd(Animator animation) {
                            super.onAnimationEnd(animation);
                            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(this) {
                        @Override
                        public void onAnimationEnd(Animator animation) {
                            super.onAnimationEnd(animation);
                            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) {
                int i = AndroidUtilities.calcDrawableColor(this.backgroundDrawable)[0];
                initDrawables();
                initPaints();
                initServiceMessageColors(this.backgroundDrawable);
                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());
        }

        public final void initDrawables() {
            Drawable messageDrawable;
            int themeDrawableColorKey;
            for (Map.Entry<String, Drawable> entry : Theme.getThemeDrawablesMap().entrySet()) {
                String key = entry.getKey();
                key.hashCode();
                switch (key) {
                    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 = entry.getValue().getConstantState();
                        messageDrawable = constantState != null ? constantState.newDrawable().mutate() : null;
                        if (messageDrawable != null && (themeDrawableColorKey = Theme.getThemeDrawableColorKey(entry.getKey())) >= 0) {
                            Theme.setDrawableColor(messageDrawable, getColor(themeDrawableColorKey));
                            break;
                        }
                        break;
                }
                if (messageDrawable != null) {
                    this.currentDrawables.put(entry.getKey(), messageDrawable);
                }
            }
        }

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

        public final void initServiceMessageColors(Drawable backgroundDrawable) {
            float f;
            int i;
            Drawable drawable = backgroundDrawable;
            if (ChatActivity.this.parentThemeDelegate != null) {
                return;
            }
            int i2 = AndroidUtilities.calcDrawableColor(backgroundDrawable)[0];
            int currentColor = getCurrentColor(Theme.key_chat_serviceBackground);
            int i3 = Theme.key_chat_selectedBackground;
            int currentColor2 = getCurrentColor(i3);
            if (currentColor != 0 && this.wallpaper == null) {
                i2 = currentColor;
            }
            this.currentServiceColor = i2;
            if (drawable instanceof ChatBackgroundDrawable) {
                ChatBackgroundDrawable chatBackgroundDrawable = (ChatBackgroundDrawable) drawable;
                f = chatBackgroundDrawable.getDimAmount();
                drawable = chatBackgroundDrawable.getDrawable(false);
            } else {
                f = 0.0f;
            }
            boolean z = drawable instanceof MotionBackgroundDrawable;
            boolean z2 = (z || (drawable instanceof BitmapDrawable)) && SharedConfig.getDevicePerformanceClass() != 0;
            this.drawServiceGradient = z2;
            this.drawSelectedGradient = z2;
            if (z2) {
                if (drawable instanceof BitmapDrawable) {
                    Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
                    int i4 = 40;
                    if (bitmap.getWidth() > bitmap.getHeight()) {
                        i = (int) ((40 / bitmap.getWidth()) * bitmap.getHeight());
                    } else {
                        i4 = (int) ((40 / bitmap.getHeight()) * bitmap.getWidth());
                        i = 40;
                    }
                    this.serviceBitmap = Bitmap.createBitmap(i4, i, Bitmap.Config.ARGB_8888);
                    this.serviceCanvas = new Canvas(this.serviceBitmap);
                    this.src.set(0, 0, bitmap.getWidth(), bitmap.getHeight());
                    this.dst.set(0, 0, this.serviceBitmap.getWidth(), this.serviceBitmap.getHeight());
                    this.serviceCanvas.drawBitmap(bitmap, this.src, this.dst, (Paint) null);
                    Bitmap bitmap2 = this.serviceBitmap;
                    Utilities.blurBitmap(bitmap2, 3, 1, bitmap2.getWidth(), this.serviceBitmap.getHeight(), this.serviceBitmap.getRowBytes());
                    this.serviceCanvas.drawColor(ColorUtils.setAlphaComponent(-16777216, (int) (f * 255.0f)));
                    Bitmap bitmap3 = this.serviceBitmap;
                    Shader.TileMode tileMode = Shader.TileMode.CLAMP;
                    this.serviceShader = new BitmapShader(bitmap3, tileMode, tileMode);
                    this.serviceBitmapSource = Bitmap.createBitmap(this.serviceBitmap);
                    Bitmap bitmap4 = this.serviceBitmapSource;
                    Shader.TileMode tileMode2 = Shader.TileMode.CLAMP;
                    this.serviceShaderSource = new BitmapShader(bitmap4, tileMode2, tileMode2);
                    if (Build.VERSION.SDK_INT >= 33) {
                        this.serviceShader.setFilterMode(2);
                        this.serviceShaderSource.setFilterMode(2);
                    }
                    this.useSourceShader = true;
                } else {
                    this.serviceBitmap = Bitmap.createBitmap(60, 80, Bitmap.Config.ARGB_8888);
                    this.serviceBitmapSource = ((MotionBackgroundDrawable) drawable).getBitmap();
                    this.serviceCanvas = new Canvas(this.serviceBitmap);
                    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, (Paint) null);
                    this.serviceCanvas.drawColor(ColorUtils.setAlphaComponent(-16777216, (int) (f * 255.0f)));
                    Bitmap bitmap5 = this.serviceBitmap;
                    Shader.TileMode tileMode3 = Shader.TileMode.CLAMP;
                    this.serviceShader = new BitmapShader(bitmap5, tileMode3, tileMode3);
                    Bitmap bitmap6 = this.serviceBitmapSource;
                    Shader.TileMode tileMode4 = Shader.TileMode.CLAMP;
                    this.serviceShaderSource = new BitmapShader(bitmap6, tileMode4, tileMode4);
                    if (Build.VERSION.SDK_INT >= 33) {
                        this.serviceShader.setFilterMode(2);
                        this.serviceShaderSource.setFilterMode(2);
                    }
                    this.useSourceShader = true;
                }
            } else {
                this.serviceBitmap = null;
                this.serviceShader = null;
                this.serviceBitmapSource = null;
                this.serviceCanvas = null;
                this.useSourceShader = false;
            }
            Paint paint = getPaint("paintChatActionBackground");
            Paint paint2 = getPaint("paintChatActionBackgroundSelected");
            Paint paint3 = getPaint("paintChatMessageBackgroundSelected");
            if (paint != null) {
                Paint paint4 = this.currentPaints.get("paintChatActionBackgroundDarken");
                if (paint4 == null) {
                    HashMap<String, Paint> hashMap = this.currentPaints;
                    Paint paint5 = new Paint(1);
                    hashMap.put("paintChatActionBackgroundDarken", paint5);
                    paint5.setColor(0);
                    paint4 = paint5;
                }
                if (this.drawServiceGradient) {
                    ColorMatrix colorMatrix = new ColorMatrix();
                    if (z) {
                        if (((MotionBackgroundDrawable) drawable).getIntensity() >= 0.0f) {
                            colorMatrix.setSaturation(1.6f);
                            AndroidUtilities.multiplyBrightnessColorMatrix(colorMatrix, this.isDark ? 0.97f : 0.92f);
                            AndroidUtilities.adjustBrightnessColorMatrix(colorMatrix, this.isDark ? 0.12f : -0.06f);
                        } else {
                            colorMatrix.setSaturation(1.1f);
                            AndroidUtilities.multiplyBrightnessColorMatrix(colorMatrix, this.isDark ? 0.4f : 0.8f);
                            AndroidUtilities.adjustBrightnessColorMatrix(colorMatrix, this.isDark ? 0.08f : -0.06f);
                        }
                    } else {
                        colorMatrix.setSaturation(1.6f);
                        AndroidUtilities.multiplyBrightnessColorMatrix(colorMatrix, this.isDark ? 0.9f : 0.84f);
                        AndroidUtilities.adjustBrightnessColorMatrix(colorMatrix, this.isDark ? 0.04f : 0.06f);
                    }
                    paint.setAlpha(255);
                    paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
                    paint.setShader(this.serviceShaderSource);
                    paint.setFilterBitmap(true);
                    paint2.setAlpha(255);
                    ColorMatrix colorMatrix2 = new ColorMatrix(colorMatrix);
                    AndroidUtilities.adjustSaturationColorMatrix(colorMatrix2, 0.26f);
                    AndroidUtilities.multiplyBrightnessColorMatrix(colorMatrix2, 0.92f);
                    paint2.setColorFilter(new ColorMatrixColorFilter(colorMatrix2));
                    paint2.setShader(this.serviceShaderSource);
                    paint2.setFilterBitmap(true);
                    paint4.setAlpha(0);
                } else {
                    paint.setColorFilter(null);
                    paint.setShader(null);
                    paint2.setColorFilter(null);
                    paint2.setShader(null);
                    paint4.setAlpha(21);
                }
            }
            if (paint3 == null) {
                paint3 = new Paint(1);
                this.currentPaints.put("paintChatMessageBackgroundSelected", paint3);
            }
            if (this.drawSelectedGradient) {
                ColorMatrix colorMatrix3 = new ColorMatrix();
                AndroidUtilities.adjustSaturationColorMatrix(colorMatrix3, 2.5f);
                AndroidUtilities.multiplyBrightnessColorMatrix(colorMatrix3, 0.75f);
                paint3.setAlpha(64);
                paint3.setColorFilter(new ColorMatrixColorFilter(colorMatrix3));
                paint3.setShader(this.serviceShaderSource);
                paint3.setFilterBitmap(true);
                return;
            }
            if (currentColor2 == 0) {
                currentColor2 = getColor(i3);
            }
            paint3.setColor(currentColor2);
            paint3.setColorFilter(null);
            paint3.setShader(null);
        }

        public final void updateServiceMessageColor(float progress) {
            Bitmap bitmap;
            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 (progress != 1.0f) {
                i = ColorUtils.blendARGB(this.startServiceColor, i, progress);
                currentColor = ColorUtils.blendARGB(this.startServiceTextColor, currentColor, progress);
                currentColor2 = ColorUtils.blendARGB(this.startServiceLinkColor, currentColor2, progress);
                currentColor3 = ColorUtils.blendARGB(this.startServiceButtonColor, currentColor3, progress);
                currentColor4 = ColorUtils.blendARGB(this.startServiceIconColor, currentColor4, progress);
            }
            if (paint != null && !this.drawServiceGradient) {
                paint.setColor(i);
                paint2.setColor(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("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 (progress != 1.0f && (bitmap2 = this.startServiceBitmap) != null) {
                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) (progress * 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) {
                    paint3.setShader(this.serviceShader);
                    return;
                }
                return;
            }
            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) {
                paint3.setShader(this.serviceShaderSource);
            }
        }

        public final 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;
        }

        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$getBackgroundDrawableFromTheme$6(MotionBackgroundDrawable motionBackgroundDrawable, ValueAnimator valueAnimator) {
            motionBackgroundDrawable.setPatternAlpha(((Float) valueAnimator.getAnimatedValue()).floatValue());
        }

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

    public final void updateBackground() {
        if (this.contentView == null || this.parentThemeDelegate != null) {
            return;
        }
        if (this.themeDelegate.backgroundDrawable == null || this.contentView.getBackgroundImage() == null) {
            if (Theme.usePlusTheme && Theme.chatSolidBGColorCheck) {
                updateBackgroundPlus();
            } else if (this.contentView.getBackgroundImage() == null) {
                this.contentView.setBackgroundImage(Theme.getCachedWallpaper(), Theme.isWallpaperMotion());
            }
        }
    }

    public final void updateBotHelpCellClick(final BotHelpCell cell) {
        if (MessagesController.getInstance(((BaseFragment) this).currentAccount).getTranslateController().isContextTranslateEnabled() && LanguageDetector.hasSupport()) {
            final CharSequence text = cell.getText();
            LanguageDetector.detectLanguage(text == null ? "" : text.toString(), new LanguageDetector.StringCallback() {
                public final void run(String str) {
                    ChatActivity.this.lambda$updateBotHelpCellClick$412(cell, text, str);
                }
            }, new LanguageDetector.ExceptionCallback() {
                public final void run(Exception exc) {
                    BotHelpCell.this.setClickable(false);
                }
            });
        } else {
            cell.setClickable(false);
        }
    }

    public void lambda$updateBotHelpCellClick$412(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.setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    ChatActivity.this.lambda$updateBotHelpCellClick$411(str, language, charSequence, botHelpCell, view);
                }
            });
        } else {
            botHelpCell.setClickable(false);
        }
    }

    public void lambda$updateBotHelpCellClick$411(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("TranslateMessage", R.string.TranslateMessage), R.drawable.msg_translate);
        actionBarMenuSubItem.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view2) {
                ChatActivity.this.lambda$updateBotHelpCellClick$409(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$409(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);
        if (runnableArr[0] != null) {
            runnableArr[0].run();
        }
    }

    public boolean allowPresentFragment() {
        return !((BaseFragment) this).inPreviewMode;
    }

    public boolean hideKeyboardOnShow() {
        MessageObject messageObject = this.threadMessageObject;
        if (messageObject != null && messageObject.getRepliesCount() == 0 && ChatObject.canSendMessages(this.currentChat)) {
            return false;
        }
        return super.hideKeyboardOnShow();
    }

    public boolean isLightStatusBar() {
        int color;
        if (this.reportType < 0) {
            return AndroidUtilities.computePerceivedBrightness(((BaseFragment) this).actionBar.getBackgroundColor()) > 0.721f;
        }
        Theme.ResourcesProvider resourceProvider = getResourceProvider();
        if (resourceProvider != null) {
            color = resourceProvider.getColorOrDefault(Theme.key_actionBarActionModeDefault);
        } else {
            color = Theme.getColor(Theme.key_actionBarActionModeDefault, null, true);
        }
        return ColorUtils.calculateLuminance(color) > 0.699999988079071d;
    }

    public MessageObject.GroupedMessages getGroup(long id) {
        return (MessageObject.GroupedMessages) this.groupedMessagesMap.get(id);
    }

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

    public SizeNotifierFrameLayout getContentView() {
        return this.contentView;
    }

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

        public MessageSkeleton() {
        }
    }

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

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

    public final 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 = this.messages.get(childAdapterPosition)) != null && messageObject.isWallpaperForBoth()) {
                ((ChatActionCell) childAt).setMessageObject(messageObject, true);
            }
        }
    }

    public final void checkLeaveChannelButton() {
        ActionBarMenuItem actionBarMenuItem = this.headerItem;
        if (actionBarMenuItem == null || this.chatMode == 3 || actionBarMenuItem.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) {
                    this.headerItem.lazilyAddSubItem(16, R.drawable.msg_leave, LocaleController.getString("LeaveMegaMenu", R.string.LeaveMegaMenu));
                    return;
                } else {
                    this.headerItem.lazilyAddSubItem(16, R.drawable.msg_leave, LocaleController.getString("LeaveChannelMenu", R.string.LeaveChannelMenu));
                    return;
                }
            }
        }
        if (ChatObject.isChannel(this.currentChat)) {
            return;
        }
        if (this.currentChat != null) {
            this.headerItem.lazilyAddSubItem(16, R.drawable.msg_leave, LocaleController.getString("DeleteAndExit", R.string.DeleteAndExit));
            return;
        }
        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 i = Theme.key_text_RedRegular;
            lazilyAddSubItem.setColors(getThemedColor(i), getThemedColor(i));
            return;
        }
        this.headerItem.lazilyAddSubItem(16, R.drawable.msg_delete, LocaleController.getString("DeleteChatUser", R.string.DeleteChatUser));
    }

    public boolean supportsThanosEffect() {
        return ThanosEffect.supports() && LiteMode.isEnabled(65536);
    }

    public ThanosEffect getChatThanosEffect() {
        if (!LiteMode.isEnabled(65536) || !ThanosEffect.supports()) {
            return null;
        }
        if (this.chatListThanosEffect == null) {
            if (getContext() == null || !ThanosEffect.supports() || this.chatListView == null || this.contentView == null) {
                return null;
            }
            View thanosEffect = new ThanosEffect(getContext(), new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$getChatThanosEffect$414();
                }
            });
            this.chatListThanosEffect = thanosEffect;
            SizeNotifierFrameLayout sizeNotifierFrameLayout = this.contentView;
            sizeNotifierFrameLayout.addView(thanosEffect, sizeNotifierFrameLayout.indexOfChild(this.chatListView) + 1, LayoutHelper.createFrame(-1, -1.0f));
        }
        return this.chatListThanosEffect;
    }

    public void lambda$getChatThanosEffect$414() {
        View view;
        if (this.removingFromParent || (view = this.chatListThanosEffect) == null) {
            return;
        }
        this.chatListThanosEffect = null;
        this.contentView.removeView(view);
    }

    public final void checkGroupMessagesOrder() {
        int i;
        if (this.reversed) {
            int i2 = -1;
            long j = 0;
            for (int i3 = 0; i3 < this.messages.size(); i3++) {
                long groupIdForUse = 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(this.messages.remove(i2));
                        }
                        Collections.sort(arrayList, new java.util.Comparator() {
                            @Override
                            public final int compare(Object obj, Object obj2) {
                                int lambda$checkGroupMessagesOrder$415;
                                lambda$checkGroupMessagesOrder$415 = ChatActivity.lambda$checkGroupMessagesOrder$415((MessageObject) obj, (MessageObject) obj2);
                                return lambda$checkGroupMessagesOrder$415;
                            }
                        });
                        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(this.messages.remove(i2));
            }
            this.messages.addAll(i2, arrayList2);
        }
    }

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

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

    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 showPremiumFloodWaitBulletin(final boolean isUpload) {
        float f;
        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;
        }
        if (isUpload) {
            f = MessagesController.getInstance(((BaseFragment) this).currentAccount).uploadPremiumSpeedupUpload;
        } else {
            f = MessagesController.getInstance(((BaseFragment) this).currentAccount).uploadPremiumSpeedupDownload;
        }
        double round = Math.round(f * 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(isUpload ? R.string.UploadSpeedLimited : R.string.DownloadSpeedLimited), AndroidUtilities.replaceCharSequence("%d", AndroidUtilities.premiumText(LocaleController.getString(isUpload ? R.string.UploadSpeedLimitedMessage : R.string.DownloadSpeedLimitedMessage), new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$showPremiumFloodWaitBulletin$416(isUpload);
            }
        }), spannableString)).setDuration(8000).show(true);
    }

    public void lambda$showPremiumFloodWaitBulletin$416(boolean z) {
        presentFragment(new PremiumPreviewFragment(z ? "upload_speed" : "download_speed"));
    }

    public void didLongPressCard(final ChatMessageCell cell, final CharacterStyle link, final String card) {
        final Browser.Progress makeProgressForLink = makeProgressForLink(cell, link);
        TLRPC.TL_payments_getBankCardData tL_payments_getBankCardData = new TLRPC.TL_payments_getBankCardData();
        tL_payments_getBankCardData.number = card;
        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$420(makeProgressForLink, cell, card, link, 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$421(sendRequest);
            }
        });
        makeProgressForLink.init();
    }

    public void lambda$didLongPressCard$420(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$419(progress, chatMessageCell, str, tLObject, characterStyle);
            }
        });
    }

    public void lambda$didLongPressCard$419(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$$ExternalSyntheticLambda365(scrimOptions));
        makeOptions.add(R.drawable.msg_copy, LocaleController.getString(R.string.CopyCardNumber), new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$didLongPressCard$417(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$418(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);
        showDialog(scrimOptions);
    }

    public void lambda$didLongPressCard$417(ScrimOptions scrimOptions, String str) {
        scrimOptions.dismiss();
        AndroidUtilities.addToClipboard(str);
        BulletinFactory.of(this).createCopyBulletin(LocaleController.getString(R.string.CardNumberCopied)).show();
    }

    public void lambda$didLongPressCard$418(TLRPC.TL_bankCardOpenUrl tL_bankCardOpenUrl) {
        Browser.openUrl(getContext(), tL_bankCardOpenUrl.url, this.inlineReturn == 0, false);
    }

    public void lambda$didLongPressCard$421(int i) {
        getConnectionsManager().cancelRequest(i, true);
    }

    public void didLongPressUsername(final ChatMessageCell cell, final CharacterStyle link, final String username) {
        final Browser.Progress makeProgressForLink = makeProgressForLink(cell, link);
        TLObject userOrChat = getMessagesController().getUserOrChat(username);
        final Utilities.Callback2 callback2 = new Utilities.Callback2() {
            public final void run(Object obj, Object obj2) {
                ChatActivity.this.lambda$didLongPressUsername$425(makeProgressForLink, cell, username, link, (TLObject) obj, (Boolean) obj2);
            }
        };
        if (userOrChat != null) {
            callback2.run(userOrChat, Boolean.FALSE);
            return;
        }
        TLRPC.TL_contacts_resolveUsername tL_contacts_resolveUsername = new TLRPC.TL_contacts_resolveUsername();
        tL_contacts_resolveUsername.username = username;
        final int sendRequest = getConnectionsManager().sendRequest(tL_contacts_resolveUsername, new RequestDelegate() {
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                ChatActivity.this.lambda$didLongPressUsername$427(makeProgressForLink, callback2, tLObject, tL_error);
            }
        });
        makeProgressForLink.onCancel(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$didLongPressUsername$428(sendRequest);
            }
        });
        makeProgressForLink.init();
    }

    public void lambda$didLongPressUsername$425(Browser.Progress progress, ChatMessageCell chatMessageCell, final String str, CharacterStyle characterStyle, TLObject tLObject, Boolean bool) {
        final long j;
        boolean z;
        int i;
        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$$ExternalSyntheticLambda365(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$422(j);
                }
            });
        }
        makeOptions.add(R.drawable.msg_copy, LocaleController.getString(R.string.ProfileCopyUsername), new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$didLongPressUsername$423(scrimOptions, str);
            }
        });
        makeOptions.addGap();
        if (j != 0) {
            if (z) {
                i = R.string.ViewProfile;
            } else {
                i = z2 ? R.string.ViewChannelProfile : R.string.ViewGroupProfile;
            }
            makeOptions.addProfile(tLObject, LocaleController.getString(i), new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$didLongPressUsername$424(j);
                }
            });
        } else {
            makeOptions.addText(LocaleController.getString(R.string.NoUsernameFound2), 13, AndroidUtilities.dp(200.0f));
        }
        scrimOptions.setItemOptions(makeOptions);
        scrimOptions.setScrim(chatMessageCell, characterStyle);
        showDialog(scrimOptions);
    }

    public void lambda$didLongPressUsername$422(long j) {
        presentFragment(of(j));
    }

    public void lambda$didLongPressUsername$423(ScrimOptions scrimOptions, String str) {
        scrimOptions.dismiss();
        AndroidUtilities.addToClipboard("@" + str);
        BulletinFactory.of(this).createCopyBulletin(LocaleController.getString(R.string.UsernameCopied)).show();
    }

    public void lambda$didLongPressUsername$424(long j) {
        presentFragment(ProfileActivity.of(j));
    }

    public void lambda$didLongPressUsername$427(final Browser.Progress progress, final Utilities.Callback2 callback2, final TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$didLongPressUsername$426(progress, tLObject, callback2);
            }
        });
    }

    public void lambda$didLongPressUsername$426(Browser.Progress progress, TLObject tLObject, Utilities.Callback2 callback2) {
        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.FALSE);
        }
        user = null;
        callback2.run(user, Boolean.FALSE);
    }

    public void lambda$didLongPressUsername$428(int i) {
        getConnectionsManager().cancelRequest(i, true);
    }

    public void didPressPhoneNumber(final ChatMessageCell cell, final CharacterStyle link, final String phone) {
        final Browser.Progress makeProgressForLink = makeProgressForLink(cell, link);
        final TLRPC.TL_contact tL_contact = (TLRPC.TL_contact) getContactsController().contactsByPhone.get(PhoneFormat.stripExceptNumbers(phone));
        final Utilities.Callback callback = new Utilities.Callback() {
            public final void run(Object obj) {
                ChatActivity.this.lambda$didPressPhoneNumber$441(cell, phone, tL_contact, link, (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$443(tL_contact, callback);
                    }
                });
                return;
            }
        }
        TLRPC.TL_contacts_resolvePhone tL_contacts_resolvePhone = new TLRPC.TL_contacts_resolvePhone();
        tL_contacts_resolvePhone.phone = PhoneFormat.stripExceptNumbers(phone);
        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$445(makeProgressForLink, callback, tLObject, tL_error);
            }
        });
        makeProgressForLink.onCancel(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.lambda$didPressPhoneNumber$446(sendRequest);
            }
        });
        makeProgressForLink.init();
    }

    public void lambda$didPressPhoneNumber$441(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$429(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$430(makeOptions, str);
            }
        });
        makeSwipeback.add(R.drawable.menu_contact_existing, LocaleController.getString(R.string.AddToExistingContact), new Runnable() {
            @Override
            public final void run() {
                ChatActivity.lambda$didPressPhoneNumber$431(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$433(str);
                }
            });
            makeOptions.add(R.drawable.msg_calls_regular, LocaleController.getString(R.string.VoiceCallViaCarrier), new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$didPressPhoneNumber$434(str);
                }
            });
            makeOptions.add(R.drawable.msg_copy, LocaleController.getString(R.string.CopyNumber), new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$didPressPhoneNumber$435(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$436(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$437(user, userFull);
                    }
                });
                makeOptions.add(R.drawable.msg_videocall, LocaleController.getString(R.string.VideoCallViaTelegram), new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.this.lambda$didPressPhoneNumber$438(user, userFull);
                    }
                });
            }
            makeOptions.add(R.drawable.msg_copy, LocaleController.getString(R.string.CopyNumber), new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$didPressPhoneNumber$439(str);
                }
            });
            makeOptions.addGap();
            makeOptions.addProfile(user, LocaleController.getString(R.string.ViewProfile), new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.lambda$didPressPhoneNumber$440(scrimOptions, user);
                }
            });
        }
        scrimOptions.setItemOptions(makeOptions);
        scrimOptions.setScrim(chatMessageCell, characterStyle);
        showDialog(scrimOptions);
    }

    public void lambda$didPressPhoneNumber$429(TLRPC.User user, String str, Boolean bool) {
        Intent intent;
        if (getParentActivity() == null) {
            return;
        }
        if (bool.booleanValue()) {
            intent = new Intent("android.intent.action.INSERT");
            intent.setType("vnd.android.cursor.dir/raw_contact");
        } else {
            intent = new Intent("android.intent.action.INSERT_OR_EDIT");
            intent.setType("vnd.android.cursor.item/contact");
        }
        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];
                    country.code = split[0];
                    country.shortname = split[1];
                    List list = (List) hashMap.get(split[0]);
                    if (list == null) {
                        String str2 = split[0];
                        list = new ArrayList();
                        hashMap.put(str2, list);
                    }
                    list.add(country);
                }
                bufferedReader.close();
            } catch (Exception e) {
                FileLog.e(e);
            }
            String str3 = currentUser.phone;
            int i = 4;
            while (true) {
                if (i < 1) {
                    break;
                }
                List list2 = (List) hashMap.get(str3.substring(0, i));
                if (list2 == null || list2.size() <= 0) {
                    i--;
                } else {
                    String str4 = ((CountrySelectActivity.Country) list2.get(0)).code;
                    if (str4.endsWith("0") && str.startsWith("0")) {
                        str = str.substring(1);
                    }
                    str = "+" + str4 + str;
                    z = true;
                }
            }
            if (!z && Build.VERSION.SDK_INT >= 23) {
                Context context = ApplicationLoader.applicationContext;
                String upperCase = context != null ? ((TelephonyManager) context.getSystemService(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$430(ItemOptions itemOptions, String str) {
        itemOptions.dismiss();
        new NewContactBottomSheet(this, getContext()).setInitialPhoneNumber(str, false).show();
    }

    public static void lambda$didPressPhoneNumber$431(Utilities.Callback callback) {
        callback.run(Boolean.FALSE);
    }

    public void lambda$didPressPhoneNumber$433(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$434(String str) {
        Browser.openUrl(getContext(), "tel:" + str);
    }

    public void lambda$didPressPhoneNumber$435(String str) {
        AndroidUtilities.addToClipboard(str);
        BulletinFactory.of(this).createCopyBulletin(LocaleController.getString(R.string.PhoneCopied)).show();
    }

    public void lambda$didPressPhoneNumber$436(TLRPC.User user) {
        presentFragment(of(user.id));
    }

    public void lambda$didPressPhoneNumber$437(TLRPC.User user, TLRPC.UserFull userFull) {
        VoIPHelper.startCall(user, false, userFull != null && userFull.video_calls_available, getParentActivity(), userFull, getAccountInstance());
    }

    public void lambda$didPressPhoneNumber$438(TLRPC.User user, TLRPC.UserFull userFull) {
        VoIPHelper.startCall(user, true, userFull != null && userFull.video_calls_available, getParentActivity(), userFull, getAccountInstance());
    }

    public void lambda$didPressPhoneNumber$439(String str) {
        AndroidUtilities.addToClipboard(str);
        BulletinFactory.of(this).createCopyBulletin(LocaleController.getString(R.string.PhoneCopied)).show();
    }

    public void lambda$didPressPhoneNumber$440(ScrimOptions scrimOptions, TLRPC.User user) {
        scrimOptions.dismiss();
        presentFragment(ProfileActivity.of(user.id));
    }

    public void lambda$didPressPhoneNumber$443(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$445(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$444(progress, tLObject, callback);
            }
        });
    }

    public void lambda$didPressPhoneNumber$444(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$446(int i) {
        getConnectionsManager().cancelRequest(i, true);
    }

    public class FirstViewPage extends View {
        public final ArrayList<View> views;
        public final ArrayList<View> viewsToMakeVisible;

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

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

        public final 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.chatListView);
            this.views.add(ChatActivity.this.messagesSearchListContainer);
            this.views.add(ChatActivity.this.mentionContainer);
            this.views.add(ChatActivity.this.floatingDateView);
            this.views.removeAll(Collections.singleton(null));
        }

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

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

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