盛康基办.apk(点击下载) / MessagesController.java


package im.guobwnxjuc.messenger;

import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.LongSparseArray;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.util.SparseIntArray;
import androidx.core.app.NotificationManagerCompat;
import androidx.recyclerview.widget.ItemTouchHelper;
import com.baidu.location.BDLocation;
import com.baidu.mapapi.UIMsg;
import com.bjz.comm.net.utils.AppPreferenceUtil;
import com.blankj.utilcode.constant.CacheConstants;
import com.google.android.exoplayer2.DefaultRenderersFactory;
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
import com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy;
import com.king.zxing.util.CodeUtils;
import com.king.zxing.util.LogUtils;
import im.guobwnxjuc.javaBean.fc.FollowedFcListBean;
import im.guobwnxjuc.javaBean.fc.HomeFcListBean;
import im.guobwnxjuc.javaBean.fc.RecommendFcListBean;
import im.guobwnxjuc.messenger.MessagesStorage;
import im.guobwnxjuc.messenger.NotificationCenter;
import im.guobwnxjuc.messenger.support.SparseLongArray;
import im.guobwnxjuc.messenger.voip.VoIPService;
import im.guobwnxjuc.sqlite.SQLiteCursor;
import im.guobwnxjuc.tgnet.ConnectionsManager;
import im.guobwnxjuc.tgnet.NativeByteBuffer;
import im.guobwnxjuc.tgnet.RequestDelegate;
import im.guobwnxjuc.tgnet.TLObject;
import im.guobwnxjuc.tgnet.TLRPC;
import im.guobwnxjuc.tgnet.TLRPCCall;
import im.guobwnxjuc.tgnet.TLRPCChats;
import im.guobwnxjuc.tgnet.TLRPCContacts;
import im.guobwnxjuc.ui.ChatActivity;
import im.guobwnxjuc.ui.DialogsActivity;
import im.guobwnxjuc.ui.ProfileActivity;
import im.guobwnxjuc.ui.actionbar.AlertDialog;
import im.guobwnxjuc.ui.actionbar.BaseFragment;
import im.guobwnxjuc.ui.actionbar.Theme;
import im.guobwnxjuc.ui.components.AlertsCreator;
import im.guobwnxjuc.ui.components.toast.ToastUtils;
import im.guobwnxjuc.ui.hui.chats.NewProfileActivity;
import im.guobwnxjuc.ui.hui.contacts.AddContactsInfoActivity;
import im.guobwnxjuc.ui.hui.friendscircle_v1.helper.FcDBHelper;
import im.guobwnxjuc.ui.hviews.helper.MryDeviceHelper;
import java.io.File;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;

public class MessagesController extends BaseController implements NotificationCenter.NotificationCenterDelegate {
    private static volatile MessagesController[] Instance = new MessagesController[3];
    public static final int UPDATE_MASK_ALL = 1535;
    public static final int UPDATE_MASK_AVATAR = 2;
    public static final int UPDATE_MASK_CHAT = 8192;
    public static final int UPDATE_MASK_CHAT_AVATAR = 8;
    public static final int UPDATE_MASK_CHAT_MEMBERS = 32;
    public static final int UPDATE_MASK_CHAT_NAME = 16;
    public static final int UPDATE_MASK_CHECK = 65536;
    public static final int UPDATE_MASK_MESSAGE_TEXT = 32768;
    public static final int UPDATE_MASK_NAME = 1;
    public static final int UPDATE_MASK_NEW_MESSAGE = 2048;
    public static final int UPDATE_MASK_PHONE = 1024;
    public static final int UPDATE_MASK_READ_DIALOG_MESSAGE = 256;
    public static final int UPDATE_MASK_REORDER = 131072;
    public static final int UPDATE_MASK_SELECT_DIALOG = 512;
    public static final int UPDATE_MASK_SEND_STATE = 4096;
    public static final int UPDATE_MASK_STATUS = 4;
    public static final int UPDATE_MASK_USER_PHONE = 128;
    public static final int UPDATE_MASK_USER_PRINT = 64;
    private static volatile long lastPasswordCheckTime;
    private static volatile long lastThemeCheckTime;
    private int DIALOGS_LOAD_TYPE_CACHE = 1;
    private int DIALOGS_LOAD_TYPE_CHANNEL = 2;
    private int DIALOGS_LOAD_TYPE_UNKNOWN = 3;
    protected ArrayList<TLRPC.Dialog> allDialogs = new ArrayList<>();
    public float animatedEmojisZoom;
    public int availableMapProviders;
    public boolean blockedCountry;
    public boolean blockedEndReached;
    public SparseIntArray blockedUsers = new SparseIntArray();
    public int callConnectTimeout;
    public int callPacketTimeout;
    public int callReceiveTimeout;
    public int callRingTimeout;
    public boolean canRevokePmInbox;
    private SparseArray<SparseArray<String>> channelAdmins = new SparseArray<>();
    private SparseArray<ArrayList<Integer>> channelViewsToSend = new SparseArray<>();
    private SparseIntArray channelsPts = new SparseIntArray();
    private ConcurrentHashMap<Integer, TLRPC.Chat> chats = new ConcurrentHashMap<>(100, 1.0f, 2);
    private SparseBooleanArray checkingLastMessagesDialogs = new SparseBooleanArray();
    private boolean checkingProxyInfo;
    private int checkingProxyInfoRequestId;
    private boolean checkingTosUpdate;
    private LongSparseArray<TLRPC.Dialog> clearingHistoryDialogs = new LongSparseArray<>();
    private boolean contactsGetDiff = false;
    private ArrayList<Long> createdDialogIds = new ArrayList<>();
    private ArrayList<Long> createdDialogMainThreadIds = new ArrayList<>();
    private ArrayList<Long> createdScheduledDialogIds = new ArrayList<>();
    private Runnable currentDeleteTaskRunnable;
    private int currentDeletingTaskChannelId;
    private ArrayList<Integer> currentDeletingTaskMids;
    private int currentDeletingTaskTime;
    public String dcDomainName;
    public boolean defaultP2pContacts;
    public LongSparseArray<Integer> deletedHistory = new LongSparseArray<>();
    private LongSparseArray<TLRPC.Dialog> deletingDialogs = new LongSparseArray<>();
    private final Comparator<TLRPC.Dialog> dialogComparator = new Comparator() {
        /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$0y5nmLTI3hzJuSKLONxbk4ksqs */

        @Override // java.util.Comparator
        public final int compare(Object obj, Object obj2) {
            return MessagesController.this.lambda$new$1$MessagesController((TLRPC.Dialog) obj, (TLRPC.Dialog) obj2);
        }
    };
    public LongSparseArray<MessageObject> dialogMessage = new LongSparseArray<>();
    public SparseArray<MessageObject> dialogMessagesByIds = new SparseArray<>();
    public LongSparseArray<MessageObject> dialogMessagesByRandomIds = new LongSparseArray<>();
    private SparseArray<ArrayList<TLRPC.Dialog>> dialogsByFolder = new SparseArray<>();
    public ArrayList<TLRPC.Dialog> dialogsCanAddUsers = new ArrayList<>();
    public ArrayList<TLRPC.Dialog> dialogsChannelsOnly = new ArrayList<>();
    private SparseBooleanArray dialogsEndReached = new SparseBooleanArray();
    public ArrayList<TLRPC.Dialog> dialogsForward = new ArrayList<>();
    public ArrayList<TLRPC.Dialog> dialogsGroupsOnly = new ArrayList<>();
    private boolean dialogsInTransaction;
    public boolean dialogsLoaded;
    public ArrayList<TLRPC.Dialog> dialogsServerOnly = new ArrayList<>();
    public ArrayList<TLRPC.Dialog> dialogsUnreadOnly = new ArrayList<>();
    public ArrayList<TLRPC.Dialog> dialogsUsersOnly = new ArrayList<>();
    public LongSparseArray<TLRPC.Dialog> dialogs_dict = new LongSparseArray<>();
    public ConcurrentHashMap<Long, Integer> dialogs_read_inbox_max = new ConcurrentHashMap<>(100, 1.0f, 2);
    public ConcurrentHashMap<Long, Integer> dialogs_read_outbox_max = new ConcurrentHashMap<>(100, 1.0f, 2);
    private SharedPreferences emojiPreferences;
    public boolean enableDigitCoin;
    public boolean enableHub;
    public boolean enableJoined;
    public boolean enableWallet;
    private ConcurrentHashMap<Integer, TLRPC.EncryptedChat> encryptedChats = new ConcurrentHashMap<>(10, 1.0f, 2);
    private SparseArray<TLRPC.ExportedChatInvite> exportedChats = new SparseArray<>();
    public boolean firstGettingTask;
    private SparseArray<TLRPC.ChatFull> fullChats = new SparseArray<>();
    private SparseArray<TLRPC.UserFull> fullUsers = new SparseArray<>();
    private boolean getDifferenceFirstSync = true;
    public boolean gettingDifference;
    private SparseBooleanArray gettingDifferenceChannels = new SparseBooleanArray();
    private boolean gettingNewDeleteTask;
    private SparseBooleanArray gettingUnknownChannels = new SparseBooleanArray();
    private LongSparseArray<Boolean> gettingUnknownDialogs = new LongSparseArray<>();
    public String gifSearchBot;
    public ArrayList<TLRPC.RecentMeUrl> hintDialogs = new ArrayList<>();
    public String imageSearchBot;
    private String installReferer;
    private boolean isLeftProxyChannel;
    private ArrayList<Integer> joiningToChannels = new ArrayList<>();
    private int lastCheckProxyId;
    private int lastPrintingStringCount;
    private long lastPushRegisterSendTime;
    private LongSparseArray<Long> lastScheduledServerQueryTime = new LongSparseArray<>();
    private long lastStatusUpdateTime;
    private long lastViewsCheckTime;
    public String linkPrefix;
    private ArrayList<Integer> loadedFullChats = new ArrayList<>();
    private ArrayList<Integer> loadedFullParticipants = new ArrayList<>();
    private ArrayList<Integer> loadedFullUsers = new ArrayList<>();
    private boolean loadingAppConfig;
    public boolean loadingBlockedUsers = false;
    private SparseIntArray loadingChannelAdmins = new SparseIntArray();
    private SparseBooleanArray loadingDialogs = new SparseBooleanArray();
    private ArrayList<Integer> loadingFullChats = new ArrayList<>();
    private ArrayList<Integer> loadingFullParticipants = new ArrayList<>();
    private ArrayList<Integer> loadingFullUsers = new ArrayList<>();
    private int loadingNotificationSettings;
    private boolean loadingNotificationSignUpSettings;
    private LongSparseArray<Boolean> loadingPeerSettings = new LongSparseArray<>();
    private SparseIntArray loadingPinnedDialogs = new SparseIntArray();
    private boolean loadingUnreadDialogs;
    private SharedPreferences mainPreferences;
    public String mapKey;
    public int mapProvider;
    public int maxBroadcastCount = 100;
    public int maxCaptionLength;
    public int maxEditTime;
    public int maxFaveStickersCount;
    public int maxFolderPinnedDialogsCount;
    public int maxGroupCount;
    public int maxMegagroupCount;
    public int maxMessageLength;
    public int maxPinnedDialogsCount;
    public int maxRecentGifsCount;
    public int maxRecentStickersCount;
    private SparseIntArray migratedChats = new SparseIntArray();
    private boolean migratingDialogs;
    public int minGroupConvertSize = ItemTouchHelper.Callback.DEFAULT_DRAG_ANIMATION_DURATION;
    private SparseIntArray needShortPollChannels = new SparseIntArray();
    private SparseIntArray needShortPollOnlines = new SparseIntArray();
    private SparseIntArray nextDialogsCacheOffset = new SparseIntArray();
    private int nextProxyInfoCheckTime;
    private int nextTosCheckTime;
    private SharedPreferences notificationsPreferences;
    private ConcurrentHashMap<String, TLObject> objectsByUsernames = new ConcurrentHashMap<>(100, 1.0f, 2);
    private boolean offlineSent;
    public ConcurrentHashMap<Integer, Integer> onlinePrivacy = new ConcurrentHashMap<>(20, 1.0f, 2);
    private Runnable passwordCheckRunnable = new Runnable() {
        /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$8GcIBfdWJcfx_dPe8vM3YX6cuc8 */

        public final void run() {
            MessagesController.this.lambda$new$0$MessagesController();
        }
    };
    private LongSparseArray<SparseArray<MessageObject>> pollsToCheck = new LongSparseArray<>();
    private int pollsToCheckSize;
    public boolean preloadFeaturedStickers;
    public LongSparseArray<CharSequence> printingStrings = new LongSparseArray<>();
    public LongSparseArray<Integer> printingStringsTypes = new LongSparseArray<>();
    public ConcurrentHashMap<Long, ArrayList<PrintingUser>> printingUsers = new ConcurrentHashMap<>(20, 1.0f, 2);
    private TLRPC.Dialog proxyDialog;
    private String proxyDialogAddress;
    private long proxyDialogId;
    public int ratingDecay;
    private ArrayList<ReadTask> readTasks = new ArrayList<>();
    private LongSparseArray<ReadTask> readTasksMap = new LongSparseArray<>();
    public boolean registeringForPush;
    private LongSparseArray<ArrayList<Integer>> reloadingMessages = new LongSparseArray<>();
    private HashMap<String, ArrayList<MessageObject>> reloadingScheduledWebpages = new HashMap<>();
    private LongSparseArray<ArrayList<MessageObject>> reloadingScheduledWebpagesPending = new LongSparseArray<>();
    private HashMap<String, ArrayList<MessageObject>> reloadingWebpages = new HashMap<>();
    private LongSparseArray<ArrayList<MessageObject>> reloadingWebpagesPending = new LongSparseArray<>();
    private TLRPC.messages_Dialogs resetDialogsAll;
    private TLRPC.TL_messages_peerDialogs resetDialogsPinned;
    private boolean resetingDialogs;
    public int revokeTimeLimit;
    public int revokeTimePmLimit;
    public int secretWebpagePreview;
    public SparseArray<LongSparseArray<Boolean>> sendingTypings = new SparseArray<>();
    private SparseBooleanArray serverDialogsEndReached = new SparseBooleanArray();
    public String sharePrefix;
    private SparseIntArray shortPollChannels = new SparseIntArray();
    private SparseIntArray shortPollOnlines = new SparseIntArray();
    private int statusRequest;
    private int statusSettingState;
    public boolean suggestContacts = true;
    public String suggestedLangCode;
    private Runnable themeCheckRunnable = $$Lambda$vysmdBIeYr3AdEYkRZgcxfN2118.INSTANCE;
    public int totalBlockedCount = -1;
    public int unreadUnmutedDialogs;
    private final Comparator<TLRPC.Update> updatesComparator = new Comparator() {
        /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$9CKFZ6r8FNtRpFaw1B74ohMpVCg */

        @Override // java.util.Comparator
        public final int compare(Object obj, Object obj2) {
            return MessagesController.this.lambda$new$2$MessagesController((TLRPC.Update) obj, (TLRPC.Update) obj2);
        }
    };
    private SparseArray<ArrayList<TLRPC.Updates>> updatesQueueChannels = new SparseArray<>();
    private ArrayList<TLRPC.Updates> updatesQueuePts = new ArrayList<>();
    private ArrayList<TLRPC.Updates> updatesQueueQts = new ArrayList<>();
    private ArrayList<TLRPC.Updates> updatesQueueSeq = new ArrayList<>();
    private SparseLongArray updatesStartWaitTimeChannels = new SparseLongArray();
    private long updatesStartWaitTimePts;
    private long updatesStartWaitTimeQts;
    private long updatesStartWaitTimeSeq;
    public boolean updatingState;
    private String uploadingAvatar;
    private HashMap<String, Theme.ThemeInfo> uploadingThemes = new HashMap<>();
    private String uploadingWallpaper;
    private boolean uploadingWallpaperBlurred;
    private boolean uploadingWallpaperMotion;
    private ConcurrentHashMap<Integer, TLRPC.User> users = new ConcurrentHashMap<>(100, 1.0f, 2);
    public String venueSearchBot;
    private ArrayList<Long> visibleDialogMainThreadIds = new ArrayList<>();
    private ArrayList<Long> visibleScheduledDialogMainThreadIds = new ArrayList<>();
    public int webFileDatacenterId;

    public static class PrintingUser {
        public TLRPC.SendMessageAction action;
        public long lastTime;
        public int userId;
    }

    static /* synthetic */ void lambda$blockUser$49(TLObject tLObject, TLRPC.TL_error tL_error) {
    }

    static /* synthetic */ void lambda$completeReadTask$164(TLObject tLObject, TLRPC.TL_error tL_error) {
    }

    static /* synthetic */ void lambda$deleteUserPhoto$70(TLObject tLObject, TLRPC.TL_error tL_error) {
    }

    static /* synthetic */ void lambda$hidePeerSettingsBar$35(TLObject tLObject, TLRPC.TL_error tL_error) {
    }

    static /* synthetic */ void lambda$installTheme$73(TLObject tLObject, TLRPC.TL_error tL_error) {
    }

    static /* synthetic */ void lambda$installTheme$74(TLObject tLObject, TLRPC.TL_error tL_error) {
    }

    static /* synthetic */ void lambda$markMentionMessageAsRead$159(TLObject tLObject, TLRPC.TL_error tL_error) {
    }

    static /* synthetic */ void lambda$markMentionsAsRead$166(TLObject tLObject, TLRPC.TL_error tL_error) {
    }

    static /* synthetic */ void lambda$markMessageContentAsRead$157(TLObject tLObject, TLRPC.TL_error tL_error) {
    }

    static /* synthetic */ void lambda$processUpdates$263(TLObject tLObject, TLRPC.TL_error tL_error) {
    }

    static /* synthetic */ void lambda$reportSpam$36(TLObject tLObject, TLRPC.TL_error tL_error) {
    }

    static /* synthetic */ void lambda$reportSpam$37(TLObject tLObject, TLRPC.TL_error tL_error) {
    }

    static /* synthetic */ void lambda$saveTheme$72(TLObject tLObject, TLRPC.TL_error tL_error) {
    }

    static /* synthetic */ void lambda$unblockUser$65(TLObject tLObject, TLRPC.TL_error tL_error) {
    }

    static /* synthetic */ void lambda$unregistedPush$207(TLObject tLObject, TLRPC.TL_error tL_error) {
    }

    public /* synthetic */ void lambda$new$0$MessagesController() {
        getUserConfig().checkSavedPassword();
    }

    /* access modifiers changed from: private */
    public static class UserActionUpdatesSeq extends TLRPC.Updates {
        private UserActionUpdatesSeq() {
        }
    }

    /* access modifiers changed from: private */
    public static class UserActionUpdatesPts extends TLRPC.Updates {
        private UserActionUpdatesPts() {
        }
    }

    /* access modifiers changed from: private */
    public class ReadTask {
        public long dialogId;
        public int maxDate;
        public int maxId;
        public long sendRequestTime;

        private ReadTask() {
        }
    }

    public /* synthetic */ int lambda$new$1$MessagesController(TLRPC.Dialog dialog, TLRPC.Dialog dialog2) {
        boolean z = dialog instanceof TLRPC.TL_dialogFolder;
        if (z && !(dialog2 instanceof TLRPC.TL_dialogFolder)) {
            return -1;
        }
        if (!z && (dialog2 instanceof TLRPC.TL_dialogFolder)) {
            return 1;
        }
        if (!dialog.pinned && dialog2.pinned) {
            return 1;
        }
        if (dialog.pinned && !dialog2.pinned) {
            return -1;
        }
        if (!dialog.pinned || !dialog2.pinned) {
            TLRPC.DraftMessage draft = getMediaDataController().getDraft(dialog.id);
            int i = (draft == null || draft.date < dialog.last_message_date) ? dialog.last_message_date : draft.date;
            TLRPC.DraftMessage draft2 = getMediaDataController().getDraft(dialog2.id);
            int i2 = (draft2 == null || draft2.date < dialog2.last_message_date) ? dialog2.last_message_date : draft2.date;
            if (i < i2) {
                return 1;
            }
            if (i > i2) {
                return -1;
            }
            return 0;
        } else if (dialog.pinnedNum < dialog2.pinnedNum) {
            return 1;
        } else {
            if (dialog.pinnedNum > dialog2.pinnedNum) {
                return -1;
            }
            return 0;
        }
    }

    public /* synthetic */ int lambda$new$2$MessagesController(TLRPC.Update update, TLRPC.Update update2) {
        int updateType = getUpdateType(update);
        int updateType2 = getUpdateType(update2);
        if (updateType != updateType2) {
            return AndroidUtilities.compare(updateType, updateType2);
        }
        if (updateType == 0) {
            return AndroidUtilities.compare(getUpdatePts(update), getUpdatePts(update2));
        }
        if (updateType == 1) {
            return AndroidUtilities.compare(getUpdateQts(update), getUpdateQts(update2));
        }
        if (updateType != 2) {
            return 0;
        }
        int updateChannelId = getUpdateChannelId(update);
        int updateChannelId2 = getUpdateChannelId(update2);
        if (updateChannelId == updateChannelId2) {
            return AndroidUtilities.compare(getUpdatePts(update), getUpdatePts(update2));
        }
        return AndroidUtilities.compare(updateChannelId, updateChannelId2);
    }

    public static MessagesController getInstance(int i) {
        MessagesController messagesController = Instance[i];
        if (messagesController == null) {
            synchronized (MessagesController.class) {
                messagesController = Instance[i];
                if (messagesController == null) {
                    MessagesController[] messagesControllerArr = Instance;
                    MessagesController messagesController2 = new MessagesController(i);
                    messagesControllerArr[i] = messagesController2;
                    messagesController = messagesController2;
                }
            }
        }
        return messagesController;
    }

    public static SharedPreferences getNotificationsSettings(int i) {
        return getInstance(i).notificationsPreferences;
    }

    public static SharedPreferences getGlobalNotificationsSettings() {
        return getInstance(0).notificationsPreferences;
    }

    public static SharedPreferences getMainSettings(int i) {
        return getInstance(i).mainPreferences;
    }

    public static SharedPreferences getGlobalMainSettings() {
        return getInstance(0).mainPreferences;
    }

    public static SharedPreferences getEmojiSettings(int i) {
        return getInstance(i).emojiPreferences;
    }

    public static SharedPreferences getGlobalEmojiSettings() {
        return getInstance(0).emojiPreferences;
    }

    public MessagesController(int i) {
        super(i);
        int i2 = 2;
        this.currentAccount = i;
        ImageLoader.getInstance();
        getMessagesStorage();
        getLocationController();
        AndroidUtilities.runOnUIThread(new Runnable() {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$ksWOKxpbebYYJBneC2L71D6ViY */

            public final void run() {
                MessagesController.this.lambda$new$3$MessagesController();
            }
        });
        addSupportUser();
        if (this.currentAccount == 0) {
            this.notificationsPreferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", 0);
            this.mainPreferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", 0);
            this.emojiPreferences = ApplicationLoader.applicationContext.getSharedPreferences("emoji", 0);
        } else {
            Context context = ApplicationLoader.applicationContext;
            this.notificationsPreferences = context.getSharedPreferences("Notifications" + this.currentAccount, 0);
            Context context2 = ApplicationLoader.applicationContext;
            this.mainPreferences = context2.getSharedPreferences("mainconfig" + this.currentAccount, 0);
            Context context3 = ApplicationLoader.applicationContext;
            this.emojiPreferences = context3.getSharedPreferences("emoji" + this.currentAccount, 0);
        }
        this.enableJoined = this.notificationsPreferences.getBoolean("EnableContactJoined", true);
        this.secretWebpagePreview = this.mainPreferences.getInt("secretWebpage2", 2);
        this.maxGroupCount = this.mainPreferences.getInt("maxGroupCount", ItemTouchHelper.Callback.DEFAULT_DRAG_ANIMATION_DURATION);
        this.maxMegagroupCount = this.mainPreferences.getInt("maxMegagroupCount", 10000);
        this.maxRecentGifsCount = this.mainPreferences.getInt("maxRecentGifsCount", ItemTouchHelper.Callback.DEFAULT_DRAG_ANIMATION_DURATION);
        this.maxRecentStickersCount = this.mainPreferences.getInt("maxRecentStickersCount", 30);
        this.maxFaveStickersCount = this.mainPreferences.getInt("maxFaveStickersCount", 5);
        this.maxEditTime = this.mainPreferences.getInt("maxEditTime", CacheConstants.HOUR);
        this.ratingDecay = this.mainPreferences.getInt("ratingDecay", 2419200);
        this.linkPrefix = "m12345.cc";
        this.sharePrefix = this.mainPreferences.getString("sharePrefix", BuildVars.RELEASE_VERSION ? "https://m12345.cc/install.html?appkey=7HDA8K35WHGPO4" : "http://www.shareinstall.com.cn/js-test.html?appkey=7HDA8K35WHGPO4");
        this.callReceiveTimeout = this.mainPreferences.getInt("callReceiveTimeout", 20000);
        this.callRingTimeout = this.mainPreferences.getInt("callRingTimeout", 90000);
        this.callConnectTimeout = this.mainPreferences.getInt("callConnectTimeout", UIMsg.m_AppUI.MSG_RADAR_SEARCH_RETURN_RESULT);
        this.callPacketTimeout = this.mainPreferences.getInt("callPacketTimeout", 10000);
        this.maxPinnedDialogsCount = this.mainPreferences.getInt("maxPinnedDialogsCount", 5);
        this.maxFolderPinnedDialogsCount = this.mainPreferences.getInt("maxFolderPinnedDialogsCount", 100);
        this.maxMessageLength = this.mainPreferences.getInt("maxMessageLength", 4096);
        this.maxCaptionLength = this.mainPreferences.getInt("maxCaptionLength", 1024);
        this.mapProvider = this.mainPreferences.getInt("mapProvider", 0);
        this.availableMapProviders = this.mainPreferences.getInt("availableMapProviders", 3);
        this.mapKey = this.mainPreferences.getString("pk", null);
        this.installReferer = this.mainPreferences.getString("installReferer", null);
        this.defaultP2pContacts = this.mainPreferences.getBoolean("defaultP2pContacts", false);
        this.revokeTimeLimit = this.mainPreferences.getInt("revokeTimeLimit", this.revokeTimeLimit);
        this.revokeTimePmLimit = this.mainPreferences.getInt("revokeTimePmLimit", this.revokeTimePmLimit);
        this.canRevokePmInbox = this.mainPreferences.getBoolean("canRevokePmInbox", this.canRevokePmInbox);
        this.preloadFeaturedStickers = this.mainPreferences.getBoolean("preloadFeaturedStickers", false);
        this.proxyDialogId = this.mainPreferences.getLong("proxy_dialog", 0);
        this.proxyDialogAddress = this.mainPreferences.getString("proxyDialogAddress", null);
        this.nextTosCheckTime = this.notificationsPreferences.getInt("nextTosCheckTime", 0);
        this.venueSearchBot = this.mainPreferences.getString("venueSearchBot", "foursquare");
        this.gifSearchBot = this.mainPreferences.getString("gifSearchBot", "gif");
        this.imageSearchBot = this.mainPreferences.getString("imageSearchBot", "pic");
        this.blockedCountry = this.mainPreferences.getBoolean("blockedCountry", false);
        this.dcDomainName = this.mainPreferences.getString("dcDomainName2", ConnectionsManager.native_isTestBackend(this.currentAccount) != 0 ? "tapv3.stel.com" : "apv3.stel.com");
        this.webFileDatacenterId = this.mainPreferences.getInt("webFileDatacenterId", ConnectionsManager.native_isTestBackend(this.currentAccount) == 0 ? 4 : i2);
        this.suggestedLangCode = this.mainPreferences.getString("suggestedLangCode", "en");
        this.animatedEmojisZoom = this.mainPreferences.getFloat("animatedEmojisZoom", 0.625f);
        this.enableHub = this.mainPreferences.getBoolean("enable_hub", false);
        this.enableWallet = this.mainPreferences.getBoolean("enable_wallet", false);
        this.enableDigitCoin = this.mainPreferences.getBoolean("enable_digit_coin", false);
    }

    public /* synthetic */ void lambda$new$3$MessagesController() {
        MessagesController messagesController = getMessagesController();
        getNotificationCenter().addObserver(messagesController, NotificationCenter.FileDidUpload);
        getNotificationCenter().addObserver(messagesController, NotificationCenter.FileDidFailUpload);
        getNotificationCenter().addObserver(messagesController, NotificationCenter.fileDidLoad);
        getNotificationCenter().addObserver(messagesController, NotificationCenter.fileDidFailToLoad);
        getNotificationCenter().addObserver(messagesController, NotificationCenter.messageReceivedByServer);
        getNotificationCenter().addObserver(messagesController, NotificationCenter.updateMessageMedia);
    }

    private void loadAppConfig() {
        if (!this.loadingAppConfig) {
            this.loadingAppConfig = true;
            getConnectionsManager().sendRequest(new TLRPC.TL_help_getAppConfig(), new RequestDelegate() {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$yX2esylPRWTZt11mo7u35ljZsz0 */

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$loadAppConfig$5$MessagesController(tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$loadAppConfig$5$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable(tLObject) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$TTl4AcYT0Q11TDDW6u065HN4VuY */
            private final /* synthetic */ TLObject f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                MessagesController.this.lambda$null$4$MessagesController(this.f$1);
            }
        });
    }

    public /* synthetic */ void lambda$null$4$MessagesController(TLObject tLObject) {
        if (tLObject instanceof TLRPC.TL_jsonObject) {
            SharedPreferences.Editor edit = this.mainPreferences.edit();
            TLRPC.TL_jsonObject tL_jsonObject = (TLRPC.TL_jsonObject) tLObject;
            int size = tL_jsonObject.value.size();
            boolean z = false;
            for (int i = 0; i < size; i++) {
                TLRPC.TL_jsonObjectValue tL_jsonObjectValue = tL_jsonObject.value.get(i);
                if ("emojies_animated_zoom".equals(tL_jsonObjectValue.key) && (tL_jsonObjectValue.value instanceof TLRPC.TL_jsonNumber)) {
                    TLRPC.TL_jsonNumber tL_jsonNumber = (TLRPC.TL_jsonNumber) tL_jsonObjectValue.value;
                    if (((double) this.animatedEmojisZoom) != tL_jsonNumber.value) {
                        float f = (float) tL_jsonNumber.value;
                        this.animatedEmojisZoom = f;
                        edit.putFloat("animatedEmojisZoom", f);
                        z = true;
                    }
                }
            }
            if (z) {
                edit.commit();
            }
        }
        this.loadingAppConfig = false;
    }

    public void updateConfig(TLRPC.TL_config tL_config) {
        AndroidUtilities.runOnUIThread(new Runnable(tL_config) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$I7JawWJDcQ4nbYHFQUhJSXyiXl4 */
            private final /* synthetic */ TLRPC.TL_config f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                MessagesController.this.lambda$updateConfig$6$MessagesController(this.f$1);
            }
        });
    }

    public /* synthetic */ void lambda$updateConfig$6$MessagesController(TLRPC.TL_config tL_config) {
        String str;
        getDownloadController().loadAutoDownloadConfig(false);
        loadAppConfig();
        this.maxMegagroupCount = tL_config.megagroup_size_max;
        this.maxGroupCount = tL_config.chat_size_max;
        this.maxEditTime = tL_config.edit_time_limit;
        this.ratingDecay = tL_config.rating_e_decay;
        this.maxRecentGifsCount = tL_config.saved_gifs_limit;
        this.maxRecentStickersCount = tL_config.stickers_recent_limit;
        this.maxFaveStickersCount = tL_config.stickers_faved_limit;
        this.revokeTimeLimit = tL_config.revoke_time_limit;
        this.revokeTimePmLimit = tL_config.revoke_pm_time_limit;
        this.canRevokePmInbox = tL_config.revoke_pm_inbox;
        this.linkPrefix = "m12345.cc";
        if ("m12345.cc".endsWith("/")) {
            String str2 = this.linkPrefix;
            this.linkPrefix = str2.substring(0, str2.length() - 1);
        }
        if (this.linkPrefix.startsWith("https://")) {
            this.linkPrefix = this.linkPrefix.substring(8);
        } else if (this.linkPrefix.startsWith("http://")) {
            this.linkPrefix = this.linkPrefix.substring(7);
        }
        this.linkPrefix = "m12345.cc";
        this.sharePrefix = tL_config.me_url_prefix;
        this.callReceiveTimeout = tL_config.call_receive_timeout_ms;
        this.callRingTimeout = tL_config.call_ring_timeout_ms;
        this.callConnectTimeout = tL_config.call_connect_timeout_ms;
        this.callPacketTimeout = tL_config.call_packet_timeout_ms;
        this.maxPinnedDialogsCount = tL_config.pinned_dialogs_count_max;
        this.maxFolderPinnedDialogsCount = tL_config.pinned_infolder_count_max;
        this.maxMessageLength = tL_config.message_length_max;
        this.maxCaptionLength = tL_config.caption_length_max;
        this.defaultP2pContacts = tL_config.default_p2p_contacts;
        this.preloadFeaturedStickers = tL_config.preload_featured_stickers;
        this.enableHub = ((tL_config.flags >> 19) & 1) != 0;
        this.enableWallet = ((tL_config.flags >> 20) & 1) != 0;
        this.enableDigitCoin = ((tL_config.flags >> 21) & 1) != 0;
        if (tL_config.venue_search_username != null) {
            this.venueSearchBot = tL_config.venue_search_username;
        }
        if (tL_config.gif_search_username != null) {
            this.gifSearchBot = tL_config.gif_search_username;
        }
        if (this.imageSearchBot != null) {
            this.imageSearchBot = tL_config.img_search_username;
        }
        this.blockedCountry = tL_config.blocked_mode;
        this.dcDomainName = tL_config.dc_txt_domain_name;
        this.webFileDatacenterId = tL_config.webfile_dc_id;
        if (tL_config.suggested_lang_code != null && ((str = this.suggestedLangCode) == null || !str.equals(tL_config.suggested_lang_code))) {
            this.suggestedLangCode = tL_config.suggested_lang_code;
            LocaleController.getInstance().loadRemoteLanguages(this.currentAccount);
        }
        Theme.loadRemoteThemes(this.currentAccount, false);
        Theme.checkCurrentRemoteTheme(false);
        if (tL_config.static_maps_provider == null) {
            tL_config.static_maps_provider = "google";
        }
        this.mapKey = null;
        this.mapProvider = 2;
        this.availableMapProviders = 0;
        String[] split = tL_config.static_maps_provider.split(",");
        for (int i = 0; i < split.length; i++) {
            String[] split2 = split[i].split("\\+");
            if (split2.length > 0) {
                String[] split3 = split2[0].split(LogUtils.COLON);
                if (split3.length > 0) {
                    if ("yandex".equals(split3[0])) {
                        if (i == 0) {
                            if (split2.length > 1) {
                                this.mapProvider = 3;
                            } else {
                                this.mapProvider = 1;
                            }
                        }
                        this.availableMapProviders |= 4;
                    } else if ("google".equals(split3[0])) {
                        if (i == 0 && split2.length > 1) {
                            this.mapProvider = 4;
                        }
                        this.availableMapProviders |= 1;
                    } else if ("hchat".equals(split3[0])) {
                        if (i == 0) {
                            this.mapProvider = 2;
                        }
                        this.availableMapProviders |= 2;
                    }
                    if (split3.length > 1) {
                        this.mapKey = split3[1];
                    }
                }
            }
        }
        SharedPreferences.Editor edit = this.mainPreferences.edit();
        edit.putInt("maxGroupCount", this.maxGroupCount);
        edit.putInt("maxMegagroupCount", this.maxMegagroupCount);
        edit.putInt("maxEditTime", this.maxEditTime);
        edit.putInt("ratingDecay", this.ratingDecay);
        edit.putInt("maxRecentGifsCount", this.maxRecentGifsCount);
        edit.putInt("maxRecentStickersCount", this.maxRecentStickersCount);
        edit.putInt("maxFaveStickersCount", this.maxFaveStickersCount);
        edit.putInt("callReceiveTimeout", this.callReceiveTimeout);
        edit.putInt("callRingTimeout", this.callRingTimeout);
        edit.putInt("callConnectTimeout", this.callConnectTimeout);
        edit.putInt("callPacketTimeout", this.callPacketTimeout);
        edit.putString("linkPrefix", this.linkPrefix);
        edit.putString("sharePrefix", this.sharePrefix);
        edit.putInt("maxPinnedDialogsCount", this.maxPinnedDialogsCount);
        edit.putInt("maxFolderPinnedDialogsCount", this.maxFolderPinnedDialogsCount);
        edit.putInt("maxMessageLength", this.maxMessageLength);
        edit.putInt("maxCaptionLength", this.maxCaptionLength);
        edit.putBoolean("defaultP2pContacts", this.defaultP2pContacts);
        edit.putBoolean("preloadFeaturedStickers", this.preloadFeaturedStickers);
        edit.putInt("revokeTimeLimit", this.revokeTimeLimit);
        edit.putInt("revokeTimePmLimit", this.revokeTimePmLimit);
        edit.putInt("mapProvider", this.mapProvider);
        String str3 = this.mapKey;
        if (str3 != null) {
            edit.putString("pk", str3);
        } else {
            edit.remove("pk");
        }
        edit.putBoolean("canRevokePmInbox", this.canRevokePmInbox);
        edit.putBoolean("blockedCountry", this.blockedCountry);
        edit.putString("venueSearchBot", this.venueSearchBot);
        edit.putString("gifSearchBot", this.gifSearchBot);
        edit.putString("imageSearchBot", this.imageSearchBot);
        edit.putString("dcDomainName2", this.dcDomainName);
        edit.putInt("webFileDatacenterId", this.webFileDatacenterId);
        edit.putString("suggestedLangCode", this.suggestedLangCode);
        edit.putBoolean("enable_hub", this.enableHub);
        edit.putBoolean("enable_wallet", this.enableWallet);
        edit.putBoolean("enable_digit_coin", this.enableDigitCoin);
        edit.commit();
        LocaleController.getInstance().checkUpdateForCurrentRemoteLocale(this.currentAccount, tL_config.lang_pack_version, tL_config.base_lang_pack_version);
        getNotificationCenter().postNotificationName(NotificationCenter.configLoaded, new Object[0]);
    }

    public void addSupportUser() {
        TLRPC.TL_userForeign_old2 tL_userForeign_old2 = new TLRPC.TL_userForeign_old2();
        tL_userForeign_old2.phone = "333";
        tL_userForeign_old2.id = 333000;
        tL_userForeign_old2.first_name = "Hong";
        tL_userForeign_old2.last_name = "";
        tL_userForeign_old2.status = null;
        tL_userForeign_old2.photo = new TLRPC.TL_userProfilePhotoEmpty();
        putUser(tL_userForeign_old2, true);
        TLRPC.TL_userForeign_old2 tL_userForeign_old22 = new TLRPC.TL_userForeign_old2();
        tL_userForeign_old22.phone = "42777";
        tL_userForeign_old22.id = 777000;
        tL_userForeign_old22.verified = true;
        tL_userForeign_old22.first_name = "Hong";
        tL_userForeign_old22.last_name = "Notifications";
        tL_userForeign_old22.status = null;
        tL_userForeign_old22.photo = new TLRPC.TL_userProfilePhotoEmpty();
        putUser(tL_userForeign_old22, true);
    }

    public TLRPC.InputUser getInputUser(TLRPC.User user) {
        if (user == null) {
            return new TLRPC.TL_inputUserEmpty();
        }
        if (user.id == getUserConfig().getClientUserId()) {
            return new TLRPC.TL_inputUserSelf();
        }
        TLRPC.TL_inputUser tL_inputUser = new TLRPC.TL_inputUser();
        tL_inputUser.user_id = user.id;
        tL_inputUser.access_hash = user.access_hash;
        return tL_inputUser;
    }

    public TLRPC.InputUser getInputUser(int i) {
        return getInputUser(getInstance(UserConfig.selectedAccount).getUser(Integer.valueOf(i)));
    }

    public static TLRPC.InputChannel getInputChannel(TLRPC.Chat chat) {
        if (!(chat instanceof TLRPC.TL_channel) && !(chat instanceof TLRPC.TL_channelForbidden)) {
            return new TLRPC.TL_inputChannelEmpty();
        }
        TLRPC.TL_inputChannel tL_inputChannel = new TLRPC.TL_inputChannel();
        tL_inputChannel.channel_id = chat.id;
        tL_inputChannel.access_hash = chat.access_hash;
        return tL_inputChannel;
    }

    public TLRPC.InputChannel getInputChannel(int i) {
        return getInputChannel(getChat(Integer.valueOf(i)));
    }

    public TLRPC.InputPeer getInputPeer(int i) {
        if (i < 0) {
            int i2 = -i;
            TLRPC.Chat chat = getChat(Integer.valueOf(i2));
            if (ChatObject.isChannel(chat)) {
                TLRPC.TL_inputPeerChannel tL_inputPeerChannel = new TLRPC.TL_inputPeerChannel();
                tL_inputPeerChannel.channel_id = i2;
                tL_inputPeerChannel.access_hash = chat.access_hash;
                return tL_inputPeerChannel;
            }
            TLRPC.TL_inputPeerChat tL_inputPeerChat = new TLRPC.TL_inputPeerChat();
            tL_inputPeerChat.chat_id = i2;
            return tL_inputPeerChat;
        }
        TLRPC.User user = getUser(Integer.valueOf(i));
        TLRPC.TL_inputPeerUser tL_inputPeerUser = new TLRPC.TL_inputPeerUser();
        tL_inputPeerUser.user_id = i;
        if (user == null) {
            return tL_inputPeerUser;
        }
        tL_inputPeerUser.access_hash = user.access_hash;
        return tL_inputPeerUser;
    }

    public TLRPC.Peer getPeer(int i) {
        if (i < 0) {
            int i2 = -i;
            TLRPC.Chat chat = getChat(Integer.valueOf(i2));
            if ((chat instanceof TLRPC.TL_channel) || (chat instanceof TLRPC.TL_channelForbidden)) {
                TLRPC.TL_peerChannel tL_peerChannel = new TLRPC.TL_peerChannel();
                tL_peerChannel.channel_id = i2;
                return tL_peerChannel;
            }
            TLRPC.TL_peerChat tL_peerChat = new TLRPC.TL_peerChat();
            tL_peerChat.chat_id = i2;
            return tL_peerChat;
        }
        getUser(Integer.valueOf(i));
        TLRPC.TL_peerUser tL_peerUser = new TLRPC.TL_peerUser();
        tL_peerUser.user_id = i;
        return tL_peerUser;
    }

    @Override // im.guobwnxjuc.messenger.NotificationCenter.NotificationCenterDelegate
    public void didReceivedNotification(int i, int i2, Object... objArr) {
        if (i == NotificationCenter.FileDidUpload) {
            String str = (String) objArr[0];
            TLRPC.InputFile inputFile = (TLRPC.InputFile) objArr[1];
            String str2 = this.uploadingAvatar;
            if (str2 == null || !str2.equals(str)) {
                String str3 = this.uploadingWallpaper;
                if (str3 == null || !str3.equals(str)) {
                    Theme.ThemeInfo themeInfo = this.uploadingThemes.get(str);
                    if (themeInfo != null) {
                        if (str.equals(themeInfo.uploadingThumb)) {
                            themeInfo.uploadedThumb = inputFile;
                            themeInfo.uploadingThumb = null;
                        } else if (str.equals(themeInfo.uploadingFile)) {
                            themeInfo.uploadedFile = inputFile;
                            themeInfo.uploadingFile = null;
                        }
                        if (!(themeInfo.uploadedFile == null || themeInfo.uploadedThumb == null)) {
                            new File(str);
                            TLRPC.TL_account_uploadTheme tL_account_uploadTheme = new TLRPC.TL_account_uploadTheme();
                            tL_account_uploadTheme.mime_type = "application/x-tgtheme-android";
                            tL_account_uploadTheme.file_name = "theme.attheme";
                            tL_account_uploadTheme.file = themeInfo.uploadedFile;
                            tL_account_uploadTheme.file.name = "theme.attheme";
                            tL_account_uploadTheme.thumb = themeInfo.uploadedThumb;
                            tL_account_uploadTheme.thumb.name = "theme-preview.jpg";
                            tL_account_uploadTheme.flags = 1 | tL_account_uploadTheme.flags;
                            themeInfo.uploadedFile = null;
                            themeInfo.uploadedThumb = null;
                            getConnectionsManager().sendRequest(tL_account_uploadTheme, new RequestDelegate(themeInfo) {
                                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$ySZPHImgQsaQhX_iBHg_H1mss */
                                private final /* synthetic */ Theme.ThemeInfo f$1;

                                {
                                    this.f$1 = r2;
                                }

                                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                                    MessagesController.this.lambda$didReceivedNotification$16$MessagesController(this.f$1, tLObject, tL_error);
                                }
                            });
                        }
                        this.uploadingThemes.remove(str);
                        return;
                    }
                    return;
                }
                TLRPC.TL_account_uploadWallPaper tL_account_uploadWallPaper = new TLRPC.TL_account_uploadWallPaper();
                tL_account_uploadWallPaper.file = inputFile;
                tL_account_uploadWallPaper.mime_type = "image/jpeg";
                TLRPC.TL_wallPaperSettings tL_wallPaperSettings = new TLRPC.TL_wallPaperSettings();
                tL_wallPaperSettings.blur = this.uploadingWallpaperBlurred;
                tL_wallPaperSettings.motion = this.uploadingWallpaperMotion;
                tL_account_uploadWallPaper.settings = tL_wallPaperSettings;
                getConnectionsManager().sendRequest(tL_account_uploadWallPaper, new RequestDelegate(tL_wallPaperSettings) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$76MSX3qTzWLq5wBIhsFYpEHd14E */
                    private final /* synthetic */ TLRPC.TL_wallPaperSettings f$1;

                    {
                        this.f$1 = r2;
                    }

                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        MessagesController.this.lambda$didReceivedNotification$10$MessagesController(this.f$1, tLObject, tL_error);
                    }
                });
                return;
            }
            TLRPC.TL_photos_uploadProfilePhoto tL_photos_uploadProfilePhoto = new TLRPC.TL_photos_uploadProfilePhoto();
            tL_photos_uploadProfilePhoto.file = inputFile;
            getConnectionsManager().sendRequest(tL_photos_uploadProfilePhoto, new RequestDelegate() {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$UrC06e5sSIFZPQf19k_hrYGcDI */

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$didReceivedNotification$8$MessagesController(tLObject, tL_error);
                }
            });
        } else if (i == NotificationCenter.FileDidFailUpload) {
            String str4 = (String) objArr[0];
            String str5 = this.uploadingAvatar;
            if (str5 == null || !str5.equals(str4)) {
                String str6 = this.uploadingWallpaper;
                if (str6 == null || !str6.equals(str4)) {
                    Theme.ThemeInfo remove = this.uploadingThemes.remove(str4);
                    if (remove != null) {
                        remove.uploadedFile = null;
                        remove.uploadedThumb = null;
                        return;
                    }
                    return;
                }
                this.uploadingWallpaper = null;
                return;
            }
            this.uploadingAvatar = null;
        } else if (i == NotificationCenter.messageReceivedByServer) {
            if (!((Boolean) objArr[6]).booleanValue()) {
                Integer num = (Integer) objArr[0];
                Integer num2 = (Integer) objArr[1];
                Long l = (Long) objArr[3];
                MessageObject messageObject = this.dialogMessage.get(l.longValue());
                if (messageObject != null && (messageObject.getId() == num.intValue() || messageObject.messageOwner.local_id == num.intValue())) {
                    messageObject.messageOwner.id = num2.intValue();
                    messageObject.messageOwner.send_state = 0;
                }
                TLRPC.Dialog dialog = this.dialogs_dict.get(l.longValue());
                if (dialog != null && dialog.top_message == num.intValue()) {
                    dialog.top_message = num2.intValue();
                    getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
                }
                MessageObject messageObject2 = this.dialogMessagesByIds.get(num.intValue());
                this.dialogMessagesByIds.remove(num.intValue());
                if (messageObject2 != null) {
                    this.dialogMessagesByIds.put(num2.intValue(), messageObject2);
                }
                int longValue = (int) l.longValue();
                if (longValue < 0) {
                    int i3 = -longValue;
                    TLRPC.ChatFull chatFull = this.fullChats.get(i3);
                    TLRPC.Chat chat = getChat(Integer.valueOf(i3));
                    if (chat != null && !ChatObject.hasAdminRights(chat) && chatFull != null && chatFull.slowmode_seconds != 0) {
                        chatFull.slowmode_next_send_date = ConnectionsManager.getInstance(this.currentAccount).getCurrentTime() + chatFull.slowmode_seconds;
                        chatFull.flags |= 262144;
                        getMessagesStorage().updateChatInfo(chatFull, false);
                    }
                }
            }
        } else if (i == NotificationCenter.updateMessageMedia) {
            TLRPC.Message message = (TLRPC.Message) objArr[0];
            MessageObject messageObject3 = this.dialogMessagesByIds.get(message.id);
            if (messageObject3 != null) {
                messageObject3.messageOwner.media = message.media;
                if (message.media.ttl_seconds == 0) {
                    return;
                }
                if ((message.media.photo instanceof TLRPC.TL_photoEmpty) || (message.media.document instanceof TLRPC.TL_documentEmpty)) {
                    messageObject3.setType();
                    getNotificationCenter().postNotificationName(NotificationCenter.notificationsSettingsUpdated, new Object[0]);
                }
            }
        }
    }

    public /* synthetic */ void lambda$didReceivedNotification$8$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            TLRPC.User user = getUser(Integer.valueOf(getUserConfig().getClientUserId()));
            if (user == null) {
                user = getUserConfig().getCurrentUser();
                putUser(user, true);
            } else {
                getUserConfig().setCurrentUser(user);
            }
            if (user != null) {
                TLRPC.TL_photos_photo tL_photos_photo = (TLRPC.TL_photos_photo) tLObject;
                ArrayList<TLRPC.PhotoSize> arrayList = tL_photos_photo.photo.sizes;
                TLRPC.PhotoSize closestPhotoSizeWithSize = FileLoader.getClosestPhotoSizeWithSize(arrayList, 100);
                TLRPC.PhotoSize closestPhotoSizeWithSize2 = FileLoader.getClosestPhotoSizeWithSize(arrayList, 1000);
                user.photo = new TLRPC.TL_userProfilePhoto();
                user.photo.photo_id = tL_photos_photo.photo.id;
                if (closestPhotoSizeWithSize != null) {
                    user.photo.photo_small = closestPhotoSizeWithSize.location;
                }
                if (closestPhotoSizeWithSize2 != null) {
                    user.photo.photo_big = closestPhotoSizeWithSize2.location;
                } else if (closestPhotoSizeWithSize != null) {
                    user.photo.photo_small = closestPhotoSizeWithSize.location;
                }
                getMessagesStorage().clearUserPhotos(user.id);
                ArrayList<TLRPC.User> arrayList2 = new ArrayList<>();
                arrayList2.add(user);
                getMessagesStorage().putUsersAndChats(arrayList2, null, false, true);
                AndroidUtilities.runOnUIThread(new Runnable() {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$_ljyzmJuyoUJ464XygQAaNKVq40 */

                    public final void run() {
                        MessagesController.this.lambda$null$7$MessagesController();
                    }
                });
            }
        }
    }

    public /* synthetic */ void lambda$null$7$MessagesController() {
        getNotificationCenter().postNotificationName(NotificationCenter.mainUserInfoChanged, new Object[0]);
        getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 2);
        getUserConfig().saveConfig(true);
    }

    public /* synthetic */ void lambda$didReceivedNotification$10$MessagesController(TLRPC.TL_wallPaperSettings tL_wallPaperSettings, TLObject tLObject, TLRPC.TL_error tL_error) {
        TLRPC.TL_wallPaper tL_wallPaper = (TLRPC.TL_wallPaper) tLObject;
        File file = new File(ApplicationLoader.getFilesDirFixed(), this.uploadingWallpaperBlurred ? "wallpaper_original.jpg" : "wallpaper.jpg");
        if (tL_wallPaper != null) {
            try {
                AndroidUtilities.copyFile(file, FileLoader.getPathToAttach(tL_wallPaper.document, true));
            } catch (Exception unused) {
            }
        }
        AndroidUtilities.runOnUIThread(new Runnable(tL_wallPaper, tL_wallPaperSettings, file) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$1NpgNWHK4JV3Ll6baGitUW1G8Hc */
            private final /* synthetic */ TLRPC.TL_wallPaper f$1;
            private final /* synthetic */ TLRPC.TL_wallPaperSettings f$2;
            private final /* synthetic */ File f$3;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
            }

            public final void run() {
                MessagesController.this.lambda$null$9$MessagesController(this.f$1, this.f$2, this.f$3);
            }
        });
    }

    public /* synthetic */ void lambda$null$9$MessagesController(TLRPC.TL_wallPaper tL_wallPaper, TLRPC.TL_wallPaperSettings tL_wallPaperSettings, File file) {
        if (this.uploadingWallpaper != null && tL_wallPaper != null) {
            tL_wallPaper.settings = tL_wallPaperSettings;
            tL_wallPaper.flags |= 4;
            SharedPreferences.Editor edit = getGlobalMainSettings().edit();
            edit.putLong("selectedBackground2", tL_wallPaper.id);
            edit.putString("selectedBackgroundSlug", tL_wallPaper.slug);
            edit.commit();
            ArrayList<TLRPC.WallPaper> arrayList = new ArrayList<>();
            arrayList.add(tL_wallPaper);
            getMessagesStorage().putWallpapers(arrayList, 2);
            TLRPC.PhotoSize closestPhotoSizeWithSize = FileLoader.getClosestPhotoSizeWithSize(tL_wallPaper.document.thumbs, 320);
            if (closestPhotoSizeWithSize != null) {
                ImageLoader.getInstance().replaceImageInCache(Utilities.MD5(file.getAbsolutePath()) + "@100_100", closestPhotoSizeWithSize.location.volume_id + "_" + closestPhotoSizeWithSize.location.local_id + "@100_100", ImageLocation.getForDocument(closestPhotoSizeWithSize, tL_wallPaper.document), false);
            }
            NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.wallpapersNeedReload, Long.valueOf(tL_wallPaper.id));
        }
    }

    public /* synthetic */ void lambda$didReceivedNotification$16$MessagesController(Theme.ThemeInfo themeInfo, TLObject tLObject, TLRPC.TL_error tL_error) {
        int lastIndexOf = themeInfo.name.lastIndexOf(".attheme");
        String substring = lastIndexOf > 0 ? themeInfo.name.substring(0, lastIndexOf) : themeInfo.name;
        if (tLObject != null) {
            TLRPC.Document document = (TLRPC.Document) tLObject;
            TLRPC.TL_inputDocument tL_inputDocument = new TLRPC.TL_inputDocument();
            tL_inputDocument.access_hash = document.access_hash;
            tL_inputDocument.id = document.id;
            tL_inputDocument.file_reference = document.file_reference;
            if (themeInfo.info == null || !themeInfo.info.creator) {
                TLRPC.TL_account_createTheme tL_account_createTheme = new TLRPC.TL_account_createTheme();
                tL_account_createTheme.document = tL_inputDocument;
                tL_account_createTheme.slug = (themeInfo.info == null || TextUtils.isEmpty(themeInfo.info.slug)) ? "" : themeInfo.info.slug;
                tL_account_createTheme.title = substring;
                getConnectionsManager().sendRequest(tL_account_createTheme, new RequestDelegate(themeInfo) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$mKqYMW5cPNWbXPGFQqeBvhUh5Yg */
                    private final /* synthetic */ Theme.ThemeInfo f$1;

                    {
                        this.f$1 = r2;
                    }

                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        MessagesController.this.lambda$null$12$MessagesController(this.f$1, tLObject, tL_error);
                    }
                });
                return;
            }
            TLRPC.TL_account_updateTheme tL_account_updateTheme = new TLRPC.TL_account_updateTheme();
            TLRPC.TL_inputTheme tL_inputTheme = new TLRPC.TL_inputTheme();
            tL_inputTheme.id = themeInfo.info.id;
            tL_inputTheme.access_hash = themeInfo.info.access_hash;
            tL_account_updateTheme.theme = tL_inputTheme;
            tL_account_updateTheme.slug = themeInfo.info.slug;
            tL_account_updateTheme.flags |= 1;
            tL_account_updateTheme.title = substring;
            tL_account_updateTheme.flags |= 2;
            tL_account_updateTheme.document = tL_inputDocument;
            tL_account_updateTheme.flags |= 4;
            tL_account_updateTheme.format = "android";
            getConnectionsManager().sendRequest(tL_account_updateTheme, new RequestDelegate(themeInfo) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$CAJJ4tFWBHTcAwB0ZJ5wUyrcqIw */
                private final /* synthetic */ Theme.ThemeInfo f$1;

                {
                    this.f$1 = r2;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$null$14$MessagesController(this.f$1, tLObject, tL_error);
                }
            });
            return;
        }
        AndroidUtilities.runOnUIThread(new Runnable(themeInfo) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$CXP1JTm6hVhgfrRNUcmfx4sdfw */
            private final /* synthetic */ Theme.ThemeInfo f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                MessagesController.this.lambda$null$15$MessagesController(this.f$1);
            }
        });
    }

    public /* synthetic */ void lambda$null$12$MessagesController(Theme.ThemeInfo themeInfo, TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable(tLObject, themeInfo) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$o1sCZSy5qm_5jHE3K_6sgRcki8c */
            private final /* synthetic */ TLObject f$1;
            private final /* synthetic */ Theme.ThemeInfo f$2;

            {
                this.f$1 = r2;
                this.f$2 = r3;
            }

            public final void run() {
                MessagesController.this.lambda$null$11$MessagesController(this.f$1, this.f$2);
            }
        });
    }

    public /* synthetic */ void lambda$null$11$MessagesController(TLObject tLObject, Theme.ThemeInfo themeInfo) {
        if (tLObject instanceof TLRPC.TL_theme) {
            Theme.setThemeUploadInfo(themeInfo, (TLRPC.TL_theme) tLObject, false);
            installTheme(themeInfo, themeInfo == Theme.getCurrentNightTheme());
            getNotificationCenter().postNotificationName(NotificationCenter.themeUploadedToServer, themeInfo);
            return;
        }
        getNotificationCenter().postNotificationName(NotificationCenter.themeUploadError, themeInfo);
    }

    public /* synthetic */ void lambda$null$14$MessagesController(Theme.ThemeInfo themeInfo, TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable(tLObject, themeInfo) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$EhgYXW6Mq4Fp_61ha0ZJDXMFrq4 */
            private final /* synthetic */ TLObject f$1;
            private final /* synthetic */ Theme.ThemeInfo f$2;

            {
                this.f$1 = r2;
                this.f$2 = r3;
            }

            public final void run() {
                MessagesController.this.lambda$null$13$MessagesController(this.f$1, this.f$2);
            }
        });
    }

    public /* synthetic */ void lambda$null$13$MessagesController(TLObject tLObject, Theme.ThemeInfo themeInfo) {
        if (tLObject instanceof TLRPC.TL_theme) {
            Theme.setThemeUploadInfo(themeInfo, (TLRPC.TL_theme) tLObject, false);
            getNotificationCenter().postNotificationName(NotificationCenter.themeUploadedToServer, themeInfo);
            return;
        }
        getNotificationCenter().postNotificationName(NotificationCenter.themeUploadError, themeInfo);
    }

    public /* synthetic */ void lambda$null$15$MessagesController(Theme.ThemeInfo themeInfo) {
        getNotificationCenter().postNotificationName(NotificationCenter.themeUploadError, themeInfo);
    }

    public void cleanup() {
        getContactsController().cleanup();
        MediaController.getInstance().cleanup();
        getNotificationsController().cleanup();
        getSendMessagesHelper().cleanup();
        getSecretChatHelper().cleanup();
        getLocationController().cleanup();
        getMediaDataController().cleanup();
        DialogsActivity.dialogsLoaded[this.currentAccount] = false;
        this.notificationsPreferences.edit().clear().commit();
        this.emojiPreferences.edit().putLong("lastGifLoadTime", 0).putLong("lastStickersLoadTime", 0).putLong("lastStickersLoadTimeMask", 0).putLong("lastStickersLoadTimeFavs", 0).commit();
        this.mainPreferences.edit().remove("archivehint").remove("archivehint_l").remove("gifhint").remove("soundHint").remove("dcDomainName2").remove("webFileDatacenterId").remove("last_contacts_get_diff").remove("contacts_apply_id").remove("contacts_apply_hash").remove("contacts_apply_count").commit();
        this.lastScheduledServerQueryTime.clear();
        this.reloadingWebpages.clear();
        this.reloadingWebpagesPending.clear();
        this.reloadingScheduledWebpages.clear();
        this.reloadingScheduledWebpagesPending.clear();
        this.dialogs_dict.clear();
        this.dialogs_read_inbox_max.clear();
        this.loadingPinnedDialogs.clear();
        this.dialogs_read_outbox_max.clear();
        this.exportedChats.clear();
        this.fullUsers.clear();
        this.fullChats.clear();
        this.dialogsByFolder.clear();
        this.unreadUnmutedDialogs = 0;
        this.joiningToChannels.clear();
        this.migratedChats.clear();
        this.channelViewsToSend.clear();
        this.pollsToCheck.clear();
        this.pollsToCheckSize = 0;
        this.dialogsServerOnly.clear();
        this.dialogsForward.clear();
        this.allDialogs.clear();
        this.dialogsCanAddUsers.clear();
        this.dialogsChannelsOnly.clear();
        this.dialogsGroupsOnly.clear();
        this.dialogsUnreadOnly.clear();
        this.dialogsUsersOnly.clear();
        this.dialogMessagesByIds.clear();
        this.dialogMessagesByRandomIds.clear();
        this.channelAdmins.clear();
        this.loadingChannelAdmins.clear();
        this.users.clear();
        this.objectsByUsernames.clear();
        this.chats.clear();
        this.dialogMessage.clear();
        this.deletedHistory.clear();
        this.printingUsers.clear();
        this.printingStrings.clear();
        this.printingStringsTypes.clear();
        this.onlinePrivacy.clear();
        this.loadingPeerSettings.clear();
        this.deletingDialogs.clear();
        this.clearingHistoryDialogs.clear();
        this.lastPrintingStringCount = 0;
        Utilities.stageQueue.postRunnable(new Runnable() {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$UIZGh12B_kCdXU_VCv_kui30944 */

            public final void run() {
                MessagesController.this.lambda$cleanup$17$MessagesController();
            }
        });
        this.createdDialogMainThreadIds.clear();
        this.visibleDialogMainThreadIds.clear();
        this.visibleScheduledDialogMainThreadIds.clear();
        this.blockedUsers.clear();
        this.sendingTypings.clear();
        this.loadingFullUsers.clear();
        this.loadedFullUsers.clear();
        this.reloadingMessages.clear();
        this.loadingFullChats.clear();
        this.loadingFullParticipants.clear();
        this.loadedFullParticipants.clear();
        this.loadedFullChats.clear();
        this.dialogsLoaded = false;
        this.nextDialogsCacheOffset.clear();
        this.loadingDialogs.clear();
        this.dialogsEndReached.clear();
        this.serverDialogsEndReached.clear();
        this.loadingAppConfig = false;
        this.checkingTosUpdate = false;
        this.nextTosCheckTime = 0;
        this.nextProxyInfoCheckTime = 0;
        this.checkingProxyInfo = false;
        this.loadingUnreadDialogs = false;
        this.currentDeletingTaskTime = 0;
        this.currentDeletingTaskMids = null;
        this.currentDeletingTaskChannelId = 0;
        this.gettingNewDeleteTask = false;
        this.loadingBlockedUsers = false;
        this.totalBlockedCount = -1;
        this.blockedEndReached = false;
        this.firstGettingTask = false;
        this.updatingState = false;
        this.resetingDialogs = false;
        this.lastStatusUpdateTime = 0;
        this.offlineSent = false;
        this.registeringForPush = false;
        this.getDifferenceFirstSync = true;
        this.uploadingAvatar = null;
        this.uploadingWallpaper = null;
        this.uploadingThemes.clear();
        this.statusRequest = 0;
        this.statusSettingState = 0;
        Utilities.stageQueue.postRunnable(new Runnable() {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$Lw_38OHMn0H_IuZvLSHrpyPBwK8 */

            public final void run() {
                MessagesController.this.lambda$cleanup$18$MessagesController();
            }
        });
        if (this.currentDeleteTaskRunnable != null) {
            Utilities.stageQueue.cancelRunnable(this.currentDeleteTaskRunnable);
            this.currentDeleteTaskRunnable = null;
        }
        addSupportUser();
        getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
        AppPreferenceUtil.putString("PublishFcBean", "");
        FcDBHelper.getInstance().deleteAll(HomeFcListBean.class);
        FcDBHelper.getInstance().deleteAll(RecommendFcListBean.class);
        FcDBHelper.getInstance().deleteAll(FollowedFcListBean.class);
    }

    public /* synthetic */ void lambda$cleanup$17$MessagesController() {
        this.readTasks.clear();
        this.readTasksMap.clear();
        this.updatesQueueSeq.clear();
        this.updatesQueuePts.clear();
        this.updatesQueueQts.clear();
        this.gettingUnknownChannels.clear();
        this.gettingUnknownDialogs.clear();
        this.updatesStartWaitTimeSeq = 0;
        this.updatesStartWaitTimePts = 0;
        this.updatesStartWaitTimeQts = 0;
        this.createdDialogIds.clear();
        this.createdScheduledDialogIds.clear();
        this.gettingDifference = false;
        this.resetDialogsPinned = null;
        this.resetDialogsAll = null;
    }

    public /* synthetic */ void lambda$cleanup$18$MessagesController() {
        getConnectionsManager().setIsUpdating(false);
        this.updatesQueueChannels.clear();
        this.updatesStartWaitTimeChannels.clear();
        this.gettingDifferenceChannels.clear();
        this.channelsPts.clear();
        this.shortPollChannels.clear();
        this.needShortPollChannels.clear();
        this.shortPollOnlines.clear();
        this.needShortPollOnlines.clear();
    }

    public TLRPC.User getUser(Integer num) {
        return this.users.get(num);
    }

    public TLObject getUserOrChat(String str) {
        if (str == null || str.length() == 0) {
            return null;
        }
        return this.objectsByUsernames.get(str.toLowerCase());
    }

    public ConcurrentHashMap<Integer, TLRPC.User> getUsers() {
        return this.users;
    }

    public ConcurrentHashMap<Integer, TLRPC.Chat> getChats() {
        return this.chats;
    }

    public TLRPC.Chat getChat(Integer num) {
        return this.chats.get(num);
    }

    public TLRPC.EncryptedChat getEncryptedChat(Integer num) {
        return this.encryptedChats.get(num);
    }

    public TLRPC.EncryptedChat getEncryptedChatDB(int i, boolean z) {
        TLRPC.EncryptedChat encryptedChat = this.encryptedChats.get(Integer.valueOf(i));
        if (encryptedChat != null) {
            if (!z) {
                return encryptedChat;
            }
            if (!(encryptedChat instanceof TLRPC.TL_encryptedChatWaiting) && !(encryptedChat instanceof TLRPC.TL_encryptedChatRequested)) {
                return encryptedChat;
            }
        }
        CountDownLatch countDownLatch = new CountDownLatch(1);
        ArrayList<TLObject> arrayList = new ArrayList<>();
        getMessagesStorage().getEncryptedChat(i, countDownLatch, arrayList);
        try {
            countDownLatch.await();
        } catch (Exception e) {
            FileLog.e(e);
        }
        if (arrayList.size() != 2) {
            return encryptedChat;
        }
        TLRPC.EncryptedChat encryptedChat2 = (TLRPC.EncryptedChat) arrayList.get(0);
        putEncryptedChat(encryptedChat2, false);
        putUser((TLRPC.User) arrayList.get(1), true);
        return encryptedChat2;
    }

    public boolean isDialogVisible(long j, boolean z) {
        return (z ? this.visibleScheduledDialogMainThreadIds : this.visibleDialogMainThreadIds).contains(Long.valueOf(j));
    }

    public void setLastVisibleDialogId(long j, boolean z, boolean z2) {
        ArrayList<Long> arrayList = z ? this.visibleScheduledDialogMainThreadIds : this.visibleDialogMainThreadIds;
        if (!z2) {
            arrayList.remove(Long.valueOf(j));
        } else if (!arrayList.contains(Long.valueOf(j))) {
            arrayList.add(Long.valueOf(j));
        }
    }

    public void setLastCreatedDialogId(long j, boolean z, boolean z2) {
        if (!z) {
            ArrayList<Long> arrayList = this.createdDialogMainThreadIds;
            if (!z2) {
                arrayList.remove(Long.valueOf(j));
                SparseArray<MessageObject> sparseArray = this.pollsToCheck.get(j);
                if (sparseArray != null) {
                    int size = sparseArray.size();
                    for (int i = 0; i < size; i++) {
                        sparseArray.valueAt(i).pollVisibleOnScreen = false;
                    }
                }
            } else if (!arrayList.contains(Long.valueOf(j))) {
                arrayList.add(Long.valueOf(j));
            } else {
                return;
            }
        }
        Utilities.stageQueue.postRunnable(new Runnable(z, z2, j) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$iJxWY9wGtqRxiNrJlQQtUviSU */
            private final /* synthetic */ boolean f$1;
            private final /* synthetic */ boolean f$2;
            private final /* synthetic */ long f$3;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
            }

            public final void run() {
                MessagesController.this.lambda$setLastCreatedDialogId$19$MessagesController(this.f$1, this.f$2, this.f$3);
            }
        });
    }

    public /* synthetic */ void lambda$setLastCreatedDialogId$19$MessagesController(boolean z, boolean z2, long j) {
        ArrayList<Long> arrayList = z ? this.createdScheduledDialogIds : this.createdDialogIds;
        if (!z2) {
            arrayList.remove(Long.valueOf(j));
        } else if (!arrayList.contains(Long.valueOf(j))) {
            arrayList.add(Long.valueOf(j));
        }
    }

    public TLRPC.ExportedChatInvite getExportedInvite(int i) {
        return this.exportedChats.get(i);
    }

    public boolean putUser(TLRPC.User user, boolean z) {
        if (user == null) {
            return false;
        }
        boolean z2 = (!z || user.id / 1000 == 333 || user.id == 777000) ? false : true;
        TLRPC.User user2 = this.users.get(Integer.valueOf(user.id));
        if (user2 == user) {
            return false;
        }
        if (user2 != null && !TextUtils.isEmpty(user2.username)) {
            this.objectsByUsernames.remove(user2.username.toLowerCase());
        }
        if (!TextUtils.isEmpty(user.username)) {
            this.objectsByUsernames.put(user.username.toLowerCase(), user);
        }
        if (user.min) {
            if (user2 == null) {
                this.users.put(Integer.valueOf(user.id), user);
            } else if (!z2) {
                if (user.bot) {
                    if (user.username != null) {
                        user2.username = user.username;
                        user2.flags |= 8;
                    } else {
                        user2.flags &= -9;
                        user2.username = null;
                    }
                }
                if (user.photo != null) {
                    user2.photo = user.photo;
                    user2.flags |= 32;
                } else {
                    user2.flags &= -33;
                    user2.photo = null;
                }
            }
        } else if (!z2) {
            this.users.put(Integer.valueOf(user.id), user);
            if (user.id == getUserConfig().getClientUserId()) {
                getUserConfig().setCurrentUser(user);
                getUserConfig().saveConfig(true);
            }
            return (user2 == null || user.status == null || user2.status == null || user.status.expires == user2.status.expires) ? false : true;
        } else if (user2 == null) {
            this.users.put(Integer.valueOf(user.id), user);
        } else if (user2.min) {
            user.min = false;
            if (user2.bot) {
                if (user2.username != null) {
                    user.username = user2.username;
                    user.flags |= 8;
                } else {
                    user.flags &= -9;
                    user.username = null;
                }
            }
            if (user2.photo != null) {
                user.photo = user2.photo;
                user.flags |= 32;
            } else {
                user.flags &= -33;
                user.photo = null;
            }
            this.users.put(Integer.valueOf(user.id), user);
        }
    }

    public void putUsers(ArrayList<TLRPC.User> arrayList, boolean z) {
        if (!(arrayList == null || arrayList.isEmpty())) {
            int size = arrayList.size();
            boolean z2 = false;
            for (int i = 0; i < size; i++) {
                if (putUser(arrayList.get(i), z)) {
                    z2 = true;
                }
            }
            if (z2) {
                AndroidUtilities.runOnUIThread(new Runnable() {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$wbLKlcUshVx7ns11IwiO0SLuAo */

                    public final void run() {
                        MessagesController.this.lambda$putUsers$20$MessagesController();
                    }
                });
            }
        }
    }

    public /* synthetic */ void lambda$putUsers$20$MessagesController() {
        getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 4);
    }

    public void putChat(TLRPC.Chat chat, boolean z) {
        TLRPC.Chat chat2;
        if (chat != null && (chat2 = this.chats.get(Integer.valueOf(chat.id))) != chat) {
            if (chat2 != null && !TextUtils.isEmpty(chat2.username)) {
                this.objectsByUsernames.remove(chat2.username.toLowerCase());
            }
            if (!TextUtils.isEmpty(chat.username)) {
                this.objectsByUsernames.put(chat.username.toLowerCase(), chat);
            }
            if (!chat.min) {
                int i = 0;
                if (!z) {
                    if (chat2 != null) {
                        if (chat.version != chat2.version) {
                            this.loadedFullChats.remove(Integer.valueOf(chat.id));
                        }
                        if (chat2.participants_count != 0 && chat.participants_count == 0) {
                            chat.participants_count = chat2.participants_count;
                            chat.flags |= 131072;
                        }
                        int i2 = chat2.banned_rights != null ? chat2.banned_rights.flags : 0;
                        int i3 = chat.banned_rights != null ? chat.banned_rights.flags : 0;
                        int i4 = chat2.default_banned_rights != null ? chat2.default_banned_rights.flags : 0;
                        if (chat.default_banned_rights != null) {
                            i = chat.default_banned_rights.flags;
                        }
                        chat2.default_banned_rights = chat.default_banned_rights;
                        if (chat2.default_banned_rights == null) {
                            chat2.flags &= -262145;
                        } else {
                            chat2.flags = 262144 | chat2.flags;
                        }
                        chat2.banned_rights = chat.banned_rights;
                        if (chat2.banned_rights == null) {
                            chat2.flags &= -32769;
                        } else {
                            chat2.flags = 32768 | chat2.flags;
                        }
                        chat2.admin_rights = chat.admin_rights;
                        if (chat2.admin_rights == null) {
                            chat2.flags &= -16385;
                        } else {
                            chat2.flags |= 16384;
                        }
                        if (!(i2 == i3 && i4 == i)) {
                            AndroidUtilities.runOnUIThread(new Runnable(chat) {
                                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$tqQ2Tx4opFiBFWP0jZa6MVxB01E */
                                private final /* synthetic */ TLRPC.Chat f$1;

                                {
                                    this.f$1 = r2;
                                }

                                public final void run() {
                                    MessagesController.this.lambda$putChat$21$MessagesController(this.f$1);
                                }
                            });
                        }
                    }
                    this.chats.put(Integer.valueOf(chat.id), chat);
                } else if (chat2 == null) {
                    this.chats.put(Integer.valueOf(chat.id), chat);
                } else if (chat2.min) {
                    chat.min = false;
                    chat.title = chat2.title;
                    chat.photo = chat2.photo;
                    chat.broadcast = chat2.broadcast;
                    chat.verified = chat2.verified;
                    chat.megagroup = chat2.megagroup;
                    if (chat2.default_banned_rights != null) {
                        chat.default_banned_rights = chat2.default_banned_rights;
                        chat.flags |= 262144;
                    }
                    if (chat2.admin_rights != null) {
                        chat.admin_rights = chat2.admin_rights;
                        chat.flags |= 16384;
                    }
                    if (chat2.banned_rights != null) {
                        chat.banned_rights = chat2.banned_rights;
                        chat.flags |= 32768;
                    }
                    if (chat2.username != null) {
                        chat.username = chat2.username;
                        chat.flags |= 64;
                    } else {
                        chat.flags &= -65;
                        chat.username = null;
                    }
                    if (chat2.participants_count != 0 && chat.participants_count == 0) {
                        chat.participants_count = chat2.participants_count;
                        chat.flags |= 131072;
                    }
                    this.chats.put(Integer.valueOf(chat.id), chat);
                }
            } else if (chat2 == null) {
                this.chats.put(Integer.valueOf(chat.id), chat);
            } else if (!z) {
                chat2.title = chat.title;
                chat2.photo = chat.photo;
                chat2.broadcast = chat.broadcast;
                chat2.verified = chat.verified;
                chat2.megagroup = chat.megagroup;
                if (chat.default_banned_rights != null) {
                    chat2.default_banned_rights = chat.default_banned_rights;
                    chat2.flags |= 262144;
                }
                if (chat.admin_rights != null) {
                    chat2.admin_rights = chat.admin_rights;
                    chat2.flags |= 16384;
                }
                if (chat.banned_rights != null) {
                    chat2.banned_rights = chat.banned_rights;
                    chat2.flags |= 32768;
                }
                if (chat.username != null) {
                    chat2.username = chat.username;
                    chat2.flags |= 64;
                } else {
                    chat2.flags &= -65;
                    chat2.username = null;
                }
                if (chat.participants_count != 0) {
                    chat2.participants_count = chat.participants_count;
                }
            }
        }
    }

    public /* synthetic */ void lambda$putChat$21$MessagesController(TLRPC.Chat chat) {
        getNotificationCenter().postNotificationName(NotificationCenter.channelRightsUpdated, chat);
    }

    public void putChats(ArrayList<TLRPC.Chat> arrayList, boolean z) {
        if (!(arrayList == null || arrayList.isEmpty())) {
            int size = arrayList.size();
            for (int i = 0; i < size; i++) {
                putChat(arrayList.get(i), z);
            }
        }
    }

    public void setReferer(String str) {
        if (str != null) {
            this.installReferer = str;
            this.mainPreferences.edit().putString("installReferer", str).commit();
        }
    }

    public void putEncryptedChat(TLRPC.EncryptedChat encryptedChat, boolean z) {
        if (encryptedChat != null) {
            if (z) {
                this.encryptedChats.putIfAbsent(Integer.valueOf(encryptedChat.id), encryptedChat);
            } else {
                this.encryptedChats.put(Integer.valueOf(encryptedChat.id), encryptedChat);
            }
        }
    }

    public void putEncryptedChats(ArrayList<TLRPC.EncryptedChat> arrayList, boolean z) {
        if (!(arrayList == null || arrayList.isEmpty())) {
            int size = arrayList.size();
            for (int i = 0; i < size; i++) {
                putEncryptedChat(arrayList.get(i), z);
            }
        }
    }

    public TLRPC.UserFull getUserFull(int i) {
        return this.fullUsers.get(i);
    }

    public TLRPC.ChatFull getChatFull(int i) {
        return this.fullChats.get(i);
    }

    public void cancelLoadFullUser(int i) {
        this.loadingFullUsers.remove(Integer.valueOf(i));
    }

    public void cancelLoadFullChat(int i) {
        this.loadingFullChats.remove(Integer.valueOf(i));
    }

    /* access modifiers changed from: protected */
    public void clearFullUsers() {
        this.loadedFullUsers.clear();
        this.loadedFullChats.clear();
    }

    private void reloadDialogsReadValue(ArrayList<TLRPC.Dialog> arrayList, long j) {
        if (j != 0 || (arrayList != null && !arrayList.isEmpty())) {
            TLRPC.TL_messages_getPeerDialogs tL_messages_getPeerDialogs = new TLRPC.TL_messages_getPeerDialogs();
            if (arrayList != null) {
                for (int i = 0; i < arrayList.size(); i++) {
                    TLRPC.InputPeer inputPeer = getInputPeer((int) arrayList.get(i).id);
                    if (!(inputPeer instanceof TLRPC.TL_inputPeerChannel) || inputPeer.access_hash != 0) {
                        TLRPC.TL_inputDialogPeer tL_inputDialogPeer = new TLRPC.TL_inputDialogPeer();
                        tL_inputDialogPeer.peer = inputPeer;
                        tL_messages_getPeerDialogs.peers.add(tL_inputDialogPeer);
                    }
                }
            } else {
                TLRPC.InputPeer inputPeer2 = getInputPeer((int) j);
                if (!(inputPeer2 instanceof TLRPC.TL_inputPeerChannel) || inputPeer2.access_hash != 0) {
                    TLRPC.TL_inputDialogPeer tL_inputDialogPeer2 = new TLRPC.TL_inputDialogPeer();
                    tL_inputDialogPeer2.peer = inputPeer2;
                    tL_messages_getPeerDialogs.peers.add(tL_inputDialogPeer2);
                } else {
                    return;
                }
            }
            if (!tL_messages_getPeerDialogs.peers.isEmpty()) {
                getConnectionsManager().sendRequest(tL_messages_getPeerDialogs, new RequestDelegate() {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$ciCgL7gWarb6UeRRpyHr1l5hJRs */

                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        MessagesController.this.lambda$reloadDialogsReadValue$22$MessagesController(tLObject, tL_error);
                    }
                });
            }
        }
    }

    public /* synthetic */ void lambda$reloadDialogsReadValue$22$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tLObject != null) {
            TLRPC.TL_messages_peerDialogs tL_messages_peerDialogs = (TLRPC.TL_messages_peerDialogs) tLObject;
            ArrayList<TLRPC.Update> arrayList = new ArrayList<>();
            for (int i = 0; i < tL_messages_peerDialogs.dialogs.size(); i++) {
                TLRPC.Dialog dialog = tL_messages_peerDialogs.dialogs.get(i);
                if (dialog.read_inbox_max_id == 0) {
                    dialog.read_inbox_max_id = 1;
                }
                if (dialog.read_outbox_max_id == 0) {
                    dialog.read_outbox_max_id = 1;
                }
                DialogObject.initDialog(dialog);
                Integer num = this.dialogs_read_inbox_max.get(Long.valueOf(dialog.id));
                if (num == null) {
                    num = 0;
                }
                this.dialogs_read_inbox_max.put(Long.valueOf(dialog.id), Integer.valueOf(Math.max(dialog.read_inbox_max_id, num.intValue())));
                if (num.intValue() == 0) {
                    if (dialog.peer.channel_id != 0) {
                        TLRPC.TL_updateReadChannelInbox tL_updateReadChannelInbox = new TLRPC.TL_updateReadChannelInbox();
                        tL_updateReadChannelInbox.channel_id = dialog.peer.channel_id;
                        tL_updateReadChannelInbox.max_id = dialog.read_inbox_max_id;
                        arrayList.add(tL_updateReadChannelInbox);
                    } else {
                        TLRPC.TL_updateReadHistoryInbox tL_updateReadHistoryInbox = new TLRPC.TL_updateReadHistoryInbox();
                        tL_updateReadHistoryInbox.peer = dialog.peer;
                        tL_updateReadHistoryInbox.max_id = dialog.read_inbox_max_id;
                        arrayList.add(tL_updateReadHistoryInbox);
                    }
                }
                Integer num2 = this.dialogs_read_outbox_max.get(Long.valueOf(dialog.id));
                if (num2 == null) {
                    num2 = 0;
                }
                this.dialogs_read_outbox_max.put(Long.valueOf(dialog.id), Integer.valueOf(Math.max(dialog.read_outbox_max_id, num2.intValue())));
                if (num2.intValue() == 0) {
                    if (dialog.peer.channel_id != 0) {
                        TLRPC.TL_updateReadChannelOutbox tL_updateReadChannelOutbox = new TLRPC.TL_updateReadChannelOutbox();
                        tL_updateReadChannelOutbox.channel_id = dialog.peer.channel_id;
                        tL_updateReadChannelOutbox.max_id = dialog.read_outbox_max_id;
                        arrayList.add(tL_updateReadChannelOutbox);
                    } else {
                        TLRPC.TL_updateReadHistoryOutbox tL_updateReadHistoryOutbox = new TLRPC.TL_updateReadHistoryOutbox();
                        tL_updateReadHistoryOutbox.peer = dialog.peer;
                        tL_updateReadHistoryOutbox.max_id = dialog.read_outbox_max_id;
                        arrayList.add(tL_updateReadHistoryOutbox);
                    }
                }
            }
            if (!arrayList.isEmpty()) {
                processUpdateArray(arrayList, null, null, false, 0);
            }
        }
    }

    public String getAdminRank(int i, int i2) {
        SparseArray<String> sparseArray = this.channelAdmins.get(i);
        if (sparseArray == null) {
            return null;
        }
        return sparseArray.get(i2);
    }

    public boolean isChannelAdminsLoaded(int i) {
        return this.channelAdmins.get(i) != null;
    }

    public void loadChannelAdmins(int i, boolean z) {
        if (SystemClock.uptimeMillis() - ((long) this.loadingChannelAdmins.get(i)) >= 60) {
            this.loadingChannelAdmins.put(i, (int) (SystemClock.uptimeMillis() / 1000));
            if (z) {
                getMessagesStorage().loadChannelAdmins(i);
                return;
            }
            TLRPC.TL_channels_getParticipants tL_channels_getParticipants = new TLRPC.TL_channels_getParticipants();
            tL_channels_getParticipants.channel = getInputChannel(i);
            tL_channels_getParticipants.limit = 100;
            tL_channels_getParticipants.filter = new TLRPC.TL_channelParticipantsAdmins();
            getConnectionsManager().sendRequest(tL_channels_getParticipants, new RequestDelegate(i) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$PATkPRvYhppP6HXGZcifqVpU_E */
                private final /* synthetic */ int f$1;

                {
                    this.f$1 = r2;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$loadChannelAdmins$23$MessagesController(this.f$1, tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$loadChannelAdmins$23$MessagesController(int i, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tLObject instanceof TLRPC.TL_channels_channelParticipants) {
            processLoadedAdminsResponse(i, (TLRPC.TL_channels_channelParticipants) tLObject);
        }
    }

    public void processLoadedAdminsResponse(int i, TLRPC.TL_channels_channelParticipants tL_channels_channelParticipants) {
        SparseArray<String> sparseArray = new SparseArray<>(tL_channels_channelParticipants.participants.size());
        for (int i2 = 0; i2 < tL_channels_channelParticipants.participants.size(); i2++) {
            TLRPC.ChannelParticipant channelParticipant = (TLRPC.ChannelParticipant) tL_channels_channelParticipants.participants.get(i2);
            sparseArray.put(channelParticipant.user_id, channelParticipant.rank != null ? channelParticipant.rank : "");
        }
        processLoadedChannelAdmins(sparseArray, i, false);
    }

    public void processLoadedChannelAdmins(SparseArray<String> sparseArray, int i, boolean z) {
        if (!z) {
            getMessagesStorage().putChannelAdmins(i, sparseArray);
        }
        AndroidUtilities.runOnUIThread(new Runnable(i, sparseArray, z) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$g3IcATlnTe6ojhq7F5Qgzzj6Y */
            private final /* synthetic */ int f$1;
            private final /* synthetic */ SparseArray f$2;
            private final /* synthetic */ boolean f$3;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
            }

            public final void run() {
                MessagesController.this.lambda$processLoadedChannelAdmins$24$MessagesController(this.f$1, this.f$2, this.f$3);
            }
        });
    }

    public /* synthetic */ void lambda$processLoadedChannelAdmins$24$MessagesController(int i, SparseArray sparseArray, boolean z) {
        this.channelAdmins.put(i, sparseArray);
        if (z) {
            this.loadingChannelAdmins.delete(i);
            loadChannelAdmins(i, false);
        }
    }

    public void loadUsers(int[] iArr, long[] jArr, int i) {
        if (!(iArr == null || jArr == null || iArr.length != jArr.length)) {
            ArrayList<Integer> arrayList = new ArrayList<>();
            if (this.users != null) {
                for (int i2 : iArr) {
                    TLRPC.User user = this.users.get(Integer.valueOf(i2));
                    if (user != null) {
                        getNotificationCenter().postNotificationName(NotificationCenter.userInfoDidLoad, Integer.valueOf(user.id), user);
                    } else {
                        arrayList.add(Integer.valueOf(i2));
                    }
                }
                if (arrayList.size() > 0) {
                    loadUsers(arrayList, jArr, i);
                }
            }
        }
    }

    public void loadUsers(ArrayList<Integer> arrayList, long[] jArr, int i) {
        if (!(arrayList == null || jArr == null || arrayList.size() != jArr.length)) {
            ArrayList<TLRPC.InputUser> arrayList2 = new ArrayList<>();
            for (int i2 = 0; i2 < arrayList.size(); i2++) {
                TLRPC.TL_inputUser tL_inputUser = new TLRPC.TL_inputUser();
                tL_inputUser.user_id = arrayList.get(i2).intValue();
                tL_inputUser.access_hash = jArr[i2];
                arrayList2.add(tL_inputUser);
            }
            loadUsers(arrayList2, i);
        }
    }

    public void loadUsers(ArrayList<TLRPC.InputUser> arrayList, int i) {
        if (arrayList != null) {
            TLRPC.TL_users_getUsers tL_users_getUsers = new TLRPC.TL_users_getUsers();
            tL_users_getUsers.id.addAll(arrayList);
            getConnectionsManager().bindRequestToGuid(getConnectionsManager().sendRequest(tL_users_getUsers, new RequestDelegate() {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$dZ3l8zvDEJmT6T_Z7SjRO_gKY1s */

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$loadUsers$26$MessagesController(tLObject, tL_error);
                }
            }), i);
        }
    }

    public /* synthetic */ void lambda$loadUsers$26$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tLObject instanceof TLRPC.Vector) {
            TLRPC.Vector vector = (TLRPC.Vector) tLObject;
            if (!vector.objects.isEmpty()) {
                for (int i = 0; i < vector.objects.size(); i++) {
                    ArrayList<TLRPC.User> arrayList = new ArrayList<>();
                    TLRPC.User user = (TLRPC.User) vector.objects.get(i);
                    arrayList.add(user);
                    getMessagesStorage().putUsersAndChats(arrayList, null, false, true);
                    AndroidUtilities.runOnUIThread(new Runnable(user) {
                        /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$ztwdlEuaeTPgWLihlILN3djBr1I */
                        private final /* synthetic */ TLRPC.User f$1;

                        {
                            this.f$1 = r2;
                        }

                        public final void run() {
                            MessagesController.this.lambda$null$25$MessagesController(this.f$1);
                        }
                    });
                }
            }
        }
    }

    public /* synthetic */ void lambda$null$25$MessagesController(TLRPC.User user) {
        putUser(user, false);
        getNotificationCenter().postNotificationName(NotificationCenter.userInfoDidLoad, Integer.valueOf(user.id), user);
    }

    /* JADX DEBUG: Multi-variable search result rejected for r12v8, resolved type: im.guobwnxjuc.tgnet.TLRPC$TL_channels_getFullChannel */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARNING: Code restructure failed: missing block: B:12:0x0066, code lost:
        if (r9.dialogs_read_outbox_max.get(java.lang.Long.valueOf(r4)) == null) goto L_0x0068;
     */
    public void loadFullChat(int i, int i2, boolean z) {
        TLRPC.TL_messages_getFullChat tL_messages_getFullChat;
        boolean contains = this.loadedFullChats.contains(Integer.valueOf(i));
        if (this.loadingFullChats.contains(Integer.valueOf(i))) {
            return;
        }
        if (z || !contains) {
            this.loadingFullChats.add(Integer.valueOf(i));
            long j = (long) (-i);
            TLRPC.Chat chat = getChat(Integer.valueOf(i));
            if (ChatObject.isChannel(chat)) {
                TLRPC.TL_channels_getFullChannel tL_channels_getFullChannel = new TLRPC.TL_channels_getFullChannel();
                tL_channels_getFullChannel.channel = getInputChannel(chat);
                tL_messages_getFullChat = tL_channels_getFullChannel;
                if (chat.megagroup) {
                    loadChannelAdmins(i, !contains);
                    tL_messages_getFullChat = tL_channels_getFullChannel;
                }
            } else {
                TLRPC.TL_messages_getFullChat tL_messages_getFullChat2 = new TLRPC.TL_messages_getFullChat();
                tL_messages_getFullChat2.chat_id = i;
                if (this.dialogs_read_inbox_max.get(Long.valueOf(j)) != null) {
                    tL_messages_getFullChat = tL_messages_getFullChat2;
                }
                reloadDialogsReadValue(null, j);
                tL_messages_getFullChat = tL_messages_getFullChat2;
            }
            int sendRequest = getConnectionsManager().sendRequest(tL_messages_getFullChat, new RequestDelegate(chat, j, i, i2) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$yt8iaHN47XL3PqBnnsHOhlj4ngk */
                private final /* synthetic */ TLRPC.Chat f$1;
                private final /* synthetic */ long f$2;
                private final /* synthetic */ int f$3;
                private final /* synthetic */ int f$4;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                    this.f$3 = r5;
                    this.f$4 = r6;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$loadFullChat$29$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, tLObject, tL_error);
                }
            });
            if (i2 != 0) {
                getConnectionsManager().bindRequestToGuid(sendRequest, i2);
            }
        }
    }

    public /* synthetic */ void lambda$loadFullChat$29$MessagesController(TLRPC.Chat chat, long j, int i, int i2, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            TLRPC.TL_messages_chatFull tL_messages_chatFull = (TLRPC.TL_messages_chatFull) tLObject;
            getMessagesStorage().putUsersAndChats(tL_messages_chatFull.users, tL_messages_chatFull.chats, true, true);
            getMessagesStorage().updateChatInfo(tL_messages_chatFull.full_chat, false);
            if (ChatObject.isChannel(chat)) {
                Integer num = this.dialogs_read_inbox_max.get(Long.valueOf(j));
                if (num == null) {
                    num = Integer.valueOf(getMessagesStorage().getDialogReadMax(false, j));
                }
                this.dialogs_read_inbox_max.put(Long.valueOf(j), Integer.valueOf(Math.max(tL_messages_chatFull.full_chat.read_inbox_max_id, num.intValue())));
                if (num.intValue() == 0) {
                    ArrayList<TLRPC.Update> arrayList = new ArrayList<>();
                    TLRPC.TL_updateReadChannelInbox tL_updateReadChannelInbox = new TLRPC.TL_updateReadChannelInbox();
                    tL_updateReadChannelInbox.channel_id = i;
                    tL_updateReadChannelInbox.max_id = tL_messages_chatFull.full_chat.read_inbox_max_id;
                    arrayList.add(tL_updateReadChannelInbox);
                    processUpdateArray(arrayList, null, null, false, 0);
                }
                Integer num2 = this.dialogs_read_outbox_max.get(Long.valueOf(j));
                if (num2 == null) {
                    num2 = Integer.valueOf(getMessagesStorage().getDialogReadMax(true, j));
                }
                this.dialogs_read_outbox_max.put(Long.valueOf(j), Integer.valueOf(Math.max(tL_messages_chatFull.full_chat.read_outbox_max_id, num2.intValue())));
                if (num2.intValue() == 0) {
                    ArrayList<TLRPC.Update> arrayList2 = new ArrayList<>();
                    TLRPC.TL_updateReadChannelOutbox tL_updateReadChannelOutbox = new TLRPC.TL_updateReadChannelOutbox();
                    tL_updateReadChannelOutbox.channel_id = i;
                    tL_updateReadChannelOutbox.max_id = tL_messages_chatFull.full_chat.read_outbox_max_id;
                    arrayList2.add(tL_updateReadChannelOutbox);
                    processUpdateArray(arrayList2, null, null, false, 0);
                }
            }
            AndroidUtilities.runOnUIThread(new Runnable(i, tL_messages_chatFull, i2) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$QvcySUs5aJ_5MGyxuNwKYotForY */
                private final /* synthetic */ int f$1;
                private final /* synthetic */ TLRPC.TL_messages_chatFull f$2;
                private final /* synthetic */ int f$3;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                    this.f$3 = r4;
                }

                public final void run() {
                    MessagesController.this.lambda$null$27$MessagesController(this.f$1, this.f$2, this.f$3);
                }
            });
            return;
        }
        AndroidUtilities.runOnUIThread(new Runnable(tL_error, i) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$2mBzQu4fRGBPXNCHC13QxoFmfXA */
            private final /* synthetic */ TLRPC.TL_error f$1;
            private final /* synthetic */ int f$2;

            {
                this.f$1 = r2;
                this.f$2 = r3;
            }

            public final void run() {
                MessagesController.this.lambda$null$28$MessagesController(this.f$1, this.f$2);
            }
        });
    }

    public /* synthetic */ void lambda$null$27$MessagesController(int i, TLRPC.TL_messages_chatFull tL_messages_chatFull, int i2) {
        this.fullChats.put(i, tL_messages_chatFull.full_chat);
        applyDialogNotificationsSettings((long) (-i), tL_messages_chatFull.full_chat.notify_settings);
        for (int i3 = 0; i3 < tL_messages_chatFull.full_chat.bot_info.size(); i3++) {
            getMediaDataController().putBotInfo(tL_messages_chatFull.full_chat.bot_info.get(i3));
        }
        this.exportedChats.put(i, tL_messages_chatFull.full_chat.exported_invite);
        this.loadingFullChats.remove(Integer.valueOf(i));
        this.loadedFullChats.add(Integer.valueOf(i));
        putUsers(tL_messages_chatFull.users, false);
        putChats(tL_messages_chatFull.chats, false);
        if (tL_messages_chatFull.full_chat.stickerset != null) {
            getMediaDataController().getGroupStickerSetById(tL_messages_chatFull.full_chat.stickerset);
        }
        getNotificationCenter().postNotificationName(NotificationCenter.chatInfoDidLoad, tL_messages_chatFull.full_chat, Integer.valueOf(i2), false, null);
    }

    public /* synthetic */ void lambda$null$28$MessagesController(TLRPC.TL_error tL_error, int i) {
        checkChannelError(tL_error.text, i);
        this.loadingFullChats.remove(Integer.valueOf(i));
    }

    public void loadFullUser(TLRPC.User user, int i, boolean z) {
        loadFullUser(user, 0, i, z);
    }

    public void loadFullUser(int i, int i2, boolean z) {
        loadFullUser(null, i, i2, z);
    }

    public void loadFullUser(TLRPC.User user, int i, int i2, boolean z) {
        if (user == null || this.loadingFullUsers.contains(Integer.valueOf(user.id)) || (!z && this.loadedFullUsers.contains(Integer.valueOf(user.id)))) {
            if (i != 0 && !this.loadingFullUsers.contains(Integer.valueOf(i))) {
                if (!z && this.loadedFullUsers.contains(Integer.valueOf(i))) {
                    return;
                }
            } else {
                return;
            }
        }
        int i3 = user != null ? user.id : i;
        this.loadingFullUsers.add(Integer.valueOf(i3));
        TLRPCContacts.CL_user_getFulluser cL_user_getFulluser = new TLRPCContacts.CL_user_getFulluser();
        cL_user_getFulluser.inputUser = user != null ? getInputUser(user) : getInputUser(i);
        long j = (long) i3;
        if (this.dialogs_read_inbox_max.get(Long.valueOf(j)) == null || this.dialogs_read_outbox_max.get(Long.valueOf(j)) == null) {
            reloadDialogsReadValue(null, j);
        }
        getConnectionsManager().bindRequestToGuid(getConnectionsManager().sendRequest(cL_user_getFulluser, new RequestDelegate(i3, user, i2) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$ik0wnKIuQBeDkp1sZG6M_LEg_vQ */
            private final /* synthetic */ int f$1;
            private final /* synthetic */ TLRPC.User f$2;
            private final /* synthetic */ int f$3;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
            }

            @Override // im.guobwnxjuc.tgnet.RequestDelegate
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                MessagesController.this.lambda$loadFullUser$32$MessagesController(this.f$1, this.f$2, this.f$3, tLObject, tL_error);
            }
        }), i2);
    }

    public /* synthetic */ void lambda$loadFullUser$32$MessagesController(int i, TLRPC.User user, int i2, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            TLRPC.UserFull userFull = (TLRPC.UserFull) tLObject;
            getMessagesStorage().updateUserInfo(userFull, false);
            AndroidUtilities.runOnUIThread(new Runnable(userFull, i, user, i2) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$dOQeLaT1CggbGuaaTS4PdX44g5E */
                private final /* synthetic */ TLRPC.UserFull f$1;
                private final /* synthetic */ int f$2;
                private final /* synthetic */ TLRPC.User f$3;
                private final /* synthetic */ int f$4;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                    this.f$3 = r4;
                    this.f$4 = r5;
                }

                public final void run() {
                    MessagesController.this.lambda$null$30$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4);
                }
            });
            return;
        }
        AndroidUtilities.runOnUIThread(new Runnable(i) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$FRFMJqiQPpSqNQ4YMeImSPTuFwQ */
            private final /* synthetic */ int f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                MessagesController.this.lambda$null$31$MessagesController(this.f$1);
            }
        });
    }

    public /* synthetic */ void lambda$null$30$MessagesController(TLRPC.UserFull userFull, int i, TLRPC.User user, int i2) {
        String str;
        savePeerSettings((long) userFull.user.id, userFull.settings, false);
        applyDialogNotificationsSettings((long) i, userFull.notify_settings);
        if (userFull.bot_info instanceof TLRPC.TL_botInfo) {
            getMediaDataController().putBotInfo(userFull.bot_info);
        }
        int indexOfKey = this.blockedUsers.indexOfKey(i);
        if (userFull.blocked) {
            if (indexOfKey < 0) {
                this.blockedUsers.put(i, 1);
                getNotificationCenter().postNotificationName(NotificationCenter.blockedUsersDidLoad, new Object[0]);
            }
        } else if (indexOfKey >= 0) {
            this.blockedUsers.removeAt(indexOfKey);
            getNotificationCenter().postNotificationName(NotificationCenter.blockedUsersDidLoad, new Object[0]);
        }
        this.fullUsers.put(i, userFull);
        this.loadingFullUsers.remove(Integer.valueOf(i));
        this.loadedFullUsers.add(Integer.valueOf(i));
        if (user != null) {
            str = user.first_name + user.last_name + user.username;
        } else {
            str = null;
        }
        ArrayList<TLRPC.User> arrayList = new ArrayList<>();
        arrayList.add(userFull.user);
        putUsers(arrayList, false);
        getMessagesStorage().putUsersAndChats(arrayList, null, false, true);
        if (str != null) {
            if (!str.equals(userFull.user.first_name + userFull.user.last_name + userFull.user.username)) {
                getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 1);
            }
        }
        if (userFull.bot_info instanceof TLRPC.TL_botInfo) {
            getNotificationCenter().postNotificationName(NotificationCenter.botInfoDidLoad, userFull.bot_info, Integer.valueOf(i2));
        }
        getNotificationCenter().postNotificationName(NotificationCenter.userFullInfoDidLoad, Integer.valueOf(i), userFull, 0);
    }

    public /* synthetic */ void lambda$null$31$MessagesController(int i) {
        this.loadingFullUsers.remove(Integer.valueOf(i));
    }

    /* JADX DEBUG: Multi-variable search result rejected for r0v5, resolved type: im.guobwnxjuc.tgnet.TLRPC$TL_channels_getMessages */
    /* JADX WARN: Multi-variable type inference failed */
    private void reloadMessages(ArrayList<Integer> arrayList, long j, boolean z) {
        TLRPC.TL_messages_getMessages tL_messages_getMessages;
        if (!arrayList.isEmpty()) {
            ArrayList<Integer> arrayList2 = new ArrayList<>();
            TLRPC.Chat chatByDialog = ChatObject.getChatByDialog(j, this.currentAccount);
            if (ChatObject.isChannel(chatByDialog)) {
                TLRPC.TL_channels_getMessages tL_channels_getMessages = new TLRPC.TL_channels_getMessages();
                tL_channels_getMessages.channel = getInputChannel(chatByDialog);
                tL_channels_getMessages.id = arrayList2;
                tL_messages_getMessages = tL_channels_getMessages;
            } else {
                TLRPC.TL_messages_getMessages tL_messages_getMessages2 = new TLRPC.TL_messages_getMessages();
                tL_messages_getMessages2.id = arrayList2;
                tL_messages_getMessages = tL_messages_getMessages2;
            }
            ArrayList<Integer> arrayList3 = this.reloadingMessages.get(j);
            for (int i = 0; i < arrayList.size(); i++) {
                Integer num = arrayList.get(i);
                if (arrayList3 == null || !arrayList3.contains(num)) {
                    arrayList2.add(num);
                }
            }
            if (!arrayList2.isEmpty()) {
                if (arrayList3 == null) {
                    arrayList3 = new ArrayList<>();
                    this.reloadingMessages.put(j, arrayList3);
                }
                arrayList3.addAll(arrayList2);
                getConnectionsManager().sendRequest(tL_messages_getMessages, new RequestDelegate(j, chatByDialog, z, arrayList2) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$_Mo3zDwCtVV689ExFZk5vk9xQb8 */
                    private final /* synthetic */ long f$1;
                    private final /* synthetic */ TLRPC.Chat f$2;
                    private final /* synthetic */ boolean f$3;
                    private final /* synthetic */ ArrayList f$4;

                    {
                        this.f$1 = r2;
                        this.f$2 = r4;
                        this.f$3 = r5;
                        this.f$4 = r6;
                    }

                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        MessagesController.this.lambda$reloadMessages$34$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, tLObject, tL_error);
                    }
                });
            }
        }
    }

    public /* synthetic */ void lambda$reloadMessages$34$MessagesController(long j, TLRPC.Chat chat, boolean z, ArrayList arrayList, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            TLRPC.messages_Messages messages_messages = (TLRPC.messages_Messages) tLObject;
            SparseArray sparseArray = new SparseArray();
            for (int i = 0; i < messages_messages.users.size(); i++) {
                TLRPC.User user = messages_messages.users.get(i);
                sparseArray.put(user.id, user);
            }
            SparseArray sparseArray2 = new SparseArray();
            for (int i2 = 0; i2 < messages_messages.chats.size(); i2++) {
                TLRPC.Chat chat2 = messages_messages.chats.get(i2);
                sparseArray2.put(chat2.id, chat2);
            }
            Integer num = this.dialogs_read_inbox_max.get(Long.valueOf(j));
            if (num == null) {
                num = Integer.valueOf(getMessagesStorage().getDialogReadMax(false, j));
                this.dialogs_read_inbox_max.put(Long.valueOf(j), num);
            }
            Integer num2 = this.dialogs_read_outbox_max.get(Long.valueOf(j));
            if (num2 == null) {
                num2 = Integer.valueOf(getMessagesStorage().getDialogReadMax(true, j));
                this.dialogs_read_outbox_max.put(Long.valueOf(j), num2);
            }
            ArrayList arrayList2 = new ArrayList();
            int i3 = 0;
            while (i3 < messages_messages.messages.size()) {
                TLRPC.Message message = messages_messages.messages.get(i3);
                if (chat != null && chat.megagroup) {
                    message.flags |= Integer.MIN_VALUE;
                }
                message.dialog_id = j;
                if (!z) {
                    message.unread = (message.out ? num2 : num).intValue() < message.id;
                }
                arrayList2.add(new MessageObject(this.currentAccount, message, (SparseArray<TLRPC.User>) sparseArray, (SparseArray<TLRPC.Chat>) sparseArray2, true));
                i3++;
                arrayList2 = arrayList2;
            }
            ImageLoader.saveMessagesThumbs(messages_messages.messages);
            getMessagesStorage().putMessages(messages_messages, j, -1, 0, false, z);
            AndroidUtilities.runOnUIThread(new Runnable(j, arrayList, arrayList2) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$Cs2jX1w3rrhjuKiHx4hKCZCHC4 */
                private final /* synthetic */ long f$1;
                private final /* synthetic */ ArrayList f$2;
                private final /* synthetic */ ArrayList f$3;

                {
                    this.f$1 = r2;
                    this.f$2 = r4;
                    this.f$3 = r5;
                }

                public final void run() {
                    MessagesController.this.lambda$null$33$MessagesController(this.f$1, this.f$2, this.f$3);
                }
            });
        }
    }

    public /* synthetic */ void lambda$null$33$MessagesController(long j, ArrayList arrayList, ArrayList arrayList2) {
        ArrayList<Integer> arrayList3 = this.reloadingMessages.get(j);
        if (arrayList3 != null) {
            arrayList3.removeAll(arrayList);
            if (arrayList3.isEmpty()) {
                this.reloadingMessages.remove(j);
            }
        }
        MessageObject messageObject = this.dialogMessage.get(j);
        if (messageObject != null) {
            int i = 0;
            while (true) {
                if (i >= arrayList2.size()) {
                    break;
                }
                MessageObject messageObject2 = (MessageObject) arrayList2.get(i);
                if (messageObject == null || messageObject.getId() != messageObject2.getId()) {
                    i++;
                } else {
                    this.dialogMessage.put(j, messageObject2);
                    if (messageObject2.messageOwner.to_id.channel_id == 0) {
                        MessageObject messageObject3 = this.dialogMessagesByIds.get(messageObject2.getId());
                        this.dialogMessagesByIds.remove(messageObject2.getId());
                        if (messageObject3 != null) {
                            this.dialogMessagesByIds.put(messageObject3.getId(), messageObject3);
                        }
                    }
                    getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
                }
            }
        }
        getNotificationCenter().postNotificationName(NotificationCenter.replaceMessagesObjects, Long.valueOf(j), arrayList2);
    }

    public void hidePeerSettingsBar(long j, TLRPC.User user, TLRPC.Chat chat) {
        if (user != null || chat != null) {
            SharedPreferences.Editor edit = this.notificationsPreferences.edit();
            edit.putInt("dialog_bar_vis3" + j, 3);
            edit.commit();
            if (((int) j) != 0) {
                TLRPC.TL_messages_hidePeerSettingsBar tL_messages_hidePeerSettingsBar = new TLRPC.TL_messages_hidePeerSettingsBar();
                if (user != null) {
                    tL_messages_hidePeerSettingsBar.peer = getInputPeer(user.id);
                } else if (chat != null) {
                    tL_messages_hidePeerSettingsBar.peer = getInputPeer(-chat.id);
                }
                getConnectionsManager().sendRequest(tL_messages_hidePeerSettingsBar, $$Lambda$MessagesController$KVZb_lfAO9J2MhFh9TqJqdtqQw4.INSTANCE);
            }
        }
    }

    public void reportSpam(long j, TLRPC.User user, TLRPC.Chat chat, TLRPC.EncryptedChat encryptedChat, boolean z) {
        if (user != null || chat != null || encryptedChat != null) {
            SharedPreferences.Editor edit = this.notificationsPreferences.edit();
            edit.putInt("dialog_bar_vis3" + j, 3);
            edit.commit();
            if (((int) j) != 0) {
                TLRPC.TL_account_reportPeer tL_account_reportPeer = new TLRPC.TL_account_reportPeer();
                if (chat != null) {
                    tL_account_reportPeer.peer = getInputPeer(-chat.id);
                } else if (user != null) {
                    tL_account_reportPeer.peer = getInputPeer(user.id);
                }
                if (z) {
                    tL_account_reportPeer.reason = new TLRPC.TL_inputReportReasonGeoIrrelevant();
                } else {
                    tL_account_reportPeer.reason = new TLRPC.TL_inputReportReasonSpam();
                }
                getConnectionsManager().sendRequest(tL_account_reportPeer, $$Lambda$MessagesController$_LuiS22PQtHADCZqd7xx4zqwMAs.INSTANCE, 2);
            } else if (encryptedChat != null && encryptedChat.access_hash != 0) {
                TLRPC.TL_messages_reportEncryptedSpam tL_messages_reportEncryptedSpam = new TLRPC.TL_messages_reportEncryptedSpam();
                tL_messages_reportEncryptedSpam.peer = new TLRPC.TL_inputEncryptedChat();
                tL_messages_reportEncryptedSpam.peer.chat_id = encryptedChat.id;
                tL_messages_reportEncryptedSpam.peer.access_hash = encryptedChat.access_hash;
                getConnectionsManager().sendRequest(tL_messages_reportEncryptedSpam, $$Lambda$MessagesController$Zi7aIlI1v0mB5Di7iaLEuxmyzK8.INSTANCE, 2);
            }
        }
    }

    private void savePeerSettings(long j, TLRPC.TL_peerSettings tL_peerSettings, boolean z) {
        if (tL_peerSettings != null) {
            SharedPreferences sharedPreferences = this.notificationsPreferences;
            if (sharedPreferences.getInt("dialog_bar_vis3" + j, 0) != 3) {
                SharedPreferences.Editor edit = this.notificationsPreferences.edit();
                boolean z2 = !tL_peerSettings.report_spam && !tL_peerSettings.add_contact && !tL_peerSettings.block_contact && !tL_peerSettings.share_contact && !tL_peerSettings.report_geo;
                edit.putInt("dialog_bar_vis3" + j, z2 ? 1 : 2);
                edit.putBoolean("dialog_bar_share" + j, tL_peerSettings.share_contact);
                edit.putBoolean("dialog_bar_report" + j, tL_peerSettings.report_spam);
                edit.putBoolean("dialog_bar_add" + j, tL_peerSettings.add_contact);
                edit.putBoolean("dialog_bar_block" + j, tL_peerSettings.block_contact);
                edit.putBoolean("dialog_bar_exception" + j, tL_peerSettings.need_contacts_exception);
                edit.putBoolean("dialog_bar_location" + j, tL_peerSettings.report_geo);
                edit.commit();
                getNotificationCenter().postNotificationName(NotificationCenter.peerSettingsDidLoad, Long.valueOf(j));
            }
        }
    }

    public void loadPeerSettings(TLRPC.User user, TLRPC.Chat chat) {
        int i;
        if (user != null || chat != null) {
            if (user != null) {
                i = user.id;
            } else {
                i = -chat.id;
            }
            long j = (long) i;
            if (this.loadingPeerSettings.indexOfKey(j) < 0) {
                this.loadingPeerSettings.put(j, true);
                if (BuildVars.LOGS_ENABLED) {
                    FileLog.d("request spam button for " + j);
                }
                SharedPreferences sharedPreferences = this.notificationsPreferences;
                int i2 = sharedPreferences.getInt("dialog_bar_vis3" + j, 0);
                if (i2 != 1 && i2 != 3) {
                    TLRPC.TL_messages_getPeerSettings tL_messages_getPeerSettings = new TLRPC.TL_messages_getPeerSettings();
                    if (user != null) {
                        tL_messages_getPeerSettings.peer = getInputPeer(user.id);
                    } else if (chat != null) {
                        tL_messages_getPeerSettings.peer = getInputPeer(-chat.id);
                    }
                    getConnectionsManager().sendRequest(tL_messages_getPeerSettings, new RequestDelegate(j) {
                        /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$W7Bsd03vz3CAs_lvuIfwbI27q9g */
                        private final /* synthetic */ long f$1;

                        {
                            this.f$1 = r2;
                        }

                        @Override // im.guobwnxjuc.tgnet.RequestDelegate
                        public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                            MessagesController.this.lambda$loadPeerSettings$39$MessagesController(this.f$1, tLObject, tL_error);
                        }
                    });
                } else if (BuildVars.LOGS_ENABLED) {
                    FileLog.d("dialog bar already hidden for " + j);
                }
            }
        }
    }

    public /* synthetic */ void lambda$loadPeerSettings$39$MessagesController(long j, TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable(j, tLObject) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$lIkwW1SojKVwODD_zBmJSvi84M */
            private final /* synthetic */ long f$1;
            private final /* synthetic */ TLObject f$2;

            {
                this.f$1 = r2;
                this.f$2 = r4;
            }

            public final void run() {
                MessagesController.this.lambda$null$38$MessagesController(this.f$1, this.f$2);
            }
        });
    }

    public /* synthetic */ void lambda$null$38$MessagesController(long j, TLObject tLObject) {
        this.loadingPeerSettings.remove(j);
        if (tLObject != null) {
            savePeerSettings(j, (TLRPC.TL_peerSettings) tLObject, false);
        }
    }

    /* access modifiers changed from: protected */
    public void processNewChannelDifferenceParams(int i, int i2, int i3) {
        int i4 = this.channelsPts.get(i3);
        if (i4 == 0) {
            i4 = getMessagesStorage().getChannelPtsSync(i3);
            if (i4 == 0) {
                i4 = 1;
            }
            this.channelsPts.put(i3, i4);
        }
        if (i4 + i2 == i) {
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("APPLY CHANNEL PTS");
            }
            this.channelsPts.put(i3, i);
            getMessagesStorage().saveChannelPts(i3, i);
        } else if (i4 != i) {
            long j = this.updatesStartWaitTimeChannels.get(i3);
            if (this.gettingDifferenceChannels.get(i3) || j == 0 || Math.abs(System.currentTimeMillis() - j) <= 1500) {
                if (BuildVars.LOGS_ENABLED) {
                    FileLog.d("ADD CHANNEL UPDATE TO QUEUE pts = " + i + " pts_count = " + i2);
                }
                if (j == 0) {
                    this.updatesStartWaitTimeChannels.put(i3, System.currentTimeMillis());
                }
                UserActionUpdatesPts userActionUpdatesPts = new UserActionUpdatesPts();
                userActionUpdatesPts.pts = i;
                userActionUpdatesPts.pts_count = i2;
                userActionUpdatesPts.chat_id = i3;
                ArrayList<TLRPC.Updates> arrayList = this.updatesQueueChannels.get(i3);
                if (arrayList == null) {
                    arrayList = new ArrayList<>();
                    this.updatesQueueChannels.put(i3, arrayList);
                }
                arrayList.add(userActionUpdatesPts);
                return;
            }
            getChannelDifference(i3);
        }
    }

    /* access modifiers changed from: protected */
    public void processNewDifferenceParams(int i, int i2, int i3, int i4) {
        if (i2 != -1) {
            if (getMessagesStorage().getLastPtsValue() + i4 == i2) {
                if (BuildVars.LOGS_ENABLED) {
                    FileLog.d("APPLY PTS");
                }
                getMessagesStorage().setLastPtsValue(i2);
                getMessagesStorage().saveDiffParams(getMessagesStorage().getLastSeqValue(), getMessagesStorage().getLastPtsValue(), getMessagesStorage().getLastDateValue(), getMessagesStorage().getLastQtsValue());
            } else if (getMessagesStorage().getLastPtsValue() != i2) {
                if (this.gettingDifference || this.updatesStartWaitTimePts == 0 || Math.abs(System.currentTimeMillis() - this.updatesStartWaitTimePts) <= 1500) {
                    if (BuildVars.LOGS_ENABLED) {
                        FileLog.d("ADD UPDATE TO QUEUE pts = " + i2 + " pts_count = " + i4);
                    }
                    if (this.updatesStartWaitTimePts == 0) {
                        this.updatesStartWaitTimePts = System.currentTimeMillis();
                    }
                    UserActionUpdatesPts userActionUpdatesPts = new UserActionUpdatesPts();
                    userActionUpdatesPts.pts = i2;
                    userActionUpdatesPts.pts_count = i4;
                    this.updatesQueuePts.add(userActionUpdatesPts);
                } else {
                    getDifference();
                }
            }
        }
        if (i == -1) {
            return;
        }
        if (getMessagesStorage().getLastSeqValue() + 1 == i) {
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("APPLY SEQ");
            }
            getMessagesStorage().setLastSeqValue(i);
            if (i3 != -1) {
                getMessagesStorage().setLastDateValue(i3);
            }
            getMessagesStorage().saveDiffParams(getMessagesStorage().getLastSeqValue(), getMessagesStorage().getLastPtsValue(), getMessagesStorage().getLastDateValue(), getMessagesStorage().getLastQtsValue());
        } else if (getMessagesStorage().getLastSeqValue() == i) {
        } else {
            if (this.gettingDifference || this.updatesStartWaitTimeSeq == 0 || Math.abs(System.currentTimeMillis() - this.updatesStartWaitTimeSeq) <= 1500) {
                if (BuildVars.LOGS_ENABLED) {
                    FileLog.d("ADD UPDATE TO QUEUE seq = " + i);
                }
                if (this.updatesStartWaitTimeSeq == 0) {
                    this.updatesStartWaitTimeSeq = System.currentTimeMillis();
                }
                UserActionUpdatesSeq userActionUpdatesSeq = new UserActionUpdatesSeq();
                userActionUpdatesSeq.seq = i;
                this.updatesQueueSeq.add(userActionUpdatesSeq);
                return;
            }
            getDifference();
        }
    }

    public void didAddedNewTask(int i, SparseArray<ArrayList<Long>> sparseArray) {
        Utilities.stageQueue.postRunnable(new Runnable(i) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$Je5b5mdCMFtjeN7XlxBlQmOJxXw */
            private final /* synthetic */ int f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                MessagesController.this.lambda$didAddedNewTask$40$MessagesController(this.f$1);
            }
        });
        AndroidUtilities.runOnUIThread(new Runnable(sparseArray) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$GXyzLPlTiTeUav5nx4vy6swvDj4 */
            private final /* synthetic */ SparseArray f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                MessagesController.this.lambda$didAddedNewTask$41$MessagesController(this.f$1);
            }
        });
    }

    public /* synthetic */ void lambda$didAddedNewTask$40$MessagesController(int i) {
        int i2;
        if ((this.currentDeletingTaskMids == null && !this.gettingNewDeleteTask) || ((i2 = this.currentDeletingTaskTime) != 0 && i < i2)) {
            getNewDeleteTask(null, 0);
        }
    }

    public /* synthetic */ void lambda$didAddedNewTask$41$MessagesController(SparseArray sparseArray) {
        getNotificationCenter().postNotificationName(NotificationCenter.didCreatedNewDeleteTask, sparseArray);
    }

    public void getNewDeleteTask(ArrayList<Integer> arrayList, int i) {
        Utilities.stageQueue.postRunnable(new Runnable(arrayList, i) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$ZpGLOqDp2sSPPWl8psFAKfEQLO8 */
            private final /* synthetic */ ArrayList f$1;
            private final /* synthetic */ int f$2;

            {
                this.f$1 = r2;
                this.f$2 = r3;
            }

            public final void run() {
                MessagesController.this.lambda$getNewDeleteTask$42$MessagesController(this.f$1, this.f$2);
            }
        });
    }

    public /* synthetic */ void lambda$getNewDeleteTask$42$MessagesController(ArrayList arrayList, int i) {
        this.gettingNewDeleteTask = true;
        getMessagesStorage().getNewTask(arrayList, i);
    }

    private boolean checkDeletingTask(boolean z) {
        int i;
        int currentTime = getConnectionsManager().getCurrentTime();
        if (this.currentDeletingTaskMids == null || (!z && ((i = this.currentDeletingTaskTime) == 0 || i > currentTime))) {
            return false;
        }
        this.currentDeletingTaskTime = 0;
        if (this.currentDeleteTaskRunnable != null && !z) {
            Utilities.stageQueue.cancelRunnable(this.currentDeleteTaskRunnable);
        }
        this.currentDeleteTaskRunnable = null;
        AndroidUtilities.runOnUIThread(new Runnable(new ArrayList(this.currentDeletingTaskMids)) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$p5kNTcivdIpNwMcVvdNvfAvo8Oo */
            private final /* synthetic */ ArrayList f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                MessagesController.this.lambda$checkDeletingTask$44$MessagesController(this.f$1);
            }
        });
        return true;
    }

    public /* synthetic */ void lambda$checkDeletingTask$44$MessagesController(ArrayList arrayList) {
        if (arrayList.isEmpty() || ((Integer) arrayList.get(0)).intValue() <= 0) {
            deleteMessages(arrayList, null, null, 0, 0, false, false);
        } else {
            getMessagesStorage().emptyMessagesMedia(arrayList);
        }
        Utilities.stageQueue.postRunnable(new Runnable(arrayList) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$ZiIDEBBD2GaTJv_WqmtMCNj198 */
            private final /* synthetic */ ArrayList f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                MessagesController.this.lambda$null$43$MessagesController(this.f$1);
            }
        });
    }

    public /* synthetic */ void lambda$null$43$MessagesController(ArrayList arrayList) {
        getNewDeleteTask(arrayList, this.currentDeletingTaskChannelId);
        this.currentDeletingTaskTime = 0;
        this.currentDeletingTaskMids = null;
    }

    public void processLoadedDeleteTask(int i, ArrayList<Integer> arrayList, int i2) {
        Utilities.stageQueue.postRunnable(new Runnable(arrayList, i) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$sdb4bIs9lAli1Sh8GbkW1pYstks */
            private final /* synthetic */ ArrayList f$1;
            private final /* synthetic */ int f$2;

            {
                this.f$1 = r2;
                this.f$2 = r3;
            }

            public final void run() {
                MessagesController.this.lambda$processLoadedDeleteTask$46$MessagesController(this.f$1, this.f$2);
            }
        });
    }

    public /* synthetic */ void lambda$processLoadedDeleteTask$46$MessagesController(ArrayList arrayList, int i) {
        this.gettingNewDeleteTask = false;
        if (arrayList != null) {
            this.currentDeletingTaskTime = i;
            this.currentDeletingTaskMids = arrayList;
            if (this.currentDeleteTaskRunnable != null) {
                Utilities.stageQueue.cancelRunnable(this.currentDeleteTaskRunnable);
                this.currentDeleteTaskRunnable = null;
            }
            if (!checkDeletingTask(false)) {
                this.currentDeleteTaskRunnable = new Runnable() {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$CrmrBwt9r_O7edunN1lyxgE9cG4 */

                    public final void run() {
                        MessagesController.this.lambda$null$45$MessagesController();
                    }
                };
                Utilities.stageQueue.postRunnable(this.currentDeleteTaskRunnable, ((long) Math.abs(getConnectionsManager().getCurrentTime() - this.currentDeletingTaskTime)) * 1000);
                return;
            }
            return;
        }
        this.currentDeletingTaskTime = 0;
        this.currentDeletingTaskMids = null;
    }

    public /* synthetic */ void lambda$null$45$MessagesController() {
        checkDeletingTask(true);
    }

    public void loadDialogPhotos(int i, int i2, long j, boolean z, int i3) {
        if (z) {
            getMessagesStorage().getDialogPhotos(i, i2, j, i3);
        } else if (i > 0) {
            TLRPC.User user = getUser(Integer.valueOf(i));
            if (user != null) {
                TLRPC.TL_photos_getUserPhotos tL_photos_getUserPhotos = new TLRPC.TL_photos_getUserPhotos();
                tL_photos_getUserPhotos.limit = i2;
                tL_photos_getUserPhotos.offset = 0;
                tL_photos_getUserPhotos.max_id = (long) ((int) j);
                tL_photos_getUserPhotos.user_id = getInputUser(user);
                getConnectionsManager().bindRequestToGuid(getConnectionsManager().sendRequest(tL_photos_getUserPhotos, new RequestDelegate(i, i2, j, i3) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$COVtoSsKsn4s5KMAxvAtd9h4kU */
                    private final /* synthetic */ int f$1;
                    private final /* synthetic */ int f$2;
                    private final /* synthetic */ long f$3;
                    private final /* synthetic */ int f$4;

                    {
                        this.f$1 = r2;
                        this.f$2 = r3;
                        this.f$3 = r4;
                        this.f$4 = r6;
                    }

                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        MessagesController.this.lambda$loadDialogPhotos$47$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, tLObject, tL_error);
                    }
                }), i3);
            }
        } else if (i < 0) {
            TLRPC.TL_messages_search tL_messages_search = new TLRPC.TL_messages_search();
            tL_messages_search.filter = new TLRPC.TL_inputMessagesFilterChatPhotos();
            tL_messages_search.limit = i2;
            tL_messages_search.offset_id = (int) j;
            tL_messages_search.q = "";
            tL_messages_search.peer = getInputPeer(i);
            getConnectionsManager().bindRequestToGuid(getConnectionsManager().sendRequest(tL_messages_search, new RequestDelegate(i, i2, j, i3) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$tIzDUymZMi7pYlcix_XIrO6Asds */
                private final /* synthetic */ int f$1;
                private final /* synthetic */ int f$2;
                private final /* synthetic */ long f$3;
                private final /* synthetic */ int f$4;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                    this.f$3 = r4;
                    this.f$4 = r6;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$loadDialogPhotos$48$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, tLObject, tL_error);
                }
            }), i3);
        }
    }

    public /* synthetic */ void lambda$loadDialogPhotos$47$MessagesController(int i, int i2, long j, int i3, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            processLoadedUserPhotos((TLRPC.photos_Photos) tLObject, i, i2, j, false, i3);
        }
    }

    public /* synthetic */ void lambda$loadDialogPhotos$48$MessagesController(int i, int i2, long j, int i3, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            TLRPC.messages_Messages messages_messages = (TLRPC.messages_Messages) tLObject;
            TLRPC.TL_photos_photos tL_photos_photos = new TLRPC.TL_photos_photos();
            tL_photos_photos.count = messages_messages.count;
            tL_photos_photos.users.addAll(messages_messages.users);
            for (int i4 = 0; i4 < messages_messages.messages.size(); i4++) {
                TLRPC.Message message = messages_messages.messages.get(i4);
                if (!(message.action == null || message.action.photo == null)) {
                    tL_photos_photos.photos.add(message.action.photo);
                }
            }
            processLoadedUserPhotos(tL_photos_photos, i, i2, j, false, i3);
        }
    }

    public void blockUser(int i) {
        TLRPC.User user = getUser(Integer.valueOf(i));
        if (user != null && this.blockedUsers.indexOfKey(i) < 0) {
            this.blockedUsers.put(i, 1);
            if (user.bot) {
                getMediaDataController().removeInline(i);
            } else {
                getMediaDataController().removePeer(i);
            }
            int i2 = this.totalBlockedCount;
            if (i2 >= 0) {
                this.totalBlockedCount = i2 + 1;
            }
            getNotificationCenter().postNotificationName(NotificationCenter.blockedUsersDidLoad, new Object[0]);
            TLRPC.TL_contacts_block tL_contacts_block = new TLRPC.TL_contacts_block();
            tL_contacts_block.id = getInputUser(user);
            getConnectionsManager().sendRequest(tL_contacts_block, $$Lambda$MessagesController$aFWbbvlSDe3awLaVehbObcNVU6s.INSTANCE);
        }
    }

    public void setUserBannedRole(int i, TLRPC.User user, TLRPC.TL_chatBannedRights tL_chatBannedRights, boolean z, BaseFragment baseFragment) {
        if (user != null && tL_chatBannedRights != null) {
            TLRPC.TL_channels_editBanned tL_channels_editBanned = new TLRPC.TL_channels_editBanned();
            tL_channels_editBanned.channel = getInputChannel(i);
            tL_channels_editBanned.user_id = getInputUser(user);
            tL_channels_editBanned.banned_rights = tL_chatBannedRights;
            getConnectionsManager().sendRequest(tL_channels_editBanned, new RequestDelegate(i, baseFragment, tL_channels_editBanned, z) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$TMW_MbQ0j9sZ0ogXv07SMVy9Wkc */
                private final /* synthetic */ int f$1;
                private final /* synthetic */ BaseFragment f$2;
                private final /* synthetic */ TLRPC.TL_channels_editBanned f$3;
                private final /* synthetic */ boolean f$4;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                    this.f$3 = r4;
                    this.f$4 = r5;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$setUserBannedRole$52$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$setUserBannedRole$52$MessagesController(int i, BaseFragment baseFragment, TLRPC.TL_channels_editBanned tL_channels_editBanned, boolean z, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            processUpdates((TLRPC.Updates) tLObject, false);
            AndroidUtilities.runOnUIThread(new Runnable(i) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$8LS4D_p7p9nowz_mbKHmWroaTI4 */
                private final /* synthetic */ int f$1;

                {
                    this.f$1 = r2;
                }

                public final void run() {
                    MessagesController.this.lambda$null$50$MessagesController(this.f$1);
                }
            }, 1000);
            return;
        }
        AndroidUtilities.runOnUIThread(new Runnable(tL_error, baseFragment, tL_channels_editBanned, z) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$NRuiqYkWKu0_qCrd98wtgnn35L8 */
            private final /* synthetic */ TLRPC.TL_error f$1;
            private final /* synthetic */ BaseFragment f$2;
            private final /* synthetic */ TLRPC.TL_channels_editBanned f$3;
            private final /* synthetic */ boolean f$4;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
                this.f$4 = r5;
            }

            public final void run() {
                MessagesController.this.lambda$null$51$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4);
            }
        });
    }

    public /* synthetic */ void lambda$null$50$MessagesController(int i) {
        loadFullChat(i, 0, true);
    }

    public /* synthetic */ void lambda$null$51$MessagesController(TLRPC.TL_error tL_error, BaseFragment baseFragment, TLRPC.TL_channels_editBanned tL_channels_editBanned, boolean z) {
        AlertsCreator.processError(this.currentAccount, tL_error, baseFragment, tL_channels_editBanned, Boolean.valueOf(z));
    }

    public void setChannelSlowMode(int i, int i2) {
        TLRPC.TL_channels_toggleSlowMode tL_channels_toggleSlowMode = new TLRPC.TL_channels_toggleSlowMode();
        tL_channels_toggleSlowMode.seconds = i2;
        tL_channels_toggleSlowMode.channel = getInputChannel(i);
        getConnectionsManager().sendRequest(tL_channels_toggleSlowMode, new RequestDelegate(i) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$GDiLOY630oWhUEr9PG5VTcQUK8I */
            private final /* synthetic */ int f$1;

            {
                this.f$1 = r2;
            }

            @Override // im.guobwnxjuc.tgnet.RequestDelegate
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                MessagesController.this.lambda$setChannelSlowMode$54$MessagesController(this.f$1, tLObject, tL_error);
            }
        });
    }

    public /* synthetic */ void lambda$setChannelSlowMode$54$MessagesController(int i, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            getMessagesController().processUpdates((TLRPC.Updates) tLObject, false);
            AndroidUtilities.runOnUIThread(new Runnable(i) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$nCeTkIeEOxRETe8arWYSrRn33ls */
                private final /* synthetic */ int f$1;

                {
                    this.f$1 = r2;
                }

                public final void run() {
                    MessagesController.this.lambda$null$53$MessagesController(this.f$1);
                }
            }, 1000);
        }
    }

    public /* synthetic */ void lambda$null$53$MessagesController(int i) {
        loadFullChat(i, 0, true);
    }

    public void setDefaultBannedRole(int i, TLRPC.TL_chatBannedRights tL_chatBannedRights, boolean z, BaseFragment baseFragment) {
        if (tL_chatBannedRights != null) {
            TLRPC.TL_messages_editChatDefaultBannedRights tL_messages_editChatDefaultBannedRights = new TLRPC.TL_messages_editChatDefaultBannedRights();
            tL_messages_editChatDefaultBannedRights.peer = getInputPeer(-i);
            tL_messages_editChatDefaultBannedRights.banned_rights = tL_chatBannedRights;
            getConnectionsManager().sendRequest(tL_messages_editChatDefaultBannedRights, new RequestDelegate(i, baseFragment, tL_messages_editChatDefaultBannedRights, z) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$2jKTl1fjtFZmUYtY0i9N384GPLQ */
                private final /* synthetic */ int f$1;
                private final /* synthetic */ BaseFragment f$2;
                private final /* synthetic */ TLRPC.TL_messages_editChatDefaultBannedRights f$3;
                private final /* synthetic */ boolean f$4;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                    this.f$3 = r4;
                    this.f$4 = r5;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$setDefaultBannedRole$57$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$setDefaultBannedRole$57$MessagesController(int i, BaseFragment baseFragment, TLRPC.TL_messages_editChatDefaultBannedRights tL_messages_editChatDefaultBannedRights, boolean z, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            processUpdates((TLRPC.Updates) tLObject, false);
            AndroidUtilities.runOnUIThread(new Runnable(i) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$Iw71RVBhm8M2QqonBEGZsOhUTs */
                private final /* synthetic */ int f$1;

                {
                    this.f$1 = r2;
                }

                public final void run() {
                    MessagesController.this.lambda$null$55$MessagesController(this.f$1);
                }
            }, 1000);
            return;
        }
        AndroidUtilities.runOnUIThread(new Runnable(tL_error, baseFragment, tL_messages_editChatDefaultBannedRights, z) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$9qSX2548rncF3O3WIikKvxF6dvs */
            private final /* synthetic */ TLRPC.TL_error f$1;
            private final /* synthetic */ BaseFragment f$2;
            private final /* synthetic */ TLRPC.TL_messages_editChatDefaultBannedRights f$3;
            private final /* synthetic */ boolean f$4;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
                this.f$4 = r5;
            }

            public final void run() {
                MessagesController.this.lambda$null$56$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4);
            }
        });
    }

    public /* synthetic */ void lambda$null$55$MessagesController(int i) {
        loadFullChat(i, 0, true);
    }

    public /* synthetic */ void lambda$null$56$MessagesController(TLRPC.TL_error tL_error, BaseFragment baseFragment, TLRPC.TL_messages_editChatDefaultBannedRights tL_messages_editChatDefaultBannedRights, boolean z) {
        AlertsCreator.processError(this.currentAccount, tL_error, baseFragment, tL_messages_editChatDefaultBannedRights, Boolean.valueOf(z));
    }

    public void setUserAdminRole(int i, TLRPC.User user, TLRPC.TL_chatAdminRights tL_chatAdminRights, String str, boolean z, BaseFragment baseFragment, boolean z2) {
        if (user != null && tL_chatAdminRights != null) {
            TLRPC.Chat chat = getChat(Integer.valueOf(i));
            if (ChatObject.isChannel(chat)) {
                TLRPC.TL_channels_editAdmin tL_channels_editAdmin = new TLRPC.TL_channels_editAdmin();
                tL_channels_editAdmin.channel = getInputChannel(chat);
                tL_channels_editAdmin.user_id = getInputUser(user);
                tL_channels_editAdmin.admin_rights = tL_chatAdminRights;
                tL_channels_editAdmin.rank = str;
                getConnectionsManager().sendRequest(tL_channels_editAdmin, new RequestDelegate(i, baseFragment, tL_channels_editAdmin, z) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$zwH11lRDYZjJrQvdRoQYmvUrARs */
                    private final /* synthetic */ int f$1;
                    private final /* synthetic */ BaseFragment f$2;
                    private final /* synthetic */ TLRPC.TL_channels_editAdmin f$3;
                    private final /* synthetic */ boolean f$4;

                    {
                        this.f$1 = r2;
                        this.f$2 = r3;
                        this.f$3 = r4;
                        this.f$4 = r5;
                    }

                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        MessagesController.this.lambda$setUserAdminRole$60$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, tLObject, tL_error);
                    }
                });
                return;
            }
            TLRPC.TL_messages_editChatAdmin tL_messages_editChatAdmin = new TLRPC.TL_messages_editChatAdmin();
            tL_messages_editChatAdmin.chat_id = i;
            tL_messages_editChatAdmin.user_id = getInputUser(user);
            tL_messages_editChatAdmin.is_admin = tL_chatAdminRights.change_info || tL_chatAdminRights.delete_messages || tL_chatAdminRights.ban_users || tL_chatAdminRights.invite_users || tL_chatAdminRights.pin_messages || tL_chatAdminRights.add_admins;
            $$Lambda$MessagesController$dFPV85Af8G_TgiTkHdWIU_R6vU r11 = new RequestDelegate(i, baseFragment, tL_messages_editChatAdmin) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$dFPV85Af8G_TgiTkHdWIU_R6vU */
                private final /* synthetic */ int f$1;
                private final /* synthetic */ BaseFragment f$2;
                private final /* synthetic */ TLRPC.TL_messages_editChatAdmin f$3;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                    this.f$3 = r4;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$setUserAdminRole$63$MessagesController(this.f$1, this.f$2, this.f$3, tLObject, tL_error);
                }
            };
            if (!tL_messages_editChatAdmin.is_admin || !z2) {
                getConnectionsManager().sendRequest(tL_messages_editChatAdmin, r11);
            } else {
                addUserToChat(i, user, null, 0, null, baseFragment, new Runnable(tL_messages_editChatAdmin, r11) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$YQaCbt99ee268e4jUZyZHk7EG3k */
                    private final /* synthetic */ TLRPC.TL_messages_editChatAdmin f$1;
                    private final /* synthetic */ RequestDelegate f$2;

                    {
                        this.f$1 = r2;
                        this.f$2 = r3;
                    }

                    public final void run() {
                        MessagesController.this.lambda$setUserAdminRole$64$MessagesController(this.f$1, this.f$2);
                    }
                });
            }
        }
    }

    public /* synthetic */ void lambda$setUserAdminRole$60$MessagesController(int i, BaseFragment baseFragment, TLRPC.TL_channels_editAdmin tL_channels_editAdmin, boolean z, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            processUpdates((TLRPC.Updates) tLObject, false);
            AndroidUtilities.runOnUIThread(new Runnable(i) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$uzBKhufZQRjUZtFe_Nf1asVW7k8 */
                private final /* synthetic */ int f$1;

                {
                    this.f$1 = r2;
                }

                public final void run() {
                    MessagesController.this.lambda$null$58$MessagesController(this.f$1);
                }
            }, 1000);
            return;
        }
        AndroidUtilities.runOnUIThread(new Runnable(tL_error, baseFragment, tL_channels_editAdmin, z) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$CLIFTnBJ6JMZMSTyftXBmFdiALY */
            private final /* synthetic */ TLRPC.TL_error f$1;
            private final /* synthetic */ BaseFragment f$2;
            private final /* synthetic */ TLRPC.TL_channels_editAdmin f$3;
            private final /* synthetic */ boolean f$4;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
                this.f$4 = r5;
            }

            public final void run() {
                MessagesController.this.lambda$null$59$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4);
            }
        });
    }

    public /* synthetic */ void lambda$null$58$MessagesController(int i) {
        loadFullChat(i, 0, true);
    }

    public /* synthetic */ void lambda$null$59$MessagesController(TLRPC.TL_error tL_error, BaseFragment baseFragment, TLRPC.TL_channels_editAdmin tL_channels_editAdmin, boolean z) {
        AlertsCreator.processError(this.currentAccount, tL_error, baseFragment, tL_channels_editAdmin, Boolean.valueOf(z));
    }

    public /* synthetic */ void lambda$null$61$MessagesController(int i) {
        loadFullChat(i, 0, true);
    }

    public /* synthetic */ void lambda$setUserAdminRole$63$MessagesController(int i, BaseFragment baseFragment, TLRPC.TL_messages_editChatAdmin tL_messages_editChatAdmin, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            AndroidUtilities.runOnUIThread(new Runnable(i) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$l_E1hvAuWcRXMZDZjyBk0XrY_HQ */
                private final /* synthetic */ int f$1;

                {
                    this.f$1 = r2;
                }

                public final void run() {
                    MessagesController.this.lambda$null$61$MessagesController(this.f$1);
                }
            }, 1000);
        } else {
            AndroidUtilities.runOnUIThread(new Runnable(tL_error, baseFragment, tL_messages_editChatAdmin) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$zWImQoRismylbTLKXXcj4m7OPQ */
                private final /* synthetic */ TLRPC.TL_error f$1;
                private final /* synthetic */ BaseFragment f$2;
                private final /* synthetic */ TLRPC.TL_messages_editChatAdmin f$3;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                    this.f$3 = r4;
                }

                public final void run() {
                    MessagesController.this.lambda$null$62$MessagesController(this.f$1, this.f$2, this.f$3);
                }
            });
        }
    }

    public /* synthetic */ void lambda$null$62$MessagesController(TLRPC.TL_error tL_error, BaseFragment baseFragment, TLRPC.TL_messages_editChatAdmin tL_messages_editChatAdmin) {
        AlertsCreator.processError(this.currentAccount, tL_error, baseFragment, tL_messages_editChatAdmin, false);
    }

    public /* synthetic */ void lambda$setUserAdminRole$64$MessagesController(TLRPC.TL_messages_editChatAdmin tL_messages_editChatAdmin, RequestDelegate requestDelegate) {
        getConnectionsManager().sendRequest(tL_messages_editChatAdmin, requestDelegate);
    }

    public void unblockUser(int i) {
        TLRPC.TL_contacts_unblock tL_contacts_unblock = new TLRPC.TL_contacts_unblock();
        TLRPC.User user = getUser(Integer.valueOf(i));
        if (user != null) {
            this.totalBlockedCount--;
            this.blockedUsers.delete(user.id);
            tL_contacts_unblock.id = getInputUser(user);
            getNotificationCenter().postNotificationName(NotificationCenter.blockedUsersDidLoad, new Object[0]);
            getConnectionsManager().sendRequest(tL_contacts_unblock, $$Lambda$MessagesController$NsiaWrgSx8LSAku7j3WGdXgCm3Y.INSTANCE);
        }
    }

    public void getBlockedUsers(boolean z) {
        int i;
        if (getUserConfig().isClientActivated() && !this.loadingBlockedUsers) {
            this.loadingBlockedUsers = true;
            TLRPC.TL_contacts_getBlocked tL_contacts_getBlocked = new TLRPC.TL_contacts_getBlocked();
            if (z) {
                i = 0;
            } else {
                i = this.blockedUsers.size();
            }
            tL_contacts_getBlocked.offset = i;
            tL_contacts_getBlocked.limit = z ? 20 : 100;
            getConnectionsManager().sendRequest(tL_contacts_getBlocked, new RequestDelegate(z, tL_contacts_getBlocked) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$LWx0Tn57q1NRUfxn4IulCKc8Pv0 */
                private final /* synthetic */ boolean f$1;
                private final /* synthetic */ TLRPC.TL_contacts_getBlocked f$2;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$getBlockedUsers$67$MessagesController(this.f$1, this.f$2, tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$getBlockedUsers$67$MessagesController(boolean z, TLRPC.TL_contacts_getBlocked tL_contacts_getBlocked, TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable(tLObject, z, tL_contacts_getBlocked) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$nf9Mb8RwrysbexEHdbiNklbBLU */
            private final /* synthetic */ TLObject f$1;
            private final /* synthetic */ boolean f$2;
            private final /* synthetic */ TLRPC.TL_contacts_getBlocked f$3;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
            }

            public final void run() {
                MessagesController.this.lambda$null$66$MessagesController(this.f$1, this.f$2, this.f$3);
            }
        });
    }

    public /* synthetic */ void lambda$null$66$MessagesController(TLObject tLObject, boolean z, TLRPC.TL_contacts_getBlocked tL_contacts_getBlocked) {
        if (tLObject != null) {
            TLRPC.contacts_Blocked contacts_blocked = (TLRPC.contacts_Blocked) tLObject;
            putUsers(contacts_blocked.users, false);
            getMessagesStorage().putUsersAndChats(contacts_blocked.users, null, true, true);
            if (z) {
                this.blockedUsers.clear();
            }
            this.totalBlockedCount = Math.max(contacts_blocked.count, contacts_blocked.blocked.size());
            this.blockedEndReached = contacts_blocked.blocked.size() < tL_contacts_getBlocked.limit;
            int size = contacts_blocked.blocked.size();
            for (int i = 0; i < size; i++) {
                this.blockedUsers.put(contacts_blocked.blocked.get(i).user_id, 1);
            }
            this.loadingBlockedUsers = false;
            getNotificationCenter().postNotificationName(NotificationCenter.blockedUsersDidLoad, new Object[0]);
        }
    }

    public void deleteUserPhoto(TLRPC.InputPhoto inputPhoto) {
        if (inputPhoto == null) {
            TLRPC.TL_photos_updateProfilePhoto tL_photos_updateProfilePhoto = new TLRPC.TL_photos_updateProfilePhoto();
            tL_photos_updateProfilePhoto.id = new TLRPC.TL_inputPhotoEmpty();
            getUserConfig().getCurrentUser().photo = new TLRPC.TL_userProfilePhotoEmpty();
            TLRPC.User user = getUser(Integer.valueOf(getUserConfig().getClientUserId()));
            if (user == null) {
                user = getUserConfig().getCurrentUser();
            }
            if (user != null) {
                user.photo = getUserConfig().getCurrentUser().photo;
                getNotificationCenter().postNotificationName(NotificationCenter.mainUserInfoChanged, new Object[0]);
                getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, Integer.valueOf((int) UPDATE_MASK_ALL));
                getConnectionsManager().sendRequest(tL_photos_updateProfilePhoto, new RequestDelegate() {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$svkmzdtwFebLLn7fEfv0cjaFw24 */

                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        MessagesController.this.lambda$deleteUserPhoto$69$MessagesController(tLObject, tL_error);
                    }
                });
                return;
            }
            return;
        }
        TLRPC.TL_photos_deletePhotos tL_photos_deletePhotos = new TLRPC.TL_photos_deletePhotos();
        tL_photos_deletePhotos.id.add(inputPhoto);
        getConnectionsManager().sendRequest(tL_photos_deletePhotos, $$Lambda$MessagesController$SERZGqsRum7xG_YVHejwUgkGRl4.INSTANCE);
    }

    public /* synthetic */ void lambda$deleteUserPhoto$69$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            TLRPC.User user = getUser(Integer.valueOf(getUserConfig().getClientUserId()));
            if (user == null) {
                user = getUserConfig().getCurrentUser();
                putUser(user, false);
            } else {
                getUserConfig().setCurrentUser(user);
            }
            if (user != null) {
                getMessagesStorage().clearUserPhotos(user.id);
                ArrayList<TLRPC.User> arrayList = new ArrayList<>();
                arrayList.add(user);
                getMessagesStorage().putUsersAndChats(arrayList, null, false, true);
                user.photo = (TLRPC.UserProfilePhoto) tLObject;
                AndroidUtilities.runOnUIThread(new Runnable() {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$2iV0Obupk1lVpe4TANE00g425o */

                    public final void run() {
                        MessagesController.this.lambda$null$68$MessagesController();
                    }
                });
            }
        }
    }

    public /* synthetic */ void lambda$null$68$MessagesController() {
        getNotificationCenter().postNotificationName(NotificationCenter.mainUserInfoChanged, new Object[0]);
        getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, Integer.valueOf((int) UPDATE_MASK_ALL));
        getUserConfig().saveConfig(true);
    }

    public void processLoadedUserPhotos(TLRPC.photos_Photos photos_photos, int i, int i2, long j, boolean z, int i3) {
        if (!z) {
            getMessagesStorage().putUsersAndChats(photos_photos.users, null, true, true);
            getMessagesStorage().putDialogPhotos(i, photos_photos);
        } else if (photos_photos == null || photos_photos.photos.isEmpty()) {
            loadDialogPhotos(i, i2, j, false, i3);
            return;
        }
        AndroidUtilities.runOnUIThread(new Runnable(photos_photos, z, i, i2, i3) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$q_DfVNQbU0TuLrYgH2wCKAQ_B0 */
            private final /* synthetic */ TLRPC.photos_Photos f$1;
            private final /* synthetic */ boolean f$2;
            private final /* synthetic */ int f$3;
            private final /* synthetic */ int f$4;
            private final /* synthetic */ int f$5;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
                this.f$4 = r5;
                this.f$5 = r6;
            }

            public final void run() {
                MessagesController.this.lambda$processLoadedUserPhotos$71$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5);
            }
        });
    }

    public /* synthetic */ void lambda$processLoadedUserPhotos$71$MessagesController(TLRPC.photos_Photos photos_photos, boolean z, int i, int i2, int i3) {
        putUsers(photos_photos.users, z);
        getNotificationCenter().postNotificationName(NotificationCenter.dialogPhotosLoaded, Integer.valueOf(i), Integer.valueOf(i2), Boolean.valueOf(z), Integer.valueOf(i3), photos_photos.photos);
    }

    public void uploadAndApplyUserAvatar(TLRPC.FileLocation fileLocation) {
        if (fileLocation != null) {
            this.uploadingAvatar = FileLoader.getDirectory(4) + "/" + fileLocation.volume_id + "_" + fileLocation.local_id + ".jpg";
            getFileLoader().uploadFile(this.uploadingAvatar, false, true, 16777216);
        }
    }

    public void uploadAvatar(TLRPC.FileLocation fileLocation) {
        if (fileLocation != null) {
            this.uploadingAvatar = FileLoader.getDirectory(4) + "/" + fileLocation.volume_id + "_" + fileLocation.local_id + ".jpg";
            getFileLoader().uploadFile(this.uploadingAvatar, false, true, 16777216, false);
        }
    }

    public void saveTheme(Theme.ThemeInfo themeInfo, boolean z, boolean z2) {
        if (themeInfo.info != null) {
            TLRPC.TL_account_saveTheme tL_account_saveTheme = new TLRPC.TL_account_saveTheme();
            TLRPC.TL_inputTheme tL_inputTheme = new TLRPC.TL_inputTheme();
            tL_inputTheme.id = themeInfo.info.id;
            tL_inputTheme.access_hash = themeInfo.info.access_hash;
            tL_account_saveTheme.theme = tL_inputTheme;
            tL_account_saveTheme.unsave = z2;
            getConnectionsManager().sendRequest(tL_account_saveTheme, $$Lambda$MessagesController$GKXyB5yHrZKa1TzTIYrTP9APWns.INSTANCE);
        }
        if (!z2) {
            installTheme(themeInfo, z);
        }
    }

    public void installTheme(Theme.ThemeInfo themeInfo, boolean z) {
        TLRPC.TL_account_installTheme tL_account_installTheme = new TLRPC.TL_account_installTheme();
        tL_account_installTheme.dark = z;
        if (themeInfo.info != null) {
            tL_account_installTheme.format = "android";
            TLRPC.TL_inputTheme tL_inputTheme = new TLRPC.TL_inputTheme();
            tL_inputTheme.id = themeInfo.info.id;
            tL_inputTheme.access_hash = themeInfo.info.access_hash;
            tL_account_installTheme.theme = tL_inputTheme;
            tL_account_installTheme.flags |= 2;
        }
        getConnectionsManager().sendRequest(tL_account_installTheme, $$Lambda$MessagesController$wDJuSG23rvat1HQvfF36z3K9C0.INSTANCE);
        if (!TextUtils.isEmpty(themeInfo.slug)) {
            TLRPC.TL_account_installWallPaper tL_account_installWallPaper = new TLRPC.TL_account_installWallPaper();
            TLRPC.TL_inputWallPaperSlug tL_inputWallPaperSlug = new TLRPC.TL_inputWallPaperSlug();
            tL_inputWallPaperSlug.slug = themeInfo.slug;
            tL_account_installWallPaper.wallpaper = tL_inputWallPaperSlug;
            tL_account_installWallPaper.settings = new TLRPC.TL_wallPaperSettings();
            tL_account_installWallPaper.settings.blur = themeInfo.isBlured;
            tL_account_installWallPaper.settings.motion = themeInfo.isMotion;
            getConnectionsManager().sendRequest(tL_account_installWallPaper, $$Lambda$MessagesController$EWclq5sKLmylrzm38oKyLW0bSCM.INSTANCE);
        }
    }

    public void saveThemeToServer(Theme.ThemeInfo themeInfo) {
        if (themeInfo != null && !this.uploadingThemes.containsKey(themeInfo.pathToFile)) {
            this.uploadingThemes.put(themeInfo.pathToFile, themeInfo);
            Utilities.globalQueue.postRunnable(new Runnable(themeInfo) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$NwZOEfTQeX9CbJWLsUZ3WJDFnt0 */
                private final /* synthetic */ Theme.ThemeInfo f$1;

                {
                    this.f$1 = r2;
                }

                public final void run() {
                    MessagesController.this.lambda$saveThemeToServer$76$MessagesController(this.f$1);
                }
            });
        }
    }

    public /* synthetic */ void lambda$saveThemeToServer$76$MessagesController(Theme.ThemeInfo themeInfo) {
        AndroidUtilities.runOnUIThread(new Runnable(Theme.createThemePreviewImage(themeInfo), themeInfo) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$CjAuqDYtgDfVl1ys1z21qh4wXFo */
            private final /* synthetic */ String f$1;
            private final /* synthetic */ Theme.ThemeInfo f$2;

            {
                this.f$1 = r2;
                this.f$2 = r3;
            }

            public final void run() {
                MessagesController.this.lambda$null$75$MessagesController(this.f$1, this.f$2);
            }
        });
    }

    public /* synthetic */ void lambda$null$75$MessagesController(String str, Theme.ThemeInfo themeInfo) {
        if (str == null) {
            this.uploadingThemes.remove(themeInfo.pathToFile);
            return;
        }
        themeInfo.uploadingFile = themeInfo.pathToFile;
        themeInfo.uploadingThumb = str;
        this.uploadingThemes.put(str, themeInfo);
        new File(themeInfo.pathToFile).length();
        new File(str).length();
        getFileLoader().uploadFile(themeInfo.pathToFile, false, true, ConnectionsManager.FileTypeFile);
        getFileLoader().uploadFile(str, false, true, 16777216);
    }

    /* JADX DEBUG: Multi-variable search result rejected for r13v3, resolved type: im.guobwnxjuc.tgnet.TLRPC$TL_account_installWallPaper */
    /* JADX WARN: Multi-variable type inference failed */
    public void saveWallpaperToServer(File file, long j, String str, long j2, boolean z, boolean z2, int i, float f, boolean z3, long j3) {
        TLRPC.TL_account_saveWallPaper tL_account_saveWallPaper;
        long j4;
        NativeByteBuffer nativeByteBuffer;
        Exception e;
        if (this.uploadingWallpaper != null) {
            File file2 = new File(ApplicationLoader.getFilesDirFixed(), this.uploadingWallpaperBlurred ? "wallpaper_original.jpg" : "wallpaper.jpg");
            if (file == null || (!file.getAbsolutePath().equals(this.uploadingWallpaper) && !file.equals(file2))) {
                getFileLoader().cancelUploadFile(this.uploadingWallpaper, false);
                this.uploadingWallpaper = null;
            } else {
                this.uploadingWallpaperMotion = z2;
                this.uploadingWallpaperBlurred = z;
                return;
            }
        }
        if (file != null) {
            this.uploadingWallpaper = file.getAbsolutePath();
            this.uploadingWallpaperMotion = z2;
            this.uploadingWallpaperBlurred = z;
            getFileLoader().uploadFile(this.uploadingWallpaper, false, true, 16777216);
        } else if (j2 != 0) {
            TLRPC.TL_inputWallPaper tL_inputWallPaper = new TLRPC.TL_inputWallPaper();
            tL_inputWallPaper.id = j;
            tL_inputWallPaper.access_hash = j2;
            TLRPC.TL_wallPaperSettings tL_wallPaperSettings = new TLRPC.TL_wallPaperSettings();
            tL_wallPaperSettings.blur = z;
            tL_wallPaperSettings.motion = z2;
            if (i != 0) {
                tL_wallPaperSettings.background_color = i;
                tL_wallPaperSettings.flags = 1 | tL_wallPaperSettings.flags;
                tL_wallPaperSettings.intensity = (int) (100.0f * f);
                tL_wallPaperSettings.flags |= 8;
            }
            if (z3) {
                TLRPC.TL_account_installWallPaper tL_account_installWallPaper = new TLRPC.TL_account_installWallPaper();
                tL_account_installWallPaper.wallpaper = tL_inputWallPaper;
                tL_account_installWallPaper.settings = tL_wallPaperSettings;
                tL_account_saveWallPaper = tL_account_installWallPaper;
            } else {
                TLRPC.TL_account_saveWallPaper tL_account_saveWallPaper2 = new TLRPC.TL_account_saveWallPaper();
                tL_account_saveWallPaper2.wallpaper = tL_inputWallPaper;
                tL_account_saveWallPaper2.settings = tL_wallPaperSettings;
                tL_account_saveWallPaper = tL_account_saveWallPaper2;
            }
            if (j3 != 0) {
                j4 = j3;
            } else {
                try {
                    nativeByteBuffer = new NativeByteBuffer(1024);
                    try {
                        nativeByteBuffer.writeInt32(19);
                        nativeByteBuffer.writeInt64(j);
                        nativeByteBuffer.writeInt64(j2);
                        nativeByteBuffer.writeBool(z);
                        nativeByteBuffer.writeBool(z2);
                        nativeByteBuffer.writeInt32(i);
                        nativeByteBuffer.writeDouble((double) f);
                        nativeByteBuffer.writeBool(z3);
                        if (str != null) {
                            nativeByteBuffer.writeString(str);
                        } else {
                            nativeByteBuffer.writeString("");
                        }
                        nativeByteBuffer.limit(nativeByteBuffer.position());
                    } catch (Exception e2) {
                        e = e2;
                        FileLog.e(e);
                        j4 = getMessagesStorage().createPendingTask(nativeByteBuffer);
                        getConnectionsManager().sendRequest(tL_account_saveWallPaper, new RequestDelegate(j4, z3, j, str) {
                            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$LS2cTO1Z2gPf8s13BIL3r0BICo */
                            private final /* synthetic */ long f$1;
                            private final /* synthetic */ boolean f$2;
                            private final /* synthetic */ long f$3;
                            private final /* synthetic */ String f$4;

                            {
                                this.f$1 = r2;
                                this.f$2 = r4;
                                this.f$3 = r5;
                                this.f$4 = r7;
                            }

                            @Override // im.guobwnxjuc.tgnet.RequestDelegate
                            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                                MessagesController.this.lambda$saveWallpaperToServer$77$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, tLObject, tL_error);
                            }
                        });
                    }
                } catch (Exception e3) {
                    e = e3;
                    nativeByteBuffer = null;
                    FileLog.e(e);
                    j4 = getMessagesStorage().createPendingTask(nativeByteBuffer);
                    getConnectionsManager().sendRequest(tL_account_saveWallPaper, new RequestDelegate(j4, z3, j, str) {
                        /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$LS2cTO1Z2gPf8s13BIL3r0BICo */
                        private final /* synthetic */ long f$1;
                        private final /* synthetic */ boolean f$2;
                        private final /* synthetic */ long f$3;
                        private final /* synthetic */ String f$4;

                        {
                            this.f$1 = r2;
                            this.f$2 = r4;
                            this.f$3 = r5;
                            this.f$4 = r7;
                        }

                        @Override // im.guobwnxjuc.tgnet.RequestDelegate
                        public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                            MessagesController.this.lambda$saveWallpaperToServer$77$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, tLObject, tL_error);
                        }
                    });
                }
                j4 = getMessagesStorage().createPendingTask(nativeByteBuffer);
            }
            getConnectionsManager().sendRequest(tL_account_saveWallPaper, new RequestDelegate(j4, z3, j, str) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$LS2cTO1Z2gPf8s13BIL3r0BICo */
                private final /* synthetic */ long f$1;
                private final /* synthetic */ boolean f$2;
                private final /* synthetic */ long f$3;
                private final /* synthetic */ String f$4;

                {
                    this.f$1 = r2;
                    this.f$2 = r4;
                    this.f$3 = r5;
                    this.f$4 = r7;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$saveWallpaperToServer$77$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$saveWallpaperToServer$77$MessagesController(long j, boolean z, long j2, String str, TLObject tLObject, TLRPC.TL_error tL_error) {
        getMessagesStorage().removePendingTask(j);
        if (!z && this.uploadingWallpaper != null) {
            SharedPreferences.Editor edit = getGlobalMainSettings().edit();
            edit.putLong("selectedBackground2", j2);
            if (!TextUtils.isEmpty(str)) {
                edit.putString("selectedBackgroundSlug", str);
            } else {
                edit.remove("selectedBackgroundSlug");
            }
            edit.commit();
        }
    }

    public void markChannelDialogMessageAsDeleted(ArrayList<Integer> arrayList, int i) {
        MessageObject messageObject = this.dialogMessage.get((long) (-i));
        if (messageObject != null) {
            for (int i2 = 0; i2 < arrayList.size(); i2++) {
                if (messageObject.getId() == arrayList.get(i2).intValue()) {
                    messageObject.deleted = true;
                    return;
                }
            }
        }
    }

    public void deleteMessages(ArrayList<Integer> arrayList, ArrayList<Long> arrayList2, TLRPC.EncryptedChat encryptedChat, long j, int i, boolean z, boolean z2) {
        deleteMessages(arrayList, arrayList2, encryptedChat, j, i, true, z2, 0, null);
    }

    public void deleteMessages(ArrayList<Integer> arrayList, ArrayList<Long> arrayList2, TLRPC.EncryptedChat encryptedChat, long j, int i, boolean z, boolean z2, long j2, TLObject tLObject) {
        ArrayList<Integer> arrayList3;
        long j3;
        TLRPC.TL_messages_deleteMessages tL_messages_deleteMessages;
        NativeByteBuffer nativeByteBuffer;
        Exception e;
        long j4;
        TLRPC.TL_channels_deleteMessages tL_channels_deleteMessages;
        NativeByteBuffer nativeByteBuffer2;
        Exception e2;
        long j5;
        TLRPC.TL_messages_deleteScheduledMessages tL_messages_deleteScheduledMessages;
        NativeByteBuffer nativeByteBuffer3;
        Exception e3;
        char c;
        if ((arrayList != null && !arrayList.isEmpty()) || tLObject != null) {
            NativeByteBuffer nativeByteBuffer4 = null;
            if (j2 == 0) {
                arrayList3 = new ArrayList<>();
                for (int i2 = 0; i2 < arrayList.size(); i2++) {
                    Integer num = arrayList.get(i2);
                    if (num.intValue() > 0) {
                        arrayList3.add(num);
                    }
                }
                if (z2) {
                    c = 1;
                    getMessagesStorage().markMessagesAsDeleted(arrayList, true, i, false, true);
                } else {
                    c = 1;
                    if (i == 0) {
                        for (int i3 = 0; i3 < arrayList.size(); i3++) {
                            MessageObject messageObject = this.dialogMessagesByIds.get(arrayList.get(i3).intValue());
                            if (messageObject != null) {
                                messageObject.deleted = true;
                            }
                        }
                    } else {
                        markChannelDialogMessageAsDeleted(arrayList, i);
                    }
                    getMessagesStorage().markMessagesAsDeleted(arrayList, true, i, z, false);
                    getMessagesStorage().updateDialogsWithDeletedMessages(arrayList, null, true, i);
                }
                NotificationCenter notificationCenter = getNotificationCenter();
                int i4 = NotificationCenter.messagesDeleted;
                Object[] objArr = new Object[3];
                objArr[0] = arrayList;
                objArr[c] = Integer.valueOf(i);
                objArr[2] = Boolean.valueOf(z2);
                notificationCenter.postNotificationName(i4, objArr);
            } else {
                arrayList3 = null;
            }
            if (z2) {
                if (tLObject != null) {
                    tL_messages_deleteScheduledMessages = (TLRPC.TL_messages_deleteScheduledMessages) tLObject;
                    j5 = j2;
                } else {
                    TLRPC.TL_messages_deleteScheduledMessages tL_messages_deleteScheduledMessages2 = new TLRPC.TL_messages_deleteScheduledMessages();
                    tL_messages_deleteScheduledMessages2.id = arrayList3;
                    tL_messages_deleteScheduledMessages2.peer = getInputPeer((int) j);
                    try {
                        nativeByteBuffer3 = new NativeByteBuffer(tL_messages_deleteScheduledMessages2.getObjectSize() + 16);
                        try {
                            nativeByteBuffer3.writeInt32(18);
                            nativeByteBuffer3.writeInt64(j);
                            nativeByteBuffer3.writeInt32(i);
                            tL_messages_deleteScheduledMessages2.serializeToStream(nativeByteBuffer3);
                        } catch (Exception e4) {
                            e3 = e4;
                            nativeByteBuffer4 = nativeByteBuffer3;
                        }
                    } catch (Exception e5) {
                        e3 = e5;
                        FileLog.e(e3);
                        nativeByteBuffer3 = nativeByteBuffer4;
                        j5 = MessagesStorage.getInstance(this.currentAccount).createPendingTask(nativeByteBuffer3);
                        tL_messages_deleteScheduledMessages = tL_messages_deleteScheduledMessages2;
                        ConnectionsManager.getInstance(this.currentAccount).sendRequest(tL_messages_deleteScheduledMessages, new RequestDelegate(j5) {
                            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$aVgHZ0CUCN1hPE_dAMH2YRRl4j8 */
                            private final /* synthetic */ long f$1;

                            {
                                this.f$1 = r2;
                            }

                            @Override // im.guobwnxjuc.tgnet.RequestDelegate
                            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                                MessagesController.this.lambda$deleteMessages$78$MessagesController(this.f$1, tLObject, tL_error);
                            }
                        });
                    }
                    j5 = MessagesStorage.getInstance(this.currentAccount).createPendingTask(nativeByteBuffer3);
                    tL_messages_deleteScheduledMessages = tL_messages_deleteScheduledMessages2;
                }
                ConnectionsManager.getInstance(this.currentAccount).sendRequest(tL_messages_deleteScheduledMessages, new RequestDelegate(j5) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$aVgHZ0CUCN1hPE_dAMH2YRRl4j8 */
                    private final /* synthetic */ long f$1;

                    {
                        this.f$1 = r2;
                    }

                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        MessagesController.this.lambda$deleteMessages$78$MessagesController(this.f$1, tLObject, tL_error);
                    }
                });
            } else if (i != 0) {
                if (tLObject != null) {
                    tL_channels_deleteMessages = (TLRPC.TL_channels_deleteMessages) tLObject;
                    j4 = j2;
                } else {
                    TLRPC.TL_channels_deleteMessages tL_channels_deleteMessages2 = new TLRPC.TL_channels_deleteMessages();
                    tL_channels_deleteMessages2.id = arrayList3;
                    tL_channels_deleteMessages2.channel = getInputChannel(i);
                    try {
                        nativeByteBuffer2 = new NativeByteBuffer(tL_channels_deleteMessages2.getObjectSize() + 8);
                        try {
                            nativeByteBuffer2.writeInt32(7);
                            nativeByteBuffer2.writeInt32(i);
                            tL_channels_deleteMessages2.serializeToStream(nativeByteBuffer2);
                        } catch (Exception e6) {
                            e2 = e6;
                            nativeByteBuffer4 = nativeByteBuffer2;
                        }
                    } catch (Exception e7) {
                        e2 = e7;
                        FileLog.e(e2);
                        nativeByteBuffer2 = nativeByteBuffer4;
                        j4 = getMessagesStorage().createPendingTask(nativeByteBuffer2);
                        tL_channels_deleteMessages = tL_channels_deleteMessages2;
                        getConnectionsManager().sendRequest(tL_channels_deleteMessages, new RequestDelegate(i, j4) {
                            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$3OJCJ9C6bY7xrDCjiW7a1gozn0o */
                            private final /* synthetic */ int f$1;
                            private final /* synthetic */ long f$2;

                            {
                                this.f$1 = r2;
                                this.f$2 = r3;
                            }

                            @Override // im.guobwnxjuc.tgnet.RequestDelegate
                            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                                MessagesController.this.lambda$deleteMessages$79$MessagesController(this.f$1, this.f$2, tLObject, tL_error);
                            }
                        });
                    }
                    j4 = getMessagesStorage().createPendingTask(nativeByteBuffer2);
                    tL_channels_deleteMessages = tL_channels_deleteMessages2;
                }
                getConnectionsManager().sendRequest(tL_channels_deleteMessages, new RequestDelegate(i, j4) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$3OJCJ9C6bY7xrDCjiW7a1gozn0o */
                    private final /* synthetic */ int f$1;
                    private final /* synthetic */ long f$2;

                    {
                        this.f$1 = r2;
                        this.f$2 = r3;
                    }

                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        MessagesController.this.lambda$deleteMessages$79$MessagesController(this.f$1, this.f$2, tLObject, tL_error);
                    }
                });
            } else {
                if (!(arrayList2 == null || encryptedChat == null || arrayList2.isEmpty())) {
                    getSecretChatHelper().sendMessagesDeleteMessage(encryptedChat, arrayList2, null);
                }
                if (tLObject != null) {
                    tL_messages_deleteMessages = (TLRPC.TL_messages_deleteMessages) tLObject;
                    j3 = j2;
                } else {
                    TLRPC.TL_messages_deleteMessages tL_messages_deleteMessages2 = new TLRPC.TL_messages_deleteMessages();
                    tL_messages_deleteMessages2.id = arrayList3;
                    tL_messages_deleteMessages2.revoke = z;
                    try {
                        nativeByteBuffer = new NativeByteBuffer(tL_messages_deleteMessages2.getObjectSize() + 8);
                        try {
                            nativeByteBuffer.writeInt32(7);
                            nativeByteBuffer.writeInt32(i);
                            tL_messages_deleteMessages2.serializeToStream(nativeByteBuffer);
                        } catch (Exception e8) {
                            e = e8;
                            nativeByteBuffer4 = nativeByteBuffer;
                        }
                    } catch (Exception e9) {
                        e = e9;
                        FileLog.e(e);
                        nativeByteBuffer = nativeByteBuffer4;
                        j3 = getMessagesStorage().createPendingTask(nativeByteBuffer);
                        tL_messages_deleteMessages = tL_messages_deleteMessages2;
                        getConnectionsManager().sendRequest(tL_messages_deleteMessages, new RequestDelegate(j3) {
                            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$AmDChsvTqbpcRBTskPGBih5hGpI */
                            private final /* synthetic */ long f$1;

                            {
                                this.f$1 = r2;
                            }

                            @Override // im.guobwnxjuc.tgnet.RequestDelegate
                            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                                MessagesController.this.lambda$deleteMessages$80$MessagesController(this.f$1, tLObject, tL_error);
                            }
                        });
                    }
                    j3 = getMessagesStorage().createPendingTask(nativeByteBuffer);
                    tL_messages_deleteMessages = tL_messages_deleteMessages2;
                }
                getConnectionsManager().sendRequest(tL_messages_deleteMessages, new RequestDelegate(j3) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$AmDChsvTqbpcRBTskPGBih5hGpI */
                    private final /* synthetic */ long f$1;

                    {
                        this.f$1 = r2;
                    }

                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        MessagesController.this.lambda$deleteMessages$80$MessagesController(this.f$1, tLObject, tL_error);
                    }
                });
            }
        }
    }

    public /* synthetic */ void lambda$deleteMessages$78$MessagesController(long j, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            processUpdates((TLRPC.Updates) tLObject, false);
        }
        if (j != 0) {
            MessagesStorage.getInstance(this.currentAccount).removePendingTask(j);
        }
    }

    public /* synthetic */ void lambda$deleteMessages$79$MessagesController(int i, long j, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            TLRPC.TL_messages_affectedMessages tL_messages_affectedMessages = (TLRPC.TL_messages_affectedMessages) tLObject;
            processNewChannelDifferenceParams(tL_messages_affectedMessages.pts, tL_messages_affectedMessages.pts_count, i);
        }
        if (j != 0) {
            getMessagesStorage().removePendingTask(j);
        }
    }

    public /* synthetic */ void lambda$deleteMessages$80$MessagesController(long j, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            TLRPC.TL_messages_affectedMessages tL_messages_affectedMessages = (TLRPC.TL_messages_affectedMessages) tLObject;
            processNewDifferenceParams(-1, tL_messages_affectedMessages.pts, -1, tL_messages_affectedMessages.pts_count);
        }
        if (j != 0) {
            getMessagesStorage().removePendingTask(j);
        }
    }

    public void pinMessage(TLRPC.Chat chat, TLRPC.User user, int i, boolean z) {
        if (chat != null || user != null) {
            TLRPC.TL_messages_updatePinnedMessage tL_messages_updatePinnedMessage = new TLRPC.TL_messages_updatePinnedMessage();
            tL_messages_updatePinnedMessage.peer = getInputPeer(chat != null ? -chat.id : user.id);
            tL_messages_updatePinnedMessage.id = i;
            tL_messages_updatePinnedMessage.silent = !z;
            getConnectionsManager().sendRequest(tL_messages_updatePinnedMessage, new RequestDelegate() {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$LNFpi5LvSr6HQxvyG4PQPL2u_Jw */

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$pinMessage$81$MessagesController(tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$pinMessage$81$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            processUpdates((TLRPC.Updates) tLObject, false);
        }
    }

    public void deleteUserChannelHistory(TLRPC.Chat chat, TLRPC.User user, int i) {
        if (i == 0) {
            getMessagesStorage().deleteUserChannelHistory(chat.id, user.id);
        }
        TLRPC.TL_channels_deleteUserHistory tL_channels_deleteUserHistory = new TLRPC.TL_channels_deleteUserHistory();
        tL_channels_deleteUserHistory.channel = getInputChannel(chat);
        tL_channels_deleteUserHistory.user_id = getInputUser(user);
        getConnectionsManager().sendRequest(tL_channels_deleteUserHistory, new RequestDelegate(chat, user) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$Wt5ThAFXAilScudDVKooDYw7kQw */
            private final /* synthetic */ TLRPC.Chat f$1;
            private final /* synthetic */ TLRPC.User f$2;

            {
                this.f$1 = r2;
                this.f$2 = r3;
            }

            @Override // im.guobwnxjuc.tgnet.RequestDelegate
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                MessagesController.this.lambda$deleteUserChannelHistory$82$MessagesController(this.f$1, this.f$2, tLObject, tL_error);
            }
        });
    }

    public /* synthetic */ void lambda$deleteUserChannelHistory$82$MessagesController(TLRPC.Chat chat, TLRPC.User user, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            TLRPC.TL_messages_affectedHistory tL_messages_affectedHistory = (TLRPC.TL_messages_affectedHistory) tLObject;
            if (tL_messages_affectedHistory.offset > 0) {
                deleteUserChannelHistory(chat, user, tL_messages_affectedHistory.offset);
            }
            processNewChannelDifferenceParams(tL_messages_affectedHistory.pts, tL_messages_affectedHistory.pts_count, chat.id);
        }
    }

    public ArrayList<TLRPC.Dialog> getAllDialogs() {
        return this.allDialogs;
    }

    public boolean isDialogsEndReached(int i) {
        return this.dialogsEndReached.get(i);
    }

    public boolean isLoadingDialogs(int i) {
        return this.loadingDialogs.get(i);
    }

    public boolean isServerDialogsEndReached(int i) {
        return this.serverDialogsEndReached.get(i);
    }

    public boolean hasHiddenArchive() {
        return SharedConfig.archiveHidden && this.dialogs_dict.get(DialogObject.makeFolderDialogId(1)) != null;
    }

    public ArrayList<TLRPC.Dialog> getDialogs(int i) {
        ArrayList<TLRPC.Dialog> arrayList = this.dialogsByFolder.get(i);
        return arrayList == null ? new ArrayList<>() : arrayList;
    }

    private void removeDialog(TLRPC.Dialog dialog) {
        if (dialog != null) {
            long j = dialog.id;
            if (this.dialogsServerOnly.remove(dialog) && DialogObject.isChannel(dialog)) {
                Utilities.stageQueue.postRunnable(new Runnable(j) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$8BEx8tgssWz6H2r6Je05hBTn5QE */
                    private final /* synthetic */ long f$1;

                    {
                        this.f$1 = r2;
                    }

                    public final void run() {
                        MessagesController.this.lambda$removeDialog$83$MessagesController(this.f$1);
                    }
                });
            }
            this.allDialogs.remove(dialog);
            this.dialogsCanAddUsers.remove(dialog);
            this.dialogsChannelsOnly.remove(dialog);
            this.dialogsGroupsOnly.remove(dialog);
            this.dialogsUnreadOnly.remove(dialog);
            this.dialogsUsersOnly.remove(dialog);
            this.dialogsForward.remove(dialog);
            this.dialogs_dict.remove(j);
            this.dialogs_read_inbox_max.remove(Long.valueOf(j));
            this.dialogs_read_outbox_max.remove(Long.valueOf(j));
            ArrayList<TLRPC.Dialog> arrayList = this.dialogsByFolder.get(dialog.folder_id);
            if (arrayList != null) {
                arrayList.remove(dialog);
            }
        }
    }

    public /* synthetic */ void lambda$removeDialog$83$MessagesController(long j) {
        int i = -((int) j);
        this.channelsPts.delete(i);
        this.shortPollChannels.delete(i);
        this.needShortPollChannels.delete(i);
        this.shortPollOnlines.delete(i);
        this.needShortPollOnlines.delete(i);
    }

    public void deleteDialog(long j, int i) {
        deleteDialog(j, i, false);
    }

    public void deleteDialog(long j, int i, boolean z) {
        deleteDialog(j, true, i, 0, z, null, 0);
    }

    public void setDialogsInTransaction(boolean z) {
        this.dialogsInTransaction = z;
        if (!z) {
            getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, true);
        }
    }

    /* access modifiers changed from: protected */
    /* JADX WARNING: Removed duplicated region for block: B:102:0x0284  */
    /* JADX WARNING: Removed duplicated region for block: B:110:0x02c9  */
    public void deleteDialog(long j, boolean z, int i, int i2, boolean z2, TLRPC.InputPeer inputPeer, long j2) {
        MessagesController messagesController;
        int i3;
        int i4;
        boolean z3;
        long j3;
        NativeByteBuffer nativeByteBuffer;
        Exception e;
        boolean z4;
        int i5;
        int i6;
        int i7;
        TLRPC.Chat chat;
        if (i == 2) {
            getMessagesStorage().deleteDialog(j, i);
            return;
        }
        if (i == 0 || i == 3) {
            getMediaDataController().uninstallShortcut(j);
        }
        int i8 = (int) j;
        int i9 = (int) (j >> 32);
        if (z) {
            getMessagesStorage().deleteDialog(j, i);
            TLRPC.Dialog dialog = this.dialogs_dict.get(j);
            if (i == 0 || i == 3) {
                getNotificationsController().deleteNotificationChannel(j);
            }
            if (dialog != null) {
                i5 = i2 == 0 ? Math.max(Math.max(Math.max(0, dialog.top_message), dialog.read_inbox_max_id), dialog.read_outbox_max_id) : i2;
                if (i == 0 || i == 3) {
                    TLRPC.Dialog dialog2 = this.proxyDialog;
                    i6 = i8;
                    z4 = dialog2 != null && dialog2.id == j;
                    if (z4) {
                        this.isLeftProxyChannel = true;
                        if (this.proxyDialog.id < 0 && (chat = getChat(Integer.valueOf(-((int) this.proxyDialog.id)))) != null) {
                            chat.left = true;
                        }
                        sortDialogs(null);
                        dialog = dialog;
                    } else {
                        removeDialog(dialog);
                        int i10 = this.nextDialogsCacheOffset.get(dialog.folder_id, 0);
                        if (i10 > 0) {
                            this.nextDialogsCacheOffset.put(dialog.folder_id, i10 - 1);
                        }
                    }
                } else {
                    dialog.unread_count = 0;
                    i6 = i8;
                    z4 = false;
                }
                if (!z4) {
                    MessageObject messageObject = this.dialogMessage.get(dialog.id);
                    this.dialogMessage.remove(dialog.id);
                    if (messageObject != null) {
                        i7 = messageObject.getId();
                        this.dialogMessagesByIds.remove(messageObject.getId());
                    } else {
                        i7 = dialog.top_message;
                        messageObject = this.dialogMessagesByIds.get(dialog.top_message);
                        this.dialogMessagesByIds.remove(dialog.top_message);
                    }
                    if (!(messageObject == null || messageObject.messageOwner.random_id == 0)) {
                        this.dialogMessagesByRandomIds.remove(messageObject.messageOwner.random_id);
                    }
                    if (i != 1 || i6 == 0 || i7 <= 0) {
                        messagesController = this;
                        i3 = i6;
                        dialog.top_message = 0;
                    } else {
                        TLRPC.TL_messageService tL_messageService = new TLRPC.TL_messageService();
                        tL_messageService.id = dialog.top_message;
                        tL_messageService.out = ((long) getUserConfig().getClientUserId()) == j;
                        tL_messageService.from_id = getUserConfig().getClientUserId();
                        tL_messageService.flags |= 256;
                        tL_messageService.action = new TLRPC.TL_messageActionHistoryClear();
                        tL_messageService.date = dialog.last_message_date;
                        i3 = i6;
                        tL_messageService.dialog_id = (long) i3;
                        if (i3 > 0) {
                            tL_messageService.to_id = new TLRPC.TL_peerUser();
                            tL_messageService.to_id.user_id = i3;
                        } else {
                            int i11 = -i3;
                            if (ChatObject.isChannel(getChat(Integer.valueOf(i11)))) {
                                tL_messageService.to_id = new TLRPC.TL_peerChannel();
                                tL_messageService.to_id.channel_id = i11;
                            } else {
                                tL_messageService.to_id = new TLRPC.TL_peerChat();
                                tL_messageService.to_id.chat_id = i11;
                            }
                        }
                        MessageObject messageObject2 = new MessageObject(this.currentAccount, tL_messageService, this.createdDialogIds.contains(Long.valueOf(tL_messageService.dialog_id)));
                        ArrayList<MessageObject> arrayList = new ArrayList<>();
                        arrayList.add(messageObject2);
                        ArrayList<TLRPC.Message> arrayList2 = new ArrayList<>();
                        arrayList2.add(tL_messageService);
                        messagesController = this;
                        messagesController.updateInterfaceWithMessages(j, arrayList, false);
                        getMessagesStorage().putMessages(arrayList2, false, true, false, 0, false);
                    }
                } else {
                    messagesController = this;
                    i3 = i6;
                }
            } else {
                i3 = i8;
                messagesController = this;
                i5 = i2;
                z4 = false;
            }
            if (messagesController.dialogsInTransaction) {
                z3 = false;
            } else if (z4) {
                z3 = false;
                getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, true);
            } else {
                z3 = false;
                getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
                getNotificationCenter().postNotificationName(NotificationCenter.removeAllMessagesFromDialog, Long.valueOf(j), false);
            }
            getMessagesStorage().getStorageQueue().postRunnable(new Runnable(j) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$u9SBmMcNx63pblEg13aohcH47X8 */
                private final /* synthetic */ long f$1;

                {
                    this.f$1 = r2;
                }

                public final void run() {
                    MessagesController.this.lambda$deleteDialog$85$MessagesController(this.f$1);
                }
            });
            i4 = i5;
        } else {
            i3 = i8;
            messagesController = this;
            z3 = false;
            i4 = i2;
        }
        if (i != 3) {
            if (i3 != 0) {
                TLRPC.InputPeer inputPeer2 = inputPeer == null ? messagesController.getInputPeer(i3) : inputPeer;
                if (inputPeer2 != null) {
                    boolean z5 = inputPeer2 instanceof TLRPC.TL_inputPeerChannel;
                    int i12 = Integer.MAX_VALUE;
                    if (!z5 || i != 0) {
                        if (i4 > 0 && i4 != Integer.MAX_VALUE) {
                            messagesController.deletedHistory.put(j, Integer.valueOf(i4));
                        }
                        if (j2 == 0) {
                            try {
                                nativeByteBuffer = new NativeByteBuffer(inputPeer2.getObjectSize() + 28);
                                try {
                                    nativeByteBuffer.writeInt32(13);
                                    nativeByteBuffer.writeInt64(j);
                                    nativeByteBuffer.writeBool(z);
                                    nativeByteBuffer.writeInt32(i);
                                    nativeByteBuffer.writeInt32(i4);
                                    nativeByteBuffer.writeBool(z2);
                                    inputPeer2.serializeToStream(nativeByteBuffer);
                                } catch (Exception e2) {
                                    e = e2;
                                }
                            } catch (Exception e3) {
                                e = e3;
                                nativeByteBuffer = null;
                                FileLog.e(e);
                                j3 = getMessagesStorage().createPendingTask(nativeByteBuffer);
                                if (!z5) {
                                }
                            }
                            j3 = getMessagesStorage().createPendingTask(nativeByteBuffer);
                            if (!z5) {
                                TLRPC.TL_messages_deleteHistory tL_messages_deleteHistory = new TLRPC.TL_messages_deleteHistory();
                                tL_messages_deleteHistory.peer = inputPeer2;
                                if (i != 0) {
                                    i12 = i4;
                                }
                                tL_messages_deleteHistory.max_id = i12;
                                if (i != 0) {
                                    z3 = true;
                                }
                                tL_messages_deleteHistory.just_clear = z3;
                                tL_messages_deleteHistory.revoke = z2;
                                getConnectionsManager().sendRequest(tL_messages_deleteHistory, new RequestDelegate(j3, j, i, i4, z2, inputPeer2) {
                                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$EB4G4h9WOEghJGwwiDYSSbK_DLs */
                                    private final /* synthetic */ long f$1;
                                    private final /* synthetic */ long f$2;
                                    private final /* synthetic */ int f$3;
                                    private final /* synthetic */ int f$4;
                                    private final /* synthetic */ boolean f$5;
                                    private final /* synthetic */ TLRPC.InputPeer f$6;

                                    {
                                        this.f$1 = r2;
                                        this.f$2 = r4;
                                        this.f$3 = r6;
                                        this.f$4 = r7;
                                        this.f$5 = r8;
                                        this.f$6 = r9;
                                    }

                                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                                        MessagesController.this.lambda$deleteDialog$88$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6, tLObject, tL_error);
                                    }
                                }, 64);
                                return;
                            } else if (i != 0) {
                                TLRPC.TL_channels_deleteHistory tL_channels_deleteHistory = new TLRPC.TL_channels_deleteHistory();
                                tL_channels_deleteHistory.channel = new TLRPC.TL_inputChannel();
                                tL_channels_deleteHistory.channel.channel_id = inputPeer2.channel_id;
                                tL_channels_deleteHistory.channel.access_hash = inputPeer2.access_hash;
                                if (i4 <= 0) {
                                    i4 = Integer.MAX_VALUE;
                                }
                                tL_channels_deleteHistory.max_id = i4;
                                getConnectionsManager().sendRequest(tL_channels_deleteHistory, new RequestDelegate(j3, j) {
                                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$eipTEq6uqQrkeZGjjpfzYCSgWko */
                                    private final /* synthetic */ long f$1;
                                    private final /* synthetic */ long f$2;

                                    {
                                        this.f$1 = r2;
                                        this.f$2 = r4;
                                    }

                                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                                        MessagesController.this.lambda$deleteDialog$87$MessagesController(this.f$1, this.f$2, tLObject, tL_error);
                                    }
                                }, 64);
                                return;
                            } else if (j3 != 0) {
                                getMessagesStorage().removePendingTask(j3);
                                return;
                            } else {
                                return;
                            }
                        }
                    }
                    j3 = j2;
                    if (!z5) {
                    }
                }
            } else if (i == 1) {
                getSecretChatHelper().sendClearHistoryMessage(messagesController.getEncryptedChat(Integer.valueOf(i9)), null);
            } else {
                getSecretChatHelper().declineSecretChat(i9);
            }
        }
    }

    public /* synthetic */ void lambda$deleteDialog$85$MessagesController(long j) {
        AndroidUtilities.runOnUIThread(new Runnable(j) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$lCIuf9Q1D_b6jjyQYntKc_9BA */
            private final /* synthetic */ long f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                MessagesController.this.lambda$null$84$MessagesController(this.f$1);
            }
        });
    }

    public /* synthetic */ void lambda$null$84$MessagesController(long j) {
        getNotificationsController().removeNotificationsForDialog(j);
    }

    public /* synthetic */ void lambda$deleteDialog$87$MessagesController(long j, long j2, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (j != 0) {
            getMessagesStorage().removePendingTask(j);
        }
        AndroidUtilities.runOnUIThread(new Runnable(j2) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$dly_REFyV4jmzY8_5EboZaluiHA */
            private final /* synthetic */ long f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                MessagesController.this.lambda$null$86$MessagesController(this.f$1);
            }
        });
    }

    public /* synthetic */ void lambda$null$86$MessagesController(long j) {
        this.deletedHistory.remove(j);
    }

    public /* synthetic */ void lambda$deleteDialog$88$MessagesController(long j, long j2, int i, int i2, boolean z, TLRPC.InputPeer inputPeer, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (j != 0) {
            getMessagesStorage().removePendingTask(j);
        }
        if (tL_error == null) {
            TLRPC.TL_messages_affectedHistory tL_messages_affectedHistory = (TLRPC.TL_messages_affectedHistory) tLObject;
            if (tL_messages_affectedHistory.offset > 0) {
                deleteDialog(j2, false, i, i2, z, inputPeer, 0);
            }
            processNewDifferenceParams(-1, tL_messages_affectedHistory.pts, -1, tL_messages_affectedHistory.pts_count);
            getMessagesStorage().onDeleteQueryComplete(j2);
        }
    }

    public void saveGif(Object obj, TLRPC.Document document) {
        if (obj != null && MessageObject.isGifDocument(document)) {
            TLRPC.TL_messages_saveGif tL_messages_saveGif = new TLRPC.TL_messages_saveGif();
            tL_messages_saveGif.id = new TLRPC.TL_inputDocument();
            tL_messages_saveGif.id.id = document.id;
            tL_messages_saveGif.id.access_hash = document.access_hash;
            tL_messages_saveGif.id.file_reference = document.file_reference;
            if (tL_messages_saveGif.id.file_reference == null) {
                tL_messages_saveGif.id.file_reference = new byte[0];
            }
            tL_messages_saveGif.unsave = false;
            getConnectionsManager().sendRequest(tL_messages_saveGif, new RequestDelegate(obj, tL_messages_saveGif) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$KdsE3_ElzQEha19CwWeH3GArEo */
                private final /* synthetic */ Object f$1;
                private final /* synthetic */ TLRPC.TL_messages_saveGif f$2;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$saveGif$89$MessagesController(this.f$1, this.f$2, tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$saveGif$89$MessagesController(Object obj, TLRPC.TL_messages_saveGif tL_messages_saveGif, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error != null && FileRefController.isFileRefError(tL_error.text) && obj != null) {
            getFileRefController().requestReference(obj, tL_messages_saveGif);
        }
    }

    public void saveRecentSticker(Object obj, TLRPC.Document document, boolean z) {
        if (obj != null && document != null) {
            TLRPC.TL_messages_saveRecentSticker tL_messages_saveRecentSticker = new TLRPC.TL_messages_saveRecentSticker();
            tL_messages_saveRecentSticker.id = new TLRPC.TL_inputDocument();
            tL_messages_saveRecentSticker.id.id = document.id;
            tL_messages_saveRecentSticker.id.access_hash = document.access_hash;
            tL_messages_saveRecentSticker.id.file_reference = document.file_reference;
            if (tL_messages_saveRecentSticker.id.file_reference == null) {
                tL_messages_saveRecentSticker.id.file_reference = new byte[0];
            }
            tL_messages_saveRecentSticker.unsave = false;
            tL_messages_saveRecentSticker.attached = z;
            getConnectionsManager().sendRequest(tL_messages_saveRecentSticker, new RequestDelegate(obj, tL_messages_saveRecentSticker) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$5TUm2WG2HOasp20NNuu0D2sNyMw */
                private final /* synthetic */ Object f$1;
                private final /* synthetic */ TLRPC.TL_messages_saveRecentSticker f$2;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$saveRecentSticker$90$MessagesController(this.f$1, this.f$2, tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$saveRecentSticker$90$MessagesController(Object obj, TLRPC.TL_messages_saveRecentSticker tL_messages_saveRecentSticker, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error != null && FileRefController.isFileRefError(tL_error.text) && obj != null) {
            getFileRefController().requestReference(obj, tL_messages_saveRecentSticker);
        }
    }

    public void loadChannelParticipants(Integer num) {
        if (!this.loadingFullParticipants.contains(num) && !this.loadedFullParticipants.contains(num)) {
            this.loadingFullParticipants.add(num);
            TLRPC.TL_channels_getParticipants tL_channels_getParticipants = new TLRPC.TL_channels_getParticipants();
            tL_channels_getParticipants.channel = getInputChannel(num.intValue());
            tL_channels_getParticipants.filter = new TLRPC.TL_channelParticipantsRecent();
            tL_channels_getParticipants.offset = 0;
            tL_channels_getParticipants.limit = 32;
            getConnectionsManager().sendRequest(tL_channels_getParticipants, new RequestDelegate(num) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$MTu4_GgoSApa31TeTaO5wzE1LGg */
                private final /* synthetic */ Integer f$1;

                {
                    this.f$1 = r2;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$loadChannelParticipants$92$MessagesController(this.f$1, tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$loadChannelParticipants$92$MessagesController(Integer num, TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable(tL_error, tLObject, num) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$20yu5NwW4MhDR8FhB8klSiob67g */
            private final /* synthetic */ TLRPC.TL_error f$1;
            private final /* synthetic */ TLObject f$2;
            private final /* synthetic */ Integer f$3;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
            }

            public final void run() {
                MessagesController.this.lambda$null$91$MessagesController(this.f$1, this.f$2, this.f$3);
            }
        });
    }

    public /* synthetic */ void lambda$null$91$MessagesController(TLRPC.TL_error tL_error, TLObject tLObject, Integer num) {
        if (tL_error == null && (tLObject instanceof TLRPC.TL_channels_channelParticipants)) {
            TLRPC.TL_channels_channelParticipants tL_channels_channelParticipants = (TLRPC.TL_channels_channelParticipants) tLObject;
            putUsers(tL_channels_channelParticipants.users, false);
            getMessagesStorage().putUsersAndChats(tL_channels_channelParticipants.users, null, true, true);
            getMessagesStorage().updateChannelUsers(num.intValue(), tL_channels_channelParticipants.participants);
            this.loadedFullParticipants.add(num);
        }
        this.loadingFullParticipants.remove(num);
    }

    public void processChatInfo(int i, TLRPC.ChatFull chatFull, ArrayList<TLRPC.User> arrayList, boolean z, boolean z2, boolean z3, MessageObject messageObject) {
        AndroidUtilities.runOnUIThread(new Runnable(z, i, z3, z2, chatFull, arrayList, messageObject) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$W5bsh5ZghRLBERZISrndK4gDqg */
            private final /* synthetic */ boolean f$1;
            private final /* synthetic */ int f$2;
            private final /* synthetic */ boolean f$3;
            private final /* synthetic */ boolean f$4;
            private final /* synthetic */ TLRPC.ChatFull f$5;
            private final /* synthetic */ ArrayList f$6;
            private final /* synthetic */ MessageObject f$7;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
                this.f$4 = r5;
                this.f$5 = r6;
                this.f$6 = r7;
                this.f$7 = r8;
            }

            public final void run() {
                MessagesController.this.lambda$processChatInfo$93$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6, this.f$7);
            }
        });
    }

    public /* synthetic */ void lambda$processChatInfo$93$MessagesController(boolean z, int i, boolean z2, boolean z3, TLRPC.ChatFull chatFull, ArrayList arrayList, MessageObject messageObject) {
        if (z && i > 0 && !z2) {
            loadFullChat(i, 0, z3);
        }
        if (chatFull != null) {
            if (this.fullChats.get(i) == null) {
                this.fullChats.put(i, chatFull);
            }
            putUsers(arrayList, z);
            if (chatFull.stickerset != null) {
                getMediaDataController().getGroupStickerSetById(chatFull.stickerset);
            }
            getNotificationCenter().postNotificationName(NotificationCenter.chatInfoDidLoad, chatFull, 0, Boolean.valueOf(z2), messageObject);
        }
    }

    public void loadUserInfo(TLRPC.User user, boolean z, int i) {
        getMessagesStorage().loadUserInfo(user, z, i);
    }

    public void processUserInfo(TLRPC.User user, TLRPC.UserFull userFull, boolean z, boolean z2, MessageObject messageObject, int i) {
        AndroidUtilities.runOnUIThread(new Runnable(z, user, i, z2, userFull, messageObject) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$VUrddXVjnAhP4KxyYoYKewjGA7U */
            private final /* synthetic */ boolean f$1;
            private final /* synthetic */ TLRPC.User f$2;
            private final /* synthetic */ int f$3;
            private final /* synthetic */ boolean f$4;
            private final /* synthetic */ TLRPC.UserFull f$5;
            private final /* synthetic */ MessageObject f$6;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
                this.f$4 = r5;
                this.f$5 = r6;
                this.f$6 = r7;
            }

            public final void run() {
                MessagesController.this.lambda$processUserInfo$94$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6);
            }
        });
    }

    public /* synthetic */ void lambda$processUserInfo$94$MessagesController(boolean z, TLRPC.User user, int i, boolean z2, TLRPC.UserFull userFull, MessageObject messageObject) {
        if (z) {
            loadFullUser(user, i, z2);
        }
        if (userFull != null) {
            if (this.fullUsers.get(user.id) == null) {
                this.fullUsers.put(user.id, userFull);
                if (userFull.blocked) {
                    this.blockedUsers.put(user.id, 1);
                } else {
                    this.blockedUsers.delete(user.id);
                }
            }
            getNotificationCenter().postNotificationName(NotificationCenter.userFullInfoDidLoad, Integer.valueOf(user.id), userFull, messageObject);
        }
    }

    public void updateTimerProc() {
        ArrayList arrayList;
        long currentTimeMillis = System.currentTimeMillis();
        checkDeletingTask(false);
        checkReadTasks();
        if (getUserConfig().isClientActivated()) {
            if (getConnectionsManager().getPauseTime() != 0 || !ApplicationLoader.isScreenOn || ApplicationLoader.mainInterfacePausedStageQueue) {
                if (this.statusSettingState != 2 && !this.offlineSent && Math.abs(System.currentTimeMillis() - getConnectionsManager().getPauseTime()) >= AdaptiveTrackSelection.DEFAULT_MIN_TIME_BETWEEN_BUFFER_REEVALUTATION_MS) {
                    this.statusSettingState = 2;
                    if (this.statusRequest != 0) {
                        getConnectionsManager().cancelRequest(this.statusRequest, true);
                    }
                    TLRPC.TL_account_updateStatus tL_account_updateStatus = new TLRPC.TL_account_updateStatus();
                    tL_account_updateStatus.offline = true;
                    this.statusRequest = getConnectionsManager().sendRequest(tL_account_updateStatus, new RequestDelegate() {
                        /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$3oW4RvGFvodfw7k5_opKSPYk */

                        @Override // im.guobwnxjuc.tgnet.RequestDelegate
                        public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                            MessagesController.this.lambda$updateTimerProc$96$MessagesController(tLObject, tL_error);
                        }
                    });
                }
            } else if (ApplicationLoader.mainInterfacePausedStageQueueTime != 0 && Math.abs(ApplicationLoader.mainInterfacePausedStageQueueTime - System.currentTimeMillis()) > 1000 && this.statusSettingState != 1 && (this.lastStatusUpdateTime == 0 || Math.abs(System.currentTimeMillis() - this.lastStatusUpdateTime) >= 55000 || this.offlineSent)) {
                this.statusSettingState = 1;
                if (this.statusRequest != 0) {
                    getConnectionsManager().cancelRequest(this.statusRequest, true);
                }
                TLRPC.TL_account_updateStatus tL_account_updateStatus2 = new TLRPC.TL_account_updateStatus();
                tL_account_updateStatus2.offline = false;
                this.statusRequest = getConnectionsManager().sendRequest(tL_account_updateStatus2, new RequestDelegate() {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$a821y4REbiYLtPlTYyn7sSHsn90 */

                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        MessagesController.this.lambda$updateTimerProc$95$MessagesController(tLObject, tL_error);
                    }
                });
            }
            if (this.updatesQueueChannels.size() != 0) {
                for (int i = 0; i < this.updatesQueueChannels.size(); i++) {
                    int keyAt = this.updatesQueueChannels.keyAt(i);
                    if (this.updatesStartWaitTimeChannels.valueAt(i) + 1500 < currentTimeMillis) {
                        if (BuildVars.LOGS_ENABLED) {
                            FileLog.d("QUEUE CHANNEL " + keyAt + " UPDATES WAIT TIMEOUT - CHECK QUEUE");
                        }
                        processChannelsUpdatesQueue(keyAt, 0);
                    }
                }
            }
            for (int i2 = 0; i2 < 3; i2++) {
                if (getUpdatesStartTime(i2) != 0 && getUpdatesStartTime(i2) + 1500 < currentTimeMillis) {
                    if (BuildVars.LOGS_ENABLED) {
                        FileLog.d(i2 + " QUEUE UPDATES WAIT TIMEOUT - CHECK QUEUE");
                    }
                    processUpdatesQueue(i2, 0);
                }
            }
        }
        if (Math.abs(System.currentTimeMillis() - this.lastViewsCheckTime) >= DefaultRenderersFactory.DEFAULT_ALLOWED_VIDEO_JOINING_TIME_MS) {
            this.lastViewsCheckTime = System.currentTimeMillis();
            if (this.channelViewsToSend.size() != 0) {
                int i3 = 0;
                while (i3 < this.channelViewsToSend.size()) {
                    int keyAt2 = this.channelViewsToSend.keyAt(i3);
                    TLRPC.TL_messages_getMessagesViews tL_messages_getMessagesViews = new TLRPC.TL_messages_getMessagesViews();
                    tL_messages_getMessagesViews.peer = getInputPeer(keyAt2);
                    tL_messages_getMessagesViews.id = this.channelViewsToSend.valueAt(i3);
                    tL_messages_getMessagesViews.increment = i3 == 0;
                    getConnectionsManager().sendRequest(tL_messages_getMessagesViews, new RequestDelegate(keyAt2, tL_messages_getMessagesViews) {
                        /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$lshRFq2xHcfZnNF2GpvfdZCLYM4 */
                        private final /* synthetic */ int f$1;
                        private final /* synthetic */ TLRPC.TL_messages_getMessagesViews f$2;

                        {
                            this.f$1 = r2;
                            this.f$2 = r3;
                        }

                        @Override // im.guobwnxjuc.tgnet.RequestDelegate
                        public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                            MessagesController.this.lambda$updateTimerProc$98$MessagesController(this.f$1, this.f$2, tLObject, tL_error);
                        }
                    });
                    i3++;
                }
                this.channelViewsToSend.clear();
            }
            if (this.pollsToCheckSize > 0) {
                AndroidUtilities.runOnUIThread(new Runnable() {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$uIVk1RroHpbScKw_Bin7birJzl4 */

                    public final void run() {
                        MessagesController.this.lambda$updateTimerProc$100$MessagesController();
                    }
                });
            }
        }
        if (!this.onlinePrivacy.isEmpty()) {
            ArrayList arrayList2 = null;
            int currentTime = getConnectionsManager().getCurrentTime();
            for (Map.Entry<Integer, Integer> entry : this.onlinePrivacy.entrySet()) {
                if (entry.getValue().intValue() < currentTime - 30) {
                    if (arrayList2 == null) {
                        arrayList2 = new ArrayList();
                    }
                    arrayList2.add(entry.getKey());
                }
            }
            if (arrayList2 != null) {
                Iterator it = arrayList2.iterator();
                while (it.hasNext()) {
                    this.onlinePrivacy.remove((Integer) it.next());
                }
                AndroidUtilities.runOnUIThread(new Runnable() {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$1PJTlV5matJj_UJDeNOixMxLk */

                    public final void run() {
                        MessagesController.this.lambda$updateTimerProc$101$MessagesController();
                    }
                });
            }
        }
        if (this.shortPollChannels.size() != 0) {
            int i4 = 0;
            while (i4 < this.shortPollChannels.size()) {
                int keyAt3 = this.shortPollChannels.keyAt(i4);
                if (((long) this.shortPollChannels.valueAt(i4)) < System.currentTimeMillis() / 1000) {
                    this.shortPollChannels.delete(keyAt3);
                    i4--;
                    if (this.needShortPollChannels.indexOfKey(keyAt3) >= 0) {
                        getChannelDifference(keyAt3);
                    }
                }
                i4++;
            }
        }
        if (this.shortPollOnlines.size() != 0) {
            long uptimeMillis = SystemClock.uptimeMillis() / 1000;
            int i5 = 0;
            while (i5 < this.shortPollOnlines.size()) {
                int keyAt4 = this.shortPollOnlines.keyAt(i5);
                if (((long) this.shortPollOnlines.valueAt(i5)) < uptimeMillis) {
                    if (this.needShortPollChannels.indexOfKey(keyAt4) >= 0) {
                        this.shortPollOnlines.put(keyAt4, (int) (300 + uptimeMillis));
                    } else {
                        this.shortPollOnlines.delete(keyAt4);
                        i5--;
                    }
                    TLRPC.TL_messages_getOnlines tL_messages_getOnlines = new TLRPC.TL_messages_getOnlines();
                    tL_messages_getOnlines.peer = getInputPeer(-keyAt4);
                    getConnectionsManager().sendRequest(tL_messages_getOnlines, new RequestDelegate(keyAt4) {
                        /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$YWVORaSVJXSEv8pDIx1pW8q5APg */
                        private final /* synthetic */ int f$1;

                        {
                            this.f$1 = r2;
                        }

                        @Override // im.guobwnxjuc.tgnet.RequestDelegate
                        public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                            MessagesController.this.lambda$updateTimerProc$103$MessagesController(this.f$1, tLObject, tL_error);
                        }
                    });
                }
                i5++;
            }
        }
        if (!this.printingUsers.isEmpty() || this.lastPrintingStringCount != this.printingUsers.size()) {
            ArrayList arrayList3 = new ArrayList(this.printingUsers.keySet());
            int i6 = 0;
            boolean z = false;
            while (i6 < arrayList3.size()) {
                long longValue = ((Long) arrayList3.get(i6)).longValue();
                ArrayList<PrintingUser> arrayList4 = this.printingUsers.get(Long.valueOf(longValue));
                if (arrayList4 != null) {
                    int i7 = 0;
                    while (i7 < arrayList4.size()) {
                        PrintingUser printingUser = arrayList4.get(i7);
                        if (printingUser.lastTime + ((long) (printingUser.action instanceof TLRPC.TL_sendMessageGamePlayAction ? UIMsg.m_AppUI.MSG_RADAR_SEARCH_RETURN_RESULT : 5900)) < currentTimeMillis) {
                            arrayList4.remove(printingUser);
                            i7--;
                            z = true;
                        }
                        i7++;
                        arrayList3 = arrayList3;
                    }
                }
                if (arrayList4 == null || arrayList4.isEmpty()) {
                    this.printingUsers.remove(Long.valueOf(longValue));
                    arrayList = arrayList3;
                    arrayList.remove(i6);
                    i6--;
                } else {
                    arrayList = arrayList3;
                }
                i6++;
                arrayList3 = arrayList;
            }
            updatePrintingStrings();
            if (z) {
                AndroidUtilities.runOnUIThread(new Runnable() {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$qEXAarXTfCiqV6WTX6_cdkKuI */

                    public final void run() {
                        MessagesController.this.lambda$updateTimerProc$104$MessagesController();
                    }
                });
            }
        }
        if (Theme.selectedAutoNightType == 1 && Math.abs(currentTimeMillis - lastThemeCheckTime) >= 60) {
            AndroidUtilities.runOnUIThread(this.themeCheckRunnable);
            lastThemeCheckTime = currentTimeMillis;
        }
        if (getUserConfig().savedPasswordHash != null && Math.abs(currentTimeMillis - lastPasswordCheckTime) >= 60) {
            AndroidUtilities.runOnUIThread(this.passwordCheckRunnable);
            lastPasswordCheckTime = currentTimeMillis;
        }
        if (this.lastPushRegisterSendTime != 0 && Math.abs(SystemClock.elapsedRealtime() - this.lastPushRegisterSendTime) >= 10800000) {
            GcmPushListenerService.sendRegistrationToServer(SharedConfig.pushString);
        }
        getLocationController().update();
        lambda$checkProxyInfo$107$MessagesController(false);
        checkTosUpdate();
    }

    public /* synthetic */ void lambda$updateTimerProc$95$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            this.lastStatusUpdateTime = System.currentTimeMillis();
            this.offlineSent = false;
            this.statusSettingState = 0;
        } else {
            long j = this.lastStatusUpdateTime;
            if (j != 0) {
                this.lastStatusUpdateTime = j + DefaultRenderersFactory.DEFAULT_ALLOWED_VIDEO_JOINING_TIME_MS;
            }
        }
        this.statusRequest = 0;
    }

    public /* synthetic */ void lambda$updateTimerProc$96$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            this.offlineSent = true;
        } else {
            long j = this.lastStatusUpdateTime;
            if (j != 0) {
                this.lastStatusUpdateTime = j + DefaultRenderersFactory.DEFAULT_ALLOWED_VIDEO_JOINING_TIME_MS;
            }
        }
        this.statusRequest = 0;
    }

    public /* synthetic */ void lambda$updateTimerProc$98$MessagesController(int i, TLRPC.TL_messages_getMessagesViews tL_messages_getMessagesViews, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tLObject != null) {
            TLRPC.Vector vector = (TLRPC.Vector) tLObject;
            SparseArray<SparseIntArray> sparseArray = new SparseArray<>();
            SparseIntArray sparseIntArray = sparseArray.get(i);
            if (sparseIntArray == null) {
                sparseIntArray = new SparseIntArray();
                sparseArray.put(i, sparseIntArray);
            }
            int i2 = 0;
            while (i2 < tL_messages_getMessagesViews.id.size() && i2 < vector.objects.size()) {
                sparseIntArray.put(tL_messages_getMessagesViews.id.get(i2).intValue(), ((Integer) vector.objects.get(i2)).intValue());
                i2++;
            }
            getMessagesStorage().putChannelViews(sparseArray, tL_messages_getMessagesViews.peer instanceof TLRPC.TL_inputPeerChannel);
            AndroidUtilities.runOnUIThread(new Runnable(sparseArray) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$UOy3gTNEYwAyRA3L7oYzPSWeYpo */
                private final /* synthetic */ SparseArray f$1;

                {
                    this.f$1 = r2;
                }

                public final void run() {
                    MessagesController.this.lambda$null$97$MessagesController(this.f$1);
                }
            });
        }
    }

    public /* synthetic */ void lambda$null$97$MessagesController(SparseArray sparseArray) {
        getNotificationCenter().postNotificationName(NotificationCenter.didUpdatedMessagesViews, sparseArray);
    }

    public /* synthetic */ void lambda$updateTimerProc$100$MessagesController() {
        long uptimeMillis = SystemClock.uptimeMillis();
        int size = this.pollsToCheck.size();
        int i = 0;
        while (i < size) {
            SparseArray<MessageObject> valueAt = this.pollsToCheck.valueAt(i);
            if (valueAt != null) {
                int size2 = valueAt.size();
                int i2 = 0;
                while (i2 < size2) {
                    MessageObject valueAt2 = valueAt.valueAt(i2);
                    if (Math.abs(uptimeMillis - valueAt2.pollLastCheckTime) >= 30000) {
                        valueAt2.pollLastCheckTime = uptimeMillis;
                        TLRPC.TL_messages_getPollResults tL_messages_getPollResults = new TLRPC.TL_messages_getPollResults();
                        tL_messages_getPollResults.peer = getInputPeer((int) valueAt2.getDialogId());
                        tL_messages_getPollResults.msg_id = valueAt2.getId();
                        getConnectionsManager().sendRequest(tL_messages_getPollResults, new RequestDelegate() {
                            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$psHQYbHXoYNx4YuRBihbhUmw */

                            @Override // im.guobwnxjuc.tgnet.RequestDelegate
                            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                                MessagesController.this.lambda$null$99$MessagesController(tLObject, tL_error);
                            }
                        });
                    } else if (!valueAt2.pollVisibleOnScreen) {
                        valueAt.remove(valueAt2.getId());
                        size2--;
                        i2--;
                    }
                    i2++;
                }
                if (valueAt.size() == 0) {
                    LongSparseArray<SparseArray<MessageObject>> longSparseArray = this.pollsToCheck;
                    longSparseArray.remove(longSparseArray.keyAt(i));
                    size--;
                    i--;
                }
            }
            i++;
        }
        this.pollsToCheckSize = this.pollsToCheck.size();
    }

    public /* synthetic */ void lambda$null$99$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            processUpdates((TLRPC.Updates) tLObject, false);
        }
    }

    public /* synthetic */ void lambda$updateTimerProc$101$MessagesController() {
        getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 4);
    }

    public /* synthetic */ void lambda$updateTimerProc$103$MessagesController(int i, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tLObject != null) {
            TLRPC.TL_chatOnlines tL_chatOnlines = (TLRPC.TL_chatOnlines) tLObject;
            getMessagesStorage().updateChatOnlineCount(i, tL_chatOnlines.onlines);
            AndroidUtilities.runOnUIThread(new Runnable(i, tL_chatOnlines) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$3knL79aAxJvs18eQ2EpN8pSDM */
                private final /* synthetic */ int f$1;
                private final /* synthetic */ TLRPC.TL_chatOnlines f$2;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                }

                public final void run() {
                    MessagesController.this.lambda$null$102$MessagesController(this.f$1, this.f$2);
                }
            });
        }
    }

    public /* synthetic */ void lambda$null$102$MessagesController(int i, TLRPC.TL_chatOnlines tL_chatOnlines) {
        getNotificationCenter().postNotificationName(NotificationCenter.chatOnlineCountDidLoad, Integer.valueOf(i), Integer.valueOf(tL_chatOnlines.onlines));
    }

    public /* synthetic */ void lambda$updateTimerProc$104$MessagesController() {
        getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 64);
    }

    private void checkTosUpdate() {
        if (this.nextTosCheckTime <= getConnectionsManager().getCurrentTime() && !this.checkingTosUpdate && getUserConfig().isClientActivated()) {
            this.checkingTosUpdate = true;
            getConnectionsManager().sendRequest(new TLRPC.TL_help_getTermsOfServiceUpdate(), new RequestDelegate() {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$6OHHJQZrB6Baxsha9SOV5avjBAk */

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$checkTosUpdate$106$MessagesController(tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$checkTosUpdate$106$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
        this.checkingTosUpdate = false;
        if (tLObject instanceof TLRPC.TL_help_termsOfServiceUpdateEmpty) {
            this.nextTosCheckTime = ((TLRPC.TL_help_termsOfServiceUpdateEmpty) tLObject).expires;
        } else if (tLObject instanceof TLRPC.TL_help_termsOfServiceUpdate) {
            TLRPC.TL_help_termsOfServiceUpdate tL_help_termsOfServiceUpdate = (TLRPC.TL_help_termsOfServiceUpdate) tLObject;
            this.nextTosCheckTime = tL_help_termsOfServiceUpdate.expires;
            AndroidUtilities.runOnUIThread(new Runnable(tL_help_termsOfServiceUpdate) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$_KvIOekkXNHSf7DXqgYJfsHa5U */
                private final /* synthetic */ TLRPC.TL_help_termsOfServiceUpdate f$1;

                {
                    this.f$1 = r2;
                }

                public final void run() {
                    MessagesController.this.lambda$null$105$MessagesController(this.f$1);
                }
            });
        } else {
            this.nextTosCheckTime = getConnectionsManager().getCurrentTime() + CacheConstants.HOUR;
        }
        this.notificationsPreferences.edit().putInt("nextTosCheckTime", this.nextTosCheckTime).commit();
    }

    public /* synthetic */ void lambda$null$105$MessagesController(TLRPC.TL_help_termsOfServiceUpdate tL_help_termsOfServiceUpdate) {
        getNotificationCenter().postNotificationName(NotificationCenter.needShowAlert, 4, tL_help_termsOfServiceUpdate.terms_of_service);
    }

    public void checkProxyInfo(boolean z) {
        Utilities.stageQueue.postRunnable(new Runnable(z) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$jLjzK28MZU5nDkxRpxEJzdJEqF4 */
            private final /* synthetic */ boolean f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                MessagesController.this.lambda$checkProxyInfo$107$MessagesController(this.f$1);
            }
        });
    }

    /* access modifiers changed from: private */
    /* JADX WARNING: Removed duplicated region for block: B:30:0x0098  */
    /* JADX WARNING: Removed duplicated region for block: B:39:? A[RETURN, SYNTHETIC] */
    /* renamed from: checkProxyInfoInternal */
    public void lambda$checkProxyInfo$107$MessagesController(boolean z) {
        char c;
        String str;
        if (z && this.checkingProxyInfo) {
            this.checkingProxyInfo = false;
        }
        if ((z || this.nextProxyInfoCheckTime <= getConnectionsManager().getCurrentTime()) && !this.checkingProxyInfo) {
            if (this.checkingProxyInfoRequestId != 0) {
                getConnectionsManager().cancelRequest(this.checkingProxyInfoRequestId, true);
                this.checkingProxyInfoRequestId = 0;
            }
            SharedPreferences globalMainSettings = getGlobalMainSettings();
            boolean z2 = globalMainSettings.getBoolean("proxy_enabled", false);
            String string = globalMainSettings.getString("proxy_ip", "");
            String string2 = globalMainSettings.getString("proxy_secret", "");
            if (!(this.proxyDialogId == 0 || (str = this.proxyDialogAddress) == null)) {
                if (!str.equals(string + string2)) {
                    c = 1;
                    this.lastCheckProxyId++;
                    if (z2 || TextUtils.isEmpty(string) || TextUtils.isEmpty(string2)) {
                        c = 2;
                    } else {
                        this.checkingProxyInfo = true;
                        this.checkingProxyInfoRequestId = getConnectionsManager().sendRequest(new TLRPC.TL_help_getProxyData(), new RequestDelegate(this.lastCheckProxyId, string, string2) {
                            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$GpsZ6sSX0tdoiGEJvslI0Rm0i5U */
                            private final /* synthetic */ int f$1;
                            private final /* synthetic */ String f$2;
                            private final /* synthetic */ String f$3;

                            {
                                this.f$1 = r2;
                                this.f$2 = r3;
                                this.f$3 = r4;
                            }

                            @Override // im.guobwnxjuc.tgnet.RequestDelegate
                            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                                MessagesController.this.lambda$checkProxyInfoInternal$112$MessagesController(this.f$1, this.f$2, this.f$3, tLObject, tL_error);
                            }
                        });
                    }
                    if (c == 0) {
                        this.proxyDialogId = 0;
                        this.proxyDialogAddress = null;
                        getGlobalMainSettings().edit().putLong("proxy_dialog", this.proxyDialogId).remove("proxyDialogAddress").commit();
                        this.nextProxyInfoCheckTime = getConnectionsManager().getCurrentTime() + CacheConstants.HOUR;
                        if (c == 2) {
                            this.checkingProxyInfo = false;
                            if (this.checkingProxyInfoRequestId != 0) {
                                getConnectionsManager().cancelRequest(this.checkingProxyInfoRequestId, true);
                                this.checkingProxyInfoRequestId = 0;
                            }
                        }
                        AndroidUtilities.runOnUIThread(new Runnable() {
                            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$zg1xOTbAfogfZW0cqHaobxJHY9I */

                            public final void run() {
                                MessagesController.this.removeProxyDialog();
                            }
                        });
                        return;
                    }
                    return;
                }
            }
            c = 0;
            this.lastCheckProxyId++;
            if (z2) {
            }
            c = 2;
            if (c == 0) {
            }
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:22:0x0057, code lost:
        if (r5.restricted == false) goto L_0x005d;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:34:0x0085, code lost:
        if (r5.restricted == false) goto L_0x0029;
     */
    /* JADX WARNING: Removed duplicated region for block: B:38:0x00bb  */
    public /* synthetic */ void lambda$checkProxyInfoInternal$112$MessagesController(int i, String str, String str2, TLObject tLObject, TLRPC.TL_error tL_error) {
        long j;
        long j2;
        if (i == this.lastCheckProxyId) {
            boolean z = true;
            if (tLObject instanceof TLRPC.TL_help_proxyDataEmpty) {
                this.nextProxyInfoCheckTime = ((TLRPC.TL_help_proxyDataEmpty) tLObject).expires;
            } else if (tLObject instanceof TLRPC.TL_help_proxyDataPromo) {
                TLRPC.TL_help_proxyDataPromo tL_help_proxyDataPromo = (TLRPC.TL_help_proxyDataPromo) tLObject;
                if (tL_help_proxyDataPromo.peer.user_id != 0) {
                    j2 = (long) tL_help_proxyDataPromo.peer.user_id;
                } else {
                    if (tL_help_proxyDataPromo.peer.chat_id == 0) {
                        j2 = (long) (-tL_help_proxyDataPromo.peer.channel_id);
                        int i2 = 0;
                        while (true) {
                            if (i2 >= tL_help_proxyDataPromo.chats.size()) {
                                break;
                            }
                            TLRPC.Chat chat = tL_help_proxyDataPromo.chats.get(i2);
                            if (chat.id != tL_help_proxyDataPromo.peer.channel_id) {
                                i2++;
                            } else if (!chat.kicked) {
                            }
                        }
                    } else {
                        j2 = (long) (-tL_help_proxyDataPromo.peer.chat_id);
                        int i3 = 0;
                        while (true) {
                            if (i3 >= tL_help_proxyDataPromo.chats.size()) {
                                break;
                            }
                            TLRPC.Chat chat2 = tL_help_proxyDataPromo.chats.get(i3);
                            if (chat2.id != tL_help_proxyDataPromo.peer.chat_id) {
                                i3++;
                            } else if (!chat2.kicked) {
                            }
                        }
                        z = false;
                    }
                    j = j2;
                    this.proxyDialogId = j;
                    this.proxyDialogAddress = str + str2;
                    getGlobalMainSettings().edit().putLong("proxy_dialog", this.proxyDialogId).putString("proxyDialogAddress", this.proxyDialogAddress).commit();
                    this.nextProxyInfoCheckTime = tL_help_proxyDataPromo.expires;
                    if (!z) {
                        AndroidUtilities.runOnUIThread(new Runnable(j, tL_help_proxyDataPromo, i) {
                            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$1YKIDmJefcL6GJDaIqdKMLJ1YGE */
                            private final /* synthetic */ long f$1;
                            private final /* synthetic */ TLRPC.TL_help_proxyDataPromo f$2;
                            private final /* synthetic */ int f$3;

                            {
                                this.f$1 = r2;
                                this.f$2 = r4;
                                this.f$3 = r5;
                            }

                            public final void run() {
                                MessagesController.this.lambda$null$111$MessagesController(this.f$1, this.f$2, this.f$3);
                            }
                        });
                    }
                }
                j = j2;
                z = false;
                this.proxyDialogId = j;
                this.proxyDialogAddress = str + str2;
                getGlobalMainSettings().edit().putLong("proxy_dialog", this.proxyDialogId).putString("proxyDialogAddress", this.proxyDialogAddress).commit();
                this.nextProxyInfoCheckTime = tL_help_proxyDataPromo.expires;
                if (!z) {
                }
            } else {
                this.nextProxyInfoCheckTime = getConnectionsManager().getCurrentTime() + CacheConstants.HOUR;
            }
            if (z) {
                this.proxyDialogId = 0;
                getGlobalMainSettings().edit().putLong("proxy_dialog", this.proxyDialogId).remove("proxyDialogAddress").commit();
                this.checkingProxyInfoRequestId = 0;
                this.checkingProxyInfo = false;
                AndroidUtilities.runOnUIThread(new Runnable() {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$zg1xOTbAfogfZW0cqHaobxJHY9I */

                    public final void run() {
                        MessagesController.this.removeProxyDialog();
                    }
                });
            }
        }
    }

    public /* synthetic */ void lambda$null$111$MessagesController(long j, TLRPC.TL_help_proxyDataPromo tL_help_proxyDataPromo, int i) {
        TLRPC.Dialog dialog = this.proxyDialog;
        if (!(dialog == null || j == dialog.id)) {
            removeProxyDialog();
        }
        TLRPC.Dialog dialog2 = this.dialogs_dict.get(j);
        this.proxyDialog = dialog2;
        if (dialog2 != null) {
            this.checkingProxyInfo = false;
            sortDialogs(null);
            getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, true);
            return;
        }
        SparseArray sparseArray = new SparseArray();
        SparseArray sparseArray2 = new SparseArray();
        for (int i2 = 0; i2 < tL_help_proxyDataPromo.users.size(); i2++) {
            TLRPC.User user = tL_help_proxyDataPromo.users.get(i2);
            sparseArray.put(user.id, user);
        }
        for (int i3 = 0; i3 < tL_help_proxyDataPromo.chats.size(); i3++) {
            TLRPC.Chat chat = tL_help_proxyDataPromo.chats.get(i3);
            sparseArray2.put(chat.id, chat);
        }
        TLRPC.TL_messages_getPeerDialogs tL_messages_getPeerDialogs = new TLRPC.TL_messages_getPeerDialogs();
        TLRPC.TL_inputDialogPeer tL_inputDialogPeer = new TLRPC.TL_inputDialogPeer();
        if (tL_help_proxyDataPromo.peer.user_id != 0) {
            tL_inputDialogPeer.peer = new TLRPC.TL_inputPeerUser();
            tL_inputDialogPeer.peer.user_id = tL_help_proxyDataPromo.peer.user_id;
            TLRPC.User user2 = (TLRPC.User) sparseArray.get(tL_help_proxyDataPromo.peer.user_id);
            if (user2 != null) {
                tL_inputDialogPeer.peer.access_hash = user2.access_hash;
            }
        } else if (tL_help_proxyDataPromo.peer.chat_id != 0) {
            tL_inputDialogPeer.peer = new TLRPC.TL_inputPeerChat();
            tL_inputDialogPeer.peer.chat_id = tL_help_proxyDataPromo.peer.chat_id;
            TLRPC.Chat chat2 = (TLRPC.Chat) sparseArray2.get(tL_help_proxyDataPromo.peer.chat_id);
            if (chat2 != null) {
                tL_inputDialogPeer.peer.access_hash = chat2.access_hash;
            }
        } else {
            tL_inputDialogPeer.peer = new TLRPC.TL_inputPeerChannel();
            tL_inputDialogPeer.peer.channel_id = tL_help_proxyDataPromo.peer.channel_id;
            TLRPC.Chat chat3 = (TLRPC.Chat) sparseArray2.get(tL_help_proxyDataPromo.peer.channel_id);
            if (chat3 != null) {
                tL_inputDialogPeer.peer.access_hash = chat3.access_hash;
            }
        }
        tL_messages_getPeerDialogs.peers.add(tL_inputDialogPeer);
        this.checkingProxyInfoRequestId = getConnectionsManager().sendRequest(tL_messages_getPeerDialogs, new RequestDelegate(i, tL_help_proxyDataPromo, j) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$Zs9541ai58Vl4j6oZIhU9BJbOMw */
            private final /* synthetic */ int f$1;
            private final /* synthetic */ TLRPC.TL_help_proxyDataPromo f$2;
            private final /* synthetic */ long f$3;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
            }

            @Override // im.guobwnxjuc.tgnet.RequestDelegate
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                MessagesController.this.lambda$null$110$MessagesController(this.f$1, this.f$2, this.f$3, tLObject, tL_error);
            }
        });
    }

    public /* synthetic */ void lambda$null$110$MessagesController(int i, TLRPC.TL_help_proxyDataPromo tL_help_proxyDataPromo, long j, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (i == this.lastCheckProxyId) {
            this.checkingProxyInfoRequestId = 0;
            TLRPC.TL_messages_peerDialogs tL_messages_peerDialogs = (TLRPC.TL_messages_peerDialogs) tLObject;
            if (tL_messages_peerDialogs == null || tL_messages_peerDialogs.dialogs.isEmpty()) {
                AndroidUtilities.runOnUIThread(new Runnable() {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$OlHrZvMMRQVedSBIka5qDfwd4wc */

                    public final void run() {
                        MessagesController.this.lambda$null$109$MessagesController();
                    }
                });
            } else {
                getMessagesStorage().putUsersAndChats(tL_help_proxyDataPromo.users, tL_help_proxyDataPromo.chats, true, true);
                TLRPC.TL_messages_dialogs tL_messages_dialogs = new TLRPC.TL_messages_dialogs();
                tL_messages_dialogs.chats = tL_messages_peerDialogs.chats;
                tL_messages_dialogs.users = tL_messages_peerDialogs.users;
                tL_messages_dialogs.dialogs = tL_messages_peerDialogs.dialogs;
                tL_messages_dialogs.messages = tL_messages_peerDialogs.messages;
                getMessagesStorage().putDialogs(tL_messages_dialogs, 2);
                AndroidUtilities.runOnUIThread(new Runnable(tL_help_proxyDataPromo, tL_messages_peerDialogs, j) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$O3UwEmvWZUahp7vXbjVFE0jg_E */
                    private final /* synthetic */ TLRPC.TL_help_proxyDataPromo f$1;
                    private final /* synthetic */ TLRPC.TL_messages_peerDialogs f$2;
                    private final /* synthetic */ long f$3;

                    {
                        this.f$1 = r2;
                        this.f$2 = r3;
                        this.f$3 = r4;
                    }

                    public final void run() {
                        MessagesController.this.lambda$null$108$MessagesController(this.f$1, this.f$2, this.f$3);
                    }
                });
            }
            this.checkingProxyInfo = false;
        }
    }

    public /* synthetic */ void lambda$null$108$MessagesController(TLRPC.TL_help_proxyDataPromo tL_help_proxyDataPromo, TLRPC.TL_messages_peerDialogs tL_messages_peerDialogs, long j) {
        Integer num = 0;
        putUsers(tL_help_proxyDataPromo.users, false);
        putChats(tL_help_proxyDataPromo.chats, false);
        putUsers(tL_messages_peerDialogs.users, false);
        putChats(tL_messages_peerDialogs.chats, false);
        TLRPC.Dialog dialog = this.proxyDialog;
        if (dialog != null) {
            int i = (int) dialog.id;
            if (i < 0) {
                TLRPC.Chat chat = getChat(Integer.valueOf(-i));
                if (ChatObject.isNotInChat(chat) || chat.restricted) {
                    removeDialog(this.proxyDialog);
                }
            } else {
                removeDialog(this.proxyDialog);
            }
        }
        TLRPC.Dialog dialog2 = tL_messages_peerDialogs.dialogs.get(0);
        this.proxyDialog = dialog2;
        dialog2.id = j;
        this.proxyDialog.folder_id = 0;
        if (DialogObject.isChannel(this.proxyDialog)) {
            this.channelsPts.put(-((int) this.proxyDialog.id), this.proxyDialog.pts);
        }
        Integer num2 = this.dialogs_read_inbox_max.get(Long.valueOf(this.proxyDialog.id));
        if (num2 == null) {
            num2 = num;
        }
        this.dialogs_read_inbox_max.put(Long.valueOf(this.proxyDialog.id), Integer.valueOf(Math.max(num2.intValue(), this.proxyDialog.read_inbox_max_id)));
        Integer num3 = this.dialogs_read_outbox_max.get(Long.valueOf(this.proxyDialog.id));
        if (num3 != null) {
            num = num3;
        }
        this.dialogs_read_outbox_max.put(Long.valueOf(this.proxyDialog.id), Integer.valueOf(Math.max(num.intValue(), this.proxyDialog.read_outbox_max_id)));
        this.dialogs_dict.put(j, this.proxyDialog);
        if (!tL_messages_peerDialogs.messages.isEmpty()) {
            SparseArray sparseArray = new SparseArray();
            SparseArray sparseArray2 = new SparseArray();
            for (int i2 = 0; i2 < tL_messages_peerDialogs.users.size(); i2++) {
                TLRPC.User user = tL_messages_peerDialogs.users.get(i2);
                sparseArray.put(user.id, user);
            }
            for (int i3 = 0; i3 < tL_messages_peerDialogs.chats.size(); i3++) {
                TLRPC.Chat chat2 = tL_messages_peerDialogs.chats.get(i3);
                sparseArray2.put(chat2.id, chat2);
            }
            MessageObject messageObject = new MessageObject(this.currentAccount, tL_messages_peerDialogs.messages.get(0), (SparseArray<TLRPC.User>) sparseArray, (SparseArray<TLRPC.Chat>) sparseArray2, false);
            this.dialogMessage.put(j, messageObject);
            if (this.proxyDialog.last_message_date == 0) {
                this.proxyDialog.last_message_date = messageObject.messageOwner.date;
            }
        }
        sortDialogs(null);
        getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, true);
    }

    public /* synthetic */ void lambda$null$109$MessagesController() {
        TLRPC.Dialog dialog = this.proxyDialog;
        if (dialog != null) {
            int i = (int) dialog.id;
            if (i < 0) {
                TLRPC.Chat chat = getChat(Integer.valueOf(-i));
                if (ChatObject.isNotInChat(chat) || chat.restricted) {
                    removeDialog(this.proxyDialog);
                }
            } else {
                removeDialog(this.proxyDialog);
            }
            this.proxyDialog = null;
            sortDialogs(null);
            getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
        }
    }

    /* access modifiers changed from: private */
    public void removeProxyDialog() {
        TLRPC.Dialog dialog = this.proxyDialog;
        if (dialog != null) {
            int i = (int) dialog.id;
            if (i < 0) {
                TLRPC.Chat chat = getChat(Integer.valueOf(-i));
                if (ChatObject.isNotInChat(chat) || chat.restricted) {
                    removeDialog(this.proxyDialog);
                }
            } else {
                removeDialog(this.proxyDialog);
            }
            this.proxyDialog = null;
            sortDialogs(null);
            getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
        }
    }

    public boolean isProxyDialog(long j, boolean z) {
        TLRPC.Dialog dialog = this.proxyDialog;
        return dialog != null && dialog.id == j && (!z || this.isLeftProxyChannel);
    }

    private String getUserNameForTyping(TLRPC.User user) {
        if (user == null) {
            return "";
        }
        if (user.first_name != null && user.first_name.length() > 0) {
            return user.first_name;
        }
        if (user.last_name == null || user.last_name.length() <= 0) {
            return "";
        }
        return user.last_name;
    }

    private void updatePrintingStrings() {
        LongSparseArray longSparseArray = new LongSparseArray();
        LongSparseArray longSparseArray2 = new LongSparseArray();
        for (Map.Entry<Long, ArrayList<PrintingUser>> entry : this.printingUsers.entrySet()) {
            long longValue = entry.getKey().longValue();
            ArrayList<PrintingUser> value = entry.getValue();
            int i = (int) longValue;
            if (i > 0 || i == 0 || value.size() == 1) {
                PrintingUser printingUser = value.get(0);
                TLRPC.User user = getUser(Integer.valueOf(printingUser.userId));
                if (user != null) {
                    if (printingUser.action instanceof TLRPC.TL_sendMessageRecordAudioAction) {
                        if (i < 0) {
                            longSparseArray.put(longValue, LocaleController.formatString("IsRecordingAudio", R.string.IsRecordingAudio, getUserNameForTyping(user)));
                        } else {
                            longSparseArray.put(longValue, LocaleController.getString("RecordingAudio", R.string.RecordingAudio));
                        }
                        longSparseArray2.put(longValue, 1);
                    } else if ((printingUser.action instanceof TLRPC.TL_sendMessageRecordRoundAction) || (printingUser.action instanceof TLRPC.TL_sendMessageUploadRoundAction)) {
                        if (i < 0) {
                            longSparseArray.put(longValue, LocaleController.formatString("IsRecordingRound", R.string.IsRecordingRound, getUserNameForTyping(user)));
                        } else {
                            longSparseArray.put(longValue, LocaleController.getString("RecordingRound", R.string.RecordingRound));
                        }
                        longSparseArray2.put(longValue, 4);
                    } else if (printingUser.action instanceof TLRPC.TL_sendMessageUploadAudioAction) {
                        if (i < 0) {
                            longSparseArray.put(longValue, LocaleController.formatString("IsSendingAudio", R.string.IsSendingAudio, getUserNameForTyping(user)));
                        } else {
                            longSparseArray.put(longValue, LocaleController.getString("SendingAudio", R.string.SendingAudio));
                        }
                        longSparseArray2.put(longValue, 2);
                    } else if ((printingUser.action instanceof TLRPC.TL_sendMessageUploadVideoAction) || (printingUser.action instanceof TLRPC.TL_sendMessageRecordVideoAction)) {
                        if (i < 0) {
                            longSparseArray.put(longValue, LocaleController.formatString("IsSendingVideo", R.string.IsSendingVideo, getUserNameForTyping(user)));
                        } else {
                            longSparseArray.put(longValue, LocaleController.getString("SendingVideoStatus", R.string.SendingVideoStatus));
                        }
                        longSparseArray2.put(longValue, 2);
                    } else if (printingUser.action instanceof TLRPC.TL_sendMessageUploadDocumentAction) {
                        if (i < 0) {
                            longSparseArray.put(longValue, LocaleController.formatString("IsSendingFile", R.string.IsSendingFile, getUserNameForTyping(user)));
                        } else {
                            longSparseArray.put(longValue, LocaleController.getString("SendingFile", R.string.SendingFile));
                        }
                        longSparseArray2.put(longValue, 2);
                    } else if (printingUser.action instanceof TLRPC.TL_sendMessageUploadPhotoAction) {
                        if (i < 0) {
                            longSparseArray.put(longValue, LocaleController.formatString("IsSendingPhoto", R.string.IsSendingPhoto, getUserNameForTyping(user)));
                        } else {
                            longSparseArray.put(longValue, LocaleController.getString("SendingPhoto", R.string.SendingPhoto));
                        }
                        longSparseArray2.put(longValue, 2);
                    } else if (printingUser.action instanceof TLRPC.TL_sendMessageGamePlayAction) {
                        if (i < 0) {
                            longSparseArray.put(longValue, LocaleController.formatString("IsSendingGame", R.string.IsSendingGame, getUserNameForTyping(user)));
                        } else {
                            longSparseArray.put(longValue, LocaleController.getString("SendingGame", R.string.SendingGame));
                        }
                        longSparseArray2.put(longValue, 3);
                    } else {
                        if (i < 0) {
                            longSparseArray.put(longValue, LocaleController.formatString("IsTypingGroup", R.string.IsTypingGroup, getUserNameForTyping(user)));
                        } else {
                            longSparseArray.put(longValue, LocaleController.getString("Typing", R.string.Typing));
                        }
                        longSparseArray2.put(longValue, 0);
                    }
                }
            } else {
                StringBuilder sb = new StringBuilder();
                Iterator<PrintingUser> it = value.iterator();
                int i2 = 0;
                while (it.hasNext()) {
                    TLRPC.User user2 = getUser(Integer.valueOf(it.next().userId));
                    if (user2 != null) {
                        if (sb.length() != 0) {
                            sb.append(", ");
                        }
                        sb.append(getUserNameForTyping(user2));
                        i2++;
                        continue;
                    }
                    if (i2 == 2) {
                        break;
                    }
                }
                if (sb.length() != 0) {
                    if (i2 == 1) {
                        longSparseArray.put(longValue, LocaleController.formatString("IsTypingGroup", R.string.IsTypingGroup, sb.toString()));
                    } else if (value.size() > 2) {
                        String pluralString = LocaleController.getPluralString("AndMoreTypingGroup", value.size() - 2);
                        try {
                            longSparseArray.put(longValue, String.format(pluralString, sb.toString(), Integer.valueOf(value.size() - 2)));
                        } catch (Exception unused) {
                            longSparseArray.put(longValue, "LOC_ERR: AndMoreTypingGroup");
                        }
                    } else {
                        longSparseArray.put(longValue, LocaleController.formatString("AreTypingGroup", R.string.AreTypingGroup, sb.toString()));
                    }
                    longSparseArray2.put(longValue, 0);
                }
            }
        }
        this.lastPrintingStringCount = longSparseArray.size();
        AndroidUtilities.runOnUIThread(new Runnable(longSparseArray, longSparseArray2) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$I2FJu1__JY0Yzv3ZWdDPzp4_d5s */
            private final /* synthetic */ LongSparseArray f$1;
            private final /* synthetic */ LongSparseArray f$2;

            {
                this.f$1 = r2;
                this.f$2 = r3;
            }

            public final void run() {
                MessagesController.this.lambda$updatePrintingStrings$113$MessagesController(this.f$1, this.f$2);
            }
        });
    }

    public /* synthetic */ void lambda$updatePrintingStrings$113$MessagesController(LongSparseArray longSparseArray, LongSparseArray longSparseArray2) {
        this.printingStrings = longSparseArray;
        this.printingStringsTypes = longSparseArray2;
    }

    public void cancelTyping(int i, long j) {
        LongSparseArray<Boolean> longSparseArray = this.sendingTypings.get(i);
        if (longSparseArray != null) {
            longSparseArray.remove(j);
        }
    }

    public void sendTyping(long j, int i, int i2) {
        TLRPC.Chat chat;
        if (j != 0) {
            LongSparseArray<Boolean> longSparseArray = this.sendingTypings.get(i);
            if (longSparseArray == null || longSparseArray.get(j) == null) {
                if (longSparseArray == null) {
                    longSparseArray = new LongSparseArray<>();
                    this.sendingTypings.put(i, longSparseArray);
                }
                int i3 = (int) j;
                int i4 = (int) (j >> 32);
                if (i3 != 0) {
                    TLRPC.TL_messages_setTyping tL_messages_setTyping = new TLRPC.TL_messages_setTyping();
                    tL_messages_setTyping.peer = getInputPeer(i3);
                    if ((!(tL_messages_setTyping.peer instanceof TLRPC.TL_inputPeerChannel) || ((chat = getChat(Integer.valueOf(tL_messages_setTyping.peer.channel_id))) != null && chat.megagroup)) && tL_messages_setTyping.peer != null) {
                        if (i == 0) {
                            tL_messages_setTyping.action = new TLRPC.TL_sendMessageTypingAction();
                        } else if (i == 1) {
                            tL_messages_setTyping.action = new TLRPC.TL_sendMessageRecordAudioAction();
                        } else if (i == 2) {
                            tL_messages_setTyping.action = new TLRPC.TL_sendMessageCancelAction();
                        } else if (i == 3) {
                            tL_messages_setTyping.action = new TLRPC.TL_sendMessageUploadDocumentAction();
                        } else if (i == 4) {
                            tL_messages_setTyping.action = new TLRPC.TL_sendMessageUploadPhotoAction();
                        } else if (i == 5) {
                            tL_messages_setTyping.action = new TLRPC.TL_sendMessageUploadVideoAction();
                        } else if (i == 6) {
                            tL_messages_setTyping.action = new TLRPC.TL_sendMessageGamePlayAction();
                        } else if (i == 7) {
                            tL_messages_setTyping.action = new TLRPC.TL_sendMessageRecordRoundAction();
                        } else if (i == 8) {
                            tL_messages_setTyping.action = new TLRPC.TL_sendMessageUploadRoundAction();
                        } else if (i == 9) {
                            tL_messages_setTyping.action = new TLRPC.TL_sendMessageUploadAudioAction();
                        }
                        longSparseArray.put(j, true);
                        int sendRequest = getConnectionsManager().sendRequest(tL_messages_setTyping, new RequestDelegate(i, j) {
                            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$O0P3R6oOXnBhaMgCpc27wYDgz4 */
                            private final /* synthetic */ int f$1;
                            private final /* synthetic */ long f$2;

                            {
                                this.f$1 = r2;
                                this.f$2 = r3;
                            }

                            @Override // im.guobwnxjuc.tgnet.RequestDelegate
                            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                                MessagesController.this.lambda$sendTyping$115$MessagesController(this.f$1, this.f$2, tLObject, tL_error);
                            }
                        }, 2);
                        if (i2 != 0) {
                            getConnectionsManager().bindRequestToGuid(sendRequest, i2);
                        }
                    }
                } else if (i == 0) {
                    TLRPC.EncryptedChat encryptedChat = getEncryptedChat(Integer.valueOf(i4));
                    if (encryptedChat.auth_key != null && encryptedChat.auth_key.length > 1 && (encryptedChat instanceof TLRPC.TL_encryptedChat)) {
                        TLRPC.TL_messages_setEncryptedTyping tL_messages_setEncryptedTyping = new TLRPC.TL_messages_setEncryptedTyping();
                        tL_messages_setEncryptedTyping.peer = new TLRPC.TL_inputEncryptedChat();
                        tL_messages_setEncryptedTyping.peer.chat_id = encryptedChat.id;
                        tL_messages_setEncryptedTyping.peer.access_hash = encryptedChat.access_hash;
                        tL_messages_setEncryptedTyping.typing = true;
                        longSparseArray.put(j, true);
                        int sendRequest2 = getConnectionsManager().sendRequest(tL_messages_setEncryptedTyping, new RequestDelegate(i, j) {
                            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$vXTAJzAjtC4eVUOvV9hxNUEDcfA */
                            private final /* synthetic */ int f$1;
                            private final /* synthetic */ long f$2;

                            {
                                this.f$1 = r2;
                                this.f$2 = r3;
                            }

                            @Override // im.guobwnxjuc.tgnet.RequestDelegate
                            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                                MessagesController.this.lambda$sendTyping$117$MessagesController(this.f$1, this.f$2, tLObject, tL_error);
                            }
                        }, 2);
                        if (i2 != 0) {
                            getConnectionsManager().bindRequestToGuid(sendRequest2, i2);
                        }
                    }
                }
            }
        }
    }

    public /* synthetic */ void lambda$sendTyping$115$MessagesController(int i, long j, TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable(i, j) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$H8srVBXvSZB7WJYHh2lNg3tE */
            private final /* synthetic */ int f$1;
            private final /* synthetic */ long f$2;

            {
                this.f$1 = r2;
                this.f$2 = r3;
            }

            public final void run() {
                MessagesController.this.lambda$null$114$MessagesController(this.f$1, this.f$2);
            }
        });
    }

    public /* synthetic */ void lambda$null$114$MessagesController(int i, long j) {
        LongSparseArray<Boolean> longSparseArray = this.sendingTypings.get(i);
        if (longSparseArray != null) {
            longSparseArray.remove(j);
        }
    }

    public /* synthetic */ void lambda$sendTyping$117$MessagesController(int i, long j, TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable(i, j) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$Ow0Y6Y04Lu9c1lQxmsIv12VAOJ0 */
            private final /* synthetic */ int f$1;
            private final /* synthetic */ long f$2;

            {
                this.f$1 = r2;
                this.f$2 = r3;
            }

            public final void run() {
                MessagesController.this.lambda$null$116$MessagesController(this.f$1, this.f$2);
            }
        });
    }

    public /* synthetic */ void lambda$null$116$MessagesController(int i, long j) {
        LongSparseArray<Boolean> longSparseArray = this.sendingTypings.get(i);
        if (longSparseArray != null) {
            longSparseArray.remove(j);
        }
    }

    /* access modifiers changed from: protected */
    public void removeDeletedMessagesFromArray(long j, ArrayList<TLRPC.Message> arrayList) {
        int i = 0;
        int intValue = this.deletedHistory.get(j, 0).intValue();
        if (intValue != 0) {
            int size = arrayList.size();
            while (i < size) {
                if (arrayList.get(i).id <= intValue) {
                    arrayList.remove(i);
                    i--;
                    size--;
                }
                i++;
            }
        }
    }

    public void loadMessages(long j, int i, int i2, int i3, boolean z, int i4, int i5, int i6, int i7, boolean z2, boolean z3, int i8) {
        loadMessages(j, i, i2, i3, z, i4, i5, i6, i7, z2, z3, i8, 0, 0, 0, false, 0);
    }

    public void loadMessages(long j, int i, int i2, int i3, boolean z, int i4, int i5, int i6, int i7, boolean z2, boolean z3, int i8, int i9, int i10, int i11, boolean z4, int i12) {
        loadMessagesInternal(j, i, i2, i3, z, i4, i5, i6, i7, z2, z3, i8, i9, i10, i11, z4, i12, true);
    }

    private void loadMessagesInternal(long j, int i, int i2, int i3, boolean z, int i4, int i5, int i6, int i7, boolean z2, boolean z3, int i8, int i9, int i10, int i11, boolean z4, int i12, boolean z5) {
        int i13 = (int) j;
        if (z || i13 == 0) {
            getMessagesStorage().getMessages(j, i, i2, i3, i4, i5, i6, z2, z3, i8);
        } else if (z3) {
            TLRPC.TL_messages_getScheduledHistory tL_messages_getScheduledHistory = new TLRPC.TL_messages_getScheduledHistory();
            tL_messages_getScheduledHistory.peer = getInputPeer(i13);
            tL_messages_getScheduledHistory.hash = i4;
            ConnectionsManager.getInstance(this.currentAccount).bindRequestToGuid(ConnectionsManager.getInstance(this.currentAccount).sendRequest(tL_messages_getScheduledHistory, new RequestDelegate(i2, i3, j, i, i5, i9, i7, i10, i11, i6, z2, i8, z4, i12) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$l0DjISAG1JQEe59iDmZ7Y8msjyU */
                private final /* synthetic */ int f$1;
                private final /* synthetic */ int f$10;
                private final /* synthetic */ boolean f$11;
                private final /* synthetic */ int f$12;
                private final /* synthetic */ boolean f$13;
                private final /* synthetic */ int f$14;
                private final /* synthetic */ int f$2;
                private final /* synthetic */ long f$3;
                private final /* synthetic */ int f$4;
                private final /* synthetic */ int f$5;
                private final /* synthetic */ int f$6;
                private final /* synthetic */ int f$7;
                private final /* synthetic */ int f$8;
                private final /* synthetic */ int f$9;

                {
                    this.f$1 = r5;
                    this.f$2 = r6;
                    this.f$3 = r7;
                    this.f$4 = r9;
                    this.f$5 = r10;
                    this.f$6 = r11;
                    this.f$7 = r12;
                    this.f$8 = r13;
                    this.f$9 = r14;
                    this.f$10 = r15;
                    this.f$11 = r16;
                    this.f$12 = r17;
                    this.f$13 = r18;
                    this.f$14 = r19;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$loadMessagesInternal$118$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6, this.f$7, this.f$8, this.f$9, this.f$10, this.f$11, this.f$12, this.f$13, this.f$14, tLObject, tL_error);
                }
            }), i5);
        } else if (!z5 || !((i6 == 3 || i6 == 2) && i7 == 0)) {
            TLRPC.TL_messages_getHistory tL_messages_getHistory = new TLRPC.TL_messages_getHistory();
            tL_messages_getHistory.peer = getInputPeer(i13);
            if (i6 == 4) {
                tL_messages_getHistory.add_offset = (-i) + 5;
            } else if (i6 == 3) {
                tL_messages_getHistory.add_offset = (-i) / 2;
            } else if (i6 == 1) {
                tL_messages_getHistory.add_offset = (-i) - 1;
            } else if (i6 == 2 && i2 != 0) {
                tL_messages_getHistory.add_offset = (-i) + 6;
            } else if (i13 < 0 && i2 != 0 && ChatObject.isChannel(getChat(Integer.valueOf(-i13)))) {
                tL_messages_getHistory.add_offset = -1;
                tL_messages_getHistory.limit++;
            }
            tL_messages_getHistory.limit = i;
            tL_messages_getHistory.offset_id = i2;
            tL_messages_getHistory.offset_date = i3;
            getConnectionsManager().bindRequestToGuid(getConnectionsManager().sendRequest(tL_messages_getHistory, new RequestDelegate(j, i, i2, i3, i5, i9, i7, i10, i11, i6, z2, i8, z4, i12) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$TtIWYSLtUS9GxhTHIQ4x6JDJ3E */
                private final /* synthetic */ long f$1;
                private final /* synthetic */ int f$10;
                private final /* synthetic */ boolean f$11;
                private final /* synthetic */ int f$12;
                private final /* synthetic */ boolean f$13;
                private final /* synthetic */ int f$14;
                private final /* synthetic */ int f$2;
                private final /* synthetic */ int f$3;
                private final /* synthetic */ int f$4;
                private final /* synthetic */ int f$5;
                private final /* synthetic */ int f$6;
                private final /* synthetic */ int f$7;
                private final /* synthetic */ int f$8;
                private final /* synthetic */ int f$9;

                {
                    this.f$1 = r5;
                    this.f$2 = r7;
                    this.f$3 = r8;
                    this.f$4 = r9;
                    this.f$5 = r10;
                    this.f$6 = r11;
                    this.f$7 = r12;
                    this.f$8 = r13;
                    this.f$9 = r14;
                    this.f$10 = r15;
                    this.f$11 = r16;
                    this.f$12 = r17;
                    this.f$13 = r18;
                    this.f$14 = r19;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$loadMessagesInternal$120$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6, this.f$7, this.f$8, this.f$9, this.f$10, this.f$11, this.f$12, this.f$13, this.f$14, tLObject, tL_error);
                }
            }), i5);
        } else {
            TLRPC.TL_messages_getPeerDialogs tL_messages_getPeerDialogs = new TLRPC.TL_messages_getPeerDialogs();
            TLRPC.InputPeer inputPeer = getInputPeer(i13);
            TLRPC.TL_inputDialogPeer tL_inputDialogPeer = new TLRPC.TL_inputDialogPeer();
            tL_inputDialogPeer.peer = inputPeer;
            tL_messages_getPeerDialogs.peers.add(tL_inputDialogPeer);
            getConnectionsManager().sendRequest(tL_messages_getPeerDialogs, new RequestDelegate(j, i, i2, i3, i4, i5, i6, z2, i8, i9, i11, z4) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$6BTp1hQY6WBOVKqbakiW1BzE06g */
                private final /* synthetic */ long f$1;
                private final /* synthetic */ int f$10;
                private final /* synthetic */ int f$11;
                private final /* synthetic */ boolean f$12;
                private final /* synthetic */ int f$2;
                private final /* synthetic */ int f$3;
                private final /* synthetic */ int f$4;
                private final /* synthetic */ int f$5;
                private final /* synthetic */ int f$6;
                private final /* synthetic */ int f$7;
                private final /* synthetic */ boolean f$8;
                private final /* synthetic */ int f$9;

                {
                    this.f$1 = r2;
                    this.f$2 = r4;
                    this.f$3 = r5;
                    this.f$4 = r6;
                    this.f$5 = r7;
                    this.f$6 = r8;
                    this.f$7 = r9;
                    this.f$8 = r10;
                    this.f$9 = r11;
                    this.f$10 = r12;
                    this.f$11 = r13;
                    this.f$12 = r14;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$loadMessagesInternal$119$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6, this.f$7, this.f$8, this.f$9, this.f$10, this.f$11, this.f$12, tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$loadMessagesInternal$118$MessagesController(int i, int i2, long j, int i3, int i4, int i5, int i6, int i7, int i8, int i9, boolean z, int i10, boolean z2, int i11, TLObject tLObject, TLRPC.TL_error tL_error) {
        int i12;
        if (tLObject != null) {
            TLRPC.messages_Messages messages_messages = (TLRPC.messages_Messages) tLObject;
            if (!(messages_messages instanceof TLRPC.TL_messages_messagesNotModified)) {
                if (i2 == 0 || messages_messages.messages.isEmpty()) {
                    i12 = i;
                } else {
                    int i13 = messages_messages.messages.get(messages_messages.messages.size() - 1).id;
                    int size = messages_messages.messages.size() - 1;
                    while (true) {
                        if (size < 0) {
                            break;
                        }
                        TLRPC.Message message = messages_messages.messages.get(size);
                        if (message.date > i2) {
                            i13 = message.id;
                            break;
                        }
                        size--;
                    }
                    i12 = i13;
                }
                processLoadedMessages(messages_messages, j, i3, i12, i2, false, i4, i5, i6, i7, i8, i9, z, false, true, i10, z2, i11);
            }
        }
    }

    public /* synthetic */ void lambda$loadMessagesInternal$119$MessagesController(long j, int i, int i2, int i3, int i4, int i5, int i6, boolean z, int i7, int i8, int i9, boolean z2, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tLObject != null) {
            TLRPC.TL_messages_peerDialogs tL_messages_peerDialogs = (TLRPC.TL_messages_peerDialogs) tLObject;
            if (!tL_messages_peerDialogs.dialogs.isEmpty()) {
                TLRPC.Dialog dialog = tL_messages_peerDialogs.dialogs.get(0);
                if (dialog.top_message != 0) {
                    TLRPC.TL_messages_dialogs tL_messages_dialogs = new TLRPC.TL_messages_dialogs();
                    tL_messages_dialogs.chats = tL_messages_peerDialogs.chats;
                    tL_messages_dialogs.users = tL_messages_peerDialogs.users;
                    tL_messages_dialogs.dialogs = tL_messages_peerDialogs.dialogs;
                    tL_messages_dialogs.messages = tL_messages_peerDialogs.messages;
                    getMessagesStorage().putDialogs(tL_messages_dialogs, 0);
                }
                loadMessagesInternal(j, i, i2, i3, false, i4, i5, i6, dialog.top_message, z, false, i7, i8, dialog.unread_count, i9, z2, dialog.unread_mentions_count, false);
                return;
            }
            loadMessagesInternal(j, i, i2, i3, false, i4, i5, i6, -1, z, false, i7, i8, tL_messages_peerDialogs.state.unread_count, i9, z2, 0, false);
        }
    }

    public /* synthetic */ void lambda$loadMessagesInternal$120$MessagesController(long j, int i, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, boolean z, int i10, boolean z2, int i11, TLObject tLObject, TLRPC.TL_error tL_error) {
        int i12;
        if (tLObject != null) {
            TLRPC.messages_Messages messages_messages = (TLRPC.messages_Messages) tLObject;
            removeDeletedMessagesFromArray(j, messages_messages.messages);
            if (messages_messages.messages.size() > i) {
                messages_messages.messages.remove(0);
            }
            if (i3 == 0 || messages_messages.messages.isEmpty()) {
                i12 = i2;
            } else {
                int i13 = messages_messages.messages.get(messages_messages.messages.size() - 1).id;
                int size = messages_messages.messages.size() - 1;
                while (true) {
                    if (size < 0) {
                        break;
                    }
                    TLRPC.Message message = messages_messages.messages.get(size);
                    if (message.date > i3) {
                        i13 = message.id;
                        break;
                    }
                    size--;
                }
                i12 = i13;
            }
            processLoadedMessages(messages_messages, j, i, i12, i3, false, i4, i5, i6, i7, i8, i9, z, false, false, i10, z2, i11);
        }
    }

    public void reloadWebPages(long j, HashMap<String, ArrayList<MessageObject>> hashMap, boolean z) {
        HashMap<String, ArrayList<MessageObject>> hashMap2 = z ? this.reloadingScheduledWebpages : this.reloadingWebpages;
        LongSparseArray<ArrayList<MessageObject>> longSparseArray = z ? this.reloadingScheduledWebpagesPending : this.reloadingWebpagesPending;
        for (Map.Entry<String, ArrayList<MessageObject>> entry : hashMap.entrySet()) {
            String key = entry.getKey();
            ArrayList<MessageObject> value = entry.getValue();
            ArrayList<MessageObject> arrayList = hashMap2.get(key);
            if (arrayList == null) {
                arrayList = new ArrayList<>();
                hashMap2.put(key, arrayList);
            }
            arrayList.addAll(value);
            TLRPC.TL_messages_getWebPagePreview tL_messages_getWebPagePreview = new TLRPC.TL_messages_getWebPagePreview();
            tL_messages_getWebPagePreview.message = key;
            getConnectionsManager().sendRequest(tL_messages_getWebPagePreview, new RequestDelegate(hashMap2, key, longSparseArray, j, z) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$nnmxiwV9w4JpsSwbBBYizZaP44g */
                private final /* synthetic */ HashMap f$1;
                private final /* synthetic */ String f$2;
                private final /* synthetic */ LongSparseArray f$3;
                private final /* synthetic */ long f$4;
                private final /* synthetic */ boolean f$5;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                    this.f$3 = r4;
                    this.f$4 = r5;
                    this.f$5 = r7;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$reloadWebPages$122$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$reloadWebPages$122$MessagesController(HashMap hashMap, String str, LongSparseArray longSparseArray, long j, boolean z, TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable(hashMap, str, tLObject, longSparseArray, j, z) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$gwJkW53gMn4yt4iTamFe_cDSUZo */
            private final /* synthetic */ HashMap f$1;
            private final /* synthetic */ String f$2;
            private final /* synthetic */ TLObject f$3;
            private final /* synthetic */ LongSparseArray f$4;
            private final /* synthetic */ long f$5;
            private final /* synthetic */ boolean f$6;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
                this.f$4 = r5;
                this.f$5 = r6;
                this.f$6 = r8;
            }

            public final void run() {
                MessagesController.this.lambda$null$121$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6);
            }
        });
    }

    public /* synthetic */ void lambda$null$121$MessagesController(HashMap hashMap, String str, TLObject tLObject, LongSparseArray longSparseArray, long j, boolean z) {
        ArrayList arrayList = (ArrayList) hashMap.remove(str);
        if (arrayList != null) {
            TLRPC.TL_messages_messages tL_messages_messages = new TLRPC.TL_messages_messages();
            if (!(tLObject instanceof TLRPC.TL_messageMediaWebPage)) {
                for (int i = 0; i < arrayList.size(); i++) {
                    ((MessageObject) arrayList.get(i)).messageOwner.media.webpage = new TLRPC.TL_webPageEmpty();
                    tL_messages_messages.messages.add(((MessageObject) arrayList.get(i)).messageOwner);
                }
            } else {
                TLRPC.TL_messageMediaWebPage tL_messageMediaWebPage = (TLRPC.TL_messageMediaWebPage) tLObject;
                if ((tL_messageMediaWebPage.webpage instanceof TLRPC.TL_webPage) || (tL_messageMediaWebPage.webpage instanceof TLRPC.TL_webPageEmpty)) {
                    for (int i2 = 0; i2 < arrayList.size(); i2++) {
                        ((MessageObject) arrayList.get(i2)).messageOwner.media.webpage = tL_messageMediaWebPage.webpage;
                        if (i2 == 0) {
                            ImageLoader.saveMessageThumbs(((MessageObject) arrayList.get(i2)).messageOwner);
                        }
                        tL_messages_messages.messages.add(((MessageObject) arrayList.get(i2)).messageOwner);
                    }
                } else {
                    longSparseArray.put(tL_messageMediaWebPage.webpage.id, arrayList);
                }
            }
            if (!tL_messages_messages.messages.isEmpty()) {
                getMessagesStorage().putMessages((TLRPC.messages_Messages) tL_messages_messages, j, -2, 0, false, z);
                getNotificationCenter().postNotificationName(NotificationCenter.replaceMessagesObjects, Long.valueOf(j), arrayList);
            }
        }
    }

    public void processLoadedMessages(TLRPC.messages_Messages messages_messages, long j, int i, int i2, int i3, boolean z, int i4, int i5, int i6, int i7, int i8, int i9, boolean z2, boolean z3, boolean z4, int i10, boolean z5, int i11) {
        Utilities.stageQueue.postRunnable(new Runnable(messages_messages, j, z4, z, i, i9, z5, i5, i2, i3, i4, i6, z2, i10, i7, i8, i11, z3) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$QfDpqHIvJaR_t9vefqyAdbwgspg */
            private final /* synthetic */ TLRPC.messages_Messages f$1;
            private final /* synthetic */ int f$10;
            private final /* synthetic */ int f$11;
            private final /* synthetic */ int f$12;
            private final /* synthetic */ boolean f$13;
            private final /* synthetic */ int f$14;
            private final /* synthetic */ int f$15;
            private final /* synthetic */ int f$16;
            private final /* synthetic */ int f$17;
            private final /* synthetic */ boolean f$18;
            private final /* synthetic */ long f$2;
            private final /* synthetic */ boolean f$3;
            private final /* synthetic */ boolean f$4;
            private final /* synthetic */ int f$5;
            private final /* synthetic */ int f$6;
            private final /* synthetic */ boolean f$7;
            private final /* synthetic */ int f$8;
            private final /* synthetic */ int f$9;

            {
                this.f$1 = r5;
                this.f$2 = r6;
                this.f$3 = r8;
                this.f$4 = r9;
                this.f$5 = r10;
                this.f$6 = r11;
                this.f$7 = r12;
                this.f$8 = r13;
                this.f$9 = r14;
                this.f$10 = r15;
                this.f$11 = r16;
                this.f$12 = r17;
                this.f$13 = r18;
                this.f$14 = r19;
                this.f$15 = r20;
                this.f$16 = r21;
                this.f$17 = r22;
                this.f$18 = r23;
            }

            public final void run() {
                MessagesController.this.lambda$processLoadedMessages$125$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6, this.f$7, this.f$8, this.f$9, this.f$10, this.f$11, this.f$12, this.f$13, this.f$14, this.f$15, this.f$16, this.f$17, this.f$18);
            }
        });
    }

    /* JADX WARNING: Code restructure failed: missing block: B:116:0x02be, code lost:
        if (r4.media.bytes[0] < 105) goto L_0x02c3;
     */
    /* JADX WARNING: Removed duplicated region for block: B:100:0x025c  */
    /* JADX WARNING: Removed duplicated region for block: B:123:0x02d5  */
    /* JADX WARNING: Removed duplicated region for block: B:151:0x0321 A[SYNTHETIC] */
    /* JADX WARNING: Removed duplicated region for block: B:52:0x0148 A[LOOP:2: B:50:0x0140->B:52:0x0148, LOOP_END] */
    /* JADX WARNING: Removed duplicated region for block: B:56:0x0161 A[LOOP:3: B:54:0x0159->B:56:0x0161, LOOP_END] */
    /* JADX WARNING: Removed duplicated region for block: B:59:0x017b  */
    /* JADX WARNING: Removed duplicated region for block: B:97:0x0246  */
    public /* synthetic */ void lambda$processLoadedMessages$125$MessagesController(TLRPC.messages_Messages messages_messages, long j, boolean z, boolean z2, int i, int i2, boolean z3, int i3, int i4, int i5, int i6, int i7, boolean z4, int i8, int i9, int i10, int i11, boolean z5) {
        boolean z6;
        boolean z7;
        TLRPC.messages_Messages messages_messages2;
        int i12;
        int i13;
        int size;
        boolean z8;
        long j2;
        int i14;
        boolean z9;
        TLRPC.User user;
        int i15;
        boolean z10;
        if (messages_messages instanceof TLRPC.TL_messages_channelMessages) {
            int i16 = -((int) j);
            if (!z && this.channelsPts.get(i16) == 0 && getMessagesStorage().getChannelPtsSync(i16) == 0) {
                this.channelsPts.put(i16, messages_messages.pts);
                if (this.needShortPollChannels.indexOfKey(i16) < 0 || this.shortPollChannels.indexOfKey(i16) >= 0) {
                    getChannelDifference(i16);
                } else {
                    getChannelDifference(i16, 2, 0, null);
                }
                z10 = true;
            } else {
                z10 = false;
            }
            int i17 = 0;
            while (true) {
                if (i17 >= messages_messages.chats.size()) {
                    z6 = z10;
                    z7 = false;
                    break;
                }
                TLRPC.Chat chat = messages_messages.chats.get(i17);
                if (chat.id == i16) {
                    z6 = z10;
                    z7 = chat.megagroup;
                    break;
                }
                i17++;
            }
        } else {
            z7 = false;
            z6 = false;
        }
        int i18 = (int) j;
        int i19 = (int) (j >> 32);
        if (!z2) {
            ImageLoader.saveMessagesThumbs(messages_messages.messages);
        }
        if (!(i19 == 1 || i18 == 0 || !z2)) {
            long j3 = 0;
            if (messages_messages.messages.size() == 0 || (z && SystemClock.uptimeMillis() - this.lastScheduledServerQueryTime.get(j, 0L).longValue() > DefaultLoadErrorHandlingPolicy.DEFAULT_TRACK_BLACKLIST_MS)) {
                if (z) {
                    this.lastScheduledServerQueryTime.put(j, Long.valueOf(SystemClock.uptimeMillis()));
                    int size2 = messages_messages.messages.size();
                    for (int i20 = 0; i20 < size2; i20++) {
                        TLRPC.Message message = messages_messages.messages.get(i20);
                        if (message.id >= 0) {
                            j3 = (((((((((((j3 * 20261) + 2147483648L) + ((long) message.id)) % 2147483648L) * 20261) + 2147483648L) + ((long) message.edit_date)) % 2147483648L) * 20261) + 2147483648L) + ((long) message.date)) % 2147483648L;
                        }
                    }
                    i15 = ((int) j3) - 1;
                } else {
                    i15 = 0;
                }
                AndroidUtilities.runOnUIThread(new Runnable(j, i, i2, z3, i3, i4, i5, i15, i6, i7, z4, z, i8, i9, i10, i11) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$gHFhnFcrZjxJicn2GgItVLk0HKA */
                    private final /* synthetic */ long f$1;
                    private final /* synthetic */ int f$10;
                    private final /* synthetic */ boolean f$11;
                    private final /* synthetic */ boolean f$12;
                    private final /* synthetic */ int f$13;
                    private final /* synthetic */ int f$14;
                    private final /* synthetic */ int f$15;
                    private final /* synthetic */ int f$16;
                    private final /* synthetic */ int f$2;
                    private final /* synthetic */ int f$3;
                    private final /* synthetic */ boolean f$4;
                    private final /* synthetic */ int f$5;
                    private final /* synthetic */ int f$6;
                    private final /* synthetic */ int f$7;
                    private final /* synthetic */ int f$8;
                    private final /* synthetic */ int f$9;

                    {
                        this.f$1 = r5;
                        this.f$2 = r7;
                        this.f$3 = r8;
                        this.f$4 = r9;
                        this.f$5 = r10;
                        this.f$6 = r11;
                        this.f$7 = r12;
                        this.f$8 = r13;
                        this.f$9 = r14;
                        this.f$10 = r15;
                        this.f$11 = r16;
                        this.f$12 = r17;
                        this.f$13 = r18;
                        this.f$14 = r19;
                        this.f$15 = r20;
                        this.f$16 = r21;
                    }

                    public final void run() {
                        MessagesController.this.lambda$null$123$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6, this.f$7, this.f$8, this.f$9, this.f$10, this.f$11, this.f$12, this.f$13, this.f$14, this.f$15, this.f$16);
                    }
                });
                messages_messages2 = messages_messages;
                if (messages_messages2.messages.isEmpty()) {
                    return;
                }
                SparseArray sparseArray = new SparseArray();
                SparseArray sparseArray2 = new SparseArray();
                for (i12 = 0; i12 < messages_messages2.users.size(); i12++) {
                    TLRPC.User user2 = messages_messages2.users.get(i12);
                    sparseArray.put(user2.id, user2);
                }
                for (i13 = 0; i13 < messages_messages2.chats.size(); i13++) {
                    TLRPC.Chat chat2 = messages_messages2.chats.get(i13);
                    sparseArray2.put(chat2.id, chat2);
                }
                size = messages_messages2.messages.size();
                MessagesController messagesController = this;
                if (z2) {
                    Integer num = messagesController.dialogs_read_inbox_max.get(Long.valueOf(j));
                    if (num == null) {
                        j2 = j;
                        z9 = false;
                        num = Integer.valueOf(getMessagesStorage().getDialogReadMax(false, j2));
                        messagesController.dialogs_read_inbox_max.put(Long.valueOf(j), num);
                    } else {
                        j2 = j;
                        z9 = false;
                    }
                    Integer num2 = messagesController.dialogs_read_outbox_max.get(Long.valueOf(j));
                    if (num2 == null) {
                        num2 = Integer.valueOf(getMessagesStorage().getDialogReadMax(true, j2));
                        messagesController.dialogs_read_outbox_max.put(Long.valueOf(j), num2);
                    }
                    for (int i21 = 0; i21 < size; i21++) {
                        TLRPC.Message message2 = messages_messages2.messages.get(i21);
                        if (z7) {
                            message2.flags |= Integer.MIN_VALUE;
                        }
                        if (!z) {
                            if ((message2.action instanceof TLRPC.TL_messageActionChatDeleteUser) && (user = (TLRPC.User) sparseArray.get(message2.action.user_id)) != null && user.bot) {
                                message2.reply_markup = new TLRPC.TL_replyKeyboardHide();
                                message2.flags |= 64;
                            }
                            if ((message2.action instanceof TLRPC.TL_messageActionChatMigrateTo) || (message2.action instanceof TLRPC.TL_messageActionChannelCreate)) {
                                message2.unread = z9;
                                message2.media_unread = z9;
                            } else {
                                message2.unread = (message2.out ? num2 : num).intValue() < message2.id;
                            }
                        }
                    }
                    z8 = z;
                    getMessagesStorage().putMessages(messages_messages, j, i2, i4, z6, z);
                } else {
                    j2 = j;
                    z8 = z;
                }
                ArrayList arrayList = new ArrayList();
                ArrayList arrayList2 = new ArrayList();
                HashMap hashMap = new HashMap();
                i14 = 0;
                while (i14 < size) {
                    TLRPC.Message message3 = messages_messages2.messages.get(i14);
                    message3.dialog_id = j2;
                    MessageObject messageObject = new MessageObject(messagesController.currentAccount, message3, (SparseArray<TLRPC.User>) sparseArray, (SparseArray<TLRPC.Chat>) sparseArray2, true);
                    messageObject.scheduled = z8;
                    arrayList.add(messageObject);
                    if (z2) {
                        if (message3.legacy && message3.layer < 105) {
                            arrayList2.add(Integer.valueOf(message3.id));
                        } else if ((message3.media instanceof TLRPC.TL_messageMediaUnsupported) && message3.media.bytes != null) {
                            if (message3.media.bytes.length != 0) {
                                if (message3.media.bytes.length == 1) {
                                }
                                if (message3.media instanceof TLRPC.TL_messageMediaWebPage) {
                                    if ((message3.media.webpage instanceof TLRPC.TL_webPagePending) && message3.media.webpage.date <= getConnectionsManager().getCurrentTime()) {
                                        arrayList2.add(Integer.valueOf(message3.id));
                                    } else if (message3.media.webpage instanceof TLRPC.TL_webPageUrlPending) {
                                        ArrayList arrayList3 = (ArrayList) hashMap.get(message3.media.webpage.url);
                                        if (arrayList3 == null) {
                                            arrayList3 = new ArrayList();
                                            hashMap.put(message3.media.webpage.url, arrayList3);
                                        }
                                        arrayList3.add(messageObject);
                                    }
                                }
                            }
                            arrayList2.add(Integer.valueOf(message3.id));
                            if (message3.media instanceof TLRPC.TL_messageMediaWebPage) {
                            }
                        }
                        if (message3.media instanceof TLRPC.TL_messageMediaWebPage) {
                        }
                    }
                    i14++;
                    hashMap = hashMap;
                    messagesController = this;
                }
                AndroidUtilities.runOnUIThread(new Runnable(messages_messages, z2, z, z3, i2, i3, i, j, arrayList, i7, i9, i10, z5, i6, i8, i4, i11, arrayList2, hashMap) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$ubcWbBPbNkZi5_5l2w0FL53Rdo */
                    private final /* synthetic */ TLRPC.messages_Messages f$1;
                    private final /* synthetic */ int f$10;
                    private final /* synthetic */ int f$11;
                    private final /* synthetic */ int f$12;
                    private final /* synthetic */ boolean f$13;
                    private final /* synthetic */ int f$14;
                    private final /* synthetic */ int f$15;
                    private final /* synthetic */ int f$16;
                    private final /* synthetic */ int f$17;
                    private final /* synthetic */ ArrayList f$18;
                    private final /* synthetic */ HashMap f$19;
                    private final /* synthetic */ boolean f$2;
                    private final /* synthetic */ boolean f$3;
                    private final /* synthetic */ boolean f$4;
                    private final /* synthetic */ int f$5;
                    private final /* synthetic */ int f$6;
                    private final /* synthetic */ int f$7;
                    private final /* synthetic */ long f$8;
                    private final /* synthetic */ ArrayList f$9;

                    {
                        this.f$1 = r5;
                        this.f$2 = r6;
                        this.f$3 = r7;
                        this.f$4 = r8;
                        this.f$5 = r9;
                        this.f$6 = r10;
                        this.f$7 = r11;
                        this.f$8 = r12;
                        this.f$9 = r14;
                        this.f$10 = r15;
                        this.f$11 = r16;
                        this.f$12 = r17;
                        this.f$13 = r18;
                        this.f$14 = r19;
                        this.f$15 = r20;
                        this.f$16 = r21;
                        this.f$17 = r22;
                        this.f$18 = r23;
                        this.f$19 = r24;
                    }

                    public final void run() {
                        MessagesController.this.lambda$null$124$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6, this.f$7, this.f$8, this.f$9, this.f$10, this.f$11, this.f$12, this.f$13, this.f$14, this.f$15, this.f$16, this.f$17, this.f$18, this.f$19);
                    }
                });
            }
        }
        messages_messages2 = messages_messages;
        SparseArray sparseArray3 = new SparseArray();
        SparseArray sparseArray22 = new SparseArray();
        while (i12 < messages_messages2.users.size()) {
        }
        while (i13 < messages_messages2.chats.size()) {
        }
        size = messages_messages2.messages.size();
        MessagesController messagesController2 = this;
        if (z2) {
        }
        ArrayList arrayList4 = new ArrayList();
        ArrayList arrayList22 = new ArrayList();
        HashMap hashMap2 = new HashMap();
        i14 = 0;
        while (i14 < size) {
        }
        AndroidUtilities.runOnUIThread(new Runnable(messages_messages, z2, z, z3, i2, i3, i, j, arrayList4, i7, i9, i10, z5, i6, i8, i4, i11, arrayList22, hashMap2) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$ubcWbBPbNkZi5_5l2w0FL53Rdo */
            private final /* synthetic */ TLRPC.messages_Messages f$1;
            private final /* synthetic */ int f$10;
            private final /* synthetic */ int f$11;
            private final /* synthetic */ int f$12;
            private final /* synthetic */ boolean f$13;
            private final /* synthetic */ int f$14;
            private final /* synthetic */ int f$15;
            private final /* synthetic */ int f$16;
            private final /* synthetic */ int f$17;
            private final /* synthetic */ ArrayList f$18;
            private final /* synthetic */ HashMap f$19;
            private final /* synthetic */ boolean f$2;
            private final /* synthetic */ boolean f$3;
            private final /* synthetic */ boolean f$4;
            private final /* synthetic */ int f$5;
            private final /* synthetic */ int f$6;
            private final /* synthetic */ int f$7;
            private final /* synthetic */ long f$8;
            private final /* synthetic */ ArrayList f$9;

            {
                this.f$1 = r5;
                this.f$2 = r6;
                this.f$3 = r7;
                this.f$4 = r8;
                this.f$5 = r9;
                this.f$6 = r10;
                this.f$7 = r11;
                this.f$8 = r12;
                this.f$9 = r14;
                this.f$10 = r15;
                this.f$11 = r16;
                this.f$12 = r17;
                this.f$13 = r18;
                this.f$14 = r19;
                this.f$15 = r20;
                this.f$16 = r21;
                this.f$17 = r22;
                this.f$18 = r23;
                this.f$19 = r24;
            }

            public final void run() {
                MessagesController.this.lambda$null$124$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6, this.f$7, this.f$8, this.f$9, this.f$10, this.f$11, this.f$12, this.f$13, this.f$14, this.f$15, this.f$16, this.f$17, this.f$18, this.f$19);
            }
        });
    }

    public /* synthetic */ void lambda$null$123$MessagesController(long j, int i, int i2, boolean z, int i3, int i4, int i5, int i6, int i7, int i8, boolean z2, boolean z3, int i9, int i10, int i11, int i12) {
        loadMessages(j, i, (i2 != 2 || !z) ? i4 : i3, i5, false, i6, i7, i2, i8, z2, z3, i9, i3, i10, i11, z, i12);
    }

    public /* synthetic */ void lambda$null$124$MessagesController(TLRPC.messages_Messages messages_messages, boolean z, boolean z2, boolean z3, int i, int i2, int i3, long j, ArrayList arrayList, int i4, int i5, int i6, boolean z4, int i7, int i8, int i9, int i10, ArrayList arrayList2, HashMap hashMap) {
        int i11;
        int i12;
        putUsers(messages_messages.users, z);
        putChats(messages_messages.chats, z);
        if (z2) {
            i11 = 0;
        } else {
            if (!z3 || i != 2) {
                i12 = i2;
                i11 = Integer.MAX_VALUE;
            } else {
                i11 = Integer.MAX_VALUE;
                for (int i13 = 0; i13 < messages_messages.messages.size(); i13++) {
                    TLRPC.Message message = messages_messages.messages.get(i13);
                    if (!message.out || message.from_scheduled) {
                        if (message.id > i2 && message.id < i11) {
                            i11 = message.id;
                        }
                    }
                }
                i12 = i2;
            }
            if (i11 == Integer.MAX_VALUE) {
                i11 = i12;
            }
        }
        if (z2 && i3 == 1) {
            getNotificationCenter().postNotificationName(NotificationCenter.scheduledMessagesUpdated, Long.valueOf(j), Integer.valueOf(arrayList.size()));
        }
        getNotificationCenter().postNotificationName(NotificationCenter.messagesDidLoad, Long.valueOf(j), Integer.valueOf(i3), arrayList, Boolean.valueOf(z), Integer.valueOf(i11), Integer.valueOf(i4), Integer.valueOf(i5), Integer.valueOf(i6), Integer.valueOf(i), Boolean.valueOf(z4), Integer.valueOf(i7), Integer.valueOf(i8), Integer.valueOf(i9), Integer.valueOf(i10), Boolean.valueOf(z2));
        if (!arrayList2.isEmpty()) {
            reloadMessages(arrayList2, j, z2);
        }
        if (!hashMap.isEmpty()) {
            reloadWebPages(j, hashMap, z2);
        }
    }

    public void loadHintDialogs() {
        if (this.hintDialogs.isEmpty() && !TextUtils.isEmpty(this.installReferer)) {
            TLRPC.TL_help_getRecentMeUrls tL_help_getRecentMeUrls = new TLRPC.TL_help_getRecentMeUrls();
            tL_help_getRecentMeUrls.referer = this.installReferer;
            getConnectionsManager().sendRequest(tL_help_getRecentMeUrls, new RequestDelegate() {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$7E5bvwRlokpS0IUzCvipbHlCvEE */

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$loadHintDialogs$127$MessagesController(tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$loadHintDialogs$127$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            AndroidUtilities.runOnUIThread(new Runnable(tLObject) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$oraIz9rMbepkA83Af1QvZFEE28 */
                private final /* synthetic */ TLObject f$1;

                {
                    this.f$1 = r2;
                }

                public final void run() {
                    MessagesController.this.lambda$null$126$MessagesController(this.f$1);
                }
            });
        }
    }

    public /* synthetic */ void lambda$null$126$MessagesController(TLObject tLObject) {
        TLRPC.TL_help_recentMeUrls tL_help_recentMeUrls = (TLRPC.TL_help_recentMeUrls) tLObject;
        putUsers(tL_help_recentMeUrls.users, false);
        putChats(tL_help_recentMeUrls.chats, false);
        this.hintDialogs.clear();
        this.hintDialogs.addAll(tL_help_recentMeUrls.urls);
        getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
    }

    private TLRPC.TL_dialogFolder ensureFolderDialogExists(int i, boolean[] zArr) {
        if (i == 0) {
            return null;
        }
        long makeFolderDialogId = DialogObject.makeFolderDialogId(i);
        TLRPC.Dialog dialog = this.dialogs_dict.get(makeFolderDialogId);
        if (dialog instanceof TLRPC.TL_dialogFolder) {
            if (zArr != null) {
                zArr[0] = false;
            }
            return (TLRPC.TL_dialogFolder) dialog;
        }
        if (zArr != null) {
            zArr[0] = true;
        }
        TLRPC.TL_dialogFolder tL_dialogFolder = new TLRPC.TL_dialogFolder();
        tL_dialogFolder.id = makeFolderDialogId;
        tL_dialogFolder.peer = new TLRPC.TL_peerUser();
        tL_dialogFolder.folder = new TLRPC.TL_folder();
        tL_dialogFolder.folder.id = i;
        tL_dialogFolder.folder.title = LocaleController.getString("ArchivedChats", R.string.ArchivedChats);
        tL_dialogFolder.pinned = true;
        int i2 = 0;
        for (int i3 = 0; i3 < this.allDialogs.size(); i3++) {
            TLRPC.Dialog dialog2 = this.allDialogs.get(i3);
            if (!dialog2.pinned) {
                break;
            }
            i2 = Math.max(dialog2.pinnedNum, i2);
        }
        tL_dialogFolder.pinnedNum = i2 + 1;
        TLRPC.TL_messages_dialogs tL_messages_dialogs = new TLRPC.TL_messages_dialogs();
        tL_messages_dialogs.dialogs.add(tL_dialogFolder);
        getMessagesStorage().putDialogs(tL_messages_dialogs, 1);
        this.dialogs_dict.put(makeFolderDialogId, tL_dialogFolder);
        this.allDialogs.add(0, tL_dialogFolder);
        return tL_dialogFolder;
    }

    /* access modifiers changed from: private */
    /* renamed from: removeFolder */
    public void lambda$onFolderEmpty$128$MessagesController(int i) {
        long makeFolderDialogId = DialogObject.makeFolderDialogId(i);
        TLRPC.Dialog dialog = this.dialogs_dict.get(makeFolderDialogId);
        if (dialog != null) {
            this.dialogs_dict.remove(makeFolderDialogId);
            this.allDialogs.remove(dialog);
            sortDialogs(null);
            getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
            getNotificationCenter().postNotificationName(NotificationCenter.folderBecomeEmpty, Integer.valueOf(i));
        }
    }

    /* access modifiers changed from: protected */
    public void onFolderEmpty(int i) {
        if (getUserConfig().getDialogLoadOffsets(i)[0] == Integer.MAX_VALUE) {
            lambda$onFolderEmpty$128$MessagesController(i);
        } else {
            loadDialogs(i, 0, 10, false, new Runnable(i) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$GlxDtQt4xHdlpu5bnsiZG8QZGWw */
                private final /* synthetic */ int f$1;

                {
                    this.f$1 = r2;
                }

                public final void run() {
                    MessagesController.this.lambda$onFolderEmpty$128$MessagesController(this.f$1);
                }
            });
        }
    }

    public void checkIfFolderEmpty(int i) {
        if (i != 0) {
            getMessagesStorage().checkIfFolderEmpty(i);
        }
    }

    public int addDialogToFolder(long j, int i, int i2, long j2) {
        ArrayList<Long> arrayList = new ArrayList<>(1);
        arrayList.add(Long.valueOf(j));
        return addDialogToFolder(arrayList, i, i2, null, j2);
    }

    /* JADX WARNING: Removed duplicated region for block: B:53:0x0127  */
    /* JADX WARNING: Removed duplicated region for block: B:55:0x0143 A[RETURN, SYNTHETIC] */
    /* JADX WARNING: Removed duplicated region for block: B:56:0x0145  */
    public int addDialogToFolder(ArrayList<Long> arrayList, int i, int i2, ArrayList<TLRPC.TL_inputFolderPeer> arrayList2, long j) {
        long j2;
        boolean[] zArr;
        long j3;
        NativeByteBuffer nativeByteBuffer;
        Exception e;
        int i3;
        int i4;
        TLRPC.Dialog dialog;
        int i5;
        TLRPC.TL_folders_editPeerFolders tL_folders_editPeerFolders = new TLRPC.TL_folders_editPeerFolders();
        int i6 = 1;
        if (j == 0) {
            int clientUserId = getUserConfig().getClientUserId();
            int size = arrayList.size();
            boolean z = false;
            boolean[] zArr2 = null;
            int i7 = 0;
            int i8 = 0;
            while (i7 < size) {
                long longValue = arrayList.get(i7).longValue();
                if ((DialogObject.isPeerDialogId(longValue) || DialogObject.isSecretDialogId(longValue)) && !((i == i6 && (longValue == ((long) clientUserId) || longValue == 777000 || isProxyDialog(longValue, false))) || (dialog = this.dialogs_dict.get(longValue)) == null)) {
                    dialog.folder_id = i;
                    if (i2 > 0) {
                        i5 = 1;
                        dialog.pinned = true;
                        dialog.pinnedNum = i2;
                    } else {
                        i5 = 1;
                        dialog.pinned = false;
                        dialog.pinnedNum = 0;
                    }
                    if (zArr2 == null) {
                        zArr2 = new boolean[i5];
                        ensureFolderDialogExists(i, zArr2);
                    }
                    if (DialogObject.isSecretDialogId(longValue)) {
                        i4 = i7;
                        i3 = size;
                        getMessagesStorage().setDialogsFolderId(null, null, longValue, i);
                    } else {
                        i4 = i7;
                        i3 = size;
                        TLRPC.TL_inputFolderPeer tL_inputFolderPeer = new TLRPC.TL_inputFolderPeer();
                        tL_inputFolderPeer.folder_id = i;
                        tL_inputFolderPeer.peer = getInputPeer((int) longValue);
                        tL_folders_editPeerFolders.folder_peers.add(tL_inputFolderPeer);
                        i8 += tL_inputFolderPeer.getObjectSize();
                    }
                    zArr2 = zArr2;
                    z = true;
                } else {
                    i4 = i7;
                    i3 = size;
                }
                i7 = i4 + 1;
                size = i3;
                i6 = 1;
            }
            if (!z) {
                return 0;
            }
            sortDialogs(null);
            getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
            if (i8 != 0) {
                try {
                    nativeByteBuffer = new NativeByteBuffer(i8 + 12);
                    try {
                        nativeByteBuffer.writeInt32(17);
                        nativeByteBuffer.writeInt32(i);
                        nativeByteBuffer.writeInt32(tL_folders_editPeerFolders.folder_peers.size());
                        int size2 = tL_folders_editPeerFolders.folder_peers.size();
                        for (int i9 = 0; i9 < size2; i9++) {
                            tL_folders_editPeerFolders.folder_peers.get(i9).serializeToStream(nativeByteBuffer);
                        }
                    } catch (Exception e2) {
                        e = e2;
                        FileLog.e(e);
                        j3 = getMessagesStorage().createPendingTask(nativeByteBuffer);
                        zArr = zArr2;
                        j2 = j3;
                        if (!tL_folders_editPeerFolders.folder_peers.isEmpty()) {
                        }
                        if (zArr == null) {
                        }
                    }
                } catch (Exception e3) {
                    e = e3;
                    nativeByteBuffer = null;
                    FileLog.e(e);
                    j3 = getMessagesStorage().createPendingTask(nativeByteBuffer);
                    zArr = zArr2;
                    j2 = j3;
                    if (!tL_folders_editPeerFolders.folder_peers.isEmpty()) {
                    }
                    if (zArr == null) {
                    }
                }
                j3 = getMessagesStorage().createPendingTask(nativeByteBuffer);
            } else {
                j3 = 0;
            }
            zArr = zArr2;
            j2 = j3;
        } else {
            tL_folders_editPeerFolders.folder_peers = arrayList2;
            zArr = null;
            j2 = j;
        }
        if (!tL_folders_editPeerFolders.folder_peers.isEmpty()) {
            getConnectionsManager().sendRequest(tL_folders_editPeerFolders, new RequestDelegate(j2) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$RLeu_HVQrJZA1oosSblBokuygGo */
                private final /* synthetic */ long f$1;

                {
                    this.f$1 = r2;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$addDialogToFolder$129$MessagesController(this.f$1, tLObject, tL_error);
                }
            });
            getMessagesStorage().setDialogsFolderId(null, tL_folders_editPeerFolders.folder_peers, 0, i);
        }
        if (zArr == null) {
            return 0;
        }
        return zArr[0] ? 2 : 1;
    }

    public /* synthetic */ void lambda$addDialogToFolder$129$MessagesController(long j, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            processUpdates((TLRPC.Updates) tLObject, false);
        }
        if (j != 0) {
            getMessagesStorage().removePendingTask(j);
        }
    }

    public void loadDialogs(int i, int i2, int i3, boolean z) {
        loadDialogs(i, i2, i3, z, null);
    }

    public void loadDialogs(int i, int i2, int i3, boolean z, Runnable runnable) {
        MessageObject messageObject;
        int i4;
        int i5;
        if (!this.loadingDialogs.get(i) && !this.resetingDialogs) {
            boolean z2 = true;
            this.loadingDialogs.put(i, true);
            int i6 = 0;
            getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
            if (z) {
                MessagesStorage messagesStorage = getMessagesStorage();
                if (i2 != 0) {
                    i6 = this.nextDialogsCacheOffset.get(i, 0);
                }
                messagesStorage.getDialogs(i, i6, i3);
                return;
            }
            TLRPC.TL_messages_getDialogs tL_messages_getDialogs = new TLRPC.TL_messages_getDialogs();
            tL_messages_getDialogs.limit = i3;
            tL_messages_getDialogs.exclude_pinned = true;
            if (i != 0) {
                tL_messages_getDialogs.flags |= 2;
                tL_messages_getDialogs.folder_id = i;
            }
            int[] dialogLoadOffsets = getUserConfig().getDialogLoadOffsets(i);
            if (dialogLoadOffsets[0] == -1) {
                ArrayList<TLRPC.Dialog> dialogs = getDialogs(i);
                int size = dialogs.size() - 1;
                while (true) {
                    if (size < 0) {
                        z2 = false;
                        break;
                    }
                    TLRPC.Dialog dialog = dialogs.get(size);
                    if (!dialog.pinned) {
                        int i7 = (int) dialog.id;
                        int i8 = (int) (dialog.id >> 32);
                        if (!(i7 == 0 || i8 == 1 || dialog.top_message <= 0 || (messageObject = this.dialogMessage.get(dialog.id)) == null || messageObject.getId() <= 0)) {
                            tL_messages_getDialogs.offset_date = messageObject.messageOwner.date;
                            tL_messages_getDialogs.offset_id = messageObject.messageOwner.id;
                            if (messageObject.messageOwner.to_id.channel_id != 0) {
                                i5 = messageObject.messageOwner.to_id.channel_id;
                            } else if (messageObject.messageOwner.to_id.chat_id != 0) {
                                i5 = messageObject.messageOwner.to_id.chat_id;
                            } else {
                                i4 = messageObject.messageOwner.to_id.user_id;
                                tL_messages_getDialogs.offset_peer = getInputPeer(i4);
                            }
                            i4 = -i5;
                            tL_messages_getDialogs.offset_peer = getInputPeer(i4);
                        }
                    }
                    size--;
                }
                if (!z2) {
                    tL_messages_getDialogs.offset_peer = new TLRPC.TL_inputPeerEmpty();
                }
            } else if (dialogLoadOffsets[0] == Integer.MAX_VALUE) {
                this.dialogsEndReached.put(i, true);
                this.serverDialogsEndReached.put(i, true);
                this.loadingDialogs.put(i, false);
                getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
                return;
            } else {
                tL_messages_getDialogs.offset_id = dialogLoadOffsets[0];
                tL_messages_getDialogs.offset_date = dialogLoadOffsets[1];
                if (tL_messages_getDialogs.offset_id == 0) {
                    tL_messages_getDialogs.offset_peer = new TLRPC.TL_inputPeerEmpty();
                } else {
                    if (dialogLoadOffsets[4] != 0) {
                        tL_messages_getDialogs.offset_peer = new TLRPC.TL_inputPeerChannel();
                        tL_messages_getDialogs.offset_peer.channel_id = dialogLoadOffsets[4];
                    } else if (dialogLoadOffsets[2] != 0) {
                        tL_messages_getDialogs.offset_peer = new TLRPC.TL_inputPeerUser();
                        tL_messages_getDialogs.offset_peer.user_id = dialogLoadOffsets[2];
                    } else {
                        tL_messages_getDialogs.offset_peer = new TLRPC.TL_inputPeerChat();
                        tL_messages_getDialogs.offset_peer.chat_id = dialogLoadOffsets[3];
                    }
                    tL_messages_getDialogs.offset_peer.access_hash = (((long) dialogLoadOffsets[5]) << 32) | ((long) dialogLoadOffsets[5]);
                }
            }
            getConnectionsManager().sendRequest(tL_messages_getDialogs, new RequestDelegate(i, i3, runnable) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$ex7Fwyy3lFSoWgDtfFj4BYYQVl0 */
                private final /* synthetic */ int f$1;
                private final /* synthetic */ int f$2;
                private final /* synthetic */ Runnable f$3;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                    this.f$3 = r4;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$loadDialogs$130$MessagesController(this.f$1, this.f$2, this.f$3, tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$loadDialogs$130$MessagesController(int i, int i2, Runnable runnable, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            TLRPC.messages_Dialogs messages_dialogs = (TLRPC.messages_Dialogs) tLObject;
            processLoadedDialogs(messages_dialogs, null, i, 0, i2, 0, false, false, false);
            if (runnable != null && messages_dialogs.dialogs.isEmpty()) {
                AndroidUtilities.runOnUIThread(runnable);
            }
        }
    }

    public void loadGlobalNotificationsSettings() {
        if (this.loadingNotificationSettings == 0 && !getUserConfig().notificationsSettingsLoaded) {
            SharedPreferences notificationsSettings = getNotificationsSettings(this.currentAccount);
            SharedPreferences.Editor editor = null;
            if (notificationsSettings.contains("EnableGroup")) {
                boolean z = notificationsSettings.getBoolean("EnableGroup", true);
                SharedPreferences.Editor edit = notificationsSettings.edit();
                if (!z) {
                    edit.putInt("EnableGroup2", Integer.MAX_VALUE);
                    edit.putInt("EnableChannel2", Integer.MAX_VALUE);
                }
                edit.remove("EnableGroup").commit();
                editor = edit;
            }
            if (notificationsSettings.contains("EnableAll")) {
                boolean z2 = notificationsSettings.getBoolean("EnableAll", true);
                if (editor == null) {
                    editor = notificationsSettings.edit();
                }
                if (!z2) {
                    editor.putInt("EnableAll2", Integer.MAX_VALUE);
                }
                editor.remove("EnableAll").commit();
            }
            if (editor != null) {
                editor.commit();
            }
            this.loadingNotificationSettings = 3;
            for (int i = 0; i < 3; i++) {
                TLRPC.TL_account_getNotifySettings tL_account_getNotifySettings = new TLRPC.TL_account_getNotifySettings();
                if (i == 0) {
                    tL_account_getNotifySettings.peer = new TLRPC.TL_inputNotifyChats();
                } else if (i == 1) {
                    tL_account_getNotifySettings.peer = new TLRPC.TL_inputNotifyUsers();
                } else if (i == 2) {
                    tL_account_getNotifySettings.peer = new TLRPC.TL_inputNotifyBroadcasts();
                }
                getConnectionsManager().sendRequest(tL_account_getNotifySettings, new RequestDelegate(i) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$fvrpxKSUju9thKr8PgcU4qBatw */
                    private final /* synthetic */ int f$1;

                    {
                        this.f$1 = r2;
                    }

                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        MessagesController.this.lambda$loadGlobalNotificationsSettings$132$MessagesController(this.f$1, tLObject, tL_error);
                    }
                });
            }
        }
        if (!getUserConfig().notificationsSignUpSettingsLoaded) {
            loadSignUpNotificationsSettings();
        }
    }

    public /* synthetic */ void lambda$loadGlobalNotificationsSettings$132$MessagesController(int i, TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable(tLObject, i) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$qG3aMPhlpvlx5YA_M99Y_Balo4 */
            private final /* synthetic */ TLObject f$1;
            private final /* synthetic */ int f$2;

            {
                this.f$1 = r2;
                this.f$2 = r3;
            }

            public final void run() {
                MessagesController.this.lambda$null$131$MessagesController(this.f$1, this.f$2);
            }
        });
    }

    public /* synthetic */ void lambda$null$131$MessagesController(TLObject tLObject, int i) {
        if (tLObject != null) {
            this.loadingNotificationSettings--;
            TLRPC.TL_peerNotifySettings tL_peerNotifySettings = (TLRPC.TL_peerNotifySettings) tLObject;
            SharedPreferences.Editor edit = this.notificationsPreferences.edit();
            if (i == 0) {
                if ((tL_peerNotifySettings.flags & 1) != 0) {
                    edit.putBoolean("EnablePreviewGroup", tL_peerNotifySettings.show_previews);
                }
                int i2 = tL_peerNotifySettings.flags;
                if ((tL_peerNotifySettings.flags & 4) != 0) {
                    edit.putInt("EnableGroup2", tL_peerNotifySettings.mute_until);
                }
            } else if (i == 1) {
                if ((tL_peerNotifySettings.flags & 1) != 0) {
                    edit.putBoolean("EnablePreviewAll", tL_peerNotifySettings.show_previews);
                }
                int i3 = tL_peerNotifySettings.flags;
                if ((tL_peerNotifySettings.flags & 4) != 0) {
                    edit.putInt("EnableAll2", tL_peerNotifySettings.mute_until);
                }
            } else if (i == 2) {
                if ((tL_peerNotifySettings.flags & 1) != 0) {
                    edit.putBoolean("EnablePreviewChannel", tL_peerNotifySettings.show_previews);
                }
                int i4 = tL_peerNotifySettings.flags;
                if ((tL_peerNotifySettings.flags & 4) != 0) {
                    edit.putInt("EnableChannel2", tL_peerNotifySettings.mute_until);
                }
            }
            edit.commit();
            if (this.loadingNotificationSettings == 0) {
                getUserConfig().notificationsSettingsLoaded = true;
                getUserConfig().saveConfig(false);
            }
        }
    }

    public void loadSignUpNotificationsSettings() {
        if (!this.loadingNotificationSignUpSettings) {
            this.loadingNotificationSignUpSettings = true;
            getConnectionsManager().sendRequest(new TLRPC.TL_account_getContactSignUpNotification(), new RequestDelegate() {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$zescuse3hekcTruiMGCbUnufGY */

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$loadSignUpNotificationsSettings$134$MessagesController(tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$loadSignUpNotificationsSettings$134$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable(tLObject) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$AUBZyKqu11HQl0LwPm1ufyI6kzs */
            private final /* synthetic */ TLObject f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                MessagesController.this.lambda$null$133$MessagesController(this.f$1);
            }
        });
    }

    public /* synthetic */ void lambda$null$133$MessagesController(TLObject tLObject) {
        this.loadingNotificationSignUpSettings = false;
        SharedPreferences.Editor edit = this.notificationsPreferences.edit();
        boolean z = tLObject instanceof TLRPC.TL_boolFalse;
        this.enableJoined = z;
        edit.putBoolean("EnableContactJoined", z);
        edit.commit();
        getUserConfig().notificationsSignUpSettingsLoaded = true;
        getUserConfig().saveConfig(false);
    }

    public void forceResetDialogs() {
        resetDialogs(true, getMessagesStorage().getLastSeqValue(), getMessagesStorage().getLastPtsValue(), getMessagesStorage().getLastDateValue(), getMessagesStorage().getLastQtsValue());
        getNotificationsController().deleteAllNotificationChannels();
    }

    /* access modifiers changed from: protected */
    public void loadUnknownDialog(TLRPC.InputPeer inputPeer, long j) {
        NativeByteBuffer nativeByteBuffer;
        Exception e;
        if (inputPeer != null) {
            long peerDialogId = DialogObject.getPeerDialogId(inputPeer);
            if (this.gettingUnknownDialogs.indexOfKey(peerDialogId) < 0) {
                this.gettingUnknownDialogs.put(peerDialogId, true);
                if (BuildVars.LOGS_ENABLED) {
                    FileLog.d("load unknown dialog " + peerDialogId);
                }
                TLRPC.TL_messages_getPeerDialogs tL_messages_getPeerDialogs = new TLRPC.TL_messages_getPeerDialogs();
                TLRPC.TL_inputDialogPeer tL_inputDialogPeer = new TLRPC.TL_inputDialogPeer();
                tL_inputDialogPeer.peer = inputPeer;
                tL_messages_getPeerDialogs.peers.add(tL_inputDialogPeer);
                if (j == 0) {
                    NativeByteBuffer nativeByteBuffer2 = null;
                    try {
                        nativeByteBuffer = new NativeByteBuffer(inputPeer.getObjectSize() + 4);
                        try {
                            nativeByteBuffer.writeInt32(15);
                            inputPeer.serializeToStream(nativeByteBuffer);
                        } catch (Exception e2) {
                            e = e2;
                            nativeByteBuffer2 = nativeByteBuffer;
                        }
                    } catch (Exception e3) {
                        e = e3;
                        FileLog.e(e);
                        nativeByteBuffer = nativeByteBuffer2;
                        j = getMessagesStorage().createPendingTask(nativeByteBuffer);
                        getConnectionsManager().sendRequest(tL_messages_getPeerDialogs, new RequestDelegate(j, peerDialogId) {
                            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$JlLuFn4hxtoDvWCS3kS4560VUig */
                            private final /* synthetic */ long f$1;
                            private final /* synthetic */ long f$2;

                            {
                                this.f$1 = r2;
                                this.f$2 = r4;
                            }

                            @Override // im.guobwnxjuc.tgnet.RequestDelegate
                            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                                MessagesController.this.lambda$loadUnknownDialog$135$MessagesController(this.f$1, this.f$2, tLObject, tL_error);
                            }
                        });
                    }
                    j = getMessagesStorage().createPendingTask(nativeByteBuffer);
                }
                getConnectionsManager().sendRequest(tL_messages_getPeerDialogs, new RequestDelegate(j, peerDialogId) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$JlLuFn4hxtoDvWCS3kS4560VUig */
                    private final /* synthetic */ long f$1;
                    private final /* synthetic */ long f$2;

                    {
                        this.f$1 = r2;
                        this.f$2 = r4;
                    }

                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        MessagesController.this.lambda$loadUnknownDialog$135$MessagesController(this.f$1, this.f$2, tLObject, tL_error);
                    }
                });
            }
        }
    }

    public /* synthetic */ void lambda$loadUnknownDialog$135$MessagesController(long j, long j2, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tLObject != null) {
            TLRPC.TL_messages_peerDialogs tL_messages_peerDialogs = (TLRPC.TL_messages_peerDialogs) tLObject;
            if (!tL_messages_peerDialogs.dialogs.isEmpty() && !(tL_messages_peerDialogs.dialogs.get(0) instanceof TLRPC.TL_dialogFolder)) {
                TLRPC.TL_messages_dialogs tL_messages_dialogs = new TLRPC.TL_messages_dialogs();
                tL_messages_dialogs.dialogs.addAll(tL_messages_peerDialogs.dialogs);
                tL_messages_dialogs.messages.addAll(tL_messages_peerDialogs.messages);
                tL_messages_dialogs.users.addAll(tL_messages_peerDialogs.users);
                tL_messages_dialogs.chats.addAll(tL_messages_peerDialogs.chats);
                processLoadedDialogs(tL_messages_dialogs, null, ((TLRPC.TL_dialog) tL_messages_peerDialogs.dialogs.get(0)).folder_id, 0, 1, this.DIALOGS_LOAD_TYPE_UNKNOWN, false, false, false);
            }
        }
        if (j != 0) {
            getMessagesStorage().removePendingTask(j);
        }
        this.gettingUnknownDialogs.delete(j2);
    }

    private void fetchFolderInLoadedPinnedDialogs(TLRPC.TL_messages_peerDialogs tL_messages_peerDialogs) {
        TLRPC.InputPeer inputPeer;
        int size = tL_messages_peerDialogs.dialogs.size();
        int i = 0;
        for (int i2 = 0; i2 < size; i2++) {
            TLRPC.Dialog dialog = tL_messages_peerDialogs.dialogs.get(i2);
            if (dialog instanceof TLRPC.TL_dialogFolder) {
                TLRPC.TL_dialogFolder tL_dialogFolder = (TLRPC.TL_dialogFolder) dialog;
                long peerDialogId = DialogObject.getPeerDialogId(dialog.peer);
                if (tL_dialogFolder.top_message == 0 || peerDialogId == 0) {
                    tL_messages_peerDialogs.dialogs.remove(tL_dialogFolder);
                } else {
                    int size2 = tL_messages_peerDialogs.messages.size();
                    for (int i3 = 0; i3 < size2; i3++) {
                        TLRPC.Message message = tL_messages_peerDialogs.messages.get(i3);
                        if (peerDialogId == MessageObject.getDialogId(message) && dialog.top_message == message.id) {
                            TLRPC.TL_dialog tL_dialog = new TLRPC.TL_dialog();
                            tL_dialog.peer = dialog.peer;
                            tL_dialog.top_message = dialog.top_message;
                            tL_dialog.folder_id = tL_dialogFolder.folder.id;
                            tL_dialog.flags |= 16;
                            tL_messages_peerDialogs.dialogs.add(tL_dialog);
                            if (dialog.peer instanceof TLRPC.TL_peerChannel) {
                                inputPeer = new TLRPC.TL_inputPeerChannel();
                                inputPeer.channel_id = dialog.peer.channel_id;
                                int size3 = tL_messages_peerDialogs.chats.size();
                                while (true) {
                                    if (i >= size3) {
                                        break;
                                    }
                                    TLRPC.Chat chat = tL_messages_peerDialogs.chats.get(i);
                                    if (chat.id == inputPeer.channel_id) {
                                        inputPeer.access_hash = chat.access_hash;
                                        break;
                                    }
                                    i++;
                                }
                            } else if (!(dialog.peer instanceof TLRPC.TL_peerChat)) {
                                inputPeer = new TLRPC.TL_inputPeerUser();
                                inputPeer.user_id = dialog.peer.user_id;
                                int size4 = tL_messages_peerDialogs.users.size();
                                while (true) {
                                    if (i >= size4) {
                                        break;
                                    }
                                    TLRPC.User user = tL_messages_peerDialogs.users.get(i);
                                    if (user.id == inputPeer.user_id) {
                                        inputPeer.access_hash = user.access_hash;
                                        break;
                                    }
                                    i++;
                                }
                            } else {
                                inputPeer = new TLRPC.TL_inputPeerChat();
                                inputPeer.chat_id = dialog.peer.chat_id;
                            }
                            loadUnknownDialog(inputPeer, 0);
                            return;
                        }
                    }
                    return;
                }
            }
        }
    }

    public /* synthetic */ void lambda$resetDialogs$136$MessagesController(int i, int i2, int i3, int i4, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tLObject != null) {
            this.resetDialogsPinned = (TLRPC.TL_messages_peerDialogs) tLObject;
            for (int i5 = 0; i5 < this.resetDialogsPinned.dialogs.size(); i5++) {
                this.resetDialogsPinned.dialogs.get(i5).pinned = true;
            }
            resetDialogs(false, i, i2, i3, i4);
        }
    }

    public /* synthetic */ void lambda$resetDialogs$137$MessagesController(int i, int i2, int i3, int i4, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            this.resetDialogsAll = (TLRPC.messages_Dialogs) tLObject;
            resetDialogs(false, i, i2, i3, i4);
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:68:0x01d2, code lost:
        if (r11.migrated_to != null) goto L_0x0185;
     */
    private void resetDialogs(boolean z, int i, int i2, int i3, int i4) {
        TLRPC.messages_Dialogs messages_dialogs;
        TLRPC.User user;
        Integer num;
        MessageObject messageObject;
        TLRPC.Chat chat;
        int i5 = 0;
        if (z) {
            if (!this.resetingDialogs) {
                getUserConfig().setPinnedDialogsLoaded(1, false);
                this.resetingDialogs = true;
                getConnectionsManager().sendRequest(new TLRPC.TL_messages_getPinnedDialogs(), new RequestDelegate(i, i2, i3, i4) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$0_RqRBfgU7b9_Ugri_GPYExHQ7U */
                    private final /* synthetic */ int f$1;
                    private final /* synthetic */ int f$2;
                    private final /* synthetic */ int f$3;
                    private final /* synthetic */ int f$4;

                    {
                        this.f$1 = r2;
                        this.f$2 = r3;
                        this.f$3 = r4;
                        this.f$4 = r5;
                    }

                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        MessagesController.this.lambda$resetDialogs$136$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, tLObject, tL_error);
                    }
                });
                TLRPC.TL_messages_getDialogs tL_messages_getDialogs = new TLRPC.TL_messages_getDialogs();
                tL_messages_getDialogs.limit = 100;
                tL_messages_getDialogs.exclude_pinned = true;
                tL_messages_getDialogs.offset_peer = new TLRPC.TL_inputPeerEmpty();
                getConnectionsManager().sendRequest(tL_messages_getDialogs, new RequestDelegate(i, i2, i3, i4) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$mibrrNlPJpZ2pt3v6aYhNJSdJ94 */
                    private final /* synthetic */ int f$1;
                    private final /* synthetic */ int f$2;
                    private final /* synthetic */ int f$3;
                    private final /* synthetic */ int f$4;

                    {
                        this.f$1 = r2;
                        this.f$2 = r3;
                        this.f$3 = r4;
                        this.f$4 = r5;
                    }

                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        MessagesController.this.lambda$resetDialogs$137$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, tLObject, tL_error);
                    }
                });
            }
        } else if (this.resetDialogsPinned != null && (messages_dialogs = this.resetDialogsAll) != null) {
            int size = messages_dialogs.messages.size();
            int size2 = this.resetDialogsAll.dialogs.size();
            fetchFolderInLoadedPinnedDialogs(this.resetDialogsPinned);
            this.resetDialogsAll.dialogs.addAll(this.resetDialogsPinned.dialogs);
            this.resetDialogsAll.messages.addAll(this.resetDialogsPinned.messages);
            this.resetDialogsAll.users.addAll(this.resetDialogsPinned.users);
            this.resetDialogsAll.chats.addAll(this.resetDialogsPinned.chats);
            LongSparseArray<TLRPC.Dialog> longSparseArray = new LongSparseArray<>();
            LongSparseArray<MessageObject> longSparseArray2 = new LongSparseArray<>();
            SparseArray sparseArray = new SparseArray();
            SparseArray sparseArray2 = new SparseArray();
            for (int i6 = 0; i6 < this.resetDialogsAll.users.size(); i6++) {
                TLRPC.User user2 = this.resetDialogsAll.users.get(i6);
                sparseArray.put(user2.id, user2);
            }
            for (int i7 = 0; i7 < this.resetDialogsAll.chats.size(); i7++) {
                TLRPC.Chat chat2 = this.resetDialogsAll.chats.get(i7);
                sparseArray2.put(chat2.id, chat2);
            }
            TLRPC.Message message = null;
            for (int i8 = 0; i8 < this.resetDialogsAll.messages.size(); i8++) {
                TLRPC.Message message2 = this.resetDialogsAll.messages.get(i8);
                if (i8 < size && (message == null || message2.date < message.date)) {
                    message = message2;
                }
                if (message2.to_id.channel_id != 0) {
                    TLRPC.Chat chat3 = (TLRPC.Chat) sparseArray2.get(message2.to_id.channel_id);
                    if (chat3 == null || !chat3.left) {
                        if (chat3 != null && chat3.megagroup) {
                            message2.flags |= Integer.MIN_VALUE;
                        }
                    }
                } else if (!(message2.to_id.chat_id == 0 || (chat = (TLRPC.Chat) sparseArray2.get(message2.to_id.chat_id)) == null || chat.migrated_to == null)) {
                }
                MessageObject messageObject2 = new MessageObject(this.currentAccount, message2, (SparseArray<TLRPC.User>) sparseArray, (SparseArray<TLRPC.Chat>) sparseArray2, false);
                longSparseArray2.put(messageObject2.getDialogId(), messageObject2);
            }
            int i9 = 0;
            while (i9 < this.resetDialogsAll.dialogs.size()) {
                TLRPC.Dialog dialog = this.resetDialogsAll.dialogs.get(i9);
                DialogObject.initDialog(dialog);
                if (dialog.id != 0) {
                    if (dialog.last_message_date == 0 && (messageObject = longSparseArray2.get(dialog.id)) != null) {
                        dialog.last_message_date = messageObject.messageOwner.date;
                    }
                    if (DialogObject.isChannel(dialog)) {
                        TLRPC.Chat chat4 = (TLRPC.Chat) sparseArray2.get(-((int) dialog.id));
                        if (chat4 == null || !chat4.left) {
                            this.channelsPts.put(-((int) dialog.id), dialog.pts);
                        }
                    } else if (((int) dialog.id) < 0) {
                        TLRPC.Chat chat5 = (TLRPC.Chat) sparseArray2.get(-((int) dialog.id));
                        if (chat5 != null) {
                        }
                    }
                    longSparseArray.put(dialog.id, dialog);
                    Integer num2 = this.dialogs_read_inbox_max.get(Long.valueOf(dialog.id));
                    if (num2 == null) {
                        num2 = i5;
                    }
                    num = i5;
                    this.dialogs_read_inbox_max.put(Long.valueOf(dialog.id), Integer.valueOf(Math.max(num2.intValue(), dialog.read_inbox_max_id)));
                    Integer num3 = this.dialogs_read_outbox_max.get(Long.valueOf(dialog.id));
                    if (num3 == null) {
                        num3 = num;
                    }
                    this.dialogs_read_outbox_max.put(Long.valueOf(dialog.id), Integer.valueOf(Math.max(num3.intValue(), dialog.read_outbox_max_id)));
                    i9++;
                    i5 = num;
                }
                num = i5;
                i9++;
                i5 = num;
            }
            ImageLoader.saveMessagesThumbs(this.resetDialogsAll.messages);
            for (int i10 = 0; i10 < this.resetDialogsAll.messages.size(); i10++) {
                TLRPC.Message message3 = this.resetDialogsAll.messages.get(i10);
                if ((message3.action instanceof TLRPC.TL_messageActionChatDeleteUser) && (user = (TLRPC.User) sparseArray.get(message3.action.user_id)) != null && user.bot) {
                    message3.reply_markup = new TLRPC.TL_replyKeyboardHide();
                    message3.flags |= 64;
                }
                if ((message3.action instanceof TLRPC.TL_messageActionChatMigrateTo) || (message3.action instanceof TLRPC.TL_messageActionChannelCreate)) {
                    message3.unread = false;
                    message3.media_unread = false;
                } else {
                    ConcurrentHashMap<Long, Integer> concurrentHashMap = message3.out ? this.dialogs_read_outbox_max : this.dialogs_read_inbox_max;
                    Integer num4 = concurrentHashMap.get(Long.valueOf(message3.dialog_id));
                    if (num4 == null) {
                        num4 = Integer.valueOf(getMessagesStorage().getDialogReadMax(message3.out, message3.dialog_id));
                        concurrentHashMap.put(Long.valueOf(message3.dialog_id), num4);
                    }
                    message3.unread = num4.intValue() < message3.id;
                }
            }
            getMessagesStorage().resetDialogs(this.resetDialogsAll, size, i, i2, i3, i4, longSparseArray, longSparseArray2, message, size2);
            this.resetDialogsPinned = null;
            this.resetDialogsAll = null;
        }
    }

    /* access modifiers changed from: protected */
    public void completeDialogsReset(TLRPC.messages_Dialogs messages_dialogs, int i, int i2, int i3, int i4, int i5, LongSparseArray<TLRPC.Dialog> longSparseArray, LongSparseArray<MessageObject> longSparseArray2, TLRPC.Message message) {
        Utilities.stageQueue.postRunnable(new Runnable(i3, i4, i5, messages_dialogs, longSparseArray, longSparseArray2) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$5ErFSX2iXAfU8XTa7iXrtvrv3a8 */
            private final /* synthetic */ int f$1;
            private final /* synthetic */ int f$2;
            private final /* synthetic */ int f$3;
            private final /* synthetic */ TLRPC.messages_Dialogs f$4;
            private final /* synthetic */ LongSparseArray f$5;
            private final /* synthetic */ LongSparseArray f$6;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
                this.f$4 = r5;
                this.f$5 = r6;
                this.f$6 = r7;
            }

            public final void run() {
                MessagesController.this.lambda$completeDialogsReset$139$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6);
            }
        });
    }

    public /* synthetic */ void lambda$completeDialogsReset$139$MessagesController(int i, int i2, int i3, TLRPC.messages_Dialogs messages_dialogs, LongSparseArray longSparseArray, LongSparseArray longSparseArray2) {
        this.gettingDifference = false;
        getMessagesStorage().setLastPtsValue(i);
        getMessagesStorage().setLastDateValue(i2);
        getMessagesStorage().setLastQtsValue(i3);
        getDifference();
        AndroidUtilities.runOnUIThread(new Runnable(messages_dialogs, longSparseArray, longSparseArray2) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$C320QjLvA8dbFYB_EM38Id0LR94 */
            private final /* synthetic */ TLRPC.messages_Dialogs f$1;
            private final /* synthetic */ LongSparseArray f$2;
            private final /* synthetic */ LongSparseArray f$3;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
            }

            public final void run() {
                MessagesController.this.lambda$null$138$MessagesController(this.f$1, this.f$2, this.f$3);
            }
        });
    }

    public /* synthetic */ void lambda$null$138$MessagesController(TLRPC.messages_Dialogs messages_dialogs, LongSparseArray longSparseArray, LongSparseArray longSparseArray2) {
        this.resetingDialogs = false;
        applyDialogsNotificationsSettings(messages_dialogs.dialogs);
        if (!getUserConfig().draftsLoaded) {
            getMediaDataController().loadDrafts();
        }
        putUsers(messages_dialogs.users, false);
        putChats(messages_dialogs.chats, false);
        for (int i = 0; i < this.allDialogs.size(); i++) {
            TLRPC.Dialog dialog = this.allDialogs.get(i);
            if (!DialogObject.isSecretDialogId(dialog.id)) {
                this.dialogs_dict.remove(dialog.id);
                MessageObject messageObject = this.dialogMessage.get(dialog.id);
                this.dialogMessage.remove(dialog.id);
                if (messageObject != null) {
                    this.dialogMessagesByIds.remove(messageObject.getId());
                    if (messageObject.messageOwner.random_id != 0) {
                        this.dialogMessagesByRandomIds.remove(messageObject.messageOwner.random_id);
                    }
                }
            }
        }
        for (int i2 = 0; i2 < longSparseArray.size(); i2++) {
            long keyAt = longSparseArray.keyAt(i2);
            TLRPC.Dialog dialog2 = (TLRPC.Dialog) longSparseArray.valueAt(i2);
            if (dialog2.draft instanceof TLRPC.TL_draftMessage) {
                getMediaDataController().saveDraft(dialog2.id, dialog2.draft, null, false);
            }
            this.dialogs_dict.put(keyAt, dialog2);
            MessageObject messageObject2 = (MessageObject) longSparseArray2.get(dialog2.id);
            this.dialogMessage.put(keyAt, messageObject2);
            if (messageObject2 != null && messageObject2.messageOwner.to_id.channel_id == 0) {
                this.dialogMessagesByIds.put(messageObject2.getId(), messageObject2);
                if (messageObject2.messageOwner.random_id != 0) {
                    this.dialogMessagesByRandomIds.put(messageObject2.messageOwner.random_id, messageObject2);
                }
            }
        }
        this.allDialogs.clear();
        int size = this.dialogs_dict.size();
        for (int i3 = 0; i3 < size; i3++) {
            this.allDialogs.add(this.dialogs_dict.valueAt(i3));
        }
        sortDialogs(null);
        this.dialogsEndReached.put(0, true);
        this.serverDialogsEndReached.put(0, false);
        this.dialogsEndReached.put(1, true);
        this.serverDialogsEndReached.put(1, false);
        int totalDialogsCount = getUserConfig().getTotalDialogsCount(0);
        int[] dialogLoadOffsets = getUserConfig().getDialogLoadOffsets(0);
        if (!(totalDialogsCount >= 400 || dialogLoadOffsets[0] == -1 || dialogLoadOffsets[0] == Integer.MAX_VALUE)) {
            loadDialogs(0, 100, 0, false);
        }
        getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
    }

    private void migrateDialogs(int i, int i2, int i3, int i4, int i5, long j) {
        if (!this.migratingDialogs && i != -1) {
            this.migratingDialogs = true;
            TLRPC.TL_messages_getDialogs tL_messages_getDialogs = new TLRPC.TL_messages_getDialogs();
            tL_messages_getDialogs.exclude_pinned = true;
            tL_messages_getDialogs.limit = 100;
            tL_messages_getDialogs.offset_id = i;
            tL_messages_getDialogs.offset_date = i2;
            if (i == 0) {
                tL_messages_getDialogs.offset_peer = new TLRPC.TL_inputPeerEmpty();
            } else {
                if (i5 != 0) {
                    tL_messages_getDialogs.offset_peer = new TLRPC.TL_inputPeerChannel();
                    tL_messages_getDialogs.offset_peer.channel_id = i5;
                } else if (i3 != 0) {
                    tL_messages_getDialogs.offset_peer = new TLRPC.TL_inputPeerUser();
                    tL_messages_getDialogs.offset_peer.user_id = i3;
                } else {
                    tL_messages_getDialogs.offset_peer = new TLRPC.TL_inputPeerChat();
                    tL_messages_getDialogs.offset_peer.chat_id = i4;
                }
                tL_messages_getDialogs.offset_peer.access_hash = j;
            }
            getConnectionsManager().sendRequest(tL_messages_getDialogs, new RequestDelegate(i) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$u2QEpCQfihAL5NR2qn1YyASV_A */
                private final /* synthetic */ int f$1;

                {
                    this.f$1 = r2;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$migrateDialogs$143$MessagesController(this.f$1, tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$migrateDialogs$143$MessagesController(int i, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            getMessagesStorage().getStorageQueue().postRunnable(new Runnable((TLRPC.messages_Dialogs) tLObject, i) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$jH5f2YX6PFXTJ6uZHSgoWRglBKo */
                private final /* synthetic */ TLRPC.messages_Dialogs f$1;
                private final /* synthetic */ int f$2;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                }

                public final void run() {
                    MessagesController.this.lambda$null$141$MessagesController(this.f$1, this.f$2);
                }
            });
        } else {
            AndroidUtilities.runOnUIThread(new Runnable() {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$VKlWFwNBeR5qv01AdgRUpABKqTs */

                public final void run() {
                    MessagesController.this.lambda$null$142$MessagesController();
                }
            });
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:91:0x0318  */
    /* JADX WARNING: Removed duplicated region for block: B:98:0x0357  */
    public /* synthetic */ void lambda$null$141$MessagesController(TLRPC.messages_Dialogs messages_dialogs, int i) {
        int i2;
        int i3;
        TLRPC.Message message;
        int i4 = i;
        try {
            getUserConfig().setTotalDialogsCount(0, getUserConfig().getTotalDialogsCount(0) + messages_dialogs.dialogs.size());
            TLRPC.Message message2 = null;
            for (int i5 = 0; i5 < messages_dialogs.messages.size(); i5++) {
                TLRPC.Message message3 = messages_dialogs.messages.get(i5);
                if (BuildVars.LOGS_ENABLED) {
                    FileLog.d("search migrate id " + message3.id + " date " + LocaleController.getInstance().formatterStats.format(((long) message3.date) * 1000));
                }
                if (message2 == null || message3.date < message2.date) {
                    message2 = message3;
                }
            }
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("migrate step with id " + message2.id + " date " + LocaleController.getInstance().formatterStats.format(((long) message2.date) * 1000));
            }
            int i6 = 2;
            int i7 = -1;
            if (messages_dialogs.dialogs.size() >= 100) {
                i2 = message2.id;
            } else {
                if (BuildVars.LOGS_ENABLED) {
                    FileLog.d("migrate stop due to not 100 dialogs");
                }
                for (int i8 = 0; i8 < 2; i8++) {
                    getUserConfig().setDialogsLoadOffset(i8, Integer.MAX_VALUE, getUserConfig().migrateOffsetDate, getUserConfig().migrateOffsetUserId, getUserConfig().migrateOffsetChatId, getUserConfig().migrateOffsetChannelId, getUserConfig().migrateOffsetAccess);
                }
                i2 = -1;
            }
            StringBuilder sb = new StringBuilder(messages_dialogs.dialogs.size() * 12);
            LongSparseArray longSparseArray = new LongSparseArray();
            for (int i9 = 0; i9 < messages_dialogs.dialogs.size(); i9++) {
                TLRPC.Dialog dialog = messages_dialogs.dialogs.get(i9);
                DialogObject.initDialog(dialog);
                if (sb.length() > 0) {
                    sb.append(",");
                }
                sb.append(dialog.id);
                longSparseArray.put(dialog.id, dialog);
            }
            SQLiteCursor queryFinalized = getMessagesStorage().getDatabase().queryFinalized(String.format(Locale.US, "SELECT did, folder_id FROM dialogs WHERE did IN (%s)", sb.toString()), new Object[0]);
            while (queryFinalized.next()) {
                long longValue = queryFinalized.longValue(0);
                int intValue = queryFinalized.intValue(1);
                TLRPC.Dialog dialog2 = (TLRPC.Dialog) longSparseArray.get(longValue);
                if (dialog2.folder_id == intValue) {
                    longSparseArray.remove(longValue);
                    if (dialog2 != null) {
                        messages_dialogs.dialogs.remove(dialog2);
                        int i10 = 0;
                        while (true) {
                            if (i10 >= messages_dialogs.messages.size()) {
                                break;
                            }
                            TLRPC.Message message4 = messages_dialogs.messages.get(i10);
                            if (MessageObject.getDialogId(message4) == longValue) {
                                messages_dialogs.messages.remove(i10);
                                i10--;
                                if (message4.id == dialog2.top_message) {
                                    dialog2.top_message = 0;
                                    break;
                                }
                            }
                            i10++;
                        }
                    }
                }
            }
            queryFinalized.dispose();
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("migrate found missing dialogs " + messages_dialogs.dialogs.size());
            }
            SQLiteCursor queryFinalized2 = getMessagesStorage().getDatabase().queryFinalized("SELECT min(date) FROM dialogs WHERE date != 0 AND did >> 32 IN (0, -1)", new Object[0]);
            if (queryFinalized2.next()) {
                int max = Math.max(1441062000, queryFinalized2.intValue(0));
                int i11 = 0;
                while (i11 < messages_dialogs.messages.size()) {
                    TLRPC.Message message5 = messages_dialogs.messages.get(i11);
                    if (message5.date < max) {
                        if (i4 != i7) {
                            int i12 = 0;
                            while (i12 < i6) {
                                getUserConfig().setDialogsLoadOffset(i12, getUserConfig().migrateOffsetId, getUserConfig().migrateOffsetDate, getUserConfig().migrateOffsetUserId, getUserConfig().migrateOffsetChatId, getUserConfig().migrateOffsetChannelId, getUserConfig().migrateOffsetAccess);
                                i12++;
                                message2 = message2;
                                i6 = 2;
                            }
                            message = message2;
                            if (BuildVars.LOGS_ENABLED) {
                                FileLog.d("migrate stop due to reached loaded dialogs " + LocaleController.getInstance().formatterStats.format(((long) max) * 1000));
                            }
                            i2 = -1;
                        } else {
                            message = message2;
                        }
                        messages_dialogs.messages.remove(i11);
                        i11--;
                        long dialogId = MessageObject.getDialogId(message5);
                        TLRPC.Dialog dialog3 = (TLRPC.Dialog) longSparseArray.get(dialogId);
                        longSparseArray.remove(dialogId);
                        if (dialog3 != null) {
                            messages_dialogs.dialogs.remove(dialog3);
                        }
                    } else {
                        message = message2;
                    }
                    i11++;
                    i4 = i;
                    message2 = message;
                    i6 = 2;
                    i7 = -1;
                }
                if (message2 != null) {
                    message2 = message2;
                    if (message2.date < max && i != -1) {
                        for (int i13 = 0; i13 < 2; i13++) {
                            getUserConfig().setDialogsLoadOffset(i13, getUserConfig().migrateOffsetId, getUserConfig().migrateOffsetDate, getUserConfig().migrateOffsetUserId, getUserConfig().migrateOffsetChatId, getUserConfig().migrateOffsetChannelId, getUserConfig().migrateOffsetAccess);
                        }
                        if (BuildVars.LOGS_ENABLED) {
                            FileLog.d("migrate stop due to reached loaded dialogs " + LocaleController.getInstance().formatterStats.format(((long) max) * 1000));
                        }
                        i3 = -1;
                        queryFinalized2.dispose();
                        getUserConfig().migrateOffsetDate = message2.date;
                        if (message2.to_id.channel_id == 0) {
                            getUserConfig().migrateOffsetChannelId = message2.to_id.channel_id;
                            getUserConfig().migrateOffsetChatId = 0;
                            getUserConfig().migrateOffsetUserId = 0;
                            int i14 = 0;
                            while (true) {
                                if (i14 >= messages_dialogs.chats.size()) {
                                    break;
                                }
                                TLRPC.Chat chat = messages_dialogs.chats.get(i14);
                                if (chat.id == getUserConfig().migrateOffsetChannelId) {
                                    getUserConfig().migrateOffsetAccess = chat.access_hash;
                                    break;
                                }
                                i14++;
                            }
                        } else if (message2.to_id.chat_id != 0) {
                            getUserConfig().migrateOffsetChatId = message2.to_id.chat_id;
                            getUserConfig().migrateOffsetChannelId = 0;
                            getUserConfig().migrateOffsetUserId = 0;
                            int i15 = 0;
                            while (true) {
                                if (i15 >= messages_dialogs.chats.size()) {
                                    break;
                                }
                                TLRPC.Chat chat2 = messages_dialogs.chats.get(i15);
                                if (chat2.id == getUserConfig().migrateOffsetChatId) {
                                    getUserConfig().migrateOffsetAccess = chat2.access_hash;
                                    break;
                                }
                                i15++;
                            }
                        } else if (message2.to_id.user_id != 0) {
                            getUserConfig().migrateOffsetUserId = message2.to_id.user_id;
                            getUserConfig().migrateOffsetChatId = 0;
                            getUserConfig().migrateOffsetChannelId = 0;
                            int i16 = 0;
                            while (true) {
                                if (i16 >= messages_dialogs.users.size()) {
                                    break;
                                }
                                TLRPC.User user = messages_dialogs.users.get(i16);
                                if (user.id == getUserConfig().migrateOffsetUserId) {
                                    getUserConfig().migrateOffsetAccess = user.access_hash;
                                    break;
                                }
                                i16++;
                            }
                        }
                        processLoadedDialogs(messages_dialogs, null, 0, i3, 0, 0, false, true, false);
                    }
                } else {
                    message2 = message2;
                }
            }
            i3 = i2;
            queryFinalized2.dispose();
            getUserConfig().migrateOffsetDate = message2.date;
            if (message2.to_id.channel_id == 0) {
            }
            processLoadedDialogs(messages_dialogs, null, 0, i3, 0, 0, false, true, false);
        } catch (Exception e) {
            FileLog.e(e);
            AndroidUtilities.runOnUIThread(new Runnable() {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$Yhy_JIcxSmv1jC1vgRGYVcSNhlU */

                public final void run() {
                    MessagesController.this.lambda$null$140$MessagesController();
                }
            });
        }
    }

    public /* synthetic */ void lambda$null$140$MessagesController() {
        this.migratingDialogs = false;
    }

    public /* synthetic */ void lambda$null$142$MessagesController() {
        this.migratingDialogs = false;
    }

    public void processLoadedDialogs(TLRPC.messages_Dialogs messages_dialogs, ArrayList<TLRPC.EncryptedChat> arrayList, int i, int i2, int i3, int i4, boolean z, boolean z2, boolean z3) {
        Utilities.stageQueue.postRunnable(new Runnable(i, i4, messages_dialogs, z, i3, arrayList, i2, z3, z2) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$XZYYmLj8tK5aaX32cpipRztVp1Q */
            private final /* synthetic */ int f$1;
            private final /* synthetic */ int f$2;
            private final /* synthetic */ TLRPC.messages_Dialogs f$3;
            private final /* synthetic */ boolean f$4;
            private final /* synthetic */ int f$5;
            private final /* synthetic */ ArrayList f$6;
            private final /* synthetic */ int f$7;
            private final /* synthetic */ boolean f$8;
            private final /* synthetic */ boolean f$9;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
                this.f$4 = r5;
                this.f$5 = r6;
                this.f$6 = r7;
                this.f$7 = r8;
                this.f$8 = r9;
                this.f$9 = r10;
            }

            public final void run() {
                MessagesController.this.lambda$processLoadedDialogs$146$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6, this.f$7, this.f$8, this.f$9);
            }
        });
    }

    /* JADX WARNING: Code restructure failed: missing block: B:117:0x0278, code lost:
        if (r3.get(r2) == null) goto L_0x027a;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:139:0x02c4, code lost:
        if (r5 == r1.id) goto L_0x02c8;
     */
    public /* synthetic */ void lambda$processLoadedDialogs$146$MessagesController(int i, int i2, TLRPC.messages_Dialogs messages_dialogs, boolean z, int i3, ArrayList arrayList, int i4, boolean z2, boolean z3) {
        SparseArray sparseArray;
        SparseArray sparseArray2;
        LongSparseArray longSparseArray;
        LongSparseArray longSparseArray2;
        SparseArray sparseArray3;
        int i5;
        SparseArray sparseArray4;
        SparseArray sparseArray5;
        boolean z4;
        TLRPC.Chat chat;
        MessageObject messageObject;
        long j;
        int i6;
        int i7;
        int i8;
        int i9;
        int i10;
        int i11;
        long j2;
        long j3;
        long j4;
        SparseArray sparseArray6;
        TLRPC.Chat chat2;
        if (!this.firstGettingTask) {
            getNewDeleteTask(null, 0);
            this.firstGettingTask = true;
        }
        int[] dialogLoadOffsets = getUserConfig().getDialogLoadOffsets(i);
        if (i2 == this.DIALOGS_LOAD_TYPE_CACHE && messages_dialogs.dialogs.size() == 0) {
            AndroidUtilities.runOnUIThread(new Runnable(messages_dialogs, i, z, dialogLoadOffsets, i3) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$dVxTGifxuOOxiKzAGyM0B5TWDn8 */
                private final /* synthetic */ TLRPC.messages_Dialogs f$1;
                private final /* synthetic */ int f$2;
                private final /* synthetic */ boolean f$3;
                private final /* synthetic */ int[] f$4;
                private final /* synthetic */ int f$5;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                    this.f$3 = r4;
                    this.f$4 = r5;
                    this.f$5 = r6;
                }

                public final void run() {
                    MessagesController.this.lambda$null$144$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5);
                }
            });
            return;
        }
        LongSparseArray longSparseArray3 = new LongSparseArray();
        LongSparseArray longSparseArray4 = new LongSparseArray();
        SparseArray sparseArray7 = new SparseArray();
        SparseArray sparseArray8 = new SparseArray();
        for (int i12 = 0; i12 < messages_dialogs.users.size(); i12++) {
            TLRPC.User user = messages_dialogs.users.get(i12);
            sparseArray7.put(user.id, user);
        }
        for (int i13 = 0; i13 < messages_dialogs.chats.size(); i13++) {
            TLRPC.Chat chat3 = messages_dialogs.chats.get(i13);
            sparseArray8.put(chat3.id, chat3);
        }
        if (arrayList != null) {
            SparseArray sparseArray9 = new SparseArray();
            int size = arrayList.size();
            for (int i14 = 0; i14 < size; i14++) {
                TLRPC.EncryptedChat encryptedChat = (TLRPC.EncryptedChat) arrayList.get(i14);
                sparseArray9.put(encryptedChat.id, encryptedChat);
            }
            sparseArray = sparseArray9;
        } else {
            sparseArray = null;
        }
        if (i2 == this.DIALOGS_LOAD_TYPE_CACHE) {
            this.nextDialogsCacheOffset.put(i, i4 + i3);
        }
        int i15 = 0;
        TLRPC.Message message = null;
        while (i15 < messages_dialogs.messages.size()) {
            TLRPC.Message message2 = messages_dialogs.messages.get(i15);
            if (message == null || message2.date < message.date) {
                message = message2;
            }
            if (message2.to_id.channel_id != 0) {
                TLRPC.Chat chat4 = (TLRPC.Chat) sparseArray8.get(message2.to_id.channel_id);
                if (chat4 == null || !chat4.left) {
                    sparseArray6 = sparseArray;
                } else {
                    sparseArray6 = sparseArray;
                    long j5 = this.proxyDialogId;
                    if (j5 != 0) {
                        if (j5 != ((long) (-chat4.id))) {
                        }
                    }
                    i15++;
                    sparseArray = sparseArray6;
                }
                if (chat4 != null && chat4.megagroup) {
                    message2.flags |= Integer.MIN_VALUE;
                }
            } else {
                sparseArray6 = sparseArray;
                if (!(message2.to_id.chat_id == 0 || (chat2 = (TLRPC.Chat) sparseArray8.get(message2.to_id.chat_id)) == null || chat2.migrated_to == null)) {
                    i15++;
                    sparseArray = sparseArray6;
                }
            }
            MessageObject messageObject2 = new MessageObject(this.currentAccount, message2, (SparseArray<TLRPC.User>) sparseArray7, (SparseArray<TLRPC.Chat>) sparseArray8, false);
            longSparseArray4.put(messageObject2.getDialogId(), messageObject2);
            i15++;
            sparseArray = sparseArray6;
        }
        SparseArray sparseArray10 = sparseArray;
        if (z2 || z3 || dialogLoadOffsets[0] == -1 || i2 != 0) {
            sparseArray3 = sparseArray8;
            sparseArray2 = sparseArray7;
            longSparseArray = longSparseArray3;
            longSparseArray2 = longSparseArray4;
        } else {
            int totalDialogsCount = getUserConfig().getTotalDialogsCount(i);
            if (message == null || message.id == dialogLoadOffsets[0]) {
                i8 = totalDialogsCount;
                j = 0;
                i11 = Integer.MAX_VALUE;
                i10 = 0;
                i9 = 0;
                i7 = 0;
                i6 = 0;
            } else {
                int size2 = totalDialogsCount + messages_dialogs.dialogs.size();
                int i16 = message.id;
                i10 = message.date;
                if (message.to_id.channel_id != 0) {
                    int i17 = message.to_id.channel_id;
                    int i18 = 0;
                    while (true) {
                        if (i18 >= messages_dialogs.chats.size()) {
                            j4 = 0;
                            break;
                        }
                        TLRPC.Chat chat5 = messages_dialogs.chats.get(i18);
                        if (chat5.id == i17) {
                            j4 = chat5.access_hash;
                            break;
                        }
                        i18++;
                    }
                    i6 = i17;
                    j = j4;
                    i9 = 0;
                    i7 = 0;
                } else if (message.to_id.chat_id != 0) {
                    int i19 = message.to_id.chat_id;
                    int i20 = 0;
                    while (true) {
                        if (i20 >= messages_dialogs.chats.size()) {
                            j3 = 0;
                            break;
                        }
                        TLRPC.Chat chat6 = messages_dialogs.chats.get(i20);
                        if (chat6.id == i19) {
                            j3 = chat6.access_hash;
                            break;
                        }
                        i20++;
                    }
                    j = j3;
                    i9 = 0;
                    i6 = 0;
                    i7 = i19;
                } else if (message.to_id.user_id != 0) {
                    int i21 = message.to_id.user_id;
                    int i22 = 0;
                    while (true) {
                        if (i22 >= messages_dialogs.users.size()) {
                            j2 = 0;
                            break;
                        }
                        TLRPC.User user2 = messages_dialogs.users.get(i22);
                        if (user2.id == i21) {
                            j2 = user2.access_hash;
                            break;
                        }
                        i22++;
                    }
                    i9 = i21;
                    j = j2;
                    i7 = 0;
                    i6 = 0;
                } else {
                    i8 = size2;
                    j = 0;
                    i9 = 0;
                    i7 = 0;
                    i6 = 0;
                    i11 = i16;
                }
                i8 = size2;
                i11 = i16;
            }
            sparseArray3 = sparseArray8;
            longSparseArray = longSparseArray3;
            sparseArray2 = sparseArray7;
            longSparseArray2 = longSparseArray4;
            getUserConfig().setDialogsLoadOffset(i, i11, i10, i9, i7, i6, j);
            getUserConfig().setTotalDialogsCount(i, i8);
            getUserConfig().saveConfig(false);
        }
        ArrayList arrayList2 = new ArrayList();
        int i23 = 0;
        while (i23 < messages_dialogs.dialogs.size()) {
            TLRPC.Dialog dialog = messages_dialogs.dialogs.get(i23);
            DialogObject.initDialog(dialog);
            if (dialog.id == 0) {
                sparseArray5 = sparseArray10;
            } else {
                int i24 = (int) dialog.id;
                int i25 = (int) (dialog.id >> 32);
                if (i24 != 0 || sparseArray10 == null) {
                    sparseArray5 = sparseArray10;
                    long j6 = this.proxyDialogId;
                    if (j6 != 0 && j6 == dialog.id) {
                        this.proxyDialog = dialog;
                    }
                    if (dialog.last_message_date == 0 && (messageObject = (MessageObject) longSparseArray2.get(dialog.id)) != null) {
                        dialog.last_message_date = messageObject.messageOwner.date;
                    }
                    if (DialogObject.isChannel(dialog)) {
                        TLRPC.Chat chat7 = (TLRPC.Chat) sparseArray3.get(-((int) dialog.id));
                        if (chat7 != null) {
                            z4 = chat7.megagroup;
                            if (chat7.left) {
                                long j7 = this.proxyDialogId;
                                if (j7 != 0) {
                                }
                            }
                        } else {
                            z4 = true;
                        }
                        this.channelsPts.put(-((int) dialog.id), dialog.pts);
                    } else if (((int) dialog.id) >= 0 || (chat = (TLRPC.Chat) sparseArray3.get(-((int) dialog.id))) == null || chat.migrated_to == null) {
                        z4 = true;
                    }
                    longSparseArray.put(dialog.id, dialog);
                    if (z4) {
                        if (i2 == this.DIALOGS_LOAD_TYPE_CACHE && ((dialog.read_outbox_max_id == 0 || dialog.read_inbox_max_id == 0) && dialog.top_message != 0)) {
                            arrayList2.add(dialog);
                        }
                    }
                    Integer num = this.dialogs_read_inbox_max.get(Long.valueOf(dialog.id));
                    if (num == null) {
                        num = 0;
                    }
                    this.dialogs_read_inbox_max.put(Long.valueOf(dialog.id), Integer.valueOf(Math.max(num.intValue(), dialog.read_inbox_max_id)));
                    Integer num2 = this.dialogs_read_outbox_max.get(Long.valueOf(dialog.id));
                    if (num2 == null) {
                        num2 = 0;
                    }
                    this.dialogs_read_outbox_max.put(Long.valueOf(dialog.id), Integer.valueOf(Math.max(num2.intValue(), dialog.read_outbox_max_id)));
                } else {
                    sparseArray5 = sparseArray10;
                }
            }
            i23++;
            sparseArray10 = sparseArray5;
        }
        if (i2 != this.DIALOGS_LOAD_TYPE_CACHE) {
            ImageLoader.saveMessagesThumbs(messages_dialogs.messages);
            int i26 = 0;
            while (i26 < messages_dialogs.messages.size()) {
                TLRPC.Message message3 = messages_dialogs.messages.get(i26);
                if (message3.action instanceof TLRPC.TL_messageActionChatDeleteUser) {
                    sparseArray4 = sparseArray2;
                    TLRPC.User user3 = (TLRPC.User) sparseArray4.get(message3.action.user_id);
                    if (user3 != null && user3.bot) {
                        message3.reply_markup = new TLRPC.TL_replyKeyboardHide();
                        message3.flags |= 64;
                    }
                } else {
                    sparseArray4 = sparseArray2;
                }
                if ((message3.action instanceof TLRPC.TL_messageActionChatMigrateTo) || (message3.action instanceof TLRPC.TL_messageActionChannelCreate)) {
                    message3.unread = false;
                    message3.media_unread = false;
                } else {
                    ConcurrentHashMap<Long, Integer> concurrentHashMap = message3.out ? this.dialogs_read_outbox_max : this.dialogs_read_inbox_max;
                    Integer num3 = concurrentHashMap.get(Long.valueOf(message3.dialog_id));
                    if (num3 == null) {
                        num3 = Integer.valueOf(getMessagesStorage().getDialogReadMax(message3.out, message3.dialog_id));
                        concurrentHashMap.put(Long.valueOf(message3.dialog_id), num3);
                    }
                    message3.unread = num3.intValue() < message3.id;
                }
                i26++;
                sparseArray2 = sparseArray4;
            }
            i5 = 0;
            getMessagesStorage().putDialogs(messages_dialogs, 0);
        } else {
            i5 = 0;
        }
        if (i2 == this.DIALOGS_LOAD_TYPE_CHANNEL) {
            TLRPC.Chat chat8 = messages_dialogs.chats.get(i5);
            getChannelDifference(chat8.id);
            checkChannelInviter(chat8.id);
        }
        AndroidUtilities.runOnUIThread(new Runnable(i2, messages_dialogs, arrayList, z3, i, longSparseArray, longSparseArray2, sparseArray3, i3, z2, i4, arrayList2) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$NulJWFNCe1vMsgni_28M0Nlb6HQ */
            private final /* synthetic */ int f$1;
            private final /* synthetic */ boolean f$10;
            private final /* synthetic */ int f$11;
            private final /* synthetic */ ArrayList f$12;
            private final /* synthetic */ TLRPC.messages_Dialogs f$2;
            private final /* synthetic */ ArrayList f$3;
            private final /* synthetic */ boolean f$4;
            private final /* synthetic */ int f$5;
            private final /* synthetic */ LongSparseArray f$6;
            private final /* synthetic */ LongSparseArray f$7;
            private final /* synthetic */ SparseArray f$8;
            private final /* synthetic */ int f$9;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
                this.f$4 = r5;
                this.f$5 = r6;
                this.f$6 = r7;
                this.f$7 = r8;
                this.f$8 = r9;
                this.f$9 = r10;
                this.f$10 = r11;
                this.f$11 = r12;
                this.f$12 = r13;
            }

            public final void run() {
                MessagesController.this.lambda$null$145$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6, this.f$7, this.f$8, this.f$9, this.f$10, this.f$11, this.f$12);
            }
        });
    }

    public /* synthetic */ void lambda$null$144$MessagesController(TLRPC.messages_Dialogs messages_dialogs, int i, boolean z, int[] iArr, int i2) {
        putUsers(messages_dialogs.users, true);
        this.loadingDialogs.put(i, false);
        if (z) {
            this.dialogsEndReached.put(i, false);
            this.serverDialogsEndReached.put(i, false);
        } else if (iArr[0] == Integer.MAX_VALUE) {
            this.dialogsEndReached.put(i, true);
            this.serverDialogsEndReached.put(i, true);
        } else {
            loadDialogs(i, 0, i2, false);
        }
        getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
    }

    /* JADX DEBUG: Multi-variable search result rejected for r2v8, resolved type: int */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r2v13 */
    /* JADX WARN: Type inference failed for: r2v14 */
    /* JADX WARN: Type inference failed for: r2v42 */
    /* JADX WARN: Type inference failed for: r2v43 */
    public /* synthetic */ void lambda$null$145$MessagesController(int i, TLRPC.messages_Dialogs messages_dialogs, ArrayList arrayList, boolean z, int i2, LongSparseArray longSparseArray, LongSparseArray longSparseArray2, SparseArray sparseArray, int i3, boolean z2, int i4, ArrayList arrayList2) {
        int i5;
        int i6;
        int i7;
        boolean z3;
        int i8;
        LongSparseArray longSparseArray3 = longSparseArray;
        if (i != this.DIALOGS_LOAD_TYPE_CACHE) {
            applyDialogsNotificationsSettings(messages_dialogs.dialogs);
            if (!getUserConfig().draftsLoaded) {
                getMediaDataController().loadDrafts();
            }
        }
        putUsers(messages_dialogs.users, i == this.DIALOGS_LOAD_TYPE_CACHE);
        putChats(messages_dialogs.chats, i == this.DIALOGS_LOAD_TYPE_CACHE);
        if (arrayList != null) {
            for (int i9 = 0; i9 < arrayList.size(); i9++) {
                TLRPC.EncryptedChat encryptedChat = (TLRPC.EncryptedChat) arrayList.get(i9);
                if ((encryptedChat instanceof TLRPC.TL_encryptedChat) && AndroidUtilities.getMyLayerVersion(encryptedChat.layer) < 101) {
                    getSecretChatHelper().sendNotifyLayerMessage(encryptedChat, null);
                }
                putEncryptedChat(encryptedChat, true);
            }
        }
        if (!(z || i == this.DIALOGS_LOAD_TYPE_UNKNOWN || i == this.DIALOGS_LOAD_TYPE_CHANNEL)) {
            this.loadingDialogs.put(i2, false);
        }
        this.dialogsLoaded = true;
        if (!z || this.allDialogs.isEmpty()) {
            i5 = 0;
        } else {
            ArrayList<TLRPC.Dialog> arrayList3 = this.allDialogs;
            i5 = arrayList3.get(arrayList3.size() - 1).last_message_date;
        }
        int i10 = 0;
        int i11 = 0;
        boolean z4 = false;
        while (i10 < longSparseArray.size()) {
            long keyAt = longSparseArray3.keyAt(i10);
            TLRPC.Dialog dialog = (TLRPC.Dialog) longSparseArray3.valueAt(i10);
            TLRPC.Dialog dialog2 = i != this.DIALOGS_LOAD_TYPE_UNKNOWN ? this.dialogs_dict.get(keyAt) : null;
            if (z && dialog2 != null) {
                dialog2.folder_id = dialog.folder_id;
            }
            if (!z || i5 == 0 || dialog.last_message_date >= i5) {
                if (i == this.DIALOGS_LOAD_TYPE_CACHE || !(dialog.draft instanceof TLRPC.TL_draftMessage)) {
                    i7 = i5;
                } else {
                    i7 = i5;
                    getMediaDataController().saveDraft(dialog.id, dialog.draft, null, false);
                }
                if (dialog.folder_id != i2) {
                    i11++;
                }
                if (dialog2 == null) {
                    this.dialogs_dict.put(keyAt, dialog);
                    MessageObject messageObject = (MessageObject) longSparseArray2.get(dialog.id);
                    this.dialogMessage.put(keyAt, messageObject);
                    if (messageObject != null && messageObject.messageOwner.to_id.channel_id == 0) {
                        this.dialogMessagesByIds.put(messageObject.getId(), messageObject);
                        if (messageObject.messageOwner.random_id != 0) {
                            this.dialogMessagesByRandomIds.put(messageObject.messageOwner.random_id, messageObject);
                        }
                    }
                    z4 = true;
                } else {
                    if (i != this.DIALOGS_LOAD_TYPE_CACHE) {
                        dialog2.notify_settings = dialog.notify_settings;
                    }
                    dialog2.pinned = dialog.pinned;
                    dialog2.pinnedNum = dialog.pinnedNum;
                    MessageObject messageObject2 = this.dialogMessage.get(keyAt);
                    if ((messageObject2 == null || !messageObject2.deleted) && messageObject2 != null && dialog2.top_message <= 0) {
                        i8 = i11;
                        z3 = z4;
                        MessageObject messageObject3 = (MessageObject) longSparseArray2.get(dialog.id);
                        if (messageObject2.deleted || messageObject3 == null || messageObject3.messageOwner.date > messageObject2.messageOwner.date) {
                            this.dialogs_dict.put(keyAt, dialog);
                            this.dialogMessage.put(keyAt, messageObject3);
                            if (messageObject3 != null && messageObject3.messageOwner.to_id.channel_id == 0) {
                                this.dialogMessagesByIds.put(messageObject3.getId(), messageObject3);
                                if (!(messageObject3 == null || messageObject3.messageOwner.random_id == 0)) {
                                    this.dialogMessagesByRandomIds.put(messageObject3.messageOwner.random_id, messageObject3);
                                }
                            }
                            this.dialogMessagesByIds.remove(messageObject2.getId());
                            if (messageObject2.messageOwner.random_id != 0) {
                                this.dialogMessagesByRandomIds.remove(messageObject2.messageOwner.random_id);
                            }
                        }
                    } else {
                        i8 = i11;
                        z3 = z4;
                        if (dialog.top_message >= dialog2.top_message) {
                            this.dialogs_dict.put(keyAt, dialog);
                            MessageObject messageObject4 = (MessageObject) longSparseArray2.get(dialog.id);
                            this.dialogMessage.put(keyAt, messageObject4);
                            if (messageObject4 != null && messageObject4.messageOwner.to_id.channel_id == 0) {
                                this.dialogMessagesByIds.put(messageObject4.getId(), messageObject4);
                                if (!(messageObject4 == null || messageObject4.messageOwner.random_id == 0)) {
                                    this.dialogMessagesByRandomIds.put(messageObject4.messageOwner.random_id, messageObject4);
                                }
                            }
                            if (messageObject2 != null) {
                                this.dialogMessagesByIds.remove(messageObject2.getId());
                                if (messageObject2.messageOwner.random_id != 0) {
                                    this.dialogMessagesByRandomIds.remove(messageObject2.messageOwner.random_id);
                                }
                            }
                        }
                    }
                    i11 = i8;
                    z4 = z3;
                }
            } else {
                i7 = i5;
            }
            i10++;
            longSparseArray3 = longSparseArray;
            i5 = i7;
        }
        this.allDialogs.clear();
        int size = this.dialogs_dict.size();
        for (int i12 = 0; i12 < size; i12++) {
            this.allDialogs.add(this.dialogs_dict.valueAt(i12));
        }
        sortDialogs(z ? sparseArray : null);
        if (!(i == this.DIALOGS_LOAD_TYPE_CHANNEL || i == this.DIALOGS_LOAD_TYPE_UNKNOWN || z)) {
            this.dialogsEndReached.put(i2, (messages_dialogs.dialogs.size() == 0 || messages_dialogs.dialogs.size() != i3) && i == 0);
            if (i11 > 0 && i11 < 20 && i2 == 0) {
                this.dialogsEndReached.put(1, true);
                if (getUserConfig().getDialogLoadOffsets(i2)[0] == Integer.MAX_VALUE) {
                    this.serverDialogsEndReached.put(1, true);
                }
            }
            if (!z2) {
                this.serverDialogsEndReached.put(i2, (messages_dialogs.dialogs.size() == 0 || messages_dialogs.dialogs.size() != i3) && i == 0);
            }
        }
        int totalDialogsCount = getUserConfig().getTotalDialogsCount(i2);
        int[] dialogLoadOffsets = getUserConfig().getDialogLoadOffsets(i2);
        if (z2 || z || totalDialogsCount >= 400) {
            i6 = 0;
        } else {
            i6 = 0;
            i6 = 0;
            i6 = 0;
            if (!(dialogLoadOffsets[0] == -1 || dialogLoadOffsets[0] == Integer.MAX_VALUE)) {
                loadDialogs(0, 100, i2, false);
            }
        }
        getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[i6]);
        if (z) {
            getUserConfig().migrateOffsetId = i4;
            getUserConfig().saveConfig(i6);
            this.migratingDialogs = i6;
            getNotificationCenter().postNotificationName(NotificationCenter.needReloadRecentDialogsSearch, new Object[i6]);
        } else {
            generateUpdateMessage();
            if (!z4 && i == this.DIALOGS_LOAD_TYPE_CACHE) {
                loadDialogs(i2, i6, i3, i6);
            }
        }
        migrateDialogs(getUserConfig().migrateOffsetId, getUserConfig().migrateOffsetDate, getUserConfig().migrateOffsetUserId, getUserConfig().migrateOffsetChatId, getUserConfig().migrateOffsetChannelId, getUserConfig().migrateOffsetAccess);
        if (!arrayList2.isEmpty()) {
            reloadDialogsReadValue(arrayList2, 0);
        }
        loadUnreadDialogs();
    }

    private void applyDialogNotificationsSettings(long j, TLRPC.PeerNotifySettings peerNotifySettings) {
        int i;
        if (peerNotifySettings != null) {
            SharedPreferences sharedPreferences = this.notificationsPreferences;
            int i2 = sharedPreferences.getInt("notify2_" + j, -1);
            SharedPreferences sharedPreferences2 = this.notificationsPreferences;
            int i3 = sharedPreferences2.getInt("notifyuntil_" + j, 0);
            SharedPreferences.Editor edit = this.notificationsPreferences.edit();
            TLRPC.Dialog dialog = this.dialogs_dict.get(j);
            if (dialog != null) {
                dialog.notify_settings = peerNotifySettings;
            }
            if ((peerNotifySettings.flags & 2) != 0) {
                edit.putBoolean("silent_" + j, peerNotifySettings.silent);
            } else {
                edit.remove("silent_" + j);
            }
            boolean z = true;
            if ((peerNotifySettings.flags & 4) == 0) {
                if (i2 != -1) {
                    if (dialog != null) {
                        dialog.notify_settings.mute_until = 0;
                    }
                    edit.remove("notify2_" + j);
                } else {
                    z = false;
                }
                getMessagesStorage().setDialogFlags(j, 0);
            } else if (peerNotifySettings.mute_until > getConnectionsManager().getCurrentTime()) {
                if (peerNotifySettings.mute_until <= getConnectionsManager().getCurrentTime() + 31536000) {
                    if (i2 == 3 && i3 == peerNotifySettings.mute_until) {
                        z = false;
                    } else {
                        edit.putInt("notify2_" + j, 3);
                        edit.putInt("notifyuntil_" + j, peerNotifySettings.mute_until);
                        if (dialog != null) {
                            dialog.notify_settings.mute_until = 0;
                        }
                    }
                    i = peerNotifySettings.mute_until;
                } else if (i2 != 2) {
                    edit.putInt("notify2_" + j, 2);
                    if (dialog != null) {
                        dialog.notify_settings.mute_until = Integer.MAX_VALUE;
                    }
                    i = 0;
                } else {
                    i = 0;
                    z = false;
                }
                getMessagesStorage().setDialogFlags(j, (((long) i) << 32) | 1);
                getNotificationsController().removeNotificationsForDialog(j);
            } else {
                if (i2 == 0 || i2 == 1) {
                    z = false;
                } else {
                    if (dialog != null) {
                        dialog.notify_settings.mute_until = 0;
                    }
                    edit.putInt("notify2_" + j, 0);
                }
                getMessagesStorage().setDialogFlags(j, 0);
            }
            edit.commit();
            if (z) {
                getNotificationCenter().postNotificationName(NotificationCenter.notificationsSettingsUpdated, new Object[0]);
            }
        }
    }

    private void applyDialogsNotificationsSettings(ArrayList<TLRPC.Dialog> arrayList) {
        int i;
        int i2;
        SharedPreferences.Editor editor = null;
        for (int i3 = 0; i3 < arrayList.size(); i3++) {
            TLRPC.Dialog dialog = arrayList.get(i3);
            if (dialog.peer != null && (dialog.notify_settings instanceof TLRPC.TL_peerNotifySettings)) {
                if (editor == null) {
                    editor = this.notificationsPreferences.edit();
                }
                if (dialog.peer.user_id != 0) {
                    i = dialog.peer.user_id;
                } else {
                    if (dialog.peer.chat_id != 0) {
                        i2 = dialog.peer.chat_id;
                    } else {
                        i2 = dialog.peer.channel_id;
                    }
                    i = -i2;
                }
                if ((dialog.notify_settings.flags & 2) != 0) {
                    editor.putBoolean("silent_" + i, dialog.notify_settings.silent);
                } else {
                    editor.remove("silent_" + i);
                }
                if ((dialog.notify_settings.flags & 4) == 0) {
                    editor.remove("notify2_" + i);
                } else if (dialog.notify_settings.mute_until <= getConnectionsManager().getCurrentTime()) {
                    editor.putInt("notify2_" + i, 0);
                } else if (dialog.notify_settings.mute_until > getConnectionsManager().getCurrentTime() + 31536000) {
                    editor.putInt("notify2_" + i, 2);
                    dialog.notify_settings.mute_until = Integer.MAX_VALUE;
                } else {
                    editor.putInt("notify2_" + i, 3);
                    editor.putInt("notifyuntil_" + i, dialog.notify_settings.mute_until);
                }
            }
        }
        if (editor != null) {
            editor.commit();
        }
    }

    public void reloadMentionsCountForChannels(ArrayList<Integer> arrayList) {
        AndroidUtilities.runOnUIThread(new Runnable(arrayList) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$zfLY04buQ9lNlToynHmLOX6Hsk */
            private final /* synthetic */ ArrayList f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                MessagesController.this.lambda$reloadMentionsCountForChannels$149$MessagesController(this.f$1);
            }
        });
    }

    public /* synthetic */ void lambda$reloadMentionsCountForChannels$149$MessagesController(ArrayList arrayList) {
        for (int i = 0; i < arrayList.size(); i++) {
            long j = (long) (-((Integer) arrayList.get(i)).intValue());
            TLRPC.TL_messages_getUnreadMentions tL_messages_getUnreadMentions = new TLRPC.TL_messages_getUnreadMentions();
            tL_messages_getUnreadMentions.peer = getInputPeer((int) j);
            tL_messages_getUnreadMentions.limit = 1;
            getConnectionsManager().sendRequest(tL_messages_getUnreadMentions, new RequestDelegate(j) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$R4qCZMri7w4uLYXHJo5mzpadcp8 */
                private final /* synthetic */ long f$1;

                {
                    this.f$1 = r2;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$null$148$MessagesController(this.f$1, tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$null$148$MessagesController(long j, TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable(tLObject, j) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$EkoxCrYsHJJLVDxHd4CEvrtHeg */
            private final /* synthetic */ TLObject f$1;
            private final /* synthetic */ long f$2;

            {
                this.f$1 = r2;
                this.f$2 = r3;
            }

            public final void run() {
                MessagesController.this.lambda$null$147$MessagesController(this.f$1, this.f$2);
            }
        });
    }

    public /* synthetic */ void lambda$null$147$MessagesController(TLObject tLObject, long j) {
        int i;
        TLRPC.messages_Messages messages_messages = (TLRPC.messages_Messages) tLObject;
        if (messages_messages != null) {
            if (messages_messages.count != 0) {
                i = messages_messages.count;
            } else {
                i = messages_messages.messages.size();
            }
            getMessagesStorage().resetMentionsCount(j, i);
        }
    }

    public void processDialogsUpdateRead(LongSparseArray<Integer> longSparseArray, LongSparseArray<Integer> longSparseArray2) {
        AndroidUtilities.runOnUIThread(new Runnable(longSparseArray, longSparseArray2) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$paliXT1KMG3fETOJBRct2SwyAXw */
            private final /* synthetic */ LongSparseArray f$1;
            private final /* synthetic */ LongSparseArray f$2;

            {
                this.f$1 = r2;
                this.f$2 = r3;
            }

            public final void run() {
                MessagesController.this.lambda$processDialogsUpdateRead$150$MessagesController(this.f$1, this.f$2);
            }
        });
    }

    public /* synthetic */ void lambda$processDialogsUpdateRead$150$MessagesController(LongSparseArray longSparseArray, LongSparseArray longSparseArray2) {
        if (longSparseArray != null) {
            for (int i = 0; i < longSparseArray.size(); i++) {
                long keyAt = longSparseArray.keyAt(i);
                TLRPC.Dialog dialog = this.dialogs_dict.get(keyAt);
                if (dialog != null) {
                    int i2 = dialog.unread_count;
                    dialog.unread_count = ((Integer) longSparseArray.valueAt(i)).intValue();
                    if (i2 != 0 && dialog.unread_count == 0 && !isDialogMuted(keyAt)) {
                        this.unreadUnmutedDialogs--;
                    } else if (i2 == 0 && !dialog.unread_mark && dialog.unread_count != 0) {
                        this.dialogsUnreadOnly.add(dialog);
                        if (!isDialogMuted(keyAt)) {
                            this.unreadUnmutedDialogs++;
                        }
                    }
                }
            }
        }
        if (longSparseArray2 != null) {
            for (int i3 = 0; i3 < longSparseArray2.size(); i3++) {
                TLRPC.Dialog dialog2 = this.dialogs_dict.get(longSparseArray2.keyAt(i3));
                if (dialog2 != null) {
                    dialog2.unread_mentions_count = ((Integer) longSparseArray2.valueAt(i3)).intValue();
                    if (this.createdDialogMainThreadIds.contains(Long.valueOf(dialog2.id))) {
                        getNotificationCenter().postNotificationName(NotificationCenter.updateMentionsCount, Long.valueOf(dialog2.id), Integer.valueOf(dialog2.unread_mentions_count));
                    }
                }
            }
        }
        getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 256);
        if (longSparseArray != null) {
            getNotificationsController().processDialogsUpdateRead(longSparseArray);
        }
    }

    /* access modifiers changed from: protected */
    public void checkLastDialogMessage(TLRPC.Dialog dialog, TLRPC.InputPeer inputPeer, long j) {
        NativeByteBuffer nativeByteBuffer;
        Exception e;
        int i = (int) dialog.id;
        if (i != 0 && this.checkingLastMessagesDialogs.indexOfKey(i) < 0) {
            TLRPC.TL_messages_getHistory tL_messages_getHistory = new TLRPC.TL_messages_getHistory();
            tL_messages_getHistory.peer = inputPeer == null ? getInputPeer(i) : inputPeer;
            if (tL_messages_getHistory.peer != null) {
                tL_messages_getHistory.limit = 1;
                this.checkingLastMessagesDialogs.put(i, true);
                if (j == 0) {
                    NativeByteBuffer nativeByteBuffer2 = null;
                    try {
                        nativeByteBuffer = new NativeByteBuffer(tL_messages_getHistory.peer.getObjectSize() + 60);
                        try {
                            nativeByteBuffer.writeInt32(14);
                            nativeByteBuffer.writeInt64(dialog.id);
                            nativeByteBuffer.writeInt32(dialog.top_message);
                            nativeByteBuffer.writeInt32(dialog.read_inbox_max_id);
                            nativeByteBuffer.writeInt32(dialog.read_outbox_max_id);
                            nativeByteBuffer.writeInt32(dialog.unread_count);
                            nativeByteBuffer.writeInt32(dialog.last_message_date);
                            nativeByteBuffer.writeInt32(dialog.pts);
                            nativeByteBuffer.writeInt32(dialog.flags);
                            nativeByteBuffer.writeBool(dialog.pinned);
                            nativeByteBuffer.writeInt32(dialog.pinnedNum);
                            nativeByteBuffer.writeInt32(dialog.unread_mentions_count);
                            nativeByteBuffer.writeBool(dialog.unread_mark);
                            nativeByteBuffer.writeInt32(dialog.folder_id);
                            inputPeer.serializeToStream(nativeByteBuffer);
                        } catch (Exception e2) {
                            e = e2;
                            nativeByteBuffer2 = nativeByteBuffer;
                        }
                    } catch (Exception e3) {
                        e = e3;
                        FileLog.e(e);
                        nativeByteBuffer = nativeByteBuffer2;
                        j = getMessagesStorage().createPendingTask(nativeByteBuffer);
                        getConnectionsManager().sendRequest(tL_messages_getHistory, new RequestDelegate(i, dialog, j) {
                            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$XzNTSz9WVA6Ua3FIhLTegIcqCM4 */
                            private final /* synthetic */ int f$1;
                            private final /* synthetic */ TLRPC.Dialog f$2;
                            private final /* synthetic */ long f$3;

                            {
                                this.f$1 = r2;
                                this.f$2 = r3;
                                this.f$3 = r4;
                            }

                            @Override // im.guobwnxjuc.tgnet.RequestDelegate
                            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                                MessagesController.this.lambda$checkLastDialogMessage$153$MessagesController(this.f$1, this.f$2, this.f$3, tLObject, tL_error);
                            }
                        });
                    }
                    j = getMessagesStorage().createPendingTask(nativeByteBuffer);
                }
                getConnectionsManager().sendRequest(tL_messages_getHistory, new RequestDelegate(i, dialog, j) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$XzNTSz9WVA6Ua3FIhLTegIcqCM4 */
                    private final /* synthetic */ int f$1;
                    private final /* synthetic */ TLRPC.Dialog f$2;
                    private final /* synthetic */ long f$3;

                    {
                        this.f$1 = r2;
                        this.f$2 = r3;
                        this.f$3 = r4;
                    }

                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        MessagesController.this.lambda$checkLastDialogMessage$153$MessagesController(this.f$1, this.f$2, this.f$3, tLObject, tL_error);
                    }
                });
            }
        }
    }

    public /* synthetic */ void lambda$checkLastDialogMessage$153$MessagesController(int i, TLRPC.Dialog dialog, long j, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tLObject != null) {
            TLRPC.messages_Messages messages_messages = (TLRPC.messages_Messages) tLObject;
            removeDeletedMessagesFromArray((long) i, messages_messages.messages);
            if (!messages_messages.messages.isEmpty()) {
                TLRPC.TL_messages_dialogs tL_messages_dialogs = new TLRPC.TL_messages_dialogs();
                TLRPC.Message message = messages_messages.messages.get(0);
                TLRPC.TL_dialog tL_dialog = new TLRPC.TL_dialog();
                tL_dialog.flags = dialog.flags;
                tL_dialog.top_message = message.id;
                tL_dialog.last_message_date = message.date;
                tL_dialog.notify_settings = dialog.notify_settings;
                tL_dialog.pts = dialog.pts;
                tL_dialog.unread_count = dialog.unread_count;
                tL_dialog.unread_mark = dialog.unread_mark;
                tL_dialog.unread_mentions_count = dialog.unread_mentions_count;
                tL_dialog.read_inbox_max_id = dialog.read_inbox_max_id;
                tL_dialog.read_outbox_max_id = dialog.read_outbox_max_id;
                tL_dialog.pinned = dialog.pinned;
                tL_dialog.pinnedNum = dialog.pinnedNum;
                tL_dialog.folder_id = dialog.folder_id;
                long j2 = dialog.id;
                tL_dialog.id = j2;
                message.dialog_id = j2;
                tL_messages_dialogs.users.addAll(messages_messages.users);
                tL_messages_dialogs.chats.addAll(messages_messages.chats);
                tL_messages_dialogs.dialogs.add(tL_dialog);
                tL_messages_dialogs.messages.addAll(messages_messages.messages);
                tL_messages_dialogs.count = 1;
                processDialogsUpdate(tL_messages_dialogs, null);
                getMessagesStorage().putMessages(messages_messages.messages, true, true, false, getDownloadController().getAutodownloadMask(), true);
            } else {
                AndroidUtilities.runOnUIThread(new Runnable(dialog) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$Ny0eJk4Td02VBO8oO98jb2Wd9E */
                    private final /* synthetic */ TLRPC.Dialog f$1;

                    {
                        this.f$1 = r2;
                    }

                    public final void run() {
                        MessagesController.this.lambda$null$151$MessagesController(this.f$1);
                    }
                });
            }
        }
        if (j != 0) {
            getMessagesStorage().removePendingTask(j);
        }
        AndroidUtilities.runOnUIThread(new Runnable(i) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$1Vsk1UQQoetLyrf07SjCvopGNW8 */
            private final /* synthetic */ int f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                MessagesController.this.lambda$null$152$MessagesController(this.f$1);
            }
        });
    }

    public /* synthetic */ void lambda$null$151$MessagesController(TLRPC.Dialog dialog) {
        TLRPC.Dialog dialog2 = this.dialogs_dict.get(dialog.id);
        if (dialog2 != null && dialog2.top_message == 0) {
            deleteDialog(dialog.id, 3);
        }
    }

    public /* synthetic */ void lambda$null$152$MessagesController(int i) {
        this.checkingLastMessagesDialogs.delete(i);
    }

    public void processDialogsUpdate(TLRPC.messages_Dialogs messages_dialogs, ArrayList<TLRPC.EncryptedChat> arrayList) {
        Utilities.stageQueue.postRunnable(new Runnable(messages_dialogs) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$DGAQaqaDtkKg0fil78LYZorhMM */
            private final /* synthetic */ TLRPC.messages_Dialogs f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                MessagesController.this.lambda$processDialogsUpdate$155$MessagesController(this.f$1);
            }
        });
    }

    public /* synthetic */ void lambda$processDialogsUpdate$155$MessagesController(TLRPC.messages_Dialogs messages_dialogs) {
        long j;
        MessageObject messageObject;
        TLRPC.Chat chat;
        TLRPC.Chat chat2;
        LongSparseArray longSparseArray = new LongSparseArray();
        LongSparseArray longSparseArray2 = new LongSparseArray();
        SparseArray sparseArray = new SparseArray(messages_dialogs.users.size());
        SparseArray sparseArray2 = new SparseArray(messages_dialogs.chats.size());
        LongSparseArray longSparseArray3 = new LongSparseArray();
        int i = 0;
        for (int i2 = 0; i2 < messages_dialogs.users.size(); i2++) {
            TLRPC.User user = messages_dialogs.users.get(i2);
            sparseArray.put(user.id, user);
        }
        for (int i3 = 0; i3 < messages_dialogs.chats.size(); i3++) {
            TLRPC.Chat chat3 = messages_dialogs.chats.get(i3);
            sparseArray2.put(chat3.id, chat3);
        }
        int i4 = 0;
        while (true) {
            j = 0;
            if (i4 >= messages_dialogs.messages.size()) {
                break;
            }
            TLRPC.Message message = messages_dialogs.messages.get(i4);
            long j2 = this.proxyDialogId;
            if (j2 == 0 || j2 != message.dialog_id) {
                if (message.to_id.channel_id != 0) {
                    TLRPC.Chat chat4 = (TLRPC.Chat) sparseArray2.get(message.to_id.channel_id);
                    if (chat4 != null && chat4.left) {
                        i4++;
                    }
                } else if (!(message.to_id.chat_id == 0 || (chat2 = (TLRPC.Chat) sparseArray2.get(message.to_id.chat_id)) == null || chat2.migrated_to == null)) {
                    i4++;
                }
            }
            MessageObject messageObject2 = new MessageObject(this.currentAccount, message, (SparseArray<TLRPC.User>) sparseArray, (SparseArray<TLRPC.Chat>) sparseArray2, false);
            longSparseArray2.put(messageObject2.getDialogId(), messageObject2);
            i4++;
        }
        while (i < messages_dialogs.dialogs.size()) {
            TLRPC.Dialog dialog = messages_dialogs.dialogs.get(i);
            DialogObject.initDialog(dialog);
            long j3 = this.proxyDialogId;
            if (j3 == j || j3 != dialog.id) {
                if (DialogObject.isChannel(dialog)) {
                    TLRPC.Chat chat5 = (TLRPC.Chat) sparseArray2.get(-((int) dialog.id));
                    if (chat5 != null && chat5.left) {
                        i++;
                        j = 0;
                    }
                } else if (!(((int) dialog.id) >= 0 || (chat = (TLRPC.Chat) sparseArray2.get(-((int) dialog.id))) == null || chat.migrated_to == null)) {
                    i++;
                    j = 0;
                }
            }
            if (dialog.last_message_date == 0 && (messageObject = (MessageObject) longSparseArray2.get(dialog.id)) != null) {
                dialog.last_message_date = messageObject.messageOwner.date;
            }
            longSparseArray.put(dialog.id, dialog);
            longSparseArray3.put(dialog.id, Integer.valueOf(dialog.unread_count));
            Integer num = this.dialogs_read_inbox_max.get(Long.valueOf(dialog.id));
            if (num == null) {
                num = 0;
            }
            this.dialogs_read_inbox_max.put(Long.valueOf(dialog.id), Integer.valueOf(Math.max(num.intValue(), dialog.read_inbox_max_id)));
            Integer num2 = this.dialogs_read_outbox_max.get(Long.valueOf(dialog.id));
            if (num2 == null) {
                num2 = 0;
            }
            this.dialogs_read_outbox_max.put(Long.valueOf(dialog.id), Integer.valueOf(Math.max(num2.intValue(), dialog.read_outbox_max_id)));
            i++;
            j = 0;
        }
        AndroidUtilities.runOnUIThread(new Runnable(messages_dialogs, longSparseArray, longSparseArray2, longSparseArray3) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$72uaxroy9zJRirUcW7pSUxIiY9I */
            private final /* synthetic */ TLRPC.messages_Dialogs f$1;
            private final /* synthetic */ LongSparseArray f$2;
            private final /* synthetic */ LongSparseArray f$3;
            private final /* synthetic */ LongSparseArray f$4;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
                this.f$4 = r5;
            }

            public final void run() {
                MessagesController.this.lambda$null$154$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4);
            }
        });
    }

    public /* synthetic */ void lambda$null$154$MessagesController(TLRPC.messages_Dialogs messages_dialogs, LongSparseArray longSparseArray, LongSparseArray longSparseArray2, LongSparseArray longSparseArray3) {
        long j;
        putUsers(messages_dialogs.users, true);
        putChats(messages_dialogs.chats, true);
        for (int i = 0; i < longSparseArray.size(); i++) {
            long keyAt = longSparseArray.keyAt(i);
            TLRPC.Dialog dialog = (TLRPC.Dialog) longSparseArray.valueAt(i);
            TLRPC.Dialog dialog2 = this.dialogs_dict.get(keyAt);
            if (dialog2 == null) {
                this.nextDialogsCacheOffset.put(dialog.folder_id, this.nextDialogsCacheOffset.get(dialog.folder_id, 0) + 1);
                this.dialogs_dict.put(keyAt, dialog);
                MessageObject messageObject = (MessageObject) longSparseArray2.get(dialog.id);
                this.dialogMessage.put(keyAt, messageObject);
                if (messageObject != null && messageObject.messageOwner.to_id.channel_id == 0) {
                    this.dialogMessagesByIds.put(messageObject.getId(), messageObject);
                    if (messageObject.messageOwner.random_id != 0) {
                        this.dialogMessagesByRandomIds.put(messageObject.messageOwner.random_id, messageObject);
                    }
                }
            } else {
                dialog2.unread_count = dialog.unread_count;
                if (dialog2.unread_mentions_count != dialog.unread_mentions_count) {
                    dialog2.unread_mentions_count = dialog.unread_mentions_count;
                    if (this.createdDialogMainThreadIds.contains(Long.valueOf(dialog2.id))) {
                        getNotificationCenter().postNotificationName(NotificationCenter.updateMentionsCount, Long.valueOf(dialog2.id), Integer.valueOf(dialog2.unread_mentions_count));
                    }
                }
                MessageObject messageObject2 = this.dialogMessage.get(keyAt);
                if (messageObject2 != null && dialog2.top_message <= 0) {
                    MessageObject messageObject3 = (MessageObject) longSparseArray2.get(dialog.id);
                    if (messageObject2.deleted || messageObject3 == null || messageObject3.messageOwner.date > messageObject2.messageOwner.date) {
                        this.dialogs_dict.put(keyAt, dialog);
                        this.dialogMessage.put(keyAt, messageObject3);
                        if (messageObject3 != null && messageObject3.messageOwner.to_id.channel_id == 0) {
                            this.dialogMessagesByIds.put(messageObject3.getId(), messageObject3);
                            if (messageObject3.messageOwner.random_id != 0) {
                                this.dialogMessagesByRandomIds.put(messageObject3.messageOwner.random_id, messageObject3);
                            }
                        }
                        this.dialogMessagesByIds.remove(messageObject2.getId());
                        if (messageObject2.messageOwner.random_id != 0) {
                            this.dialogMessagesByRandomIds.remove(messageObject2.messageOwner.random_id);
                        }
                    }
                } else if ((messageObject2 != null && messageObject2.deleted) || dialog.top_message > dialog2.top_message) {
                    this.dialogs_dict.put(keyAt, dialog);
                    MessageObject messageObject4 = (MessageObject) longSparseArray2.get(dialog.id);
                    this.dialogMessage.put(keyAt, messageObject4);
                    if (messageObject4 != null && messageObject4.messageOwner.to_id.channel_id == 0) {
                        this.dialogMessagesByIds.put(messageObject4.getId(), messageObject4);
                        if (messageObject4.messageOwner.random_id != 0) {
                            this.dialogMessagesByRandomIds.put(messageObject4.messageOwner.random_id, messageObject4);
                        }
                    }
                    if (messageObject2 != null) {
                        this.dialogMessagesByIds.remove(messageObject2.getId());
                        j = 0;
                        if (messageObject2.messageOwner.random_id != 0) {
                            this.dialogMessagesByRandomIds.remove(messageObject2.messageOwner.random_id);
                        }
                    } else {
                        j = 0;
                    }
                    if (messageObject4 == null) {
                        checkLastDialogMessage(dialog, null, j);
                    }
                }
            }
        }
        this.allDialogs.clear();
        int size = this.dialogs_dict.size();
        for (int i2 = 0; i2 < size; i2++) {
            this.allDialogs.add(this.dialogs_dict.valueAt(i2));
        }
        sortDialogs(null);
        getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
        getNotificationsController().processDialogsUpdateRead(longSparseArray3);
    }

    public void addToViewsQueue(MessageObject messageObject) {
        Utilities.stageQueue.postRunnable(new Runnable(messageObject) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$OrwXqAMTNsHL_iF23MCZPFgZAA */
            private final /* synthetic */ MessageObject f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                MessagesController.this.lambda$addToViewsQueue$156$MessagesController(this.f$1);
            }
        });
    }

    public /* synthetic */ void lambda$addToViewsQueue$156$MessagesController(MessageObject messageObject) {
        int dialogId = (int) messageObject.getDialogId();
        int id = messageObject.getId();
        ArrayList<Integer> arrayList = this.channelViewsToSend.get(dialogId);
        if (arrayList == null) {
            arrayList = new ArrayList<>();
            this.channelViewsToSend.put(dialogId, arrayList);
        }
        if (!arrayList.contains(Integer.valueOf(id))) {
            arrayList.add(Integer.valueOf(id));
        }
    }

    public void addToPollsQueue(long j, ArrayList<MessageObject> arrayList) {
        SparseArray<MessageObject> sparseArray = this.pollsToCheck.get(j);
        if (sparseArray == null) {
            sparseArray = new SparseArray<>();
            this.pollsToCheck.put(j, sparseArray);
            this.pollsToCheckSize++;
        }
        int size = sparseArray.size();
        for (int i = 0; i < size; i++) {
            sparseArray.valueAt(i).pollVisibleOnScreen = false;
        }
        int size2 = arrayList.size();
        for (int i2 = 0; i2 < size2; i2++) {
            MessageObject messageObject = arrayList.get(i2);
            if (messageObject.type == 17) {
                int id = messageObject.getId();
                MessageObject messageObject2 = sparseArray.get(id);
                if (messageObject2 != null) {
                    messageObject2.pollVisibleOnScreen = true;
                } else {
                    sparseArray.put(id, messageObject);
                }
            }
        }
    }

    public void markMessageContentAsRead(MessageObject messageObject) {
        if (!messageObject.scheduled) {
            ArrayList<Long> arrayList = new ArrayList<>();
            long id = (long) messageObject.getId();
            if (messageObject.messageOwner.to_id.channel_id != 0) {
                id |= ((long) messageObject.messageOwner.to_id.channel_id) << 32;
            }
            if (messageObject.messageOwner.mentioned) {
                getMessagesStorage().markMentionMessageAsRead(messageObject.getId(), messageObject.messageOwner.to_id.channel_id, messageObject.getDialogId());
            }
            arrayList.add(Long.valueOf(id));
            getMessagesStorage().markMessagesContentAsRead(arrayList, 0);
            getNotificationCenter().postNotificationName(NotificationCenter.messagesReadContent, arrayList);
            if (messageObject.getId() < 0) {
                markMessageAsRead(messageObject.getDialogId(), messageObject.messageOwner.random_id, Integer.MIN_VALUE);
            } else if (messageObject.messageOwner.to_id.channel_id != 0) {
                TLRPC.TL_channels_readMessageContents tL_channels_readMessageContents = new TLRPC.TL_channels_readMessageContents();
                tL_channels_readMessageContents.channel = getInputChannel(messageObject.messageOwner.to_id.channel_id);
                if (tL_channels_readMessageContents.channel != null) {
                    tL_channels_readMessageContents.id.add(Integer.valueOf(messageObject.getId()));
                    getConnectionsManager().sendRequest(tL_channels_readMessageContents, $$Lambda$MessagesController$x5cRkHkJj8sIaWLPXtvnEsoZY7E.INSTANCE);
                }
            } else {
                TLRPC.TL_messages_readMessageContents tL_messages_readMessageContents = new TLRPC.TL_messages_readMessageContents();
                tL_messages_readMessageContents.id.add(Integer.valueOf(messageObject.getId()));
                getConnectionsManager().sendRequest(tL_messages_readMessageContents, new RequestDelegate() {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$b8Pp8YrtenPCUYsoAFSV9v7J8 */

                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        MessagesController.this.lambda$markMessageContentAsRead$158$MessagesController(tLObject, tL_error);
                    }
                });
            }
        }
    }

    public /* synthetic */ void lambda$markMessageContentAsRead$158$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            TLRPC.TL_messages_affectedMessages tL_messages_affectedMessages = (TLRPC.TL_messages_affectedMessages) tLObject;
            processNewDifferenceParams(-1, tL_messages_affectedMessages.pts, -1, tL_messages_affectedMessages.pts_count);
        }
    }

    public void markMentionMessageAsRead(int i, int i2, long j) {
        getMessagesStorage().markMentionMessageAsRead(i, i2, j);
        if (i2 != 0) {
            TLRPC.TL_channels_readMessageContents tL_channels_readMessageContents = new TLRPC.TL_channels_readMessageContents();
            tL_channels_readMessageContents.channel = getInputChannel(i2);
            if (tL_channels_readMessageContents.channel != null) {
                tL_channels_readMessageContents.id.add(Integer.valueOf(i));
                getConnectionsManager().sendRequest(tL_channels_readMessageContents, $$Lambda$MessagesController$vyF3Vx9CTwPZyc2KDYhgS9Crdhc.INSTANCE);
                return;
            }
            return;
        }
        TLRPC.TL_messages_readMessageContents tL_messages_readMessageContents = new TLRPC.TL_messages_readMessageContents();
        tL_messages_readMessageContents.id.add(Integer.valueOf(i));
        getConnectionsManager().sendRequest(tL_messages_readMessageContents, new RequestDelegate() {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$BQB_H1lYsUoq9ZaVZNBE53SmW8 */

            @Override // im.guobwnxjuc.tgnet.RequestDelegate
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                MessagesController.this.lambda$markMentionMessageAsRead$160$MessagesController(tLObject, tL_error);
            }
        });
    }

    public /* synthetic */ void lambda$markMentionMessageAsRead$160$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            TLRPC.TL_messages_affectedMessages tL_messages_affectedMessages = (TLRPC.TL_messages_affectedMessages) tLObject;
            processNewDifferenceParams(-1, tL_messages_affectedMessages.pts, -1, tL_messages_affectedMessages.pts_count);
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:28:0x0064  */
    /* JADX WARNING: Removed duplicated region for block: B:29:0x0081  */
    public void markMessageAsRead(int i, int i2, TLRPC.InputChannel inputChannel, int i3, long j) {
        NativeByteBuffer nativeByteBuffer;
        Exception e;
        if (i != 0 && i3 > 0) {
            if (i2 == 0 || inputChannel != null || (inputChannel = getInputChannel(i2)) != null) {
                if (j == 0) {
                    NativeByteBuffer nativeByteBuffer2 = null;
                    try {
                        nativeByteBuffer = new NativeByteBuffer(16 + (inputChannel != null ? inputChannel.getObjectSize() : 0));
                        try {
                            nativeByteBuffer.writeInt32(11);
                            nativeByteBuffer.writeInt32(i);
                            nativeByteBuffer.writeInt32(i2);
                            nativeByteBuffer.writeInt32(i3);
                            if (i2 != 0) {
                                inputChannel.serializeToStream(nativeByteBuffer);
                            }
                        } catch (Exception e2) {
                            e = e2;
                            nativeByteBuffer2 = nativeByteBuffer;
                            FileLog.e(e);
                            nativeByteBuffer = nativeByteBuffer2;
                            j = getMessagesStorage().createPendingTask(nativeByteBuffer);
                            int currentTime = getConnectionsManager().getCurrentTime();
                            getMessagesStorage().createTaskForMid(i, i2, currentTime, currentTime, i3, false);
                            if (i2 != 0) {
                            }
                        }
                    } catch (Exception e3) {
                        e = e3;
                        FileLog.e(e);
                        nativeByteBuffer = nativeByteBuffer2;
                        j = getMessagesStorage().createPendingTask(nativeByteBuffer);
                        int currentTime2 = getConnectionsManager().getCurrentTime();
                        getMessagesStorage().createTaskForMid(i, i2, currentTime2, currentTime2, i3, false);
                        if (i2 != 0) {
                        }
                    }
                    j = getMessagesStorage().createPendingTask(nativeByteBuffer);
                }
                int currentTime22 = getConnectionsManager().getCurrentTime();
                getMessagesStorage().createTaskForMid(i, i2, currentTime22, currentTime22, i3, false);
                if (i2 != 0) {
                    TLRPC.TL_channels_readMessageContents tL_channels_readMessageContents = new TLRPC.TL_channels_readMessageContents();
                    tL_channels_readMessageContents.channel = inputChannel;
                    tL_channels_readMessageContents.id.add(Integer.valueOf(i));
                    getConnectionsManager().sendRequest(tL_channels_readMessageContents, new RequestDelegate(j) {
                        /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$CQabKqzzhF6NA3R6h8xlgbvR10 */
                        private final /* synthetic */ long f$1;

                        {
                            this.f$1 = r2;
                        }

                        @Override // im.guobwnxjuc.tgnet.RequestDelegate
                        public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                            MessagesController.this.lambda$markMessageAsRead$161$MessagesController(this.f$1, tLObject, tL_error);
                        }
                    });
                    return;
                }
                TLRPC.TL_messages_readMessageContents tL_messages_readMessageContents = new TLRPC.TL_messages_readMessageContents();
                tL_messages_readMessageContents.id.add(Integer.valueOf(i));
                getConnectionsManager().sendRequest(tL_messages_readMessageContents, new RequestDelegate(j) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$cXNNq3pdu7fehIDxl5Fj1xiEWic */
                    private final /* synthetic */ long f$1;

                    {
                        this.f$1 = r2;
                    }

                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        MessagesController.this.lambda$markMessageAsRead$162$MessagesController(this.f$1, tLObject, tL_error);
                    }
                });
            }
        }
    }

    public /* synthetic */ void lambda$markMessageAsRead$161$MessagesController(long j, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (j != 0) {
            getMessagesStorage().removePendingTask(j);
        }
    }

    public /* synthetic */ void lambda$markMessageAsRead$162$MessagesController(long j, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            TLRPC.TL_messages_affectedMessages tL_messages_affectedMessages = (TLRPC.TL_messages_affectedMessages) tLObject;
            processNewDifferenceParams(-1, tL_messages_affectedMessages.pts, -1, tL_messages_affectedMessages.pts_count);
        }
        if (j != 0) {
            getMessagesStorage().removePendingTask(j);
        }
    }

    public void markMessageAsRead(long j, long j2, int i) {
        TLRPC.EncryptedChat encryptedChat;
        if (j2 != 0 && j != 0) {
            if (i > 0 || i == Integer.MIN_VALUE) {
                int i2 = (int) (j >> 32);
                if (((int) j) == 0 && (encryptedChat = getEncryptedChat(Integer.valueOf(i2))) != null) {
                    ArrayList<Long> arrayList = new ArrayList<>();
                    arrayList.add(Long.valueOf(j2));
                    getSecretChatHelper().sendMessagesReadMessage(encryptedChat, arrayList, null);
                    if (i > 0) {
                        int currentTime = getConnectionsManager().getCurrentTime();
                        getMessagesStorage().createTaskForSecretChat(encryptedChat.id, currentTime, currentTime, 0, arrayList);
                    }
                }
            }
        }
    }

    /* JADX DEBUG: Multi-variable search result rejected for r0v9, resolved type: im.guobwnxjuc.tgnet.TLRPC$TL_channels_readHistory */
    /* JADX WARN: Multi-variable type inference failed */
    private void completeReadTask(ReadTask readTask) {
        TLRPC.TL_messages_readHistory tL_messages_readHistory;
        int i = (int) readTask.dialogId;
        int i2 = (int) (readTask.dialogId >> 32);
        if (i != 0) {
            TLRPC.InputPeer inputPeer = getInputPeer(i);
            if (inputPeer instanceof TLRPC.TL_inputPeerChannel) {
                TLRPC.TL_channels_readHistory tL_channels_readHistory = new TLRPC.TL_channels_readHistory();
                tL_channels_readHistory.channel = getInputChannel(-i);
                tL_channels_readHistory.max_id = readTask.maxId;
                tL_messages_readHistory = tL_channels_readHistory;
            } else {
                TLRPC.TL_messages_readHistory tL_messages_readHistory2 = new TLRPC.TL_messages_readHistory();
                tL_messages_readHistory2.peer = inputPeer;
                tL_messages_readHistory2.max_id = readTask.maxId;
                tL_messages_readHistory = tL_messages_readHistory2;
            }
            getConnectionsManager().sendRequest(tL_messages_readHistory, new RequestDelegate() {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$JGD639WgdWQomwNmXR012Y0Rubg */

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$completeReadTask$163$MessagesController(tLObject, tL_error);
                }
            });
            return;
        }
        TLRPC.EncryptedChat encryptedChat = getEncryptedChat(Integer.valueOf(i2));
        if (encryptedChat.auth_key != null && encryptedChat.auth_key.length > 1 && (encryptedChat instanceof TLRPC.TL_encryptedChat)) {
            TLRPC.TL_messages_readEncryptedHistory tL_messages_readEncryptedHistory = new TLRPC.TL_messages_readEncryptedHistory();
            tL_messages_readEncryptedHistory.peer = new TLRPC.TL_inputEncryptedChat();
            tL_messages_readEncryptedHistory.peer.chat_id = encryptedChat.id;
            tL_messages_readEncryptedHistory.peer.access_hash = encryptedChat.access_hash;
            tL_messages_readEncryptedHistory.max_date = readTask.maxDate;
            getConnectionsManager().sendRequest(tL_messages_readEncryptedHistory, $$Lambda$MessagesController$ZT5RiFuv8d66EkCIiPjINROWvY.INSTANCE);
        }
    }

    public /* synthetic */ void lambda$completeReadTask$163$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null && (tLObject instanceof TLRPC.TL_messages_affectedMessages)) {
            TLRPC.TL_messages_affectedMessages tL_messages_affectedMessages = (TLRPC.TL_messages_affectedMessages) tLObject;
            processNewDifferenceParams(-1, tL_messages_affectedMessages.pts, -1, tL_messages_affectedMessages.pts_count);
        }
    }

    private void checkReadTasks() {
        long elapsedRealtime = SystemClock.elapsedRealtime();
        int size = this.readTasks.size();
        int i = 0;
        while (i < size) {
            ReadTask readTask = this.readTasks.get(i);
            if (readTask.sendRequestTime <= elapsedRealtime) {
                completeReadTask(readTask);
                this.readTasks.remove(i);
                this.readTasksMap.remove(readTask.dialogId);
                i--;
                size--;
            }
            i++;
        }
    }

    public void markDialogAsReadNow(long j) {
        Utilities.stageQueue.postRunnable(new Runnable(j) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$lqcL5uUWDpo59l2799P4R7HwZ4Y */
            private final /* synthetic */ long f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                MessagesController.this.lambda$markDialogAsReadNow$165$MessagesController(this.f$1);
            }
        });
    }

    public /* synthetic */ void lambda$markDialogAsReadNow$165$MessagesController(long j) {
        ReadTask readTask = this.readTasksMap.get(j);
        if (readTask != null) {
            completeReadTask(readTask);
            this.readTasks.remove(readTask);
            this.readTasksMap.remove(j);
        }
    }

    public void markMentionsAsRead(long j) {
        int i = (int) j;
        if (i != 0) {
            getMessagesStorage().resetMentionsCount(j, 0);
            TLRPC.TL_messages_readMentions tL_messages_readMentions = new TLRPC.TL_messages_readMentions();
            tL_messages_readMentions.peer = getInputPeer(i);
            getConnectionsManager().sendRequest(tL_messages_readMentions, $$Lambda$MessagesController$10lJncHsrz_108d3NADowjnBzm8.INSTANCE);
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:12:0x004b  */
    /* JADX WARNING: Removed duplicated region for block: B:15:0x0092  */
    public void markDialogAsRead(long j, int i, int i2, int i3, boolean z, int i4, boolean z2, int i5) {
        boolean z3;
        long j2;
        long j3;
        Integer num;
        int i6 = (int) j;
        int i7 = (int) (j >> 32);
        boolean z4 = getNotificationsController().showBadgeMessages;
        boolean z5 = true;
        if (i6 != 0) {
            if (i != 0) {
                long j4 = (long) i;
                long j5 = (long) i2;
                if (i6 < 0) {
                    int i8 = -i6;
                    if (ChatObject.isChannel(getChat(Integer.valueOf(i8)))) {
                        long j6 = ((long) i8) << 32;
                        j2 = j6 | j5;
                        j3 = j4 | j6;
                        z3 = true;
                        num = this.dialogs_read_inbox_max.get(Long.valueOf(j));
                        if (num == null) {
                            num = 0;
                        }
                        this.dialogs_read_inbox_max.put(Long.valueOf(j), Integer.valueOf(Math.max(num.intValue(), i)));
                        getMessagesStorage().processPendingRead(j, j3, j2, z3, i5);
                        getMessagesStorage().getStorageQueue().postRunnable(new Runnable(j, i4, i, z4, z) {
                            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$BNH8rIXBmexQk9RKlve_P7K1qXE */
                            private final /* synthetic */ long f$1;
                            private final /* synthetic */ int f$2;
                            private final /* synthetic */ int f$3;
                            private final /* synthetic */ boolean f$4;
                            private final /* synthetic */ boolean f$5;

                            {
                                this.f$1 = r2;
                                this.f$2 = r4;
                                this.f$3 = r5;
                                this.f$4 = r6;
                                this.f$5 = r7;
                            }

                            public final void run() {
                                MessagesController.this.lambda$markDialogAsRead$168$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5);
                            }
                        });
                        if (i == Integer.MAX_VALUE) {
                            z5 = false;
                        }
                    }
                }
                j2 = j5;
                z3 = false;
                j3 = j4;
                num = this.dialogs_read_inbox_max.get(Long.valueOf(j));
                if (num == null) {
                }
                this.dialogs_read_inbox_max.put(Long.valueOf(j), Integer.valueOf(Math.max(num.intValue(), i)));
                getMessagesStorage().processPendingRead(j, j3, j2, z3, i5);
                getMessagesStorage().getStorageQueue().postRunnable(new Runnable(j, i4, i, z4, z) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$BNH8rIXBmexQk9RKlve_P7K1qXE */
                    private final /* synthetic */ long f$1;
                    private final /* synthetic */ int f$2;
                    private final /* synthetic */ int f$3;
                    private final /* synthetic */ boolean f$4;
                    private final /* synthetic */ boolean f$5;

                    {
                        this.f$1 = r2;
                        this.f$2 = r4;
                        this.f$3 = r5;
                        this.f$4 = r6;
                        this.f$5 = r7;
                    }

                    public final void run() {
                        MessagesController.this.lambda$markDialogAsRead$168$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5);
                    }
                });
                if (i == Integer.MAX_VALUE) {
                }
            } else {
                return;
            }
        } else if (i3 != 0) {
            TLRPC.EncryptedChat encryptedChat = getEncryptedChat(Integer.valueOf(i7));
            getMessagesStorage().processPendingRead(j, (long) i, (long) i2, false, i5);
            getMessagesStorage().getStorageQueue().postRunnable(new Runnable(j, i3, z, i4, i2, z4) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$nwnSzo_KC9JYFH5Tf0iWGfxGEo */
                private final /* synthetic */ long f$1;
                private final /* synthetic */ int f$2;
                private final /* synthetic */ boolean f$3;
                private final /* synthetic */ int f$4;
                private final /* synthetic */ int f$5;
                private final /* synthetic */ boolean f$6;

                {
                    this.f$1 = r2;
                    this.f$2 = r4;
                    this.f$3 = r5;
                    this.f$4 = r6;
                    this.f$5 = r7;
                    this.f$6 = r8;
                }

                public final void run() {
                    MessagesController.this.lambda$markDialogAsRead$170$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6);
                }
            });
            if (encryptedChat != null && encryptedChat.ttl > 0) {
                int max = Math.max(getConnectionsManager().getCurrentTime(), i3);
                getMessagesStorage().createTaskForSecretChat(encryptedChat.id, max, max, 0, null);
            }
        } else {
            return;
        }
        if (z5) {
            Utilities.stageQueue.postRunnable(new Runnable(j, z2, i3, i) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$V_M_zlj8VKkrTzBzoMsOvatqj4U */
                private final /* synthetic */ long f$1;
                private final /* synthetic */ boolean f$2;
                private final /* synthetic */ int f$3;
                private final /* synthetic */ int f$4;

                {
                    this.f$1 = r2;
                    this.f$2 = r4;
                    this.f$3 = r5;
                    this.f$4 = r6;
                }

                public final void run() {
                    MessagesController.this.lambda$markDialogAsRead$171$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4);
                }
            });
        }
    }

    public /* synthetic */ void lambda$markDialogAsRead$168$MessagesController(long j, int i, int i2, boolean z, boolean z2) {
        AndroidUtilities.runOnUIThread(new Runnable(j, i, i2, z, z2) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$Pk4Rfcdi18jWu_WvILx3QewFnMY */
            private final /* synthetic */ long f$1;
            private final /* synthetic */ int f$2;
            private final /* synthetic */ int f$3;
            private final /* synthetic */ boolean f$4;
            private final /* synthetic */ boolean f$5;

            {
                this.f$1 = r2;
                this.f$2 = r4;
                this.f$3 = r5;
                this.f$4 = r6;
                this.f$5 = r7;
            }

            public final void run() {
                MessagesController.this.lambda$null$167$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5);
            }
        });
    }

    public /* synthetic */ void lambda$null$167$MessagesController(long j, int i, int i2, boolean z, boolean z2) {
        TLRPC.Dialog dialog;
        TLRPC.Dialog dialog2 = this.dialogs_dict.get(j);
        if (dialog2 != null) {
            int i3 = dialog2.unread_count;
            if (i == 0 || i2 >= dialog2.top_message) {
                dialog2.unread_count = 0;
            } else {
                dialog2.unread_count = Math.max(dialog2.unread_count - i, 0);
                if (i2 != Integer.MIN_VALUE && dialog2.unread_count > dialog2.top_message - i2) {
                    dialog2.unread_count = dialog2.top_message - i2;
                }
            }
            if (!(dialog2.folder_id == 0 || (dialog = this.dialogs_dict.get(DialogObject.makeFolderDialogId(dialog2.folder_id))) == null)) {
                if (z) {
                    if (isDialogMuted(dialog2.id)) {
                        dialog.unread_count -= i3 - dialog2.unread_count;
                    } else {
                        dialog.unread_mentions_count -= i3 - dialog2.unread_count;
                    }
                } else if (dialog2.unread_count == 0) {
                    if (isDialogMuted(dialog2.id)) {
                        dialog.unread_count--;
                    } else {
                        dialog.unread_mentions_count--;
                    }
                }
            }
            if ((i3 != 0 || dialog2.unread_mark) && dialog2.unread_count == 0 && !isDialogMuted(j)) {
                this.unreadUnmutedDialogs--;
            }
            if (dialog2.unread_mark) {
                dialog2.unread_mark = false;
                getMessagesStorage().setDialogUnread(dialog2.id, false);
            }
            getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 256);
        }
        if (!z2) {
            getNotificationsController().processReadMessages(null, j, 0, i2, false);
            LongSparseArray<Integer> longSparseArray = new LongSparseArray<>(1);
            longSparseArray.put(j, 0);
            getNotificationsController().processDialogsUpdateRead(longSparseArray);
            return;
        }
        getNotificationsController().processReadMessages(null, j, 0, i2, true);
        LongSparseArray<Integer> longSparseArray2 = new LongSparseArray<>(1);
        longSparseArray2.put(j, -1);
        getNotificationsController().processDialogsUpdateRead(longSparseArray2);
    }

    public /* synthetic */ void lambda$markDialogAsRead$170$MessagesController(long j, int i, boolean z, int i2, int i3, boolean z2) {
        AndroidUtilities.runOnUIThread(new Runnable(j, i, z, i2, i3, z2) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$9huoHWC5JxdrZNgQvc9cNbvvLLo */
            private final /* synthetic */ long f$1;
            private final /* synthetic */ int f$2;
            private final /* synthetic */ boolean f$3;
            private final /* synthetic */ int f$4;
            private final /* synthetic */ int f$5;
            private final /* synthetic */ boolean f$6;

            {
                this.f$1 = r2;
                this.f$2 = r4;
                this.f$3 = r5;
                this.f$4 = r6;
                this.f$5 = r7;
                this.f$6 = r8;
            }

            public final void run() {
                MessagesController.this.lambda$null$169$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6);
            }
        });
    }

    public /* synthetic */ void lambda$null$169$MessagesController(long j, int i, boolean z, int i2, int i3, boolean z2) {
        TLRPC.Dialog dialog;
        getNotificationsController().processReadMessages(null, j, i, 0, z);
        TLRPC.Dialog dialog2 = this.dialogs_dict.get(j);
        if (dialog2 != null) {
            int i4 = dialog2.unread_count;
            if (i2 == 0 || i3 <= dialog2.top_message) {
                dialog2.unread_count = 0;
            } else {
                dialog2.unread_count = Math.max(dialog2.unread_count - i2, 0);
                if (i3 != Integer.MAX_VALUE && dialog2.unread_count > i3 - dialog2.top_message) {
                    dialog2.unread_count = i3 - dialog2.top_message;
                }
            }
            if (!(dialog2.folder_id == 0 || (dialog = this.dialogs_dict.get(DialogObject.makeFolderDialogId(dialog2.folder_id))) == null)) {
                if (z2) {
                    if (isDialogMuted(dialog2.id)) {
                        dialog.unread_count -= i4 - dialog2.unread_count;
                    } else {
                        dialog.unread_mentions_count -= i4 - dialog2.unread_count;
                    }
                } else if (dialog2.unread_count == 0) {
                    if (isDialogMuted(dialog2.id)) {
                        dialog.unread_count--;
                    } else {
                        dialog.unread_mentions_count--;
                    }
                }
            }
            if ((i4 != 0 || dialog2.unread_mark) && dialog2.unread_count == 0 && !isDialogMuted(j)) {
                this.unreadUnmutedDialogs--;
            }
            if (dialog2.unread_mark) {
                dialog2.unread_mark = false;
                getMessagesStorage().setDialogUnread(dialog2.id, false);
            }
            getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 256);
        }
        LongSparseArray<Integer> longSparseArray = new LongSparseArray<>(1);
        longSparseArray.put(j, 0);
        getNotificationsController().processDialogsUpdateRead(longSparseArray);
    }

    public /* synthetic */ void lambda$markDialogAsRead$171$MessagesController(long j, boolean z, int i, int i2) {
        ReadTask readTask = this.readTasksMap.get(j);
        if (readTask == null) {
            readTask = new ReadTask();
            readTask.dialogId = j;
            readTask.sendRequestTime = SystemClock.elapsedRealtime() + DefaultRenderersFactory.DEFAULT_ALLOWED_VIDEO_JOINING_TIME_MS;
            if (!z) {
                this.readTasksMap.put(j, readTask);
                this.readTasks.add(readTask);
            }
        }
        readTask.maxDate = i;
        readTask.maxId = i2;
        if (z) {
            completeReadTask(readTask);
        }
    }

    public int createChat(String str, ArrayList<Integer> arrayList, String str2, int i, BDLocation bDLocation, String str3, BaseFragment baseFragment) {
        if (i == 0) {
            TLRPC.TL_messages_createChat tL_messages_createChat = new TLRPC.TL_messages_createChat();
            tL_messages_createChat.title = str;
            for (int i2 = 0; i2 < arrayList.size(); i2++) {
                TLRPC.User user = getUser(arrayList.get(i2));
                if (user != null) {
                    tL_messages_createChat.users.add(getInputUser(user));
                }
            }
            return getConnectionsManager().sendRequest(tL_messages_createChat, new RequestDelegate(baseFragment, tL_messages_createChat) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$ZwlIpjkc9Vt0EE4p7WRWW1EX090 */
                private final /* synthetic */ BaseFragment f$1;
                private final /* synthetic */ TLRPC.TL_messages_createChat f$2;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$createChat$174$MessagesController(this.f$1, this.f$2, tLObject, tL_error);
                }
            }, 2);
        } else if (i != 2 && i != 4) {
            return 0;
        } else {
            TLRPC.TL_channels_createChannel tL_channels_createChannel = new TLRPC.TL_channels_createChannel();
            tL_channels_createChannel.title = str;
            if (str2 == null) {
                str2 = "";
            }
            tL_channels_createChannel.about = str2;
            if (i == 4) {
                tL_channels_createChannel.megagroup = true;
            } else {
                tL_channels_createChannel.broadcast = true;
            }
            if (bDLocation != null) {
                tL_channels_createChannel.geo_point = new TLRPC.TL_inputGeoPoint();
                tL_channels_createChannel.geo_point.lat = bDLocation.getLatitude();
                tL_channels_createChannel.geo_point._long = bDLocation.getLongitude();
                tL_channels_createChannel.address = str3;
                tL_channels_createChannel.flags |= 4;
            }
            return getConnectionsManager().sendRequest(tL_channels_createChannel, new RequestDelegate(baseFragment, tL_channels_createChannel) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$rd7nGLo04qEk8cr_2dBW7n5K2hg */
                private final /* synthetic */ BaseFragment f$1;
                private final /* synthetic */ TLRPC.TL_channels_createChannel f$2;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$createChat$177$MessagesController(this.f$1, this.f$2, tLObject, tL_error);
                }
            }, 2);
        }
    }

    public /* synthetic */ void lambda$createChat$174$MessagesController(BaseFragment baseFragment, TLRPC.TL_messages_createChat tL_messages_createChat, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error != null) {
            AndroidUtilities.runOnUIThread(new Runnable(tL_error, baseFragment, tL_messages_createChat) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$7MUSZ5lm11KLOTvaMHKQof5bsRc */
                private final /* synthetic */ TLRPC.TL_error f$1;
                private final /* synthetic */ BaseFragment f$2;
                private final /* synthetic */ TLRPC.TL_messages_createChat f$3;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                    this.f$3 = r4;
                }

                public final void run() {
                    MessagesController.this.lambda$null$172$MessagesController(this.f$1, this.f$2, this.f$3);
                }
            });
            return;
        }
        TLRPC.Updates updates = (TLRPC.Updates) tLObject;
        processUpdates(updates, false);
        AndroidUtilities.runOnUIThread(new Runnable(updates) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$i2d9ERMTpnuR5IaLMMpKT198oc */
            private final /* synthetic */ TLRPC.Updates f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                MessagesController.this.lambda$null$173$MessagesController(this.f$1);
            }
        });
    }

    public /* synthetic */ void lambda$null$172$MessagesController(TLRPC.TL_error tL_error, BaseFragment baseFragment, TLRPC.TL_messages_createChat tL_messages_createChat) {
        AlertsCreator.processError(this.currentAccount, tL_error, baseFragment, tL_messages_createChat, new Object[0]);
        getNotificationCenter().postNotificationName(NotificationCenter.chatDidFailCreate, new Object[0]);
    }

    public /* synthetic */ void lambda$null$173$MessagesController(TLRPC.Updates updates) {
        putUsers(updates.users, false);
        putChats(updates.chats, false);
        if (updates.chats == null || updates.chats.isEmpty()) {
            getNotificationCenter().postNotificationName(NotificationCenter.chatDidFailCreate, new Object[0]);
            return;
        }
        getNotificationCenter().postNotificationName(NotificationCenter.chatDidCreated, Integer.valueOf(updates.chats.get(0).id));
    }

    public /* synthetic */ void lambda$createChat$177$MessagesController(BaseFragment baseFragment, TLRPC.TL_channels_createChannel tL_channels_createChannel, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error != null) {
            AndroidUtilities.runOnUIThread(new Runnable(tL_error, baseFragment, tL_channels_createChannel) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$apFDoxQCPyEPF4YU8L9hi7Xm6xM */
                private final /* synthetic */ TLRPC.TL_error f$1;
                private final /* synthetic */ BaseFragment f$2;
                private final /* synthetic */ TLRPC.TL_channels_createChannel f$3;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                    this.f$3 = r4;
                }

                public final void run() {
                    MessagesController.this.lambda$null$175$MessagesController(this.f$1, this.f$2, this.f$3);
                }
            });
            return;
        }
        TLRPC.Updates updates = (TLRPC.Updates) tLObject;
        processUpdates(updates, false);
        AndroidUtilities.runOnUIThread(new Runnable(updates) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$bhifJ7Yfd61OoAbgo23jvzsoTPI */
            private final /* synthetic */ TLRPC.Updates f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                MessagesController.this.lambda$null$176$MessagesController(this.f$1);
            }
        });
    }

    public /* synthetic */ void lambda$null$175$MessagesController(TLRPC.TL_error tL_error, BaseFragment baseFragment, TLRPC.TL_channels_createChannel tL_channels_createChannel) {
        AlertsCreator.processError(this.currentAccount, tL_error, baseFragment, tL_channels_createChannel, new Object[0]);
        getNotificationCenter().postNotificationName(NotificationCenter.chatDidFailCreate, new Object[0]);
    }

    public /* synthetic */ void lambda$null$176$MessagesController(TLRPC.Updates updates) {
        putUsers(updates.users, false);
        putChats(updates.chats, false);
        if (updates.chats == null || updates.chats.isEmpty()) {
            getNotificationCenter().postNotificationName(NotificationCenter.chatDidFailCreate, new Object[0]);
            return;
        }
        getNotificationCenter().postNotificationName(NotificationCenter.chatDidCreated, Integer.valueOf(updates.chats.get(0).id));
    }

    public int createMegaGroup(String str, ArrayList<Integer> arrayList, String str2, int i, BDLocation bDLocation, String str3, BaseFragment baseFragment, boolean z) {
        if (i != 2 && i != 4) {
            return 0;
        }
        TLRPCChats.TL_channels_createChannel_v1 tL_channels_createChannel_v1 = new TLRPCChats.TL_channels_createChannel_v1();
        tL_channels_createChannel_v1.title = str;
        if (str2 == null) {
            str2 = "";
        }
        tL_channels_createChannel_v1.about = str2;
        tL_channels_createChannel_v1.ban_add_contact = z;
        if (i == 4) {
            tL_channels_createChannel_v1.megagroup = true;
        } else {
            tL_channels_createChannel_v1.broadcast = true;
        }
        if (bDLocation != null) {
            tL_channels_createChannel_v1.geo_point = new TLRPC.TL_inputGeoPoint();
            tL_channels_createChannel_v1.geo_point.lat = bDLocation.getLatitude();
            tL_channels_createChannel_v1.geo_point._long = bDLocation.getLongitude();
            tL_channels_createChannel_v1.address = str3;
            tL_channels_createChannel_v1.flags |= 4;
        }
        return getConnectionsManager().sendRequest(tL_channels_createChannel_v1, new RequestDelegate(baseFragment, tL_channels_createChannel_v1, arrayList) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$1z5fxsoJSNercnSKYoL_LjluvNg */
            private final /* synthetic */ BaseFragment f$1;
            private final /* synthetic */ TLRPCChats.TL_channels_createChannel_v1 f$2;
            private final /* synthetic */ ArrayList f$3;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
            }

            @Override // im.guobwnxjuc.tgnet.RequestDelegate
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                MessagesController.this.lambda$createMegaGroup$180$MessagesController(this.f$1, this.f$2, this.f$3, tLObject, tL_error);
            }
        }, 2);
    }

    public /* synthetic */ void lambda$createMegaGroup$180$MessagesController(BaseFragment baseFragment, TLRPCChats.TL_channels_createChannel_v1 tL_channels_createChannel_v1, ArrayList arrayList, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error != null) {
            AndroidUtilities.runOnUIThread(new Runnable(tL_error, baseFragment, tL_channels_createChannel_v1) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$x1vKe6s_qEdcUgxLTEpXpwZc8zk */
                private final /* synthetic */ TLRPC.TL_error f$1;
                private final /* synthetic */ BaseFragment f$2;
                private final /* synthetic */ TLRPCChats.TL_channels_createChannel_v1 f$3;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                    this.f$3 = r4;
                }

                public final void run() {
                    MessagesController.this.lambda$null$178$MessagesController(this.f$1, this.f$2, this.f$3);
                }
            });
            return;
        }
        TLRPC.Updates updates = (TLRPC.Updates) tLObject;
        AndroidUtilities.runOnUIThread(new Runnable(updates) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$DvyPqyajVSg4UU9sXDi1j1CTKo */
            private final /* synthetic */ TLRPC.Updates f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                MessagesController.this.lambda$null$179$MessagesController(this.f$1);
            }
        });
        ArrayList<TLRPC.InputUser> arrayList2 = new ArrayList<>();
        for (int i = 0; i < arrayList.size(); i++) {
            TLRPC.InputUser inputUser = getInstance(this.currentAccount).getInputUser(getInstance(this.currentAccount).getUser((Integer) arrayList.get(i)));
            if (inputUser != null) {
                arrayList2.add(inputUser);
            }
        }
        getInstance(this.currentAccount).addUsersToChannelWithCreate(updates.chats.get(0), arrayList2, null);
        processUpdates(updates, false);
    }

    public /* synthetic */ void lambda$null$178$MessagesController(TLRPC.TL_error tL_error, BaseFragment baseFragment, TLRPCChats.TL_channels_createChannel_v1 tL_channels_createChannel_v1) {
        AlertsCreator.processError(this.currentAccount, tL_error, baseFragment, tL_channels_createChannel_v1, new Object[0]);
        getNotificationCenter().postNotificationName(NotificationCenter.chatDidFailCreate, new Object[0]);
    }

    public /* synthetic */ void lambda$null$179$MessagesController(TLRPC.Updates updates) {
        putUsers(updates.users, false);
        putChats(updates.chats, false);
        if (updates.chats == null || updates.chats.isEmpty()) {
            getNotificationCenter().postNotificationName(NotificationCenter.chatDidFailCreate, new Object[0]);
            return;
        }
        getNotificationCenter().postNotificationName(NotificationCenter.chatDidCreated, Integer.valueOf(updates.chats.get(0).id));
    }

    public void addUsersToChannelWithCreate(TLRPC.Chat chat, ArrayList<TLRPC.InputUser> arrayList, BaseFragment baseFragment) {
        if (arrayList != null && !arrayList.isEmpty()) {
            TLRPC.TL_channels_inviteToChannel tL_channels_inviteToChannel = new TLRPC.TL_channels_inviteToChannel();
            tL_channels_inviteToChannel.channel = getInputChannel(chat);
            tL_channels_inviteToChannel.users = arrayList;
            getConnectionsManager().sendRequest(tL_channels_inviteToChannel, new RequestDelegate(baseFragment, tL_channels_inviteToChannel) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$kd1g8kJBNG5DGH0wW3NlJrAC6JI */
                private final /* synthetic */ BaseFragment f$1;
                private final /* synthetic */ TLRPC.TL_channels_inviteToChannel f$2;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$addUsersToChannelWithCreate$182$MessagesController(this.f$1, this.f$2, tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$addUsersToChannelWithCreate$182$MessagesController(BaseFragment baseFragment, TLRPC.TL_channels_inviteToChannel tL_channels_inviteToChannel, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error != null) {
            AndroidUtilities.runOnUIThread(new Runnable(tL_error, baseFragment, tL_channels_inviteToChannel) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$VAUdWZU77veoxufs81bjfaK4JZo */
                private final /* synthetic */ TLRPC.TL_error f$1;
                private final /* synthetic */ BaseFragment f$2;
                private final /* synthetic */ TLRPC.TL_channels_inviteToChannel f$3;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                    this.f$3 = r4;
                }

                public final void run() {
                    MessagesController.this.lambda$null$181$MessagesController(this.f$1, this.f$2, this.f$3);
                }
            });
        } else {
            processUpdates((TLRPC.Updates) tLObject, false);
        }
    }

    public /* synthetic */ void lambda$null$181$MessagesController(TLRPC.TL_error tL_error, BaseFragment baseFragment, TLRPC.TL_channels_inviteToChannel tL_channels_inviteToChannel) {
        AlertsCreator.processError(this.currentAccount, tL_error, baseFragment, tL_channels_inviteToChannel, true);
    }

    public void convertToMegaGroup(Context context, int i, BaseFragment baseFragment, MessagesStorage.IntCallback intCallback) {
        TLRPC.TL_messages_migrateChat tL_messages_migrateChat = new TLRPC.TL_messages_migrateChat();
        tL_messages_migrateChat.chat_id = i;
        AlertDialog alertDialog = new AlertDialog(context, 3);
        alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener(getConnectionsManager().sendRequest(tL_messages_migrateChat, new RequestDelegate(context, alertDialog, intCallback, baseFragment, tL_messages_migrateChat) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$kK25VXyC2cfnNlZP_LpUtw3QUE */
            private final /* synthetic */ Context f$1;
            private final /* synthetic */ AlertDialog f$2;
            private final /* synthetic */ MessagesStorage.IntCallback f$3;
            private final /* synthetic */ BaseFragment f$4;
            private final /* synthetic */ TLRPC.TL_messages_migrateChat f$5;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
                this.f$4 = r5;
                this.f$5 = r6;
            }

            @Override // im.guobwnxjuc.tgnet.RequestDelegate
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                MessagesController.this.lambda$convertToMegaGroup$186$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, tLObject, tL_error);
            }
        })) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$DRwrkHt8PCaAZWq9_enmWeSxyo */
            private final /* synthetic */ int f$1;

            {
                this.f$1 = r2;
            }

            public final void onCancel(DialogInterface dialogInterface) {
                MessagesController.this.lambda$convertToMegaGroup$187$MessagesController(this.f$1, dialogInterface);
            }
        });
        try {
            alertDialog.show();
        } catch (Exception unused) {
        }
    }

    public /* synthetic */ void lambda$convertToMegaGroup$186$MessagesController(Context context, AlertDialog alertDialog, MessagesStorage.IntCallback intCallback, BaseFragment baseFragment, TLRPC.TL_messages_migrateChat tL_messages_migrateChat, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            AndroidUtilities.runOnUIThread(new Runnable(context, alertDialog) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$nmC3iJmbppRMQl8s7VRlcIFqktw */
                private final /* synthetic */ Context f$0;
                private final /* synthetic */ AlertDialog f$1;

                {
                    this.f$0 = r1;
                    this.f$1 = r2;
                }

                public final void run() {
                    MessagesController.lambda$null$183(this.f$0, this.f$1);
                }
            });
            TLRPC.Updates updates = (TLRPC.Updates) tLObject;
            processUpdates(updates, false);
            AndroidUtilities.runOnUIThread(new Runnable(updates) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$BlJ6wuHuo4zNyBf6pY5YhmN2aRI */
                private final /* synthetic */ TLRPC.Updates f$1;

                {
                    this.f$1 = r2;
                }

                public final void run() {
                    MessagesController.lambda$null$184(MessagesStorage.IntCallback.this, this.f$1);
                }
            });
            return;
        }
        AndroidUtilities.runOnUIThread(new Runnable(intCallback, context, alertDialog, tL_error, baseFragment, tL_messages_migrateChat) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$8NMDRmgLRKni1MdSqLkL_kI2wDc */
            private final /* synthetic */ MessagesStorage.IntCallback f$1;
            private final /* synthetic */ Context f$2;
            private final /* synthetic */ AlertDialog f$3;
            private final /* synthetic */ TLRPC.TL_error f$4;
            private final /* synthetic */ BaseFragment f$5;
            private final /* synthetic */ TLRPC.TL_messages_migrateChat f$6;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
                this.f$4 = r5;
                this.f$5 = r6;
                this.f$6 = r7;
            }

            public final void run() {
                MessagesController.this.lambda$null$185$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6);
            }
        });
    }

    static /* synthetic */ void lambda$null$183(Context context, AlertDialog alertDialog) {
        if (!((Activity) context).isFinishing()) {
            try {
                alertDialog.dismiss();
            } catch (Exception e) {
                FileLog.e(e);
            }
        }
    }

    static /* synthetic */ void lambda$null$184(MessagesStorage.IntCallback intCallback, TLRPC.Updates updates) {
        if (intCallback != null) {
            for (int i = 0; i < updates.chats.size(); i++) {
                TLRPC.Chat chat = updates.chats.get(i);
                if (ChatObject.isChannel(chat)) {
                    intCallback.run(chat.id);
                    return;
                }
            }
        }
    }

    public /* synthetic */ void lambda$null$185$MessagesController(MessagesStorage.IntCallback intCallback, Context context, AlertDialog alertDialog, TLRPC.TL_error tL_error, BaseFragment baseFragment, TLRPC.TL_messages_migrateChat tL_messages_migrateChat) {
        if (intCallback != null) {
            intCallback.run(0);
        }
        if (!((Activity) context).isFinishing()) {
            try {
                alertDialog.dismiss();
            } catch (Exception e) {
                FileLog.e(e);
            }
            AlertsCreator.processError(this.currentAccount, tL_error, baseFragment, tL_messages_migrateChat, false);
        }
    }

    public /* synthetic */ void lambda$convertToMegaGroup$187$MessagesController(int i, DialogInterface dialogInterface) {
        getConnectionsManager().cancelRequest(i, true);
    }

    public void addUsersToChannel(int i, ArrayList<TLRPC.InputUser> arrayList, BaseFragment baseFragment) {
        if (arrayList != null && !arrayList.isEmpty()) {
            TLRPC.TL_channels_inviteToChannel tL_channels_inviteToChannel = new TLRPC.TL_channels_inviteToChannel();
            tL_channels_inviteToChannel.channel = getInputChannel(i);
            tL_channels_inviteToChannel.users = arrayList;
            getConnectionsManager().sendRequest(tL_channels_inviteToChannel, new RequestDelegate(baseFragment, tL_channels_inviteToChannel) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$a8irLL6FpYJoMFQu0TdDe7T61jU */
                private final /* synthetic */ BaseFragment f$1;
                private final /* synthetic */ TLRPC.TL_channels_inviteToChannel f$2;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$addUsersToChannel$189$MessagesController(this.f$1, this.f$2, tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$addUsersToChannel$189$MessagesController(BaseFragment baseFragment, TLRPC.TL_channels_inviteToChannel tL_channels_inviteToChannel, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error != null) {
            AndroidUtilities.runOnUIThread(new Runnable(tL_error, baseFragment, tL_channels_inviteToChannel) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$2fqZwh32ME2_9W3YnxVYQ2WGaDQ */
                private final /* synthetic */ TLRPC.TL_error f$1;
                private final /* synthetic */ BaseFragment f$2;
                private final /* synthetic */ TLRPC.TL_channels_inviteToChannel f$3;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                    this.f$3 = r4;
                }

                public final void run() {
                    MessagesController.this.lambda$null$188$MessagesController(this.f$1, this.f$2, this.f$3);
                }
            });
        } else {
            processUpdates((TLRPC.Updates) tLObject, false);
        }
    }

    public /* synthetic */ void lambda$null$188$MessagesController(TLRPC.TL_error tL_error, BaseFragment baseFragment, TLRPC.TL_channels_inviteToChannel tL_channels_inviteToChannel) {
        AlertsCreator.processError(this.currentAccount, tL_error, baseFragment, tL_channels_inviteToChannel, true);
    }

    public void toogleChannelSignatures(int i, boolean z) {
        TLRPC.TL_channels_toggleSignatures tL_channels_toggleSignatures = new TLRPC.TL_channels_toggleSignatures();
        tL_channels_toggleSignatures.channel = getInputChannel(i);
        tL_channels_toggleSignatures.enabled = z;
        getConnectionsManager().sendRequest(tL_channels_toggleSignatures, new RequestDelegate() {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$NhKawLR7MZAZSWju3w0hDRTbLWk */

            @Override // im.guobwnxjuc.tgnet.RequestDelegate
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                MessagesController.this.lambda$toogleChannelSignatures$191$MessagesController(tLObject, tL_error);
            }
        }, 64);
    }

    public /* synthetic */ void lambda$toogleChannelSignatures$191$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tLObject != null) {
            processUpdates((TLRPC.Updates) tLObject, false);
            AndroidUtilities.runOnUIThread(new Runnable() {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$hKeO9oy7nT3BvKwRHjmkXFlox4 */

                public final void run() {
                    MessagesController.this.lambda$null$190$MessagesController();
                }
            });
        }
    }

    public /* synthetic */ void lambda$null$190$MessagesController() {
        getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 8192);
    }

    public void toogleChannelInvitesHistory(int i, boolean z) {
        TLRPC.TL_channels_togglePreHistoryHidden tL_channels_togglePreHistoryHidden = new TLRPC.TL_channels_togglePreHistoryHidden();
        tL_channels_togglePreHistoryHidden.channel = getInputChannel(i);
        tL_channels_togglePreHistoryHidden.enabled = z;
        getConnectionsManager().sendRequest(tL_channels_togglePreHistoryHidden, new RequestDelegate() {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$WoCZFn4NpC_0uDYrZ0ZOi1fF544 */

            @Override // im.guobwnxjuc.tgnet.RequestDelegate
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                MessagesController.this.lambda$toogleChannelInvitesHistory$193$MessagesController(tLObject, tL_error);
            }
        }, 64);
    }

    public /* synthetic */ void lambda$toogleChannelInvitesHistory$193$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tLObject != null) {
            processUpdates((TLRPC.Updates) tLObject, false);
            AndroidUtilities.runOnUIThread(new Runnable() {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$_bGZCrXR1wPACksarQTwS89bTI */

                public final void run() {
                    MessagesController.this.lambda$null$192$MessagesController();
                }
            });
        }
    }

    public /* synthetic */ void lambda$null$192$MessagesController() {
        getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 8192);
    }

    public void updateChatAbout(int i, String str, TLRPC.ChatFull chatFull) {
        if (chatFull != null) {
            TLRPC.TL_messages_editChatAbout tL_messages_editChatAbout = new TLRPC.TL_messages_editChatAbout();
            tL_messages_editChatAbout.peer = getInputPeer(-i);
            tL_messages_editChatAbout.about = str;
            getConnectionsManager().sendRequest(tL_messages_editChatAbout, new RequestDelegate(chatFull, str) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$kbPL70xqbbZ_4QddajuYxSi8X9M */
                private final /* synthetic */ TLRPC.ChatFull f$1;
                private final /* synthetic */ String f$2;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$updateChatAbout$195$MessagesController(this.f$1, this.f$2, tLObject, tL_error);
                }
            }, 64);
        }
    }

    public /* synthetic */ void lambda$updateChatAbout$195$MessagesController(TLRPC.ChatFull chatFull, String str, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tLObject instanceof TLRPC.TL_boolTrue) {
            AndroidUtilities.runOnUIThread(new Runnable(chatFull, str) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$VSwAWuCR1n84vo1ANtrqd7Gm_Wk */
                private final /* synthetic */ TLRPC.ChatFull f$1;
                private final /* synthetic */ String f$2;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                }

                public final void run() {
                    MessagesController.this.lambda$null$194$MessagesController(this.f$1, this.f$2);
                }
            });
        }
    }

    public /* synthetic */ void lambda$null$194$MessagesController(TLRPC.ChatFull chatFull, String str) {
        chatFull.about = str;
        getMessagesStorage().updateChatInfo(chatFull, false);
        getNotificationCenter().postNotificationName(NotificationCenter.chatInfoDidLoad, chatFull, 0, false, 0);
    }

    public void updateChannelUserName(int i, String str) {
        TLRPC.TL_channels_updateUsername tL_channels_updateUsername = new TLRPC.TL_channels_updateUsername();
        tL_channels_updateUsername.channel = getInputChannel(i);
        tL_channels_updateUsername.username = str;
        getConnectionsManager().sendRequest(tL_channels_updateUsername, new RequestDelegate(i, str) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$0nUzsckvkm93UD4ybulvoc_K1Ic */
            private final /* synthetic */ int f$1;
            private final /* synthetic */ String f$2;

            {
                this.f$1 = r2;
                this.f$2 = r3;
            }

            @Override // im.guobwnxjuc.tgnet.RequestDelegate
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                MessagesController.this.lambda$updateChannelUserName$197$MessagesController(this.f$1, this.f$2, tLObject, tL_error);
            }
        }, 64);
    }

    public /* synthetic */ void lambda$updateChannelUserName$197$MessagesController(int i, String str, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tLObject instanceof TLRPC.TL_boolTrue) {
            AndroidUtilities.runOnUIThread(new Runnable(i, str) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$Dvip15J6e1o2_XU4AblFYSfKBY */
                private final /* synthetic */ int f$1;
                private final /* synthetic */ String f$2;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                }

                public final void run() {
                    MessagesController.this.lambda$null$196$MessagesController(this.f$1, this.f$2);
                }
            });
        }
    }

    public /* synthetic */ void lambda$null$196$MessagesController(int i, String str) {
        TLRPC.Chat chat = getChat(Integer.valueOf(i));
        if (str.length() != 0) {
            chat.flags |= 64;
        } else {
            chat.flags &= -65;
        }
        chat.username = str;
        ArrayList<TLRPC.Chat> arrayList = new ArrayList<>();
        arrayList.add(chat);
        getMessagesStorage().putUsersAndChats(null, arrayList, true, true);
        getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 8192);
    }

    public void sendBotStart(TLRPC.User user, String str) {
        if (user != null) {
            TLRPC.TL_messages_startBot tL_messages_startBot = new TLRPC.TL_messages_startBot();
            tL_messages_startBot.bot = getInputUser(user);
            tL_messages_startBot.peer = getInputPeer(user.id);
            tL_messages_startBot.start_param = str;
            tL_messages_startBot.random_id = Utilities.random.nextLong();
            getConnectionsManager().sendRequest(tL_messages_startBot, new RequestDelegate() {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$_1k2F4sSg1LFjpVIADZfO0AYQx4 */

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$sendBotStart$198$MessagesController(tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$sendBotStart$198$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            processUpdates((TLRPC.Updates) tLObject, false);
        }
    }

    public boolean isJoiningChannel(int i) {
        return this.joiningToChannels.contains(Integer.valueOf(i));
    }

    /* JADX DEBUG: Multi-variable search result rejected for r0v15, resolved type: im.guobwnxjuc.tgnet.TLRPC$TL_channels_inviteToChannel */
    /* JADX DEBUG: Multi-variable search result rejected for r0v18, resolved type: im.guobwnxjuc.tgnet.TLRPC$TL_channels_joinChannel */
    /* JADX DEBUG: Multi-variable search result rejected for r0v19, resolved type: im.guobwnxjuc.tgnet.TLRPC$TL_messages_startBot */
    /* JADX WARN: Multi-variable type inference failed */
    public void addUserToChat(int i, TLRPC.User user, TLRPC.ChatFull chatFull, int i2, String str, BaseFragment baseFragment, Runnable runnable) {
        TLRPC.TL_messages_addChatUser tL_messages_addChatUser;
        if (user != null) {
            if (i > 0) {
                boolean isChannel = ChatObject.isChannel(i, this.currentAccount);
                boolean z = isChannel && getChat(Integer.valueOf(i)).megagroup;
                TLRPC.InputUser inputUser = getInputUser(user);
                if (str != null && (!isChannel || z)) {
                    TLRPC.TL_messages_startBot tL_messages_startBot = new TLRPC.TL_messages_startBot();
                    tL_messages_startBot.bot = inputUser;
                    if (isChannel) {
                        tL_messages_startBot.peer = getInputPeer(-i);
                    } else {
                        tL_messages_startBot.peer = new TLRPC.TL_inputPeerChat();
                        tL_messages_startBot.peer.chat_id = i;
                    }
                    tL_messages_startBot.start_param = str;
                    tL_messages_startBot.random_id = Utilities.random.nextLong();
                    tL_messages_addChatUser = tL_messages_startBot;
                } else if (!isChannel) {
                    TLRPC.TL_messages_addChatUser tL_messages_addChatUser2 = new TLRPC.TL_messages_addChatUser();
                    tL_messages_addChatUser2.chat_id = i;
                    tL_messages_addChatUser2.fwd_limit = i2;
                    tL_messages_addChatUser2.user_id = inputUser;
                    tL_messages_addChatUser = tL_messages_addChatUser2;
                } else if (!(inputUser instanceof TLRPC.TL_inputUserSelf)) {
                    TLRPC.TL_channels_inviteToChannel tL_channels_inviteToChannel = new TLRPC.TL_channels_inviteToChannel();
                    tL_channels_inviteToChannel.channel = getInputChannel(i);
                    tL_channels_inviteToChannel.users.add(inputUser);
                    tL_messages_addChatUser = tL_channels_inviteToChannel;
                } else if (!this.joiningToChannels.contains(Integer.valueOf(i))) {
                    TLRPC.TL_channels_joinChannel tL_channels_joinChannel = new TLRPC.TL_channels_joinChannel();
                    tL_channels_joinChannel.channel = getInputChannel(i);
                    this.joiningToChannels.add(Integer.valueOf(i));
                    tL_messages_addChatUser = tL_channels_joinChannel;
                } else {
                    return;
                }
                getConnectionsManager().sendRequest(tL_messages_addChatUser, new RequestDelegate(isChannel, inputUser, i, baseFragment, tL_messages_addChatUser, z, runnable) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$9LBIlL67b_vm7OkcUsC7172mc */
                    private final /* synthetic */ boolean f$1;
                    private final /* synthetic */ TLRPC.InputUser f$2;
                    private final /* synthetic */ int f$3;
                    private final /* synthetic */ BaseFragment f$4;
                    private final /* synthetic */ TLObject f$5;
                    private final /* synthetic */ boolean f$6;
                    private final /* synthetic */ Runnable f$7;

                    {
                        this.f$1 = r2;
                        this.f$2 = r3;
                        this.f$3 = r4;
                        this.f$4 = r5;
                        this.f$5 = r6;
                        this.f$6 = r7;
                        this.f$7 = r8;
                    }

                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        MessagesController.this.lambda$addUserToChat$202$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6, this.f$7, tLObject, tL_error);
                    }
                });
            } else if (chatFull instanceof TLRPC.TL_chatFull) {
                for (int i3 = 0; i3 < chatFull.participants.participants.size(); i3++) {
                    if (chatFull.participants.participants.get(i3).user_id == user.id) {
                        return;
                    }
                }
                TLRPC.Chat chat = getChat(Integer.valueOf(i));
                chat.participants_count++;
                ArrayList<TLRPC.Chat> arrayList = new ArrayList<>();
                arrayList.add(chat);
                getMessagesStorage().putUsersAndChats(null, arrayList, true, true);
                TLRPC.TL_chatParticipant tL_chatParticipant = new TLRPC.TL_chatParticipant();
                tL_chatParticipant.user_id = user.id;
                tL_chatParticipant.inviter_id = getUserConfig().getClientUserId();
                tL_chatParticipant.date = getConnectionsManager().getCurrentTime();
                chatFull.participants.participants.add(0, tL_chatParticipant);
                getMessagesStorage().updateChatInfo(chatFull, true);
                getNotificationCenter().postNotificationName(NotificationCenter.chatInfoDidLoad, chatFull, 0, false, null);
                getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 32);
            }
        }
    }

    public /* synthetic */ void lambda$addUserToChat$202$MessagesController(boolean z, TLRPC.InputUser inputUser, int i, BaseFragment baseFragment, TLObject tLObject, boolean z2, Runnable runnable, TLObject tLObject2, TLRPC.TL_error tL_error) {
        boolean z3;
        if (z && (inputUser instanceof TLRPC.TL_inputUserSelf)) {
            AndroidUtilities.runOnUIThread(new Runnable(i) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$R3YIQmCTpaaRIih3sU4rSHRPXo */
                private final /* synthetic */ int f$1;

                {
                    this.f$1 = r2;
                }

                public final void run() {
                    MessagesController.this.lambda$null$199$MessagesController(this.f$1);
                }
            });
        }
        if (tL_error != null) {
            AndroidUtilities.runOnUIThread(new Runnable(tL_error, baseFragment, tLObject, z, z2, inputUser) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$cM8KKIu0n3ikq3KaYoRRIfPovFQ */
                private final /* synthetic */ TLRPC.TL_error f$1;
                private final /* synthetic */ BaseFragment f$2;
                private final /* synthetic */ TLObject f$3;
                private final /* synthetic */ boolean f$4;
                private final /* synthetic */ boolean f$5;
                private final /* synthetic */ TLRPC.InputUser f$6;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                    this.f$3 = r4;
                    this.f$4 = r5;
                    this.f$5 = r6;
                    this.f$6 = r7;
                }

                public final void run() {
                    MessagesController.this.lambda$null$200$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6);
                }
            });
            return;
        }
        TLRPC.Updates updates = (TLRPC.Updates) tLObject2;
        int i2 = 0;
        while (true) {
            if (i2 >= updates.updates.size()) {
                z3 = false;
                break;
            }
            TLRPC.Update update = updates.updates.get(i2);
            if ((update instanceof TLRPC.TL_updateNewChannelMessage) && (((TLRPC.TL_updateNewChannelMessage) update).message.action instanceof TLRPC.TL_messageActionChatAddUser)) {
                z3 = true;
                break;
            }
            i2++;
        }
        processUpdates(updates, false);
        if (z) {
            if (!z3 && (inputUser instanceof TLRPC.TL_inputUserSelf)) {
                generateJoinMessage(i, true);
            }
            AndroidUtilities.runOnUIThread(new Runnable(i) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$0qkzMpKf7_hF533BxE56tlKQzI */
                private final /* synthetic */ int f$1;

                {
                    this.f$1 = r2;
                }

                public final void run() {
                    MessagesController.this.lambda$null$201$MessagesController(this.f$1);
                }
            }, 1000);
        }
        if (z && (inputUser instanceof TLRPC.TL_inputUserSelf)) {
            getMessagesStorage().updateDialogsWithDeletedMessages(new ArrayList<>(), null, true, i);
        }
        if (runnable != null) {
            AndroidUtilities.runOnUIThread(runnable);
        }
    }

    public /* synthetic */ void lambda$null$199$MessagesController(int i) {
        this.joiningToChannels.remove(Integer.valueOf(i));
    }

    public /* synthetic */ void lambda$null$200$MessagesController(TLRPC.TL_error tL_error, BaseFragment baseFragment, TLObject tLObject, boolean z, boolean z2, TLRPC.InputUser inputUser) {
        int i = this.currentAccount;
        Object[] objArr = new Object[1];
        objArr[0] = Boolean.valueOf(z && !z2);
        AlertsCreator.processError(i, tL_error, baseFragment, tLObject, objArr);
        if (z && (inputUser instanceof TLRPC.TL_inputUserSelf)) {
            getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 8192);
        }
    }

    public /* synthetic */ void lambda$null$201$MessagesController(int i) {
        loadFullChat(i, 0, true);
    }

    public void deleteUserFromChat(int i, TLRPC.User user, TLRPC.ChatFull chatFull) {
        deleteUserFromChat(i, user, chatFull, false, false);
    }

    /* JADX DEBUG: Multi-variable search result rejected for r9v19, resolved type: im.guobwnxjuc.tgnet.TLRPC$TL_channels_editBanned */
    /* JADX DEBUG: Multi-variable search result rejected for r9v20, resolved type: im.guobwnxjuc.tgnet.TLRPC$TL_channels_leaveChannel */
    /* JADX DEBUG: Multi-variable search result rejected for r9v21, resolved type: im.guobwnxjuc.tgnet.TLRPC$TL_channels_deleteChannel */
    /* JADX WARN: Multi-variable type inference failed */
    public void deleteUserFromChat(int i, TLRPC.User user, TLRPC.ChatFull chatFull, boolean z, boolean z2) {
        boolean z3;
        TLRPC.TL_messages_deleteChatUser tL_messages_deleteChatUser;
        if (user != null) {
            if (i > 0) {
                TLRPC.InputUser inputUser = getInputUser(user);
                TLRPC.Chat chat = getChat(Integer.valueOf(i));
                boolean isChannel = ChatObject.isChannel(chat);
                if (!isChannel) {
                    TLRPC.TL_messages_deleteChatUser tL_messages_deleteChatUser2 = new TLRPC.TL_messages_deleteChatUser();
                    tL_messages_deleteChatUser2.chat_id = i;
                    tL_messages_deleteChatUser2.user_id = getInputUser(user);
                    tL_messages_deleteChatUser = tL_messages_deleteChatUser2;
                } else if (!(inputUser instanceof TLRPC.TL_inputUserSelf)) {
                    TLRPC.TL_channels_editBanned tL_channels_editBanned = new TLRPC.TL_channels_editBanned();
                    tL_channels_editBanned.channel = getInputChannel(chat);
                    tL_channels_editBanned.user_id = inputUser;
                    tL_channels_editBanned.banned_rights = new TLRPC.TL_chatBannedRights();
                    tL_channels_editBanned.banned_rights.view_messages = true;
                    tL_channels_editBanned.banned_rights.send_media = true;
                    tL_channels_editBanned.banned_rights.send_messages = true;
                    tL_channels_editBanned.banned_rights.send_stickers = true;
                    tL_channels_editBanned.banned_rights.send_gifs = true;
                    tL_channels_editBanned.banned_rights.send_games = true;
                    tL_channels_editBanned.banned_rights.send_inline = true;
                    tL_channels_editBanned.banned_rights.embed_links = true;
                    tL_channels_editBanned.banned_rights.pin_messages = true;
                    tL_channels_editBanned.banned_rights.send_polls = true;
                    tL_channels_editBanned.banned_rights.invite_users = true;
                    tL_channels_editBanned.banned_rights.change_info = true;
                    tL_messages_deleteChatUser = tL_channels_editBanned;
                } else if (!chat.creator || !z) {
                    TLRPC.TL_channels_leaveChannel tL_channels_leaveChannel = new TLRPC.TL_channels_leaveChannel();
                    tL_channels_leaveChannel.channel = getInputChannel(chat);
                    tL_messages_deleteChatUser = tL_channels_leaveChannel;
                } else {
                    TLRPC.TL_channels_deleteChannel tL_channels_deleteChannel = new TLRPC.TL_channels_deleteChannel();
                    tL_channels_deleteChannel.channel = getInputChannel(chat);
                    tL_messages_deleteChatUser = tL_channels_deleteChannel;
                }
                if (user.id == getUserConfig().getClientUserId()) {
                    deleteDialog((long) (-i), 0, z2);
                }
                getConnectionsManager().sendRequest(tL_messages_deleteChatUser, new RequestDelegate(isChannel, inputUser, i) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$vjsxHV6pB_uHemG6EljmmFPZPE */
                    private final /* synthetic */ boolean f$1;
                    private final /* synthetic */ TLRPC.InputUser f$2;
                    private final /* synthetic */ int f$3;

                    {
                        this.f$1 = r2;
                        this.f$2 = r3;
                        this.f$3 = r4;
                    }

                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        MessagesController.this.lambda$deleteUserFromChat$204$MessagesController(this.f$1, this.f$2, this.f$3, tLObject, tL_error);
                    }
                }, 64);
            } else if (chatFull instanceof TLRPC.TL_chatFull) {
                TLRPC.Chat chat2 = getChat(Integer.valueOf(i));
                chat2.participants_count--;
                ArrayList<TLRPC.Chat> arrayList = new ArrayList<>();
                arrayList.add(chat2);
                getMessagesStorage().putUsersAndChats(null, arrayList, true, true);
                int i2 = 0;
                while (true) {
                    if (i2 >= chatFull.participants.participants.size()) {
                        z3 = false;
                        break;
                    } else if (chatFull.participants.participants.get(i2).user_id == user.id) {
                        chatFull.participants.participants.remove(i2);
                        z3 = true;
                        break;
                    } else {
                        i2++;
                    }
                }
                if (z3) {
                    getMessagesStorage().updateChatInfo(chatFull, true);
                    getNotificationCenter().postNotificationName(NotificationCenter.chatInfoDidLoad, chatFull, 0, false, null);
                }
                getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 32);
            }
        }
    }

    public /* synthetic */ void lambda$deleteUserFromChat$204$MessagesController(boolean z, TLRPC.InputUser inputUser, int i, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            processUpdates((TLRPC.Updates) tLObject, false);
            if (z && !(inputUser instanceof TLRPC.TL_inputUserSelf)) {
                AndroidUtilities.runOnUIThread(new Runnable(i) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$cYqdQyTjf0IyFe1cbkLy192Mfgc */
                    private final /* synthetic */ int f$1;

                    {
                        this.f$1 = r2;
                    }

                    public final void run() {
                        MessagesController.this.lambda$null$203$MessagesController(this.f$1);
                    }
                }, 1000);
            }
        }
    }

    public /* synthetic */ void lambda$null$203$MessagesController(int i) {
        loadFullChat(i, 0, true);
    }

    /* JADX DEBUG: Multi-variable search result rejected for r0v6, resolved type: im.guobwnxjuc.tgnet.TLRPC$TL_channels_editTitle */
    /* JADX WARN: Multi-variable type inference failed */
    public void changeChatTitle(int i, String str) {
        TLRPC.TL_messages_editChatTitle tL_messages_editChatTitle;
        if (i > 0) {
            if (ChatObject.isChannel(i, this.currentAccount)) {
                TLRPC.TL_channels_editTitle tL_channels_editTitle = new TLRPC.TL_channels_editTitle();
                tL_channels_editTitle.channel = getInputChannel(i);
                tL_channels_editTitle.title = str;
                tL_messages_editChatTitle = tL_channels_editTitle;
            } else {
                TLRPC.TL_messages_editChatTitle tL_messages_editChatTitle2 = new TLRPC.TL_messages_editChatTitle();
                tL_messages_editChatTitle2.chat_id = i;
                tL_messages_editChatTitle2.title = str;
                tL_messages_editChatTitle = tL_messages_editChatTitle2;
            }
            getConnectionsManager().sendRequest(tL_messages_editChatTitle, new RequestDelegate() {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$bMGTct2Uh9O5MYir4K8OlrXRY */

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$changeChatTitle$205$MessagesController(tLObject, tL_error);
                }
            }, 64);
            return;
        }
        TLRPC.Chat chat = getChat(Integer.valueOf(i));
        chat.title = str;
        ArrayList<TLRPC.Chat> arrayList = new ArrayList<>();
        arrayList.add(chat);
        getMessagesStorage().putUsersAndChats(null, arrayList, true, true);
        getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
        getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 16);
    }

    public /* synthetic */ void lambda$changeChatTitle$205$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            processUpdates((TLRPC.Updates) tLObject, false);
        }
    }

    /* JADX DEBUG: Multi-variable search result rejected for r0v4, resolved type: im.guobwnxjuc.tgnet.TLRPC$TL_channels_editPhoto */
    /* JADX WARN: Multi-variable type inference failed */
    public void changeChatAvatar(int i, TLRPC.InputFile inputFile, TLRPC.FileLocation fileLocation, TLRPC.FileLocation fileLocation2) {
        TLRPC.TL_messages_editChatPhoto tL_messages_editChatPhoto;
        if (ChatObject.isChannel(i, this.currentAccount)) {
            TLRPC.TL_channels_editPhoto tL_channels_editPhoto = new TLRPC.TL_channels_editPhoto();
            tL_channels_editPhoto.channel = getInputChannel(i);
            if (inputFile != null) {
                tL_channels_editPhoto.photo = new TLRPC.TL_inputChatUploadedPhoto();
                tL_channels_editPhoto.photo.file = inputFile;
                tL_messages_editChatPhoto = tL_channels_editPhoto;
            } else {
                tL_channels_editPhoto.photo = new TLRPC.TL_inputChatPhotoEmpty();
                tL_messages_editChatPhoto = tL_channels_editPhoto;
            }
        } else {
            TLRPC.TL_messages_editChatPhoto tL_messages_editChatPhoto2 = new TLRPC.TL_messages_editChatPhoto();
            tL_messages_editChatPhoto2.chat_id = i;
            if (inputFile != null) {
                tL_messages_editChatPhoto2.photo = new TLRPC.TL_inputChatUploadedPhoto();
                tL_messages_editChatPhoto2.photo.file = inputFile;
                tL_messages_editChatPhoto = tL_messages_editChatPhoto2;
            } else {
                tL_messages_editChatPhoto2.photo = new TLRPC.TL_inputChatPhotoEmpty();
                tL_messages_editChatPhoto = tL_messages_editChatPhoto2;
            }
        }
        getConnectionsManager().sendRequest(tL_messages_editChatPhoto, new RequestDelegate(fileLocation, fileLocation2) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$Grnzxks49GXAeAjrr_fVviOBHcE */
            private final /* synthetic */ TLRPC.FileLocation f$1;
            private final /* synthetic */ TLRPC.FileLocation f$2;

            {
                this.f$1 = r2;
                this.f$2 = r3;
            }

            @Override // im.guobwnxjuc.tgnet.RequestDelegate
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                MessagesController.this.lambda$changeChatAvatar$206$MessagesController(this.f$1, this.f$2, tLObject, tL_error);
            }
        }, 64);
    }

    public /* synthetic */ void lambda$changeChatAvatar$206$MessagesController(TLRPC.FileLocation fileLocation, TLRPC.FileLocation fileLocation2, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            TLRPC.Updates updates = (TLRPC.Updates) tLObject;
            TLRPC.Photo photo = null;
            int size = updates.updates.size();
            int i = 0;
            while (true) {
                if (i >= size) {
                    break;
                }
                TLRPC.Update update = updates.updates.get(i);
                if (update instanceof TLRPC.TL_updateNewChannelMessage) {
                    TLRPC.Message message = ((TLRPC.TL_updateNewChannelMessage) update).message;
                    if ((message.action instanceof TLRPC.TL_messageActionChatEditPhoto) && (message.action.photo instanceof TLRPC.TL_photo)) {
                        photo = message.action.photo;
                        break;
                    }
                } else if (update instanceof TLRPC.TL_updateNewMessage) {
                    TLRPC.Message message2 = ((TLRPC.TL_updateNewMessage) update).message;
                    if ((message2.action instanceof TLRPC.TL_messageActionChatEditPhoto) && (message2.action.photo instanceof TLRPC.TL_photo)) {
                        photo = message2.action.photo;
                        break;
                    }
                } else {
                    continue;
                }
                i++;
            }
            if (photo != null) {
                TLRPC.PhotoSize closestPhotoSizeWithSize = FileLoader.getClosestPhotoSizeWithSize(photo.sizes, 150);
                if (!(closestPhotoSizeWithSize == null || fileLocation == null)) {
                    FileLoader.getPathToAttach(fileLocation, true).renameTo(FileLoader.getPathToAttach(closestPhotoSizeWithSize, true));
                    ImageLoader.getInstance().replaceImageInCache(fileLocation.volume_id + "_" + fileLocation.local_id + "@50_50", closestPhotoSizeWithSize.location.volume_id + "_" + closestPhotoSizeWithSize.location.local_id + "@50_50", ImageLocation.getForPhoto(closestPhotoSizeWithSize, photo), true);
                }
                TLRPC.PhotoSize closestPhotoSizeWithSize2 = FileLoader.getClosestPhotoSizeWithSize(photo.sizes, CodeUtils.DEFAULT_REQ_HEIGHT);
                if (!(closestPhotoSizeWithSize2 == null || fileLocation2 == null)) {
                    FileLoader.getPathToAttach(fileLocation2, true).renameTo(FileLoader.getPathToAttach(closestPhotoSizeWithSize2, true));
                }
            }
            processUpdates(updates, false);
        }
    }

    public void unregistedPush() {
        if (getUserConfig().registeredForPush && SharedConfig.pushString.length() == 0) {
            TLRPC.TL_account_unregisterDevice tL_account_unregisterDevice = new TLRPC.TL_account_unregisterDevice();
            tL_account_unregisterDevice.token = SharedConfig.pushString;
            tL_account_unregisterDevice.token_type = 2;
            for (int i = 0; i < 3; i++) {
                UserConfig instance = UserConfig.getInstance(i);
                if (i != this.currentAccount && instance.isClientActivated()) {
                    tL_account_unregisterDevice.other_uids.add(Integer.valueOf(instance.getClientUserId()));
                }
            }
            getConnectionsManager().sendRequest(tL_account_unregisterDevice, $$Lambda$MessagesController$IM3aDi_MtL4Pw2yRRm3fTbPu7A.INSTANCE);
        }
    }

    public void generateUpdateMessage() {
        if (!BuildVars.DEBUG_VERSION && SharedConfig.lastUpdateVersion != null && !SharedConfig.lastUpdateVersion.equals(BuildVars.BUILD_VERSION_STRING)) {
            TLRPC.TL_help_getAppChangelog tL_help_getAppChangelog = new TLRPC.TL_help_getAppChangelog();
            tL_help_getAppChangelog.prev_app_version = SharedConfig.lastUpdateVersion;
            getConnectionsManager().sendRequest(tL_help_getAppChangelog, new RequestDelegate() {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$sIDZZW4E9dviW6_EJw_nhCqtzEc */

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$generateUpdateMessage$208$MessagesController(tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$generateUpdateMessage$208$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            SharedConfig.lastUpdateVersion = BuildVars.BUILD_VERSION_STRING;
            SharedConfig.saveConfig();
        }
        if (tLObject instanceof TLRPC.Updates) {
            processUpdates((TLRPC.Updates) tLObject, false);
        }
    }

    public void performLogout(int i) {
        boolean z = true;
        if (i == 1) {
            unregistedPush();
            getConnectionsManager().sendRequest(new TLRPC.TL_auth_logOut(), new RequestDelegate() {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$QN2mqF_19Le8tExIb5hmF99dA */

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$performLogout$209$MessagesController(tLObject, tL_error);
                }
            });
        } else {
            ConnectionsManager connectionsManager = getConnectionsManager();
            if (i != 2) {
                z = false;
            }
            connectionsManager.cleanup(z);
        }
        getUserConfig().clearConfig();
        getNotificationCenter().postNotificationName(NotificationCenter.appDidLogout, new Object[0]);
        getMessagesStorage().cleanup(false);
        cleanup();
        getContactsController().deleteUnknownAppAccounts();
        AndroidUtilities.runOnUIThread($$Lambda$MessagesController$tqIrbgBZAPIJU3Rm3SCCveRpsgc.INSTANCE);
    }

    public /* synthetic */ void lambda$performLogout$209$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
        getConnectionsManager().cleanup(false);
    }

    public void registerForPush(String str) {
        if (!(TextUtils.isEmpty(str) || this.registeringForPush || getUserConfig().getClientUserId() == 0)) {
            if (!getUserConfig().registeredForPush || !str.equals(SharedConfig.pushString)) {
                this.registeringForPush = true;
                this.lastPushRegisterSendTime = SystemClock.elapsedRealtime();
                if (SharedConfig.pushAuthKey == null) {
                    SharedConfig.pushAuthKey = new byte[256];
                    Utilities.random.nextBytes(SharedConfig.pushAuthKey);
                    SharedConfig.saveConfig();
                }
                TLRPC.TL_account_registerDevice tL_account_registerDevice = new TLRPC.TL_account_registerDevice();
                tL_account_registerDevice.token_type = 2;
                tL_account_registerDevice.token = str;
                tL_account_registerDevice.no_muted = false;
                tL_account_registerDevice.secret = SharedConfig.pushAuthKey;
                for (int i = 0; i < 3; i++) {
                    UserConfig instance = UserConfig.getInstance(i);
                    if (i != this.currentAccount && instance.isClientActivated()) {
                        tL_account_registerDevice.other_uids.add(Integer.valueOf(instance.getClientUserId()));
                    }
                }
                getConnectionsManager().sendRequest(tL_account_registerDevice, new RequestDelegate(str) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$QjBYxu5AgQLVbCLpNN6EUfcvkgY */
                    private final /* synthetic */ String f$1;

                    {
                        this.f$1 = r2;
                    }

                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        MessagesController.this.lambda$registerForPush$212$MessagesController(this.f$1, tLObject, tL_error);
                    }
                });
            }
        }
    }

    public /* synthetic */ void lambda$registerForPush$212$MessagesController(String str, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tLObject instanceof TLRPC.TL_boolTrue) {
            getUserConfig().registeredForPush = true;
            SharedConfig.pushString = str;
            getUserConfig().saveConfig(false);
        }
        AndroidUtilities.runOnUIThread(new Runnable() {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$O66Zu3VGPj9Zkiek1AhtAXoTwvI */

            public final void run() {
                MessagesController.this.lambda$null$211$MessagesController();
            }
        });
    }

    public /* synthetic */ void lambda$null$211$MessagesController() {
        this.registeringForPush = false;
    }

    public void registerForUPush(String str) {
        if (!(TextUtils.isEmpty(str) || this.registeringForPush || getUserConfig().getClientUserId() == 0)) {
            if (!getUserConfig().registeredForPush || !str.equals(SharedConfig.pushString)) {
                this.registeringForPush = true;
                this.lastPushRegisterSendTime = SystemClock.elapsedRealtime();
                if (SharedConfig.pushAuthKey == null) {
                    SharedConfig.pushAuthKey = new byte[256];
                    Utilities.random.nextBytes(SharedConfig.pushAuthKey);
                    SharedConfig.saveConfig();
                }
                TLRPC.TL_account_registerDevice tL_account_registerDevice = new TLRPC.TL_account_registerDevice();
                tL_account_registerDevice.token_type = getPushDeviceType();
                tL_account_registerDevice.token = str;
                tL_account_registerDevice.no_muted = false;
                tL_account_registerDevice.secret = SharedConfig.pushAuthKey;
                for (int i = 0; i < 3; i++) {
                    UserConfig instance = UserConfig.getInstance(i);
                    if (i != this.currentAccount && instance.isClientActivated()) {
                        int clientUserId = instance.getClientUserId();
                        tL_account_registerDevice.other_uids.add(Integer.valueOf(clientUserId));
                        if (BuildVars.LOGS_ENABLED) {
                            FileLog.d("add other uid = " + clientUserId + " for account " + this.currentAccount);
                        }
                    }
                }
                getConnectionsManager().sendRequest(tL_account_registerDevice, new RequestDelegate(str) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$3c744UlFHt5sUCueA4QrTNq7KI4 */
                    private final /* synthetic */ String f$1;

                    {
                        this.f$1 = r2;
                    }

                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        MessagesController.this.lambda$registerForUPush$214$MessagesController(this.f$1, tLObject, tL_error);
                    }
                });
            }
        }
    }

    public /* synthetic */ void lambda$registerForUPush$214$MessagesController(String str, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tLObject instanceof TLRPC.TL_boolTrue) {
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("account " + this.currentAccount + " registered for push");
            }
            getUserConfig().registeredForPush = true;
            SharedConfig.pushString = str;
            getUserConfig().saveConfig(false);
        }
        AndroidUtilities.runOnUIThread(new Runnable() {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$uWu5BRHGiveEd99MVAHaQDwcPwQ */

            public final void run() {
                MessagesController.this.lambda$null$213$MessagesController();
            }
        });
    }

    public /* synthetic */ void lambda$null$213$MessagesController() {
        this.registeringForPush = false;
    }

    private int getPushDeviceType() {
        if (MryDeviceHelper.isHuawei()) {
            return 5;
        }
        if (MryDeviceHelper.isXiaomi()) {
            return 6;
        }
        return MryDeviceHelper.isOppo() ? 7 : 8;
    }

    public void loadCurrentState() {
        if (!this.updatingState) {
            this.updatingState = true;
            getConnectionsManager().sendRequest(new TLRPC.TL_updates_getState(), new RequestDelegate() {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$qSn54yyAzNnnmk0XBKbozr9ZVPk */

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$loadCurrentState$215$MessagesController(tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$loadCurrentState$215$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
        this.updatingState = false;
        if (tL_error == null) {
            TLRPC.TL_updates_state tL_updates_state = (TLRPC.TL_updates_state) tLObject;
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("loadCurrentState ===> response = " + tL_updates_state.toString());
            }
            getMessagesStorage().setLastDateValue(tL_updates_state.date);
            getMessagesStorage().setLastPtsValue(tL_updates_state.pts);
            getMessagesStorage().setLastSeqValue(tL_updates_state.seq);
            getMessagesStorage().setLastQtsValue(tL_updates_state.qts);
            for (int i = 0; i < 3; i++) {
                processUpdatesQueue(i, 2);
            }
            getMessagesStorage().saveDiffParams(getMessagesStorage().getLastSeqValue(), getMessagesStorage().getLastPtsValue(), getMessagesStorage().getLastDateValue(), getMessagesStorage().getLastQtsValue());
        } else if (tL_error.code != 401) {
            loadCurrentState();
        }
    }

    private int getUpdateSeq(TLRPC.Updates updates) {
        if (updates instanceof TLRPC.TL_updatesCombined) {
            return updates.seq_start;
        }
        return updates.seq;
    }

    private void setUpdatesStartTime(int i, long j) {
        if (i == 0) {
            this.updatesStartWaitTimeSeq = j;
        } else if (i == 1) {
            this.updatesStartWaitTimePts = j;
        } else if (i == 2) {
            this.updatesStartWaitTimeQts = j;
        }
    }

    public long getUpdatesStartTime(int i) {
        if (i == 0) {
            return this.updatesStartWaitTimeSeq;
        }
        if (i == 1) {
            return this.updatesStartWaitTimePts;
        }
        if (i == 2) {
            return this.updatesStartWaitTimeQts;
        }
        return 0;
    }

    private int isValidUpdate(TLRPC.Updates updates, int i) {
        if (i == 0) {
            int updateSeq = getUpdateSeq(updates);
            if (getMessagesStorage().getLastSeqValue() + 1 == updateSeq || getMessagesStorage().getLastSeqValue() == updateSeq) {
                return 0;
            }
            return getMessagesStorage().getLastSeqValue() < updateSeq ? 1 : 2;
        } else if (i == 1) {
            if (updates.pts <= getMessagesStorage().getLastPtsValue()) {
                return 2;
            }
            return getMessagesStorage().getLastPtsValue() + updates.pts_count == updates.pts ? 0 : 1;
        } else if (i != 2) {
            return 0;
        } else {
            if (updates.pts <= getMessagesStorage().getLastQtsValue()) {
                return 2;
            }
            return getMessagesStorage().getLastQtsValue() + updates.updates.size() == updates.pts ? 0 : 1;
        }
    }

    private void processChannelsUpdatesQueue(int i, int i2) {
        char c;
        ArrayList<TLRPC.Updates> arrayList = this.updatesQueueChannels.get(i);
        if (arrayList != null) {
            int i3 = this.channelsPts.get(i);
            if (arrayList.isEmpty() || i3 == 0) {
                this.updatesQueueChannels.remove(i);
                return;
            }
            Collections.sort(arrayList, $$Lambda$MessagesController$7alz_5Stvwpz6s8l_XW0HgvAU.INSTANCE);
            if (i2 == 2) {
                this.channelsPts.put(i, arrayList.get(0).pts);
            }
            boolean z = false;
            while (arrayList.size() > 0) {
                TLRPC.Updates updates = arrayList.get(0);
                if (updates.pts <= i3) {
                    c = 2;
                } else {
                    c = updates.pts_count + i3 == updates.pts ? (char) 0 : 1;
                }
                if (c == 0) {
                    processUpdates(updates, true);
                    arrayList.remove(0);
                    z = true;
                } else if (c == 1) {
                    long j = this.updatesStartWaitTimeChannels.get(i);
                    if (j == 0 || (!z && Math.abs(System.currentTimeMillis() - j) > 1500)) {
                        if (BuildVars.LOGS_ENABLED) {
                            FileLog.d("HOLE IN CHANNEL " + i + " UPDATES QUEUE - getChannelDifference ");
                        }
                        this.updatesStartWaitTimeChannels.delete(i);
                        this.updatesQueueChannels.remove(i);
                        getChannelDifference(i);
                        return;
                    }
                    if (BuildVars.LOGS_ENABLED) {
                        FileLog.d("HOLE IN CHANNEL " + i + " UPDATES QUEUE - will wait more time");
                    }
                    if (z) {
                        this.updatesStartWaitTimeChannels.put(i, System.currentTimeMillis());
                        return;
                    }
                    return;
                } else {
                    arrayList.remove(0);
                }
            }
            this.updatesQueueChannels.remove(i);
            this.updatesStartWaitTimeChannels.delete(i);
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("UPDATES CHANNEL " + i + " QUEUE PROCEED - OK");
            }
        }
    }

    private void processUpdatesQueue(int i, int i2) {
        ArrayList<TLRPC.Updates> arrayList;
        if (i == 0) {
            arrayList = this.updatesQueueSeq;
            Collections.sort(arrayList, new Comparator() {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$gMIGH6Lo9PvUXQBqe8c99y6HvC8 */

                @Override // java.util.Comparator
                public final int compare(Object obj, Object obj2) {
                    return MessagesController.this.lambda$processUpdatesQueue$217$MessagesController((TLRPC.Updates) obj, (TLRPC.Updates) obj2);
                }
            });
        } else if (i == 1) {
            arrayList = this.updatesQueuePts;
            Collections.sort(arrayList, $$Lambda$MessagesController$zOgkc4LiIbQP2rrzavBF9N9og.INSTANCE);
        } else if (i == 2) {
            arrayList = this.updatesQueueQts;
            Collections.sort(arrayList, $$Lambda$MessagesController$UoTaH7dTXmq2K2v4Z8STLP2E3Y.INSTANCE);
        } else {
            arrayList = null;
        }
        if (arrayList != null && !arrayList.isEmpty()) {
            if (i2 == 2) {
                TLRPC.Updates updates = arrayList.get(0);
                if (i == 0) {
                    getMessagesStorage().setLastSeqValue(getUpdateSeq(updates));
                } else if (i == 1) {
                    getMessagesStorage().setLastPtsValue(updates.pts);
                } else {
                    getMessagesStorage().setLastQtsValue(updates.pts);
                }
            }
            boolean z = false;
            while (arrayList.size() > 0) {
                TLRPC.Updates updates2 = arrayList.get(0);
                int isValidUpdate = isValidUpdate(updates2, i);
                if (isValidUpdate == 0) {
                    processUpdates(updates2, true);
                    arrayList.remove(0);
                    z = true;
                } else if (isValidUpdate != 1) {
                    arrayList.remove(0);
                } else if (getUpdatesStartTime(i) == 0 || (!z && Math.abs(System.currentTimeMillis() - getUpdatesStartTime(i)) > 1500)) {
                    if (BuildVars.LOGS_ENABLED) {
                        FileLog.d("HOLE IN UPDATES QUEUE - getDifference");
                    }
                    setUpdatesStartTime(i, 0);
                    arrayList.clear();
                    getDifference();
                    return;
                } else {
                    if (BuildVars.LOGS_ENABLED) {
                        FileLog.d("HOLE IN UPDATES QUEUE - will wait more time");
                    }
                    if (z) {
                        setUpdatesStartTime(i, System.currentTimeMillis());
                        return;
                    }
                    return;
                }
            }
            arrayList.clear();
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("UPDATES QUEUE PROCEED - OK");
            }
        }
        setUpdatesStartTime(i, 0);
    }

    public /* synthetic */ int lambda$processUpdatesQueue$217$MessagesController(TLRPC.Updates updates, TLRPC.Updates updates2) {
        return AndroidUtilities.compare(getUpdateSeq(updates), getUpdateSeq(updates2));
    }

    /* access modifiers changed from: protected */
    public void loadUnknownChannel(TLRPC.Chat chat, long j) {
        NativeByteBuffer nativeByteBuffer;
        Exception e;
        if ((chat instanceof TLRPC.TL_channel) && this.gettingUnknownChannels.indexOfKey(chat.id) < 0) {
            if (chat.access_hash != 0) {
                TLRPC.TL_inputPeerChannel tL_inputPeerChannel = new TLRPC.TL_inputPeerChannel();
                tL_inputPeerChannel.channel_id = chat.id;
                tL_inputPeerChannel.access_hash = chat.access_hash;
                this.gettingUnknownChannels.put(chat.id, true);
                TLRPC.TL_messages_getPeerDialogs tL_messages_getPeerDialogs = new TLRPC.TL_messages_getPeerDialogs();
                TLRPC.TL_inputDialogPeer tL_inputDialogPeer = new TLRPC.TL_inputDialogPeer();
                tL_inputDialogPeer.peer = tL_inputPeerChannel;
                tL_messages_getPeerDialogs.peers.add(tL_inputDialogPeer);
                if (j == 0) {
                    try {
                        nativeByteBuffer = new NativeByteBuffer(chat.getObjectSize() + 4);
                        try {
                            nativeByteBuffer.writeInt32(0);
                            chat.serializeToStream(nativeByteBuffer);
                        } catch (Exception e2) {
                            e = e2;
                        }
                    } catch (Exception e3) {
                        nativeByteBuffer = null;
                        e = e3;
                        FileLog.e(e);
                        j = getMessagesStorage().createPendingTask(nativeByteBuffer);
                        getConnectionsManager().sendRequest(tL_messages_getPeerDialogs, new RequestDelegate(j, chat) {
                            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$ooJUP6GlaiS1DaA3n8DF82En1bY */
                            private final /* synthetic */ long f$1;
                            private final /* synthetic */ TLRPC.Chat f$2;

                            {
                                this.f$1 = r2;
                                this.f$2 = r4;
                            }

                            @Override // im.guobwnxjuc.tgnet.RequestDelegate
                            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                                MessagesController.this.lambda$loadUnknownChannel$220$MessagesController(this.f$1, this.f$2, tLObject, tL_error);
                            }
                        });
                    }
                    j = getMessagesStorage().createPendingTask(nativeByteBuffer);
                }
                getConnectionsManager().sendRequest(tL_messages_getPeerDialogs, new RequestDelegate(j, chat) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$ooJUP6GlaiS1DaA3n8DF82En1bY */
                    private final /* synthetic */ long f$1;
                    private final /* synthetic */ TLRPC.Chat f$2;

                    {
                        this.f$1 = r2;
                        this.f$2 = r4;
                    }

                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        MessagesController.this.lambda$loadUnknownChannel$220$MessagesController(this.f$1, this.f$2, tLObject, tL_error);
                    }
                });
            } else if (j != 0) {
                getMessagesStorage().removePendingTask(j);
            }
        }
    }

    public /* synthetic */ void lambda$loadUnknownChannel$220$MessagesController(long j, TLRPC.Chat chat, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tLObject != null) {
            TLRPC.TL_messages_peerDialogs tL_messages_peerDialogs = (TLRPC.TL_messages_peerDialogs) tLObject;
            if (!tL_messages_peerDialogs.dialogs.isEmpty() && !tL_messages_peerDialogs.chats.isEmpty() && !(tL_messages_peerDialogs.dialogs.get(0) instanceof TLRPC.TL_dialogFolder)) {
                TLRPC.TL_messages_dialogs tL_messages_dialogs = new TLRPC.TL_messages_dialogs();
                tL_messages_dialogs.dialogs.addAll(tL_messages_peerDialogs.dialogs);
                tL_messages_dialogs.messages.addAll(tL_messages_peerDialogs.messages);
                tL_messages_dialogs.users.addAll(tL_messages_peerDialogs.users);
                tL_messages_dialogs.chats.addAll(tL_messages_peerDialogs.chats);
                processLoadedDialogs(tL_messages_dialogs, null, ((TLRPC.TL_dialog) tL_messages_peerDialogs.dialogs.get(0)).folder_id, 0, 1, this.DIALOGS_LOAD_TYPE_CHANNEL, false, false, false);
            }
        }
        if (j != 0) {
            getMessagesStorage().removePendingTask(j);
        }
        this.gettingUnknownChannels.delete(chat.id);
    }

    public void startShortPoll(TLRPC.Chat chat, boolean z) {
        Utilities.stageQueue.postRunnable(new Runnable(z, chat) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$WEW8ZvRD1ouvuTh5Bgm9eitnE */
            private final /* synthetic */ boolean f$1;
            private final /* synthetic */ TLRPC.Chat f$2;

            {
                this.f$1 = r2;
                this.f$2 = r3;
            }

            public final void run() {
                MessagesController.this.lambda$startShortPoll$221$MessagesController(this.f$1, this.f$2);
            }
        });
    }

    public /* synthetic */ void lambda$startShortPoll$221$MessagesController(boolean z, TLRPC.Chat chat) {
        if (z) {
            this.needShortPollChannels.delete(chat.id);
            if (chat.megagroup) {
                this.needShortPollOnlines.delete(chat.id);
                return;
            }
            return;
        }
        this.needShortPollChannels.put(chat.id, 0);
        if (this.shortPollChannels.indexOfKey(chat.id) < 0) {
            getChannelDifference(chat.id, 3, 0, null);
        }
        if (chat.megagroup) {
            this.needShortPollOnlines.put(chat.id, 0);
            if (this.shortPollOnlines.indexOfKey(chat.id) < 0) {
                this.shortPollOnlines.put(chat.id, 0);
            }
        }
    }

    private void getChannelDifference(int i) {
        getChannelDifference(i, 0, 0, null);
    }

    public static boolean isSupportUser(TLRPC.User user) {
        return user != null && (user.support || user.id == 777000 || user.id == 333000 || user.id == 4240000 || user.id == 4244000 || user.id == 4245000 || user.id == 4246000 || user.id == 410000 || user.id == 420000 || user.id == 431000 || user.id == 431415000 || user.id == 434000 || user.id == 4243000 || user.id == 439000 || user.id == 449000 || user.id == 450000 || user.id == 452000 || user.id == 454000 || user.id == 4254000 || user.id == 455000 || user.id == 460000 || user.id == 470000 || user.id == 479000 || user.id == 796000 || user.id == 482000 || user.id == 490000 || user.id == 496000 || user.id == 497000 || user.id == 498000 || user.id == 4298000);
    }

    /* access modifiers changed from: protected */
    /* JADX WARNING: Removed duplicated region for block: B:47:0x00b8  */
    public void getChannelDifference(int i, int i2, long j, TLRPC.InputChannel inputChannel) {
        int i3;
        TLRPC.InputChannel inputChannel2;
        NativeByteBuffer nativeByteBuffer;
        Exception e;
        long j2 = j;
        if (!this.gettingDifferenceChannels.get(i)) {
            int i4 = 100;
            boolean z = true;
            if (i2 != 1) {
                i3 = this.channelsPts.get(i);
                if (i3 == 0) {
                    i3 = getMessagesStorage().getChannelPtsSync(i);
                    if (i3 != 0) {
                        this.channelsPts.put(i, i3);
                    }
                    if (i3 == 0 && (i2 == 2 || i2 == 3)) {
                        return;
                    }
                }
                if (i3 == 0) {
                    return;
                }
            } else if (this.channelsPts.get(i) == 0) {
                i4 = 1;
                i3 = 1;
            } else {
                return;
            }
            if (inputChannel == null) {
                TLRPC.Chat chat = getChat(Integer.valueOf(i));
                if (chat == null && (chat = getMessagesStorage().getChatSync(i)) != null) {
                    putChat(chat, true);
                }
                inputChannel2 = getInputChannel(chat);
            } else {
                inputChannel2 = inputChannel;
            }
            if (inputChannel2 != null && inputChannel2.access_hash != 0) {
                if (j2 == 0) {
                    NativeByteBuffer nativeByteBuffer2 = null;
                    try {
                        nativeByteBuffer = new NativeByteBuffer(inputChannel2.getObjectSize() + 12);
                        try {
                            nativeByteBuffer.writeInt32(6);
                            nativeByteBuffer.writeInt32(i);
                            nativeByteBuffer.writeInt32(i2);
                            inputChannel2.serializeToStream(nativeByteBuffer);
                        } catch (Exception e2) {
                            e = e2;
                            nativeByteBuffer2 = nativeByteBuffer;
                        }
                    } catch (Exception e3) {
                        e = e3;
                        FileLog.e(e);
                        nativeByteBuffer = nativeByteBuffer2;
                        j2 = getMessagesStorage().createPendingTask(nativeByteBuffer);
                        this.gettingDifferenceChannels.put(i, true);
                        TLRPC.TL_updates_getChannelDifference tL_updates_getChannelDifference = new TLRPC.TL_updates_getChannelDifference();
                        tL_updates_getChannelDifference.channel = inputChannel2;
                        tL_updates_getChannelDifference.filter = new TLRPC.TL_channelMessagesFilterEmpty();
                        tL_updates_getChannelDifference.pts = i3;
                        tL_updates_getChannelDifference.limit = i4;
                        if (i2 == 3) {
                        }
                        tL_updates_getChannelDifference.force = z;
                        getConnectionsManager().sendRequest(tL_updates_getChannelDifference, new RequestDelegate(i, i2, j2) {
                            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$lEpatrb54zvVHu1J_uoOPpy_dQk */
                            private final /* synthetic */ int f$1;
                            private final /* synthetic */ int f$2;
                            private final /* synthetic */ long f$3;

                            {
                                this.f$1 = r2;
                                this.f$2 = r3;
                                this.f$3 = r4;
                            }

                            @Override // im.guobwnxjuc.tgnet.RequestDelegate
                            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                                MessagesController.this.lambda$getChannelDifference$230$MessagesController(this.f$1, this.f$2, this.f$3, tLObject, tL_error);
                            }
                        });
                    }
                    j2 = getMessagesStorage().createPendingTask(nativeByteBuffer);
                }
                this.gettingDifferenceChannels.put(i, true);
                TLRPC.TL_updates_getChannelDifference tL_updates_getChannelDifference2 = new TLRPC.TL_updates_getChannelDifference();
                tL_updates_getChannelDifference2.channel = inputChannel2;
                tL_updates_getChannelDifference2.filter = new TLRPC.TL_channelMessagesFilterEmpty();
                tL_updates_getChannelDifference2.pts = i3;
                tL_updates_getChannelDifference2.limit = i4;
                if (i2 == 3) {
                    z = false;
                }
                tL_updates_getChannelDifference2.force = z;
                getConnectionsManager().sendRequest(tL_updates_getChannelDifference2, new RequestDelegate(i, i2, j2) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$lEpatrb54zvVHu1J_uoOPpy_dQk */
                    private final /* synthetic */ int f$1;
                    private final /* synthetic */ int f$2;
                    private final /* synthetic */ long f$3;

                    {
                        this.f$1 = r2;
                        this.f$2 = r3;
                        this.f$3 = r4;
                    }

                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        MessagesController.this.lambda$getChannelDifference$230$MessagesController(this.f$1, this.f$2, this.f$3, tLObject, tL_error);
                    }
                });
            } else if (j2 != 0) {
                getMessagesStorage().removePendingTask(j2);
            }
        }
    }

    public /* synthetic */ void lambda$getChannelDifference$230$MessagesController(int i, int i2, long j, TLObject tLObject, TLRPC.TL_error tL_error) {
        TLRPC.Chat chat;
        if (tLObject != null) {
            TLRPC.updates_ChannelDifference updates_channeldifference = (TLRPC.updates_ChannelDifference) tLObject;
            SparseArray sparseArray = new SparseArray();
            int i3 = 0;
            for (int i4 = 0; i4 < updates_channeldifference.users.size(); i4++) {
                TLRPC.User user = updates_channeldifference.users.get(i4);
                sparseArray.put(user.id, user);
            }
            int i5 = 0;
            while (true) {
                if (i5 >= updates_channeldifference.chats.size()) {
                    chat = null;
                    break;
                }
                chat = updates_channeldifference.chats.get(i5);
                if (chat.id == i) {
                    break;
                }
                i5++;
            }
            ArrayList arrayList = new ArrayList();
            if (!updates_channeldifference.other_updates.isEmpty()) {
                while (i3 < updates_channeldifference.other_updates.size()) {
                    TLRPC.Update update = updates_channeldifference.other_updates.get(i3);
                    if (update instanceof TLRPC.TL_updateMessageID) {
                        arrayList.add((TLRPC.TL_updateMessageID) update);
                        updates_channeldifference.other_updates.remove(i3);
                        i3--;
                    }
                    i3++;
                }
            }
            getMessagesStorage().putUsersAndChats(updates_channeldifference.users, updates_channeldifference.chats, true, true);
            AndroidUtilities.runOnUIThread(new Runnable(updates_channeldifference) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$GB56997xRpXWuVhcbWCsJsWNz7w */
                private final /* synthetic */ TLRPC.updates_ChannelDifference f$1;

                {
                    this.f$1 = r2;
                }

                public final void run() {
                    MessagesController.this.lambda$null$222$MessagesController(this.f$1);
                }
            });
            getMessagesStorage().getStorageQueue().postRunnable(new Runnable(arrayList, i, updates_channeldifference, chat, sparseArray, i2, j) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$cmJIUNW62j3jy3_vt2YU5AQAoow */
                private final /* synthetic */ ArrayList f$1;
                private final /* synthetic */ int f$2;
                private final /* synthetic */ TLRPC.updates_ChannelDifference f$3;
                private final /* synthetic */ TLRPC.Chat f$4;
                private final /* synthetic */ SparseArray f$5;
                private final /* synthetic */ int f$6;
                private final /* synthetic */ long f$7;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                    this.f$3 = r4;
                    this.f$4 = r5;
                    this.f$5 = r6;
                    this.f$6 = r7;
                    this.f$7 = r8;
                }

                public final void run() {
                    MessagesController.this.lambda$null$228$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6, this.f$7);
                }
            });
        } else if (tL_error != null) {
            AndroidUtilities.runOnUIThread(new Runnable(tL_error, i) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$1cyPxcis0L1qfiIju574wQFe0jU */
                private final /* synthetic */ TLRPC.TL_error f$1;
                private final /* synthetic */ int f$2;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                }

                public final void run() {
                    MessagesController.this.lambda$null$229$MessagesController(this.f$1, this.f$2);
                }
            });
            this.gettingDifferenceChannels.delete(i);
            if (j != 0) {
                getMessagesStorage().removePendingTask(j);
            }
        }
    }

    public /* synthetic */ void lambda$null$222$MessagesController(TLRPC.updates_ChannelDifference updates_channeldifference) {
        putUsers(updates_channeldifference.users, false);
        putChats(updates_channeldifference.chats, false);
    }

    public /* synthetic */ void lambda$null$228$MessagesController(ArrayList arrayList, int i, TLRPC.updates_ChannelDifference updates_channeldifference, TLRPC.Chat chat, SparseArray sparseArray, int i2, long j) {
        if (!arrayList.isEmpty()) {
            SparseArray sparseArray2 = new SparseArray();
            Iterator it = arrayList.iterator();
            while (it.hasNext()) {
                TLRPC.TL_updateMessageID tL_updateMessageID = (TLRPC.TL_updateMessageID) it.next();
                long[] updateMessageStateAndId = getMessagesStorage().updateMessageStateAndId(tL_updateMessageID.random_id, null, tL_updateMessageID.id, 0, false, i, -1);
                if (updateMessageStateAndId != null) {
                    sparseArray2.put(tL_updateMessageID.id, updateMessageStateAndId);
                }
            }
            if (sparseArray2.size() != 0) {
                AndroidUtilities.runOnUIThread(new Runnable(sparseArray2) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$7IvDNqzYnNVpHaakL5SLk3joas */
                    private final /* synthetic */ SparseArray f$1;

                    {
                        this.f$1 = r2;
                    }

                    public final void run() {
                        MessagesController.this.lambda$null$223$MessagesController(this.f$1);
                    }
                });
                Utilities.stageQueue.postRunnable(new Runnable(updates_channeldifference, i, chat, sparseArray, i2, j) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$1C9nDnfRH8ok8skDuEFpECaEF2Q */
                    private final /* synthetic */ TLRPC.updates_ChannelDifference f$1;
                    private final /* synthetic */ int f$2;
                    private final /* synthetic */ TLRPC.Chat f$3;
                    private final /* synthetic */ SparseArray f$4;
                    private final /* synthetic */ int f$5;
                    private final /* synthetic */ long f$6;

                    {
                        this.f$1 = r2;
                        this.f$2 = r3;
                        this.f$3 = r4;
                        this.f$4 = r5;
                        this.f$5 = r6;
                        this.f$6 = r7;
                    }

                    public final void run() {
                        MessagesController.this.lambda$null$227$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6);
                    }
                });
            }
        }
        Utilities.stageQueue.postRunnable(new Runnable(updates_channeldifference, i, chat, sparseArray, i2, j) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$1C9nDnfRH8ok8skDuEFpECaEF2Q */
            private final /* synthetic */ TLRPC.updates_ChannelDifference f$1;
            private final /* synthetic */ int f$2;
            private final /* synthetic */ TLRPC.Chat f$3;
            private final /* synthetic */ SparseArray f$4;
            private final /* synthetic */ int f$5;
            private final /* synthetic */ long f$6;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
                this.f$4 = r5;
                this.f$5 = r6;
                this.f$6 = r7;
            }

            public final void run() {
                MessagesController.this.lambda$null$227$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6);
            }
        });
    }

    public /* synthetic */ void lambda$null$223$MessagesController(SparseArray sparseArray) {
        for (int i = 0; i < sparseArray.size(); i++) {
            int keyAt = sparseArray.keyAt(i);
            long[] jArr = (long[]) sparseArray.valueAt(i);
            int i2 = (int) jArr[1];
            getSendMessagesHelper().processSentMessage(i2);
            getNotificationCenter().postNotificationName(NotificationCenter.messageReceivedByServer, Integer.valueOf(i2), Integer.valueOf(keyAt), null, Long.valueOf(jArr[0]), 0L, -1, false);
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:100:0x018f A[SYNTHETIC] */
    /* JADX WARNING: Removed duplicated region for block: B:75:0x0187  */
    public /* synthetic */ void lambda$null$227$MessagesController(TLRPC.updates_ChannelDifference updates_channeldifference, int i, TLRPC.Chat chat, SparseArray sparseArray, int i2, long j) {
        boolean z;
        MessageObject messageObject;
        ArrayList arrayList;
        boolean z2;
        TLRPC.Chat chat2 = chat;
        if ((updates_channeldifference instanceof TLRPC.TL_updates_channelDifference) || (updates_channeldifference instanceof TLRPC.TL_updates_channelDifferenceEmpty)) {
            if (!updates_channeldifference.new_messages.isEmpty()) {
                LongSparseArray longSparseArray = new LongSparseArray();
                ImageLoader.saveMessagesThumbs(updates_channeldifference.new_messages);
                ArrayList arrayList2 = new ArrayList();
                long j2 = (long) (-i);
                Integer num = this.dialogs_read_inbox_max.get(Long.valueOf(j2));
                if (num == null) {
                    num = Integer.valueOf(getMessagesStorage().getDialogReadMax(false, j2));
                    this.dialogs_read_inbox_max.put(Long.valueOf(j2), num);
                }
                Integer num2 = this.dialogs_read_outbox_max.get(Long.valueOf(j2));
                if (num2 == null) {
                    num2 = Integer.valueOf(getMessagesStorage().getDialogReadMax(true, j2));
                    this.dialogs_read_outbox_max.put(Long.valueOf(j2), num2);
                }
                int i3 = 0;
                while (i3 < updates_channeldifference.new_messages.size()) {
                    TLRPC.Message message = updates_channeldifference.new_messages.get(i3);
                    if (chat2 == null || !chat2.left) {
                        if ((message.out ? num2 : num).intValue() < message.id && !(message.action instanceof TLRPC.TL_messageActionChannelCreate)) {
                            z = true;
                            message.unread = z;
                            if (chat2 == null && chat2.megagroup) {
                                message.flags |= Integer.MIN_VALUE;
                            }
                            messageObject = new MessageObject(this.currentAccount, message, sparseArray, this.createdDialogIds.contains(Long.valueOf(j2)));
                            if ((!messageObject.isOut() || messageObject.messageOwner.from_scheduled) && messageObject.isUnread()) {
                                arrayList2.add(messageObject);
                            }
                            arrayList = (ArrayList) longSparseArray.get(j2);
                            if (arrayList != null) {
                                arrayList = new ArrayList();
                                longSparseArray.put(j2, arrayList);
                            }
                            arrayList.add(messageObject);
                            i3++;
                            chat2 = chat;
                            num = num;
                        }
                    }
                    z = false;
                    message.unread = z;
                    if (chat2 == null) {
                    }
                    messageObject = new MessageObject(this.currentAccount, message, sparseArray, this.createdDialogIds.contains(Long.valueOf(j2)));
                    arrayList2.add(messageObject);
                    arrayList = (ArrayList) longSparseArray.get(j2);
                    if (arrayList != null) {
                    }
                    arrayList.add(messageObject);
                    i3++;
                    chat2 = chat;
                    num = num;
                }
                AndroidUtilities.runOnUIThread(new Runnable(longSparseArray) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$RLCJWAQN4jvCKEh9qmgDxFzsYY */
                    private final /* synthetic */ LongSparseArray f$1;

                    {
                        this.f$1 = r2;
                    }

                    public final void run() {
                        MessagesController.this.lambda$null$224$MessagesController(this.f$1);
                    }
                });
                getMessagesStorage().getStorageQueue().postRunnable(new Runnable(arrayList2, updates_channeldifference) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$vnDc_n9Y4Dms4GnsQR5BChVsoOs */
                    private final /* synthetic */ ArrayList f$1;
                    private final /* synthetic */ TLRPC.updates_ChannelDifference f$2;

                    {
                        this.f$1 = r2;
                        this.f$2 = r3;
                    }

                    public final void run() {
                        MessagesController.this.lambda$null$226$MessagesController(this.f$1, this.f$2);
                    }
                });
            }
            if (!updates_channeldifference.other_updates.isEmpty()) {
                processUpdateArray(updates_channeldifference.other_updates, updates_channeldifference.users, updates_channeldifference.chats, true, 0);
            }
            processChannelsUpdatesQueue(i, 1);
            getMessagesStorage().saveChannelPts(i, updates_channeldifference.pts);
        } else if (updates_channeldifference instanceof TLRPC.TL_updates_channelDifferenceTooLong) {
            long j3 = (long) (-i);
            Integer num3 = this.dialogs_read_inbox_max.get(Long.valueOf(j3));
            if (num3 == null) {
                num3 = Integer.valueOf(getMessagesStorage().getDialogReadMax(false, j3));
                this.dialogs_read_inbox_max.put(Long.valueOf(j3), num3);
            }
            Integer num4 = this.dialogs_read_outbox_max.get(Long.valueOf(j3));
            if (num4 == null) {
                num4 = Integer.valueOf(getMessagesStorage().getDialogReadMax(true, j3));
                this.dialogs_read_outbox_max.put(Long.valueOf(j3), num4);
            }
            for (int i4 = 0; i4 < updates_channeldifference.messages.size(); i4++) {
                TLRPC.Message message2 = updates_channeldifference.messages.get(i4);
                message2.dialog_id = j3;
                if (!(message2.action instanceof TLRPC.TL_messageActionChannelCreate) && (chat2 == null || !chat2.left)) {
                    if ((message2.out ? num4 : num3).intValue() < message2.id) {
                        z2 = true;
                        message2.unread = z2;
                        if (chat2 != null && chat2.megagroup) {
                            message2.flags |= Integer.MIN_VALUE;
                        }
                    }
                }
                z2 = false;
                message2.unread = z2;
                message2.flags |= Integer.MIN_VALUE;
            }
            getMessagesStorage().overwriteChannel(i, (TLRPC.TL_updates_channelDifferenceTooLong) updates_channeldifference, i2);
        }
        this.gettingDifferenceChannels.delete(i);
        this.channelsPts.put(i, updates_channeldifference.pts);
        if ((updates_channeldifference.flags & 2) != 0) {
            this.shortPollChannels.put(i, ((int) (System.currentTimeMillis() / 1000)) + updates_channeldifference.timeout);
        }
        if (!updates_channeldifference.isFinal) {
            getChannelDifference(i);
        }
        if (BuildVars.LOGS_ENABLED) {
            FileLog.d("received channel difference with pts = " + updates_channeldifference.pts + " channelId = " + i);
        }
        if (j != 0) {
            getMessagesStorage().removePendingTask(j);
        }
    }

    public /* synthetic */ void lambda$null$224$MessagesController(LongSparseArray longSparseArray) {
        for (int i = 0; i < longSparseArray.size(); i++) {
            updateInterfaceWithMessages(longSparseArray.keyAt(i), (ArrayList) longSparseArray.valueAt(i), false);
        }
        getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
    }

    public /* synthetic */ void lambda$null$226$MessagesController(ArrayList arrayList, TLRPC.updates_ChannelDifference updates_channeldifference) {
        if (!arrayList.isEmpty()) {
            AndroidUtilities.runOnUIThread(new Runnable(arrayList) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$YMuw3bgC4T9VaexR0kjSJUVJeoQ */
                private final /* synthetic */ ArrayList f$1;

                {
                    this.f$1 = r2;
                }

                public final void run() {
                    MessagesController.this.lambda$null$225$MessagesController(this.f$1);
                }
            });
        }
        getMessagesStorage().putMessages(updates_channeldifference.new_messages, true, true, false, getDownloadController().getAutodownloadMask(), false);
    }

    public /* synthetic */ void lambda$null$225$MessagesController(ArrayList arrayList) {
        getNotificationsController().processNewMessages(arrayList, true, false, null);
    }

    public /* synthetic */ void lambda$null$229$MessagesController(TLRPC.TL_error tL_error, int i) {
        checkChannelError(tL_error.text, i);
    }

    /* JADX WARNING: Removed duplicated region for block: B:17:0x0038  */
    /* JADX WARNING: Removed duplicated region for block: B:21:0x006d  */
    private void checkChannelError(String str, int i) {
        char c;
        int hashCode = str.hashCode();
        if (hashCode != -1809401834) {
            if (hashCode != -795226617) {
                if (hashCode == -471086771 && str.equals("CHANNEL_PUBLIC_GROUP_NA")) {
                    c = 1;
                    if (c != 0) {
                        getNotificationCenter().postNotificationName(NotificationCenter.chatInfoCantLoad, Integer.valueOf(i), 0);
                        return;
                    } else if (c == 1) {
                        getNotificationCenter().postNotificationName(NotificationCenter.chatInfoCantLoad, Integer.valueOf(i), 1);
                        return;
                    } else if (c == 2) {
                        getNotificationCenter().postNotificationName(NotificationCenter.chatInfoCantLoad, Integer.valueOf(i), 2);
                        return;
                    } else {
                        return;
                    }
                }
            } else if (str.equals("CHANNEL_PRIVATE")) {
                c = 0;
                if (c != 0) {
                }
            }
        } else if (str.equals("USER_BANNED_IN_CHANNEL")) {
            c = 2;
            if (c != 0) {
            }
        }
        c = 65535;
        if (c != 0) {
        }
    }

    public void getDifference() {
        getDifference(getMessagesStorage().getLastPtsValue(), getMessagesStorage().getLastDateValue(), getMessagesStorage().getLastQtsValue(), false);
    }

    public void getDifference(int i, int i2, int i3, boolean z) {
        registerForPush(SharedConfig.pushString);
        if (getMessagesStorage().getLastPtsValue() == 0) {
            loadCurrentState();
        } else if (z || !this.gettingDifference) {
            this.gettingDifference = true;
            TLRPC.TL_updates_getDifference tL_updates_getDifference = new TLRPC.TL_updates_getDifference();
            tL_updates_getDifference.pts = i;
            tL_updates_getDifference.date = i2;
            tL_updates_getDifference.qts = i3;
            if (this.getDifferenceFirstSync) {
                tL_updates_getDifference.flags |= 1;
                if (ApplicationLoader.isConnectedOrConnectingToWiFi()) {
                    tL_updates_getDifference.pts_total_limit = 5000;
                } else {
                    tL_updates_getDifference.pts_total_limit = 1000;
                }
                this.getDifferenceFirstSync = false;
            }
            if (tL_updates_getDifference.date == 0) {
                tL_updates_getDifference.date = getConnectionsManager().getCurrentTime();
            }
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("getDiff start ===> act=" + this.currentAccount + " ,date=" + i2 + " ,pts=" + i + " ,qts=" + i3);
            }
            getConnectionsManager().setIsUpdating(true);
            getConnectionsManager().sendRequest(tL_updates_getDifference, new RequestDelegate(i2, i3) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$w9Zj2B93txHch5FttdOw70AGcY */
                private final /* synthetic */ int f$1;
                private final /* synthetic */ int f$2;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$getDifference$239$MessagesController(this.f$1, this.f$2, tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$getDifference$239$MessagesController(int i, int i2, TLObject tLObject, TLRPC.TL_error tL_error) {
        int i3 = 0;
        if (tL_error == null) {
            TLRPC.updates_Difference updates_difference = (TLRPC.updates_Difference) tLObject;
            if (BuildVars.DEBUG_VERSION) {
                FileLog.d("getDiff success ===> act=" + this.currentAccount + " ,date=" + i + " ,res=" + updates_difference.toString());
            }
            if (updates_difference instanceof TLRPC.TL_updates_differenceTooLong) {
                AndroidUtilities.runOnUIThread(new Runnable(updates_difference, i, i2) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$sfzxp1v74yUXU_AGmRBlS68ksgQ */
                    private final /* synthetic */ TLRPC.updates_Difference f$1;
                    private final /* synthetic */ int f$2;
                    private final /* synthetic */ int f$3;

                    {
                        this.f$1 = r2;
                        this.f$2 = r3;
                        this.f$3 = r4;
                    }

                    public final void run() {
                        MessagesController.this.lambda$null$231$MessagesController(this.f$1, this.f$2, this.f$3);
                    }
                });
                return;
            }
            if (updates_difference instanceof TLRPC.TL_updates_differenceSlice) {
                getDifference(updates_difference.intermediate_state.pts, updates_difference.intermediate_state.date, updates_difference.intermediate_state.qts, true);
            }
            SparseArray sparseArray = new SparseArray();
            SparseArray sparseArray2 = new SparseArray();
            for (int i4 = 0; i4 < updates_difference.users.size(); i4++) {
                TLRPC.User user = updates_difference.users.get(i4);
                sparseArray.put(user.id, user);
            }
            for (int i5 = 0; i5 < updates_difference.chats.size(); i5++) {
                TLRPC.Chat chat = updates_difference.chats.get(i5);
                sparseArray2.put(chat.id, chat);
            }
            ArrayList arrayList = new ArrayList();
            if (!updates_difference.other_updates.isEmpty()) {
                while (i3 < updates_difference.other_updates.size()) {
                    TLRPC.Update update = updates_difference.other_updates.get(i3);
                    if (update instanceof TLRPC.TL_updateMessageID) {
                        arrayList.add((TLRPC.TL_updateMessageID) update);
                        updates_difference.other_updates.remove(i3);
                    } else {
                        if (getUpdateType(update) == 2) {
                            int updateChannelId = getUpdateChannelId(update);
                            int i6 = this.channelsPts.get(updateChannelId);
                            if (i6 == 0 && (i6 = getMessagesStorage().getChannelPtsSync(updateChannelId)) != 0) {
                                this.channelsPts.put(updateChannelId, i6);
                            }
                            if (i6 != 0 && getUpdatePts(update) <= i6) {
                                updates_difference.other_updates.remove(i3);
                            }
                        }
                        i3++;
                    }
                    i3--;
                    i3++;
                }
            }
            AndroidUtilities.runOnUIThread(new Runnable(updates_difference) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$F4ovTd7oP_xXC9qQLmVD3Qv3U */
                private final /* synthetic */ TLRPC.updates_Difference f$1;

                {
                    this.f$1 = r2;
                }

                public final void run() {
                    MessagesController.this.lambda$null$232$MessagesController(this.f$1);
                }
            });
            getMessagesStorage().getStorageQueue().postRunnable(new Runnable(updates_difference, arrayList, sparseArray, sparseArray2) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$tgaiCBpkheeXi9VF8aEfxuVwlgw */
                private final /* synthetic */ TLRPC.updates_Difference f$1;
                private final /* synthetic */ ArrayList f$2;
                private final /* synthetic */ SparseArray f$3;
                private final /* synthetic */ SparseArray f$4;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                    this.f$3 = r4;
                    this.f$4 = r5;
                }

                public final void run() {
                    MessagesController.this.lambda$null$238$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4);
                }
            });
            return;
        }
        this.gettingDifference = false;
        getConnectionsManager().setIsUpdating(false);
    }

    public /* synthetic */ void lambda$null$231$MessagesController(TLRPC.updates_Difference updates_difference, int i, int i2) {
        this.loadedFullUsers.clear();
        this.loadedFullChats.clear();
        resetDialogs(true, getMessagesStorage().getLastSeqValue(), updates_difference.pts, i, i2);
    }

    public /* synthetic */ void lambda$null$232$MessagesController(TLRPC.updates_Difference updates_difference) {
        this.loadedFullUsers.clear();
        this.loadedFullChats.clear();
        putUsers(updates_difference.users, false);
        putChats(updates_difference.chats, false);
    }

    public /* synthetic */ void lambda$null$238$MessagesController(TLRPC.updates_Difference updates_difference, ArrayList arrayList, SparseArray sparseArray, SparseArray sparseArray2) {
        getMessagesStorage().putUsersAndChats(updates_difference.users, updates_difference.chats, true, false);
        if (!arrayList.isEmpty()) {
            SparseArray sparseArray3 = new SparseArray();
            for (int i = 0; i < arrayList.size(); i++) {
                TLRPC.TL_updateMessageID tL_updateMessageID = (TLRPC.TL_updateMessageID) arrayList.get(i);
                long[] updateMessageStateAndId = getMessagesStorage().updateMessageStateAndId(tL_updateMessageID.random_id, null, tL_updateMessageID.id, 0, false, 0, -1);
                if (updateMessageStateAndId != null) {
                    sparseArray3.put(tL_updateMessageID.id, updateMessageStateAndId);
                }
            }
            if (sparseArray3.size() != 0) {
                AndroidUtilities.runOnUIThread(new Runnable(sparseArray3) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$wkSjpxHJhVZTcZngdS1W67tmiQ */
                    private final /* synthetic */ SparseArray f$1;

                    {
                        this.f$1 = r2;
                    }

                    public final void run() {
                        MessagesController.this.lambda$null$233$MessagesController(this.f$1);
                    }
                });
            }
        }
        Utilities.stageQueue.postRunnable(new Runnable(updates_difference, sparseArray, sparseArray2) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$RxgXvs6vbP8Sf1UYY_2kYqC1hF8 */
            private final /* synthetic */ TLRPC.updates_Difference f$1;
            private final /* synthetic */ SparseArray f$2;
            private final /* synthetic */ SparseArray f$3;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
            }

            public final void run() {
                MessagesController.this.lambda$null$237$MessagesController(this.f$1, this.f$2, this.f$3);
            }
        });
    }

    public /* synthetic */ void lambda$null$233$MessagesController(SparseArray sparseArray) {
        for (int i = 0; i < sparseArray.size(); i++) {
            int keyAt = sparseArray.keyAt(i);
            long[] jArr = (long[]) sparseArray.valueAt(i);
            int i2 = (int) jArr[1];
            getSendMessagesHelper().processSentMessage(i2);
            getNotificationCenter().postNotificationName(NotificationCenter.messageReceivedByServer, Integer.valueOf(i2), Integer.valueOf(keyAt), null, Long.valueOf(jArr[0]), 0L, -1, false);
        }
    }

    public /* synthetic */ void lambda$null$237$MessagesController(TLRPC.updates_Difference updates_difference, SparseArray sparseArray, SparseArray sparseArray2) {
        int i = 0;
        if (!updates_difference.new_messages.isEmpty() || !updates_difference.new_encrypted_messages.isEmpty()) {
            LongSparseArray longSparseArray = new LongSparseArray();
            for (int i2 = 0; i2 < updates_difference.new_encrypted_messages.size(); i2++) {
                ArrayList<TLRPC.Message> decryptMessage = getSecretChatHelper().decryptMessage(updates_difference.new_encrypted_messages.get(i2));
                if (decryptMessage != null && !decryptMessage.isEmpty()) {
                    updates_difference.new_messages.addAll(decryptMessage);
                }
            }
            ImageLoader.saveMessagesThumbs(updates_difference.new_messages);
            ArrayList arrayList = new ArrayList();
            int clientUserId = getUserConfig().getClientUserId();
            for (int i3 = 0; i3 < updates_difference.new_messages.size(); i3++) {
                TLRPC.Message message = updates_difference.new_messages.get(i3);
                if (message.dialog_id == 0) {
                    if (message.to_id.chat_id != 0) {
                        message.dialog_id = (long) (-message.to_id.chat_id);
                    } else {
                        if (message.to_id.user_id == getUserConfig().getClientUserId()) {
                            message.to_id.user_id = message.from_id;
                        }
                        message.dialog_id = (long) message.to_id.user_id;
                    }
                }
                if (((int) message.dialog_id) != 0) {
                    if (message.action instanceof TLRPC.TL_messageActionChatDeleteUser) {
                        TLRPC.User user = (TLRPC.User) sparseArray.get(message.action.user_id);
                        if (user != null && user.bot) {
                            message.reply_markup = new TLRPC.TL_replyKeyboardHide();
                            message.flags |= 64;
                        }
                    }
                    if ((message.action instanceof TLRPC.TL_messageActionChatMigrateTo) || (message.action instanceof TLRPC.TL_messageActionChannelCreate)) {
                        message.unread = false;
                        message.media_unread = false;
                    } else {
                        ConcurrentHashMap<Long, Integer> concurrentHashMap = message.out ? this.dialogs_read_outbox_max : this.dialogs_read_inbox_max;
                        Integer num = concurrentHashMap.get(Long.valueOf(message.dialog_id));
                        if (num == null) {
                            num = Integer.valueOf(getMessagesStorage().getDialogReadMax(message.out, message.dialog_id));
                            concurrentHashMap.put(Long.valueOf(message.dialog_id), num);
                        }
                        message.unread = num.intValue() < message.id;
                    }
                }
                if (message.dialog_id == ((long) clientUserId)) {
                    message.unread = false;
                    message.media_unread = false;
                    message.out = true;
                }
                MessageObject messageObject = new MessageObject(this.currentAccount, message, sparseArray, sparseArray2, this.createdDialogIds.contains(Long.valueOf(message.dialog_id)));
                if ((!messageObject.isOut() || messageObject.messageOwner.from_scheduled) && messageObject.isUnread()) {
                    arrayList.add(messageObject);
                }
                ArrayList arrayList2 = (ArrayList) longSparseArray.get(message.dialog_id);
                if (arrayList2 == null) {
                    arrayList2 = new ArrayList();
                    longSparseArray.put(message.dialog_id, arrayList2);
                }
                arrayList2.add(messageObject);
            }
            AndroidUtilities.runOnUIThread(new Runnable(longSparseArray) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$tpyB_AOX09o88cOeDbmtWwThfnA */
                private final /* synthetic */ LongSparseArray f$1;

                {
                    this.f$1 = r2;
                }

                public final void run() {
                    MessagesController.this.lambda$null$234$MessagesController(this.f$1);
                }
            });
            getMessagesStorage().getStorageQueue().postRunnable(new Runnable(arrayList, updates_difference) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$gC26j8dFfJ1jTTzRntwjp8Ita4 */
                private final /* synthetic */ ArrayList f$1;
                private final /* synthetic */ TLRPC.updates_Difference f$2;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                }

                public final void run() {
                    MessagesController.this.lambda$null$236$MessagesController(this.f$1, this.f$2);
                }
            });
            getSecretChatHelper().processPendingEncMessages();
        }
        if (!updates_difference.other_updates.isEmpty()) {
            processUpdateArray(updates_difference.other_updates, updates_difference.users, updates_difference.chats, true, 0);
        }
        if (updates_difference instanceof TLRPC.TL_updates_difference) {
            this.gettingDifference = false;
            getMessagesStorage().setLastSeqValue(updates_difference.state.seq);
            getMessagesStorage().setLastDateValue(updates_difference.state.date);
            getMessagesStorage().setLastPtsValue(updates_difference.state.pts);
            getMessagesStorage().setLastQtsValue(updates_difference.state.qts);
            getConnectionsManager().setIsUpdating(false);
            while (i < 3) {
                processUpdatesQueue(i, 1);
                i++;
            }
        } else if (updates_difference instanceof TLRPC.TL_updates_differenceSlice) {
            getMessagesStorage().setLastDateValue(updates_difference.intermediate_state.date);
            getMessagesStorage().setLastPtsValue(updates_difference.intermediate_state.pts);
            getMessagesStorage().setLastQtsValue(updates_difference.intermediate_state.qts);
        } else if (updates_difference instanceof TLRPC.TL_updates_differenceEmpty) {
            this.gettingDifference = false;
            getMessagesStorage().setLastSeqValue(updates_difference.seq);
            getMessagesStorage().setLastDateValue(updates_difference.date);
            getConnectionsManager().setIsUpdating(false);
            while (i < 3) {
                processUpdatesQueue(i, 1);
                i++;
            }
        }
        getMessagesStorage().saveDiffParams(getMessagesStorage().getLastSeqValue(), getMessagesStorage().getLastPtsValue(), getMessagesStorage().getLastDateValue(), getMessagesStorage().getLastQtsValue());
        if (BuildVars.LOGS_ENABLED) {
            FileLog.d("getDiff save last diff value ===> act=" + this.currentAccount + " ,date=" + getMessagesStorage().getLastDateValue() + " ,pts=" + getMessagesStorage().getLastPtsValue() + " ,seq=" + getMessagesStorage().getLastSeqValue() + " ,qts=" + getMessagesStorage().getLastQtsValue());
        }
    }

    public /* synthetic */ void lambda$null$234$MessagesController(LongSparseArray longSparseArray) {
        for (int i = 0; i < longSparseArray.size(); i++) {
            updateInterfaceWithMessages(longSparseArray.keyAt(i), (ArrayList) longSparseArray.valueAt(i), false);
        }
        getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
    }

    public /* synthetic */ void lambda$null$236$MessagesController(ArrayList arrayList, TLRPC.updates_Difference updates_difference) {
        if (!arrayList.isEmpty()) {
            AndroidUtilities.runOnUIThread(new Runnable(arrayList, updates_difference) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$dX7r_ucF5DTBzRvHJ5QYPzZAsM */
                private final /* synthetic */ ArrayList f$1;
                private final /* synthetic */ TLRPC.updates_Difference f$2;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                }

                public final void run() {
                    MessagesController.this.lambda$null$235$MessagesController(this.f$1, this.f$2);
                }
            });
        }
        getMessagesStorage().putMessages(updates_difference.new_messages, true, true, false, getDownloadController().getAutodownloadMask(), false);
    }

    public /* synthetic */ void lambda$null$235$MessagesController(ArrayList arrayList, TLRPC.updates_Difference updates_difference) {
        getNotificationsController().processNewMessages(arrayList, !(updates_difference instanceof TLRPC.TL_updates_differenceSlice), false, null);
    }

    public void markDialogAsUnread(long j, TLRPC.InputPeer inputPeer, long j2) {
        NativeByteBuffer nativeByteBuffer;
        Exception e;
        TLRPC.Dialog dialog = this.dialogs_dict.get(j);
        if (dialog != null) {
            dialog.unread_mark = true;
            if (dialog.unread_count == 0) {
                this.dialogsUnreadOnly.add(dialog);
                if (!isDialogMuted(j)) {
                    this.unreadUnmutedDialogs++;
                }
            }
            getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 256);
            getMessagesStorage().setDialogUnread(j, true);
        }
        int i = (int) j;
        if (i != 0) {
            TLRPC.TL_messages_markDialogUnread tL_messages_markDialogUnread = new TLRPC.TL_messages_markDialogUnread();
            tL_messages_markDialogUnread.unread = true;
            if (inputPeer == null) {
                inputPeer = getInputPeer(i);
            }
            if (!(inputPeer instanceof TLRPC.TL_inputPeerEmpty)) {
                TLRPC.TL_inputDialogPeer tL_inputDialogPeer = new TLRPC.TL_inputDialogPeer();
                tL_inputDialogPeer.peer = inputPeer;
                tL_messages_markDialogUnread.peer = tL_inputDialogPeer;
                if (j2 == 0) {
                    NativeByteBuffer nativeByteBuffer2 = null;
                    try {
                        nativeByteBuffer = new NativeByteBuffer(inputPeer.getObjectSize() + 12);
                        try {
                            nativeByteBuffer.writeInt32(9);
                            nativeByteBuffer.writeInt64(j);
                            inputPeer.serializeToStream(nativeByteBuffer);
                        } catch (Exception e2) {
                            e = e2;
                            nativeByteBuffer2 = nativeByteBuffer;
                        }
                    } catch (Exception e3) {
                        e = e3;
                        FileLog.e(e);
                        nativeByteBuffer = nativeByteBuffer2;
                        j2 = getMessagesStorage().createPendingTask(nativeByteBuffer);
                        getConnectionsManager().sendRequest(tL_messages_markDialogUnread, new RequestDelegate(j2) {
                            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$LLvHhrdg6Xpaac17qU16iZA48Hg */
                            private final /* synthetic */ long f$1;

                            {
                                this.f$1 = r2;
                            }

                            @Override // im.guobwnxjuc.tgnet.RequestDelegate
                            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                                MessagesController.this.lambda$markDialogAsUnread$240$MessagesController(this.f$1, tLObject, tL_error);
                            }
                        });
                    }
                    j2 = getMessagesStorage().createPendingTask(nativeByteBuffer);
                }
                getConnectionsManager().sendRequest(tL_messages_markDialogUnread, new RequestDelegate(j2) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$LLvHhrdg6Xpaac17qU16iZA48Hg */
                    private final /* synthetic */ long f$1;

                    {
                        this.f$1 = r2;
                    }

                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        MessagesController.this.lambda$markDialogAsUnread$240$MessagesController(this.f$1, tLObject, tL_error);
                    }
                });
            }
        }
    }

    public /* synthetic */ void lambda$markDialogAsUnread$240$MessagesController(long j, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (j != 0) {
            getMessagesStorage().removePendingTask(j);
        }
    }

    public void loadUnreadDialogs() {
        if (!this.loadingUnreadDialogs && !getUserConfig().unreadDialogsLoaded) {
            this.loadingUnreadDialogs = true;
            getConnectionsManager().sendRequest(new TLRPC.TL_messages_getDialogUnreadMarks(), new RequestDelegate() {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$COkNI4remfxgwsqB7xGB45yYLE */

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$loadUnreadDialogs$242$MessagesController(tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$loadUnreadDialogs$242$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable(tLObject) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$bfWGPj5Rnv5FuCGp3WNl_RAnc */
            private final /* synthetic */ TLObject f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                MessagesController.this.lambda$null$241$MessagesController(this.f$1);
            }
        });
    }

    public /* synthetic */ void lambda$null$241$MessagesController(TLObject tLObject) {
        long j;
        int i;
        int i2;
        if (tLObject != null) {
            TLRPC.Vector vector = (TLRPC.Vector) tLObject;
            int size = vector.objects.size();
            for (int i3 = 0; i3 < size; i3++) {
                TLRPC.DialogPeer dialogPeer = (TLRPC.DialogPeer) vector.objects.get(i3);
                if (dialogPeer instanceof TLRPC.TL_dialogPeer) {
                    TLRPC.TL_dialogPeer tL_dialogPeer = (TLRPC.TL_dialogPeer) dialogPeer;
                    if (tL_dialogPeer.peer.user_id != 0) {
                        if (tL_dialogPeer.peer.user_id != 0) {
                            i2 = tL_dialogPeer.peer.user_id;
                        } else {
                            if (tL_dialogPeer.peer.chat_id != 0) {
                                i = tL_dialogPeer.peer.chat_id;
                            } else {
                                i = tL_dialogPeer.peer.channel_id;
                            }
                            i2 = -i;
                        }
                        j = (long) i2;
                    } else {
                        j = 0;
                    }
                    getMessagesStorage().setDialogUnread(j, true);
                    TLRPC.Dialog dialog = this.dialogs_dict.get(j);
                    if (dialog != null && !dialog.unread_mark) {
                        dialog.unread_mark = true;
                        if (dialog.unread_count == 0) {
                            this.dialogsUnreadOnly.add(dialog);
                            if (!isDialogMuted(j)) {
                                this.unreadUnmutedDialogs++;
                            }
                        }
                    }
                }
            }
            getUserConfig().unreadDialogsLoaded = true;
            getUserConfig().saveConfig(false);
            getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 256);
            this.loadingUnreadDialogs = false;
        }
    }

    public void reorderPinnedDialogs(int i, ArrayList<TLRPC.InputDialogPeer> arrayList, long j) {
        NativeByteBuffer nativeByteBuffer;
        Exception e;
        TLRPC.TL_messages_reorderPinnedDialogs tL_messages_reorderPinnedDialogs = new TLRPC.TL_messages_reorderPinnedDialogs();
        tL_messages_reorderPinnedDialogs.folder_id = i;
        tL_messages_reorderPinnedDialogs.force = true;
        if (j == 0) {
            ArrayList<TLRPC.Dialog> dialogs = getDialogs(i);
            if (!dialogs.isEmpty()) {
                int size = dialogs.size();
                int i2 = 0;
                for (int i3 = 0; i3 < size; i3++) {
                    TLRPC.Dialog dialog = dialogs.get(i3);
                    if (!(dialog instanceof TLRPC.TL_dialogFolder)) {
                        if (!dialog.pinned) {
                            break;
                        }
                        getMessagesStorage().setDialogPinned(dialog.id, dialog.pinnedNum);
                        if (((int) dialog.id) != 0) {
                            TLRPC.InputPeer inputPeer = getInputPeer((int) dialogs.get(i3).id);
                            TLRPC.TL_inputDialogPeer tL_inputDialogPeer = new TLRPC.TL_inputDialogPeer();
                            tL_inputDialogPeer.peer = inputPeer;
                            tL_messages_reorderPinnedDialogs.order.add(tL_inputDialogPeer);
                            i2 += tL_inputDialogPeer.getObjectSize();
                        }
                    }
                }
                NativeByteBuffer nativeByteBuffer2 = null;
                try {
                    nativeByteBuffer = new NativeByteBuffer(i2 + 12);
                    try {
                        nativeByteBuffer.writeInt32(16);
                        nativeByteBuffer.writeInt32(i);
                        nativeByteBuffer.writeInt32(tL_messages_reorderPinnedDialogs.order.size());
                        int size2 = tL_messages_reorderPinnedDialogs.order.size();
                        for (int i4 = 0; i4 < size2; i4++) {
                            tL_messages_reorderPinnedDialogs.order.get(i4).serializeToStream(nativeByteBuffer);
                        }
                    } catch (Exception e2) {
                        e = e2;
                        nativeByteBuffer2 = nativeByteBuffer;
                        FileLog.e(e);
                        nativeByteBuffer = nativeByteBuffer2;
                        j = getMessagesStorage().createPendingTask(nativeByteBuffer);
                        getConnectionsManager().sendRequest(tL_messages_reorderPinnedDialogs, new RequestDelegate(j) {
                            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$xM68j7iHF_3VNziK96F9w3npDY */
                            private final /* synthetic */ long f$1;

                            {
                                this.f$1 = r2;
                            }

                            @Override // im.guobwnxjuc.tgnet.RequestDelegate
                            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                                MessagesController.this.lambda$reorderPinnedDialogs$243$MessagesController(this.f$1, tLObject, tL_error);
                            }
                        });
                    }
                } catch (Exception e3) {
                    e = e3;
                    FileLog.e(e);
                    nativeByteBuffer = nativeByteBuffer2;
                    j = getMessagesStorage().createPendingTask(nativeByteBuffer);
                    getConnectionsManager().sendRequest(tL_messages_reorderPinnedDialogs, new RequestDelegate(j) {
                        /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$xM68j7iHF_3VNziK96F9w3npDY */
                        private final /* synthetic */ long f$1;

                        {
                            this.f$1 = r2;
                        }

                        @Override // im.guobwnxjuc.tgnet.RequestDelegate
                        public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                            MessagesController.this.lambda$reorderPinnedDialogs$243$MessagesController(this.f$1, tLObject, tL_error);
                        }
                    });
                }
                j = getMessagesStorage().createPendingTask(nativeByteBuffer);
            } else {
                return;
            }
        } else {
            tL_messages_reorderPinnedDialogs.order = arrayList;
        }
        getConnectionsManager().sendRequest(tL_messages_reorderPinnedDialogs, new RequestDelegate(j) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$xM68j7iHF_3VNziK96F9w3npDY */
            private final /* synthetic */ long f$1;

            {
                this.f$1 = r2;
            }

            @Override // im.guobwnxjuc.tgnet.RequestDelegate
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                MessagesController.this.lambda$reorderPinnedDialogs$243$MessagesController(this.f$1, tLObject, tL_error);
            }
        });
    }

    public /* synthetic */ void lambda$reorderPinnedDialogs$243$MessagesController(long j, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (j != 0) {
            getMessagesStorage().removePendingTask(j);
        }
    }

    public boolean pinDialog(long j, boolean z, TLRPC.InputPeer inputPeer, long j2) {
        long j3;
        NativeByteBuffer nativeByteBuffer;
        Exception e;
        int i = (int) j;
        TLRPC.Dialog dialog = this.dialogs_dict.get(j);
        if (dialog != null && dialog.pinned != z) {
            int i2 = dialog.folder_id;
            ArrayList<TLRPC.Dialog> dialogs = getDialogs(i2);
            dialog.pinned = z;
            if (z) {
                int i3 = 0;
                for (int i4 = 0; i4 < dialogs.size(); i4++) {
                    TLRPC.Dialog dialog2 = dialogs.get(i4);
                    if (!(dialog2 instanceof TLRPC.TL_dialogFolder)) {
                        if (!dialog2.pinned) {
                            break;
                        }
                        i3 = Math.max(dialog2.pinnedNum, i3);
                    }
                }
                dialog.pinnedNum = i3 + 1;
            } else {
                dialog.pinnedNum = 0;
            }
            NativeByteBuffer nativeByteBuffer2 = null;
            sortDialogs(null);
            if (!z && dialogs.get(dialogs.size() - 1) == dialog && !this.dialogsEndReached.get(i2)) {
                dialogs.remove(dialogs.size() - 1);
            }
            getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
            if (!(i == 0 || j2 == -1)) {
                TLRPC.TL_messages_toggleDialogPin tL_messages_toggleDialogPin = new TLRPC.TL_messages_toggleDialogPin();
                tL_messages_toggleDialogPin.pinned = z;
                TLRPC.InputPeer inputPeer2 = inputPeer == null ? getInputPeer(i) : inputPeer;
                if (inputPeer2 instanceof TLRPC.TL_inputPeerEmpty) {
                    return false;
                }
                TLRPC.TL_inputDialogPeer tL_inputDialogPeer = new TLRPC.TL_inputDialogPeer();
                tL_inputDialogPeer.peer = inputPeer2;
                tL_messages_toggleDialogPin.peer = tL_inputDialogPeer;
                if (j2 == 0) {
                    try {
                        nativeByteBuffer = new NativeByteBuffer(inputPeer2.getObjectSize() + 16);
                        try {
                            nativeByteBuffer.writeInt32(4);
                            nativeByteBuffer.writeInt64(j);
                            nativeByteBuffer.writeBool(z);
                            inputPeer2.serializeToStream(nativeByteBuffer);
                        } catch (Exception e2) {
                            e = e2;
                            nativeByteBuffer2 = nativeByteBuffer;
                        }
                    } catch (Exception e3) {
                        e = e3;
                        FileLog.e(e);
                        nativeByteBuffer = nativeByteBuffer2;
                        j3 = getMessagesStorage().createPendingTask(nativeByteBuffer);
                        getConnectionsManager().sendRequest(tL_messages_toggleDialogPin, new RequestDelegate(j3) {
                            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$LnOwgz1P1SUqi5_5sdP5DNQxbXw */
                            private final /* synthetic */ long f$1;

                            {
                                this.f$1 = r2;
                            }

                            @Override // im.guobwnxjuc.tgnet.RequestDelegate
                            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                                MessagesController.this.lambda$pinDialog$244$MessagesController(this.f$1, tLObject, tL_error);
                            }
                        });
                        getMessagesStorage().setDialogPinned(j, dialog.pinnedNum);
                        return true;
                    }
                    j3 = getMessagesStorage().createPendingTask(nativeByteBuffer);
                } else {
                    j3 = j2;
                }
                getConnectionsManager().sendRequest(tL_messages_toggleDialogPin, new RequestDelegate(j3) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$LnOwgz1P1SUqi5_5sdP5DNQxbXw */
                    private final /* synthetic */ long f$1;

                    {
                        this.f$1 = r2;
                    }

                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        MessagesController.this.lambda$pinDialog$244$MessagesController(this.f$1, tLObject, tL_error);
                    }
                });
            }
            getMessagesStorage().setDialogPinned(j, dialog.pinnedNum);
            return true;
        } else if (dialog != null) {
            return true;
        } else {
            return false;
        }
    }

    public /* synthetic */ void lambda$pinDialog$244$MessagesController(long j, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (j != 0) {
            getMessagesStorage().removePendingTask(j);
        }
    }

    public void loadPinnedDialogs(int i, long j, ArrayList<Long> arrayList) {
        if (this.loadingPinnedDialogs.indexOfKey(i) < 0 && !getUserConfig().isPinnedDialogsLoaded(i)) {
            this.loadingPinnedDialogs.put(i, 1);
            TLRPC.TL_messages_getPinnedDialogs tL_messages_getPinnedDialogs = new TLRPC.TL_messages_getPinnedDialogs();
            tL_messages_getPinnedDialogs.folder_id = i;
            getConnectionsManager().sendRequest(tL_messages_getPinnedDialogs, new RequestDelegate(i) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$GlTsaxNNqm6PntkePuzgo3KOo8 */
                private final /* synthetic */ int f$1;

                {
                    this.f$1 = r2;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$loadPinnedDialogs$247$MessagesController(this.f$1, tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$loadPinnedDialogs$247$MessagesController(int i, TLObject tLObject, TLRPC.TL_error tL_error) {
        MessageObject messageObject;
        TLRPC.Chat chat;
        TLRPC.Chat chat2;
        if (tLObject != null) {
            TLRPC.TL_messages_peerDialogs tL_messages_peerDialogs = (TLRPC.TL_messages_peerDialogs) tLObject;
            ArrayList arrayList = new ArrayList(tL_messages_peerDialogs.dialogs);
            fetchFolderInLoadedPinnedDialogs(tL_messages_peerDialogs);
            TLRPC.TL_messages_dialogs tL_messages_dialogs = new TLRPC.TL_messages_dialogs();
            tL_messages_dialogs.users.addAll(tL_messages_peerDialogs.users);
            tL_messages_dialogs.chats.addAll(tL_messages_peerDialogs.chats);
            tL_messages_dialogs.dialogs.addAll(tL_messages_peerDialogs.dialogs);
            tL_messages_dialogs.messages.addAll(tL_messages_peerDialogs.messages);
            LongSparseArray longSparseArray = new LongSparseArray();
            SparseArray sparseArray = new SparseArray();
            SparseArray sparseArray2 = new SparseArray();
            for (int i2 = 0; i2 < tL_messages_peerDialogs.users.size(); i2++) {
                TLRPC.User user = tL_messages_peerDialogs.users.get(i2);
                sparseArray.put(user.id, user);
            }
            for (int i3 = 0; i3 < tL_messages_peerDialogs.chats.size(); i3++) {
                TLRPC.Chat chat3 = tL_messages_peerDialogs.chats.get(i3);
                sparseArray2.put(chat3.id, chat3);
            }
            for (int i4 = 0; i4 < tL_messages_peerDialogs.messages.size(); i4++) {
                TLRPC.Message message = tL_messages_peerDialogs.messages.get(i4);
                if (message.to_id.channel_id != 0) {
                    TLRPC.Chat chat4 = (TLRPC.Chat) sparseArray2.get(message.to_id.channel_id);
                    if (chat4 != null && chat4.left) {
                    }
                } else if (!(message.to_id.chat_id == 0 || (chat2 = (TLRPC.Chat) sparseArray2.get(message.to_id.chat_id)) == null || chat2.migrated_to == null)) {
                }
                MessageObject messageObject2 = new MessageObject(this.currentAccount, message, (SparseArray<TLRPC.User>) sparseArray, (SparseArray<TLRPC.Chat>) sparseArray2, false);
                longSparseArray.put(messageObject2.getDialogId(), messageObject2);
            }
            boolean z = !arrayList.isEmpty() && (arrayList.get(0) instanceof TLRPC.TL_dialogFolder);
            int size = arrayList.size();
            for (int i5 = 0; i5 < size; i5++) {
                TLRPC.Dialog dialog = (TLRPC.Dialog) arrayList.get(i5);
                dialog.pinned = true;
                DialogObject.initDialog(dialog);
                if (DialogObject.isChannel(dialog)) {
                    TLRPC.Chat chat5 = (TLRPC.Chat) sparseArray2.get(-((int) dialog.id));
                    if (chat5 != null && chat5.left) {
                    }
                } else if (!(((int) dialog.id) >= 0 || (chat = (TLRPC.Chat) sparseArray2.get(-((int) dialog.id))) == null || chat.migrated_to == null)) {
                }
                if (dialog.last_message_date == 0 && (messageObject = (MessageObject) longSparseArray.get(dialog.id)) != null) {
                    dialog.last_message_date = messageObject.messageOwner.date;
                }
                Integer num = this.dialogs_read_inbox_max.get(Long.valueOf(dialog.id));
                if (num == null) {
                    num = 0;
                }
                this.dialogs_read_inbox_max.put(Long.valueOf(dialog.id), Integer.valueOf(Math.max(num.intValue(), dialog.read_inbox_max_id)));
                Integer num2 = this.dialogs_read_outbox_max.get(Long.valueOf(dialog.id));
                if (num2 == null) {
                    num2 = 0;
                }
                this.dialogs_read_outbox_max.put(Long.valueOf(dialog.id), Integer.valueOf(Math.max(num2.intValue(), dialog.read_outbox_max_id)));
            }
            getMessagesStorage().getStorageQueue().postRunnable(new Runnable(i, arrayList, z, tL_messages_peerDialogs, longSparseArray, tL_messages_dialogs) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$JI0yaGOtbcmtaWoG1fZmtBsIB4 */
                private final /* synthetic */ int f$1;
                private final /* synthetic */ ArrayList f$2;
                private final /* synthetic */ boolean f$3;
                private final /* synthetic */ TLRPC.TL_messages_peerDialogs f$4;
                private final /* synthetic */ LongSparseArray f$5;
                private final /* synthetic */ TLRPC.TL_messages_dialogs f$6;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                    this.f$3 = r4;
                    this.f$4 = r5;
                    this.f$5 = r6;
                    this.f$6 = r7;
                }

                public final void run() {
                    MessagesController.this.lambda$null$246$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6);
                }
            });
        }
    }

    public /* synthetic */ void lambda$null$246$MessagesController(int i, ArrayList arrayList, boolean z, TLRPC.TL_messages_peerDialogs tL_messages_peerDialogs, LongSparseArray longSparseArray, TLRPC.TL_messages_dialogs tL_messages_dialogs) {
        AndroidUtilities.runOnUIThread(new Runnable(i, arrayList, z, tL_messages_peerDialogs, longSparseArray, tL_messages_dialogs) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$RTi3YgW3Gfq1Z4KU2HOUeZvrPng */
            private final /* synthetic */ int f$1;
            private final /* synthetic */ ArrayList f$2;
            private final /* synthetic */ boolean f$3;
            private final /* synthetic */ TLRPC.TL_messages_peerDialogs f$4;
            private final /* synthetic */ LongSparseArray f$5;
            private final /* synthetic */ TLRPC.TL_messages_dialogs f$6;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
                this.f$4 = r5;
                this.f$5 = r6;
                this.f$6 = r7;
            }

            public final void run() {
                MessagesController.this.lambda$null$245$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6);
            }
        });
    }

    public /* synthetic */ void lambda$null$245$MessagesController(int i, ArrayList arrayList, boolean z, TLRPC.TL_messages_peerDialogs tL_messages_peerDialogs, LongSparseArray longSparseArray, TLRPC.TL_messages_dialogs tL_messages_dialogs) {
        boolean z2;
        this.loadingPinnedDialogs.delete(i);
        applyDialogsNotificationsSettings(arrayList);
        ArrayList<TLRPC.Dialog> dialogs = getDialogs(i);
        int i2 = z ? 1 : 0;
        int i3 = 0;
        boolean z3 = false;
        for (int i4 = 0; i4 < dialogs.size(); i4++) {
            TLRPC.Dialog dialog = dialogs.get(i4);
            if (!(dialog instanceof TLRPC.TL_dialogFolder)) {
                if (((int) dialog.id) == 0) {
                    if (i2 < arrayList.size()) {
                        arrayList.add(i2, dialog);
                    } else {
                        arrayList.add(dialog);
                    }
                    i2++;
                } else if (!dialog.pinned) {
                    break;
                } else {
                    i3 = Math.max(dialog.pinnedNum, i3);
                    dialog.pinned = false;
                    dialog.pinnedNum = 0;
                    i2++;
                    z3 = true;
                }
            }
        }
        ArrayList<Long> arrayList2 = new ArrayList<>();
        if (!arrayList.isEmpty()) {
            putUsers(tL_messages_peerDialogs.users, false);
            putChats(tL_messages_peerDialogs.chats, false);
            int size = arrayList.size();
            int i5 = 0;
            z2 = false;
            while (i5 < size) {
                TLRPC.Dialog dialog2 = (TLRPC.Dialog) arrayList.get(i5);
                dialog2.pinnedNum = (size - i5) + i3;
                arrayList2.add(Long.valueOf(dialog2.id));
                TLRPC.Dialog dialog3 = this.dialogs_dict.get(dialog2.id);
                if (dialog3 != null) {
                    dialog3.pinned = true;
                    dialog3.pinnedNum = dialog2.pinnedNum;
                    getMessagesStorage().setDialogPinned(dialog2.id, dialog2.pinnedNum);
                } else {
                    this.dialogs_dict.put(dialog2.id, dialog2);
                    MessageObject messageObject = (MessageObject) longSparseArray.get(dialog2.id);
                    this.dialogMessage.put(dialog2.id, messageObject);
                    if (messageObject != null && messageObject.messageOwner.to_id.channel_id == 0) {
                        this.dialogMessagesByIds.put(messageObject.getId(), messageObject);
                        if (messageObject.messageOwner.random_id != 0) {
                            this.dialogMessagesByRandomIds.put(messageObject.messageOwner.random_id, messageObject);
                        }
                    }
                    z2 = true;
                }
                i5++;
                z3 = true;
            }
        } else {
            z2 = false;
        }
        if (z3) {
            if (z2) {
                this.allDialogs.clear();
                int size2 = this.dialogs_dict.size();
                for (int i6 = 0; i6 < size2; i6++) {
                    this.allDialogs.add(this.dialogs_dict.valueAt(i6));
                }
            }
            sortDialogs(null);
            getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
        }
        getMessagesStorage().unpinAllDialogsExceptNew(arrayList2, i);
        getMessagesStorage().putDialogs(tL_messages_dialogs, 1);
        getUserConfig().setPinnedDialogsLoaded(i, true);
        getUserConfig().saveConfig(false);
    }

    public void generateJoinMessage(int i, boolean z) {
        TLRPC.Chat chat = getChat(Integer.valueOf(i));
        if (chat != null && ChatObject.isChannel(i, this.currentAccount)) {
            if ((!chat.left && !chat.kicked) || z) {
                TLRPC.TL_messageService tL_messageService = new TLRPC.TL_messageService();
                tL_messageService.flags = 256;
                int newMessageId = getUserConfig().getNewMessageId();
                tL_messageService.id = newMessageId;
                tL_messageService.local_id = newMessageId;
                tL_messageService.date = getConnectionsManager().getCurrentTime();
                tL_messageService.from_id = getUserConfig().getClientUserId();
                tL_messageService.to_id = new TLRPC.TL_peerChannel();
                tL_messageService.to_id.channel_id = i;
                tL_messageService.dialog_id = (long) (-i);
                tL_messageService.post = true;
                tL_messageService.action = new TLRPC.TL_messageActionChatAddUser();
                tL_messageService.action.users.add(Integer.valueOf(getUserConfig().getClientUserId()));
                if (chat.megagroup) {
                    tL_messageService.flags |= Integer.MIN_VALUE;
                }
                getUserConfig().saveConfig(false);
                ArrayList arrayList = new ArrayList();
                ArrayList<TLRPC.Message> arrayList2 = new ArrayList<>();
                arrayList2.add(tL_messageService);
                arrayList.add(new MessageObject(this.currentAccount, tL_messageService, true));
                getMessagesStorage().getStorageQueue().postRunnable(new Runnable(arrayList) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$0NN9VOdYSL9lB98Effe57pmXv6Y */
                    private final /* synthetic */ ArrayList f$1;

                    {
                        this.f$1 = r2;
                    }

                    public final void run() {
                        MessagesController.this.lambda$generateJoinMessage$249$MessagesController(this.f$1);
                    }
                });
                getMessagesStorage().putMessages(arrayList2, true, true, false, 0, false);
                AndroidUtilities.runOnUIThread(new Runnable(i, arrayList) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$Hr6BnweK9baU4S35N6EzVrw1upY */
                    private final /* synthetic */ int f$1;
                    private final /* synthetic */ ArrayList f$2;

                    {
                        this.f$1 = r2;
                        this.f$2 = r3;
                    }

                    public final void run() {
                        MessagesController.this.lambda$generateJoinMessage$250$MessagesController(this.f$1, this.f$2);
                    }
                });
            }
        }
    }

    public /* synthetic */ void lambda$generateJoinMessage$249$MessagesController(ArrayList arrayList) {
        AndroidUtilities.runOnUIThread(new Runnable(arrayList) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$Tp6HLjf_V1EwaF6xTF6htg50T2g */
            private final /* synthetic */ ArrayList f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                MessagesController.this.lambda$null$248$MessagesController(this.f$1);
            }
        });
    }

    public /* synthetic */ void lambda$null$248$MessagesController(ArrayList arrayList) {
        getNotificationsController().processNewMessages(arrayList, true, false, null);
    }

    public /* synthetic */ void lambda$generateJoinMessage$250$MessagesController(int i, ArrayList arrayList) {
        updateInterfaceWithMessages((long) (-i), arrayList, false);
        getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
    }

    /* access modifiers changed from: protected */
    public void deleteMessagesByPush(long j, ArrayList<Integer> arrayList, int i) {
        getMessagesStorage().getStorageQueue().postRunnable(new Runnable(arrayList, i, j) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$q6iPyIP_yifwmxQ3iJawMiaX0 */
            private final /* synthetic */ ArrayList f$1;
            private final /* synthetic */ int f$2;
            private final /* synthetic */ long f$3;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
            }

            public final void run() {
                MessagesController.this.lambda$deleteMessagesByPush$252$MessagesController(this.f$1, this.f$2, this.f$3);
            }
        });
    }

    public /* synthetic */ void lambda$deleteMessagesByPush$252$MessagesController(ArrayList arrayList, int i, long j) {
        AndroidUtilities.runOnUIThread(new Runnable(arrayList, i) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$OQGUQp7sTdIW_2JpDI_kVzBf6CA */
            private final /* synthetic */ ArrayList f$1;
            private final /* synthetic */ int f$2;

            {
                this.f$1 = r2;
                this.f$2 = r3;
            }

            public final void run() {
                MessagesController.this.lambda$null$251$MessagesController(this.f$1, this.f$2);
            }
        });
        getMessagesStorage().deletePushMessages(j, arrayList);
        getMessagesStorage().updateDialogsWithDeletedMessages(arrayList, getMessagesStorage().markMessagesAsDeleted(arrayList, false, i, true, false), false, i);
    }

    public /* synthetic */ void lambda$null$251$MessagesController(ArrayList arrayList, int i) {
        int i2 = 0;
        getNotificationCenter().postNotificationName(NotificationCenter.messagesDeleted, arrayList, Integer.valueOf(i), false);
        if (i == 0) {
            int size = arrayList.size();
            while (i2 < size) {
                MessageObject messageObject = this.dialogMessagesByIds.get(((Integer) arrayList.get(i2)).intValue());
                if (messageObject != null) {
                    messageObject.deleted = true;
                }
                i2++;
            }
            return;
        }
        MessageObject messageObject2 = this.dialogMessage.get((long) (-i));
        if (messageObject2 != null) {
            int size2 = arrayList.size();
            while (i2 < size2) {
                if (messageObject2.getId() == ((Integer) arrayList.get(i2)).intValue()) {
                    messageObject2.deleted = true;
                    return;
                }
                i2++;
            }
        }
    }

    public void checkChannelInviter(int i) {
        AndroidUtilities.runOnUIThread(new Runnable(i) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$hiUk4B9BKwahcoJ4RUn_Sm_mi8 */
            private final /* synthetic */ int f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                MessagesController.this.lambda$checkChannelInviter$258$MessagesController(this.f$1);
            }
        });
    }

    public /* synthetic */ void lambda$checkChannelInviter$258$MessagesController(int i) {
        TLRPC.Chat chat = getChat(Integer.valueOf(i));
        if (chat != null && ChatObject.isChannel(i, this.currentAccount) && !chat.creator) {
            TLRPC.TL_channels_getParticipant tL_channels_getParticipant = new TLRPC.TL_channels_getParticipant();
            tL_channels_getParticipant.channel = getInputChannel(i);
            tL_channels_getParticipant.user_id = new TLRPC.TL_inputUserSelf();
            getConnectionsManager().sendRequest(tL_channels_getParticipant, new RequestDelegate(chat, i) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$y6WMEtm3tse7mA4mDQxNi9WOrR0 */
                private final /* synthetic */ TLRPC.Chat f$1;
                private final /* synthetic */ int f$2;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$null$257$MessagesController(this.f$1, this.f$2, tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$null$257$MessagesController(TLRPC.Chat chat, int i, TLObject tLObject, TLRPC.TL_error tL_error) {
        TLRPC.TL_channels_channelParticipant tL_channels_channelParticipant = (TLRPC.TL_channels_channelParticipant) tLObject;
        if (!(tL_channels_channelParticipant == null || !(tL_channels_channelParticipant.participant instanceof TLRPC.TL_channelParticipantSelf) || tL_channels_channelParticipant.participant.inviter_id == getUserConfig().getClientUserId())) {
            if (!chat.megagroup || !getMessagesStorage().isMigratedChat(chat.id)) {
                AndroidUtilities.runOnUIThread(new Runnable(tL_channels_channelParticipant) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$hMU2c6PdkCxtkpDCUvLLjBOPSaA */
                    private final /* synthetic */ TLRPC.TL_channels_channelParticipant f$1;

                    {
                        this.f$1 = r2;
                    }

                    public final void run() {
                        MessagesController.this.lambda$null$253$MessagesController(this.f$1);
                    }
                });
                getMessagesStorage().putUsersAndChats(tL_channels_channelParticipant.users, null, true, true);
                TLRPC.TL_messageService tL_messageService = new TLRPC.TL_messageService();
                tL_messageService.media_unread = true;
                tL_messageService.unread = true;
                tL_messageService.flags = 256;
                tL_messageService.post = true;
                if (chat.megagroup) {
                    tL_messageService.flags |= Integer.MIN_VALUE;
                }
                int newMessageId = getUserConfig().getNewMessageId();
                tL_messageService.id = newMessageId;
                tL_messageService.local_id = newMessageId;
                tL_messageService.date = tL_channels_channelParticipant.participant.date;
                tL_messageService.action = new TLRPC.TL_messageActionChatAddUser();
                tL_messageService.from_id = tL_channels_channelParticipant.participant.inviter_id;
                tL_messageService.action.users.add(Integer.valueOf(getUserConfig().getClientUserId()));
                tL_messageService.to_id = new TLRPC.TL_peerChannel();
                tL_messageService.to_id.channel_id = i;
                tL_messageService.dialog_id = (long) (-i);
                getUserConfig().saveConfig(false);
                ArrayList arrayList = new ArrayList();
                ArrayList<TLRPC.Message> arrayList2 = new ArrayList<>();
                ConcurrentHashMap concurrentHashMap = new ConcurrentHashMap();
                for (int i2 = 0; i2 < tL_channels_channelParticipant.users.size(); i2++) {
                    TLRPC.User user = tL_channels_channelParticipant.users.get(i2);
                    concurrentHashMap.put(Integer.valueOf(user.id), user);
                }
                arrayList2.add(tL_messageService);
                arrayList.add(new MessageObject(this.currentAccount, (TLRPC.Message) tL_messageService, (AbstractMap<Integer, TLRPC.User>) concurrentHashMap, true));
                getMessagesStorage().getStorageQueue().postRunnable(new Runnable(arrayList) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$N6Yyfl6S_Rp4hGjxUBwRDm9hY4k */
                    private final /* synthetic */ ArrayList f$1;

                    {
                        this.f$1 = r2;
                    }

                    public final void run() {
                        MessagesController.this.lambda$null$255$MessagesController(this.f$1);
                    }
                });
                getMessagesStorage().putMessages(arrayList2, true, true, false, 0, false);
                AndroidUtilities.runOnUIThread(new Runnable(i, arrayList) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$0X5XbcdX2KaNsxjyNAEQjoCKDU */
                    private final /* synthetic */ int f$1;
                    private final /* synthetic */ ArrayList f$2;

                    {
                        this.f$1 = r2;
                        this.f$2 = r3;
                    }

                    public final void run() {
                        MessagesController.this.lambda$null$256$MessagesController(this.f$1, this.f$2);
                    }
                });
            }
        }
    }

    public /* synthetic */ void lambda$null$253$MessagesController(TLRPC.TL_channels_channelParticipant tL_channels_channelParticipant) {
        putUsers(tL_channels_channelParticipant.users, false);
    }

    public /* synthetic */ void lambda$null$254$MessagesController(ArrayList arrayList) {
        getNotificationsController().processNewMessages(arrayList, true, false, null);
    }

    public /* synthetic */ void lambda$null$255$MessagesController(ArrayList arrayList) {
        AndroidUtilities.runOnUIThread(new Runnable(arrayList) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$MguLNtCEeLesxHNnvXUDFVQ0w */
            private final /* synthetic */ ArrayList f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                MessagesController.this.lambda$null$254$MessagesController(this.f$1);
            }
        });
    }

    public /* synthetic */ void lambda$null$256$MessagesController(int i, ArrayList arrayList) {
        updateInterfaceWithMessages((long) (-i), arrayList, false);
        getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
    }

    private int getUpdateType(TLRPC.Update update) {
        if ((update instanceof TLRPC.TL_updateNewMessage) || (update instanceof TLRPC.TL_updateReadMessagesContents) || (update instanceof TLRPC.TL_updateReadHistoryInbox) || (update instanceof TLRPC.TL_updateReadHistoryOutbox) || (update instanceof TLRPC.TL_updateDeleteMessages) || (update instanceof TLRPC.TL_updateWebPage) || (update instanceof TLRPC.TL_updateEditMessage) || (update instanceof TLRPC.TL_updateFolderPeers)) {
            return 0;
        }
        if (update instanceof TLRPC.TL_updateNewEncryptedMessage) {
            return 1;
        }
        return ((update instanceof TLRPC.TL_updateNewChannelMessage) || (update instanceof TLRPC.TL_updateDeleteChannelMessages) || (update instanceof TLRPC.TL_updateEditChannelMessage) || (update instanceof TLRPC.TL_updateChannelWebPage)) ? 2 : 3;
    }

    private static int getUpdatePts(TLRPC.Update update) {
        if (update instanceof TLRPC.TL_updateDeleteMessages) {
            return ((TLRPC.TL_updateDeleteMessages) update).pts;
        }
        if (update instanceof TLRPC.TL_updateNewChannelMessage) {
            return ((TLRPC.TL_updateNewChannelMessage) update).pts;
        }
        if (update instanceof TLRPC.TL_updateReadHistoryOutbox) {
            return ((TLRPC.TL_updateReadHistoryOutbox) update).pts;
        }
        if (update instanceof TLRPC.TL_updateNewMessage) {
            return ((TLRPC.TL_updateNewMessage) update).pts;
        }
        if (update instanceof TLRPC.TL_updateEditMessage) {
            return ((TLRPC.TL_updateEditMessage) update).pts;
        }
        if (update instanceof TLRPC.TL_updateWebPage) {
            return ((TLRPC.TL_updateWebPage) update).pts;
        }
        if (update instanceof TLRPC.TL_updateReadHistoryInbox) {
            return ((TLRPC.TL_updateReadHistoryInbox) update).pts;
        }
        if (update instanceof TLRPC.TL_updateChannelWebPage) {
            return ((TLRPC.TL_updateChannelWebPage) update).pts;
        }
        if (update instanceof TLRPC.TL_updateDeleteChannelMessages) {
            return ((TLRPC.TL_updateDeleteChannelMessages) update).pts;
        }
        if (update instanceof TLRPC.TL_updateEditChannelMessage) {
            return ((TLRPC.TL_updateEditChannelMessage) update).pts;
        }
        if (update instanceof TLRPC.TL_updateReadMessagesContents) {
            return ((TLRPC.TL_updateReadMessagesContents) update).pts;
        }
        if (update instanceof TLRPC.TL_updateChannelTooLong) {
            return ((TLRPC.TL_updateChannelTooLong) update).pts;
        }
        if (update instanceof TLRPC.TL_updateFolderPeers) {
            return ((TLRPC.TL_updateFolderPeers) update).pts;
        }
        return 0;
    }

    private static int getUpdatePtsCount(TLRPC.Update update) {
        if (update instanceof TLRPC.TL_updateDeleteMessages) {
            return ((TLRPC.TL_updateDeleteMessages) update).pts_count;
        }
        if (update instanceof TLRPC.TL_updateNewChannelMessage) {
            return ((TLRPC.TL_updateNewChannelMessage) update).pts_count;
        }
        if (update instanceof TLRPC.TL_updateReadHistoryOutbox) {
            return ((TLRPC.TL_updateReadHistoryOutbox) update).pts_count;
        }
        if (update instanceof TLRPC.TL_updateNewMessage) {
            return ((TLRPC.TL_updateNewMessage) update).pts_count;
        }
        if (update instanceof TLRPC.TL_updateEditMessage) {
            return ((TLRPC.TL_updateEditMessage) update).pts_count;
        }
        if (update instanceof TLRPC.TL_updateWebPage) {
            return ((TLRPC.TL_updateWebPage) update).pts_count;
        }
        if (update instanceof TLRPC.TL_updateReadHistoryInbox) {
            return ((TLRPC.TL_updateReadHistoryInbox) update).pts_count;
        }
        if (update instanceof TLRPC.TL_updateChannelWebPage) {
            return ((TLRPC.TL_updateChannelWebPage) update).pts_count;
        }
        if (update instanceof TLRPC.TL_updateDeleteChannelMessages) {
            return ((TLRPC.TL_updateDeleteChannelMessages) update).pts_count;
        }
        if (update instanceof TLRPC.TL_updateEditChannelMessage) {
            return ((TLRPC.TL_updateEditChannelMessage) update).pts_count;
        }
        if (update instanceof TLRPC.TL_updateReadMessagesContents) {
            return ((TLRPC.TL_updateReadMessagesContents) update).pts_count;
        }
        if (update instanceof TLRPC.TL_updateFolderPeers) {
            return ((TLRPC.TL_updateFolderPeers) update).pts_count;
        }
        return 0;
    }

    private static int getUpdateQts(TLRPC.Update update) {
        if (update instanceof TLRPC.TL_updateNewEncryptedMessage) {
            return ((TLRPC.TL_updateNewEncryptedMessage) update).qts;
        }
        return 0;
    }

    private static int getUpdateChannelId(TLRPC.Update update) {
        if (update instanceof TLRPC.TL_updateNewChannelMessage) {
            return ((TLRPC.TL_updateNewChannelMessage) update).message.to_id.channel_id;
        }
        if (update instanceof TLRPC.TL_updateEditChannelMessage) {
            return ((TLRPC.TL_updateEditChannelMessage) update).message.to_id.channel_id;
        }
        if (update instanceof TLRPC.TL_updateReadChannelOutbox) {
            return ((TLRPC.TL_updateReadChannelOutbox) update).channel_id;
        }
        if (update instanceof TLRPC.TL_updateChannelMessageViews) {
            return ((TLRPC.TL_updateChannelMessageViews) update).channel_id;
        }
        if (update instanceof TLRPC.TL_updateChannelTooLong) {
            return ((TLRPC.TL_updateChannelTooLong) update).channel_id;
        }
        if (update instanceof TLRPC.TL_updateChannelPinnedMessage) {
            return ((TLRPC.TL_updateChannelPinnedMessage) update).channel_id;
        }
        if (update instanceof TLRPC.TL_updateChannelReadMessagesContents) {
            return ((TLRPC.TL_updateChannelReadMessagesContents) update).channel_id;
        }
        if (update instanceof TLRPC.TL_updateChannelAvailableMessages) {
            return ((TLRPC.TL_updateChannelAvailableMessages) update).channel_id;
        }
        if (update instanceof TLRPC.TL_updateChannel) {
            return ((TLRPC.TL_updateChannel) update).channel_id;
        }
        if (update instanceof TLRPC.TL_updateChannelWebPage) {
            return ((TLRPC.TL_updateChannelWebPage) update).channel_id;
        }
        if (update instanceof TLRPC.TL_updateDeleteChannelMessages) {
            return ((TLRPC.TL_updateDeleteChannelMessages) update).channel_id;
        }
        if (update instanceof TLRPC.TL_updateReadChannelInbox) {
            return ((TLRPC.TL_updateReadChannelInbox) update).channel_id;
        }
        if (!BuildVars.LOGS_ENABLED) {
            return 0;
        }
        FileLog.e("trying to get unknown update channel_id for " + update);
        return 0;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:118:0x0296, code lost:
        if (java.lang.Math.abs(java.lang.System.currentTimeMillis() - r25.updatesStartWaitTimeQts) > r12) goto L_0x01b7;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:276:0x05f6, code lost:
        if (r3 != null) goto L_0x05f8;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:278:0x05fa, code lost:
        if (r5 != null) goto L_0x05fd;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:288:0x0623, code lost:
        if (r3 != null) goto L_0x0625;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:290:0x0627, code lost:
        if (r5 != null) goto L_0x05fd;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:86:0x01ee, code lost:
        if (java.lang.Math.abs(java.lang.System.currentTimeMillis() - r25.updatesStartWaitTimePts) > r12) goto L_0x01b7;
     */
    /* JADX WARNING: Removed duplicated region for block: B:145:0x032c  */
    /* JADX WARNING: Removed duplicated region for block: B:153:0x0366  */
    /* JADX WARNING: Removed duplicated region for block: B:186:0x041e  */
    /* JADX WARNING: Removed duplicated region for block: B:297:0x063d  */
    /* JADX WARNING: Removed duplicated region for block: B:314:0x0679 A[ADDED_TO_REGION] */
    /* JADX WARNING: Removed duplicated region for block: B:325:0x06b1  */
    /* JADX WARNING: Removed duplicated region for block: B:391:0x089a  */
    /* JADX WARNING: Removed duplicated region for block: B:409:0x08d4  */
    /* JADX WARNING: Removed duplicated region for block: B:411:0x08ee  */
    /* JADX WARNING: Removed duplicated region for block: B:441:0x0675 A[EDGE_INSN: B:441:0x0675->B:312:0x0675 ?: BREAK  , SYNTHETIC] */
    public void processUpdates(TLRPC.Updates updates, boolean z) {
        boolean z2;
        boolean z3;
        TLRPC.Chat chat;
        TLRPC.User user;
        boolean z4;
        TLRPC.User user2;
        boolean z5;
        int i;
        int i2;
        boolean z6;
        int i3;
        boolean z7;
        ArrayList arrayList;
        boolean z8;
        boolean z9;
        ArrayList arrayList2 = null;
        int i4 = 0;
        int i5 = 1;
        if (updates instanceof TLRPC.TL_updateShort) {
            ArrayList<TLRPC.Update> arrayList3 = new ArrayList<>();
            arrayList3.add(updates.update);
            processUpdateArray(arrayList3, null, null, false, updates.date);
        } else {
            boolean z10 = updates instanceof TLRPC.TL_updateShortChatMessage;
            long j = 1500;
            if (z10 || (updates instanceof TLRPC.TL_updateShortMessage)) {
                int i6 = z10 ? updates.from_id : updates.user_id;
                TLRPC.User user3 = getUser(Integer.valueOf(i6));
                if (user3 == null || user3.min) {
                    user3 = getMessagesStorage().getUserSync(i6);
                    if (user3 != null && user3.min) {
                        user3 = null;
                    }
                    putUser(user3, true);
                }
                if (updates.fwd_from != null) {
                    if (updates.fwd_from.from_id != 0) {
                        user = getUser(Integer.valueOf(updates.fwd_from.from_id));
                        if (user == null) {
                            user = getMessagesStorage().getUserSync(updates.fwd_from.from_id);
                            putUser(user, true);
                        }
                        z6 = true;
                    } else {
                        user = null;
                        z6 = false;
                    }
                    if (updates.fwd_from.channel_id != 0) {
                        chat = getChat(Integer.valueOf(updates.fwd_from.channel_id));
                        if (chat == null) {
                            chat = getMessagesStorage().getChatSync(updates.fwd_from.channel_id);
                            putChat(chat, true);
                        }
                        z3 = true;
                    } else {
                        z3 = z6;
                        chat = null;
                    }
                } else {
                    user = null;
                    chat = null;
                    z3 = false;
                }
                if (updates.via_bot_id != 0) {
                    user2 = getUser(Integer.valueOf(updates.via_bot_id));
                    if (user2 == null) {
                        user2 = getMessagesStorage().getUserSync(updates.via_bot_id);
                        putUser(user2, true);
                    }
                    z4 = true;
                } else {
                    user2 = null;
                    z4 = false;
                }
                boolean z11 = updates instanceof TLRPC.TL_updateShortMessage;
                if (z11) {
                    if (user3 != null) {
                        if (z3) {
                            if (user == null) {
                            }
                        }
                        if (z4) {
                        }
                    }
                    z5 = true;
                    if (!z5 && !updates.entities.isEmpty()) {
                        i2 = 0;
                        while (true) {
                            if (i2 >= updates.entities.size()) {
                                break;
                            }
                            TLRPC.MessageEntity messageEntity = updates.entities.get(i2);
                            if (messageEntity instanceof TLRPC.TL_messageEntityMentionName) {
                                int i7 = ((TLRPC.TL_messageEntityMentionName) messageEntity).user_id;
                                TLRPC.User user4 = getUser(Integer.valueOf(i7));
                                if (user4 == null || user4.min) {
                                    TLRPC.User userSync = getMessagesStorage().getUserSync(i7);
                                    if (userSync != null && userSync.min) {
                                        userSync = null;
                                    }
                                    if (userSync == null) {
                                        z5 = true;
                                        break;
                                    }
                                    putUser(user3, true);
                                }
                            }
                            i2++;
                        }
                    }
                    if (!updates.out || user3 == null || user3.status == null || user3.status.expires > 0 || Math.abs(getConnectionsManager().getCurrentTime() - updates.date) >= 30) {
                        i = 0;
                    } else {
                        this.onlinePrivacy.put(Integer.valueOf(user3.id), Integer.valueOf(updates.date));
                        i = 1;
                    }
                    if (!z5) {
                        if (getMessagesStorage().getLastPtsValue() + updates.pts_count == updates.pts) {
                            TLRPC.TL_message tL_message = new TLRPC.TL_message();
                            tL_message.id = updates.id;
                            int clientUserId = getUserConfig().getClientUserId();
                            if (z11) {
                                if (updates.out) {
                                    tL_message.from_id = clientUserId;
                                } else {
                                    tL_message.from_id = i6;
                                }
                                tL_message.to_id = new TLRPC.TL_peerUser();
                                tL_message.to_id.user_id = i6;
                                tL_message.dialog_id = (long) i6;
                            } else {
                                tL_message.from_id = i6;
                                tL_message.to_id = new TLRPC.TL_peerChat();
                                tL_message.to_id.chat_id = updates.chat_id;
                                tL_message.dialog_id = (long) (-updates.chat_id);
                            }
                            tL_message.fwd_from = updates.fwd_from;
                            tL_message.silent = updates.silent;
                            tL_message.out = updates.out;
                            tL_message.mentioned = updates.mentioned;
                            tL_message.media_unread = updates.media_unread;
                            tL_message.entities = updates.entities;
                            tL_message.message = updates.message;
                            tL_message.date = updates.date;
                            tL_message.via_bot_id = updates.via_bot_id;
                            tL_message.flags = updates.flags | 256;
                            tL_message.reply_to_msg_id = updates.reply_to_msg_id;
                            tL_message.media = new TLRPC.TL_messageMediaEmpty();
                            ConcurrentHashMap<Long, Integer> concurrentHashMap = tL_message.out ? this.dialogs_read_outbox_max : this.dialogs_read_inbox_max;
                            Integer num = concurrentHashMap.get(Long.valueOf(tL_message.dialog_id));
                            if (num == null) {
                                num = Integer.valueOf(getMessagesStorage().getDialogReadMax(tL_message.out, tL_message.dialog_id));
                                concurrentHashMap.put(Long.valueOf(tL_message.dialog_id), num);
                            }
                            tL_message.unread = num.intValue() < tL_message.id;
                            if (tL_message.dialog_id == ((long) clientUserId)) {
                                tL_message.unread = false;
                                tL_message.media_unread = false;
                                tL_message.out = true;
                            }
                            getMessagesStorage().setLastPtsValue(updates.pts);
                            MessageObject messageObject = new MessageObject(this.currentAccount, tL_message, this.createdDialogIds.contains(Long.valueOf(tL_message.dialog_id)));
                            ArrayList<MessageObject> arrayList4 = new ArrayList<>();
                            arrayList4.add(messageObject);
                            ArrayList<TLRPC.Message> arrayList5 = new ArrayList<>();
                            arrayList5.add(tL_message);
                            if (z11) {
                                boolean z12 = !updates.out && updatePrintingUsersWithNewMessages((long) updates.user_id, arrayList4);
                                if (z12) {
                                    updatePrintingStrings();
                                }
                                AndroidUtilities.runOnUIThread(new Runnable(z12, i6, arrayList4) {
                                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$njPTITuNWJj9c2q9saQTXMoNB5k */
                                    private final /* synthetic */ boolean f$1;
                                    private final /* synthetic */ int f$2;
                                    private final /* synthetic */ ArrayList f$3;

                                    {
                                        this.f$1 = r2;
                                        this.f$2 = r3;
                                        this.f$3 = r4;
                                    }

                                    public final void run() {
                                        MessagesController.this.lambda$processUpdates$259$MessagesController(this.f$1, this.f$2, this.f$3);
                                    }
                                });
                            } else {
                                boolean updatePrintingUsersWithNewMessages = updatePrintingUsersWithNewMessages((long) (-updates.chat_id), arrayList4);
                                if (updatePrintingUsersWithNewMessages) {
                                    updatePrintingStrings();
                                }
                                AndroidUtilities.runOnUIThread(new Runnable(updatePrintingUsersWithNewMessages, updates, arrayList4) {
                                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$bn8QSGmsZEgMqDN8INuwJGwF794 */
                                    private final /* synthetic */ boolean f$1;
                                    private final /* synthetic */ TLRPC.Updates f$2;
                                    private final /* synthetic */ ArrayList f$3;

                                    {
                                        this.f$1 = r2;
                                        this.f$2 = r3;
                                        this.f$3 = r4;
                                    }

                                    public final void run() {
                                        MessagesController.this.lambda$processUpdates$260$MessagesController(this.f$1, this.f$2, this.f$3);
                                    }
                                });
                            }
                            if (!messageObject.isOut()) {
                                getMessagesStorage().getStorageQueue().postRunnable(new Runnable(arrayList4) {
                                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$MwVxv5mecePdhLtqGgaDqs5JlMs */
                                    private final /* synthetic */ ArrayList f$1;

                                    {
                                        this.f$1 = r2;
                                    }

                                    public final void run() {
                                        MessagesController.this.lambda$processUpdates$262$MessagesController(this.f$1);
                                    }
                                });
                            }
                            getMessagesStorage().putMessages(arrayList5, false, true, false, 0, false);
                        } else if (getMessagesStorage().getLastPtsValue() != updates.pts) {
                            if (BuildVars.LOGS_ENABLED) {
                                FileLog.d("need get diff short message, act=" + this.currentAccount + " ,pts: " + getMessagesStorage().getLastPtsValue() + " ,up.pts=" + updates.pts + " ,count=" + updates.pts_count);
                            }
                            if (this.gettingDifference || this.updatesStartWaitTimePts == 0 || Math.abs(System.currentTimeMillis() - this.updatesStartWaitTimePts) <= 1500) {
                                if (this.updatesStartWaitTimePts == 0) {
                                    this.updatesStartWaitTimePts = System.currentTimeMillis();
                                }
                                if (BuildVars.LOGS_ENABLED) {
                                    FileLog.d("add to queue");
                                }
                                this.updatesQueuePts.add(updates);
                            }
                        }
                        i5 = 0;
                        i4 = i;
                    }
                    i5 = 1;
                    i4 = i;
                } else {
                    TLRPC.Chat chat2 = getChat(Integer.valueOf(updates.chat_id));
                    if (chat2 == null) {
                        chat2 = getMessagesStorage().getChatSync(updates.chat_id);
                        putChat(chat2, true);
                    }
                    if (chat2 != null) {
                        if (user3 != null) {
                            if (z3) {
                                if (user == null) {
                                }
                            }
                            if (z4) {
                            }
                        }
                    }
                    z5 = true;
                    i2 = 0;
                    while (true) {
                        if (i2 >= updates.entities.size()) {
                        }
                        i2++;
                    }
                    if (!updates.out) {
                    }
                    i = 0;
                    if (!z5) {
                    }
                    i5 = 1;
                    i4 = i;
                }
                z5 = false;
                i2 = 0;
                while (true) {
                    if (i2 >= updates.entities.size()) {
                    }
                    i2++;
                }
                if (!updates.out) {
                }
                i = 0;
                if (!z5) {
                }
                i5 = 1;
                i4 = i;
            } else {
                boolean z13 = updates instanceof TLRPC.TL_updatesCombined;
                if (z13 || (updates instanceof TLRPC.TL_updates)) {
                    SparseArray sparseArray = null;
                    for (int i8 = 0; i8 < updates.chats.size(); i8++) {
                        TLRPC.Chat chat3 = updates.chats.get(i8);
                        if ((chat3 instanceof TLRPC.TL_channel) && chat3.min) {
                            TLRPC.Chat chat4 = getChat(Integer.valueOf(chat3.id));
                            if (chat4 == null || chat4.min) {
                                chat4 = getMessagesStorage().getChatSync(updates.chat_id);
                                putChat(chat4, true);
                            }
                            if (chat4 == null || chat4.min) {
                                if (sparseArray == null) {
                                    sparseArray = new SparseArray();
                                }
                                sparseArray.put(chat3.id, chat3);
                            }
                        }
                    }
                    if (sparseArray != null) {
                        int i9 = 0;
                        while (true) {
                            if (i9 >= updates.updates.size()) {
                                break;
                            }
                            TLRPC.Update update = updates.updates.get(i9);
                            if (update instanceof TLRPC.TL_updateNewChannelMessage) {
                                int i10 = ((TLRPC.TL_updateNewChannelMessage) update).message.to_id.channel_id;
                                if (sparseArray.indexOfKey(i10) >= 0) {
                                    if (BuildVars.LOGS_ENABLED) {
                                        FileLog.d("need get diff because of min channel=" + i10 + " ,act=" + this.currentAccount);
                                    }
                                    i3 = 1;
                                }
                            }
                            i9++;
                        }
                    }
                    i3 = 0;
                    if (i3 == 0) {
                        getMessagesStorage().putUsersAndChats(updates.users, updates.chats, true, true);
                        Collections.sort(updates.updates, this.updatesComparator);
                        ArrayList arrayList6 = null;
                        z7 = false;
                        int i11 = i3;
                        while (true) {
                            if (updates.updates.size() <= 0) {
                                arrayList = arrayList6;
                                z8 = z13;
                                break;
                            }
                            TLRPC.Update update2 = updates.updates.get(i4);
                            if (getUpdateType(update2) == 0) {
                                TLRPC.TL_updates tL_updates = new TLRPC.TL_updates();
                                tL_updates.updates.add(update2);
                                tL_updates.pts = getUpdatePts(update2);
                                tL_updates.pts_count = getUpdatePtsCount(update2);
                                while (i5 < updates.updates.size()) {
                                    TLRPC.Update update3 = updates.updates.get(i5);
                                    int updatePts = getUpdatePts(update3);
                                    int updatePtsCount = getUpdatePtsCount(update3);
                                    if (!(getUpdateType(update3) == 0 && tL_updates.pts + updatePtsCount == updatePts)) {
                                        break;
                                    }
                                    tL_updates.updates.add(update3);
                                    tL_updates.pts = updatePts;
                                    tL_updates.pts_count += updatePtsCount;
                                    updates.updates.remove(i5);
                                }
                                if (getMessagesStorage().getLastPtsValue() + tL_updates.pts_count == tL_updates.pts) {
                                    arrayList = arrayList6;
                                    z8 = z13;
                                    if (processUpdateArray(tL_updates.updates, updates.users, updates.chats, false, updates.date)) {
                                        getMessagesStorage().setLastPtsValue(tL_updates.pts);
                                        arrayList6 = arrayList;
                                        updates.updates.remove(0);
                                        z13 = z8;
                                        i4 = 0;
                                        i5 = 1;
                                        j = 1500;
                                    }
                                } else {
                                    arrayList = arrayList6;
                                    z8 = z13;
                                    if (getMessagesStorage().getLastPtsValue() != tL_updates.pts) {
                                        if (!this.gettingDifference) {
                                            long j2 = this.updatesStartWaitTimePts;
                                            if (j2 != 0) {
                                                if (j2 != 0) {
                                                }
                                            }
                                        }
                                        if (this.updatesStartWaitTimePts == 0) {
                                            this.updatesStartWaitTimePts = System.currentTimeMillis();
                                        }
                                        if (BuildVars.LOGS_ENABLED) {
                                            FileLog.d("add to queue");
                                        }
                                        this.updatesQueuePts.add(tL_updates);
                                    }
                                    arrayList6 = arrayList;
                                    updates.updates.remove(0);
                                    z13 = z8;
                                    i4 = 0;
                                    i5 = 1;
                                    j = 1500;
                                }
                            } else {
                                arrayList = arrayList6;
                                z8 = z13;
                                if (getUpdateType(update2) != 1) {
                                    if (getUpdateType(update2) != 2) {
                                        break;
                                    }
                                    int updateChannelId = getUpdateChannelId(update2);
                                    int i12 = this.channelsPts.get(updateChannelId);
                                    if (i12 == 0) {
                                        i12 = getMessagesStorage().getChannelPtsSync(updateChannelId);
                                        if (i12 == 0) {
                                            int i13 = 0;
                                            while (true) {
                                                if (i13 >= updates.chats.size()) {
                                                    break;
                                                }
                                                TLRPC.Chat chat5 = updates.chats.get(i13);
                                                if (chat5.id == updateChannelId) {
                                                    loadUnknownChannel(chat5, 0);
                                                    z9 = true;
                                                    break;
                                                }
                                                i13++;
                                            }
                                            TLRPC.TL_updates tL_updates2 = new TLRPC.TL_updates();
                                            tL_updates2.updates.add(update2);
                                            tL_updates2.pts = getUpdatePts(update2);
                                            tL_updates2.pts_count = getUpdatePtsCount(update2);
                                            while (1 < updates.updates.size()) {
                                                TLRPC.Update update4 = updates.updates.get(1);
                                                int updatePts2 = getUpdatePts(update4);
                                                int updatePtsCount2 = getUpdatePtsCount(update4);
                                                if (!(getUpdateType(update4) == 2 && updateChannelId == getUpdateChannelId(update4) && tL_updates2.pts + updatePtsCount2 == updatePts2)) {
                                                    break;
                                                }
                                                tL_updates2.updates.add(update4);
                                                tL_updates2.pts = updatePts2;
                                                tL_updates2.pts_count += updatePtsCount2;
                                                updates.updates.remove(1);
                                            }
                                            if (z9) {
                                                if (tL_updates2.pts_count + i12 == tL_updates2.pts) {
                                                    if (processUpdateArray(tL_updates2.updates, updates.users, updates.chats, false, updates.date)) {
                                                        this.channelsPts.put(updateChannelId, tL_updates2.pts);
                                                        getMessagesStorage().saveChannelPts(updateChannelId, tL_updates2.pts);
                                                    } else if (arrayList == null) {
                                                        arrayList6 = new ArrayList();
                                                        updates.updates.remove(0);
                                                        z13 = z8;
                                                        i4 = 0;
                                                        i5 = 1;
                                                        j = 1500;
                                                    } else if (!arrayList.contains(Integer.valueOf(updateChannelId))) {
                                                        arrayList.add(Integer.valueOf(updateChannelId));
                                                    }
                                                } else if (i12 != tL_updates2.pts) {
                                                    long j3 = this.updatesStartWaitTimeChannels.get(updateChannelId);
                                                    if (this.gettingDifferenceChannels.get(updateChannelId) || j3 == 0 || Math.abs(System.currentTimeMillis() - j3) <= 1500) {
                                                        if (j3 == 0) {
                                                            this.updatesStartWaitTimeChannels.put(updateChannelId, System.currentTimeMillis());
                                                        }
                                                        if (BuildVars.LOGS_ENABLED) {
                                                            FileLog.d("add to queue");
                                                        }
                                                        ArrayList<TLRPC.Updates> arrayList7 = this.updatesQueueChannels.get(updateChannelId);
                                                        if (arrayList7 == null) {
                                                            arrayList7 = new ArrayList<>();
                                                            this.updatesQueueChannels.put(updateChannelId, arrayList7);
                                                        }
                                                        arrayList7.add(tL_updates2);
                                                    } else if (arrayList == null) {
                                                        arrayList6 = new ArrayList();
                                                        updates.updates.remove(0);
                                                        z13 = z8;
                                                        i4 = 0;
                                                        i5 = 1;
                                                        j = 1500;
                                                    } else if (!arrayList.contains(Integer.valueOf(updateChannelId))) {
                                                        arrayList.add(Integer.valueOf(updateChannelId));
                                                    }
                                                }
                                            } else if (BuildVars.LOGS_ENABLED) {
                                                FileLog.d("need load unknown channel = " + updateChannelId);
                                            }
                                        } else {
                                            this.channelsPts.put(updateChannelId, i12);
                                        }
                                    }
                                    z9 = false;
                                    TLRPC.TL_updates tL_updates22 = new TLRPC.TL_updates();
                                    tL_updates22.updates.add(update2);
                                    tL_updates22.pts = getUpdatePts(update2);
                                    tL_updates22.pts_count = getUpdatePtsCount(update2);
                                    while (1 < updates.updates.size()) {
                                    }
                                    if (z9) {
                                    }
                                } else {
                                    TLRPC.TL_updates tL_updates3 = new TLRPC.TL_updates();
                                    tL_updates3.updates.add(update2);
                                    tL_updates3.pts = getUpdateQts(update2);
                                    while (1 < updates.updates.size()) {
                                        TLRPC.Update update5 = updates.updates.get(1);
                                        int updateQts = getUpdateQts(update5);
                                        if (!(getUpdateType(update5) == 1 && tL_updates3.pts + 1 == updateQts)) {
                                            break;
                                        }
                                        tL_updates3.updates.add(update5);
                                        tL_updates3.pts = updateQts;
                                        updates.updates.remove(1);
                                    }
                                    if (getMessagesStorage().getLastQtsValue() == 0 || getMessagesStorage().getLastQtsValue() + tL_updates3.updates.size() == tL_updates3.pts) {
                                        processUpdateArray(tL_updates3.updates, updates.users, updates.chats, false, updates.date);
                                        getMessagesStorage().setLastQtsValue(tL_updates3.pts);
                                        z7 = true;
                                    } else if (getMessagesStorage().getLastPtsValue() != tL_updates3.pts) {
                                        if (!this.gettingDifference) {
                                            long j4 = this.updatesStartWaitTimeQts;
                                            if (j4 != 0) {
                                                if (j4 != 0) {
                                                }
                                            }
                                        }
                                        if (this.updatesStartWaitTimeQts == 0) {
                                            this.updatesStartWaitTimeQts = System.currentTimeMillis();
                                        }
                                        if (BuildVars.LOGS_ENABLED) {
                                            FileLog.d("add to queue");
                                        }
                                        this.updatesQueueQts.add(tL_updates3);
                                    }
                                }
                                arrayList6 = arrayList;
                                updates.updates.remove(0);
                                z13 = z8;
                                i4 = 0;
                                i5 = 1;
                                j = 1500;
                            }
                            i11 = 1;
                            arrayList6 = arrayList;
                            updates.updates.remove(0);
                            z13 = z8;
                            i4 = 0;
                            i5 = 1;
                            j = 1500;
                        }
                        if (!z8 ? getMessagesStorage().getLastSeqValue() + 1 == updates.seq || updates.seq == 0 || updates.seq == getMessagesStorage().getLastSeqValue() : getMessagesStorage().getLastSeqValue() + 1 == updates.seq_start || getMessagesStorage().getLastSeqValue() == updates.seq_start) {
                            processUpdateArray(updates.updates, updates.users, updates.chats, false, updates.date);
                            if (updates.seq != 0) {
                                if (updates.date != 0) {
                                    getMessagesStorage().setLastDateValue(updates.date);
                                }
                                getMessagesStorage().setLastSeqValue(updates.seq);
                            }
                        } else {
                            if (BuildVars.LOGS_ENABLED) {
                                if (z8) {
                                    FileLog.d("need get diff TL_updatesCombined, seq=" + getMessagesStorage().getLastSeqValue() + " ,up.seq_start=" + updates.seq_start);
                                } else {
                                    FileLog.d("need get diff TL_updates, seq=" + getMessagesStorage().getLastSeqValue() + " ,up.seq_start=" + updates.seq);
                                }
                            }
                            if (this.gettingDifference || this.updatesStartWaitTimeSeq == 0 || Math.abs(System.currentTimeMillis() - this.updatesStartWaitTimeSeq) <= 1500) {
                                if (this.updatesStartWaitTimeSeq == 0) {
                                    this.updatesStartWaitTimeSeq = System.currentTimeMillis();
                                }
                                if (BuildVars.LOGS_ENABLED) {
                                    FileLog.d("add TL_updates/Combined to queue");
                                }
                                this.updatesQueueSeq.add(updates);
                            } else {
                                arrayList2 = arrayList;
                                i5 = 1;
                            }
                        }
                        i5 = i11;
                        arrayList2 = arrayList;
                    } else {
                        i5 = i3;
                        z7 = false;
                    }
                    z2 = z7;
                    i4 = 0;
                    getSecretChatHelper().processPendingEncMessages();
                    if (!z) {
                        for (int i14 = 0; i14 < this.updatesQueueChannels.size(); i14++) {
                            int keyAt = this.updatesQueueChannels.keyAt(i14);
                            if (arrayList2 == null || !arrayList2.contains(Integer.valueOf(keyAt))) {
                                processChannelsUpdatesQueue(keyAt, 0);
                            } else {
                                getChannelDifference(keyAt);
                            }
                        }
                        if (i5 != 0) {
                            getDifference();
                        } else {
                            for (int i15 = 0; i15 < 3; i15++) {
                                processUpdatesQueue(i15, 0);
                            }
                        }
                    }
                    if (z2) {
                        TLRPC.TL_messages_receivedQueue tL_messages_receivedQueue = new TLRPC.TL_messages_receivedQueue();
                        tL_messages_receivedQueue.max_qts = getMessagesStorage().getLastQtsValue();
                        getConnectionsManager().sendRequest(tL_messages_receivedQueue, $$Lambda$MessagesController$APUrbKxjmt4zz5EA4pydjUtoBA.INSTANCE);
                    }
                    if (i4 != 0) {
                        AndroidUtilities.runOnUIThread(new Runnable() {
                            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$La5xfDs6WHKPxOcCBVobO9K3Cvg */

                            public final void run() {
                                MessagesController.this.lambda$processUpdates$264$MessagesController();
                            }
                        });
                    }
                    getMessagesStorage().saveDiffParams(getMessagesStorage().getLastSeqValue(), getMessagesStorage().getLastPtsValue(), getMessagesStorage().getLastDateValue(), getMessagesStorage().getLastQtsValue());
                } else if (!(updates instanceof TLRPC.TL_updatesTooLong)) {
                    if (updates instanceof UserActionUpdatesSeq) {
                        getMessagesStorage().setLastSeqValue(updates.seq);
                    } else if (updates instanceof UserActionUpdatesPts) {
                        if (updates.chat_id != 0) {
                            this.channelsPts.put(updates.chat_id, updates.pts);
                            getMessagesStorage().saveChannelPts(updates.chat_id, updates.pts);
                        } else {
                            getMessagesStorage().setLastPtsValue(updates.pts);
                        }
                    }
                }
            }
            z2 = false;
            getSecretChatHelper().processPendingEncMessages();
            if (!z) {
            }
            if (z2) {
            }
            if (i4 != 0) {
            }
            getMessagesStorage().saveDiffParams(getMessagesStorage().getLastSeqValue(), getMessagesStorage().getLastPtsValue(), getMessagesStorage().getLastDateValue(), getMessagesStorage().getLastQtsValue());
        }
        z2 = false;
        i5 = 0;
        getSecretChatHelper().processPendingEncMessages();
        if (!z) {
        }
        if (z2) {
        }
        if (i4 != 0) {
        }
        getMessagesStorage().saveDiffParams(getMessagesStorage().getLastSeqValue(), getMessagesStorage().getLastPtsValue(), getMessagesStorage().getLastDateValue(), getMessagesStorage().getLastQtsValue());
    }

    public /* synthetic */ void lambda$processUpdates$259$MessagesController(boolean z, int i, ArrayList arrayList) {
        if (z) {
            getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 64);
        }
        updateInterfaceWithMessages((long) i, arrayList, false);
        getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
    }

    public /* synthetic */ void lambda$processUpdates$260$MessagesController(boolean z, TLRPC.Updates updates, ArrayList arrayList) {
        if (z) {
            getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 64);
        }
        updateInterfaceWithMessages((long) (-updates.chat_id), arrayList, false);
        getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
    }

    public /* synthetic */ void lambda$null$261$MessagesController(ArrayList arrayList) {
        getNotificationsController().processNewMessages(arrayList, true, false, null);
    }

    public /* synthetic */ void lambda$processUpdates$262$MessagesController(ArrayList arrayList) {
        AndroidUtilities.runOnUIThread(new Runnable(arrayList) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$bMLaYnXlI2JQzaOmGXUEROc_p4M */
            private final /* synthetic */ ArrayList f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                MessagesController.this.lambda$null$261$MessagesController(this.f$1);
            }
        });
    }

    public /* synthetic */ void lambda$processUpdates$264$MessagesController() {
        getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 4);
    }

    public void ensureMessagesLoaded(final long j, boolean z, int i, final Runnable runnable) {
        int i2;
        SharedPreferences notificationsSettings = getNotificationsSettings(this.currentAccount);
        if (i == 0) {
            i2 = notificationsSettings.getInt("diditem" + j, 0);
        } else {
            i2 = i;
        }
        final int generateClassGuid = ConnectionsManager.generateClassGuid();
        getNotificationCenter().addObserver(new NotificationCenter.NotificationCenterDelegate() {
            /* class im.guobwnxjuc.messenger.MessagesController.AnonymousClass1 */

            @Override // im.guobwnxjuc.messenger.NotificationCenter.NotificationCenterDelegate
            public void didReceivedNotification(int i, int i2, Object... objArr) {
                if (i == NotificationCenter.messagesDidLoad && ((Integer) objArr[10]).intValue() == generateClassGuid) {
                    boolean booleanValue = ((Boolean) objArr[3]).booleanValue();
                    if (!((ArrayList) objArr[2]).isEmpty() || !booleanValue) {
                        MessagesController.this.getNotificationCenter().removeObserver(this, NotificationCenter.didReceiveNewMessages);
                        runnable.run();
                        return;
                    }
                    MessagesController.this.loadMessages(j, 20, 3, 0, false, 0, generateClassGuid, 3, 0, false, false, 0);
                }
            }
        }, NotificationCenter.messagesDidLoad);
        loadMessages(j, 1, i2, 0, true, 0, generateClassGuid, 3, 0, false, false, 0);
    }

    /* JADX DEBUG: Failed to insert an additional move for type inference into block B:1022:0x146f */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r31v12, types: [java.util.ArrayList] */
    /* JADX WARNING: Removed duplicated region for block: B:541:0x0c7a  */
    /* JADX WARNING: Removed duplicated region for block: B:580:0x0d14  */
    /* JADX WARNING: Removed duplicated region for block: B:648:0x0e83  */
    /* JADX WARNING: Removed duplicated region for block: B:672:0x0edd  */
    /* JADX WARNING: Removed duplicated region for block: B:673:0x0ee6  */
    /* JADX WARNING: Removed duplicated region for block: B:682:0x0f14  */
    /* JADX WARNING: Removed duplicated region for block: B:683:0x0f17  */
    /* JADX WARNING: Removed duplicated region for block: B:686:0x0f27  */
    /* JADX WARNING: Removed duplicated region for block: B:689:0x0f48  */
    /* JADX WARNING: Removed duplicated region for block: B:690:0x0f4a  */
    /* JADX WARNING: Removed duplicated region for block: B:693:0x0f54  */
    /* JADX WARNING: Removed duplicated region for block: B:701:0x0f91  */
    /* JADX WARNING: Removed duplicated region for block: B:702:0x0f97  */
    /* JADX WARNING: Removed duplicated region for block: B:705:0x0fa2  */
    /* JADX WARNING: Removed duplicated region for block: B:775:0x1149  */
    /* JADX WARNING: Removed duplicated region for block: B:780:0x116c  */
    /* JADX WARNING: Removed duplicated region for block: B:782:0x1170  */
    /* JADX WARNING: Removed duplicated region for block: B:810:0x11d3  */
    /* JADX WARNING: Removed duplicated region for block: B:842:0x1261  */
    /* JADX WARNING: Removed duplicated region for block: B:852:0x1285  */
    /* JADX WARNING: Removed duplicated region for block: B:866:0x12ed  */
    /* JADX WARNING: Removed duplicated region for block: B:867:0x12f6  */
    /* JADX WARNING: Removed duplicated region for block: B:878:0x1324  */
    /* JADX WARNING: Removed duplicated region for block: B:888:0x1375  */
    public boolean processUpdateArray(ArrayList<TLRPC.Update> arrayList, ArrayList<TLRPC.User> arrayList2, ArrayList<TLRPC.Chat> arrayList3, boolean z, int i) {
        boolean z2;
        ConcurrentHashMap<Integer, TLRPC.User> concurrentHashMap;
        ConcurrentHashMap<Integer, TLRPC.Chat> concurrentHashMap2;
        ArrayList<Long> arrayList4;
        SparseLongArray sparseLongArray;
        boolean z3;
        LongSparseArray<TLRPC.WebPage> longSparseArray;
        SparseArray sparseArray;
        ArrayList arrayList5;
        long j;
        TLRPC.Message message;
        int i2;
        int i3;
        TLRPC.Chat chat;
        boolean z4;
        boolean z5;
        long j2;
        int i4;
        int i5;
        int i6;
        TLRPC.SendMessageAction sendMessageAction;
        long j3;
        boolean z6;
        int i7;
        ArrayList<Integer> arrayList6;
        ArrayList<Long> arrayList7;
        SparseArray<SparseIntArray> sparseArray2;
        ArrayList arrayList8;
        SparseIntArray sparseIntArray;
        SparseLongArray sparseLongArray2;
        SparseLongArray sparseLongArray3;
        SparseArray<SparseIntArray> sparseArray3;
        LongSparseArray longSparseArray2;
        ArrayList arrayList9;
        SparseIntArray sparseIntArray2;
        SparseArray<SparseIntArray> sparseArray4;
        boolean z7;
        TLRPC.Message message2;
        Integer num;
        ArrayList arrayList10;
        HashMap hashMap;
        ArrayList arrayList11;
        int i8;
        int i9;
        int i10;
        ArrayList arrayList12;
        ArrayList<TLRPC.Message> arrayList13;
        ArrayList<TLRPC.Message> arrayList14;
        long j4;
        boolean z8;
        LongSparseArray longSparseArray3;
        SparseArray sparseArray5;
        ArrayList<TLRPC.Message> arrayList15;
        TLRPC.User user;
        ArrayList arrayList16;
        ArrayList arrayList17;
        int i11;
        int i12;
        int i13;
        ArrayList<TLRPC.Update> arrayList18 = arrayList;
        if (arrayList.isEmpty()) {
            if (!(arrayList2 == null && arrayList3 == null)) {
                AndroidUtilities.runOnUIThread(new Runnable(arrayList2, arrayList3) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$MP_rLNkAl1wz_vz34W5iru1FpI */
                    private final /* synthetic */ ArrayList f$1;
                    private final /* synthetic */ ArrayList f$2;

                    {
                        this.f$1 = r2;
                        this.f$2 = r3;
                    }

                    public final void run() {
                        MessagesController.this.lambda$processUpdateArray$265$MessagesController(this.f$1, this.f$2);
                    }
                });
            }
            return true;
        }
        long currentTimeMillis = System.currentTimeMillis();
        if (arrayList2 != null) {
            concurrentHashMap = new ConcurrentHashMap<>();
            int size = arrayList2.size();
            for (int i14 = 0; i14 < size; i14++) {
                TLRPC.User user2 = arrayList2.get(i14);
                concurrentHashMap.put(Integer.valueOf(user2.id), user2);
            }
            z2 = true;
        } else {
            concurrentHashMap = this.users;
            z2 = false;
        }
        if (arrayList3 != null) {
            ConcurrentHashMap<Integer, TLRPC.Chat> concurrentHashMap3 = new ConcurrentHashMap<>();
            int size2 = arrayList3.size();
            for (int i15 = 0; i15 < size2; i15++) {
                TLRPC.Chat chat2 = arrayList3.get(i15);
                concurrentHashMap3.put(Integer.valueOf(chat2.id), chat2);
            }
            concurrentHashMap2 = concurrentHashMap3;
        } else {
            concurrentHashMap2 = this.chats;
            z2 = false;
        }
        boolean z9 = z ? false : z2;
        if (!(arrayList2 == null && arrayList3 == null)) {
            AndroidUtilities.runOnUIThread(new Runnable(arrayList2, arrayList3) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$FKBsjmw5x8a5onYsIA2j_vFcxpE */
                private final /* synthetic */ ArrayList f$1;
                private final /* synthetic */ ArrayList f$2;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                }

                public final void run() {
                    MessagesController.this.lambda$processUpdateArray$266$MessagesController(this.f$1, this.f$2);
                }
            });
        }
        HashMap hashMap2 = new HashMap();
        for (int i16 = 0; i16 < arrayList.size(); i16++) {
            TLRPC.Update update = arrayList18.get(i16);
            if (update instanceof TLRPCCall.TL_UpdateMeetCallRequested) {
                hashMap2.put(((TLRPCCall.TL_UpdateMeetCallRequested) update).id, "1");
            }
            if (update instanceof TLRPCCall.TL_UpdateMeetCallDiscarded) {
                TLRPCCall.TL_UpdateMeetCallDiscarded tL_UpdateMeetCallDiscarded = (TLRPCCall.TL_UpdateMeetCallDiscarded) update;
                if (hashMap2.get(tL_UpdateMeetCallDiscarded.id) != null) {
                    hashMap2.remove(tL_UpdateMeetCallDiscarded.id);
                }
            }
        }
        int size3 = arrayList.size();
        HashMap hashMap3 = hashMap2;
        long j5 = currentTimeMillis;
        LongSparseArray<TLRPC.WebPage> longSparseArray4 = null;
        SparseLongArray sparseLongArray4 = null;
        SparseArray sparseArray6 = null;
        SparseArray sparseArray7 = null;
        SparseArray<SparseIntArray> sparseArray8 = null;
        ArrayList<Integer> arrayList19 = null;
        LongSparseArray longSparseArray5 = null;
        LongSparseArray longSparseArray6 = null;
        ArrayList<Long> arrayList20 = null;
        SparseLongArray sparseLongArray5 = null;
        ArrayList arrayList21 = null;
        LongSparseArray longSparseArray7 = null;
        ArrayList arrayList22 = null;
        ArrayList arrayList23 = null;
        ArrayList<TLRPC.Message> arrayList24 = null;
        ArrayList<TLRPC.Message> arrayList25 = null;
        SparseIntArray sparseIntArray3 = null;
        SparseIntArray sparseIntArray4 = null;
        ArrayList arrayList26 = null;
        int i17 = 0;
        int i18 = 0;
        boolean z10 = false;
        while (i17 < size3) {
            TLRPC.Update update2 = arrayList18.get(i17);
            boolean z11 = update2 instanceof TLRPC.TL_updateNewMessage;
            if (z11 || (update2 instanceof TLRPC.TL_updateNewChannelMessage) || (update2 instanceof TLRPC.TL_updateNewScheduledMessage)) {
                sparseArray = sparseArray7;
                int i19 = i18;
                arrayList5 = arrayList23;
                long j6 = j5;
                if (z11) {
                    message = ((TLRPC.TL_updateNewMessage) update2).message;
                } else if (update2 instanceof TLRPC.TL_updateNewScheduledMessage) {
                    message = ((TLRPC.TL_updateNewScheduledMessage) update2).message;
                } else {
                    message = ((TLRPC.TL_updateNewChannelMessage) update2).message;
                    if (!message.out && message.from_id == getUserConfig().getClientUserId()) {
                        message.out = true;
                    }
                }
                if (message.to_id.channel_id != 0) {
                    i3 = message.to_id.channel_id;
                } else if (message.to_id.chat_id != 0) {
                    i3 = message.to_id.chat_id;
                } else if (message.to_id.user_id != 0) {
                    i2 = message.to_id.user_id;
                    i3 = 0;
                    if (i3 == 0) {
                        chat = concurrentHashMap2.get(Integer.valueOf(i3));
                        if (chat == null) {
                            chat = getChat(Integer.valueOf(i3));
                        }
                        if (chat == null) {
                            chat = getMessagesStorage().getChatSync(i3);
                            putChat(chat, true);
                        }
                    } else {
                        chat = null;
                    }
                    if (z9) {
                        if (i3 == 0 || chat != null) {
                            int size4 = message.entities.size() + 3;
                            int i20 = 0;
                            while (i20 < size4) {
                                if (i20 != 0) {
                                    if (i20 == 1) {
                                        i4 = message.from_id;
                                        if (message.post) {
                                            i2 = i4;
                                            z5 = true;
                                            if (i2 <= 0) {
                                                TLRPC.User user3 = concurrentHashMap.get(Integer.valueOf(i2));
                                                j2 = j6;
                                                if (user3 == null || (!z5 && user3.min)) {
                                                    user3 = getUser(Integer.valueOf(i2));
                                                }
                                                if (user3 == null || (!z5 && user3.min)) {
                                                    user3 = getMessagesStorage().getUserSync(i2);
                                                    if (user3 != null && !z5 && user3.min) {
                                                        user3 = null;
                                                    }
                                                    putUser(user3, true);
                                                }
                                                if (user3 == null) {
                                                    if (!BuildVars.LOGS_ENABLED) {
                                                        return false;
                                                    }
                                                    FileLog.d("not found user " + i2);
                                                    return false;
                                                } else if (!message.out && i20 == 1 && user3.status != null && user3.status.expires <= 0) {
                                                    if (Math.abs(getConnectionsManager().getCurrentTime() - message.date) < 30) {
                                                        this.onlinePrivacy.put(Integer.valueOf(i2), Integer.valueOf(message.date));
                                                        i19 |= 4;
                                                    }
                                                    i20++;
                                                    size4 = size4;
                                                    sparseArray6 = sparseArray6;
                                                    j6 = j2;
                                                }
                                            } else {
                                                j2 = j6;
                                            }
                                            i20++;
                                            size4 = size4;
                                            sparseArray6 = sparseArray6;
                                            j6 = j2;
                                        }
                                    } else if (i20 == 2) {
                                        i2 = message.fwd_from != null ? message.fwd_from.from_id : 0;
                                    } else {
                                        TLRPC.MessageEntity messageEntity = message.entities.get(i20 - 3);
                                        i4 = messageEntity instanceof TLRPC.TL_messageEntityMentionName ? ((TLRPC.TL_messageEntityMentionName) messageEntity).user_id : 0;
                                    }
                                    i2 = i4;
                                }
                                z5 = false;
                                if (i2 <= 0) {
                                }
                                i20++;
                                size4 = size4;
                                sparseArray6 = sparseArray6;
                                j6 = j2;
                            }
                        } else if (!BuildVars.LOGS_ENABLED) {
                            return false;
                        } else {
                            FileLog.d("not found chat " + i3);
                            return false;
                        }
                    }
                    j = j6;
                    if (chat != null && chat.megagroup) {
                        message.flags |= Integer.MIN_VALUE;
                    }
                    if (message.action instanceof TLRPC.TL_messageActionChatDeleteUser) {
                        TLRPC.User user4 = concurrentHashMap.get(Integer.valueOf(message.action.user_id));
                        if (user4 != null && user4.bot) {
                            message.reply_markup = new TLRPC.TL_replyKeyboardHide();
                            message.flags |= 64;
                        } else if (message.from_id == getUserConfig().getClientUserId() && message.action.user_id == getUserConfig().getClientUserId()) {
                            longSparseArray = longSparseArray4;
                            longSparseArray5 = longSparseArray5;
                            longSparseArray6 = longSparseArray6;
                            sparseArray8 = sparseArray8;
                            sparseLongArray4 = sparseLongArray4;
                            sparseLongArray5 = sparseLongArray5;
                            arrayList20 = arrayList20;
                            arrayList19 = arrayList19;
                            sparseIntArray4 = sparseIntArray4;
                            i18 = i19;
                            sparseArray6 = sparseArray6;
                        }
                    }
                    ImageLoader.saveMessageThumbs(message);
                    int clientUserId = getUserConfig().getClientUserId();
                    if (message.to_id.chat_id == 0) {
                        message.dialog_id = (long) (-message.to_id.chat_id);
                    } else if (message.to_id.channel_id != 0) {
                        message.dialog_id = (long) (-message.to_id.channel_id);
                    } else {
                        if (message.to_id.user_id == clientUserId) {
                            message.to_id.user_id = message.from_id;
                        }
                        if (clientUserId == 0) {
                            message.dialog_id = (long) message.from_id;
                        } else {
                            message.dialog_id = (long) message.to_id.user_id;
                        }
                    }
                    if (!(update2 instanceof TLRPC.TL_updateNewScheduledMessage)) {
                        if (arrayList24 == null) {
                            arrayList24 = new ArrayList<>();
                        }
                        arrayList24.add(message);
                        j5 = j;
                        MessageObject messageObject = new MessageObject(this.currentAccount, message, concurrentHashMap, concurrentHashMap2, this.createdScheduledDialogIds.contains(Long.valueOf(message.dialog_id)));
                        messageObject.scheduled = true;
                        if (longSparseArray7 == null) {
                            longSparseArray7 = new LongSparseArray();
                        }
                        ArrayList arrayList27 = (ArrayList) longSparseArray7.get(message.dialog_id);
                        if (arrayList27 == null) {
                            arrayList27 = new ArrayList();
                            longSparseArray7.put(message.dialog_id, arrayList27);
                        }
                        arrayList27.add(messageObject);
                        arrayList24 = arrayList24;
                        longSparseArray7 = longSparseArray7;
                        longSparseArray6 = longSparseArray6;
                    } else {
                        j5 = j;
                        ArrayList<TLRPC.Message> arrayList28 = arrayList25;
                        if (arrayList25 == null) {
                            arrayList28 = new ArrayList<>();
                        }
                        arrayList28.add(message);
                        ConcurrentHashMap<Long, Integer> concurrentHashMap4 = message.out ? this.dialogs_read_outbox_max : this.dialogs_read_inbox_max;
                        Integer num2 = concurrentHashMap4.get(Long.valueOf(message.dialog_id));
                        if (num2 == null) {
                            num2 = Integer.valueOf(getMessagesStorage().getDialogReadMax(message.out, message.dialog_id));
                            concurrentHashMap4.put(Long.valueOf(message.dialog_id), num2);
                        }
                        message.unread = num2.intValue() < message.id && (chat == null || !ChatObject.isNotInChat(chat)) && !(message.action instanceof TLRPC.TL_messageActionChatMigrateTo) && !(message.action instanceof TLRPC.TL_messageActionChannelCreate);
                        if (message.dialog_id == ((long) clientUserId)) {
                            if (!message.from_scheduled) {
                                z4 = false;
                                message.unread = false;
                            } else {
                                z4 = false;
                            }
                            message.media_unread = z4;
                            message.out = true;
                        }
                        MessageObject messageObject2 = new MessageObject(this.currentAccount, message, concurrentHashMap, concurrentHashMap2, this.createdDialogIds.contains(Long.valueOf(message.dialog_id)));
                        if (messageObject2.type == 11) {
                            i19 |= 8;
                        } else if (messageObject2.type == 10) {
                            i19 |= 16;
                        }
                        longSparseArray6 = longSparseArray6 == null ? new LongSparseArray() : longSparseArray6;
                        ArrayList arrayList29 = (ArrayList) longSparseArray6.get(message.dialog_id);
                        if (arrayList29 == null) {
                            arrayList29 = new ArrayList();
                            longSparseArray6.put(message.dialog_id, arrayList29);
                        }
                        arrayList29.add(messageObject2);
                        if ((!messageObject2.isOut() || messageObject2.messageOwner.from_scheduled) && messageObject2.isUnread()) {
                            ArrayList arrayList30 = arrayList5 == null ? new ArrayList() : arrayList5;
                            arrayList30.add(messageObject2);
                            arrayList25 = arrayList28;
                            arrayList5 = arrayList30;
                        } else {
                            arrayList25 = arrayList28;
                        }
                    }
                    i18 = i19;
                    longSparseArray = longSparseArray4;
                    longSparseArray5 = longSparseArray5;
                    sparseArray8 = sparseArray8;
                    sparseLongArray4 = sparseLongArray4;
                    sparseLongArray5 = sparseLongArray5;
                    arrayList20 = arrayList20;
                    arrayList19 = arrayList19;
                    sparseIntArray4 = sparseIntArray4;
                    sparseArray6 = sparseArray6;
                    arrayList25 = arrayList25;
                    arrayList23 = arrayList5;
                    sparseArray7 = sparseArray;
                    longSparseArray4 = longSparseArray;
                    size3 = size3;
                    i17++;
                    arrayList18 = arrayList;
                    arrayList25 = arrayList25;
                } else {
                    i3 = 0;
                }
                i2 = 0;
                if (i3 == 0) {
                }
                if (z9) {
                }
                j = j6;
                message.flags |= Integer.MIN_VALUE;
                if (message.action instanceof TLRPC.TL_messageActionChatDeleteUser) {
                }
                ImageLoader.saveMessageThumbs(message);
                int clientUserId2 = getUserConfig().getClientUserId();
                if (message.to_id.chat_id == 0) {
                }
                if (!(update2 instanceof TLRPC.TL_updateNewScheduledMessage)) {
                }
                i18 = i19;
                longSparseArray = longSparseArray4;
                longSparseArray5 = longSparseArray5;
                sparseArray8 = sparseArray8;
                sparseLongArray4 = sparseLongArray4;
                sparseLongArray5 = sparseLongArray5;
                arrayList20 = arrayList20;
                arrayList19 = arrayList19;
                sparseIntArray4 = sparseIntArray4;
                sparseArray6 = sparseArray6;
                arrayList25 = arrayList25;
                arrayList23 = arrayList5;
                sparseArray7 = sparseArray;
                longSparseArray4 = longSparseArray;
                size3 = size3;
                i17++;
                arrayList18 = arrayList;
                arrayList25 = arrayList25;
            } else {
                if (update2 instanceof TLRPC.TL_updateReadMessagesContents) {
                    TLRPC.TL_updateReadMessagesContents tL_updateReadMessagesContents = (TLRPC.TL_updateReadMessagesContents) update2;
                    if (arrayList20 == null) {
                        arrayList20 = new ArrayList<>();
                    }
                    int size5 = tL_updateReadMessagesContents.messages.size();
                    int i21 = 0;
                    while (i21 < size5) {
                        arrayList20.add(Long.valueOf((long) tL_updateReadMessagesContents.messages.get(i21).intValue()));
                        i21++;
                        size5 = size5;
                        longSparseArray6 = longSparseArray6;
                        longSparseArray5 = longSparseArray5;
                    }
                } else {
                    LongSparseArray longSparseArray8 = longSparseArray5;
                    if (update2 instanceof TLRPC.TL_updateChannelReadMessagesContents) {
                        TLRPC.TL_updateChannelReadMessagesContents tL_updateChannelReadMessagesContents = (TLRPC.TL_updateChannelReadMessagesContents) update2;
                        if (arrayList20 == null) {
                            arrayList20 = new ArrayList<>();
                        }
                        int size6 = tL_updateChannelReadMessagesContents.messages.size();
                        int i22 = 0;
                        while (i22 < size6) {
                            arrayList20.add(Long.valueOf(((long) tL_updateChannelReadMessagesContents.messages.get(i22).intValue()) | (((long) tL_updateChannelReadMessagesContents.channel_id) << 32)));
                            i22++;
                            sparseArray8 = sparseArray8;
                            i18 = i18;
                        }
                        longSparseArray = longSparseArray4;
                        longSparseArray6 = longSparseArray6;
                        longSparseArray5 = longSparseArray8;
                    } else {
                        SparseArray<SparseIntArray> sparseArray9 = sparseArray8;
                        if (update2 instanceof TLRPC.TL_updateReadHistoryInbox) {
                            TLRPC.TL_updateReadHistoryInbox tL_updateReadHistoryInbox = (TLRPC.TL_updateReadHistoryInbox) update2;
                            if (sparseLongArray5 == null) {
                                sparseLongArray5 = new SparseLongArray();
                            }
                            if (tL_updateReadHistoryInbox.peer.chat_id != 0) {
                                sparseLongArray5.put(-tL_updateReadHistoryInbox.peer.chat_id, (long) tL_updateReadHistoryInbox.max_id);
                                i13 = -tL_updateReadHistoryInbox.peer.chat_id;
                            } else {
                                sparseLongArray5.put(tL_updateReadHistoryInbox.peer.user_id, (long) tL_updateReadHistoryInbox.max_id);
                                i13 = tL_updateReadHistoryInbox.peer.user_id;
                            }
                            long j7 = (long) i13;
                            Integer num3 = this.dialogs_read_inbox_max.get(Long.valueOf(j7));
                            if (num3 == null) {
                                num3 = Integer.valueOf(getMessagesStorage().getDialogReadMax(false, j7));
                            }
                            this.dialogs_read_inbox_max.put(Long.valueOf(j7), Integer.valueOf(Math.max(num3.intValue(), tL_updateReadHistoryInbox.max_id)));
                        } else if (update2 instanceof TLRPC.TL_updateReadHistoryOutbox) {
                            TLRPC.TL_updateReadHistoryOutbox tL_updateReadHistoryOutbox = (TLRPC.TL_updateReadHistoryOutbox) update2;
                            if (sparseLongArray4 == null) {
                                sparseLongArray4 = new SparseLongArray();
                            }
                            if (tL_updateReadHistoryOutbox.peer.chat_id != 0) {
                                sparseLongArray4.put(-tL_updateReadHistoryOutbox.peer.chat_id, (long) tL_updateReadHistoryOutbox.max_id);
                                i12 = -tL_updateReadHistoryOutbox.peer.chat_id;
                            } else {
                                sparseLongArray4.put(tL_updateReadHistoryOutbox.peer.user_id, (long) tL_updateReadHistoryOutbox.max_id);
                                i12 = tL_updateReadHistoryOutbox.peer.user_id;
                            }
                            long j8 = (long) i12;
                            Integer num4 = this.dialogs_read_outbox_max.get(Long.valueOf(j8));
                            if (num4 == null) {
                                num4 = Integer.valueOf(getMessagesStorage().getDialogReadMax(true, j8));
                            }
                            this.dialogs_read_outbox_max.put(Long.valueOf(j8), Integer.valueOf(Math.max(num4.intValue(), tL_updateReadHistoryOutbox.max_id)));
                        } else if (update2 instanceof TLRPC.TL_updateDeleteMessages) {
                            TLRPC.TL_updateDeleteMessages tL_updateDeleteMessages = (TLRPC.TL_updateDeleteMessages) update2;
                            if (sparseArray6 == null) {
                                sparseArray6 = new SparseArray();
                            }
                            ArrayList arrayList31 = (ArrayList) sparseArray6.get(0);
                            if (arrayList31 == null) {
                                arrayList31 = new ArrayList();
                                sparseArray6.put(0, arrayList31);
                            }
                            arrayList31.addAll(tL_updateDeleteMessages.messages);
                        } else if (update2 instanceof TLRPC.TL_updateDeleteScheduledMessages) {
                            TLRPC.TL_updateDeleteScheduledMessages tL_updateDeleteScheduledMessages = (TLRPC.TL_updateDeleteScheduledMessages) update2;
                            if (sparseArray7 == null) {
                                sparseArray7 = new SparseArray();
                            }
                            if (tL_updateDeleteScheduledMessages.peer instanceof TLRPC.TL_peerChannel) {
                                i11 = tL_updateDeleteScheduledMessages.peer.channel_id;
                                arrayList17 = (ArrayList) sparseArray7.get(i11);
                            } else {
                                arrayList17 = (ArrayList) sparseArray7.get(0);
                                i11 = 0;
                            }
                            if (arrayList17 == null) {
                                arrayList17 = new ArrayList();
                                sparseArray7.put(i11, arrayList17);
                            }
                            arrayList17.addAll(tL_updateDeleteScheduledMessages.messages);
                        } else {
                            boolean z12 = update2 instanceof TLRPC.TL_updateUserTyping;
                            if (z12 || (update2 instanceof TLRPC.TL_updateChatUserTyping)) {
                                sparseArray = sparseArray7;
                                arrayList5 = arrayList23;
                                if (z12) {
                                    TLRPC.TL_updateUserTyping tL_updateUserTyping = (TLRPC.TL_updateUserTyping) update2;
                                    i6 = tL_updateUserTyping.user_id;
                                    sendMessageAction = tL_updateUserTyping.action;
                                    i5 = 0;
                                } else {
                                    TLRPC.TL_updateChatUserTyping tL_updateChatUserTyping = (TLRPC.TL_updateChatUserTyping) update2;
                                    int i23 = tL_updateChatUserTyping.chat_id;
                                    int i24 = tL_updateChatUserTyping.user_id;
                                    sendMessageAction = tL_updateChatUserTyping.action;
                                    i5 = i23;
                                    i6 = i24;
                                }
                                if (i6 != getUserConfig().getClientUserId()) {
                                    long j9 = (long) (-i5);
                                    if (j9 == 0) {
                                        j9 = (long) i6;
                                    }
                                    ArrayList<PrintingUser> arrayList32 = this.printingUsers.get(Long.valueOf(j9));
                                    if (sendMessageAction instanceof TLRPC.TL_sendMessageCancelAction) {
                                        if (arrayList32 != null) {
                                            int size7 = arrayList32.size();
                                            int i25 = 0;
                                            while (true) {
                                                if (i25 >= size7) {
                                                    break;
                                                } else if (arrayList32.get(i25).userId == i6) {
                                                    arrayList32.remove(i25);
                                                    z10 = true;
                                                    break;
                                                } else {
                                                    i25++;
                                                }
                                            }
                                            if (arrayList32.isEmpty()) {
                                                this.printingUsers.remove(Long.valueOf(j9));
                                            }
                                        }
                                        j3 = j5;
                                    } else {
                                        if (arrayList32 == null) {
                                            arrayList32 = new ArrayList<>();
                                            this.printingUsers.put(Long.valueOf(j9), arrayList32);
                                        }
                                        Iterator<PrintingUser> it = arrayList32.iterator();
                                        while (true) {
                                            if (!it.hasNext()) {
                                                j3 = j5;
                                                z6 = false;
                                                break;
                                            }
                                            PrintingUser next = it.next();
                                            if (next.userId == i6) {
                                                j3 = j5;
                                                next.lastTime = j3;
                                                if (next.action.getClass() != sendMessageAction.getClass()) {
                                                    z10 = true;
                                                }
                                                next.action = sendMessageAction;
                                                z6 = true;
                                            }
                                        }
                                        if (!z6) {
                                            PrintingUser printingUser = new PrintingUser();
                                            printingUser.userId = i6;
                                            printingUser.lastTime = j3;
                                            printingUser.action = sendMessageAction;
                                            arrayList32.add(printingUser);
                                            z10 = true;
                                        }
                                    }
                                    if (Math.abs(getConnectionsManager().getCurrentTime() - i) < 30) {
                                        this.onlinePrivacy.put(Integer.valueOf(i6), Integer.valueOf(i));
                                    }
                                } else {
                                    j3 = j5;
                                }
                                longSparseArray = longSparseArray4;
                                longSparseArray5 = longSparseArray8;
                                j5 = j3;
                                longSparseArray6 = longSparseArray6;
                                sparseArray8 = sparseArray9;
                                sparseLongArray4 = sparseLongArray4;
                                sparseLongArray5 = sparseLongArray5;
                                arrayList20 = arrayList20;
                                arrayList19 = arrayList19;
                                sparseIntArray4 = sparseIntArray4;
                                i18 = i18;
                                arrayList25 = arrayList25;
                                arrayList23 = arrayList5;
                                sparseArray7 = sparseArray;
                            } else {
                                if (update2 instanceof TLRPC.TL_updateChatParticipants) {
                                    TLRPC.TL_updateChatParticipants tL_updateChatParticipants = (TLRPC.TL_updateChatParticipants) update2;
                                    i18 |= 32;
                                    if (arrayList22 == null) {
                                        arrayList22 = new ArrayList();
                                    }
                                    arrayList22.add(tL_updateChatParticipants.participants);
                                    longSparseArray = longSparseArray4;
                                    arrayList22 = arrayList22;
                                } else {
                                    if (update2 instanceof TLRPC.TL_updateUserStatus) {
                                        i18 |= 4;
                                        if (arrayList21 == null) {
                                            arrayList21 = new ArrayList();
                                        }
                                        arrayList16 = arrayList21;
                                        arrayList16.add(update2);
                                    } else if (update2 instanceof TLRPC.TL_updateUserName) {
                                        i18 |= 1;
                                        if (arrayList21 == null) {
                                            arrayList21 = new ArrayList();
                                        }
                                        arrayList16 = arrayList21;
                                        arrayList16.add(update2);
                                    } else if (update2 instanceof TLRPC.TL_updateUserPhoto) {
                                        i18 |= 2;
                                        getMessagesStorage().clearUserPhotos(((TLRPC.TL_updateUserPhoto) update2).user_id);
                                        if (arrayList21 == null) {
                                            arrayList21 = new ArrayList();
                                        }
                                        arrayList16 = arrayList21;
                                        arrayList16.add(update2);
                                    } else if (update2 instanceof TLRPC.TL_updateUserPhone) {
                                        i18 |= 1024;
                                        if (arrayList21 == null) {
                                            arrayList21 = new ArrayList();
                                        }
                                        arrayList16 = arrayList21;
                                        arrayList16.add(update2);
                                    } else {
                                        int i26 = i18;
                                        if (update2 instanceof TLRPC.TL_updatePeerSettings) {
                                            TLRPC.TL_updatePeerSettings tL_updatePeerSettings = (TLRPC.TL_updatePeerSettings) update2;
                                            if (arrayList19 == null) {
                                                arrayList19 = new ArrayList<>();
                                            }
                                            if ((tL_updatePeerSettings.peer instanceof TLRPC.TL_peerUser) && (user = concurrentHashMap.get(Integer.valueOf(tL_updatePeerSettings.peer.user_id))) != null) {
                                                if (user.contact) {
                                                    int indexOf = arrayList19.indexOf(Integer.valueOf(-tL_updatePeerSettings.peer.user_id));
                                                    if (indexOf != -1) {
                                                        arrayList19.remove(indexOf);
                                                    }
                                                    if (!arrayList19.contains(Integer.valueOf(tL_updatePeerSettings.peer.user_id))) {
                                                        arrayList19.add(Integer.valueOf(tL_updatePeerSettings.peer.user_id));
                                                    }
                                                } else {
                                                    int indexOf2 = arrayList19.indexOf(Integer.valueOf(tL_updatePeerSettings.peer.user_id));
                                                    if (indexOf2 != -1) {
                                                        arrayList19.remove(indexOf2);
                                                    }
                                                    if (!arrayList19.contains(Integer.valueOf(tL_updatePeerSettings.peer.user_id))) {
                                                        arrayList19.add(Integer.valueOf(-tL_updatePeerSettings.peer.user_id));
                                                    }
                                                }
                                            }
                                            if (arrayList21 == null) {
                                                arrayList21 = new ArrayList();
                                            }
                                            arrayList21.add(update2);
                                            i18 = i26;
                                            arrayList21 = arrayList21;
                                            longSparseArray6 = longSparseArray6;
                                            longSparseArray5 = longSparseArray8;
                                            sparseArray8 = sparseArray9;
                                        } else {
                                            if (update2 instanceof TLRPC.TL_updateNewEncryptedMessage) {
                                                TLRPC.TL_updateNewEncryptedMessage tL_updateNewEncryptedMessage = (TLRPC.TL_updateNewEncryptedMessage) update2;
                                                ArrayList<TLRPC.Message> decryptMessage = getSecretChatHelper().decryptMessage(tL_updateNewEncryptedMessage.message);
                                                if (decryptMessage == null || decryptMessage.isEmpty()) {
                                                    i7 = i26;
                                                    sparseArray = sparseArray7;
                                                    arrayList6 = arrayList19;
                                                    arrayList7 = arrayList20;
                                                    longSparseArray3 = longSparseArray8;
                                                    sparseArray2 = sparseArray9;
                                                    longSparseArray6 = longSparseArray6;
                                                } else {
                                                    long j10 = ((long) tL_updateNewEncryptedMessage.message.chat_id) << 32;
                                                    LongSparseArray longSparseArray9 = longSparseArray6 == null ? new LongSparseArray() : longSparseArray6;
                                                    ArrayList arrayList33 = (ArrayList) longSparseArray9.get(j10);
                                                    if (arrayList33 == null) {
                                                        arrayList33 = new ArrayList();
                                                        longSparseArray9.put(j10, arrayList33);
                                                    }
                                                    ArrayList arrayList34 = arrayList33;
                                                    int size8 = decryptMessage.size();
                                                    int i27 = 0;
                                                    while (i27 < size8) {
                                                        TLRPC.Message message3 = decryptMessage.get(i27);
                                                        ImageLoader.saveMessageThumbs(message3);
                                                        if (arrayList25 == null) {
                                                            sparseArray5 = sparseArray7;
                                                            arrayList15 = new ArrayList<>();
                                                        } else {
                                                            sparseArray5 = sparseArray7;
                                                            arrayList15 = arrayList25;
                                                        }
                                                        arrayList15.add(message3);
                                                        MessageObject messageObject3 = new MessageObject(this.currentAccount, message3, concurrentHashMap, concurrentHashMap2, this.createdDialogIds.contains(Long.valueOf(j10)));
                                                        arrayList34.add(messageObject3);
                                                        ArrayList arrayList35 = arrayList23 == null ? new ArrayList() : arrayList23;
                                                        arrayList35.add(messageObject3);
                                                        i27++;
                                                        arrayList23 = arrayList35;
                                                        arrayList34 = arrayList34;
                                                        arrayList25 = arrayList15;
                                                        decryptMessage = decryptMessage;
                                                        size8 = size8;
                                                        j10 = j10;
                                                        sparseArray7 = sparseArray5;
                                                        arrayList20 = arrayList20;
                                                        arrayList19 = arrayList19;
                                                        sparseArray9 = sparseArray9;
                                                        longSparseArray8 = longSparseArray8;
                                                        i26 = i26;
                                                    }
                                                    i7 = i26;
                                                    sparseArray = sparseArray7;
                                                    arrayList6 = arrayList19;
                                                    arrayList7 = arrayList20;
                                                    longSparseArray3 = longSparseArray8;
                                                    sparseArray2 = sparseArray9;
                                                    longSparseArray6 = longSparseArray9;
                                                }
                                                longSparseArray = longSparseArray4;
                                                longSparseArray5 = longSparseArray3;
                                            } else {
                                                i7 = i26;
                                                sparseArray = sparseArray7;
                                                arrayList6 = arrayList19;
                                                arrayList7 = arrayList20;
                                                sparseArray2 = sparseArray9;
                                                if (update2 instanceof TLRPC.TL_updateEncryptedChatTyping) {
                                                    TLRPC.TL_updateEncryptedChatTyping tL_updateEncryptedChatTyping = (TLRPC.TL_updateEncryptedChatTyping) update2;
                                                    TLRPC.EncryptedChat encryptedChatDB = getEncryptedChatDB(tL_updateEncryptedChatTyping.chat_id, true);
                                                    if (encryptedChatDB != null) {
                                                        long j11 = ((long) tL_updateEncryptedChatTyping.chat_id) << 32;
                                                        ArrayList<PrintingUser> arrayList36 = this.printingUsers.get(Long.valueOf(j11));
                                                        if (arrayList36 == null) {
                                                            arrayList36 = new ArrayList<>();
                                                            this.printingUsers.put(Long.valueOf(j11), arrayList36);
                                                        }
                                                        int size9 = arrayList36.size();
                                                        int i28 = 0;
                                                        while (true) {
                                                            if (i28 >= size9) {
                                                                j4 = j5;
                                                                z8 = false;
                                                                break;
                                                            }
                                                            PrintingUser printingUser2 = arrayList36.get(i28);
                                                            if (printingUser2.userId == encryptedChatDB.user_id) {
                                                                j4 = j5;
                                                                printingUser2.lastTime = j4;
                                                                printingUser2.action = new TLRPC.TL_sendMessageTypingAction();
                                                                z8 = true;
                                                                break;
                                                            }
                                                            i28++;
                                                        }
                                                        if (!z8) {
                                                            PrintingUser printingUser3 = new PrintingUser();
                                                            printingUser3.userId = encryptedChatDB.user_id;
                                                            printingUser3.lastTime = j4;
                                                            printingUser3.action = new TLRPC.TL_sendMessageTypingAction();
                                                            arrayList36.add(printingUser3);
                                                            z10 = true;
                                                        }
                                                        if (Math.abs(getConnectionsManager().getCurrentTime() - i) < 30) {
                                                            this.onlinePrivacy.put(Integer.valueOf(encryptedChatDB.user_id), Integer.valueOf(i));
                                                        }
                                                    } else {
                                                        j4 = j5;
                                                    }
                                                    longSparseArray = longSparseArray4;
                                                    longSparseArray5 = longSparseArray8;
                                                    j5 = j4;
                                                } else {
                                                    if (update2 instanceof TLRPC.TL_updateEncryptedMessagesRead) {
                                                        TLRPC.TL_updateEncryptedMessagesRead tL_updateEncryptedMessagesRead = (TLRPC.TL_updateEncryptedMessagesRead) update2;
                                                        SparseIntArray sparseIntArray5 = sparseIntArray3 == null ? new SparseIntArray() : sparseIntArray3;
                                                        sparseIntArray5.put(tL_updateEncryptedMessagesRead.chat_id, tL_updateEncryptedMessagesRead.max_date);
                                                        arrayList8 = arrayList26;
                                                        if (arrayList8 == null) {
                                                            arrayList8 = new ArrayList();
                                                        }
                                                        arrayList8.add(tL_updateEncryptedMessagesRead);
                                                        longSparseArray = longSparseArray4;
                                                        longSparseArray5 = longSparseArray8;
                                                        sparseIntArray3 = sparseIntArray5;
                                                    } else {
                                                        arrayList8 = arrayList26;
                                                        if (update2 instanceof TLRPC.TL_updateChatParticipantAdd) {
                                                            TLRPC.TL_updateChatParticipantAdd tL_updateChatParticipantAdd = (TLRPC.TL_updateChatParticipantAdd) update2;
                                                            getMessagesStorage().updateChatInfo(tL_updateChatParticipantAdd.chat_id, tL_updateChatParticipantAdd.user_id, 0, tL_updateChatParticipantAdd.inviter_id, tL_updateChatParticipantAdd.version);
                                                        } else if (update2 instanceof TLRPC.TL_updateChatParticipantDelete) {
                                                            TLRPC.TL_updateChatParticipantDelete tL_updateChatParticipantDelete = (TLRPC.TL_updateChatParticipantDelete) update2;
                                                            getMessagesStorage().updateChatInfo(tL_updateChatParticipantDelete.chat_id, tL_updateChatParticipantDelete.user_id, 1, 0, tL_updateChatParticipantDelete.version);
                                                        } else if ((update2 instanceof TLRPC.TL_updateDcOptions) || (update2 instanceof TLRPC.TL_updateConfig)) {
                                                            j = j5;
                                                            arrayList26 = arrayList8;
                                                            arrayList5 = arrayList23;
                                                            longSparseArray2 = longSparseArray6;
                                                            sparseLongArray3 = sparseLongArray4;
                                                            sparseLongArray2 = sparseLongArray5;
                                                            sparseArray3 = sparseArray2;
                                                            sparseIntArray = sparseIntArray4;
                                                            getConnectionsManager().updateDcSettings();
                                                            longSparseArray = longSparseArray4;
                                                            longSparseArray5 = longSparseArray8;
                                                            longSparseArray6 = longSparseArray2;
                                                            sparseArray8 = sparseArray3;
                                                            sparseLongArray4 = sparseLongArray3;
                                                            sparseLongArray5 = sparseLongArray2;
                                                            arrayList20 = arrayList7;
                                                            arrayList19 = arrayList6;
                                                            sparseIntArray4 = sparseIntArray;
                                                            i18 = i7;
                                                        } else if (update2 instanceof TLRPC.TL_updateEncryption) {
                                                            getSecretChatHelper().processUpdateEncryption((TLRPC.TL_updateEncryption) update2, concurrentHashMap);
                                                        } else if (update2 instanceof TLRPC.TL_updateUserBlocked) {
                                                            getMessagesStorage().getStorageQueue().postRunnable(new Runnable((TLRPC.TL_updateUserBlocked) update2) {
                                                                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$8nkzS7ZF9jV_DIXJsy23iqW2O3k */
                                                                private final /* synthetic */ TLRPC.TL_updateUserBlocked f$1;

                                                                {
                                                                    this.f$1 = r2;
                                                                }

                                                                public final void run() {
                                                                    MessagesController.this.lambda$processUpdateArray$268$MessagesController(this.f$1);
                                                                }
                                                            });
                                                        } else if (update2 instanceof TLRPC.TL_updateNotifySettings) {
                                                            if (arrayList21 == null) {
                                                                arrayList21 = new ArrayList();
                                                            }
                                                            arrayList21.add(update2);
                                                            longSparseArray = longSparseArray4;
                                                            longSparseArray5 = longSparseArray8;
                                                            arrayList21 = arrayList21;
                                                        } else {
                                                            if (update2 instanceof TLRPC.TL_updateServiceNotification) {
                                                                TLRPC.TL_updateServiceNotification tL_updateServiceNotification = (TLRPC.TL_updateServiceNotification) update2;
                                                                if (tL_updateServiceNotification.popup && tL_updateServiceNotification.message != null && tL_updateServiceNotification.message.length() > 0) {
                                                                    AndroidUtilities.runOnUIThread(new Runnable(tL_updateServiceNotification) {
                                                                        /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$19oCgxmSdmjkeI6Gk6aCWTcuksU */
                                                                        private final /* synthetic */ TLRPC.TL_updateServiceNotification f$1;

                                                                        {
                                                                            this.f$1 = r2;
                                                                        }

                                                                        public final void run() {
                                                                            MessagesController.this.lambda$processUpdateArray$269$MessagesController(this.f$1);
                                                                        }
                                                                    });
                                                                }
                                                                if ((tL_updateServiceNotification.flags & 2) == 0 || tL_updateServiceNotification.message.equals("ErrorSendMessageTooFreq")) {
                                                                    j = j5;
                                                                    arrayList26 = arrayList8;
                                                                    arrayList23 = arrayList23;
                                                                    longSparseArray6 = longSparseArray6;
                                                                    arrayList14 = arrayList25;
                                                                } else {
                                                                    TLRPC.TL_message tL_message = new TLRPC.TL_message();
                                                                    int newMessageId = getUserConfig().getNewMessageId();
                                                                    tL_message.id = newMessageId;
                                                                    tL_message.local_id = newMessageId;
                                                                    getUserConfig().saveConfig(false);
                                                                    tL_message.unread = true;
                                                                    tL_message.flags = 256;
                                                                    if (tL_updateServiceNotification.inbox_date != 0) {
                                                                        tL_message.date = tL_updateServiceNotification.inbox_date;
                                                                    } else {
                                                                        tL_message.date = (int) (System.currentTimeMillis() / 1000);
                                                                    }
                                                                    tL_message.from_id = 777000;
                                                                    tL_message.to_id = new TLRPC.TL_peerUser();
                                                                    tL_message.to_id.user_id = getUserConfig().getClientUserId();
                                                                    tL_message.dialog_id = 777000;
                                                                    if (tL_updateServiceNotification.media != null) {
                                                                        tL_message.media = tL_updateServiceNotification.media;
                                                                        tL_message.flags |= 512;
                                                                    }
                                                                    tL_message.message = tL_updateServiceNotification.message;
                                                                    if (tL_updateServiceNotification.entities != null) {
                                                                        tL_message.entities = tL_updateServiceNotification.entities;
                                                                        tL_message.flags |= 128;
                                                                    }
                                                                    if (arrayList25 == null) {
                                                                        arrayList25 = new ArrayList<>();
                                                                    }
                                                                    arrayList25.add(tL_message);
                                                                    arrayList26 = arrayList8;
                                                                    j = j5;
                                                                    MessageObject messageObject4 = new MessageObject(this.currentAccount, tL_message, concurrentHashMap, concurrentHashMap2, this.createdDialogIds.contains(Long.valueOf(tL_message.dialog_id)));
                                                                    longSparseArray6 = longSparseArray6 == null ? new LongSparseArray() : longSparseArray6;
                                                                    ArrayList arrayList37 = (ArrayList) longSparseArray6.get(tL_message.dialog_id);
                                                                    if (arrayList37 == null) {
                                                                        arrayList37 = new ArrayList();
                                                                        longSparseArray6.put(tL_message.dialog_id, arrayList37);
                                                                    }
                                                                    arrayList37.add(messageObject4);
                                                                    ArrayList arrayList38 = arrayList23;
                                                                    if (arrayList38 == null) {
                                                                        arrayList38 = new ArrayList();
                                                                    }
                                                                    arrayList38.add(messageObject4);
                                                                    arrayList23 = arrayList38;
                                                                    arrayList14 = arrayList25;
                                                                }
                                                                longSparseArray = longSparseArray4;
                                                                longSparseArray5 = longSparseArray8;
                                                                arrayList13 = arrayList14;
                                                            } else {
                                                                j = j5;
                                                                arrayList26 = arrayList8;
                                                                arrayList5 = arrayList23;
                                                                longSparseArray2 = longSparseArray6;
                                                                if (update2 instanceof TLRPC.TL_updateDialogPinned) {
                                                                    if (arrayList21 == null) {
                                                                        arrayList21 = new ArrayList();
                                                                    }
                                                                    arrayList12 = arrayList21;
                                                                    arrayList12.add(update2);
                                                                } else if (update2 instanceof TLRPC.TL_updatePinnedDialogs) {
                                                                    if (arrayList21 == null) {
                                                                        arrayList21 = new ArrayList();
                                                                    }
                                                                    arrayList12 = arrayList21;
                                                                    arrayList12.add(update2);
                                                                } else if (update2 instanceof TLRPC.TL_updateFolderPeers) {
                                                                    if (arrayList21 == null) {
                                                                        arrayList21 = new ArrayList();
                                                                    }
                                                                    arrayList12 = arrayList21;
                                                                    arrayList12.add(update2);
                                                                    getMessagesStorage().setDialogsFolderId(((TLRPC.TL_updateFolderPeers) update2).folder_peers, null, 0, 0);
                                                                } else if (update2 instanceof TLRPC.TL_updatePrivacy) {
                                                                    if (arrayList21 == null) {
                                                                        arrayList21 = new ArrayList();
                                                                    }
                                                                    arrayList12 = arrayList21;
                                                                    arrayList12.add(update2);
                                                                } else {
                                                                    if (update2 instanceof TLRPC.TL_updateWebPage) {
                                                                        TLRPC.TL_updateWebPage tL_updateWebPage = (TLRPC.TL_updateWebPage) update2;
                                                                        longSparseArray = longSparseArray4 == null ? new LongSparseArray<>() : longSparseArray4;
                                                                        longSparseArray.put(tL_updateWebPage.webpage.id, tL_updateWebPage.webpage);
                                                                    } else if (update2 instanceof TLRPC.TL_updateChannelWebPage) {
                                                                        TLRPC.TL_updateChannelWebPage tL_updateChannelWebPage = (TLRPC.TL_updateChannelWebPage) update2;
                                                                        longSparseArray = longSparseArray4 == null ? new LongSparseArray<>() : longSparseArray4;
                                                                        longSparseArray.put(tL_updateChannelWebPage.webpage.id, tL_updateChannelWebPage.webpage);
                                                                    } else if (update2 instanceof TLRPC.TL_updateChannelTooLong) {
                                                                        TLRPC.TL_updateChannelTooLong tL_updateChannelTooLong = (TLRPC.TL_updateChannelTooLong) update2;
                                                                        if (BuildVars.LOGS_ENABLED) {
                                                                            FileLog.d(update2 + " channelId = " + tL_updateChannelTooLong.channel_id);
                                                                        }
                                                                        int i29 = this.channelsPts.get(tL_updateChannelTooLong.channel_id);
                                                                        if (i29 == 0) {
                                                                            i29 = getMessagesStorage().getChannelPtsSync(tL_updateChannelTooLong.channel_id);
                                                                            if (i29 == 0) {
                                                                                TLRPC.Chat chat3 = concurrentHashMap2.get(Integer.valueOf(tL_updateChannelTooLong.channel_id));
                                                                                if (chat3 == null || chat3.min) {
                                                                                    chat3 = getChat(Integer.valueOf(tL_updateChannelTooLong.channel_id));
                                                                                }
                                                                                if (chat3 == null || chat3.min) {
                                                                                    chat3 = getMessagesStorage().getChatSync(tL_updateChannelTooLong.channel_id);
                                                                                    putChat(chat3, true);
                                                                                }
                                                                                if (chat3 != null && !chat3.min) {
                                                                                    loadUnknownChannel(chat3, 0);
                                                                                }
                                                                            } else {
                                                                                this.channelsPts.put(tL_updateChannelTooLong.channel_id, i29);
                                                                            }
                                                                        }
                                                                        if (i29 != 0) {
                                                                            if ((tL_updateChannelTooLong.flags & 1) == 0) {
                                                                                getChannelDifference(tL_updateChannelTooLong.channel_id);
                                                                            } else if (tL_updateChannelTooLong.pts > i29) {
                                                                                getChannelDifference(tL_updateChannelTooLong.channel_id);
                                                                            }
                                                                        }
                                                                        sparseLongArray3 = sparseLongArray4;
                                                                        sparseLongArray2 = sparseLongArray5;
                                                                        sparseArray3 = sparseArray2;
                                                                        sparseIntArray = sparseIntArray4;
                                                                        longSparseArray = longSparseArray4;
                                                                        longSparseArray5 = longSparseArray8;
                                                                        longSparseArray6 = longSparseArray2;
                                                                        sparseArray8 = sparseArray3;
                                                                        sparseLongArray4 = sparseLongArray3;
                                                                        sparseLongArray5 = sparseLongArray2;
                                                                        arrayList20 = arrayList7;
                                                                        arrayList19 = arrayList6;
                                                                        sparseIntArray4 = sparseIntArray;
                                                                        i18 = i7;
                                                                    } else {
                                                                        if (update2 instanceof TLRPC.TL_updateReadChannelInbox) {
                                                                            TLRPC.TL_updateReadChannelInbox tL_updateReadChannelInbox = (TLRPC.TL_updateReadChannelInbox) update2;
                                                                            long j12 = ((long) tL_updateReadChannelInbox.max_id) | (((long) tL_updateReadChannelInbox.channel_id) << 32);
                                                                            long j13 = (long) (-tL_updateReadChannelInbox.channel_id);
                                                                            if (sparseLongArray5 == null) {
                                                                                sparseLongArray5 = new SparseLongArray();
                                                                            }
                                                                            sparseLongArray5.put(-tL_updateReadChannelInbox.channel_id, j12);
                                                                            Integer num5 = this.dialogs_read_inbox_max.get(Long.valueOf(j13));
                                                                            if (num5 == null) {
                                                                                num5 = Integer.valueOf(getMessagesStorage().getDialogReadMax(false, j13));
                                                                            }
                                                                            this.dialogs_read_inbox_max.put(Long.valueOf(j13), Integer.valueOf(Math.max(num5.intValue(), tL_updateReadChannelInbox.max_id)));
                                                                        } else if (update2 instanceof TLRPC.TL_updateReadChannelOutbox) {
                                                                            TLRPC.TL_updateReadChannelOutbox tL_updateReadChannelOutbox = (TLRPC.TL_updateReadChannelOutbox) update2;
                                                                            long j14 = ((long) tL_updateReadChannelOutbox.max_id) | (((long) tL_updateReadChannelOutbox.channel_id) << 32);
                                                                            long j15 = (long) (-tL_updateReadChannelOutbox.channel_id);
                                                                            if (sparseLongArray4 == null) {
                                                                                sparseLongArray4 = new SparseLongArray();
                                                                            }
                                                                            sparseLongArray4.put(-tL_updateReadChannelOutbox.channel_id, j14);
                                                                            Integer num6 = this.dialogs_read_outbox_max.get(Long.valueOf(j15));
                                                                            if (num6 == null) {
                                                                                num6 = Integer.valueOf(getMessagesStorage().getDialogReadMax(true, j15));
                                                                            }
                                                                            this.dialogs_read_outbox_max.put(Long.valueOf(j15), Integer.valueOf(Math.max(num6.intValue(), tL_updateReadChannelOutbox.max_id)));
                                                                        } else if (update2 instanceof TLRPC.TL_updateDeleteChannelMessages) {
                                                                            TLRPC.TL_updateDeleteChannelMessages tL_updateDeleteChannelMessages = (TLRPC.TL_updateDeleteChannelMessages) update2;
                                                                            if (BuildVars.LOGS_ENABLED) {
                                                                                FileLog.d(update2 + " channelId = " + tL_updateDeleteChannelMessages.channel_id);
                                                                            }
                                                                            if (sparseArray6 == null) {
                                                                                sparseArray6 = new SparseArray();
                                                                            }
                                                                            ArrayList arrayList39 = (ArrayList) sparseArray6.get(tL_updateDeleteChannelMessages.channel_id);
                                                                            if (arrayList39 == null) {
                                                                                arrayList39 = new ArrayList();
                                                                                sparseArray6.put(tL_updateDeleteChannelMessages.channel_id, arrayList39);
                                                                            }
                                                                            arrayList39.addAll(tL_updateDeleteChannelMessages.messages);
                                                                        } else if (update2 instanceof TLRPC.TL_updateChannel) {
                                                                            if (BuildVars.LOGS_ENABLED) {
                                                                                FileLog.d(update2 + " channelId = " + ((TLRPC.TL_updateChannel) update2).channel_id);
                                                                            }
                                                                            if (arrayList21 == null) {
                                                                                arrayList21 = new ArrayList();
                                                                            }
                                                                            arrayList12 = arrayList21;
                                                                            arrayList12.add(update2);
                                                                        } else {
                                                                            if (update2 instanceof TLRPC.TL_updateChannelMessageViews) {
                                                                                TLRPC.TL_updateChannelMessageViews tL_updateChannelMessageViews = (TLRPC.TL_updateChannelMessageViews) update2;
                                                                                if (BuildVars.LOGS_ENABLED) {
                                                                                    FileLog.d(update2 + " channelId = " + tL_updateChannelMessageViews.channel_id);
                                                                                }
                                                                                sparseArray8 = sparseArray2 == null ? new SparseArray<>() : sparseArray2;
                                                                                SparseIntArray sparseIntArray6 = sparseArray8.get(tL_updateChannelMessageViews.channel_id);
                                                                                if (sparseIntArray6 == null) {
                                                                                    sparseIntArray6 = new SparseIntArray();
                                                                                    sparseArray8.put(tL_updateChannelMessageViews.channel_id, sparseIntArray6);
                                                                                }
                                                                                sparseIntArray6.put(tL_updateChannelMessageViews.id, tL_updateChannelMessageViews.views);
                                                                                longSparseArray = longSparseArray4;
                                                                                longSparseArray5 = longSparseArray8;
                                                                                arrayList23 = arrayList5;
                                                                            } else {
                                                                                if (update2 instanceof TLRPC.TL_updateChatParticipantAdmin) {
                                                                                    TLRPC.TL_updateChatParticipantAdmin tL_updateChatParticipantAdmin = (TLRPC.TL_updateChatParticipantAdmin) update2;
                                                                                    getMessagesStorage().updateChatInfo(tL_updateChatParticipantAdmin.chat_id, tL_updateChatParticipantAdmin.user_id, 2, tL_updateChatParticipantAdmin.is_admin ? 1 : 0, tL_updateChatParticipantAdmin.version);
                                                                                } else {
                                                                                    if (update2 instanceof TLRPC.TL_updateChatDefaultBannedRights) {
                                                                                        TLRPC.TL_updateChatDefaultBannedRights tL_updateChatDefaultBannedRights = (TLRPC.TL_updateChatDefaultBannedRights) update2;
                                                                                        if (tL_updateChatDefaultBannedRights.peer.channel_id != 0) {
                                                                                            i10 = tL_updateChatDefaultBannedRights.peer.channel_id;
                                                                                        } else {
                                                                                            i10 = tL_updateChatDefaultBannedRights.peer.chat_id;
                                                                                        }
                                                                                        getMessagesStorage().updateChatDefaultBannedRights(i10, tL_updateChatDefaultBannedRights.default_banned_rights, tL_updateChatDefaultBannedRights.version);
                                                                                        if (arrayList21 == null) {
                                                                                            arrayList21 = new ArrayList();
                                                                                        }
                                                                                        arrayList9 = arrayList21;
                                                                                        arrayList9.add(update2);
                                                                                    } else if (update2 instanceof TLRPC.TL_updateStickerSets) {
                                                                                        if (arrayList21 == null) {
                                                                                            arrayList21 = new ArrayList();
                                                                                        }
                                                                                        arrayList9 = arrayList21;
                                                                                        arrayList9.add(update2);
                                                                                    } else if (update2 instanceof TLRPC.TL_updateStickerSetsOrder) {
                                                                                        if (arrayList21 == null) {
                                                                                            arrayList21 = new ArrayList();
                                                                                        }
                                                                                        arrayList9 = arrayList21;
                                                                                        arrayList9.add(update2);
                                                                                    } else if (update2 instanceof TLRPC.TL_updateNewStickerSet) {
                                                                                        if (arrayList21 == null) {
                                                                                            arrayList21 = new ArrayList();
                                                                                        }
                                                                                        arrayList9 = arrayList21;
                                                                                        arrayList9.add(update2);
                                                                                    } else if (update2 instanceof TLRPC.TL_updateDraftMessage) {
                                                                                        if (arrayList21 == null) {
                                                                                            arrayList21 = new ArrayList();
                                                                                        }
                                                                                        arrayList9 = arrayList21;
                                                                                        arrayList9.add(update2);
                                                                                    } else if (update2 instanceof TLRPC.TL_updateSavedGifs) {
                                                                                        if (arrayList21 == null) {
                                                                                            arrayList21 = new ArrayList();
                                                                                        }
                                                                                        arrayList9 = arrayList21;
                                                                                        arrayList9.add(update2);
                                                                                    } else {
                                                                                        boolean z13 = update2 instanceof TLRPC.TL_updateEditChannelMessage;
                                                                                        if (z13 || (update2 instanceof TLRPC.TL_updateEditMessage)) {
                                                                                            sparseLongArray3 = sparseLongArray4;
                                                                                            int clientUserId3 = getUserConfig().getClientUserId();
                                                                                            if (z13) {
                                                                                                message2 = ((TLRPC.TL_updateEditChannelMessage) update2).message;
                                                                                                if (message2.media instanceof TLRPC.TL_messageMediaShare) {
                                                                                                    AndroidUtilities.runOnUIThread(new Runnable(message2) {
                                                                                                        /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$Ivj0r5P2Pu8nnQoN7pSx04mF9iY */
                                                                                                        private final /* synthetic */ TLRPC.Message f$1;

                                                                                                        {
                                                                                                            this.f$1 = r2;
                                                                                                        }

                                                                                                        public final void run() {
                                                                                                            MessagesController.this.lambda$processUpdateArray$270$MessagesController(this.f$1);
                                                                                                        }
                                                                                                    });
                                                                                                }
                                                                                                TLRPC.Chat chat4 = concurrentHashMap2.get(Integer.valueOf(message2.to_id.channel_id));
                                                                                                if (chat4 == null) {
                                                                                                    chat4 = getChat(Integer.valueOf(message2.to_id.channel_id));
                                                                                                }
                                                                                                if (chat4 == null) {
                                                                                                    chat4 = getMessagesStorage().getChatSync(message2.to_id.channel_id);
                                                                                                    putChat(chat4, true);
                                                                                                }
                                                                                                if (chat4 != null && chat4.megagroup) {
                                                                                                    message2.flags |= Integer.MIN_VALUE;
                                                                                                }
                                                                                                sparseArray4 = sparseArray2;
                                                                                                sparseIntArray2 = sparseIntArray4;
                                                                                            } else {
                                                                                                message2 = ((TLRPC.TL_updateEditMessage) update2).message;
                                                                                                sparseArray4 = sparseArray2;
                                                                                                sparseIntArray2 = sparseIntArray4;
                                                                                                if (message2.dialog_id == ((long) clientUserId3)) {
                                                                                                    message2.unread = false;
                                                                                                    message2.media_unread = false;
                                                                                                    z7 = true;
                                                                                                    message2.out = true;
                                                                                                    if (!message2.out && message2.from_id == getUserConfig().getClientUserId()) {
                                                                                                        message2.out = z7;
                                                                                                    }
                                                                                                    if (!z) {
                                                                                                        int size10 = message2.entities.size();
                                                                                                        for (int i30 = 0; i30 < size10; i30++) {
                                                                                                            TLRPC.MessageEntity messageEntity2 = message2.entities.get(i30);
                                                                                                            if (messageEntity2 instanceof TLRPC.TL_messageEntityMentionName) {
                                                                                                                int i31 = ((TLRPC.TL_messageEntityMentionName) messageEntity2).user_id;
                                                                                                                TLRPC.User user5 = concurrentHashMap.get(Integer.valueOf(i31));
                                                                                                                if (user5 == null || user5.min) {
                                                                                                                    user5 = getUser(Integer.valueOf(i31));
                                                                                                                }
                                                                                                                if (user5 == null || user5.min) {
                                                                                                                    TLRPC.User userSync = getMessagesStorage().getUserSync(i31);
                                                                                                                    user5 = (userSync == null || !userSync.min) ? userSync : null;
                                                                                                                    putUser(user5, true);
                                                                                                                }
                                                                                                                if (user5 == null) {
                                                                                                                    return false;
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                    if (message2.to_id.chat_id == 0) {
                                                                                                        message2.dialog_id = (long) (-message2.to_id.chat_id);
                                                                                                    } else if (message2.to_id.channel_id != 0) {
                                                                                                        message2.dialog_id = (long) (-message2.to_id.channel_id);
                                                                                                    } else {
                                                                                                        if (message2.to_id.user_id == getUserConfig().getClientUserId()) {
                                                                                                            message2.to_id.user_id = message2.from_id;
                                                                                                        }
                                                                                                        message2.dialog_id = (long) message2.to_id.user_id;
                                                                                                    }
                                                                                                    ConcurrentHashMap<Long, Integer> concurrentHashMap5 = !message2.out ? this.dialogs_read_outbox_max : this.dialogs_read_inbox_max;
                                                                                                    num = concurrentHashMap5.get(Long.valueOf(message2.dialog_id));
                                                                                                    if (num == null) {
                                                                                                        num = Integer.valueOf(getMessagesStorage().getDialogReadMax(message2.out, message2.dialog_id));
                                                                                                        concurrentHashMap5.put(Long.valueOf(message2.dialog_id), num);
                                                                                                    }
                                                                                                    message2.unread = num.intValue() >= message2.id;
                                                                                                    if (message2.dialog_id == ((long) clientUserId3)) {
                                                                                                        message2.out = true;
                                                                                                        message2.unread = false;
                                                                                                        message2.media_unread = false;
                                                                                                    }
                                                                                                    if (message2.out && message2.message == null) {
                                                                                                        message2.message = "";
                                                                                                        message2.attachPath = "";
                                                                                                    }
                                                                                                    ImageLoader.saveMessageThumbs(message2);
                                                                                                    sparseLongArray2 = sparseLongArray5;
                                                                                                    sparseArray3 = sparseArray4;
                                                                                                    sparseIntArray = sparseIntArray2;
                                                                                                    hashMap3 = hashMap3;
                                                                                                    MessageObject messageObject5 = new MessageObject(this.currentAccount, message2, concurrentHashMap, concurrentHashMap2, this.createdDialogIds.contains(Long.valueOf(message2.dialog_id)));
                                                                                                    longSparseArray5 = longSparseArray8 != null ? new LongSparseArray() : longSparseArray8;
                                                                                                    arrayList10 = (ArrayList) longSparseArray5.get(message2.dialog_id);
                                                                                                    if (arrayList10 == null) {
                                                                                                        arrayList10 = new ArrayList();
                                                                                                        longSparseArray5.put(message2.dialog_id, arrayList10);
                                                                                                    }
                                                                                                    arrayList10.add(messageObject5);
                                                                                                    longSparseArray = longSparseArray4;
                                                                                                    longSparseArray6 = longSparseArray2;
                                                                                                    sparseArray8 = sparseArray3;
                                                                                                    sparseLongArray4 = sparseLongArray3;
                                                                                                    sparseLongArray5 = sparseLongArray2;
                                                                                                    arrayList20 = arrayList7;
                                                                                                    arrayList19 = arrayList6;
                                                                                                    sparseIntArray4 = sparseIntArray;
                                                                                                    i18 = i7;
                                                                                                }
                                                                                            }
                                                                                            z7 = true;
                                                                                            message2.out = z7;
                                                                                            if (!z) {
                                                                                            }
                                                                                            if (message2.to_id.chat_id == 0) {
                                                                                            }
                                                                                            if (!message2.out) {
                                                                                            }
                                                                                            num = concurrentHashMap5.get(Long.valueOf(message2.dialog_id));
                                                                                            if (num == null) {
                                                                                            }
                                                                                            message2.unread = num.intValue() >= message2.id;
                                                                                            if (message2.dialog_id == ((long) clientUserId3)) {
                                                                                            }
                                                                                            message2.message = "";
                                                                                            message2.attachPath = "";
                                                                                            ImageLoader.saveMessageThumbs(message2);
                                                                                            sparseLongArray2 = sparseLongArray5;
                                                                                            sparseArray3 = sparseArray4;
                                                                                            sparseIntArray = sparseIntArray2;
                                                                                            hashMap3 = hashMap3;
                                                                                            MessageObject messageObject52 = new MessageObject(this.currentAccount, message2, concurrentHashMap, concurrentHashMap2, this.createdDialogIds.contains(Long.valueOf(message2.dialog_id)));
                                                                                            if (longSparseArray8 != null) {
                                                                                            }
                                                                                            arrayList10 = (ArrayList) longSparseArray5.get(message2.dialog_id);
                                                                                            if (arrayList10 == null) {
                                                                                            }
                                                                                            arrayList10.add(messageObject52);
                                                                                            longSparseArray = longSparseArray4;
                                                                                            longSparseArray6 = longSparseArray2;
                                                                                            sparseArray8 = sparseArray3;
                                                                                            sparseLongArray4 = sparseLongArray3;
                                                                                            sparseLongArray5 = sparseLongArray2;
                                                                                            arrayList20 = arrayList7;
                                                                                            arrayList19 = arrayList6;
                                                                                            sparseIntArray4 = sparseIntArray;
                                                                                            i18 = i7;
                                                                                        } else if (update2 instanceof TLRPC.TL_updateChannelPinnedMessage) {
                                                                                            TLRPC.TL_updateChannelPinnedMessage tL_updateChannelPinnedMessage = (TLRPC.TL_updateChannelPinnedMessage) update2;
                                                                                            if (BuildVars.LOGS_ENABLED) {
                                                                                                FileLog.d(update2 + " channelId = " + tL_updateChannelPinnedMessage.channel_id);
                                                                                            }
                                                                                            getMessagesStorage().updateChatPinnedMessage(tL_updateChannelPinnedMessage.channel_id, tL_updateChannelPinnedMessage.id);
                                                                                        } else if (update2 instanceof TLRPC.TL_updateChatPinnedMessage) {
                                                                                            TLRPC.TL_updateChatPinnedMessage tL_updateChatPinnedMessage = (TLRPC.TL_updateChatPinnedMessage) update2;
                                                                                            getMessagesStorage().updateChatPinnedMessage(tL_updateChatPinnedMessage.chat_id, tL_updateChatPinnedMessage.id);
                                                                                        } else if (update2 instanceof TLRPC.TL_updateUserPinnedMessage) {
                                                                                            TLRPC.TL_updateUserPinnedMessage tL_updateUserPinnedMessage = (TLRPC.TL_updateUserPinnedMessage) update2;
                                                                                            getMessagesStorage().updateUserPinnedMessage(tL_updateUserPinnedMessage.user_id, tL_updateUserPinnedMessage.id);
                                                                                        } else if (update2 instanceof TLRPC.TL_updateReadFeaturedStickers) {
                                                                                            if (arrayList21 == null) {
                                                                                                arrayList21 = new ArrayList();
                                                                                            }
                                                                                            arrayList9 = arrayList21;
                                                                                            arrayList9.add(update2);
                                                                                        } else if (update2 instanceof TLRPC.TL_updatePhoneCall) {
                                                                                            if (arrayList21 == null) {
                                                                                                arrayList21 = new ArrayList();
                                                                                            }
                                                                                            arrayList9 = arrayList21;
                                                                                            arrayList9.add(update2);
                                                                                        } else if (update2 instanceof TLRPC.TL_updateLangPack) {
                                                                                            AndroidUtilities.runOnUIThread(new Runnable((TLRPC.TL_updateLangPack) update2) {
                                                                                                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$vAn9c9yh6B5esmGUI_VIhuOs */
                                                                                                private final /* synthetic */ TLRPC.TL_updateLangPack f$1;

                                                                                                {
                                                                                                    this.f$1 = r2;
                                                                                                }

                                                                                                public final void run() {
                                                                                                    MessagesController.this.lambda$processUpdateArray$271$MessagesController(this.f$1);
                                                                                                }
                                                                                            });
                                                                                        } else if (update2 instanceof TLRPC.TL_updateLangPackTooLong) {
                                                                                            LocaleController.getInstance().reloadCurrentRemoteLocale(this.currentAccount, ((TLRPC.TL_updateLangPackTooLong) update2).lang_code);
                                                                                        } else if (update2 instanceof TLRPC.TL_updateFavedStickers) {
                                                                                            if (arrayList21 == null) {
                                                                                                arrayList21 = new ArrayList();
                                                                                            }
                                                                                            arrayList9 = arrayList21;
                                                                                            arrayList9.add(update2);
                                                                                        } else if (update2 instanceof TLRPC.TL_updateContactsReset) {
                                                                                            if (arrayList21 == null) {
                                                                                                arrayList21 = new ArrayList();
                                                                                            }
                                                                                            arrayList9 = arrayList21;
                                                                                            arrayList9.add(update2);
                                                                                        } else if (update2 instanceof TLRPC.TL_updateChannelAvailableMessages) {
                                                                                            TLRPC.TL_updateChannelAvailableMessages tL_updateChannelAvailableMessages = (TLRPC.TL_updateChannelAvailableMessages) update2;
                                                                                            SparseIntArray sparseIntArray7 = sparseIntArray4;
                                                                                            if (sparseIntArray7 == null) {
                                                                                                sparseIntArray7 = new SparseIntArray();
                                                                                            }
                                                                                            int i32 = sparseIntArray7.get(tL_updateChannelAvailableMessages.channel_id);
                                                                                            if (i32 == 0 || i32 < tL_updateChannelAvailableMessages.available_min_id) {
                                                                                                sparseIntArray7.put(tL_updateChannelAvailableMessages.channel_id, tL_updateChannelAvailableMessages.available_min_id);
                                                                                            }
                                                                                            longSparseArray = longSparseArray4;
                                                                                            longSparseArray5 = longSparseArray8;
                                                                                            arrayList23 = arrayList5;
                                                                                            sparseArray8 = sparseArray2;
                                                                                            sparseIntArray4 = sparseIntArray7;
                                                                                        } else if (update2 instanceof TLRPC.TL_updateDialogUnreadMark) {
                                                                                            if (arrayList21 == null) {
                                                                                                arrayList21 = new ArrayList();
                                                                                            }
                                                                                            arrayList21.add(update2);
                                                                                            longSparseArray5 = longSparseArray8;
                                                                                            arrayList23 = arrayList5;
                                                                                            arrayList21 = arrayList21;
                                                                                            sparseArray8 = sparseArray2;
                                                                                            sparseIntArray4 = sparseIntArray4;
                                                                                            longSparseArray6 = longSparseArray2;
                                                                                            sparseArray7 = sparseArray;
                                                                                            arrayList20 = arrayList7;
                                                                                            arrayList19 = arrayList6;
                                                                                            i18 = i7;
                                                                                            j5 = j;
                                                                                        } else {
                                                                                            if (update2 instanceof TLRPC.TL_updateMessagePoll) {
                                                                                                TLRPC.TL_updateMessagePoll tL_updateMessagePoll = (TLRPC.TL_updateMessagePoll) update2;
                                                                                                if (Math.abs(SystemClock.uptimeMillis() - getSendMessagesHelper().getVoteSendTime(tL_updateMessagePoll.poll_id)) < 600) {
                                                                                                    sparseLongArray3 = sparseLongArray4;
                                                                                                } else {
                                                                                                    sparseLongArray3 = sparseLongArray4;
                                                                                                    getMessagesStorage().updateMessagePollResults(tL_updateMessagePoll.poll_id, tL_updateMessagePoll.poll, tL_updateMessagePoll.results);
                                                                                                    if (arrayList21 == null) {
                                                                                                        arrayList21 = new ArrayList();
                                                                                                    }
                                                                                                    arrayList11 = arrayList21;
                                                                                                    arrayList11.add(update2);
                                                                                                    longSparseArray = longSparseArray4;
                                                                                                    arrayList21 = arrayList11;
                                                                                                    longSparseArray5 = longSparseArray8;
                                                                                                    sparseArray8 = sparseArray2;
                                                                                                    sparseIntArray4 = sparseIntArray4;
                                                                                                    longSparseArray6 = longSparseArray2;
                                                                                                    sparseLongArray4 = sparseLongArray3;
                                                                                                    arrayList20 = arrayList7;
                                                                                                    arrayList19 = arrayList6;
                                                                                                    i18 = i7;
                                                                                                }
                                                                                            } else {
                                                                                                sparseLongArray3 = sparseLongArray4;
                                                                                                if (update2 instanceof TLRPC.TL_updateMessageReactions) {
                                                                                                    TLRPC.TL_updateMessageReactions tL_updateMessageReactions = (TLRPC.TL_updateMessageReactions) update2;
                                                                                                    if (tL_updateMessageReactions.peer.chat_id != 0) {
                                                                                                        i9 = tL_updateMessageReactions.peer.chat_id;
                                                                                                    } else if (tL_updateMessageReactions.peer.channel_id != 0) {
                                                                                                        i9 = tL_updateMessageReactions.peer.channel_id;
                                                                                                    } else {
                                                                                                        i8 = tL_updateMessageReactions.peer.user_id;
                                                                                                        getMessagesStorage().updateMessageReactions((long) i8, tL_updateMessageReactions.msg_id, tL_updateMessageReactions.peer.channel_id, tL_updateMessageReactions.reactions);
                                                                                                        if (arrayList21 == null) {
                                                                                                            arrayList21 = new ArrayList();
                                                                                                        }
                                                                                                        arrayList11 = arrayList21;
                                                                                                        arrayList11.add(update2);
                                                                                                    }
                                                                                                    i8 = -i9;
                                                                                                    getMessagesStorage().updateMessageReactions((long) i8, tL_updateMessageReactions.msg_id, tL_updateMessageReactions.peer.channel_id, tL_updateMessageReactions.reactions);
                                                                                                    if (arrayList21 == null) {
                                                                                                    }
                                                                                                    arrayList11 = arrayList21;
                                                                                                    arrayList11.add(update2);
                                                                                                } else if (update2 instanceof TLRPC.TL_updatePeerLocated) {
                                                                                                    if (arrayList21 == null) {
                                                                                                        arrayList21 = new ArrayList();
                                                                                                    }
                                                                                                    arrayList11 = arrayList21;
                                                                                                    arrayList11.add(update2);
                                                                                                } else if (update2 instanceof TLRPC.TL_updateTheme) {
                                                                                                    if (arrayList21 == null) {
                                                                                                        arrayList21 = new ArrayList();
                                                                                                    }
                                                                                                    arrayList11 = arrayList21;
                                                                                                    arrayList11.add(update2);
                                                                                                } else if (!(update2 instanceof TLRPCContacts.UpdateContactApplyRequested)) {
                                                                                                    if (update2 instanceof TLRPC.TL_updateUserMomentStateV1) {
                                                                                                        TLRPC.TL_updateUserMomentStateV1 tL_updateUserMomentStateV1 = (TLRPC.TL_updateUserMomentStateV1) update2;
                                                                                                        if (!(tL_updateUserMomentStateV1 == null || tL_updateUserMomentStateV1.user_id == 0 || tL_updateUserMomentStateV1.type == 0)) {
                                                                                                            AndroidUtilities.runOnUIThread(new Runnable(tL_updateUserMomentStateV1) {
                                                                                                                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$1L6vMUyKxievoe3p761sh48NFvU */
                                                                                                                private final /* synthetic */ TLRPC.TL_updateUserMomentStateV1 f$1;

                                                                                                                {
                                                                                                                    this.f$1 = r2;
                                                                                                                }

                                                                                                                public final void run() {
                                                                                                                    MessagesController.this.lambda$processUpdateArray$272$MessagesController(this.f$1);
                                                                                                                }
                                                                                                            });
                                                                                                        }
                                                                                                    } else {
                                                                                                        if (update2 instanceof TLRPCCall.TL_UpdateMeetCallRequested) {
                                                                                                            TLRPCCall.TL_UpdateMeetCallRequested tL_UpdateMeetCallRequested = (TLRPCCall.TL_UpdateMeetCallRequested) update2;
                                                                                                            if (tL_UpdateMeetCallRequested == null || tL_UpdateMeetCallRequested.admin_id == getUserConfig().getClientUserId() || (System.currentTimeMillis() / 1000) - ((long) tL_UpdateMeetCallRequested.date) >= 35) {
                                                                                                                hashMap = hashMap3;
                                                                                                            } else {
                                                                                                                if (BuildVars.LOGS_ENABLED) {
                                                                                                                    FileLog.d("MessagesController call ===> receive video call , id = " + tL_UpdateMeetCallRequested.id);
                                                                                                                }
                                                                                                                if (tL_UpdateMeetCallRequested.participant_id != null) {
                                                                                                                    Iterator<TLRPC.InputPeer> it2 = tL_UpdateMeetCallRequested.participant_id.iterator();
                                                                                                                    while (it2.hasNext() && it2.next().user_id != AccountInstance.getInstance(UserConfig.selectedAccount).getUserConfig().getCurrentUser().id) {
                                                                                                                        while (it2.hasNext()) {
                                                                                                                            while (it2.hasNext()) {
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                                hashMap = hashMap3;
                                                                                                                hashMap.get(tL_UpdateMeetCallRequested.id);
                                                                                                            }
                                                                                                        } else {
                                                                                                            hashMap = hashMap3;
                                                                                                            if (update2 instanceof TLRPCCall.TL_UpdateMeetCallAccepted) {
                                                                                                                if (BuildVars.LOGS_ENABLED) {
                                                                                                                    FileLog.d("MessagesController call ===> 对方已接受请求");
                                                                                                                }
                                                                                                                AndroidUtilities.runOnUIThread(new Runnable() {
                                                                                                                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$3vcZf4cfj941WqC492judKXiiHo */

                                                                                                                    public final void run() {
                                                                                                                        NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.receivedAVideoCallAccept, TLRPC.Update.this);
                                                                                                                    }
                                                                                                                });
                                                                                                            } else if (update2 instanceof TLRPCCall.TL_UpdateMeetCallDiscarded) {
                                                                                                                TLRPCCall.TL_UpdateMeetCallDiscarded tL_UpdateMeetCallDiscarded2 = (TLRPCCall.TL_UpdateMeetCallDiscarded) update2;
                                                                                                                if (BuildVars.LOGS_ENABLED) {
                                                                                                                    FileLog.d("MessagesController call ===> 收到挂断反馈 , d.id = " + tL_UpdateMeetCallDiscarded2.id + " d.duration = " + tL_UpdateMeetCallDiscarded2.duration);
                                                                                                                }
                                                                                                                AndroidUtilities.runOnUIThread(new Runnable() {
                                                                                                                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$_njyiPeXitWmuZ_GF7FUsO_jzs */

                                                                                                                    public final void run() {
                                                                                                                        NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.reecivedAVideoDiscarded, TLRPC.Update.this);
                                                                                                                    }
                                                                                                                });
                                                                                                            } else if (update2 instanceof TLRPCCall.TL_UpdateMeetCall) {
                                                                                                                if (BuildVars.LOGS_ENABLED) {
                                                                                                                    FileLog.d("MessagesController call ===> 准备进入视频通道");
                                                                                                                }
                                                                                                                AndroidUtilities.runOnUIThread(new Runnable() {
                                                                                                                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$_agmhSx072Z54S1qQQoWMPSVYg */

                                                                                                                    public final void run() {
                                                                                                                        NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.receivedAVideoCallReady, TLRPC.Update.this);
                                                                                                                    }
                                                                                                                });
                                                                                                            } else if (update2 instanceof TLRPCContacts.UpdateResetContactsApplyUnread) {
                                                                                                                handleUpdatesContactsApply(0);
                                                                                                                AndroidUtilities.runOnUIThread(new Runnable() {
                                                                                                                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$CFSVd4iAEdTS9dlAQ6KQ7spee8k */

                                                                                                                    public final void run() {
                                                                                                                        MessagesController.this.lambda$processUpdateArray$276$MessagesController();
                                                                                                                    }
                                                                                                                });
                                                                                                            } else if (update2 instanceof TLRPCContacts.UpdateRegetContactsApplies) {
                                                                                                                getContactsApplyDifferenceV2(true, false);
                                                                                                            } else if (update2 instanceof TLRPCCall.TL_UpdateMeetCallWaiting) {
                                                                                                                AndroidUtilities.runOnUIThread(new Runnable() {
                                                                                                                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$Yf8Qypm9QlGi_lQ2sKgWGDe4QJE */

                                                                                                                    public final void run() {
                                                                                                                        NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.receivedAVideoCallBusy, TLRPC.Update.this);
                                                                                                                    }
                                                                                                                }, AdaptiveTrackSelection.DEFAULT_MIN_TIME_BETWEEN_BUFFER_REEVALUTATION_MS);
                                                                                                            } else if (update2 instanceof TLRPCCall.TL_UpdateMeetChangeCall) {
                                                                                                                if (BuildVars.LOGS_ENABLED) {
                                                                                                                    FileLog.d("MessagesController call ===> 对方切换到语音");
                                                                                                                }
                                                                                                                AndroidUtilities.runOnUIThread(new Runnable() {
                                                                                                                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$GYGxI1mkVgfFLoQhhrDgxVoZJY */

                                                                                                                    public final void run() {
                                                                                                                        NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.receivedAVideoCallChangeVoice, TLRPC.Update.this);
                                                                                                                    }
                                                                                                                });
                                                                                                            } else if (!(update2 instanceof TLRPCContacts.CL_user_updateUserFull) && (update2 instanceof TLRPCContacts.TL_updateContactGroups)) {
                                                                                                                AndroidUtilities.runOnUIThread(new Runnable() {
                                                                                                                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$eVphOoHONdC6vmlOquBH1FBn43M */

                                                                                                                    public final void run() {
                                                                                                                        MessagesController.this.lambda$processUpdateArray$279$MessagesController();
                                                                                                                    }
                                                                                                                });
                                                                                                            }
                                                                                                        }
                                                                                                        hashMap3 = hashMap;
                                                                                                    }
                                                                                                }
                                                                                                longSparseArray = longSparseArray4;
                                                                                                arrayList21 = arrayList11;
                                                                                                longSparseArray5 = longSparseArray8;
                                                                                                sparseArray8 = sparseArray2;
                                                                                                sparseIntArray4 = sparseIntArray4;
                                                                                                longSparseArray6 = longSparseArray2;
                                                                                                sparseLongArray4 = sparseLongArray3;
                                                                                                arrayList20 = arrayList7;
                                                                                                arrayList19 = arrayList6;
                                                                                                i18 = i7;
                                                                                            }
                                                                                            sparseIntArray = sparseIntArray4;
                                                                                            sparseLongArray2 = sparseLongArray5;
                                                                                            sparseArray3 = sparseArray2;
                                                                                            longSparseArray = longSparseArray4;
                                                                                            longSparseArray5 = longSparseArray8;
                                                                                            longSparseArray6 = longSparseArray2;
                                                                                            sparseArray8 = sparseArray3;
                                                                                            sparseLongArray4 = sparseLongArray3;
                                                                                            sparseLongArray5 = sparseLongArray2;
                                                                                            arrayList20 = arrayList7;
                                                                                            arrayList19 = arrayList6;
                                                                                            sparseIntArray4 = sparseIntArray;
                                                                                            i18 = i7;
                                                                                        }
                                                                                    }
                                                                                    longSparseArray5 = longSparseArray8;
                                                                                    arrayList23 = arrayList5;
                                                                                    arrayList21 = arrayList9;
                                                                                    sparseArray8 = sparseArray2;
                                                                                    longSparseArray6 = longSparseArray2;
                                                                                    sparseArray7 = sparseArray;
                                                                                    arrayList20 = arrayList7;
                                                                                    arrayList19 = arrayList6;
                                                                                    i18 = i7;
                                                                                    j5 = j;
                                                                                }
                                                                                sparseLongArray3 = sparseLongArray4;
                                                                                sparseIntArray = sparseIntArray4;
                                                                                sparseLongArray2 = sparseLongArray5;
                                                                                sparseArray3 = sparseArray2;
                                                                                longSparseArray = longSparseArray4;
                                                                                longSparseArray5 = longSparseArray8;
                                                                                longSparseArray6 = longSparseArray2;
                                                                                sparseArray8 = sparseArray3;
                                                                                sparseLongArray4 = sparseLongArray3;
                                                                                sparseLongArray5 = sparseLongArray2;
                                                                                arrayList20 = arrayList7;
                                                                                arrayList19 = arrayList6;
                                                                                sparseIntArray4 = sparseIntArray;
                                                                                i18 = i7;
                                                                            }
                                                                            longSparseArray6 = longSparseArray2;
                                                                            sparseArray7 = sparseArray;
                                                                            arrayList20 = arrayList7;
                                                                            arrayList19 = arrayList6;
                                                                            arrayList25 = arrayList25;
                                                                            i18 = i7;
                                                                            j5 = j;
                                                                        }
                                                                        longSparseArray = longSparseArray4;
                                                                    }
                                                                    longSparseArray5 = longSparseArray8;
                                                                    arrayList23 = arrayList5;
                                                                    longSparseArray6 = longSparseArray2;
                                                                    arrayList13 = arrayList25;
                                                                }
                                                                longSparseArray5 = longSparseArray8;
                                                                arrayList23 = arrayList5;
                                                                arrayList21 = arrayList12;
                                                                longSparseArray6 = longSparseArray2;
                                                                sparseArray7 = sparseArray;
                                                                arrayList20 = arrayList7;
                                                                arrayList19 = arrayList6;
                                                                sparseArray8 = sparseArray2;
                                                                i18 = i7;
                                                                j5 = j;
                                                            }
                                                            sparseArray7 = sparseArray;
                                                            arrayList20 = arrayList7;
                                                            arrayList19 = arrayList6;
                                                            sparseArray8 = sparseArray2;
                                                            arrayList25 = arrayList13;
                                                            i18 = i7;
                                                            j5 = j;
                                                        }
                                                        j = j5;
                                                        arrayList26 = arrayList8;
                                                        arrayList5 = arrayList23;
                                                        longSparseArray2 = longSparseArray6;
                                                        sparseLongArray3 = sparseLongArray4;
                                                        sparseLongArray2 = sparseLongArray5;
                                                        sparseArray3 = sparseArray2;
                                                        sparseIntArray = sparseIntArray4;
                                                        longSparseArray = longSparseArray4;
                                                        longSparseArray5 = longSparseArray8;
                                                        longSparseArray6 = longSparseArray2;
                                                        sparseArray8 = sparseArray3;
                                                        sparseLongArray4 = sparseLongArray3;
                                                        sparseLongArray5 = sparseLongArray2;
                                                        arrayList20 = arrayList7;
                                                        arrayList19 = arrayList6;
                                                        sparseIntArray4 = sparseIntArray;
                                                        i18 = i7;
                                                    }
                                                    j5 = j5;
                                                    arrayList26 = arrayList8;
                                                }
                                                longSparseArray6 = longSparseArray6;
                                            }
                                            sparseArray7 = sparseArray;
                                            arrayList20 = arrayList7;
                                            arrayList19 = arrayList6;
                                            sparseArray8 = sparseArray2;
                                            i18 = i7;
                                        }
                                    }
                                    longSparseArray = longSparseArray4;
                                    arrayList21 = arrayList16;
                                }
                                longSparseArray6 = longSparseArray6;
                                longSparseArray5 = longSparseArray8;
                                sparseArray8 = sparseArray9;
                            }
                        }
                        longSparseArray = longSparseArray4;
                        longSparseArray6 = longSparseArray6;
                        longSparseArray5 = longSparseArray8;
                        sparseArray8 = sparseArray9;
                        i18 = i18;
                    }
                    longSparseArray4 = longSparseArray;
                    size3 = size3;
                    i17++;
                    arrayList18 = arrayList;
                    arrayList25 = arrayList25;
                }
                longSparseArray = longSparseArray4;
                longSparseArray4 = longSparseArray;
                size3 = size3;
                i17++;
                arrayList18 = arrayList;
                arrayList25 = arrayList25;
            }
            j5 = j;
            arrayList25 = arrayList25;
            arrayList23 = arrayList5;
            sparseArray7 = sparseArray;
            longSparseArray4 = longSparseArray;
            size3 = size3;
            i17++;
            arrayList18 = arrayList;
            arrayList25 = arrayList25;
        }
        if (longSparseArray6 != null) {
            int size11 = longSparseArray6.size();
            for (int i33 = 0; i33 < size11; i33++) {
                if (updatePrintingUsersWithNewMessages(longSparseArray6.keyAt(i33), (ArrayList) longSparseArray6.valueAt(i33))) {
                    z10 = true;
                }
            }
        }
        if (z10) {
            updatePrintingStrings();
        }
        if (arrayList19 != null) {
            getContactsController().processContactsUpdates(arrayList19, concurrentHashMap);
        }
        if (arrayList23 != null) {
            getMessagesStorage().getStorageQueue().postRunnable(new Runnable(arrayList23) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$5HwzSz7CpVTl4oc7XJDI7tUSyEw */
                private final /* synthetic */ ArrayList f$1;

                {
                    this.f$1 = r2;
                }

                public final void run() {
                    MessagesController.this.lambda$processUpdateArray$281$MessagesController(this.f$1);
                }
            });
        }
        if (arrayList24 != null) {
            getMessagesStorage().putMessages(arrayList24, true, true, false, getDownloadController().getAutodownloadMask(), true);
        }
        if (arrayList25 != null) {
            getStatsController().incrementReceivedItemsCount(ApplicationLoader.getCurrentNetworkType(), 1, arrayList25.size());
            getMessagesStorage().putMessages(arrayList25, true, true, false, getDownloadController().getAutodownloadMask(), false);
        }
        if (longSparseArray5 != null) {
            int size12 = longSparseArray5.size();
            for (int i34 = 0; i34 < size12; i34++) {
                TLRPC.TL_messages_messages tL_messages_messages = new TLRPC.TL_messages_messages();
                ArrayList arrayList40 = (ArrayList) longSparseArray5.valueAt(i34);
                int size13 = arrayList40.size();
                for (int i35 = 0; i35 < size13; i35++) {
                    tL_messages_messages.messages.add(((MessageObject) arrayList40.get(i35)).messageOwner);
                }
                getMessagesStorage().putMessages((TLRPC.messages_Messages) tL_messages_messages, longSparseArray5.keyAt(i34), -2, 0, false, false);
            }
        }
        if (sparseArray8 != null) {
            getMessagesStorage().putChannelViews(sparseArray8, true);
        }
        AndroidUtilities.runOnUIThread(new Runnable(i18, arrayList21, longSparseArray4, longSparseArray6, longSparseArray7, longSparseArray5, z10, arrayList19, arrayList22, sparseArray8) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$coiDMay80OXAjCwqlQP4e4IRU */
            private final /* synthetic */ int f$1;
            private final /* synthetic */ SparseArray f$10;
            private final /* synthetic */ ArrayList f$2;
            private final /* synthetic */ LongSparseArray f$3;
            private final /* synthetic */ LongSparseArray f$4;
            private final /* synthetic */ LongSparseArray f$5;
            private final /* synthetic */ LongSparseArray f$6;
            private final /* synthetic */ boolean f$7;
            private final /* synthetic */ ArrayList f$8;
            private final /* synthetic */ ArrayList f$9;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
                this.f$4 = r5;
                this.f$5 = r6;
                this.f$6 = r7;
                this.f$7 = r8;
                this.f$8 = r9;
                this.f$9 = r10;
                this.f$10 = r11;
            }

            public final void run() {
                MessagesController.this.lambda$processUpdateArray$286$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6, this.f$7, this.f$8, this.f$9, this.f$10);
            }
        });
        getMessagesStorage().getStorageQueue().postRunnable(new Runnable(sparseLongArray5, sparseLongArray4, sparseIntArray3, arrayList20, sparseArray6, sparseArray7, sparseIntArray4) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$1aeNtfxzv1mUbIqn8UINYywhWn0 */
            private final /* synthetic */ SparseLongArray f$1;
            private final /* synthetic */ SparseLongArray f$2;
            private final /* synthetic */ SparseIntArray f$3;
            private final /* synthetic */ ArrayList f$4;
            private final /* synthetic */ SparseArray f$5;
            private final /* synthetic */ SparseArray f$6;
            private final /* synthetic */ SparseIntArray f$7;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
                this.f$4 = r5;
                this.f$5 = r6;
                this.f$6 = r7;
                this.f$7 = r8;
            }

            public final void run() {
                MessagesController.this.lambda$processUpdateArray$288$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6, this.f$7);
            }
        });
        if (longSparseArray4 != null) {
            getMessagesStorage().putWebPages(longSparseArray4);
        }
        if (sparseLongArray5 == null && sparseLongArray4 == null && sparseIntArray3 == null && arrayList20 == null) {
            arrayList4 = arrayList20;
        } else {
            if (sparseLongArray5 == null && arrayList20 == null) {
                sparseLongArray = sparseLongArray5;
                arrayList4 = arrayList20;
                z3 = true;
            } else {
                sparseLongArray = sparseLongArray5;
                arrayList4 = arrayList20;
                z3 = true;
                getMessagesStorage().updateDialogsWithReadMessages(sparseLongArray, sparseLongArray4, arrayList4, true);
            }
            getMessagesStorage().markMessagesAsRead(sparseLongArray, sparseLongArray4, sparseIntArray3, z3);
        }
        if (arrayList4 != null) {
            getMessagesStorage().markMessagesContentAsRead(arrayList4, getConnectionsManager().getCurrentTime());
        }
        if (sparseArray6 != null) {
            int size14 = sparseArray6.size();
            for (int i36 = 0; i36 < size14; i36++) {
                getMessagesStorage().getStorageQueue().postRunnable(new Runnable((ArrayList) sparseArray6.valueAt(i36), sparseArray6.keyAt(i36)) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$qn3wCGs1GLdiOMQKsLGI3k7jXes */
                    private final /* synthetic */ ArrayList f$1;
                    private final /* synthetic */ int f$2;

                    {
                        this.f$1 = r2;
                        this.f$2 = r3;
                    }

                    public final void run() {
                        MessagesController.this.lambda$processUpdateArray$289$MessagesController(this.f$1, this.f$2);
                    }
                });
            }
        }
        if (sparseArray7 != null) {
            int size15 = sparseArray7.size();
            for (int i37 = 0; i37 < size15; i37++) {
                MessagesStorage.getInstance(this.currentAccount).markMessagesAsDeleted((ArrayList) sparseArray7.valueAt(i37), true, sparseArray7.keyAt(i37), false, true);
            }
        }
        if (sparseIntArray4 != null) {
            int size16 = sparseIntArray4.size();
            for (int i38 = 0; i38 < size16; i38++) {
                getMessagesStorage().getStorageQueue().postRunnable(new Runnable(sparseIntArray4.keyAt(i38), sparseIntArray4.valueAt(i38)) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$f9RQzYZ1HgOoqotiINRp7v3FVOI */
                    private final /* synthetic */ int f$1;
                    private final /* synthetic */ int f$2;

                    {
                        this.f$1 = r2;
                        this.f$2 = r3;
                    }

                    public final void run() {
                        MessagesController.this.lambda$processUpdateArray$290$MessagesController(this.f$1, this.f$2);
                    }
                });
            }
        }
        if (arrayList26 == null) {
            return true;
        }
        int size17 = arrayList26.size();
        for (int i39 = 0; i39 < size17; i39++) {
            TLRPC.TL_updateEncryptedMessagesRead tL_updateEncryptedMessagesRead2 = (TLRPC.TL_updateEncryptedMessagesRead) arrayList26.get(i39);
            getMessagesStorage().createTaskForSecretChat(tL_updateEncryptedMessagesRead2.chat_id, tL_updateEncryptedMessagesRead2.max_date, tL_updateEncryptedMessagesRead2.date, 1, null);
        }
        return true;
    }

    public /* synthetic */ void lambda$processUpdateArray$265$MessagesController(ArrayList arrayList, ArrayList arrayList2) {
        putUsers(arrayList, false);
        putChats(arrayList2, false);
    }

    public /* synthetic */ void lambda$processUpdateArray$266$MessagesController(ArrayList arrayList, ArrayList arrayList2) {
        putUsers(arrayList, false);
        putChats(arrayList2, false);
    }

    public /* synthetic */ void lambda$processUpdateArray$268$MessagesController(TLRPC.TL_updateUserBlocked tL_updateUserBlocked) {
        AndroidUtilities.runOnUIThread(new Runnable(tL_updateUserBlocked) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$4_s7_CPs7aH06i2FWtQmx9yYp_E */
            private final /* synthetic */ TLRPC.TL_updateUserBlocked f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                MessagesController.this.lambda$null$267$MessagesController(this.f$1);
            }
        });
    }

    public /* synthetic */ void lambda$null$267$MessagesController(TLRPC.TL_updateUserBlocked tL_updateUserBlocked) {
        if (!tL_updateUserBlocked.blocked) {
            this.blockedUsers.delete(tL_updateUserBlocked.user_id);
        } else if (this.blockedUsers.indexOfKey(tL_updateUserBlocked.user_id) < 0) {
            this.blockedUsers.put(tL_updateUserBlocked.user_id, 1);
        }
        getNotificationCenter().postNotificationName(NotificationCenter.blockedUsersDidLoad, new Object[0]);
    }

    public /* synthetic */ void lambda$processUpdateArray$269$MessagesController(TLRPC.TL_updateServiceNotification tL_updateServiceNotification) {
        getNotificationCenter().postNotificationName(NotificationCenter.needShowAlert, 2, tL_updateServiceNotification.message, tL_updateServiceNotification.type);
    }

    public /* synthetic */ void lambda$processUpdateArray$270$MessagesController(TLRPC.Message message) {
        getNotificationCenter().postNotificationName(NotificationCenter.livestatechange, message.media);
    }

    public /* synthetic */ void lambda$processUpdateArray$271$MessagesController(TLRPC.TL_updateLangPack tL_updateLangPack) {
        LocaleController.getInstance().saveRemoteLocaleStringsForCurrentLocale(tL_updateLangPack.difference, this.currentAccount);
    }

    public /* synthetic */ void lambda$processUpdateArray$272$MessagesController(TLRPC.TL_updateUserMomentStateV1 tL_updateUserMomentStateV1) {
        NotificationCenter.getInstance(this.currentAccount).postNotificationName(NotificationCenter.userFriendsCircleUpdate, tL_updateUserMomentStateV1);
    }

    public /* synthetic */ void lambda$processUpdateArray$276$MessagesController() {
        getNotificationCenter().postNotificationName(NotificationCenter.contactApplyUpdateCount, 0);
    }

    public /* synthetic */ void lambda$processUpdateArray$279$MessagesController() {
        getNotificationCenter().postNotificationName(NotificationCenter.groupingChanged, new Object[0]);
    }

    public /* synthetic */ void lambda$null$280$MessagesController(ArrayList arrayList) {
        getNotificationsController().processNewMessages(arrayList, true, false, null);
    }

    public /* synthetic */ void lambda$processUpdateArray$281$MessagesController(ArrayList arrayList) {
        AndroidUtilities.runOnUIThread(new Runnable(arrayList) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$Nvlxa8192xGf5__g99pbDENM70 */
            private final /* synthetic */ ArrayList f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                MessagesController.this.lambda$null$280$MessagesController(this.f$1);
            }
        });
    }

    /* JADX WARNING: Removed duplicated region for block: B:433:0x0a1b  */
    /* JADX WARNING: Removed duplicated region for block: B:438:0x0a37  */
    /* JADX WARNING: Removed duplicated region for block: B:466:0x0ae3  */
    /* JADX WARNING: Removed duplicated region for block: B:468:0x0af0  */
    /* JADX WARNING: Removed duplicated region for block: B:470:0x0af4  */
    /* JADX WARNING: Removed duplicated region for block: B:473:0x0afc  */
    /* JADX WARNING: Removed duplicated region for block: B:477:0x0b15  */
    /* JADX WARNING: Removed duplicated region for block: B:478:0x0b25  */
    /* JADX WARNING: Removed duplicated region for block: B:480:0x0b29  */
    /* JADX WARNING: Removed duplicated region for block: B:544:? A[RETURN, SYNTHETIC] */
    public /* synthetic */ void lambda$processUpdateArray$286$MessagesController(int i, ArrayList arrayList, LongSparseArray longSparseArray, LongSparseArray longSparseArray2, LongSparseArray longSparseArray3, LongSparseArray longSparseArray4, boolean z, ArrayList arrayList2, ArrayList arrayList3, SparseArray sparseArray) {
        boolean z2;
        int i2;
        int i3;
        boolean z3;
        char c;
        int i4;
        LongSparseArray<ArrayList<MessageObject>> longSparseArray5;
        long j;
        int i5;
        ArrayList<TLRPC.User> arrayList4;
        ArrayList<TLRPC.User> arrayList5;
        int i6;
        int i7;
        ArrayList<TLRPC.User> arrayList6;
        int i8;
        int i9;
        int i10;
        int i11;
        long j2;
        int i12;
        int i13;
        int i14;
        int i15;
        int i16;
        int i17;
        int i18;
        TLRPC.Dialog dialog;
        int i19;
        int i20;
        int i21;
        int i22;
        ArrayList<Long> arrayList7;
        long j3;
        ArrayList<TLRPC.User> arrayList8;
        int i23;
        int i24;
        boolean z4 = false;
        int i25 = 0;
        if (arrayList != null) {
            ArrayList<TLRPC.User> arrayList9 = new ArrayList<>();
            ArrayList<TLRPC.User> arrayList10 = new ArrayList<>();
            int size = arrayList.size();
            int i26 = i;
            int i27 = 0;
            SharedPreferences.Editor editor = null;
            z2 = false;
            while (i27 < size) {
                TLRPC.Update update = (TLRPC.Update) arrayList.get(i27);
                if (update instanceof TLRPC.TL_updatePrivacy) {
                    TLRPC.TL_updatePrivacy tL_updatePrivacy = (TLRPC.TL_updatePrivacy) update;
                    if (tL_updatePrivacy.key instanceof TLRPC.TL_privacyKeyStatusTimestamp) {
                        getContactsController().setPrivacyRules(tL_updatePrivacy.rules, i25);
                    } else if (tL_updatePrivacy.key instanceof TLRPC.TL_privacyKeyChatInvite) {
                        getContactsController().setPrivacyRules(tL_updatePrivacy.rules, 1);
                    } else if (tL_updatePrivacy.key instanceof TLRPC.TL_privacyKeyMoment) {
                        getContactsController().setPrivacyRules(tL_updatePrivacy.rules, 8);
                    } else if (tL_updatePrivacy.key instanceof TLRPC.TL_privacyKeyPhoneCall) {
                        getContactsController().setPrivacyRules(tL_updatePrivacy.rules, 2);
                    } else if (tL_updatePrivacy.key instanceof TLRPC.TL_privacyKeyPhoneP2P) {
                        getContactsController().setPrivacyRules(tL_updatePrivacy.rules, 3);
                    } else if (tL_updatePrivacy.key instanceof TLRPC.TL_privacyKeyProfilePhoto) {
                        getContactsController().setPrivacyRules(tL_updatePrivacy.rules, 4);
                    } else if (tL_updatePrivacy.key instanceof TLRPC.TL_privacyKeyForwards) {
                        getContactsController().setPrivacyRules(tL_updatePrivacy.rules, 5);
                    } else if (tL_updatePrivacy.key instanceof TLRPC.TL_privacyKeyPhoneNumber) {
                        getContactsController().setPrivacyRules(tL_updatePrivacy.rules, 6);
                    } else if (tL_updatePrivacy.key instanceof TLRPC.TL_privacyKeyAddedByPhone) {
                        getContactsController().setPrivacyRules(tL_updatePrivacy.rules, 7);
                    }
                } else if (update instanceof TLRPC.TL_updateUserStatus) {
                    TLRPC.TL_updateUserStatus tL_updateUserStatus = (TLRPC.TL_updateUserStatus) update;
                    TLRPC.User user = getUser(Integer.valueOf(tL_updateUserStatus.user_id));
                    if (tL_updateUserStatus.status instanceof TLRPC.TL_userStatusRecently) {
                        tL_updateUserStatus.status.expires = -100;
                    } else if (tL_updateUserStatus.status instanceof TLRPC.TL_userStatusLastWeek) {
                        tL_updateUserStatus.status.expires = -101;
                    } else if (tL_updateUserStatus.status instanceof TLRPC.TL_userStatusLastMonth) {
                        tL_updateUserStatus.status.expires = -102;
                    }
                    if (user != null) {
                        user.id = tL_updateUserStatus.user_id;
                        user.status = tL_updateUserStatus.status;
                    }
                    TLRPC.TL_user tL_user = new TLRPC.TL_user();
                    tL_user.id = tL_updateUserStatus.user_id;
                    tL_user.status = tL_updateUserStatus.status;
                    arrayList10.add(tL_user);
                    if (tL_updateUserStatus.user_id == getUserConfig().getClientUserId()) {
                        getNotificationsController().setLastOnlineFromOtherDevice(tL_updateUserStatus.status.expires);
                    }
                } else if (update instanceof TLRPC.TL_updateUserName) {
                    TLRPC.TL_updateUserName tL_updateUserName = (TLRPC.TL_updateUserName) update;
                    TLRPC.User user2 = getUser(Integer.valueOf(tL_updateUserName.user_id));
                    if (user2 != null) {
                        if (!UserObject.isContact(user2)) {
                            user2.first_name = tL_updateUserName.first_name;
                            user2.last_name = tL_updateUserName.last_name;
                        }
                        if (!TextUtils.isEmpty(user2.username)) {
                            this.objectsByUsernames.remove(user2.username);
                        }
                        if (TextUtils.isEmpty(tL_updateUserName.username)) {
                            this.objectsByUsernames.put(tL_updateUserName.username, user2);
                        }
                        user2.username = tL_updateUserName.username;
                    }
                    TLRPC.TL_user tL_user2 = new TLRPC.TL_user();
                    tL_user2.id = tL_updateUserName.user_id;
                    tL_user2.first_name = tL_updateUserName.first_name;
                    tL_user2.last_name = tL_updateUserName.last_name;
                    tL_user2.username = tL_updateUserName.username;
                    arrayList9.add(tL_user2);
                } else {
                    if (update instanceof TLRPC.TL_updateDialogPinned) {
                        TLRPC.TL_updateDialogPinned tL_updateDialogPinned = (TLRPC.TL_updateDialogPinned) update;
                        long peerDialogId = tL_updateDialogPinned.peer instanceof TLRPC.TL_dialogPeer ? DialogObject.getPeerDialogId(((TLRPC.TL_dialogPeer) tL_updateDialogPinned.peer).peer) : 0;
                        arrayList6 = arrayList9;
                        i7 = i26;
                        i5 = size;
                        if (!pinDialog(peerDialogId, tL_updateDialogPinned.pinned, null, -1)) {
                            getUserConfig().setPinnedDialogsLoaded(tL_updateDialogPinned.folder_id, false);
                            getUserConfig().saveConfig(false);
                            loadPinnedDialogs(tL_updateDialogPinned.folder_id, peerDialogId, null);
                        }
                        arrayList4 = arrayList10;
                    } else {
                        arrayList6 = arrayList9;
                        i7 = i26;
                        i5 = size;
                        ArrayList<TLRPC.User> arrayList11 = arrayList10;
                        if (update instanceof TLRPC.TL_updatePinnedDialogs) {
                            TLRPC.TL_updatePinnedDialogs tL_updatePinnedDialogs = (TLRPC.TL_updatePinnedDialogs) update;
                            getUserConfig().setPinnedDialogsLoaded(tL_updatePinnedDialogs.folder_id, false);
                            getUserConfig().saveConfig(false);
                            if ((tL_updatePinnedDialogs.flags & 1) != 0) {
                                arrayList7 = new ArrayList<>();
                                ArrayList<TLRPC.DialogPeer> arrayList12 = tL_updatePinnedDialogs.order;
                                int size2 = arrayList12.size();
                                int i28 = 0;
                                while (i28 < size2) {
                                    TLRPC.DialogPeer dialogPeer = arrayList12.get(i28);
                                    if (dialogPeer instanceof TLRPC.TL_dialogPeer) {
                                        TLRPC.Peer peer = ((TLRPC.TL_dialogPeer) dialogPeer).peer;
                                        if (peer.user_id != 0) {
                                            i24 = peer.user_id;
                                            arrayList8 = arrayList11;
                                        } else {
                                            arrayList8 = arrayList11;
                                            if (peer.chat_id != 0) {
                                                i23 = peer.chat_id;
                                            } else {
                                                i23 = peer.channel_id;
                                            }
                                            i24 = -i23;
                                        }
                                        j3 = (long) i24;
                                    } else {
                                        arrayList8 = arrayList11;
                                        j3 = 0;
                                    }
                                    arrayList7.add(Long.valueOf(j3));
                                    i28++;
                                    arrayList11 = arrayList8;
                                }
                                arrayList4 = arrayList11;
                            } else {
                                arrayList4 = arrayList11;
                                arrayList7 = null;
                            }
                            loadPinnedDialogs(tL_updatePinnedDialogs.folder_id, 0, arrayList7);
                        } else {
                            arrayList4 = arrayList11;
                            if (update instanceof TLRPC.TL_updateFolderPeers) {
                                TLRPC.TL_updateFolderPeers tL_updateFolderPeers = (TLRPC.TL_updateFolderPeers) update;
                                int size3 = tL_updateFolderPeers.folder_peers.size();
                                for (int i29 = 0; i29 < size3; i29++) {
                                    TLRPC.TL_folderPeer tL_folderPeer = tL_updateFolderPeers.folder_peers.get(i29);
                                    TLRPC.Dialog dialog2 = this.dialogs_dict.get(DialogObject.getPeerDialogId(tL_folderPeer.peer));
                                    if (!(dialog2 == null || dialog2.folder_id == tL_folderPeer.folder_id)) {
                                        dialog2.pinned = false;
                                        dialog2.pinnedNum = 0;
                                        dialog2.folder_id = tL_folderPeer.folder_id;
                                        ensureFolderDialogExists(tL_folderPeer.folder_id, null);
                                    }
                                }
                                arrayList5 = arrayList6;
                                i6 = i7;
                            } else {
                                if (update instanceof TLRPC.TL_updateUserPhoto) {
                                    TLRPC.TL_updateUserPhoto tL_updateUserPhoto = (TLRPC.TL_updateUserPhoto) update;
                                    TLRPC.User user3 = getUser(Integer.valueOf(tL_updateUserPhoto.user_id));
                                    if (user3 != null) {
                                        user3.photo = tL_updateUserPhoto.photo;
                                    }
                                    TLRPC.TL_user tL_user3 = new TLRPC.TL_user();
                                    tL_user3.id = tL_updateUserPhoto.user_id;
                                    tL_user3.photo = tL_updateUserPhoto.photo;
                                    arrayList5 = arrayList6;
                                    arrayList5.add(tL_user3);
                                } else {
                                    arrayList5 = arrayList6;
                                    if (update instanceof TLRPC.TL_updateUserPhone) {
                                        TLRPC.TL_updateUserPhone tL_updateUserPhone = (TLRPC.TL_updateUserPhone) update;
                                        TLRPC.User user4 = getUser(Integer.valueOf(tL_updateUserPhone.user_id));
                                        if (user4 != null) {
                                            user4.phone = tL_updateUserPhone.phone;
                                            Utilities.phoneBookQueue.postRunnable(new Runnable(user4) {
                                                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$wutOLkCubjysQfjtSpcJ693joI */
                                                private final /* synthetic */ TLRPC.User f$1;

                                                {
                                                    this.f$1 = r2;
                                                }

                                                public final void run() {
                                                    MessagesController.this.lambda$null$282$MessagesController(this.f$1);
                                                }
                                            });
                                            if (UserObject.isUserSelf(user4)) {
                                                getNotificationCenter().postNotificationName(NotificationCenter.mainUserInfoChanged, new Object[0]);
                                            }
                                        }
                                        TLRPC.TL_user tL_user4 = new TLRPC.TL_user();
                                        tL_user4.id = tL_updateUserPhone.user_id;
                                        tL_user4.phone = tL_updateUserPhone.phone;
                                        arrayList5.add(tL_user4);
                                    } else if (update instanceof TLRPC.TL_updateNotifySettings) {
                                        TLRPC.TL_updateNotifySettings tL_updateNotifySettings = (TLRPC.TL_updateNotifySettings) update;
                                        if (tL_updateNotifySettings.notify_settings instanceof TLRPC.TL_peerNotifySettings) {
                                            if (editor == null) {
                                                editor = this.notificationsPreferences.edit();
                                            }
                                            int currentTime = getConnectionsManager().getCurrentTime();
                                            if (tL_updateNotifySettings.peer instanceof TLRPC.TL_notifyPeer) {
                                                TLRPC.TL_notifyPeer tL_notifyPeer = (TLRPC.TL_notifyPeer) tL_updateNotifySettings.peer;
                                                if (tL_notifyPeer.peer.user_id != 0) {
                                                    i20 = tL_notifyPeer.peer.user_id;
                                                } else {
                                                    if (tL_notifyPeer.peer.chat_id != 0) {
                                                        i19 = tL_notifyPeer.peer.chat_id;
                                                    } else {
                                                        i19 = tL_notifyPeer.peer.channel_id;
                                                    }
                                                    i20 = -i19;
                                                }
                                                long j4 = (long) i20;
                                                TLRPC.Dialog dialog3 = this.dialogs_dict.get(j4);
                                                if (dialog3 != null) {
                                                    dialog3.notify_settings = tL_updateNotifySettings.notify_settings;
                                                }
                                                if ((tL_updateNotifySettings.notify_settings.flags & 2) != 0) {
                                                    editor.putBoolean("silent_" + j4, tL_updateNotifySettings.notify_settings.silent);
                                                } else {
                                                    editor.remove("silent_" + j4);
                                                }
                                                if ((tL_updateNotifySettings.notify_settings.flags & 4) == 0) {
                                                    if (dialog3 != null) {
                                                        tL_updateNotifySettings.notify_settings.mute_until = 0;
                                                    }
                                                    editor.remove("notify2_" + j4);
                                                    getMessagesStorage().setDialogFlags(j4, 0);
                                                } else if (tL_updateNotifySettings.notify_settings.mute_until > currentTime) {
                                                    if (tL_updateNotifySettings.notify_settings.mute_until > currentTime + 31536000) {
                                                        editor.putInt("notify2_" + j4, 2);
                                                        if (dialog3 != null) {
                                                            tL_updateNotifySettings.notify_settings.mute_until = Integer.MAX_VALUE;
                                                        }
                                                        i22 = 0;
                                                    } else {
                                                        int i30 = tL_updateNotifySettings.notify_settings.mute_until;
                                                        editor.putInt("notify2_" + j4, 3);
                                                        editor.putInt("notifyuntil_" + j4, tL_updateNotifySettings.notify_settings.mute_until);
                                                        if (dialog3 != null) {
                                                            tL_updateNotifySettings.notify_settings.mute_until = i30;
                                                        }
                                                        i22 = i30;
                                                    }
                                                    getMessagesStorage().setDialogFlags(j4, (((long) i22) << 32) | 1);
                                                    getNotificationsController().removeNotificationsForDialog(j4);
                                                } else {
                                                    if (dialog3 != null) {
                                                        i21 = 0;
                                                        tL_updateNotifySettings.notify_settings.mute_until = 0;
                                                    } else {
                                                        i21 = 0;
                                                    }
                                                    editor.putInt("notify2_" + j4, i21);
                                                    getMessagesStorage().setDialogFlags(j4, 0);
                                                }
                                            } else if (tL_updateNotifySettings.peer instanceof TLRPC.TL_notifyChats) {
                                                if ((tL_updateNotifySettings.notify_settings.flags & 1) != 0) {
                                                    editor.putBoolean("EnablePreviewGroup", tL_updateNotifySettings.notify_settings.show_previews);
                                                }
                                                int i31 = tL_updateNotifySettings.notify_settings.flags;
                                                if ((tL_updateNotifySettings.notify_settings.flags & 4) != 0) {
                                                    editor.putInt("EnableGroup2", tL_updateNotifySettings.notify_settings.mute_until);
                                                }
                                            } else if (tL_updateNotifySettings.peer instanceof TLRPC.TL_notifyUsers) {
                                                if ((tL_updateNotifySettings.notify_settings.flags & 1) != 0) {
                                                    editor.putBoolean("EnablePreviewAll", tL_updateNotifySettings.notify_settings.show_previews);
                                                }
                                                int i32 = tL_updateNotifySettings.notify_settings.flags;
                                                if ((tL_updateNotifySettings.notify_settings.flags & 4) != 0) {
                                                    editor.putInt("EnableAll2", tL_updateNotifySettings.notify_settings.mute_until);
                                                }
                                            } else if (tL_updateNotifySettings.peer instanceof TLRPC.TL_notifyBroadcasts) {
                                                if ((tL_updateNotifySettings.notify_settings.flags & 1) != 0) {
                                                    editor.putBoolean("EnablePreviewChannel", tL_updateNotifySettings.notify_settings.show_previews);
                                                }
                                                int i33 = tL_updateNotifySettings.notify_settings.flags;
                                                if ((tL_updateNotifySettings.notify_settings.flags & 4) != 0) {
                                                    editor.putInt("EnableChannel2", tL_updateNotifySettings.notify_settings.mute_until);
                                                }
                                            }
                                            editor = editor;
                                        }
                                    } else {
                                        if (update instanceof TLRPC.TL_updateChannel) {
                                            TLRPC.TL_updateChannel tL_updateChannel = (TLRPC.TL_updateChannel) update;
                                            TLRPC.Dialog dialog4 = this.dialogs_dict.get(-((long) tL_updateChannel.channel_id));
                                            TLRPC.Chat chat = getChat(Integer.valueOf(tL_updateChannel.channel_id));
                                            if (chat != null) {
                                                if (dialog4 == null && (chat instanceof TLRPC.TL_channel) && !chat.left) {
                                                    Utilities.stageQueue.postRunnable(new Runnable(tL_updateChannel) {
                                                        /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$aNb4X4k9T9as2zCVcUdGF3ONYUQ */
                                                        private final /* synthetic */ TLRPC.TL_updateChannel f$1;

                                                        {
                                                            this.f$1 = r2;
                                                        }

                                                        public final void run() {
                                                            MessagesController.this.lambda$null$283$MessagesController(this.f$1);
                                                        }
                                                    });
                                                } else if (chat.left && dialog4 != null && ((dialog = this.proxyDialog) == null || dialog.id != dialog4.id)) {
                                                    i18 = 0;
                                                    deleteDialog(dialog4.id, 0);
                                                    i6 = i7 | 8192;
                                                    loadFullChat(tL_updateChannel.channel_id, i18, true);
                                                }
                                            }
                                            i18 = 0;
                                            i6 = i7 | 8192;
                                            loadFullChat(tL_updateChannel.channel_id, i18, true);
                                        } else {
                                            i6 = i7;
                                            if (update instanceof TLRPC.TL_updateChatDefaultBannedRights) {
                                                TLRPC.TL_updateChatDefaultBannedRights tL_updateChatDefaultBannedRights = (TLRPC.TL_updateChatDefaultBannedRights) update;
                                                if (tL_updateChatDefaultBannedRights.peer.channel_id != 0) {
                                                    i17 = tL_updateChatDefaultBannedRights.peer.channel_id;
                                                } else {
                                                    i17 = tL_updateChatDefaultBannedRights.peer.chat_id;
                                                }
                                                TLRPC.Chat chat2 = getChat(Integer.valueOf(i17));
                                                if (chat2 != null) {
                                                    chat2.default_banned_rights = tL_updateChatDefaultBannedRights.default_banned_rights;
                                                    AndroidUtilities.runOnUIThread(new Runnable(chat2) {
                                                        /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$IVqndu6EA0UHFV1Z1zPei9Hp4 */
                                                        private final /* synthetic */ TLRPC.Chat f$1;

                                                        {
                                                            this.f$1 = r2;
                                                        }

                                                        public final void run() {
                                                            MessagesController.this.lambda$null$284$MessagesController(this.f$1);
                                                        }
                                                    });
                                                }
                                            } else if (update instanceof TLRPC.TL_updateStickerSets) {
                                                TLRPC.TL_updateStickerSets tL_updateStickerSets = (TLRPC.TL_updateStickerSets) update;
                                                getMediaDataController().loadStickers(0, false, true);
                                            } else if (update instanceof TLRPC.TL_updateStickerSetsOrder) {
                                                TLRPC.TL_updateStickerSetsOrder tL_updateStickerSetsOrder = (TLRPC.TL_updateStickerSetsOrder) update;
                                                getMediaDataController().reorderStickers(tL_updateStickerSetsOrder.masks ? 1 : 0, tL_updateStickerSetsOrder.order);
                                            } else if (update instanceof TLRPC.TL_updateFavedStickers) {
                                                getMediaDataController().loadRecents(2, false, false, true);
                                            } else if (update instanceof TLRPC.TL_updateContactsReset) {
                                                getContactsController().forceImportContacts();
                                            } else if (update instanceof TLRPC.TL_updateNewStickerSet) {
                                                getMediaDataController().addNewStickerSet(((TLRPC.TL_updateNewStickerSet) update).stickerset);
                                            } else if (update instanceof TLRPC.TL_updateSavedGifs) {
                                                this.emojiPreferences.edit().putLong("lastGifLoadTime", 0).commit();
                                            } else if (update instanceof TLRPC.TL_updateRecentStickers) {
                                                this.emojiPreferences.edit().putLong("lastStickersLoadTime", 0).commit();
                                            } else if (update instanceof TLRPC.TL_updateDraftMessage) {
                                                TLRPC.TL_updateDraftMessage tL_updateDraftMessage = (TLRPC.TL_updateDraftMessage) update;
                                                TLRPC.Peer peer2 = tL_updateDraftMessage.peer;
                                                if (peer2.user_id != 0) {
                                                    i16 = peer2.user_id;
                                                } else {
                                                    if (peer2.channel_id != 0) {
                                                        i15 = peer2.channel_id;
                                                    } else {
                                                        i15 = peer2.chat_id;
                                                    }
                                                    i16 = -i15;
                                                }
                                                getMediaDataController().saveDraft((long) i16, tL_updateDraftMessage.draft, null, true);
                                            } else if (update instanceof TLRPC.TL_updateReadFeaturedStickers) {
                                                getMediaDataController().markFaturedStickersAsRead(false);
                                            } else if (update instanceof TLRPC.TL_updatePhoneCall) {
                                                TLRPC.PhoneCall phoneCall = ((TLRPC.TL_updatePhoneCall) update).phone_call;
                                                VoIPService sharedInstance = VoIPService.getSharedInstance();
                                                if (BuildVars.LOGS_ENABLED) {
                                                    FileLog.d("Received call in update: " + phoneCall);
                                                    FileLog.d("call id " + phoneCall.id);
                                                }
                                                if (phoneCall instanceof TLRPC.TL_phoneCallRequested) {
                                                    if (phoneCall.date + (this.callRingTimeout / 1000) < getConnectionsManager().getCurrentTime()) {
                                                        if (BuildVars.LOGS_ENABLED) {
                                                            FileLog.d("ignoring too old call");
                                                        }
                                                    } else if (Build.VERSION.SDK_INT < 21 || NotificationManagerCompat.from(ApplicationLoader.applicationContext).areNotificationsEnabled()) {
                                                        TelephonyManager telephonyManager = (TelephonyManager) ApplicationLoader.applicationContext.getSystemService("phone");
                                                        if (sharedInstance == null && VoIPService.callIShouldHavePutIntoIntent == null && telephonyManager.getCallState() == 0) {
                                                            if (BuildVars.LOGS_ENABLED) {
                                                                FileLog.d("Starting service for call " + phoneCall.id);
                                                            }
                                                            VoIPService.callIShouldHavePutIntoIntent = phoneCall;
                                                            Intent intent = new Intent(ApplicationLoader.applicationContext, VoIPService.class);
                                                            intent.putExtra("is_outgoing", false);
                                                            intent.putExtra("user_id", phoneCall.participant_id == getUserConfig().getClientUserId() ? phoneCall.admin_id : phoneCall.participant_id);
                                                            intent.putExtra("account", this.currentAccount);
                                                            try {
                                                                if (Build.VERSION.SDK_INT >= 26) {
                                                                    ApplicationLoader.applicationContext.startForegroundService(intent);
                                                                } else {
                                                                    ApplicationLoader.applicationContext.startService(intent);
                                                                }
                                                            } catch (Throwable th) {
                                                                FileLog.e(th);
                                                            }
                                                        } else {
                                                            if (BuildVars.LOGS_ENABLED) {
                                                                FileLog.d("Auto-declining call " + phoneCall.id + " because there's already active one");
                                                            }
                                                            TLRPC.TL_phone_discardCall tL_phone_discardCall = new TLRPC.TL_phone_discardCall();
                                                            tL_phone_discardCall.peer = new TLRPC.TL_inputPhoneCall();
                                                            tL_phone_discardCall.peer.access_hash = phoneCall.access_hash;
                                                            tL_phone_discardCall.peer.id = phoneCall.id;
                                                            tL_phone_discardCall.reason = new TLRPC.TL_phoneCallDiscardReasonBusy();
                                                            getConnectionsManager().sendRequest(tL_phone_discardCall, new RequestDelegate() {
                                                                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$7j6SuPyezyrB6I8fxxNCymDKPwQ */

                                                                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                                                                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                                                                    MessagesController.this.lambda$null$285$MessagesController(tLObject, tL_error);
                                                                }
                                                            });
                                                        }
                                                    } else if (BuildVars.LOGS_ENABLED) {
                                                        FileLog.d("Ignoring incoming call because notifications are disabled in system");
                                                    }
                                                } else if (sharedInstance != null && phoneCall != null) {
                                                    sharedInstance.onCallUpdated(phoneCall);
                                                } else if (VoIPService.callIShouldHavePutIntoIntent != null) {
                                                    if (BuildVars.LOGS_ENABLED) {
                                                        FileLog.d("Updated the call while the service is starting");
                                                    }
                                                    if (phoneCall.id == VoIPService.callIShouldHavePutIntoIntent.id) {
                                                        VoIPService.callIShouldHavePutIntoIntent = phoneCall;
                                                    }
                                                }
                                            } else if (update instanceof TLRPC.TL_updateDialogUnreadMark) {
                                                TLRPC.TL_updateDialogUnreadMark tL_updateDialogUnreadMark = (TLRPC.TL_updateDialogUnreadMark) update;
                                                if (tL_updateDialogUnreadMark.peer instanceof TLRPC.TL_dialogPeer) {
                                                    TLRPC.TL_dialogPeer tL_dialogPeer = (TLRPC.TL_dialogPeer) tL_updateDialogUnreadMark.peer;
                                                    if (tL_dialogPeer.peer.user_id != 0) {
                                                        i14 = tL_dialogPeer.peer.user_id;
                                                    } else {
                                                        if (tL_dialogPeer.peer.chat_id != 0) {
                                                            i13 = tL_dialogPeer.peer.chat_id;
                                                        } else {
                                                            i13 = tL_dialogPeer.peer.channel_id;
                                                        }
                                                        i14 = -i13;
                                                    }
                                                    j2 = (long) i14;
                                                } else {
                                                    j2 = 0;
                                                }
                                                getMessagesStorage().setDialogUnread(j2, tL_updateDialogUnreadMark.unread);
                                                TLRPC.Dialog dialog5 = this.dialogs_dict.get(j2);
                                                if (dialog5 == null || dialog5.unread_mark == tL_updateDialogUnreadMark.unread) {
                                                    i12 = i6;
                                                } else {
                                                    dialog5.unread_mark = tL_updateDialogUnreadMark.unread;
                                                    if (dialog5.unread_count == 0 && !isDialogMuted(j2)) {
                                                        if (dialog5.unread_mark) {
                                                            this.unreadUnmutedDialogs++;
                                                        } else {
                                                            this.unreadUnmutedDialogs--;
                                                        }
                                                    }
                                                    if (dialog5.unread_count == 0 && dialog5.unread_mark) {
                                                        this.dialogsUnreadOnly.add(dialog5);
                                                    }
                                                    i12 = i6 | 256;
                                                }
                                                i6 = i12;
                                            } else if (update instanceof TLRPC.TL_updateMessagePoll) {
                                                TLRPC.TL_updateMessagePoll tL_updateMessagePoll = (TLRPC.TL_updateMessagePoll) update;
                                                getNotificationCenter().postNotificationName(NotificationCenter.didUpdatePollResults, Long.valueOf(tL_updateMessagePoll.poll_id), tL_updateMessagePoll.poll, tL_updateMessagePoll.results);
                                            } else if (update instanceof TLRPC.TL_updatePeerSettings) {
                                                TLRPC.TL_updatePeerSettings tL_updatePeerSettings = (TLRPC.TL_updatePeerSettings) update;
                                                if (tL_updatePeerSettings.peer instanceof TLRPC.TL_peerUser) {
                                                    i11 = tL_updatePeerSettings.peer.user_id;
                                                } else {
                                                    if (tL_updatePeerSettings.peer instanceof TLRPC.TL_peerChat) {
                                                        i10 = tL_updatePeerSettings.peer.chat_id;
                                                    } else {
                                                        i10 = tL_updatePeerSettings.peer.channel_id;
                                                    }
                                                    i11 = -i10;
                                                }
                                                savePeerSettings((long) i11, tL_updatePeerSettings.settings, true);
                                            } else if (update instanceof TLRPC.TL_updatePeerLocated) {
                                                getNotificationCenter().postNotificationName(NotificationCenter.newPeopleNearbyAvailable, update);
                                            } else if (update instanceof TLRPC.TL_updateMessageReactions) {
                                                TLRPC.TL_updateMessageReactions tL_updateMessageReactions = (TLRPC.TL_updateMessageReactions) update;
                                                if (tL_updateMessageReactions.peer.chat_id != 0) {
                                                    i9 = tL_updateMessageReactions.peer.chat_id;
                                                } else if (tL_updateMessageReactions.peer.channel_id != 0) {
                                                    i9 = tL_updateMessageReactions.peer.channel_id;
                                                } else {
                                                    i8 = tL_updateMessageReactions.peer.user_id;
                                                    getNotificationCenter().postNotificationName(NotificationCenter.didUpdateReactions, Long.valueOf((long) i8), Integer.valueOf(tL_updateMessageReactions.msg_id), tL_updateMessageReactions.reactions);
                                                }
                                                i8 = -i9;
                                                getNotificationCenter().postNotificationName(NotificationCenter.didUpdateReactions, Long.valueOf((long) i8), Integer.valueOf(tL_updateMessageReactions.msg_id), tL_updateMessageReactions.reactions);
                                            } else if (update instanceof TLRPC.TL_updateTheme) {
                                                Theme.setThemeUploadInfo(null, (TLRPC.TL_theme) ((TLRPC.TL_updateTheme) update).theme, true);
                                            }
                                        }
                                        i27++;
                                        arrayList10 = arrayList4;
                                        size = i5;
                                        i25 = 0;
                                        i26 = i6;
                                        arrayList9 = arrayList5;
                                    }
                                }
                                i6 = i7;
                                i27++;
                                arrayList10 = arrayList4;
                                size = i5;
                                i25 = 0;
                                i26 = i6;
                                arrayList9 = arrayList5;
                            }
                            z2 = true;
                            i27++;
                            arrayList10 = arrayList4;
                            size = i5;
                            i25 = 0;
                            i26 = i6;
                            arrayList9 = arrayList5;
                        }
                    }
                    arrayList5 = arrayList6;
                    i6 = i7;
                    i27++;
                    arrayList10 = arrayList4;
                    size = i5;
                    i25 = 0;
                    i26 = i6;
                    arrayList9 = arrayList5;
                }
                i5 = size;
                arrayList4 = arrayList10;
                arrayList5 = arrayList9;
                i6 = i26;
                i27++;
                arrayList10 = arrayList4;
                size = i5;
                i25 = 0;
                i26 = i6;
                arrayList9 = arrayList5;
            }
            i3 = i26;
            if (editor != null) {
                editor.commit();
                z4 = false;
                getNotificationCenter().postNotificationName(NotificationCenter.notificationsSettingsUpdated, new Object[0]);
            } else {
                z4 = false;
            }
            i2 = 1;
            getMessagesStorage().updateUsers(arrayList10, true, true, true);
            getMessagesStorage().updateUsers(arrayList9, z4, true, true);
        } else {
            i2 = 1;
            i3 = i;
            z2 = false;
        }
        if (longSparseArray != null) {
            NotificationCenter notificationCenter = getNotificationCenter();
            int i34 = NotificationCenter.didReceivedWebpagesInUpdates;
            Object[] objArr = new Object[i2];
            char c2 = z4 ? 1 : 0;
            char c3 = z4 ? 1 : 0;
            char c4 = z4 ? 1 : 0;
            char c5 = z4 ? 1 : 0;
            char c6 = z4 ? 1 : 0;
            objArr[c2] = longSparseArray;
            notificationCenter.postNotificationName(i34, objArr);
            int i35 = 2;
            int i36 = 0;
            while (i36 < i35) {
                LongSparseArray<ArrayList<MessageObject>> longSparseArray6 = i36 == i2 ? this.reloadingScheduledWebpagesPending : this.reloadingWebpagesPending;
                int size4 = longSparseArray.size();
                int i37 = 0;
                while (i37 < size4) {
                    long keyAt = longSparseArray.keyAt(i37);
                    ArrayList<MessageObject> arrayList13 = longSparseArray6.get(keyAt);
                    longSparseArray6.remove(keyAt);
                    if (arrayList13 != null) {
                        TLRPC.WebPage webPage = (TLRPC.WebPage) longSparseArray.valueAt(i37);
                        ArrayList<TLRPC.Message> arrayList14 = new ArrayList<>();
                        if ((webPage instanceof TLRPC.TL_webPage) || (webPage instanceof TLRPC.TL_webPageEmpty)) {
                            int size5 = arrayList13.size();
                            int i38 = 0;
                            j = 0;
                            while (i38 < size5) {
                                arrayList13.get(i38).messageOwner.media.webpage = webPage;
                                if (i38 == 0) {
                                    j = arrayList13.get(i38).getDialogId();
                                    ImageLoader.saveMessageThumbs(arrayList13.get(i38).messageOwner);
                                }
                                arrayList14.add(arrayList13.get(i38).messageOwner);
                                i38++;
                                longSparseArray6 = longSparseArray6;
                            }
                            longSparseArray5 = longSparseArray6;
                        } else {
                            longSparseArray6.put(webPage.id, arrayList13);
                            longSparseArray5 = longSparseArray6;
                            j = 0;
                        }
                        if (!arrayList14.isEmpty()) {
                            getMessagesStorage().putMessages(arrayList14, true, true, false, getDownloadController().getAutodownloadMask(), i36 == 1);
                            getNotificationCenter().postNotificationName(NotificationCenter.replaceMessagesObjects, Long.valueOf(j), arrayList13);
                        }
                    } else {
                        longSparseArray5 = longSparseArray6;
                    }
                    i37++;
                    longSparseArray6 = longSparseArray5;
                }
                i36++;
                i35 = 2;
                i2 = 1;
            }
        }
        if (longSparseArray2 != null) {
            int size6 = longSparseArray2.size();
            for (int i39 = 0; i39 < size6; i39++) {
                updateInterfaceWithMessages(longSparseArray2.keyAt(i39), (ArrayList) longSparseArray2.valueAt(i39), false);
            }
        } else if (z2) {
            sortDialogs(null);
        } else {
            z3 = false;
            if (longSparseArray3 != null) {
                int size7 = longSparseArray3.size();
                for (int i40 = 0; i40 < size7; i40++) {
                    updateInterfaceWithMessages(longSparseArray3.keyAt(i40), (ArrayList) longSparseArray3.valueAt(i40), true);
                }
            }
            if (longSparseArray4 != null) {
                int size8 = longSparseArray4.size();
                for (int i41 = 0; i41 < size8; i41++) {
                    long keyAt2 = longSparseArray4.keyAt(i41);
                    ArrayList<MessageObject> arrayList15 = (ArrayList) longSparseArray4.valueAt(i41);
                    MessageObject messageObject = this.dialogMessage.get(keyAt2);
                    if (messageObject != null) {
                        int size9 = arrayList15.size();
                        int i42 = 0;
                        while (true) {
                            if (i42 >= size9) {
                                break;
                            }
                            MessageObject messageObject2 = arrayList15.get(i42);
                            if (messageObject.getId() != messageObject2.getId()) {
                                if (messageObject.getDialogId() == messageObject2.getDialogId() && (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage) && messageObject.replyMessageObject != null && messageObject.replyMessageObject.getId() == messageObject2.getId()) {
                                    messageObject.replyMessageObject = messageObject2;
                                    messageObject.generatePinMessageText(null, null);
                                    z3 = true;
                                    break;
                                }
                                i42++;
                            } else {
                                this.dialogMessage.put(keyAt2, messageObject2);
                                if (messageObject2.messageOwner.to_id != null && messageObject2.messageOwner.to_id.channel_id == 0) {
                                    this.dialogMessagesByIds.put(messageObject2.getId(), messageObject2);
                                }
                                z3 = true;
                            }
                        }
                    }
                    getMediaDataController().loadReplyMessagesForMessages(arrayList15, keyAt2, false);
                    getNotificationCenter().postNotificationName(NotificationCenter.replaceMessagesObjects, Long.valueOf(keyAt2), arrayList15, false);
                }
            }
            if (z3) {
                getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
            }
            if (z) {
                i3 |= 64;
            }
            if (arrayList2 != null) {
                i3 = i3 | 1 | 128;
            }
            if (arrayList3 != null) {
                int size10 = arrayList3.size();
                for (int i43 = 0; i43 < size10; i43++) {
                    getMessagesStorage().updateChatParticipants((TLRPC.ChatParticipants) arrayList3.get(i43));
                }
            }
            if (sparseArray == null) {
                i4 = 1;
                c = 0;
                getNotificationCenter().postNotificationName(NotificationCenter.didUpdatedMessagesViews, sparseArray);
            } else {
                i4 = 1;
                c = 0;
            }
            if (i3 == 0) {
                NotificationCenter notificationCenter2 = getNotificationCenter();
                int i44 = NotificationCenter.updateInterfaces;
                Object[] objArr2 = new Object[i4];
                objArr2[c] = Integer.valueOf(i3);
                notificationCenter2.postNotificationName(i44, objArr2);
                return;
            }
            return;
        }
        z3 = true;
        if (longSparseArray3 != null) {
        }
        if (longSparseArray4 != null) {
        }
        if (z3) {
        }
        if (z) {
        }
        if (arrayList2 != null) {
        }
        if (arrayList3 != null) {
        }
        if (sparseArray == null) {
        }
        if (i3 == 0) {
        }
    }

    public /* synthetic */ void lambda$null$282$MessagesController(TLRPC.User user) {
        getContactsController().addContactToPhoneBook(user, true);
    }

    public /* synthetic */ void lambda$null$283$MessagesController(TLRPC.TL_updateChannel tL_updateChannel) {
        getChannelDifference(tL_updateChannel.channel_id, 1, 0, null);
    }

    public /* synthetic */ void lambda$null$284$MessagesController(TLRPC.Chat chat) {
        getNotificationCenter().postNotificationName(NotificationCenter.channelRightsUpdated, chat);
    }

    public /* synthetic */ void lambda$null$285$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tLObject != null) {
            processUpdates((TLRPC.Updates) tLObject, false);
        }
    }

    public /* synthetic */ void lambda$processUpdateArray$288$MessagesController(SparseLongArray sparseLongArray, SparseLongArray sparseLongArray2, SparseIntArray sparseIntArray, ArrayList arrayList, SparseArray sparseArray, SparseArray sparseArray2, SparseIntArray sparseIntArray2) {
        AndroidUtilities.runOnUIThread(new Runnable(sparseLongArray, sparseLongArray2, sparseIntArray, arrayList, sparseArray, sparseArray2, sparseIntArray2) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$lTirPOPuZvMdBKKE8IfRIobjK7Y */
            private final /* synthetic */ SparseLongArray f$1;
            private final /* synthetic */ SparseLongArray f$2;
            private final /* synthetic */ SparseIntArray f$3;
            private final /* synthetic */ ArrayList f$4;
            private final /* synthetic */ SparseArray f$5;
            private final /* synthetic */ SparseArray f$6;
            private final /* synthetic */ SparseIntArray f$7;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
                this.f$4 = r5;
                this.f$5 = r6;
                this.f$6 = r7;
                this.f$7 = r8;
            }

            public final void run() {
                MessagesController.this.lambda$null$287$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6, this.f$7);
            }
        });
    }

    public /* synthetic */ void lambda$null$287$MessagesController(SparseLongArray sparseLongArray, SparseLongArray sparseLongArray2, SparseIntArray sparseIntArray, ArrayList arrayList, SparseArray sparseArray, SparseArray sparseArray2, SparseIntArray sparseIntArray2) {
        int i;
        MessageObject messageObject;
        MessageObject messageObject2;
        MessageObject messageObject3;
        if (sparseLongArray == null && sparseLongArray2 == null) {
            i = 0;
        } else {
            getNotificationCenter().postNotificationName(NotificationCenter.messagesRead, sparseLongArray, sparseLongArray2);
            if (sparseLongArray != null) {
                getNotificationsController().processReadMessages(sparseLongArray, 0, 0, 0, false);
                SharedPreferences.Editor edit = this.notificationsPreferences.edit();
                int size = sparseLongArray.size();
                i = 0;
                for (int i2 = 0; i2 < size; i2++) {
                    int keyAt = sparseLongArray.keyAt(i2);
                    int valueAt = (int) sparseLongArray.valueAt(i2);
                    TLRPC.Dialog dialog = this.dialogs_dict.get((long) keyAt);
                    if (dialog != null && dialog.top_message > 0 && dialog.top_message <= valueAt && (messageObject3 = this.dialogMessage.get(dialog.id)) != null && !messageObject3.isOut()) {
                        messageObject3.setIsRead();
                        i |= 256;
                    }
                    if (keyAt != getUserConfig().getClientUserId()) {
                        edit.remove("diditem" + keyAt);
                        edit.remove("diditemo" + keyAt);
                    }
                }
                edit.commit();
            } else {
                i = 0;
            }
            if (sparseLongArray2 != null) {
                int size2 = sparseLongArray2.size();
                for (int i3 = 0; i3 < size2; i3++) {
                    int keyAt2 = sparseLongArray2.keyAt(i3);
                    int valueAt2 = (int) sparseLongArray2.valueAt(i3);
                    TLRPC.Dialog dialog2 = this.dialogs_dict.get((long) keyAt2);
                    if (dialog2 != null && dialog2.top_message > 0 && dialog2.top_message <= valueAt2 && (messageObject2 = this.dialogMessage.get(dialog2.id)) != null && messageObject2.isOut()) {
                        messageObject2.setIsRead();
                        i |= 256;
                    }
                }
            }
        }
        if (sparseIntArray != null) {
            int size3 = sparseIntArray.size();
            for (int i4 = 0; i4 < size3; i4++) {
                int keyAt3 = sparseIntArray.keyAt(i4);
                int valueAt3 = sparseIntArray.valueAt(i4);
                getNotificationCenter().postNotificationName(NotificationCenter.messagesReadEncrypted, Integer.valueOf(keyAt3), Integer.valueOf(valueAt3));
                long j = ((long) keyAt3) << 32;
                if (!(this.dialogs_dict.get(j) == null || (messageObject = this.dialogMessage.get(j)) == null || messageObject.messageOwner.date > valueAt3)) {
                    messageObject.setIsRead();
                    i |= 256;
                }
            }
        }
        if (arrayList != null) {
            getNotificationCenter().postNotificationName(NotificationCenter.messagesReadContent, arrayList);
        }
        if (sparseArray != null) {
            int size4 = sparseArray.size();
            for (int i5 = 0; i5 < size4; i5++) {
                int keyAt4 = sparseArray.keyAt(i5);
                ArrayList arrayList2 = (ArrayList) sparseArray.valueAt(i5);
                if (arrayList2 != null) {
                    getNotificationCenter().postNotificationName(NotificationCenter.messagesDeleted, arrayList2, Integer.valueOf(keyAt4), false);
                    if (keyAt4 == 0) {
                        int size5 = arrayList2.size();
                        for (int i6 = 0; i6 < size5; i6++) {
                            MessageObject messageObject4 = this.dialogMessagesByIds.get(((Integer) arrayList2.get(i6)).intValue());
                            if (messageObject4 != null) {
                                messageObject4.deleted = true;
                            }
                        }
                    } else {
                        MessageObject messageObject5 = this.dialogMessage.get((long) (-keyAt4));
                        if (messageObject5 != null) {
                            int size6 = arrayList2.size();
                            int i7 = 0;
                            while (true) {
                                if (i7 >= size6) {
                                    break;
                                } else if (messageObject5.getId() == ((Integer) arrayList2.get(i7)).intValue()) {
                                    messageObject5.deleted = true;
                                    break;
                                } else {
                                    i7++;
                                }
                            }
                        }
                    }
                }
            }
            getNotificationsController().removeDeletedMessagesFromNotifications(sparseArray);
        }
        if (sparseArray2 != null) {
            int size7 = sparseArray2.size();
            for (int i8 = 0; i8 < size7; i8++) {
                int keyAt5 = sparseArray2.keyAt(i8);
                ArrayList arrayList3 = (ArrayList) sparseArray2.valueAt(i8);
                if (arrayList3 != null) {
                    NotificationCenter.getInstance(this.currentAccount).postNotificationName(NotificationCenter.messagesDeleted, arrayList3, Integer.valueOf(keyAt5), true);
                }
            }
        }
        if (sparseIntArray2 != null) {
            int size8 = sparseIntArray2.size();
            int i9 = 0;
            while (true) {
                if (i9 >= size8) {
                    break;
                }
                int keyAt6 = sparseIntArray2.keyAt(i9);
                int valueAt4 = sparseIntArray2.valueAt(i9);
                long j2 = (long) (-keyAt6);
                getNotificationCenter().postNotificationName(NotificationCenter.historyCleared, Long.valueOf(j2), Integer.valueOf(valueAt4));
                MessageObject messageObject6 = this.dialogMessage.get(j2);
                if (messageObject6 != null && messageObject6.getId() <= valueAt4) {
                    messageObject6.deleted = true;
                    break;
                }
                i9++;
            }
            getNotificationsController().removeDeletedHisoryFromNotifications(sparseIntArray2);
        }
        if (i != 0) {
            getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, Integer.valueOf(i));
        }
    }

    public /* synthetic */ void lambda$processUpdateArray$289$MessagesController(ArrayList arrayList, int i) {
        getMessagesStorage().updateDialogsWithDeletedMessages(arrayList, getMessagesStorage().markMessagesAsDeleted(arrayList, false, i, true, false), false, i);
    }

    public /* synthetic */ void lambda$processUpdateArray$290$MessagesController(int i, int i2) {
        getMessagesStorage().updateDialogsWithDeletedMessages(new ArrayList<>(), getMessagesStorage().markMessagesAsDeleted(i, i2, false, true), false, i);
    }

    public boolean isDialogMuted(long j) {
        SharedPreferences sharedPreferences = this.notificationsPreferences;
        int i = sharedPreferences.getInt("notify2_" + j, -1);
        if (i == -1) {
            return !getNotificationsController().isGlobalNotificationsEnabled(j);
        }
        if (i == 2) {
            return true;
        }
        if (i == 3) {
            SharedPreferences sharedPreferences2 = this.notificationsPreferences;
            if (sharedPreferences2.getInt("notifyuntil_" + j, 0) >= getConnectionsManager().getCurrentTime()) {
                return true;
            }
        }
        return false;
    }

    private boolean updatePrintingUsersWithNewMessages(long j, ArrayList<MessageObject> arrayList) {
        boolean z;
        if (j > 0) {
            if (this.printingUsers.get(Long.valueOf(j)) != null) {
                this.printingUsers.remove(Long.valueOf(j));
                return true;
            }
        } else if (j < 0) {
            ArrayList arrayList2 = new ArrayList();
            Iterator<MessageObject> it = arrayList.iterator();
            while (it.hasNext()) {
                MessageObject next = it.next();
                if (!arrayList2.contains(Integer.valueOf(next.messageOwner.from_id))) {
                    arrayList2.add(Integer.valueOf(next.messageOwner.from_id));
                }
            }
            ArrayList<PrintingUser> arrayList3 = this.printingUsers.get(Long.valueOf(j));
            if (arrayList3 != null) {
                int i = 0;
                z = false;
                while (i < arrayList3.size()) {
                    if (arrayList2.contains(Integer.valueOf(arrayList3.get(i).userId))) {
                        arrayList3.remove(i);
                        i--;
                        if (arrayList3.isEmpty()) {
                            this.printingUsers.remove(Long.valueOf(j));
                        }
                        z = true;
                    }
                    i++;
                }
            } else {
                z = false;
            }
            if (z) {
                return true;
            }
        }
        return false;
    }

    /* access modifiers changed from: protected */
    /* JADX WARNING: Removed duplicated region for block: B:129:0x0328  */
    /* JADX WARNING: Removed duplicated region for block: B:131:0x032e  */
    /* JADX WARNING: Removed duplicated region for block: B:143:? A[RETURN, SYNTHETIC] */
    public void updateInterfaceWithMessages(long j, ArrayList<MessageObject> arrayList, boolean z) {
        boolean z2;
        int i;
        boolean z3;
        MessageObject messageObject;
        boolean z4;
        if (arrayList != null && !arrayList.isEmpty()) {
            boolean z5 = false;
            boolean z6 = ((int) j) == 0;
            if (!z) {
                messageObject = null;
                z3 = false;
                i = 0;
                z2 = false;
                for (int i2 = 0; i2 < arrayList.size(); i2++) {
                    MessageObject messageObject2 = arrayList.get(i2);
                    if (messageObject == null || ((!z6 && messageObject2.getId() > messageObject.getId()) || (((z6 || (messageObject2.getId() < 0 && messageObject.getId() < 0)) && messageObject2.getId() < messageObject.getId()) || messageObject2.messageOwner.date > messageObject.messageOwner.date))) {
                        if (messageObject2.messageOwner.to_id.channel_id != 0) {
                            i = messageObject2.messageOwner.to_id.channel_id;
                        }
                        messageObject = messageObject2;
                    }
                    if (!z3 && !messageObject2.isOut()) {
                        z3 = true;
                    }
                    if (messageObject2.isOut() && !messageObject2.isSending() && !messageObject2.isForwarded()) {
                        if (messageObject2.isNewGif()) {
                            getMediaDataController().addRecentGif(messageObject2.messageOwner.media.document, messageObject2.messageOwner.date);
                        } else if (!messageObject2.isAnimatedEmoji() && (messageObject2.isSticker() || messageObject2.isAnimatedSticker())) {
                            getMediaDataController().addRecentSticker(0, messageObject2, messageObject2.messageOwner.media.document, messageObject2.messageOwner.date, false);
                        }
                    }
                    if (messageObject2.isOut() && messageObject2.isSent()) {
                        z2 = true;
                    }
                }
            } else {
                messageObject = null;
                z3 = false;
                i = 0;
                z2 = false;
            }
            getMediaDataController().loadReplyMessagesForMessages(arrayList, j, z);
            getNotificationCenter().postNotificationName(NotificationCenter.didReceiveNewMessages, Long.valueOf(j), arrayList, Boolean.valueOf(z));
            if (messageObject != null && !z) {
                TLRPC.TL_dialog tL_dialog = (TLRPC.TL_dialog) this.dialogs_dict.get(j);
                if (!(messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatMigrateTo)) {
                    if (tL_dialog == null) {
                        TLRPC.Chat chat = getChat(Integer.valueOf(i));
                        if (i != 0 && chat == null) {
                            return;
                        }
                        if (chat == null || !ChatObject.isNotInChat(chat)) {
                            if (BuildVars.LOGS_ENABLED) {
                                FileLog.d("not found dialog with id " + j + " dictCount = " + this.dialogs_dict.size() + " allCount = " + this.allDialogs.size());
                            }
                            TLRPC.TL_dialog tL_dialog2 = new TLRPC.TL_dialog();
                            tL_dialog2.id = j;
                            tL_dialog2.unread_count = 0;
                            tL_dialog2.top_message = messageObject.getId();
                            tL_dialog2.last_message_date = messageObject.messageOwner.date;
                            tL_dialog2.flags = ChatObject.isChannel(chat) ? 1 : 0;
                            this.dialogs_dict.put(j, tL_dialog2);
                            this.allDialogs.add(tL_dialog2);
                            this.dialogMessage.put(j, messageObject);
                            if (messageObject.messageOwner.to_id.channel_id == 0) {
                                this.dialogMessagesByIds.put(messageObject.getId(), messageObject);
                                if (messageObject.messageOwner.random_id != 0) {
                                    this.dialogMessagesByRandomIds.put(messageObject.messageOwner.random_id, messageObject);
                                }
                            }
                            getMessagesStorage().getDialogFolderId(j, new MessagesStorage.IntCallback(tL_dialog2, j) {
                                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$A4ZHDD6eQo3SfDLCJu8qPybmjIU */
                                private final /* synthetic */ TLRPC.Dialog f$1;
                                private final /* synthetic */ long f$2;

                                {
                                    this.f$1 = r2;
                                    this.f$2 = r3;
                                }

                                @Override // im.guobwnxjuc.messenger.MessagesStorage.IntCallback
                                public final void run(int i) {
                                    MessagesController.this.lambda$updateInterfaceWithMessages$291$MessagesController(this.f$1, this.f$2, i);
                                }
                            });
                        } else {
                            return;
                        }
                    } else {
                        if (z3) {
                            if (tL_dialog.folder_id == 1 && !isDialogMuted(tL_dialog.id)) {
                                tL_dialog.folder_id = 0;
                                tL_dialog.pinned = false;
                                tL_dialog.pinnedNum = 0;
                                getMessagesStorage().setDialogsFolderId(null, null, tL_dialog.id, 0);
                                z5 = true;
                            }
                        }
                        if ((tL_dialog.top_message <= 0 || messageObject.getId() <= 0 || messageObject.getId() <= tL_dialog.top_message) && ((tL_dialog.top_message >= 0 || messageObject.getId() >= 0 || messageObject.getId() >= tL_dialog.top_message) && this.dialogMessage.indexOfKey(j) >= 0 && tL_dialog.top_message >= 0 && tL_dialog.last_message_date > messageObject.messageOwner.date)) {
                            z4 = z5;
                            if (z4) {
                                sortDialogs(null);
                            }
                            if (!z2) {
                                getMediaDataController().increasePeerRaiting(j);
                                return;
                            }
                            return;
                        }
                        MessageObject messageObject3 = this.dialogMessagesByIds.get(tL_dialog.top_message);
                        this.dialogMessagesByIds.remove(tL_dialog.top_message);
                        if (!(messageObject3 == null || messageObject3.messageOwner.random_id == 0)) {
                            this.dialogMessagesByRandomIds.remove(messageObject3.messageOwner.random_id);
                        }
                        tL_dialog.top_message = messageObject.getId();
                        tL_dialog.last_message_date = messageObject.messageOwner.date;
                        this.dialogMessage.put(j, messageObject);
                        if (messageObject.messageOwner.to_id.channel_id == 0) {
                            this.dialogMessagesByIds.put(messageObject.getId(), messageObject);
                            if (messageObject.messageOwner.random_id != 0) {
                                this.dialogMessagesByRandomIds.put(messageObject.messageOwner.random_id, messageObject);
                            }
                        }
                    }
                    z4 = true;
                    if (z4) {
                    }
                    if (!z2) {
                    }
                } else if (tL_dialog != null) {
                    this.allDialogs.remove(tL_dialog);
                    this.dialogsServerOnly.remove(tL_dialog);
                    this.dialogsCanAddUsers.remove(tL_dialog);
                    this.dialogsChannelsOnly.remove(tL_dialog);
                    this.dialogsGroupsOnly.remove(tL_dialog);
                    this.dialogsUnreadOnly.remove(tL_dialog);
                    this.dialogsUsersOnly.remove(tL_dialog);
                    this.dialogsForward.remove(tL_dialog);
                    this.dialogs_dict.remove(tL_dialog.id);
                    this.dialogs_read_inbox_max.remove(Long.valueOf(tL_dialog.id));
                    this.dialogs_read_outbox_max.remove(Long.valueOf(tL_dialog.id));
                    int i3 = this.nextDialogsCacheOffset.get(tL_dialog.folder_id, 0);
                    if (i3 > 0) {
                        this.nextDialogsCacheOffset.put(tL_dialog.folder_id, i3 - 1);
                    }
                    this.dialogMessage.remove(tL_dialog.id);
                    ArrayList<TLRPC.Dialog> arrayList2 = this.dialogsByFolder.get(tL_dialog.folder_id);
                    if (arrayList2 != null) {
                        arrayList2.remove(tL_dialog);
                    }
                    MessageObject messageObject4 = this.dialogMessagesByIds.get(tL_dialog.top_message);
                    this.dialogMessagesByIds.remove(tL_dialog.top_message);
                    if (!(messageObject4 == null || messageObject4.messageOwner.random_id == 0)) {
                        this.dialogMessagesByRandomIds.remove(messageObject4.messageOwner.random_id);
                    }
                    tL_dialog.top_message = 0;
                    getNotificationsController().removeNotificationsForDialog(tL_dialog.id);
                    getNotificationCenter().postNotificationName(NotificationCenter.needReloadRecentDialogsSearch, new Object[0]);
                }
            }
        }
    }

    public /* synthetic */ void lambda$updateInterfaceWithMessages$291$MessagesController(TLRPC.Dialog dialog, long j, int i) {
        if (i == -1) {
            int i2 = (int) j;
            if (i2 != 0) {
                loadUnknownDialog(getInputPeer(i2), 0);
            }
        } else if (i != 0) {
            dialog.folder_id = i;
            sortDialogs(null);
            getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, true);
        }
    }

    public void addDialogAction(long j, boolean z) {
        TLRPC.Dialog dialog = this.dialogs_dict.get(j);
        if (dialog != null) {
            if (z) {
                this.clearingHistoryDialogs.put(j, dialog);
            } else {
                this.deletingDialogs.put(j, dialog);
                this.allDialogs.remove(dialog);
                sortDialogs(null);
            }
            getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, true);
        }
    }

    public void removeDialogAction(long j, boolean z, boolean z2) {
        TLRPC.Dialog dialog = this.dialogs_dict.get(j);
        if (dialog != null) {
            if (z) {
                this.clearingHistoryDialogs.remove(j);
            } else {
                this.deletingDialogs.remove(j);
                if (!z2) {
                    this.allDialogs.add(dialog);
                    sortDialogs(null);
                }
            }
            if (!z2) {
                getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, true);
            }
        }
    }

    public boolean isClearingDialog(long j) {
        return this.clearingHistoryDialogs.get(j) != null;
    }

    /* JADX WARNING: Removed duplicated region for block: B:67:0x0130  */
    /* JADX WARNING: Removed duplicated region for block: B:68:0x0137  */
    public void sortDialogs(SparseArray<TLRPC.Chat> sparseArray) {
        TLRPC.User currentUser;
        boolean z;
        TLRPC.Chat chat;
        TLRPC.Chat chat2;
        this.dialogsServerOnly.clear();
        this.dialogsCanAddUsers.clear();
        this.dialogsChannelsOnly.clear();
        this.dialogsGroupsOnly.clear();
        this.dialogsUnreadOnly.clear();
        this.dialogsUsersOnly.clear();
        this.dialogsForward.clear();
        for (int i = 0; i < this.dialogsByFolder.size(); i++) {
            ArrayList<TLRPC.Dialog> valueAt = this.dialogsByFolder.valueAt(i);
            if (valueAt != null) {
                valueAt.clear();
            }
        }
        this.unreadUnmutedDialogs = 0;
        int clientUserId = getUserConfig().getClientUserId();
        Collections.sort(this.allDialogs, this.dialogComparator);
        this.isLeftProxyChannel = true;
        TLRPC.Dialog dialog = this.proxyDialog;
        if (dialog != null && dialog.id < 0 && (chat2 = getChat(Integer.valueOf(-((int) this.proxyDialog.id)))) != null && !chat2.left) {
            this.isLeftProxyChannel = false;
        }
        boolean z2 = getNotificationsController().showBadgeMessages;
        int size = this.allDialogs.size();
        int i2 = 0;
        boolean z3 = false;
        while (i2 < size) {
            TLRPC.Dialog dialog2 = this.allDialogs.get(i2);
            int i3 = (int) (dialog2.id >> 32);
            int i4 = (int) dialog2.id;
            if (dialog2 instanceof TLRPC.TL_dialog) {
                if (!(i4 == 0 || i3 == 1)) {
                    this.dialogsServerOnly.add(dialog2);
                    if (DialogObject.isChannel(dialog2)) {
                        TLRPC.Chat chat3 = getChat(Integer.valueOf(-i4));
                        if (chat3 != null && ((chat3.megagroup && chat3.admin_rights != null && (chat3.admin_rights.post_messages || chat3.admin_rights.add_admins)) || chat3.creator)) {
                            this.dialogsCanAddUsers.add(dialog2);
                        }
                        if (chat3 == null || !chat3.megagroup) {
                            this.dialogsChannelsOnly.add(dialog2);
                            if (!ChatObject.hasAdminRights(chat3) || !ChatObject.canPost(chat3)) {
                                z = false;
                                if (!(dialog2.unread_count == 0 && dialog2.unread_mentions_count == 0)) {
                                    this.dialogsUnreadOnly.add(dialog2);
                                }
                                if (z && dialog2.folder_id == 0) {
                                    if (i4 != clientUserId) {
                                        this.dialogsForward.add(0, dialog2);
                                        z3 = true;
                                    } else {
                                        this.dialogsForward.add(dialog2);
                                    }
                                }
                            }
                        } else {
                            this.dialogsGroupsOnly.add(dialog2);
                        }
                    } else if (i4 < 0) {
                        if (sparseArray == null || (chat = sparseArray.get(-i4)) == null || chat.migrated_to == null) {
                            this.dialogsCanAddUsers.add(dialog2);
                            this.dialogsGroupsOnly.add(dialog2);
                        } else {
                            this.allDialogs.remove(i2);
                            i2--;
                            size--;
                            i2++;
                        }
                    } else if (i4 > 0 && i4 != clientUserId) {
                        this.dialogsUsersOnly.add(dialog2);
                    }
                }
                z = true;
                this.dialogsUnreadOnly.add(dialog2);
                if (i4 != clientUserId) {
                }
            }
            if ((dialog2.unread_count != 0 || dialog2.unread_mark) && !isDialogMuted(dialog2.id)) {
                this.unreadUnmutedDialogs++;
            }
            if (this.proxyDialog == null || dialog2.id != this.proxyDialog.id || !this.isLeftProxyChannel) {
                addDialogToItsFolder(-1, dialog2, z2);
                i2++;
            } else {
                this.allDialogs.remove(i2);
                i2--;
                size--;
                i2++;
            }
        }
        TLRPC.Dialog dialog3 = this.proxyDialog;
        if (dialog3 != null && this.isLeftProxyChannel) {
            this.allDialogs.add(0, dialog3);
            addDialogToItsFolder(-2, this.proxyDialog, z2);
        }
        if (!z3 && (currentUser = getUserConfig().getCurrentUser()) != null) {
            TLRPC.TL_dialog tL_dialog = new TLRPC.TL_dialog();
            tL_dialog.id = (long) currentUser.id;
            tL_dialog.notify_settings = new TLRPC.TL_peerNotifySettings();
            tL_dialog.peer = new TLRPC.TL_peerUser();
            tL_dialog.peer.user_id = currentUser.id;
            this.dialogsForward.add(0, tL_dialog);
        }
        for (int i5 = 0; i5 < this.dialogsByFolder.size(); i5++) {
            int keyAt = this.dialogsByFolder.keyAt(i5);
            if (this.dialogsByFolder.valueAt(i5).isEmpty()) {
                this.dialogsByFolder.remove(keyAt);
            }
        }
    }

    private void addDialogToItsFolder(int i, TLRPC.Dialog dialog, boolean z) {
        int i2;
        TLRPC.Dialog dialog2;
        if (dialog instanceof TLRPC.TL_dialogFolder) {
            dialog.unread_count = 0;
            dialog.unread_mentions_count = 0;
            i2 = 0;
        } else {
            i2 = dialog.folder_id;
        }
        ArrayList<TLRPC.Dialog> arrayList = this.dialogsByFolder.get(i2);
        if (arrayList == null) {
            arrayList = new ArrayList<>();
            this.dialogsByFolder.put(i2, arrayList);
        }
        if (!(i2 == 0 || dialog.unread_count == 0 || (dialog2 = this.dialogs_dict.get(DialogObject.makeFolderDialogId(i2))) == null)) {
            if (z) {
                if (isDialogMuted(dialog.id)) {
                    dialog2.unread_count += dialog.unread_count;
                } else {
                    dialog2.unread_mentions_count += dialog.unread_count;
                }
            } else if (isDialogMuted(dialog.id)) {
                dialog2.unread_count++;
            } else {
                dialog2.unread_mentions_count++;
            }
        }
        if (i == -1) {
            arrayList.add(dialog);
        } else if (i != -2) {
            arrayList.add(i, dialog);
        } else if (arrayList.isEmpty() || !(arrayList.get(0) instanceof TLRPC.TL_dialogFolder)) {
            arrayList.add(0, dialog);
        } else {
            arrayList.add(1, dialog);
        }
    }

    public static String getRestrictionReason(ArrayList<TLRPC.TL_restrictionReason> arrayList) {
        if (arrayList.isEmpty()) {
            return null;
        }
        int size = arrayList.size();
        for (int i = 0; i < size; i++) {
            TLRPC.TL_restrictionReason tL_restrictionReason = arrayList.get(i);
            if ("all".equals(tL_restrictionReason.platform) || "android".equals(tL_restrictionReason.platform)) {
                return tL_restrictionReason.text;
            }
        }
        return null;
    }

    private static void showCantOpenAlert(BaseFragment baseFragment, String str) {
        if (baseFragment != null && baseFragment.getParentActivity() != null) {
            AlertDialog.Builder builder = new AlertDialog.Builder(baseFragment.getParentActivity());
            builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
            builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
            builder.setMessage(str);
            baseFragment.showDialog(builder.create());
        }
    }

    public boolean checkCanOpenChat(Bundle bundle, BaseFragment baseFragment) {
        return checkCanOpenChat(bundle, baseFragment, null);
    }

    /* JADX DEBUG: Multi-variable search result rejected for r3v7, resolved type: im.guobwnxjuc.tgnet.TLRPC$TL_channels_getMessages */
    /* JADX WARN: Multi-variable type inference failed */
    public boolean checkCanOpenChat(Bundle bundle, BaseFragment baseFragment, MessageObject messageObject) {
        TLRPC.Chat chat;
        TLRPC.User user;
        int dialogId;
        TLRPC.TL_messages_getMessages tL_messages_getMessages;
        if (!(bundle == null || baseFragment == null)) {
            int i = bundle.getInt("user_id", 0);
            int i2 = bundle.getInt("chat_id", 0);
            int i3 = bundle.getInt("message_id", 0);
            String str = null;
            if (i != 0) {
                user = getUser(Integer.valueOf(i));
                chat = null;
            } else if (i2 != 0) {
                chat = getChat(Integer.valueOf(i2));
                user = null;
            } else {
                user = null;
                chat = null;
            }
            if (user == null && chat == null) {
                return true;
            }
            if (chat != null) {
                str = getRestrictionReason(chat.restriction_reason);
            } else if (user != null) {
                str = getRestrictionReason(user.restriction_reason);
            }
            if (str != null) {
                showCantOpenAlert(baseFragment, str);
                return false;
            } else if (!(i3 == 0 || messageObject == null || chat == null || chat.access_hash != 0 || (dialogId = (int) messageObject.getDialogId()) == 0)) {
                AlertDialog alertDialog = new AlertDialog(baseFragment.getParentActivity(), 3);
                if (dialogId < 0) {
                    chat = getChat(Integer.valueOf(-dialogId));
                }
                if (dialogId > 0 || !ChatObject.isChannel(chat)) {
                    TLRPC.TL_messages_getMessages tL_messages_getMessages2 = new TLRPC.TL_messages_getMessages();
                    tL_messages_getMessages2.id.add(Integer.valueOf(messageObject.getId()));
                    tL_messages_getMessages = tL_messages_getMessages2;
                } else {
                    TLRPC.Chat chat2 = getChat(Integer.valueOf(-dialogId));
                    TLRPC.TL_channels_getMessages tL_channels_getMessages = new TLRPC.TL_channels_getMessages();
                    tL_channels_getMessages.channel = getInputChannel(chat2);
                    tL_channels_getMessages.id.add(Integer.valueOf(messageObject.getId()));
                    tL_messages_getMessages = tL_channels_getMessages;
                }
                alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener(getConnectionsManager().sendRequest(tL_messages_getMessages, new RequestDelegate(alertDialog, baseFragment, bundle) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$s4kSnHLzV68fUB1YUP8OvTRBTBE */
                    private final /* synthetic */ AlertDialog f$1;
                    private final /* synthetic */ BaseFragment f$2;
                    private final /* synthetic */ Bundle f$3;

                    {
                        this.f$1 = r2;
                        this.f$2 = r3;
                        this.f$3 = r4;
                    }

                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        MessagesController.this.lambda$checkCanOpenChat$293$MessagesController(this.f$1, this.f$2, this.f$3, tLObject, tL_error);
                    }
                }), baseFragment) {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$c9TTou6CGfsnK0A0GnupOW2paB8 */
                    private final /* synthetic */ int f$1;
                    private final /* synthetic */ BaseFragment f$2;

                    {
                        this.f$1 = r2;
                        this.f$2 = r3;
                    }

                    public final void onCancel(DialogInterface dialogInterface) {
                        MessagesController.this.lambda$checkCanOpenChat$294$MessagesController(this.f$1, this.f$2, dialogInterface);
                    }
                });
                baseFragment.setVisibleDialog(alertDialog);
                alertDialog.show();
                return false;
            }
        }
        return true;
    }

    public /* synthetic */ void lambda$checkCanOpenChat$293$MessagesController(AlertDialog alertDialog, BaseFragment baseFragment, Bundle bundle, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tLObject != null) {
            AndroidUtilities.runOnUIThread(new Runnable(alertDialog, tLObject, baseFragment, bundle) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$488oOuIzENYXxOuCgTFLsKqoKZc */
                private final /* synthetic */ AlertDialog f$1;
                private final /* synthetic */ TLObject f$2;
                private final /* synthetic */ BaseFragment f$3;
                private final /* synthetic */ Bundle f$4;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                    this.f$3 = r4;
                    this.f$4 = r5;
                }

                public final void run() {
                    MessagesController.this.lambda$null$292$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4);
                }
            });
        }
    }

    public /* synthetic */ void lambda$null$292$MessagesController(AlertDialog alertDialog, TLObject tLObject, BaseFragment baseFragment, Bundle bundle) {
        try {
            alertDialog.dismiss();
        } catch (Exception e) {
            FileLog.e(e);
        }
        TLRPC.messages_Messages messages_messages = (TLRPC.messages_Messages) tLObject;
        putUsers(messages_messages.users, false);
        putChats(messages_messages.chats, false);
        getMessagesStorage().putUsersAndChats(messages_messages.users, messages_messages.chats, true, true);
        baseFragment.presentFragment(new ChatActivity(bundle), true);
    }

    public /* synthetic */ void lambda$checkCanOpenChat$294$MessagesController(int i, BaseFragment baseFragment, DialogInterface dialogInterface) {
        getConnectionsManager().cancelRequest(i, true);
        if (baseFragment != null) {
            baseFragment.setVisibleDialog(null);
        }
    }

    public static void openChatOrProfileWith(TLRPC.User user, TLRPC.Chat chat, BaseFragment baseFragment, int i, boolean z) {
        if ((user != null || chat != null) && baseFragment != null) {
            String str = null;
            if (chat != null) {
                str = getRestrictionReason(chat.restriction_reason);
            } else if (user != null) {
                str = getRestrictionReason(user.restriction_reason);
                if (user.bot) {
                    i = 1;
                    z = true;
                }
            }
            if (str != null) {
                showCantOpenAlert(baseFragment, str);
                return;
            }
            Bundle bundle = new Bundle();
            if (chat != null) {
                bundle.putInt("chat_id", chat.id);
            } else {
                bundle.putInt("user_id", user.id);
            }
            if (i == 0) {
                baseFragment.presentFragment(new ProfileActivity(bundle));
            } else if (i == 2) {
                baseFragment.presentFragment(new ChatActivity(bundle), true, true);
            } else {
                baseFragment.presentFragment(new ChatActivity(bundle), z);
            }
        }
    }

    public void openByUserName(String str, BaseFragment baseFragment, int i) {
        openByUserName(str, baseFragment, i, false);
    }

    /* JADX WARNING: Removed duplicated region for block: B:14:0x002a  */
    /* JADX WARNING: Removed duplicated region for block: B:15:0x002e  */
    public void openByUserName(String str, BaseFragment baseFragment, int i, boolean z) {
        TLRPC.Chat chat;
        TLRPC.User user;
        if (str != null && baseFragment != null) {
            TLObject userOrChat = getUserOrChat(str);
            if (userOrChat instanceof TLRPC.User) {
                user = (TLRPC.User) userOrChat;
                if (!user.min) {
                    chat = null;
                    if (user != null) {
                        openChatOrProfileWith(user, null, baseFragment, i, z);
                        return;
                    } else if (chat != null) {
                        openChatOrProfileWith(null, chat, baseFragment, 1, z);
                        return;
                    } else if (baseFragment.getParentActivity() != null) {
                        AlertDialog[] alertDialogArr = {new AlertDialog(baseFragment.getParentActivity(), 3)};
                        TLRPC.TL_contacts_resolveUsername tL_contacts_resolveUsername = new TLRPC.TL_contacts_resolveUsername();
                        tL_contacts_resolveUsername.username = str;
                        AndroidUtilities.runOnUIThread(new Runnable(alertDialogArr, getConnectionsManager().sendRequest(tL_contacts_resolveUsername, new RequestDelegate(alertDialogArr, baseFragment, z, i) {
                            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$RHsfUdW8rUh94HLIHNKDD7ajlWA */
                            private final /* synthetic */ AlertDialog[] f$1;
                            private final /* synthetic */ BaseFragment f$2;
                            private final /* synthetic */ boolean f$3;
                            private final /* synthetic */ int f$4;

                            {
                                this.f$1 = r2;
                                this.f$2 = r3;
                                this.f$3 = r4;
                                this.f$4 = r5;
                            }

                            @Override // im.guobwnxjuc.tgnet.RequestDelegate
                            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                                MessagesController.this.lambda$openByUserName$296$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, tLObject, tL_error);
                            }
                        }), baseFragment) {
                            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$HKelu9Ms9xoK2038mL9GGyxrfw */
                            private final /* synthetic */ AlertDialog[] f$1;
                            private final /* synthetic */ int f$2;
                            private final /* synthetic */ BaseFragment f$3;

                            {
                                this.f$1 = r2;
                                this.f$2 = r3;
                                this.f$3 = r4;
                            }

                            public final void run() {
                                MessagesController.this.lambda$openByUserName$298$MessagesController(this.f$1, this.f$2, this.f$3);
                            }
                        }, 500);
                        return;
                    } else {
                        return;
                    }
                }
            } else if (userOrChat instanceof TLRPC.Chat) {
                TLRPC.Chat chat2 = (TLRPC.Chat) userOrChat;
                if (!chat2.min) {
                    chat = chat2;
                    user = null;
                    if (user != null) {
                    }
                }
            }
            user = null;
            chat = null;
            if (user != null) {
            }
        }
    }

    public /* synthetic */ void lambda$openByUserName$296$MessagesController(AlertDialog[] alertDialogArr, BaseFragment baseFragment, boolean z, int i, TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable(alertDialogArr, baseFragment, tL_error, tLObject, z, i) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$8K0cUW5bS3WZVWsOzvQCgTPHlwk */
            private final /* synthetic */ AlertDialog[] f$1;
            private final /* synthetic */ BaseFragment f$2;
            private final /* synthetic */ TLRPC.TL_error f$3;
            private final /* synthetic */ TLObject f$4;
            private final /* synthetic */ boolean f$5;
            private final /* synthetic */ int f$6;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
                this.f$4 = r5;
                this.f$5 = r6;
                this.f$6 = r7;
            }

            public final void run() {
                MessagesController.this.lambda$null$295$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6);
            }
        });
    }

    public /* synthetic */ void lambda$null$295$MessagesController(AlertDialog[] alertDialogArr, BaseFragment baseFragment, TLRPC.TL_error tL_error, TLObject tLObject, boolean z, int i) {
        try {
            alertDialogArr[0].dismiss();
        } catch (Exception unused) {
        }
        alertDialogArr[0] = null;
        baseFragment.setVisibleDialog(null);
        if (tL_error == null) {
            TLRPC.TL_contacts_resolvedPeer tL_contacts_resolvedPeer = (TLRPC.TL_contacts_resolvedPeer) tLObject;
            putUsers(tL_contacts_resolvedPeer.users, false);
            putChats(tL_contacts_resolvedPeer.chats, false);
            getMessagesStorage().putUsersAndChats(tL_contacts_resolvedPeer.users, tL_contacts_resolvedPeer.chats, false, true);
            if (!tL_contacts_resolvedPeer.chats.isEmpty()) {
                openChatOrProfileWith(null, tL_contacts_resolvedPeer.chats.get(0), baseFragment, 1, z);
            } else if (tL_contacts_resolvedPeer.users.isEmpty()) {
            } else {
                if (!tL_contacts_resolvedPeer.users.get(0).contact) {
                    baseFragment.presentFragment(new AddContactsInfoActivity(null, tL_contacts_resolvedPeer.users.get(0)));
                } else {
                    openChatOrProfileWith(tL_contacts_resolvedPeer.users.get(0), null, baseFragment, i, z);
                }
            }
        } else if (baseFragment != null && baseFragment.getParentActivity() != null) {
            if (i == 0) {
                ToastUtils.show((int) R.string.NoUsernameFound);
            } else {
                AlertsCreator.createSimpleAlert(baseFragment.getParentActivity(), LocaleController.getString("JoinToGroupErrorNotExist", R.string.JoinToGroupErrorNotExist)).show();
            }
        }
    }

    public /* synthetic */ void lambda$openByUserName$298$MessagesController(AlertDialog[] alertDialogArr, int i, BaseFragment baseFragment) {
        if (alertDialogArr[0] != null) {
            alertDialogArr[0].setOnCancelListener(new DialogInterface.OnCancelListener(i) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$Diew_nxCxXvp_zXrgDJZT2Es8 */
                private final /* synthetic */ int f$1;

                {
                    this.f$1 = r2;
                }

                public final void onCancel(DialogInterface dialogInterface) {
                    MessagesController.this.lambda$null$297$MessagesController(this.f$1, dialogInterface);
                }
            });
            baseFragment.showDialog(alertDialogArr[0]);
        }
    }

    public /* synthetic */ void lambda$null$297$MessagesController(int i, DialogInterface dialogInterface) {
        getConnectionsManager().cancelRequest(i, true);
    }

    /* JADX WARNING: Removed duplicated region for block: B:19:0x0039  */
    /* JADX WARNING: Removed duplicated region for block: B:52:0x00bf  */
    public void openByUserName(String str, BaseFragment baseFragment, TLRPC.Chat chat, boolean z) {
        TLRPC.Chat chat2;
        TLRPC.User user;
        if (str != null && baseFragment != null) {
            if (!ChatObject.canSendEmbed(chat)) {
                ToastUtils.show((int) R.string.ForbidViewUserAndGroupInfoTips);
                return;
            }
            TLObject userOrChat = getUserOrChat(str);
            if (userOrChat instanceof TLRPC.User) {
                user = (TLRPC.User) userOrChat;
                if (!user.min) {
                    chat2 = null;
                    boolean z2 = false;
                    if (user != null) {
                        if (!user.self && chat != null && !ChatObject.hasAdminRights(chat) && chat.megagroup && (chat.flags & ConnectionsManager.FileTypeVideo) != 0 && !user.mutual_contact) {
                            ToastUtils.show((int) R.string.ForbidViewUserInfoTips);
                            return;
                        } else if (user.contact) {
                            Bundle bundle = new Bundle();
                            bundle.putInt("user_id", user.id);
                            if (chat != null) {
                                if (chat.megagroup && (33554432 & chat.flags) != 0) {
                                    z2 = true;
                                }
                                bundle.putBoolean("forbid_add_contact", z2);
                                bundle.putBoolean("has_admin_right", ChatObject.hasAdminRights(chat));
                            }
                            baseFragment.presentFragment(new NewProfileActivity(bundle));
                            return;
                        } else {
                            Bundle bundle2 = new Bundle();
                            bundle2.putInt("user_id", user.id);
                            if (chat != null) {
                                if (chat.megagroup && (33554432 & chat.flags) != 0) {
                                    z2 = true;
                                }
                                bundle2.putBoolean("forbid_add_contact", z2);
                                bundle2.putBoolean("has_admin_right", ChatObject.hasAdminRights(chat));
                            }
                            bundle2.putInt("from_type", 2);
                            baseFragment.presentFragment(new NewProfileActivity(bundle2));
                            return;
                        }
                    } else if (chat2 != null) {
                        openChatOrProfileWith(null, chat2, baseFragment, 1, z);
                        return;
                    } else if (baseFragment.getParentActivity() != null) {
                        AlertDialog[] alertDialogArr = {new AlertDialog(baseFragment.getParentActivity(), 3)};
                        TLRPC.TL_contacts_resolveUsername tL_contacts_resolveUsername = new TLRPC.TL_contacts_resolveUsername();
                        tL_contacts_resolveUsername.username = str;
                        AndroidUtilities.runOnUIThread(new Runnable(alertDialogArr, getConnectionsManager().sendRequest(tL_contacts_resolveUsername, new RequestDelegate(alertDialogArr, baseFragment, z, chat) {
                            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$g9ujDvs3zIqlkB0q0wrYnTr9noo */
                            private final /* synthetic */ AlertDialog[] f$1;
                            private final /* synthetic */ BaseFragment f$2;
                            private final /* synthetic */ boolean f$3;
                            private final /* synthetic */ TLRPC.Chat f$4;

                            {
                                this.f$1 = r2;
                                this.f$2 = r3;
                                this.f$3 = r4;
                                this.f$4 = r5;
                            }

                            @Override // im.guobwnxjuc.tgnet.RequestDelegate
                            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                                MessagesController.this.lambda$openByUserName$300$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, tLObject, tL_error);
                            }
                        }), baseFragment) {
                            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$x7VkJ9SyuiItyAkZEE0Yg7KLGY */
                            private final /* synthetic */ AlertDialog[] f$1;
                            private final /* synthetic */ int f$2;
                            private final /* synthetic */ BaseFragment f$3;

                            {
                                this.f$1 = r2;
                                this.f$2 = r3;
                                this.f$3 = r4;
                            }

                            public final void run() {
                                MessagesController.this.lambda$openByUserName$302$MessagesController(this.f$1, this.f$2, this.f$3);
                            }
                        }, 500);
                        return;
                    } else {
                        return;
                    }
                }
            } else if (userOrChat instanceof TLRPC.Chat) {
                TLRPC.Chat chat3 = (TLRPC.Chat) userOrChat;
                if (!chat3.min) {
                    chat2 = chat3;
                    user = null;
                    boolean z22 = false;
                    if (user != null) {
                    }
                }
            }
            user = null;
            chat2 = null;
            boolean z222 = false;
            if (user != null) {
            }
        }
    }

    public /* synthetic */ void lambda$openByUserName$300$MessagesController(AlertDialog[] alertDialogArr, BaseFragment baseFragment, boolean z, TLRPC.Chat chat, TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable(alertDialogArr, baseFragment, tL_error, tLObject, z, chat) {
            /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$tMjwvBZ2VzufrGEiCagBzduHkRg */
            private final /* synthetic */ AlertDialog[] f$1;
            private final /* synthetic */ BaseFragment f$2;
            private final /* synthetic */ TLRPC.TL_error f$3;
            private final /* synthetic */ TLObject f$4;
            private final /* synthetic */ boolean f$5;
            private final /* synthetic */ TLRPC.Chat f$6;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
                this.f$4 = r5;
                this.f$5 = r6;
                this.f$6 = r7;
            }

            public final void run() {
                MessagesController.this.lambda$null$299$MessagesController(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, this.f$6);
            }
        });
    }

    public /* synthetic */ void lambda$null$299$MessagesController(AlertDialog[] alertDialogArr, BaseFragment baseFragment, TLRPC.TL_error tL_error, TLObject tLObject, boolean z, TLRPC.Chat chat) {
        boolean z2 = false;
        try {
            alertDialogArr[0].dismiss();
        } catch (Exception unused) {
        }
        alertDialogArr[0] = null;
        baseFragment.setVisibleDialog(null);
        if (tL_error == null) {
            TLRPC.TL_contacts_resolvedPeer tL_contacts_resolvedPeer = (TLRPC.TL_contacts_resolvedPeer) tLObject;
            putUsers(tL_contacts_resolvedPeer.users, false);
            putChats(tL_contacts_resolvedPeer.chats, false);
            getMessagesStorage().putUsersAndChats(tL_contacts_resolvedPeer.users, tL_contacts_resolvedPeer.chats, true, true);
            if (!tL_contacts_resolvedPeer.chats.isEmpty()) {
                openChatOrProfileWith(null, tL_contacts_resolvedPeer.chats.get(0), baseFragment, 1, z);
            } else if (!tL_contacts_resolvedPeer.users.isEmpty()) {
                TLRPC.User user = tL_contacts_resolvedPeer.users.get(0);
                if (user.self || chat == null || ChatObject.hasAdminRights(chat) || !chat.megagroup || (chat.flags & ConnectionsManager.FileTypeVideo) == 0 || user.mutual_contact) {
                    Bundle bundle = new Bundle();
                    bundle.putInt("user_id", user.id);
                    if (chat != null) {
                        if (chat.megagroup && (chat.flags & ConnectionsManager.FileTypeVideo) != 0) {
                            z2 = true;
                        }
                        bundle.putBoolean("forbid_add_contact", z2);
                        bundle.putBoolean("has_admin_right", ChatObject.hasAdminRights(chat));
                    }
                    bundle.putInt("from_type", 2);
                    baseFragment.presentFragment(new NewProfileActivity(bundle));
                    return;
                }
                ToastUtils.show((int) R.string.ForbidViewUserInfoTips);
            }
        } else if (baseFragment != null && baseFragment.getParentActivity() != null) {
            try {
                ToastUtils.show((int) R.string.NoUsernameFound);
            } catch (Exception e) {
                FileLog.e(e);
            }
        }
    }

    public /* synthetic */ void lambda$openByUserName$302$MessagesController(AlertDialog[] alertDialogArr, int i, BaseFragment baseFragment) {
        if (alertDialogArr[0] != null) {
            alertDialogArr[0].setOnCancelListener(new DialogInterface.OnCancelListener(i) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$YASVEZrxAJzd7imoQYNuiWWFNLI */
                private final /* synthetic */ int f$1;

                {
                    this.f$1 = r2;
                }

                public final void onCancel(DialogInterface dialogInterface) {
                    MessagesController.this.lambda$null$301$MessagesController(this.f$1, dialogInterface);
                }
            });
            baseFragment.showDialog(alertDialogArr[0]);
        }
    }

    public /* synthetic */ void lambda$null$301$MessagesController(int i, DialogInterface dialogInterface) {
        getConnectionsManager().cancelRequest(i, true);
    }

    public void saveContactsAppliesId(int i) {
        this.mainPreferences.edit().putInt("contacts_apply_id", i).apply();
    }

    public void saveContactsAppliesDate(int i) {
        this.mainPreferences.edit().putInt("last_contacts_get_diff", i).apply();
    }

    public void saveContactsAppliesHash(long j) {
        this.mainPreferences.edit().putLong("contacts_apply_hash", j).apply();
    }

    public void handleUpdatesContactsApply(int i) {
        if (i <= 0) {
            this.mainPreferences.edit().putInt("contacts_apply_count", 0).apply();
        } else {
            this.mainPreferences.edit().putInt("contacts_apply_count", i).apply();
        }
    }

    public void getContactsApplyDifferenceV2(boolean z, boolean z2) {
        getContactsApplyDifferenceV2(z, false, z2);
    }

    public void getContactsApplyDifferenceV2(boolean z, boolean z2, boolean z3) {
        if (!this.contactsGetDiff) {
            this.contactsGetDiff = true;
            int i = -1;
            int i2 = this.mainPreferences.getInt("contacts_apply_id", -1);
            int i3 = this.mainPreferences.getInt("last_contacts_get_diff", 0);
            long j = 0;
            long j2 = this.mainPreferences.getLong("contacts_apply_hash", 0);
            TLRPCContacts.GetContactAppliesDifferenceV2 getContactAppliesDifferenceV2 = new TLRPCContacts.GetContactAppliesDifferenceV2();
            if (!z) {
                i = i2;
            }
            getContactAppliesDifferenceV2.apply_id = i;
            getContactAppliesDifferenceV2.total_limit = 100;
            getContactAppliesDifferenceV2.date = i3;
            if (!z2) {
                j = j2;
            }
            getContactAppliesDifferenceV2.hash = j;
            getConnectionsManager().sendRequest(getContactAppliesDifferenceV2, new RequestDelegate(z) {
                /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$FH9wC4z65I5BhJEpqi0z2k8YZTc */
                private final /* synthetic */ boolean f$1;

                {
                    this.f$1 = r2;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    MessagesController.this.lambda$getContactsApplyDifferenceV2$306$MessagesController(this.f$1, tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$getContactsApplyDifferenceV2$306$MessagesController(boolean z, TLObject tLObject, TLRPC.TL_error tL_error) {
        this.contactsGetDiff = false;
        if (tL_error == null) {
            TLRPCContacts.ContactsAppiesDifferenceV2 contactsAppiesDifferenceV2 = (TLRPCContacts.ContactsAppiesDifferenceV2) tLObject;
            if (contactsAppiesDifferenceV2 instanceof TLRPCContacts.HC_contacts_apply_notModified) {
                AndroidUtilities.runOnUIThread(new Runnable() {
                    /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$d_Aq65cP1bkphjrhtHXuHj8Zy8 */

                    public final void run() {
                        MessagesController.this.lambda$null$303$MessagesController();
                    }
                });
            } else if (contactsAppiesDifferenceV2 instanceof TLRPCContacts.HC_contacts_apply_differenceSlice_v2) {
                getMessagesController().putUsers(contactsAppiesDifferenceV2.users, false);
                ArrayList arrayList = new ArrayList();
                for (int i = 0; i < contactsAppiesDifferenceV2.otherUpdates.size(); i++) {
                    TLRPC.Update update = contactsAppiesDifferenceV2.otherUpdates.get(i);
                    if (update instanceof TLRPCContacts.UpdateContactApplyRequested) {
                        TLRPCContacts.UpdateContactApplyRequested updateContactApplyRequested = (TLRPCContacts.UpdateContactApplyRequested) update;
                        if (updateContactApplyRequested.apply_info.from_peer.user_id != getUserConfig().clientUserId) {
                            arrayList.add(updateContactApplyRequested.apply_info);
                        }
                    }
                }
                getContactsApplyDifferenceV2(false, true);
                if (BuildVars.LOGS_ENABLED) {
                    FileLog.e("------------> slice response");
                }
                if (arrayList.size() > 0 && BuildVars.LOGS_ENABLED) {
                    FileLog.e("------------> infos.size() :" + arrayList.size());
                }
            } else {
                ArrayList arrayList2 = new ArrayList();
                getMessagesController().putUsers(contactsAppiesDifferenceV2.users, false);
                for (int i2 = 0; i2 < contactsAppiesDifferenceV2.otherUpdates.size(); i2++) {
                    TLRPC.Update update2 = contactsAppiesDifferenceV2.otherUpdates.get(i2);
                    if (update2 instanceof TLRPCContacts.UpdateContactApplyRequested) {
                        TLRPCContacts.UpdateContactApplyRequested updateContactApplyRequested2 = (TLRPCContacts.UpdateContactApplyRequested) update2;
                        if (updateContactApplyRequested2.apply_info.from_peer.user_id != getUserConfig().clientUserId) {
                            arrayList2.add(updateContactApplyRequested2.apply_info);
                        }
                    }
                }
                if (arrayList2.size() > 0) {
                    handleUpdatesContactsApply(contactsAppiesDifferenceV2.state.unread_count);
                    AndroidUtilities.runOnUIThread(new Runnable(contactsAppiesDifferenceV2, arrayList2) {
                        /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$35kqFCZnUqGg9_7tlw1sWg_CGSM */
                        private final /* synthetic */ TLRPCContacts.ContactsAppiesDifferenceV2 f$1;
                        private final /* synthetic */ ArrayList f$2;

                        {
                            this.f$1 = r2;
                            this.f$2 = r3;
                        }

                        public final void run() {
                            MessagesController.this.lambda$null$304$MessagesController(this.f$1, this.f$2);
                        }
                    });
                } else {
                    handleUpdatesContactsApply(contactsAppiesDifferenceV2.state.unread_count);
                    AndroidUtilities.runOnUIThread(new Runnable(contactsAppiesDifferenceV2) {
                        /* class im.guobwnxjuc.messenger.$$Lambda$MessagesController$jvL0eesmkaC0z7WDPh4RgFSubu8 */
                        private final /* synthetic */ TLRPCContacts.ContactsAppiesDifferenceV2 f$1;

                        {
                            this.f$1 = r2;
                        }

                        public final void run() {
                            MessagesController.this.lambda$null$305$MessagesController(this.f$1);
                        }
                    });
                }
                saveContactsAppliesId(contactsAppiesDifferenceV2.state.apply_id);
                saveContactsAppliesHash(contactsAppiesDifferenceV2.hash);
            }
        }
    }

    public /* synthetic */ void lambda$null$303$MessagesController() {
        getNotificationCenter().postNotificationName(NotificationCenter.contactApplyUpdateCount, 0);
    }

    public /* synthetic */ void lambda$null$304$MessagesController(TLRPCContacts.ContactsAppiesDifferenceV2 contactsAppiesDifferenceV2, ArrayList arrayList) {
        getNotificationCenter().postNotificationName(NotificationCenter.contactApplyUpdateCount, Integer.valueOf(contactsAppiesDifferenceV2.state.unread_count));
        getNotificationCenter().postNotificationName(NotificationCenter.contactApplieReceived, arrayList, contactsAppiesDifferenceV2.users);
    }

    public /* synthetic */ void lambda$null$305$MessagesController(TLRPCContacts.ContactsAppiesDifferenceV2 contactsAppiesDifferenceV2) {
        getNotificationCenter().postNotificationName(NotificationCenter.contactApplyUpdateCount, Integer.valueOf(contactsAppiesDifferenceV2.state.unread_count));
    }
}