导航菜单

页面标题

页面副标题

Biko v2.0.23 - ChatActivity.java 源代码

正在查看: Biko v2.0.23 应用的 ChatActivity.java JAVA 源代码文件

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


package app.callpe.ui.chat;

import android.R;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Dialog;
import android.app.NotificationManager;
import android.app.ProgressDialog;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ResolveInfo;
import android.graphics.Bitmap;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.media.MediaPlayer;
import android.media.ThumbnailUtils;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.service.notification.StatusBarNotification;
import android.text.Editable;
import android.text.InputFilter;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.ActionMode;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.view.ActionMode;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.app.ActivityCompat;
import androidx.core.app.ShareCompat;
import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import app.callpe.App;
import app.callpe.adapters.MessageAdapter;
import app.callpe.common.utils.AnimatorHelper;
import app.callpe.common.utils.AudioMediaPlayer;
import app.callpe.common.utils.CenterSmoothScroller;
import app.callpe.common.utils.Constants;
import app.callpe.common.utils.DateHelper;
import app.callpe.common.utils.GroupUtils;
import app.callpe.common.utils.Helper;
import app.callpe.common.utils.ImageHW;
import app.callpe.common.utils.ImageUtils;
import app.callpe.common.utils.InternetSpeedTest;
import app.callpe.common.utils.PermissionHelper;
import app.callpe.common.utils.RxBus;
import app.callpe.common.utils.custom.CustomLinearLayoutManager;
import app.callpe.common.utils.custom.RecyclerSectionItemDecoration;
import app.callpe.common.utils.custom.mediaslider.ImageAndVideoActivity;
import app.callpe.common.utils.file_helper.CompressFile;
import app.callpe.common.utils.file_helper.Files;
import app.callpe.common.utils.helper_functions.AudioRecorder;
import app.callpe.common.utils.helper_functions.DialogHelper;
import app.callpe.common.utils.helper_functions.Result;
import app.callpe.common.utils.helper_functions.SoundManager;
import app.callpe.common.utils.interfaces.TwoWayEndlessAdapter;
import app.callpe.common.utils.popupkeyboardwidget.GridMenuAdapter;
import app.callpe.common.utils.popupkeyboardwidget.MenuEditText;
import app.callpe.common.utils.popupkeyboardwidget.SoftKeyBoardPopup;
import app.callpe.common.utils.sharedpref.PrefKeys;
import app.callpe.common.utils.sharedpref.SharedPref;
import app.callpe.data.model.APIError;
import app.callpe.data.model.BandwidthInfo;
import app.callpe.data.model.DownloadStatus;
import app.callpe.data.model.ErrorHandler;
import app.callpe.data.model.GiftBracketItem;
import app.callpe.data.model.GiftModel;
import app.callpe.data.model.GiftRequestModel;
import app.callpe.data.model.GroupModel;
import app.callpe.data.model.GroupOfflineModel;
import app.callpe.data.model.IntentModel;
import app.callpe.data.model.LoginResponse;
import app.callpe.data.model.Metadata;
import app.callpe.data.model.OnlineFailedErrorModel;
import app.callpe.data.model.ParticipantModel;
import app.callpe.data.model.SuccessModel;
import app.callpe.databinding.ActivityTaskDetailBinding;
import app.callpe.databinding.ChatMessageInputBinding;
import app.callpe.databinding.GiftPopupBinding;
import app.callpe.databinding.GiftReceivedPopupBinding;
import app.callpe.db.LocalDB;
import app.callpe.db.dao.ChatDao;
import app.callpe.db.dao.NotificationDAO;
import app.callpe.service.ApiService;
import app.callpe.service.FirebaseNotificationService;
import app.callpe.service.SyncResponse;
import app.callpe.service.SyncResponseEventType;
import app.callpe.service.SyncRxBus;
import app.callpe.ui.bottomsheet.GiftBottomSheet;
import app.callpe.ui.bottomsheet.StreamerDetailBottomSheet;
import app.callpe.ui.bottomsheet.UserDetailBottomSheet;
import app.callpe.ui.call.CallActivity;
import app.callpe.ui.chat.ChatActivity;
import app.callpe.ui.dialog.RechargeDialog;
import app.callpe.ui.home.BaseActivity;
import app.callpe.ui.home.HomeActivity;
import app.callpe.ui.home.StreamerDetailActivity;
import app.callpe.ui.home.StreamerHomeActivity;
import app.callpe.ui.home.fragments.ChatListFragment;
import app.callpe.ui.home.fragments.SystemChatListFragment;
import app.callpe.ui.login.LoginActivity;
import app.callpe.ui.misc.ImageShowActivity;
import app.callpe.ui.misc.VideoListActivity;
import app.callpe.ui.user.UserDetailsActivity;
import com.abedelazizshe.lightcompressorlibrary.CompressionListener;
import com.abedelazizshe.lightcompressorlibrary.VideoCompressor;
import com.abedelazizshe.lightcompressorlibrary.VideoQuality;
import com.abedelazizshe.lightcompressorlibrary.config.AppSpecificStorageConfiguration;
import com.abedelazizshe.lightcompressorlibrary.config.Configuration;
import com.asynctaskcoffee.audiorecorder.worker.AudioRecordListener;
import com.bumptech.glide.Glide;
import com.devlomi.record_view.OnRecordListener;
import com.devlomi.record_view.RecordButton;
import com.devlomi.record_view.RecordPermissionHandler;
import com.devlomi.record_view.RecordView;
import com.downloader.Error;
import com.downloader.Progress;
import com.facebook.internal.FacebookRequestErrorClassification;
import com.facebook.internal.NativeProtocol;
import com.github.dhaval2404.imagepicker.ImagePicker;
import com.github.dhaval2404.imagepicker.constant.ImageProvider;
import com.github.dhaval2404.imagepicker.listener.DismissListener;
import com.github.dhaval2404.imagepicker.listener.ResultListener;
import com.github.dhaval2404.imagepicker.provider.GalleryProvider;
import com.github.dhaval2404.imagepicker.util.GalleryFile;
import com.google.gson.Gson;
import com.uzairiqbal.circulartimerview.CircularTimerListener;
import com.uzairiqbal.circulartimerview.CircularTimerView;
import com.uzairiqbal.circulartimerview.TimeFormatEnum;
import com.vanniktech.emoji.EmojiPopup;
import in.onato.imageeditor.editor.EditorActivity;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.functions.Consumer;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.inject.Inject;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.functions.Function3;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import timber.log.Timber;

public class ChatActivity extends BaseActivity<ActivityTaskDetailBinding> implements AudioRecordListener, MenuEditText.PopupListener, MessageAdapter.TaskItemAdapterClickListener, SoftKeyBoardPopup.PopMenuClick {
    public static final int CAMERA_PERMISSION = 8002;
    public static final int DOC_CODE = 5000;
    public static final int MEDIA_PERMISSION = 8001;
    public static boolean PrevChatScreen = false;
    public static final int RECORD_PERMISSION = 8000;
    public static final int REQUEST_PERMISSIONS = 200;
    private static final int REQUEST_VIDEO_CAPTURE = 1000;
    private static final long UPDATE_INTERVAL = 1500;
    public static long chatId = -1;
    public static boolean refresh = false;
    private ActionMode actionMode;
    private ActionModeCallback actionModeCallback;
    private Dialog alertDialog;

    @Inject
    ApiService apiService;
    private AudioMediaPlayer audioMediaPlayer;
    private AudioRecorder audioRecorder;

    @Inject
    ChatDao chatDao;
    private RecyclerView chatRecyclerView;
    private GroupViewModel chatViewModel;
    private CompositeDisposable disposable;
    public MenuEditText editText;
    EmojiPopup emojiPopup;
    private LoginResponse loginResponse;
    public SoftKeyBoardPopup menuKeyboard;
    private MessageAdapter messageAdapter;

    @Inject
    NotificationDAO notificationDAO;
    public View parentView;
    private ProgressDialog progressDialog;
    private RecordButton recordButton;
    private File recordFile;
    public ConstraintLayout rootView;

    @Inject
    RxBus rxBus;
    private SoundManager soundManager;
    ChatMessageInputBinding viewMessageInputBinding;
    private String accountId = "";
    private boolean isStreamer = false;
    private boolean isCurrentSender = false;
    private boolean adminOnly = false;
    private String[] permissions = {"android.permission.RECORD_AUDIO", "android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE"};
    private final String[] cameraPermission = {"android.permission.CAMERA", "android.permission.RECORD_AUDIO"};
    boolean permissionAccepted = false;
    private int streamerChatGiftEarningLimit = 0;
    private boolean isVisible = false;
    private String role = Constants.ROLE.STREAMER.name();
    private Long currentPage = -1L;
    private Long bottomPage = -1L;
    private final int PAGE_SIZE = 50;
    private Long searchMessageId = -1L;
    private Long replyId = null;
    private String replyMessage = null;
    private String replyType = null;
    private String name = "";
    private boolean important = false;
    private final ArrayList<GroupModel> chatModelArrayList = new ArrayList<>();
    private final HashMap<Long, Long> idMapper = new HashMap<>();
    private boolean isRecording = false;
    private boolean isForceFinished = false;
    private ConcurrentHashMap<Uri, Float> progressMap = new ConcurrentHashMap<>();
    private AtomicInteger activeCompressions = new AtomicInteger(0);
    private Handler handler = new Handler(Looper.getMainLooper());
    private long lastUpdateTime = 0;
    private final ExecutorService compressionExecutor = Executors.newSingleThreadExecutor();
    private final BroadcastReceiver broadcastReceiver = new AnonymousClass19();

    public interface HandleResult {
        void onResult(File file);
    }

    public Context getContext() {
        return this;
    }

    private void handleForward() {
    }

    static void lambda$cameraResult$41() {
    }

    static void lambda$canCompress$57() {
    }

    static void lambda$chooseAppDialog$31() {
    }

    static void lambda$onClick$16(View view) {
    }

    static void lambda$onClick$17(View view) {
    }

    private void showPlacePicker() {
    }

    @Override
    public void onAudioClick(GroupModel chatModel, int position) {
    }

    @Override
    public void onInfoClick(GroupModel chatModel, int position) {
    }

    @Override
    public void onLocationClick(GroupModel chatModel, int position) {
    }

    @Override
    public void onReadyForRecord() {
    }

    @Override
    public void onRecordFailed(String errorMessage) {
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (Build.VERSION.SDK_INT >= 33) {
            this.permissions = new String[]{"android.permission.READ_MEDIA_IMAGES"};
        } else if (Build.VERSION.SDK_INT >= 30) {
            this.permissions = new String[]{"android.permission.READ_EXTERNAL_STORAGE"};
        } else if (Build.VERSION.SDK_INT == 29) {
            this.permissions = new String[]{"android.permission.READ_EXTERNAL_STORAGE"};
        } else {
            this.permissions = new String[]{"android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE"};
        }
        this.viewMessageInputBinding = ChatMessageInputBinding.bind(((ActivityTaskDetailBinding) this.binding).getRoot());
        chatId = App.chatId;
        refresh = false;
        PrevChatScreen = true;
        if (savedInstanceState != null) {
            chatId = savedInstanceState.getLong("chatId");
            String string = savedInstanceState.getString("taskTitle");
            if (string == null) {
                string = "";
            }
            App.chatTitle = string;
            this.name = savedInstanceState.getString(FacebookRequestErrorClassification.KEY_NAME);
            this.accountId = savedInstanceState.getString("userId");
            this.isCurrentSender = savedInstanceState.getBoolean("isCurrentSender");
            this.adminOnly = savedInstanceState.getBoolean("adminOnly");
            this.important = savedInstanceState.getBoolean("important");
        }
        getUserId();
        Intent intent = getIntent();
        if (intent.hasExtra("notification_clicked") && intent.getBooleanExtra("notification_clicked", false)) {
            long longExtra = intent.getLongExtra("chatId", -1L);
            String stringExtra = intent.getStringExtra("chatName");
            Timber.e("onCreate: ----  int %s", new Object[]{Long.valueOf(longExtra)});
            App.chatTitle = stringExtra;
            if (chatId == longExtra) {
                App.chatId = longExtra;
            } else {
                App.chatId = longExtra;
                finish();
                startActivity(getIntent());
            }
        }
        chatId = App.chatId;
        this.important = App.important;
        if (chatId == -1) {
            onBackPressed();
        }
        App.isChatScreen = true;
        setContentView(((ActivityTaskDetailBinding) this.binding).getRoot());
        this.actionModeCallback = new ActionModeCallback();
        this.chatViewModel = (GroupViewModel) new ViewModelProvider(this).get(GroupViewModel.class);
        long j = chatId;
        if (j != -1) {
            clearNotificationCount(Long.valueOf(j));
        }
        this.rootView = ((ActivityTaskDetailBinding) this.binding).rootView;
        this.parentView = findViewById(R.id.content);
        this.editText = this.viewMessageInputBinding.messageInput;
        this.viewMessageInputBinding.camera.setVisibility(0);
        if (!this.isStreamer) {
            this.viewMessageInputBinding.btnGift.setVisibility(0);
        }
        this.viewMessageInputBinding.emoji.setVisibility(0);
        this.viewMessageInputBinding.messageInput.setLongClickable(false);
        ActionMode.Callback callback = new ActionMode.Callback() {
            @Override
            public boolean onActionItemClicked(android.view.ActionMode mode, MenuItem item) {
                return false;
            }

            @Override
            public boolean onCreateActionMode(android.view.ActionMode mode, Menu menu) {
                return true;
            }

            @Override
            public void onDestroyActionMode(android.view.ActionMode mode) {
            }

            @Override
            public boolean onPrepareActionMode(android.view.ActionMode mode, Menu menu) {
                if (menu == null) {
                    return true;
                }
                menu.removeItem(R.id.paste);
                return true;
            }
        };
        this.viewMessageInputBinding.messageInput.setCustomInsertionActionModeCallback(callback);
        this.viewMessageInputBinding.messageInput.setCustomSelectionActionModeCallback(callback);
        ConstraintLayout constraintLayout = ((ActivityTaskDetailBinding) this.binding).chatLayout;
        this.editText.setPopupListener(this);
        this.menuKeyboard = new SoftKeyBoardPopup(this, this.rootView, this.editText, constraintLayout, this.viewMessageInputBinding.menuChatContainer, this, this);
        try {
            this.emojiPopup = new EmojiPopup(this.rootView, this.editText);
            this.viewMessageInputBinding.messageInput.setFilters(new InputFilter[]{new InputFilter.LengthFilter(200)});
            this.soundManager = new SoundManager(this);
        } catch (Exception e) {
            Timber.e(e);
        }
        this.viewMessageInputBinding.menuChat.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ChatActivity.this.m1010lambda$onCreate$0$appcallpeuichatChatActivity(view);
            }
        });
        handleSearchIntent();
        setRecycler();
        setUpRecordView();
        setProgressDialog();
        getLoginResponse();
        getParticipantResponse();
        if (!App.notificationAvailable) {
            getChatResponse(true ^ this.chatViewModel.fromSearch, false);
        }
        submitChatOnClick();
        onBackClick();
        setToolbar();
        setSwipeToRefresh();
        observerMessageText();
        observeSyncResponse();
        onReplyClose();
        onClick();
        handleForward();
        intent.getStringExtra("intentModel");
    }

    void m1010lambda$onCreate$0$appcallpeuichatChatActivity(View view) {
        toggle();
    }

    private void getUserId() {
        String string = SharedPref.getString(getContext(), PrefKeys.ACCOUNT_ID);
        if (SharedPref.getString(getContext(), PrefKeys.USER_ROLE).equals(Constants.ROLE.STREAMER.name())) {
            this.isStreamer = true;
            this.streamerChatGiftEarningLimit = SharedPref.getInt(this, PrefKeys.CHAT_GIFT_EARNING_LIMIT).intValue();
            this.role = Constants.ROLE.STREAMER.name();
        } else {
            this.role = Constants.ROLE.USER.name();
        }
        this.accountId = string;
    }

    public void handleRechargeAndGiftFlow(ParticipantModel participantModel) {
        if (!this.isStreamer) {
            getBalanceResponse(participantModel);
        }
        getGifts();
        getGiftBrackets();
    }

    private void handleSearchIntent() {
        this.chatViewModel.messageId = Long.valueOf(getIntent().getLongExtra("messageId", -1L));
        if (this.chatViewModel.messageId.longValue() != -1) {
            this.idMapper.put(this.chatViewModel.messageId, this.chatViewModel.messageId);
            this.chatViewModel.fromSearch = true;
            this.searchMessageId = this.chatViewModel.messageId;
            if (getIntent().getStringExtra("query") != null) {
                this.chatViewModel.query = getIntent().getStringExtra("query");
            }
        }
    }

    private void setUpRecordView() {
        RecordView recordView = this.viewMessageInputBinding.recordView;
        if (recordView == null) {
            Timber.e("RecordView is null, cannot set up recording", new Object[0]);
            return;
        }
        recordView.setLessThanSecondAllowed(false);
        RecordButton recordButton = this.viewMessageInputBinding.recordMessageBtn;
        this.recordButton = recordButton;
        recordButton.setRecordView(recordView);
        recordView.setRecordPermissionHandler(new RecordPermissionHandler() {
            public final boolean isPermissionGranted() {
                return ChatActivity.this.m1023lambda$setUpRecordView$1$appcallpeuichatChatActivity();
            }
        });
        recordView.setTimeLimit(60000L);
        recordView.setOnRecordListener(new AnonymousClass2(recordView));
    }

    boolean m1023lambda$setUpRecordView$1$appcallpeuichatChatActivity() {
        if (ContextCompat.checkSelfPermission(this, "android.permission.RECORD_AUDIO") == 0) {
            return true;
        }
        ActivityCompat.requestPermissions(this, new String[]{"android.permission.RECORD_AUDIO"}, 0);
        return false;
    }

    class AnonymousClass2 implements OnRecordListener {
        final RecordView val$recordView;

        public void onLock() {
        }

        AnonymousClass2(final RecordView val$recordView) {
            this.val$recordView = val$recordView;
        }

        public void onStart() {
            try {
                this.val$recordView.setBackground(ContextCompat.getDrawable(ChatActivity.this.getContext(), 2131231768));
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.AnonymousClass2.this.m1044lambda$onStart$0$appcallpeuichatChatActivity$2();
                    }
                }, 300L);
            } catch (Exception e) {
                Toast.makeText((Context) ChatActivity.this, (CharSequence) ("Error: " + e), 0).show();
            }
        }

        void m1044lambda$onStart$0$appcallpeuichatChatActivity$2() {
            String absolutePath = ChatActivity.this.getContext().getExternalFilesDir(null) != null ? ChatActivity.this.getContext().getExternalFilesDir(null).getAbsolutePath() : null;
            if (absolutePath == null) {
                Timber.e("Failed to get external files directory", new Object[0]);
                Toast.makeText((Context) ChatActivity.this, (CharSequence) "Not able to record. Try again later", 0).show();
                return;
            }
            ChatActivity.this.recordFile = new File(absolutePath + "/Recorder_" + UUID.randomUUID().toString() + ".m4a");
            try {
                ChatActivity.this.isRecording = true;
                ChatActivity.this.audioRecorder = new AudioRecorder();
                ChatActivity.this.audioRecorder.start(ChatActivity.this.recordFile.getPath());
            } catch (Exception e) {
                ChatActivity.this.isRecording = false;
                e.printStackTrace();
            }
        }

        public void onCancel() {
            try {
                ChatActivity.this.isRecording = false;
                Handler handler = new Handler();
                final RecordView recordView = this.val$recordView;
                handler.postDelayed(new Runnable() {
                    @Override
                    public final void run() {
                        recordView.setBackground((Drawable) null);
                    }
                }, 500L);
                ChatActivity.this.stopRecording(true);
            } catch (Exception e) {
                Toast.makeText((Context) ChatActivity.this, (CharSequence) ("Error: " + e), 0).show();
            }
        }

        public void onFinish(long recordTime, boolean limitReached) {
            try {
                ChatActivity.this.isRecording = false;
                this.val$recordView.setBackground((Drawable) null);
                Timber.e("record time %s", new Object[]{Long.valueOf(recordTime)});
                ChatActivity.this.stopRecording(false);
                if (ChatActivity.this.isForceFinished) {
                    ChatActivity.this.isForceFinished = false;
                    ChatActivity chatActivity = ChatActivity.this;
                    chatActivity.showStopRecordingLayout(recordTime, chatActivity.recordFile);
                } else if (ChatActivity.this.recordFile != null && !ChatActivity.this.recordFile.getPath().isEmpty()) {
                    ChatActivity chatActivity2 = ChatActivity.this;
                    chatActivity2.submitChatResponse(chatActivity2.recordFile.getPath(), Constants.CHAT_TYPE.AUDIO.name(), recordTime);
                }
            } catch (Exception e) {
                Toast.makeText((Context) ChatActivity.this, (CharSequence) ("Error: " + e), 0).show();
            }
        }

        public void onLessThanSecond() {
            try {
                ChatActivity.this.isRecording = false;
                this.val$recordView.setBackground((Drawable) null);
                Timber.e("Recording was less than a second", new Object[0]);
                ChatActivity.this.stopRecording(true);
            } catch (Exception e) {
                Toast.makeText((Context) ChatActivity.this, (CharSequence) ("Error: " + e), 0).show();
            }
        }
    }

    public void showStopRecordingLayout(final long recordTime, final File recordFile) {
        ((ActivityTaskDetailBinding) this.binding).recordingStopLayout.setVisibility(0);
        ((ActivityTaskDetailBinding) this.binding).audioDuration.setText(DateHelper.formatMilliSecond(recordTime));
        this.audioMediaPlayer = new AudioMediaPlayer(((ActivityTaskDetailBinding) this.binding).audioProgress, ((ActivityTaskDetailBinding) this.binding).btnPlayPause, ((ActivityTaskDetailBinding) this.binding).audioDuration);
        ((ActivityTaskDetailBinding) this.binding).btnPlayPause.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ChatActivity.this.m1025lambda$showStopRecordingLayout$2$appcallpeuichatChatActivity(recordFile, view);
            }
        });
        ((ActivityTaskDetailBinding) this.binding).deleteAudio.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ChatActivity.this.m1026lambda$showStopRecordingLayout$3$appcallpeuichatChatActivity(view);
            }
        });
        ((ActivityTaskDetailBinding) this.binding).sendAudio.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ChatActivity.this.m1027lambda$showStopRecordingLayout$4$appcallpeuichatChatActivity(recordFile, recordTime, view);
            }
        });
    }

    void m1025lambda$showStopRecordingLayout$2$appcallpeuichatChatActivity(File file, View view) {
        AudioMediaPlayer audioMediaPlayer = this.audioMediaPlayer;
        if (audioMediaPlayer != null) {
            MediaPlayer mediaPlayer = audioMediaPlayer.mediaPlayer;
            if (mediaPlayer != null) {
                if (mediaPlayer.isPlaying()) {
                    this.audioMediaPlayer.pauseAudio();
                    return;
                } else {
                    if (file == null || file.getPath().isEmpty()) {
                        return;
                    }
                    this.audioMediaPlayer.playAudioWithUrl(file.getPath());
                    return;
                }
            }
            if (file == null || file.getPath().isEmpty()) {
                return;
            }
            this.audioMediaPlayer.playAudioWithUrl(file.getPath());
        }
    }

    void m1026lambda$showStopRecordingLayout$3$appcallpeuichatChatActivity(View view) {
        ((ActivityTaskDetailBinding) this.binding).recordingStopLayout.setVisibility(8);
        AudioMediaPlayer audioMediaPlayer = this.audioMediaPlayer;
        if (audioMediaPlayer != null) {
            audioMediaPlayer.stopAudio();
            this.audioMediaPlayer.release();
        }
    }

    void m1027lambda$showStopRecordingLayout$4$appcallpeuichatChatActivity(File file, long j, View view) {
        ((ActivityTaskDetailBinding) this.binding).recordingStopLayout.setVisibility(8);
        AudioMediaPlayer audioMediaPlayer = this.audioMediaPlayer;
        if (audioMediaPlayer != null) {
            audioMediaPlayer.stopAudio();
            this.audioMediaPlayer.release();
        }
        if (file == null || file.getPath().isEmpty()) {
            return;
        }
        submitChatResponse(file.getPath(), Constants.CHAT_TYPE.AUDIO.name(), j);
    }

    private void onReplyClose() {
        ((ActivityTaskDetailBinding) this.binding).replyClose.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ChatActivity.this.m1014lambda$onReplyClose$5$appcallpeuichatChatActivity(view);
            }
        });
    }

    void m1014lambda$onReplyClose$5$appcallpeuichatChatActivity(View view) {
        this.replyId = null;
        this.replyMessage = null;
        this.replyType = null;
        AnimatorHelper.collapse(((ActivityTaskDetailBinding) this.binding).replyViewParent);
    }

    private void setRecycler() {
        boolean z = false;
        ((ActivityTaskDetailBinding) this.binding).taskDetailRefreshLayout.setEnabled(false);
        this.chatRecyclerView = ((ActivityTaskDetailBinding) this.binding).taskDetailRecyclerView;
        CustomLinearLayoutManager customLinearLayoutManager = new CustomLinearLayoutManager(this);
        customLinearLayoutManager.setStackFromEnd(!this.chatViewModel.fromSearch);
        ((ActivityTaskDetailBinding) this.binding).taskDetailRecyclerView.setLayoutManager(customLinearLayoutManager);
        this.chatRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                super.onScrollStateChanged(recyclerView, newState);
            }

            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
            }
        });
        this.chatRecyclerView.addItemDecoration(new RecyclerSectionItemDecoration(getResources().getDimensionPixelSize(2131167283), true, new RecyclerSectionItemDecoration.SectionCallback() {
            @Override
            public boolean isSection(int position) {
                try {
                    if (ChatActivity.this.messageAdapter == null) {
                        return false;
                    }
                    if (position != 0) {
                        if (ChatActivity.this.messageAdapter.getUserMessagesList().get(position).getCreationDate().equals(ChatActivity.this.messageAdapter.getUserMessagesList().get(position - 1).getCreationDate())) {
                            return false;
                        }
                    }
                    return true;
                } catch (Exception unused) {
                    return false;
                }
            }

            @Override
            public CharSequence getSectionHeader(int position) {
                try {
                    return ChatActivity.this.messageAdapter == null ? "" : ChatActivity.this.messageAdapter.getUserMessagesList().get(position).getCreationDate().isEmpty() ? DateHelper.chatHeaderDate(DateHelper.getTodayDate(), "yyyy-MM-dd", ChatActivity.this.getContext()) : DateHelper.chatHeaderDate(ChatActivity.this.messageAdapter.getUserMessagesList().get(position).getCreationDate(), "yyyy-MM-dd", ChatActivity.this.getContext());
                } catch (Exception unused) {
                    return "";
                }
            }
        }));
        this.chatRecyclerView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
            @Override
            public final void onLayoutChange(View view, int i, int i2, int i3, int i4, int i5, int i6, int i7, int i8) {
                ChatActivity.this.m1021lambda$setRecycler$7$appcallpeuichatChatActivity(view, i, i2, i3, i4, i5, i6, i7, i8);
            }
        });
        Timber.e("account id %s", new Object[]{this.accountId});
        int intValue = SharedPref.getInt(this, PrefKeys.MESSAGE_UNLOCK_AMOUNT, 10).intValue();
        if (BaseActivity.getAccountId().isEmpty()) {
            Helper.signOut(getContext(), LoginActivity.class);
            return;
        }
        MessageAdapter messageAdapter = new MessageAdapter(new ArrayList(), this, Long.valueOf(BaseActivity.getAccountId()), this);
        this.messageAdapter = messageAdapter;
        messageAdapter.role = this.role;
        this.messageAdapter.allowSelection = true;
        boolean z2 = SharedPref.getBoolean(getContext(), PrefKeys.FIRST_RECHARGE_DONE);
        boolean z3 = SharedPref.getBoolean(getContext(), PrefKeys.UNLOCK_CHAT);
        boolean z4 = SharedPref.getBoolean(getContext(), PrefKeys.LOCK_CHAT_MESSAGES_AFTER_FREE_PERIOD);
        MessageAdapter messageAdapter2 = this.messageAdapter;
        if (z4 && z2 && z3) {
            z = true;
        }
        messageAdapter2.allMessagesLocked = z;
        this.messageAdapter.messageUnlockAmount = intValue;
        this.messageAdapter.setDataContainer(new ArrayList());
        this.messageAdapter.setEndlessCallback(new TwoWayEndlessAdapter.Callback() {
            @Override
            public void onTopReached() {
                ChatActivity.this.addItems(true);
                Timber.e("I am Top", new Object[0]);
            }

            @Override
            public void onBottomReached() {
                if (ChatActivity.this.chatViewModel.fromSearch) {
                    ChatActivity.this.addItems(false);
                }
                Timber.e("I am bottom", new Object[0]);
            }
        });
        this.chatRecyclerView.setAdapter(this.messageAdapter);
    }

    void m1021lambda$setRecycler$7$appcallpeuichatChatActivity(View view, int i, int i2, int i3, int i4, int i5, int i6, int i7, int i8) {
        if (i4 < i8) {
            this.chatRecyclerView.postDelayed(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.m1020lambda$setRecycler$6$appcallpeuichatChatActivity();
                }
            }, 100L);
        }
    }

    void m1020lambda$setRecycler$6$appcallpeuichatChatActivity() {
        try {
            if (isLastVisible()) {
                Timber.e("isLastVisible", new Object[0]);
                if (this.messageAdapter != null) {
                    this.chatRecyclerView.scrollToPosition(r0.getItemCount() - 1);
                }
            }
        } catch (Exception unused) {
        }
    }

    public void addItems(boolean isTop) {
        Timber.i("add items %s", new Object[]{this.currentPage});
        if (isTop) {
            MessageAdapter messageAdapter = this.messageAdapter;
            if ((messageAdapter != null && messageAdapter.getItemCount() == 1) || this.idMapper.containsKey(this.currentPage)) {
                return;
            }
            HashMap<Long, Long> hashMap = this.idMapper;
            Long l = this.currentPage;
            hashMap.put(l, l);
            Timber.i("add items after %s", new Object[]{this.currentPage});
        } else {
            MessageAdapter messageAdapter2 = this.messageAdapter;
            if ((messageAdapter2 != null && messageAdapter2.getItemCount() == 1) || this.idMapper.containsKey(this.bottomPage)) {
                return;
            }
            HashMap<Long, Long> hashMap2 = this.idMapper;
            Long l2 = this.bottomPage;
            hashMap2.put(l2, l2);
        }
        getChatResponse(false, isTop);
    }

    private void setToolbar() {
        try {
            ((ActivityTaskDetailBinding) this.binding).taskDetailToolbar.taskName.setText(App.chatTitle);
            ((ActivityTaskDetailBinding) this.binding).taskDetailToolbar.profile.setVisibility(0);
            ((ActivityTaskDetailBinding) this.binding).taskDetailToolbar.moreIcon.setVisibility(0);
            ((ActivityTaskDetailBinding) this.binding).taskDetailToolbar.callIcon.setVisibility(4);
            Glide.with(getContext()).load(App.profile).error(2131230886).into(((ActivityTaskDetailBinding) this.binding).taskDetailToolbar.profile);
        } catch (Exception e) {
            Timber.e(e);
        }
    }

    private void setSwipeToRefresh() {
        ((ActivityTaskDetailBinding) this.binding).taskDetailRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            public final void onRefresh() {
                ChatActivity.this.m1022lambda$setSwipeToRefresh$8$appcallpeuichatChatActivity();
            }
        });
    }

    void m1022lambda$setSwipeToRefresh$8$appcallpeuichatChatActivity() {
        releasePlayer();
        getChatResponse(true, false);
        ((ActivityTaskDetailBinding) this.binding).taskDetailRefreshLayout.setRefreshing(false);
    }

    public void setProgress(boolean isVisible) {
        if (isVisible) {
            this.viewMessageInputBinding.recordMessageBtn.setEnabled(false);
            ((ActivityTaskDetailBinding) this.binding).taskDetailProgress.setVisibility(0);
        } else {
            this.viewMessageInputBinding.recordMessageBtn.setEnabled(true);
            ((ActivityTaskDetailBinding) this.binding).taskDetailProgress.setVisibility(8);
        }
    }

    private void submitChatOnClick() {
        this.viewMessageInputBinding.recordMessageBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ChatActivity.this.m1028lambda$submitChatOnClick$9$appcallpeuichatChatActivity(view);
            }
        });
    }

    void m1028lambda$submitChatOnClick$9$appcallpeuichatChatActivity(View view) {
        submitChat();
    }

    public void checkInternetSpeedTest() {
        final com.techiness.progressdialoglibrary.ProgressDialog progressDialog = new com.techiness.progressdialoglibrary.ProgressDialog(this);
        progressDialog.setMessage("Checking Network Status...");
        progressDialog.setCancelable(false);
        progressDialog.show();
        BandwidthInfo bandwidthInfo = (BandwidthInfo) new Gson().fromJson(SharedPref.getString(this, PrefKeys.INTERNET_BANDWIDTH_CONFIG), BandwidthInfo.class);
        if (bandwidthInfo == null) {
            m974lambda$checkInternetSpeedTest$11$appcallpeuichatChatActivity();
            progressDialog.dismiss();
        } else if (!bandwidthInfo.getCheckBandwidth()) {
            m974lambda$checkInternetSpeedTest$11$appcallpeuichatChatActivity();
            progressDialog.dismiss();
        } else {
            InternetSpeedTest.INSTANCE.checkSpeed(bandwidthInfo.getSpeedTestDownloadUrl() != null ? bandwidthInfo.getSpeedTestDownloadUrl() : "http://speedtest.tele2.net/1MB.zip", bandwidthInfo.getSpeedTestUploadUrl() != null ? bandwidthInfo.getSpeedTestUploadUrl() : "https://store1.gofile.io/uploadFile", bandwidthInfo.getMinDownloadSpeedInKBps(), bandwidthInfo.getMinUploadSpeedInKBps(), new Function3() {
                public final Object invoke(Object obj, Object obj2, Object obj3) {
                    return ChatActivity.this.m976lambda$checkInternetSpeedTest$13$appcallpeuichatChatActivity(progressDialog, (Boolean) obj, (Double) obj2, (Double) obj3);
                }
            });
        }
    }

    Unit m976lambda$checkInternetSpeedTest$13$appcallpeuichatChatActivity(com.techiness.progressdialoglibrary.ProgressDialog progressDialog, Boolean bool, Double d, Double d2) {
        progressDialog.dismiss();
        if (d.doubleValue() == -1.0d || d2.doubleValue() == -1.0d) {
            runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.m973lambda$checkInternetSpeedTest$10$appcallpeuichatChatActivity();
                }
            });
            return null;
        }
        if (bool.booleanValue()) {
            runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.m974lambda$checkInternetSpeedTest$11$appcallpeuichatChatActivity();
                }
            });
        } else {
            runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.m975lambda$checkInternetSpeedTest$12$appcallpeuichatChatActivity();
                }
            });
        }
        Timber.d("SPEED_TEST: isGoodNetwork: %s, download: %s kbps, upload: %s kbps", new Object[]{bool, d, d2});
        return null;
    }

    void m975lambda$checkInternetSpeedTest$12$appcallpeuichatChatActivity() {
        StreamerHomeActivity.showLowInternetSpeedDialog(this);
    }

    private void onClick() {
        ((ActivityTaskDetailBinding) this.binding).goOnlineBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ChatActivity.this.m996lambda$onClick$14$appcallpeuichatChatActivity(view);
            }
        });
        ((ActivityTaskDetailBinding) this.binding).retryBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ChatActivity.this.m997lambda$onClick$15$appcallpeuichatChatActivity(view);
            }
        });
        ((ActivityTaskDetailBinding) this.binding).taskDetailToolbar.toolbarParent.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ChatActivity.lambda$onClick$16(view);
            }
        });
        ((ActivityTaskDetailBinding) this.binding).recordingBottom.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ChatActivity.lambda$onClick$17(view);
            }
        });
        this.viewMessageInputBinding.camera.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ChatActivity.this.m998lambda$onClick$18$appcallpeuichatChatActivity(view);
            }
        });
        this.viewMessageInputBinding.emoji.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ChatActivity.this.m999lambda$onClick$19$appcallpeuichatChatActivity(view);
            }
        });
        ((ActivityTaskDetailBinding) this.binding).paymentBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ChatActivity.this.m1002lambda$onClick$22$appcallpeuichatChatActivity(view);
            }
        });
        ((ActivityTaskDetailBinding) this.binding).becomePaidUserButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ChatActivity.this.m1005lambda$onClick$25$appcallpeuichatChatActivity(view);
            }
        });
        this.viewMessageInputBinding.btnGift.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ChatActivity.this.m1008lambda$onClick$28$appcallpeuichatChatActivity(view);
            }
        });
        this.viewMessageInputBinding.lockCamera.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ChatActivity.this.m1009lambda$onClick$29$appcallpeuichatChatActivity(view);
            }
        });
    }

    void m996lambda$onClick$14$appcallpeuichatChatActivity(View view) {
        DialogHelper.showReasonDialog((Context) this, "", "Are you sure you want to go Online?", true, new DialogHelper.ConfirmationListener() {
            @Override
            public final void onPositiveClick() {
                ChatActivity.this.checkInternetSpeedTest();
            }
        });
    }

    void m997lambda$onClick$15$appcallpeuichatChatActivity(View view) {
        reset();
        getChatResponse(true, false);
    }

    void m998lambda$onClick$18$appcallpeuichatChatActivity(View view) {
        chooseAppDialog();
    }

    void m999lambda$onClick$19$appcallpeuichatChatActivity(View view) {
        EmojiPopup emojiPopup = this.emojiPopup;
        if (emojiPopup != null) {
            if (emojiPopup.isShowing()) {
                this.emojiPopup.dismiss();
                showEmojiIcon(true);
            } else {
                showEmojiIcon(false);
                this.emojiPopup.show();
            }
        }
    }

    void m1002lambda$onClick$22$appcallpeuichatChatActivity(View view) {
        try {
            boolean z = SharedPref.getBoolean(getContext(), PrefKeys.FIRST_RECHARGE_DONE);
            boolean z2 = SharedPref.getBoolean(getContext(), PrefKeys.UNLOCK_CHAT);
            Integer num = SharedPref.getInt(getContext(), PrefKeys.UNLOCK_CHAT_DAYS);
            String str = null;
            if (z2 && z) {
                str = String.format(getString(2131952500), String.valueOf(num));
            }
            RechargeDialog rechargeDialog = new RechargeDialog(null, this.chatViewModel.balance, this.chatViewModel.profile, str, null, new Function0() {
                public final Object invoke() {
                    return ChatActivity.this.m1000lambda$onClick$20$appcallpeuichatChatActivity();
                }
            }, new Function0() {
                public final Object invoke() {
                    return ChatActivity.this.m1001lambda$onClick$21$appcallpeuichatChatActivity();
                }
            });
            if (rechargeDialog.isVisible()) {
                return;
            }
            rechargeDialog.show(getSupportFragmentManager(), rechargeDialog.getTag());
        } catch (Exception e) {
            Timber.e(e);
        }
    }

    Unit m1000lambda$onClick$20$appcallpeuichatChatActivity() {
        getMetaDataResponse();
        return Unit.INSTANCE;
    }

    Unit m1001lambda$onClick$21$appcallpeuichatChatActivity() {
        getMetaDataResponse();
        return Unit.INSTANCE;
    }

    void m1005lambda$onClick$25$appcallpeuichatChatActivity(View view) {
        try {
            boolean z = SharedPref.getBoolean(getContext(), PrefKeys.FIRST_RECHARGE_DONE);
            boolean z2 = SharedPref.getBoolean(getContext(), PrefKeys.UNLOCK_CHAT);
            Integer num = SharedPref.getInt(getContext(), PrefKeys.UNLOCK_CHAT_DAYS);
            String str = null;
            if (z2 && z) {
                str = String.format(getString(2131952500), String.valueOf(num));
            }
            RechargeDialog rechargeDialog = new RechargeDialog(null, this.chatViewModel.balance, this.chatViewModel.profile, str, null, new Function0() {
                public final Object invoke() {
                    return ChatActivity.this.m1003lambda$onClick$23$appcallpeuichatChatActivity();
                }
            }, new Function0() {
                public final Object invoke() {
                    return ChatActivity.this.m1004lambda$onClick$24$appcallpeuichatChatActivity();
                }
            });
            if (rechargeDialog.isVisible()) {
                return;
            }
            rechargeDialog.show(getSupportFragmentManager(), rechargeDialog.getTag());
        } catch (Exception e) {
            Timber.e(e);
        }
    }

    Unit m1003lambda$onClick$23$appcallpeuichatChatActivity() {
        getMetaDataResponse();
        return Unit.INSTANCE;
    }

    Unit m1004lambda$onClick$24$appcallpeuichatChatActivity() {
        getMetaDataResponse();
        return Unit.INSTANCE;
    }

    void m1008lambda$onClick$28$appcallpeuichatChatActivity(View view) {
        GiftBottomSheet giftBottomSheet = new GiftBottomSheet(App.Companion.getGifts() != null ? App.Companion.getGifts() : new ArrayList(), App.Companion.getGiftBrackets() != null ? App.Companion.getGiftBrackets() : new ArrayList(), this.isStreamer, true, new Function1() {
            public final Object invoke(Object obj) {
                return ChatActivity.this.m1006lambda$onClick$26$appcallpeuichatChatActivity((GiftModel) obj);
            }
        }, new Function1() {
            public final Object invoke(Object obj) {
                return ChatActivity.this.m1007lambda$onClick$27$appcallpeuichatChatActivity((Long) obj);
            }
        });
        if (giftBottomSheet.isVisible()) {
            return;
        }
        giftBottomSheet.show(getSupportFragmentManager(), giftBottomSheet.getTag());
    }

    Unit m1006lambda$onClick$26$appcallpeuichatChatActivity(GiftModel giftModel) {
        sendGift(giftModel);
        return Unit.INSTANCE;
    }

    Unit m1007lambda$onClick$27$appcallpeuichatChatActivity(Long l) {
        requestGift(l);
        return Unit.INSTANCE;
    }

    void m1009lambda$onClick$29$appcallpeuichatChatActivity(View view) {
        chooseAppDialog();
    }

    private void submitChat() {
        if (this.viewMessageInputBinding.messageInput.getText() == null || this.viewMessageInputBinding.messageInput.getText().toString().isEmpty()) {
            return;
        }
        String trim = this.viewMessageInputBinding.messageInput.getText().toString().trim();
        if (TextUtils.isEmpty(trim)) {
            return;
        }
        submitChatResponse(trim, Constants.CHAT_TYPE.TEXT.toString(), 0L);
    }

    private void showGlowButton() {
        if (this.isStreamer) {
            return;
        }
        try {
            RelativeLayout relativeLayout = ((ActivityTaskDetailBinding) this.binding).glowBtnParent;
            ObjectAnimator ofFloat = ObjectAnimator.ofFloat(relativeLayout, "alpha", 1.0f, 0.1f);
            ofFloat.setDuration(1000L);
            ObjectAnimator ofFloat2 = ObjectAnimator.ofFloat(relativeLayout, "alpha", 1.0f, 0.1f);
            ofFloat2.setDuration(1000L);
            final AnimatorSet animatorSet = new AnimatorSet();
            animatorSet.play(ofFloat2).after(ofFloat);
            animatorSet.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    animatorSet.start();
                }
            });
            animatorSet.start();
        } catch (Exception e) {
            Timber.e(e);
        }
    }

    private void chooseAppDialog() {
        com.github.dhaval2404.imagepicker.util.DialogHelper.INSTANCE.showChooseAppDialog(this, new ResultListener() {
            public final void onResult(Object obj) {
                ChatActivity.this.m977lambda$chooseAppDialog$30$appcallpeuichatChatActivity((ImageProvider) obj);
            }
        }, new DismissListener() {
            public final void onDismiss() {
                ChatActivity.lambda$chooseAppDialog$31();
            }
        });
    }

    void m977lambda$chooseAppDialog$30$appcallpeuichatChatActivity(ImageProvider imageProvider) {
        if (imageProvider != null) {
            if (imageProvider == ImageProvider.CAMERA) {
                openCamera();
            } else if (imageProvider == ImageProvider.GALLERY) {
                openGallery();
            }
        }
    }

    public void submitChatResponse(String str, String str2, long j) {
        int i;
        String todayDateWithTime;
        Long valueOf;
        Long valueOf2;
        Long l;
        String str3;
        String str4;
        String str5;
        String str6;
        int i2 = 0;
        i2 = 0;
        i2 = 0;
        try {
        } catch (Exception e) {
            e = e;
            i = i2;
        }
        try {
            if (!str2.equals(Constants.CHAT_TYPE.TEXT.name()) && !str2.equals(Constants.CHAT_TYPE.LOCATION.name())) {
                if (str2.equals(Constants.CHAT_TYPE.IMAGE.name()) || str2.equals(Constants.CHAT_TYPE.VIDEO.name()) || str2.equals(Constants.CHAT_TYPE.AUDIO.name()) || str2.equals(Constants.CHAT_TYPE.DOCUMENT.name())) {
                    Timber.e("file path %s", new Object[]{str});
                    uploadOffline(str, str2, j);
                }
                return;
            }
            this.chatViewModel.addGroupModel(new GroupOfflineModel(str, false, null, todayDateWithTime, valueOf, valueOf2, l, str3, str4, str5, false, null, str6, str2, null, this.role, false, true, UUID.randomUUID().toString(), 0L));
            this.viewMessageInputBinding.messageInput.setText("");
            this.viewMessageInputBinding.messageInput.setHint("Type a message");
            i2 = str6;
            return;
        } catch (Exception e2) {
            e = e2;
            i = 0;
            Timber.e(e, "Error: ", new Object[i]);
            return;
        }
        todayDateWithTime = DateHelper.getTodayDateWithTime("yyyy-MM-dd HH:mm:ss", true);
        valueOf = Long.valueOf(chatId);
        valueOf2 = Long.valueOf(Long.parseLong(this.accountId));
        l = this.replyId;
        str3 = this.replyMessage;
        str4 = this.replyType;
        str5 = this.name;
        str6 = this.name;
    }

    private void deleteMessageResponse(GroupModel model) {
        androidx.appcompat.view.ActionMode actionMode = this.actionMode;
        if (actionMode != null && this.actionModeCallback != null) {
            actionMode.finish();
            this.actionModeCallback.onDestroyActionMode(this.actionMode);
        }
        if (model.isRetry().booleanValue()) {
            this.chatViewModel.deleteMessage(model);
        } else {
            this.apiService.deleteMessage(String.valueOf(model.getId())).enqueue(new Callback<SuccessModel>() {
                public void onResponse(Call<SuccessModel> call, Response<SuccessModel> response) {
                    try {
                        ChatActivity.this.setProgress(false);
                        Timber.d("onResponse: %s", new Object[]{response.raw()});
                        if (response.isSuccessful()) {
                            if (response.body() != null) {
                                ChatActivity.this.setProgress(false);
                                ChatActivity.this.reset();
                                ChatActivity.this.getChatResponse(true, false);
                            }
                        } else {
                            try {
                                APIError parseError = ErrorHandler.parseError(response);
                                Toast.makeText(this, ChatActivity.this.getString(2131952996) + ": " + parseError.getReason(), 0).show();
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    } catch (Exception unused) {
                    }
                }

                public void onFailure(Call<SuccessModel> call, Throwable t) {
                    ChatActivity.this.setProgress(false);
                    Timber.e("onFailure: %s", new Object[]{t.getMessage()});
                    Helper.noNetworkToast(this, t);
                }
            });
        }
    }

    public void getChatResponse(final boolean canScroll, final boolean isTop) {
        Timber.d("getChatResponse: task id %s", new Object[]{Long.valueOf(chatId)});
        setProgress(true);
        ((ActivityTaskDetailBinding) this.binding).retryParent.setVisibility(8);
        if (chatId == -1) {
            onBackPressed();
        }
        this.chatViewModel.getChatList(this.accountId, this.role, String.valueOf(chatId), isTop ? this.currentPage : this.bottomPage, 50, "CHAT").observe(this, new Observer() {
            public final void onChanged(Object obj) {
                ChatActivity.this.m980lambda$getChatResponse$32$appcallpeuichatChatActivity(canScroll, isTop, (Result) obj);
            }
        });
    }

    void m980lambda$getChatResponse$32$appcallpeuichatChatActivity(boolean z, boolean z2, Result result) {
        if (result instanceof Result.Success) {
            ((ActivityTaskDetailBinding) this.binding).retryParent.setVisibility(8);
            setProgress(false);
            List list = (List) ((Result.Success) result).data;
            if (list == null || list.isEmpty()) {
                return;
            }
            if (this.chatViewModel.fromSearch) {
                if (this.currentPage.longValue() != -1) {
                    Timber.i("Page Current %s", new Object[]{this.currentPage});
                    Timber.i("Page Current Id %s", new Object[]{((GroupModel) list.get(list.size() - 1)).getId()});
                    this.currentPage = Long.valueOf(Math.min(((GroupModel) list.get(list.size() - 1)).getId().longValue(), this.currentPage.longValue()));
                } else {
                    this.currentPage = ((GroupModel) list.get(list.size() - 1)).getId();
                }
                Timber.i("Page Top %s", new Object[]{this.currentPage});
                Timber.i("Page Bottom %s", new Object[]{this.bottomPage});
                Timber.i("can scroll %s", new Object[]{Boolean.valueOf(z)});
            } else {
                this.currentPage = ((GroupModel) list.get(list.size() - 1)).getId();
            }
            Timber.i("current page %s", new Object[]{this.currentPage});
            this.chatModelArrayList.clear();
            this.chatModelArrayList.addAll(list);
            Collections.reverse(this.chatModelArrayList);
            MessageAdapter messageAdapter = this.messageAdapter;
            if (messageAdapter != null) {
                if (z2) {
                    messageAdapter.addItemsAtTop(this.chatModelArrayList);
                } else {
                    messageAdapter.addItemsAtBottom(this.chatModelArrayList);
                }
                this.messageAdapter.addAll(this.chatModelArrayList);
                if (this.chatViewModel.groupMessage != null) {
                    this.messageAdapter.addItem(this.chatViewModel.groupMessage);
                    this.chatViewModel.groupMessage = null;
                    this.chatRecyclerView.scrollToPosition(this.chatModelArrayList.size() - 1);
                }
            }
            try {
                if (this.searchMessageId.longValue() != -1) {
                    scrollAndHighlightBackground(this.searchMessageId.longValue());
                    this.searchMessageId = -1L;
                } else if (z) {
                    this.chatRecyclerView.scrollToPosition(this.chatModelArrayList.size() - 1);
                }
                return;
            } catch (Exception unused) {
                return;
            }
        }
        if (result instanceof Result.Error) {
            try {
                ((ActivityTaskDetailBinding) this.binding).retryParent.setVisibility(8);
                setProgress(false);
                Toast.makeText((Context) this, (CharSequence) ("" + ((Result.Error) result).exception), 0).show();
                return;
            } catch (Exception e) {
                Timber.e(e);
                return;
            }
        }
        if (result instanceof Result.Retry) {
            try {
                setProgress(false);
                ((ActivityTaskDetailBinding) this.binding).retryParent.setVisibility(0);
                Toast.makeText((Context) this, (CharSequence) ("" + ((Result.Retry) result).exception), 0).show();
                return;
            } catch (Exception e2) {
                Timber.e(e2);
                return;
            }
        }
        if (result instanceof Result.Failure) {
            try {
                ((ActivityTaskDetailBinding) this.binding).retryParent.setVisibility(8);
                setProgress(false);
                Toast.makeText((Context) this, (CharSequence) ("" + ((Result.Failure) result).failure.getMessage()), 0).show();
            } catch (Exception e3) {
                Timber.e(e3);
            }
        }
    }

    public void notifyCall() {
        Call<ArrayList<GroupModel>> userChatMessageList = this.apiService.getUserChatMessageList(String.valueOf(chatId), -1L, 1);
        if (this.isStreamer) {
            userChatMessageList = this.apiService.getStreamerChatMessageList(String.valueOf(chatId), -1L, 1);
        }
        userChatMessageList.enqueue(new Callback<ArrayList<GroupModel>>() {
            public void onFailure(Call<ArrayList<GroupModel>> call, Throwable t) {
            }

            public void onResponse(Call<ArrayList<GroupModel>> call, Response<ArrayList<GroupModel>> response) {
                Timber.e("onResponse: notifyCall %s", new Object[]{response.raw()});
            }
        });
    }

    class AnonymousClass9 implements Callback<ParticipantModel> {
        public void onFailure(Call<ParticipantModel> call, Throwable t) {
        }

        AnonymousClass9() {
        }

        public void onResponse(Call<ParticipantModel> call, final Response<ParticipantModel> response) {
            Timber.e("onResponse: Participant Response %s", new Object[]{response.raw()});
            try {
                if (!response.isSuccessful() || response.body() == null) {
                    return;
                }
                ChatActivity.this.important = ((ParticipantModel) response.body()).getImportant();
                ChatActivity.this.handleRechargeAndGiftFlow((ParticipantModel) response.body());
                if (!ChatActivity.this.isStreamer) {
                    ((ActivityTaskDetailBinding) ChatActivity.this.binding).taskDetailToolbar.taskName.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public final void onClick(View view) {
                            ChatActivity.AnonymousClass9.this.m1045lambda$onResponse$0$appcallpeuichatChatActivity$9(response, view);
                        }
                    });
                    ((ActivityTaskDetailBinding) ChatActivity.this.binding).taskDetailToolbar.profile.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public final void onClick(View view) {
                            ChatActivity.AnonymousClass9.this.m1046lambda$onResponse$1$appcallpeuichatChatActivity$9(response, view);
                        }
                    });
                    ChatActivity.this.chatViewModel.userId = Long.valueOf(((ParticipantModel) response.body()).getStreamerId());
                    ChatActivity.this.chatViewModel.senderPic = ((ParticipantModel) response.body()).getUserDetails().getAvatar();
                    ((ActivityTaskDetailBinding) ChatActivity.this.binding).taskDetailToolbar.userStatus.setVisibility(0);
                    SharedPref.getBoolean(ChatActivity.this.getContext(), PrefKeys.FIRST_RECHARGE_DONE);
                    if (!LoginActivity.isVitok() && !App.getStatusApiPingEnabled()) {
                        ((ActivityTaskDetailBinding) ChatActivity.this.binding).taskDetailToolbar.userStatus.setText(ChatActivity.this.getString(2131952384));
                    } else if (((ParticipantModel) response.body()).getStreamerDetails().getBusy()) {
                        ((ActivityTaskDetailBinding) ChatActivity.this.binding).taskDetailToolbar.userStatus.setText(ChatActivity.this.getString(2131951753));
                    } else if (((ParticipantModel) response.body()).getStreamerDetails().getOnline()) {
                        ((ActivityTaskDetailBinding) ChatActivity.this.binding).taskDetailToolbar.userStatus.setText(ChatActivity.this.getString(2131952384));
                    } else {
                        ((ActivityTaskDetailBinding) ChatActivity.this.binding).taskDetailToolbar.userStatus.setText(ChatActivity.this.getString(2131952376));
                    }
                    if (((ParticipantModel) response.body()).getUserDetails().getLevelName() != null && Integer.parseInt(((ParticipantModel) response.body()).getUserDetails().getLevelName()) > 0) {
                        ChatActivity.this.viewMessageInputBinding.btnGift.setVisibility(0);
                    } else {
                        ChatActivity.this.viewMessageInputBinding.btnGift.setVisibility(8);
                    }
                    ChatActivity.this.chatViewModel.profile = ((ParticipantModel) response.body()).getStreamerDetails().getProfile(false);
                    Glide.with(ChatActivity.this.getApplicationContext()).load(((ParticipantModel) response.body()).getStreamerDetails().getProfile(false)).error(2131230886).into(((ActivityTaskDetailBinding) ChatActivity.this.binding).taskDetailToolbar.profile);
                    ((ActivityTaskDetailBinding) ChatActivity.this.binding).taskDetailToolbar.moreIcon.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public final void onClick(View view) {
                            ChatActivity.AnonymousClass9.this.m1053lambda$onResponse$5$appcallpeuichatChatActivity$9(response, view);
                        }
                    });
                    return;
                }
                ((ActivityTaskDetailBinding) ChatActivity.this.binding).taskDetailToolbar.toolbarParent.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public final void onClick(View view) {
                        ChatActivity.AnonymousClass9.this.m1054lambda$onResponse$6$appcallpeuichatChatActivity$9(response, view);
                    }
                });
                ChatActivity.this.chatViewModel.senderPic = ((ParticipantModel) response.body()).getStreamerDetails().getProfile(false);
                ChatActivity.this.chatViewModel.userId = Long.valueOf(((ParticipantModel) response.body()).getUserId());
                ((ActivityTaskDetailBinding) ChatActivity.this.binding).taskDetailToolbar.userStatus.setVisibility(0);
                Glide.with(ChatActivity.this.getApplicationContext()).load(((ParticipantModel) response.body()).getUserDetails().getAvatar()).error(2131230886).into(((ActivityTaskDetailBinding) ChatActivity.this.binding).taskDetailToolbar.profile);
                if (((ParticipantModel) response.body()).getStreamerDetails().getOnline()) {
                    ((ActivityTaskDetailBinding) ChatActivity.this.binding).chatLayout.setVisibility(0);
                    ((ActivityTaskDetailBinding) ChatActivity.this.binding).goOnlineLayout.setVisibility(8);
                } else {
                    ((ActivityTaskDetailBinding) ChatActivity.this.binding).chatLayout.setVisibility(8);
                    if (LoginActivity.isVitok()) {
                        ((ActivityTaskDetailBinding) ChatActivity.this.binding).goOnlineLayout.setVisibility(0);
                    }
                }
                SharedPref.getBoolean(ChatActivity.this.getContext(), PrefKeys.FIRST_RECHARGE_DONE);
                if (!LoginActivity.isVitok() && !App.getStatusApiPingEnabled()) {
                    ((ActivityTaskDetailBinding) ChatActivity.this.binding).taskDetailToolbar.userStatus.setText(ChatActivity.this.getString(2131952384));
                } else if (((ParticipantModel) response.body()).getUserDetails().getBusy()) {
                    ((ActivityTaskDetailBinding) ChatActivity.this.binding).taskDetailToolbar.userStatus.setText(ChatActivity.this.getString(2131951753));
                } else if (((ParticipantModel) response.body()).getUserDetails().getOnline()) {
                    ((ActivityTaskDetailBinding) ChatActivity.this.binding).taskDetailToolbar.userStatus.setText(ChatActivity.this.getString(2131952384));
                } else {
                    ((ActivityTaskDetailBinding) ChatActivity.this.binding).taskDetailToolbar.userStatus.setText(ChatActivity.this.getString(2131952376));
                }
                if (((ParticipantModel) response.body()).getUserDetails().getLevelName() != null) {
                    app.callpe.common.utils.TextUtils.setTruncatedText(((ActivityTaskDetailBinding) ChatActivity.this.binding).taskDetailToolbar.taskName, App.chatTitle, 12);
                    String str = "Lvl " + ((ParticipantModel) response.body()).getUserDetails().getLevelName();
                    ((ActivityTaskDetailBinding) ChatActivity.this.binding).taskDetailToolbar.levelParent.setVisibility(0);
                    ((ActivityTaskDetailBinding) ChatActivity.this.binding).taskDetailToolbar.userLevel.setText(str);
                } else {
                    ((ActivityTaskDetailBinding) ChatActivity.this.binding).taskDetailToolbar.levelParent.setVisibility(8);
                }
                ((ActivityTaskDetailBinding) ChatActivity.this.binding).taskDetailToolbar.moreIcon.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public final void onClick(View view) {
                        ChatActivity.AnonymousClass9.this.m1048lambda$onResponse$11$appcallpeuichatChatActivity$9(response, view);
                    }
                });
                ((ActivityTaskDetailBinding) ChatActivity.this.binding).taskDetailToolbar.callIcon.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public final void onClick(View view) {
                        ChatActivity.AnonymousClass9.this.m1049lambda$onResponse$12$appcallpeuichatChatActivity$9(response, view);
                    }
                });
                if (((ParticipantModel) response.body()).getStreamerDetails().getStreamerEarningFromThisUser() > ChatActivity.this.streamerChatGiftEarningLimit) {
                    ChatActivity.this.viewMessageInputBinding.btnGift.setVisibility(0);
                } else {
                    ChatActivity.this.viewMessageInputBinding.btnGift.setVisibility(8);
                }
            } catch (Exception e) {
                Toast.makeText((Context) ChatActivity.this, (CharSequence) ("Erro " + e.getMessage()), 0).show();
            }
        }

        void m1045lambda$onResponse$0$appcallpeuichatChatActivity$9(Response response, View view) {
            if (ChatActivity.this.isStreamer) {
                return;
            }
            Intent intent = new Intent(ChatActivity.this.getContext(), (Class<?>) StreamerDetailActivity.class);
            intent.putExtra("id", ((ParticipantModel) response.body()).getStreamerId());
            ChatActivity.this.startActivity(intent);
        }

        void m1046lambda$onResponse$1$appcallpeuichatChatActivity$9(Response response, View view) {
            if (ChatActivity.this.isStreamer) {
                return;
            }
            Intent intent = new Intent(ChatActivity.this.getContext(), (Class<?>) StreamerDetailActivity.class);
            intent.putExtra("id", ((ParticipantModel) response.body()).getStreamerId());
            ChatActivity.this.startActivity(intent);
        }

        void m1053lambda$onResponse$5$appcallpeuichatChatActivity$9(Response response, View view) {
            StreamerDetailBottomSheet streamerDetailBottomSheet = new StreamerDetailBottomSheet(((ParticipantModel) response.body()).getStreamerDetails(), new Function0() {
                public final Object invoke() {
                    return ChatActivity.AnonymousClass9.this.m1050lambda$onResponse$2$appcallpeuichatChatActivity$9();
                }
            }, new Function0() {
                public final Object invoke() {
                    return ChatActivity.AnonymousClass9.this.m1051lambda$onResponse$3$appcallpeuichatChatActivity$9();
                }
            }, new Function0() {
                public final Object invoke() {
                    return ChatActivity.AnonymousClass9.this.m1052lambda$onResponse$4$appcallpeuichatChatActivity$9();
                }
            });
            if (streamerDetailBottomSheet.isVisible()) {
                return;
            }
            streamerDetailBottomSheet.show(ChatActivity.this.getSupportFragmentManager(), streamerDetailBottomSheet.getTag());
        }

        Unit m1050lambda$onResponse$2$appcallpeuichatChatActivity$9() {
            ChatActivity.this.getParticipantResponse();
            return Unit.INSTANCE;
        }

        Unit m1051lambda$onResponse$3$appcallpeuichatChatActivity$9() {
            ChatActivity.this.onBackPressed();
            return Unit.INSTANCE;
        }

        Unit m1052lambda$onResponse$4$appcallpeuichatChatActivity$9() {
            StreamerDetailActivity.INSTANCE.setRefresh(true);
            ChatActivity.this.onBackPressed();
            return Unit.INSTANCE;
        }

        void m1054lambda$onResponse$6$appcallpeuichatChatActivity$9(Response response, View view) {
            if (ChatActivity.this.isStreamer) {
                Intent intent = new Intent(ChatActivity.this.getContext(), (Class<?>) UserDetailsActivity.class);
                intent.putExtra("userId", ((ParticipantModel) response.body()).getUserId());
                ChatActivity.this.startActivity(intent);
            }
        }

        void m1048lambda$onResponse$11$appcallpeuichatChatActivity$9(Response response, View view) {
            UserDetailBottomSheet userDetailBottomSheet = new UserDetailBottomSheet(((ParticipantModel) response.body()).getUserDetails(), ChatActivity.this.important, new Function0() {
                public final Object invoke() {
                    return ChatActivity.AnonymousClass9.this.m1055lambda$onResponse$7$appcallpeuichatChatActivity$9();
                }
            }, new Function0() {
                public final Object invoke() {
                    return ChatActivity.AnonymousClass9.this.m1056lambda$onResponse$8$appcallpeuichatChatActivity$9();
                }
            }, new Function0() {
                public final Object invoke() {
                    return ChatActivity.AnonymousClass9.this.m1057lambda$onResponse$9$appcallpeuichatChatActivity$9();
                }
            }, new Function0() {
                public final Object invoke() {
                    return ChatActivity.AnonymousClass9.this.m1047lambda$onResponse$10$appcallpeuichatChatActivity$9();
                }
            });
            if (userDetailBottomSheet.isVisible()) {
                return;
            }
            userDetailBottomSheet.show(ChatActivity.this.getSupportFragmentManager(), userDetailBottomSheet.getTag());
        }

        Unit m1055lambda$onResponse$7$appcallpeuichatChatActivity$9() {
            ChatActivity.this.getParticipantResponse();
            return Unit.INSTANCE;
        }

        Unit m1056lambda$onResponse$8$appcallpeuichatChatActivity$9() {
            ChatActivity.this.onBackPressed();
            return Unit.INSTANCE;
        }

        Unit m1057lambda$onResponse$9$appcallpeuichatChatActivity$9() {
            ChatListFragment.refreshScreen = true;
            SystemChatListFragment.refreshScreen = true;
            StrangerChatListActivity.setRefreshScreen(true);
            ChatActivity chatActivity = ChatActivity.this;
            chatActivity.important = true ^ chatActivity.important;
            return Unit.INSTANCE;
        }

        Unit m1047lambda$onResponse$10$appcallpeuichatChatActivity$9() {
            UserDetailsActivity.INSTANCE.setResume(true);
            ChatActivity.this.onBackPressed();
            return Unit.INSTANCE;
        }

        void m1049lambda$onResponse$12$appcallpeuichatChatActivity$9(Response response, View view) {
            CallActivity.INSTANCE.userCall(ChatActivity.this, ((ParticipantModel) response.body()).getUserId(), ((ParticipantModel) response.body()).getUserPic(), ((ParticipantModel) response.body()).getUserName(), Constants.ROLE.STREAMER);
        }
    }

    public void getParticipantResponse() {
        this.apiService.getParticipants(String.valueOf(chatId)).enqueue(new AnonymousClass9());
    }

    public void getMetaDataResponse() {
        this.apiService.getMetaData().enqueue(new Callback<Metadata>() {
            public void onFailure(Call<Metadata> call, Throwable t) {
            }

            public void onResponse(Call<Metadata> call, Response<Metadata> response) {
                Timber.e("onResponse: Participant Response %s", new Object[]{response.raw()});
                if (!response.isSuccessful() || response.body() == null) {
                    return;
                }
                SharedPref.setBoolean(ChatActivity.this, PrefKeys.UNLOCK_CHAT, ((Metadata) response.body()).getChatLocked());
                if (((Metadata) response.body()).getAppDetails() != null) {
                    SharedPref.setBoolean(ChatActivity.this, PrefKeys.LOCK_CHAT_MESSAGES_AFTER_FREE_PERIOD, ((Metadata) response.body()).getAppDetails().getLockChatMessagesAfterFreePeriod());
                }
                SharedPref.setInt(ChatActivity.this, PrefKeys.UNLOCK_CHAT_DAYS, ((Metadata) response.body()).getFreeChatDays());
                ChatActivity.this.getParticipantResponse();
                ChatActivity.this.resetFreeChatOverLayoutAndRv();
            }
        });
    }

    public void m974lambda$checkInternetSpeedTest$11$appcallpeuichatChatActivity() {
        ((ActivityTaskDetailBinding) this.binding).taskDetailProgress.setVisibility(0);
        ((ActivityTaskDetailBinding) this.binding).goOnlineBtn.setClickable(false);
        this.apiService.goOnlineFromChatScreen().enqueue(new AnonymousClass11(this));
    }

    class AnonymousClass11 implements Callback<SuccessModel> {
        final Context val$context;

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

        public void onResponse(Call<SuccessModel> call, Response<SuccessModel> response) {
            int intValue;
            ((ActivityTaskDetailBinding) ChatActivity.this.binding).taskDetailProgress.setVisibility(8);
            if (response.isSuccessful()) {
                StreamerHomeActivity.setUserOnline(true);
                StreamerHomeActivity.setUserOffline(false);
                ((ActivityTaskDetailBinding) ChatActivity.this.binding).chatLayout.setVisibility(0);
                ((ActivityTaskDetailBinding) ChatActivity.this.binding).goOnlineLayout.setVisibility(8);
                return;
            }
            try {
                APIError parseError = ErrorHandler.parseError(response);
                if (parseError.getReason().equals("UNWATCHED_VIDEOS")) {
                    StreamerHomeActivity.showAlert(ChatActivity.this, new DialogInterface.OnClickListener() {
                        @Override
                        public final void onClick(DialogInterface dialogInterface, int i) {
                            ChatActivity.AnonymousClass11.this.m1029lambda$onResponse$0$appcallpeuichatChatActivity$11(dialogInterface, i);
                        }
                    });
                } else if (parseError.getReason().contains("PENDING_MEDIA")) {
                    if (parseError.getReason().equals("PENDING_MEDIA")) {
                        StreamerHomeActivity.showPendingMediaUploadAlert(ChatActivity.this, "Please add at least 3 pics or videos in profile to go online\n\nकृपया ऑनलाइन होने के लिए प्रोफ़ाइल में कम से कम 3 तस्वीरें या वीडियो जोड़ें", new DialogInterface.OnClickListener() {
                            @Override
                            public final void onClick(DialogInterface dialogInterface, int i) {
                                ChatActivity.AnonymousClass11.this.m1030lambda$onResponse$1$appcallpeuichatChatActivity$11(dialogInterface, i);
                            }
                        });
                    } else {
                        try {
                            OnlineFailedErrorModel onlineFailedErrorModel = (OnlineFailedErrorModel) new Gson().fromJson(parseError.getReason(), OnlineFailedErrorModel.class);
                            if (onlineFailedErrorModel != null && onlineFailedErrorModel.getData() != null && onlineFailedErrorModel.getData().getMediaCountRequired() != null && (intValue = onlineFailedErrorModel.getData().getMediaCountRequired().intValue()) > 0) {
                                StreamerHomeActivity.showPendingMediaUploadAlert(ChatActivity.this, "Please add " + intValue + " more pics or videos in profile to go online\n\nकृपया ऑनलाइन होने के लिए प्रोफ़ाइल में " + intValue + " और तस्वीरें या वीडियो जोड़ें", new DialogInterface.OnClickListener() {
                                    @Override
                                    public final void onClick(DialogInterface dialogInterface, int i) {
                                        ChatActivity.AnonymousClass11.this.m1031lambda$onResponse$2$appcallpeuichatChatActivity$11(dialogInterface, i);
                                    }
                                });
                            }
                        } catch (Exception e) {
                            Timber.e("Error: Error parsing json: %s", new Object[]{e.getMessage()});
                        }
                    }
                } else {
                    Toast.makeText(this.val$context, ChatActivity.this.getString(2131952996) + ": " + parseError.getReason(), 0).show();
                }
                ((ActivityTaskDetailBinding) ChatActivity.this.binding).goOnlineBtn.setClickable(true);
            } catch (Exception e2) {
                e2.printStackTrace();
            }
        }

        void m1029lambda$onResponse$0$appcallpeuichatChatActivity$11(DialogInterface dialogInterface, int i) {
            Intent intent = new Intent((Context) ChatActivity.this, (Class<?>) VideoListActivity.class);
            intent.putExtra("unwatched", true);
            ChatActivity.this.startActivity(intent);
        }

        void m1030lambda$onResponse$1$appcallpeuichatChatActivity$11(DialogInterface dialogInterface, int i) {
            ChatActivity.this.startActivity(new Intent((Context) ChatActivity.this, (Class<?>) ImageAndVideoActivity.class));
        }

        void m1031lambda$onResponse$2$appcallpeuichatChatActivity$11(DialogInterface dialogInterface, int i) {
            ChatActivity.this.startActivity(new Intent((Context) ChatActivity.this, (Class<?>) ImageAndVideoActivity.class));
        }

        public void onFailure(Call<SuccessModel> call, Throwable t) {
            Helper.noNetworkToast(this.val$context, t);
            StreamerHomeActivity.setUserOnline(false);
            StreamerHomeActivity.setUserOffline(true);
            ((ActivityTaskDetailBinding) ChatActivity.this.binding).taskDetailProgress.setVisibility(8);
            ((ActivityTaskDetailBinding) ChatActivity.this.binding).goOnlineBtn.setClickable(true);
        }
    }

    private void getBalanceResponse(ParticipantModel participantModel) {
        boolean z = SharedPref.getBoolean(getContext(), PrefKeys.FIRST_RECHARGE_DONE);
        boolean z2 = SharedPref.getBoolean(getContext(), PrefKeys.UNLOCK_CHAT);
        boolean z3 = SharedPref.getBoolean(getContext(), PrefKeys.LOCK_CHAT_MESSAGES_AFTER_FREE_PERIOD);
        if (z3 && z && z2) {
            ((ActivityTaskDetailBinding) this.binding).rechargeToActivateFreeChat.setVisibility(0);
            ((ActivityTaskDetailBinding) this.binding).paymentLayout.setVisibility(8);
            ((ActivityTaskDetailBinding) this.binding).chatLayout.setVisibility(8);
            ((ActivityTaskDetailBinding) this.binding).taskDetailRecyclerView.setPadding(0, 0, 0, Helper.dpToPx(this, 160.0f));
            return;
        }
        if (z3 && z) {
            ((ActivityTaskDetailBinding) this.binding).rechargeToActivateFreeChat.setVisibility(0);
            ((ActivityTaskDetailBinding) this.binding).paymentLayout.setVisibility(8);
            ((ActivityTaskDetailBinding) this.binding).chatLayout.setVisibility(8);
            ((ActivityTaskDetailBinding) this.binding).taskDetailRecyclerView.setPadding(0, 0, 0, Helper.dpToPx(this, 160.0f));
            return;
        }
        if (z2 && z) {
            ((ActivityTaskDetailBinding) this.binding).paymentLayout.setVisibility(0);
            ((ActivityTaskDetailBinding) this.binding).icLock.setVisibility(0);
            ((ActivityTaskDetailBinding) this.binding).chatLayout.setVisibility(8);
            ((ActivityTaskDetailBinding) this.binding).rechargeToActivateFreeChat.setVisibility(8);
            ((ActivityTaskDetailBinding) this.binding).paymentBtn.setText("Recharge to unlock chat");
            showGlowButton();
            ((ActivityTaskDetailBinding) this.binding).taskDetailRecyclerView.setPadding(0, 0, 0, Helper.dpToPx(this, 140.0f));
            return;
        }
        if (z) {
            ((ActivityTaskDetailBinding) this.binding).rechargeToActivateFreeChat.setVisibility(8);
            ((ActivityTaskDetailBinding) this.binding).paymentLayout.setVisibility(8);
            ((ActivityTaskDetailBinding) this.binding).icLock.setVisibility(8);
            ((ActivityTaskDetailBinding) this.binding).taskDetailRecyclerView.setPadding(0, 0, 0, Helper.dpToPx(this, 0.0f));
            ((ActivityTaskDetailBinding) this.binding).chatLayout.setVisibility(0);
            return;
        }
        ((ActivityTaskDetailBinding) this.binding).rechargeToActivateFreeChat.setVisibility(8);
        ((ActivityTaskDetailBinding) this.binding).paymentLayout.setVisibility(0);
        ((ActivityTaskDetailBinding) this.binding).icLock.setVisibility(0);
        ((ActivityTaskDetailBinding) this.binding).chatLayout.setVisibility(8);
        if (LoginActivity.isNewUIApp()) {
            ((ActivityTaskDetailBinding) this.binding).paymentBtn.setText("Recharge to send unlimited messages");
        }
        showGlowButton();
        ((ActivityTaskDetailBinding) this.binding).taskDetailRecyclerView.setPadding(0, 0, 0, Helper.dpToPx(this, 140.0f));
    }

    private void getGifts() {
        if (App.Companion.getGifts() == null || App.Companion.getGifts().isEmpty()) {
            this.apiService.getGiftListForChat().enqueue(new Callback<ArrayList<GiftModel>>() {
                public void onFailure(Call<ArrayList<GiftModel>> call, Throwable t) {
                }

                public void onResponse(Call<ArrayList<GiftModel>> call, Response<ArrayList<GiftModel>> response) {
                    Timber.e("onResponse: Balance Response %s", new Object[]{response.raw()});
                    if (!response.isSuccessful() || response.body() == null) {
                        return;
                    }
                    if (App.Companion.getGifts() != null) {
                        App.Companion.getGifts().clear();
                    }
                    App.Companion.setGifts((ArrayList) response.body());
                }
            });
        }
    }

    private void getGiftBrackets() {
        if (App.Companion.getGiftBrackets() == null || App.Companion.getGiftBrackets().isEmpty()) {
            this.apiService.getGiftBracketsListForChat().enqueue(new Callback<ArrayList<GiftBracketItem>>() {
                public void onFailure(Call<ArrayList<GiftBracketItem>> call, Throwable t) {
                }

                public void onResponse(Call<ArrayList<GiftBracketItem>> call, Response<ArrayList<GiftBracketItem>> response) {
                    Timber.e("onResponse: Balance Response %s", new Object[]{response.raw()});
                    if (!response.isSuccessful() || response.body() == null) {
                        return;
                    }
                    if (App.Companion.getGiftBrackets() != null) {
                        App.Companion.getGiftBrackets().clear();
                    }
                    App.Companion.setGiftBrackets((ArrayList) response.body());
                }
            });
        }
    }

    class AnonymousClass14 implements Callback<SuccessModel> {
        final Context val$context;
        final GiftModel val$giftModel;

        AnonymousClass14(final GiftModel val$giftModel, final Context val$context) {
            this.val$giftModel = val$giftModel;
            this.val$context = val$context;
        }

        public void onResponse(Call<SuccessModel> call, Response<SuccessModel> response) {
            try {
                ChatActivity.this.setProgress(false);
                Timber.d("onResponse: %s", new Object[]{response.raw()});
                if (response.isSuccessful()) {
                    if (response.body() != null) {
                        if (((SuccessModel) response.body()).getReason() != null && Objects.equals(((SuccessModel) response.body()).getReason(), "lowBalance")) {
                            try {
                                RechargeDialog rechargeDialog = new RechargeDialog(null, null, ChatActivity.this.chatViewModel.profile, String.format(ChatActivity.this.getString(2131952501).replace("₹", ChatActivity.this.replaceWithSign()), String.valueOf(this.val$giftModel.getAmount())), null, new Function0() {
                                    public final Object invoke() {
                                        return ChatActivity.AnonymousClass14.this.m1032lambda$onResponse$0$appcallpeuichatChatActivity$14();
                                    }
                                }, new Function0() {
                                    public final Object invoke() {
                                        return ChatActivity.AnonymousClass14.this.m1033lambda$onResponse$1$appcallpeuichatChatActivity$14();
                                    }
                                });
                                if (rechargeDialog.isVisible()) {
                                    return;
                                } else {
                                    rechargeDialog.show(ChatActivity.this.getSupportFragmentManager(), rechargeDialog.getTag());
                                }
                            } catch (Exception e) {
                                Timber.e(e);
                            }
                        } else {
                            ?? r11 = ChatActivity.this;
                            Toast.makeText((Context) r11, r11.getString(2131952102), 0).show();
                            ChatActivity.this.reset();
                            ChatActivity.this.getChatResponse(true, false);
                        }
                    }
                }
                try {
                    APIError parseError = ErrorHandler.parseError(response);
                    Toast.makeText(this.val$context, ChatActivity.this.getString(2131952996) + ": " + parseError.getReason(), 0).show();
                } catch (Exception e2) {
                    e2.printStackTrace();
                }
            } catch (Exception unused) {
            }
        }

        Unit m1032lambda$onResponse$0$appcallpeuichatChatActivity$14() {
            ChatActivity.this.getParticipantResponse();
            return Unit.INSTANCE;
        }

        Unit m1033lambda$onResponse$1$appcallpeuichatChatActivity$14() {
            ChatActivity.this.getMetaDataResponse();
            return Unit.INSTANCE;
        }

        public void onFailure(Call<SuccessModel> call, Throwable t) {
            ChatActivity.this.setProgress(false);
            Timber.e("onFailure: %s", new Object[]{t.getMessage()});
            Helper.noNetworkToast(this.val$context, t);
        }
    }

    private void sendGift(GiftModel giftModel) {
        this.apiService.sendGiftForChat(chatId, giftModel.getId(), giftModel.getCount()).enqueue(new AnonymousClass14(giftModel, this));
    }

    public CharSequence replaceWithSign() {
        return App.getUseRupeeSign() ? "₹" : App.getTalktimeCurrencySign();
    }

    class AnonymousClass15 implements Callback<SuccessModel> {
        final Context val$context;
        final GiftModel val$giftModel;

        AnonymousClass15(final GiftModel val$giftModel, final Context val$context) {
            this.val$giftModel = val$giftModel;
            this.val$context = val$context;
        }

        public void onResponse(Call<SuccessModel> call, Response<SuccessModel> response) {
            try {
                ChatActivity.this.setProgress(false);
                Timber.d("onResponse: %s", new Object[]{response.raw()});
                if (response.isSuccessful()) {
                    if (response.body() != null) {
                        if (((SuccessModel) response.body()).getReason() != null && Objects.equals(((SuccessModel) response.body()).getReason(), "lowBalance")) {
                            try {
                                RechargeDialog rechargeDialog = new RechargeDialog(null, null, ChatActivity.this.chatViewModel.profile, String.format(ChatActivity.this.getString(2131952501).replace("₹", ChatActivity.this.replaceWithSign()), String.valueOf(this.val$giftModel.getAmount())), null, new Function0() {
                                    public final Object invoke() {
                                        return ChatActivity.AnonymousClass15.this.m1034lambda$onResponse$0$appcallpeuichatChatActivity$15();
                                    }
                                }, new Function0() {
                                    public final Object invoke() {
                                        return ChatActivity.AnonymousClass15.this.m1035lambda$onResponse$1$appcallpeuichatChatActivity$15();
                                    }
                                });
                                if (rechargeDialog.isVisible()) {
                                    return;
                                } else {
                                    rechargeDialog.show(ChatActivity.this.getSupportFragmentManager(), rechargeDialog.getTag());
                                }
                            } catch (Exception e) {
                                Timber.e(e);
                            }
                        } else {
                            StrangerChatListActivity.setRefreshScreen(true);
                            ?? r11 = ChatActivity.this;
                            Toast.makeText((Context) r11, r11.getString(2131952102), 0).show();
                            ChatActivity.this.reset();
                            ChatActivity.this.getChatResponse(true, false);
                        }
                    }
                }
                try {
                    APIError parseError = ErrorHandler.parseError(response);
                    Toast.makeText(this.val$context, ChatActivity.this.getString(2131952996) + ": " + parseError.getReason(), 0).show();
                } catch (Exception e2) {
                    e2.printStackTrace();
                }
            } catch (Exception unused) {
            }
        }

        Unit m1034lambda$onResponse$0$appcallpeuichatChatActivity$15() {
            ChatActivity.this.getParticipantResponse();
            return Unit.INSTANCE;
        }

        Unit m1035lambda$onResponse$1$appcallpeuichatChatActivity$15() {
            ChatActivity.this.getMetaDataResponse();
            return Unit.INSTANCE;
        }

        public void onFailure(Call<SuccessModel> call, Throwable t) {
            ChatActivity.this.setProgress(false);
            Timber.e("onFailure: %s", new Object[]{t.getMessage()});
            Helper.noNetworkToast(this.val$context, t);
        }
    }

    public void m1011lambda$onGiftSent$54$appcallpeuichatChatActivity(GiftModel giftModel, Long messageId) {
        this.apiService.sendGiftForChatWithMessageId(messageId.longValue()).enqueue(new AnonymousClass15(giftModel, this));
    }

    class AnonymousClass16 implements Callback<SuccessModel> {
        final Context val$context;

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

        public void onResponse(Call<SuccessModel> call, Response<SuccessModel> response) {
            try {
                ChatActivity.this.setProgress(false);
                Timber.d("onResponse: %s", new Object[]{response.raw()});
                if (response.isSuccessful()) {
                    if (response.body() != null) {
                        if (((SuccessModel) response.body()).getReason() != null && Objects.equals(((SuccessModel) response.body()).getReason(), "lowBalance")) {
                            try {
                                if (ChatActivity.this.messageAdapter == null) {
                                    return;
                                }
                                RechargeDialog rechargeDialog = new RechargeDialog(null, null, ChatActivity.this.chatViewModel.profile, String.format(ChatActivity.this.getString(2131952502), String.valueOf(ChatActivity.this.messageAdapter.messageUnlockAmount)), null, new Function0() {
                                    public final Object invoke() {
                                        return ChatActivity.AnonymousClass16.this.m1036lambda$onResponse$0$appcallpeuichatChatActivity$16();
                                    }
                                }, new Function0() {
                                    public final Object invoke() {
                                        return ChatActivity.AnonymousClass16.this.m1037lambda$onResponse$1$appcallpeuichatChatActivity$16();
                                    }
                                });
                                if (rechargeDialog.isVisible()) {
                                    return;
                                } else {
                                    rechargeDialog.show(ChatActivity.this.getSupportFragmentManager(), rechargeDialog.getTag());
                                }
                            } catch (Exception e) {
                                Timber.e(e);
                            }
                        } else {
                            StrangerChatListActivity.setRefreshScreen(true);
                            Toast.makeText((Context) ChatActivity.this, (CharSequence) "Photo unlocked", 0).show();
                            ChatActivity.this.reset();
                            ChatActivity.this.getChatResponse(true, false);
                        }
                    }
                }
                try {
                    APIError parseError = ErrorHandler.parseError(response);
                    Toast.makeText(this.val$context, ChatActivity.this.getString(2131952996) + ": " + parseError.getReason(), 0).show();
                } catch (Exception e2) {
                    e2.printStackTrace();
                }
            } catch (Exception unused) {
            }
        }

        Unit m1036lambda$onResponse$0$appcallpeuichatChatActivity$16() {
            ChatActivity.this.getParticipantResponse();
            return Unit.INSTANCE;
        }

        Unit m1037lambda$onResponse$1$appcallpeuichatChatActivity$16() {
            ChatActivity.this.getMetaDataResponse();
            return Unit.INSTANCE;
        }

        public void onFailure(Call<SuccessModel> call, Throwable t) {
            ChatActivity.this.setProgress(false);
            Timber.e("onFailure: %s", new Object[]{t.getMessage()});
            Helper.noNetworkToast(this.val$context, t);
        }
    }

    private void unlockPhoto(Long messageId) {
        this.apiService.unlockImage(messageId.longValue()).enqueue(new AnonymousClass16(this));
    }

    private void requestGift(Long giftId) {
        this.apiService.requestGiftForChat(chatId, giftId.longValue()).enqueue(new Callback<SuccessModel>() {
            public void onResponse(Call<SuccessModel> call, Response<SuccessModel> response) {
                try {
                    ChatActivity.this.setProgress(false);
                    Timber.d("onResponse: %s", new Object[]{response.raw()});
                    if (response.isSuccessful()) {
                        StrangerChatListActivity.setRefreshScreen(true);
                        ChatActivity.this.reset();
                        ChatActivity.this.getChatResponse(true, false);
                    } else {
                        try {
                            APIError parseError = ErrorHandler.parseError(response);
                            Toast.makeText(this, ChatActivity.this.getString(2131952996) + ": " + parseError.getReason(), 0).show();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                } catch (Exception unused) {
                }
            }

            public void onFailure(Call<SuccessModel> call, Throwable t) {
                ChatActivity.this.setProgress(false);
                Timber.e("onFailure: %s", new Object[]{t.getMessage()});
                Helper.noNetworkToast(this, t);
            }
        });
    }

    private void uploadOffline(String filePath, String type, long recordTime) {
        GroupOfflineModel groupOfflineModel;
        FileOutputStream fileOutputStream;
        if (type.equals(Constants.CHAT_TYPE.VIDEO.name())) {
            Bitmap createVideoThumbnail = ThumbnailUtils.createVideoThumbnail(filePath, 1);
            String str = getContext().getExternalFilesDir(Environment.DIRECTORY_DCIM) + "/video_" + System.currentTimeMillis() + ".jpg";
            Timber.e("uploadImage: bitmap file %s", new Object[]{str});
            try {
                fileOutputStream = new FileOutputStream(str);
            } catch (Exception e) {
                e.printStackTrace();
            }
            try {
                createVideoThumbnail.compress(Bitmap.CompressFormat.JPEG, 90, fileOutputStream);
                fileOutputStream.close();
                this.chatViewModel.addGroupModel(new GroupOfflineModel(filePath, false, null, DateHelper.getTodayDateWithTime("yyyy-MM-dd HH:mm:ss", true), Long.valueOf(chatId), Long.valueOf(Long.parseLong(this.accountId)), this.replyId, this.replyMessage, this.replyType, this.name, false, null, this.name, type, str, this.role, false, true, UUID.randomUUID().toString(), Long.valueOf(recordTime)));
            } finally {
            }
        } else {
            GroupOfflineModel groupOfflineModel2 = new GroupOfflineModel(filePath, false, null, DateHelper.getTodayDateWithTime("yyyy-MM-dd HH:mm:ss", true), Long.valueOf(chatId), Long.valueOf(Long.parseLong(this.accountId)), this.replyId, this.replyMessage, this.replyType, this.name, false, null, this.name, type, null, this.role, false, true, UUID.randomUUID().toString(), Long.valueOf(recordTime / 1000));
            if (type.equals(Constants.CHAT_TYPE.DOCUMENT.name())) {
                try {
                    if (filePath.contains(".pdf")) {
                        String convertBitmapToFile = Helper.convertBitmapToFile(filePath, getContext());
                        if (convertBitmapToFile != null) {
                            groupOfflineModel = groupOfflineModel2;
                            try {
                                groupOfflineModel.setThumbnail(convertBitmapToFile);
                                groupOfflineModel.setFileName(new File(filePath).getName());
                            } catch (Exception e2) {
                                e = e2;
                                Timber.e(e);
                                this.chatViewModel.addGroupModel(groupOfflineModel);
                            }
                        }
                    }
                    groupOfflineModel = groupOfflineModel2;
                    groupOfflineModel.setFileName(new File(filePath).getName());
                } catch (Exception e3) {
                    e = e3;
                    groupOfflineModel = groupOfflineModel2;
                }
            } else {
                groupOfflineModel = groupOfflineModel2;
                if (type.equals(Constants.CHAT_TYPE.IMAGE.name())) {
                    try {
                        ImageHW imageHeightWidth = ImageUtils.INSTANCE.getImageHeightWidth(new File(filePath), 260.0f, 320.0f);
                        Integer valueOf = Integer.valueOf(imageHeightWidth.getHeight());
                        groupOfflineModel.setWidth(Integer.valueOf(imageHeightWidth.getWidth()));
                        groupOfflineModel.setHeight(valueOf);
                        if (this.isStreamer && this.chatViewModel.isLockedImage) {
                            groupOfflineModel.setMessageType(Constants.CHAT_TYPE.LOCKED_IMAGE.name());
                            this.chatViewModel.isLockedImage = false;
                        }
                    } catch (Exception e4) {
                        Timber.e(e4);
                    }
                } else if (type.equals("AUDIO")) {
                    groupOfflineModel.setSenderPic(this.chatViewModel.senderPic);
                }
            }
            this.chatViewModel.addGroupModel(groupOfflineModel);
        }
    }

    private void compression(final Uri uri) {
        try {
            this.activeCompressions.incrementAndGet();
            final Context context = getContext();
            runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.showProgressDialog();
                }
            });
            final List singletonList = Collections.singletonList(uri);
            final List list = (List) singletonList.stream().map(new Function() {
                @Override
                public final Object apply(Object obj) {
                    return ChatActivity.lambda$compression$33((Uri) obj);
                }
            }).collect(Collectors.toList());
            new Thread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.m979lambda$compression$34$appcallpeuichatChatActivity(context, singletonList, list, uri);
                }
            }).start();
        } catch (Exception unused) {
            Toast.makeText((Context) this, (CharSequence) "Something went wrong try again later.", 1).show();
        }
    }

    static String lambda$compression$33(Uri uri) {
        if (uri.getLastPathSegment() != null) {
            return uri.getLastPathSegment();
        }
        return "video_" + System.currentTimeMillis() + ".mp4";
    }

    void m979lambda$compression$34$appcallpeuichatChatActivity(Context context, List list, List list2, Uri uri) {
        VideoCompressor.start(context, list, false, null, new AppSpecificStorageConfiguration("media"), new Configuration(VideoQuality.LOW, false, null, false, false, null, null, list2), new AnonymousClass18(uri, context));
    }

    class AnonymousClass18 implements CompressionListener {
        final Context val$context;
        final Uri val$uri;

        static void lambda$onSuccess$0() {
        }

        @Override
        public void onStart(int index) {
        }

        AnonymousClass18(final Uri val$uri, final Context val$context) {
            this.val$uri = val$uri;
            this.val$context = val$context;
        }

        @Override
        public void onSuccess(int index, long size, final String path) {
            ChatActivity chatActivity = ChatActivity.this;
            final Uri uri = this.val$uri;
            final Context context = this.val$context;
            chatActivity.runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.AnonymousClass18.this.m1041lambda$onSuccess$1$appcallpeuichatChatActivity$18(path, uri, context);
                }
            });
        }

        void m1041lambda$onSuccess$1$appcallpeuichatChatActivity$18(String str, Uri uri, Context context) {
            Timber.e("onSuccess: %s", new Object[]{str});
            ChatActivity.this.progressMap.put(uri, Float.valueOf(100.0f));
            if (!Helper.isFileGreaterThan(new File(str), 5)) {
                ChatActivity.this.submitChatResponse(str, Constants.CHAT_TYPE.VIDEO.name(), Helper.getVideoDuration(context, uri));
            } else {
                DialogHelper.showReasonDialog(context, ChatActivity.this.getString(2131952988), ChatActivity.this.getString(2131952253), new DialogHelper.ConfirmationListener() {
                    @Override
                    public final void onPositiveClick() {
                        ChatActivity.AnonymousClass18.lambda$onSuccess$0();
                    }
                });
            }
            ChatActivity.this.checkAndDismissProgressDialog();
        }

        @Override
        public void onFailure(int index, String failureMessage) {
            Timber.e("onFailure: %s", new Object[]{failureMessage});
            ChatActivity chatActivity = ChatActivity.this;
            final Uri uri = this.val$uri;
            chatActivity.runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.AnonymousClass18.this.m1039lambda$onFailure$2$appcallpeuichatChatActivity$18(uri);
                }
            });
        }

        void m1039lambda$onFailure$2$appcallpeuichatChatActivity$18(Uri uri) {
            ChatActivity.this.progressMap.remove(uri);
            ChatActivity.this.checkAndDismissProgressDialog();
        }

        @Override
        public void onProgress(int index, float progressPercent) {
            ChatActivity.this.progressMap.put(this.val$uri, Float.valueOf(progressPercent));
            long currentTimeMillis = System.currentTimeMillis();
            if (currentTimeMillis - ChatActivity.this.lastUpdateTime >= ChatActivity.UPDATE_INTERVAL) {
                ChatActivity.this.lastUpdateTime = currentTimeMillis;
                ChatActivity.this.handler.post(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.AnonymousClass18.this.m1040lambda$onProgress$3$appcallpeuichatChatActivity$18();
                    }
                });
            }
        }

        void m1040lambda$onProgress$3$appcallpeuichatChatActivity$18() {
            float calculateAverageProgress = ChatActivity.this.calculateAverageProgress();
            Timber.e("run: progressPercent %s", new Object[]{Float.valueOf(calculateAverageProgress)});
            ChatActivity.this.progressDialogPercent(calculateAverageProgress);
        }

        @Override
        public void onCancelled(int index) {
            ChatActivity chatActivity = ChatActivity.this;
            final Uri uri = this.val$uri;
            chatActivity.runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.AnonymousClass18.this.m1038lambda$onCancelled$4$appcallpeuichatChatActivity$18(uri);
                }
            });
        }

        void m1038lambda$onCancelled$4$appcallpeuichatChatActivity$18(Uri uri) {
            ChatActivity.this.progressMap.remove(uri);
            ChatActivity.this.checkAndDismissProgressDialog();
        }
    }

    public void checkAndDismissProgressDialog() {
        Timber.d("active compressions: %s", new Object[]{this.activeCompressions});
        if (this.activeCompressions.decrementAndGet() == 0) {
            hideProgressDialog();
        }
    }

    public float calculateAverageProgress() {
        Iterator<Float> it = this.progressMap.values().iterator();
        int i = 0;
        float f = 0.0f;
        while (it.hasNext()) {
            f += it.next().floatValue();
            i++;
        }
        if (i == 0) {
            return 0.0f;
        }
        return f / i;
    }

    private void onBackClick() {
        ((ActivityTaskDetailBinding) this.binding).taskDetailToolbar.goBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ChatActivity.this.m995lambda$onBackClick$35$appcallpeuichatChatActivity(view);
            }
        });
    }

    void m995lambda$onBackClick$35$appcallpeuichatChatActivity(View view) {
        onBackPressed();
    }

    private void getLoginResponse() {
        LoginResponse loginResponse = (LoginResponse) new Gson().fromJson(SharedPref.getString(this, PrefKeys.LOGIN_RESPONSE), LoginResponse.class);
        this.loginResponse = loginResponse;
        if (loginResponse == null) {
            return;
        }
        String name = loginResponse.getName();
        this.name = name;
        if (name == null) {
            this.name = "";
        }
    }

    private void toggle() {
        if (this.menuKeyboard.isShowing()) {
            this.menuKeyboard.dismiss();
        } else {
            this.menuKeyboard.show();
        }
    }

    private void setProgressDialog() {
        ProgressDialog progressDialog = new ProgressDialog(this);
        this.progressDialog = progressDialog;
        progressDialog.setTitle(getString(2131953045));
        this.progressDialog.setCancelable(false);
    }

    private void showProgressDialog(boolean isVisible) {
        if (isVisible) {
            ProgressDialog progressDialog = this.progressDialog;
            if (progressDialog != null) {
                progressDialog.show();
                return;
            }
            return;
        }
        ProgressDialog progressDialog2 = this.progressDialog;
        if (progressDialog2 != null) {
            progressDialog2.dismiss();
        }
    }

    private void showDownloadProgressDialog() {
        ProgressDialog progressDialog = new ProgressDialog(this);
        this.progressDialog = progressDialog;
        progressDialog.setTitle(getString(2131951964));
        this.progressDialog.setProgressStyle(1);
        this.progressDialog.setCancelable(false);
        this.progressDialog.setIndeterminate(false);
        this.progressDialog.setMax(100);
        this.progressDialog.setProgress(0);
        if (this.progressDialog.isShowing()) {
            return;
        }
        this.progressDialog.show();
    }

    public void showProgressDialog() {
        ProgressDialog progressDialog = this.progressDialog;
        if (progressDialog == null || !progressDialog.isShowing()) {
            ProgressDialog progressDialog2 = new ProgressDialog(this);
            this.progressDialog = progressDialog2;
            progressDialog2.setTitle(getString(2131951907));
            this.progressDialog.setProgressStyle(1);
            this.progressDialog.setCancelable(false);
            this.progressDialog.setIndeterminate(false);
            this.progressDialog.setMax(100);
            this.progressDialog.setProgress(0);
            this.progressDialog.show();
        }
    }

    public void progressDialogPercent(float progress) {
        ProgressDialog progressDialog = this.progressDialog;
        if (progressDialog == null || !progressDialog.isShowing()) {
            return;
        }
        this.progressDialog.setProgress((int) progress);
    }

    private void hideProgressDialog() {
        ProgressDialog progressDialog = this.progressDialog;
        if (progressDialog == null || !progressDialog.isShowing()) {
            return;
        }
        this.progressDialog.dismiss();
        setProgressDialog();
    }

    private void openGallery() {
        if (!PermissionHelper.permissionArrayGranted(this, this.permissions)) {
            ActivityCompat.requestPermissions(this, this.permissions, 200);
            return;
        }
        String[] strArr = {"video/*", "image/*"};
        if (this.isStreamer && this.chatViewModel.isLockedImage) {
            strArr = new String[]{"image/*"};
        }
        ImagePicker.Companion.with(this).galleryOnly().allowMultiple().galleryMimeTypes(strArr).start(new Function2() {
            public final Object invoke(Object obj, Object obj2) {
                return ChatActivity.this.m1018lambda$openGallery$38$appcallpeuichatChatActivity((Integer) obj, (Intent) obj2);
            }
        });
    }

    Unit m1018lambda$openGallery$38$appcallpeuichatChatActivity(Integer num, Intent intent) {
        if (num.intValue() == -1) {
            ArrayList<GalleryFile> parcelableArrayListExtra = intent.getParcelableArrayListExtra("extra.file_path");
            Timber.i("galleryFiles: %s", new Object[]{parcelableArrayListExtra});
            if (parcelableArrayListExtra != null && !parcelableArrayListExtra.isEmpty()) {
                for (GalleryFile galleryFile : parcelableArrayListExtra) {
                    Timber.i("GalleryFile: %s", new Object[]{galleryFile.getPath()});
                    Timber.i("GalleryFile: %s", new Object[]{galleryFile.getType()});
                    if (galleryFile.getType().equals(GalleryProvider.FILETYPE.IMAGE)) {
                        Intent intent2 = new Intent();
                        intent2.setData(Uri.fromFile(new File(galleryFile.getPath())));
                        intent2.putExtra("uri", Uri.fromFile(new File(galleryFile.getPath())));
                        imageData(intent2);
                    } else {
                        final Uri parse = Uri.parse(galleryFile.getPath());
                        this.compressionExecutor.submit(new Runnable() {
                            @Override
                            public final void run() {
                                ChatActivity.this.m1017lambda$openGallery$37$appcallpeuichatChatActivity(parse);
                            }
                        });
                    }
                }
            } else if (intent.getData() != null && intent.getData() != null) {
                imageData(intent);
            }
        }
        return Unit.INSTANCE;
    }

    void m1017lambda$openGallery$37$appcallpeuichatChatActivity(Uri uri) {
        try {
            canCompress(uri);
        } catch (Exception e) {
            runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.m1016lambda$openGallery$36$appcallpeuichatChatActivity(e);
                }
            });
        }
    }

    void m1016lambda$openGallery$36$appcallpeuichatChatActivity(Exception exc) {
        Toast.makeText(getContext(), "Error " + exc, 0).show();
    }

    private void openCamera() {
        if (!PermissionHelper.permissionArrayGranted(this, this.cameraPermission)) {
            ActivityCompat.requestPermissions(this, this.cameraPermission, 200);
            return;
        }
        EmojiPopup emojiPopup = this.emojiPopup;
        if (emojiPopup != null && emojiPopup.isShowing()) {
            showEmojiIcon(true);
            this.emojiPopup.dismiss();
        }
        ImagePicker.Companion.with(this).cameraOnly().start(new Function2() {
            public final Object invoke(Object obj, Object obj2) {
                return ChatActivity.this.m1015lambda$openCamera$39$appcallpeuichatChatActivity((Integer) obj, (Intent) obj2);
            }
        });
    }

    Unit m1015lambda$openCamera$39$appcallpeuichatChatActivity(Integer num, Intent intent) {
        if (num.intValue() == -1 && intent.getData() != null && intent.getData() != null) {
            imageData(intent);
        }
        return Unit.INSTANCE;
    }

    private void openDocuments() {
        Intent intent = new Intent("android.intent.action.OPEN_DOCUMENT");
        intent.addCategory("android.intent.category.OPENABLE");
        intent.setType("*/*");
        intent.putExtra("android.intent.extra.MIME_TYPES", new String[]{"audio/*", "application/*", "application/pdf", "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"});
        intent.putExtra("android.intent.extra.ALLOW_MULTIPLE", true);
        startActivityForResult(intent, 5000);
    }

    private void imageData(Intent data) {
        if (data.getData() == null || data.getData() == null || data.getData() == null) {
            return;
        }
        if (Helper.isVideoFile(data.getData().toString())) {
            if (!data.hasExtra("uri") || data.getStringExtra("uri") == null) {
                return;
            }
            try {
                canCompress(Uri.parse(data.getStringExtra("uri")));
                return;
            } catch (IOException e) {
                Toast.makeText(getContext(), "Error " + e, 0).show();
                return;
            }
        }
        cameraResult(data);
    }

    private void cameraResult(Intent data) {
        try {
            final Uri data2 = data.getData();
            LocalDB.databaseWriteExecutor.execute(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.m971lambda$cameraResult$43$appcallpeuichatChatActivity(data2);
                }
            });
        } catch (IllegalStateException e) {
            showProgressDialog(false);
            e.printStackTrace();
        } catch (Exception unused) {
            showProgressDialog(false);
            Toast.makeText((Context) this, (CharSequence) "Something went wrong", 0).show();
        }
    }

    void m971lambda$cameraResult$43$appcallpeuichatChatActivity(Uri uri) {
        final String compressedImageFile = CompressFile.getCompressedImageFile(uri, getContext(), 30);
        if (compressedImageFile == null) {
            runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.m969lambda$cameraResult$40$appcallpeuichatChatActivity();
                }
            });
        } else {
            runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.m970lambda$cameraResult$42$appcallpeuichatChatActivity(compressedImageFile);
                }
            });
        }
    }

    void m969lambda$cameraResult$40$appcallpeuichatChatActivity() {
        Toast.makeText((Context) this, (CharSequence) getString(2131952060), 0).show();
    }

    void m970lambda$cameraResult$42$appcallpeuichatChatActivity(String str) {
        if (Helper.isFileGreaterThan(new File(str), 1)) {
            DialogHelper.showReasonDialog(getContext(), getString(2131952988), getString(2131952253), new DialogHelper.ConfirmationListener() {
                @Override
                public final void onPositiveClick() {
                    ChatActivity.lambda$cameraResult$41();
                }
            });
        } else {
            submitChatResponse(str, Constants.CHAT_TYPE.IMAGE.name(), 0L);
        }
    }

    private void startReplyFlow(GroupModel chatModel, int position) {
        int i;
        if (this.replyId == null) {
            AnimatorHelper.expand(((ActivityTaskDetailBinding) this.binding).replyViewParent);
            this.viewMessageInputBinding.messageInput.requestFocus();
            Helper.showSoftKeyboard(this);
        }
        this.replyId = chatModel.getId();
        this.replyMessage = chatModel.getMessage();
        this.replyType = chatModel.getMessageType();
        boolean equals = (chatModel.getSenderId() + chatModel.getSenderType()).equals(this.accountId + this.role);
        Helper.getColor(chatModel.getSenderName(), false);
        if (!equals) {
            i = Helper.getColor(chatModel.getSenderName(), false);
            ((ActivityTaskDetailBinding) this.binding).replayLayout.userName.setTextColor(i);
            ((ActivityTaskDetailBinding) this.binding).replayLayout.userName.setText(chatModel.getSenderName());
        } else {
            int color = Helper.getColor(getString(2131952981), false);
            ((ActivityTaskDetailBinding) this.binding).replayLayout.userName.setTextColor(color);
            ((ActivityTaskDetailBinding) this.binding).replayLayout.userName.setText(getString(2131952981));
            i = color;
        }
        ((ActivityTaskDetailBinding) this.binding).replayLayout.replyPhoto.setVisibility(0);
        if (chatModel.getMessageType().equals(Constants.CHAT_TYPE.TEXT.name())) {
            ((ActivityTaskDetailBinding) this.binding).replayLayout.replyMessageText.setText(chatModel.getMessage());
            ((ActivityTaskDetailBinding) this.binding).replayLayout.replyPhoto.setVisibility(8);
        } else if (chatModel.getMessageType().equals(Constants.CHAT_TYPE.IMAGE.name())) {
            ((ActivityTaskDetailBinding) this.binding).replayLayout.replyPhoto.setImageResource(2131231676);
            ((ActivityTaskDetailBinding) this.binding).replayLayout.replyMessageText.setText(getString(2131952969));
        } else if (chatModel.getMessageType().equals(Constants.CHAT_TYPE.VIDEO.name())) {
            ((ActivityTaskDetailBinding) this.binding).replayLayout.replyPhoto.setImageResource(2131231676);
            ((ActivityTaskDetailBinding) this.binding).replayLayout.replyMessageText.setText(getString(2131952979));
        } else if (chatModel.getMessageType().equals(Constants.CHAT_TYPE.DOCUMENT.name())) {
            ((ActivityTaskDetailBinding) this.binding).replayLayout.replyPhoto.setImageResource(2131231669);
            ((ActivityTaskDetailBinding) this.binding).replayLayout.replyMessageText.setText(getString(2131952975));
        } else if (chatModel.getMessageType().equals(Constants.CHAT_TYPE.LOCATION.name())) {
            ((ActivityTaskDetailBinding) this.binding).replayLayout.replyMessageText.setText(getString(2131952970));
            ((ActivityTaskDetailBinding) this.binding).replayLayout.replyPhoto.setImageResource(2131231636);
        } else if (chatModel.getMessageType().equals(Constants.CHAT_TYPE.AUDIO.name())) {
            ((ActivityTaskDetailBinding) this.binding).replayLayout.replyPhoto.setImageResource(2131231523);
            ((ActivityTaskDetailBinding) this.binding).replayLayout.replyMessageText.setText(getString(2131952959));
        } else if (chatModel.getMessageType().equals(Constants.CHAT_TYPE.CONTACT.name())) {
            ((ActivityTaskDetailBinding) this.binding).replayLayout.replyPhoto.setImageResource(2131230886);
            ((ActivityTaskDetailBinding) this.binding).replayLayout.replyMessageText.setText(chatModel.getMessage());
        }
        ((ActivityTaskDetailBinding) this.binding).replayLayout.view4.setBackgroundColor(i);
    }

    void handleIntent(final IntentModel intentModel) {
        IntentModel.Types types = intentModel.getTypes();
        Timber.e("Type --- %s", new Object[]{types});
        if (types != null) {
            if (types.equals(IntentModel.Types.TEXT)) {
                if (intentModel.getUri() != null) {
                    this.viewMessageInputBinding.messageInput.setText(intentModel.getUri());
                    return;
                }
                return;
            }
            if (types.equals(IntentModel.Types.IMAGE)) {
                try {
                    File file = intentModel.getFile();
                    Intent intent = new Intent((Context) this, (Class<?>) EditorActivity.class);
                    intent.putExtra("imageUri", Uri.fromFile(file).toString());
                    startActivityForResult(intent, 401);
                    return;
                } catch (Exception e) {
                    Timber.e(e, "Error: ", new Object[0]);
                    Toast.makeText(getContext(), "File not found", 0).show();
                    return;
                }
            }
            if (types.equals(IntentModel.Types.PDF) || types.equals(IntentModel.Types.DOCS)) {
                new Handler(Looper.myLooper()).postDelayed(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.this.m982lambda$handleIntent$45$appcallpeuichatChatActivity(intentModel);
                    }
                }, 200L);
            } else if (types.equals(IntentModel.Types.VIDEO)) {
                new Handler(Looper.myLooper()).postDelayed(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.this.m985lambda$handleIntent$48$appcallpeuichatChatActivity(intentModel);
                    }
                }, 200L);
            } else if (types.equals(IntentModel.Types.AUDIO)) {
                new Handler(Looper.myLooper()).postDelayed(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.this.m987lambda$handleIntent$50$appcallpeuichatChatActivity(intentModel);
                    }
                }, 200L);
            }
        }
    }

    void m982lambda$handleIntent$45$appcallpeuichatChatActivity(final IntentModel intentModel) {
        try {
            LocalDB.databaseWriteExecutor.execute(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.m981lambda$handleIntent$44$appcallpeuichatChatActivity(intentModel);
                }
            });
        } catch (Exception e) {
            Timber.e(e, "Error: ", new Object[0]);
            Toast.makeText(getContext(), "File not found", 0).show();
        }
    }

    void m981lambda$handleIntent$44$appcallpeuichatChatActivity(IntentModel intentModel) {
        try {
            submitChatResponse(intentModel.getFile().getPath(), Constants.CHAT_TYPE.DOCUMENT.name(), 0L);
        } catch (Exception e) {
            Timber.e(e);
        }
    }

    void m985lambda$handleIntent$48$appcallpeuichatChatActivity(final IntentModel intentModel) {
        try {
            LocalDB.databaseWriteExecutor.execute(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.m984lambda$handleIntent$47$appcallpeuichatChatActivity(intentModel);
                }
            });
        } catch (Exception e) {
            Timber.e(e, "Error: ", new Object[0]);
            Toast.makeText(getContext(), "File not found", 0).show();
        }
    }

    void m984lambda$handleIntent$47$appcallpeuichatChatActivity(IntentModel intentModel) {
        try {
            final File file = intentModel.getFile();
            runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.m983lambda$handleIntent$46$appcallpeuichatChatActivity(file);
                }
            });
        } catch (Exception e) {
            Timber.e(e);
            Toast.makeText((Context) this, (CharSequence) ("" + e.getMessage()), 0).show();
        }
    }

    void m983lambda$handleIntent$46$appcallpeuichatChatActivity(File file) {
        try {
            submitChatResponse(file.getPath(), Constants.CHAT_TYPE.VIDEO.name(), Helper.getDuration(file));
        } catch (Exception e) {
            Timber.e(e);
            Toast.makeText((Context) this, (CharSequence) ("" + e.getMessage()), 0).show();
        }
    }

    void m987lambda$handleIntent$50$appcallpeuichatChatActivity(final IntentModel intentModel) {
        try {
            LocalDB.databaseWriteExecutor.execute(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.this.m986lambda$handleIntent$49$appcallpeuichatChatActivity(intentModel);
                }
            });
        } catch (Exception e) {
            Timber.e(e, "Error: ", new Object[0]);
            Toast.makeText(getContext(), "File not found", 0).show();
        }
    }

    void m986lambda$handleIntent$49$appcallpeuichatChatActivity(IntentModel intentModel) {
        try {
            File file = intentModel.getFile();
            submitChatResponse(file.getPath(), Constants.CHAT_TYPE.AUDIO.name(), Helper.getDuration(file) * 1000);
        } catch (Exception e) {
            Timber.e(e);
        }
    }

    public void handleIntents() {
        try {
            Intent intent = getIntent();
            if (intent == null) {
                return;
            }
            String action = intent.getAction();
            String type = intent.getType();
            if ("android.intent.action.SEND".equals(action) && type != null) {
                if ("application/pdf".equals(type)) {
                    handleSend(intent, IntentModel.Types.PDF);
                } else if (type.startsWith("image/")) {
                    handleSend(intent, IntentModel.Types.IMAGE);
                } else if (type.startsWith("video/")) {
                    handleSend(intent, IntentModel.Types.VIDEO);
                } else if (type.startsWith("audio/")) {
                    handleSend(intent, IntentModel.Types.AUDIO);
                }
            }
        } catch (Exception e) {
            Timber.e(e, "Error: ", new Object[0]);
        }
    }

    void handleSend(Intent intent, IntentModel.Types type) {
        IntentModel intentModel;
        Uri uri = (Uri) intent.getParcelableExtra("android.intent.extra.STREAM");
        if (uri != null) {
            Timber.e("image Uri %s", new Object[]{uri});
            if (type.equals(IntentModel.Types.IMAGE)) {
                intentModel = new IntentModel(IntentModel.Types.IMAGE, String.valueOf(uri));
            } else if (type.equals(IntentModel.Types.PDF)) {
                intentModel = new IntentModel(IntentModel.Types.PDF, String.valueOf(uri));
            } else if (type.equals(IntentModel.Types.VIDEO)) {
                intentModel = new IntentModel(IntentModel.Types.VIDEO, String.valueOf(uri));
            } else {
                intentModel = type.equals(IntentModel.Types.AUDIO) ? new IntentModel(IntentModel.Types.AUDIO, String.valueOf(uri)) : null;
            }
            if (intentModel != null) {
                handleIntent(intentModel);
            }
        }
    }

    protected void onDestroy() {
        this.menuKeyboard.clear();
        ProgressDialog progressDialog = this.progressDialog;
        if (progressDialog != null) {
            progressDialog.dismiss();
        }
        AudioMediaPlayer audioMediaPlayer = this.audioMediaPlayer;
        if (audioMediaPlayer != null) {
            audioMediaPlayer.release();
            this.audioMediaPlayer = null;
        }
        Dialog dialog = this.alertDialog;
        if (dialog != null) {
            dialog.dismiss();
        }
        releasePlayer();
        CompositeDisposable compositeDisposable = this.disposable;
        if (compositeDisposable != null && !compositeDisposable.isDisposed()) {
            this.disposable.dispose();
            this.disposable.clear();
        }
        SoundManager soundManager = this.soundManager;
        if (soundManager != null) {
            soundManager.release();
        }
        super.onDestroy();
    }

    private boolean isLastVisible() {
        CustomLinearLayoutManager layoutManager = ((ActivityTaskDetailBinding) this.binding).taskDetailRecyclerView.getLayoutManager();
        return ((ActivityTaskDetailBinding) this.binding).taskDetailRecyclerView.getAdapter() != null && (layoutManager != null ? layoutManager.findLastVisibleItemPosition() : 0) >= ((ActivityTaskDetailBinding) this.binding).taskDetailRecyclerView.getAdapter().getItemCount() - 1;
    }

    @Override
    public PopupWindow getPopup() {
        return this.menuKeyboard;
    }

    @Override
    public void onPopUpBack() {
        super.onPopUpBack();
        EmojiPopup emojiPopup = this.emojiPopup;
        if (emojiPopup == null || !emojiPopup.isShowing()) {
            return;
        }
        showEmojiIcon(true);
    }

    @Override
    public void onImageClick(final GroupModel chatModel, int position) {
        if (!chatModel.isUnlocked() && !this.isStreamer && Objects.equals(chatModel.getMessageType(), Constants.CHAT_TYPE.LOCKED_IMAGE.name())) {
            DialogHelper.showReasonDialog((Context) this, "", "Proceed to unlock", true, new DialogHelper.ConfirmationListener() {
                @Override
                public final void onPositiveClick() {
                    ChatActivity.this.m1012lambda$onImageClick$51$appcallpeuichatChatActivity(chatModel);
                }
            });
            return;
        }
        Intent intent = new Intent((Context) this, (Class<?>) ImageShowActivity.class);
        intent.putExtra("pics", chatModel.getMessage());
        startActivity(intent);
    }

    void m1012lambda$onImageClick$51$appcallpeuichatChatActivity(GroupModel groupModel) {
        unlockPhoto(groupModel.getId());
    }

    @Override
    public void onVideoClick(GroupModel chatModel, int position) {
        if (!chatModel.getMessage().contains("https://")) {
            Helper.openPlayer(getContext(), chatModel.getMessage());
        } else if (this.chatViewModel.isFileExists(getContext(), chatModel, false)) {
            Helper.openPlayer(getContext(), this.chatViewModel.getFilePath(getContext(), chatModel, false));
        } else {
            this.chatViewModel.createDownload(getContext(), chatModel, false, false, false);
        }
    }

    void m1013lambda$onLongClick$52$appcallpeuichatChatActivity(GroupModel groupModel, DialogInterface dialogInterface, int i) {
        deleteMessageResponse(groupModel);
    }

    @Override
    public void onLongClick(final GroupModel chatModel, int position) {
        new AlertDialog.Builder(this).setMessage(getString(2131952995) + "?").setPositiveButton(getString(2131953093), new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                ChatActivity.this.m1013lambda$onLongClick$52$appcallpeuichatChatActivity(chatModel, dialogInterface, i);
            }
        }).setNegativeButton(getString(2131952360), new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                dialogInterface.dismiss();
            }
        }).create().show();
    }

    @Override
    public void onDocumentClick(GroupModel chatModel, int position) {
        onDocumentClick(chatModel);
    }

    private void onDocumentClick(GroupModel chatModel) {
        try {
            if (this.chatViewModel.isFileExists(getContext(), chatModel, false)) {
                try {
                    Uri uriForFile = FileProvider.getUriForFile(getApplicationContext(), "app.b1k0.provider", new File(this.chatViewModel.getFilePath(getContext(), chatModel, false)));
                    Intent intent = new Intent();
                    intent.addFlags(268435456);
                    intent.setAction("android.intent.action.VIEW");
                    intent.addFlags(1);
                    intent.setDataAndType(uriForFile, Files.getMimeFromUrl(chatModel.getMessage()));
                    startActivity(intent);
                } catch (ActivityNotFoundException unused) {
                    Toast.makeText((Context) this, 2131952361, 0).show();
                }
            } else {
                this.chatViewModel.createDownload(getContext(), chatModel, false, false, false);
            }
        } catch (Exception e) {
            Toast.makeText((Context) this, (CharSequence) ("" + e.getMessage()), 0).show();
        }
    }

    @Override
    public void onReplyClick(GroupModel chatModel, int position) {
        startReplyFlow(chatModel, position);
    }

    @Override
    public void onReplyMessage(GroupModel chatModel, int position) {
        boolean z;
        MessageAdapter messageAdapter = this.messageAdapter;
        if (messageAdapter == null) {
            return;
        }
        if (messageAdapter.getSelectedItemCount() > 0) {
            enableActionMode(position);
            return;
        }
        Iterator<GroupModel> it = this.messageAdapter.getUserMessagesList().iterator();
        int i = 0;
        while (true) {
            if (!it.hasNext()) {
                z = false;
                break;
            } else {
                if (it.next().getId().equals(chatModel.getReplyMessageId())) {
                    z = true;
                    break;
                }
                i++;
            }
        }
        if (!z) {
            reset();
            this.chatViewModel.fromSearch = true;
            this.searchMessageId = chatModel.getReplyMessageId();
            this.chatViewModel.messageId = chatModel.getReplyMessageId();
            Timber.e("current reply id %s", new Object[]{this.currentPage});
            getChatResponse(true, false);
            return;
        }
        Timber.e("scroll position %s", new Object[]{Integer.valueOf(i)});
        if (((ActivityTaskDetailBinding) this.binding).taskDetailRecyclerView.getLayoutManager() != null) {
            ((ActivityTaskDetailBinding) this.binding).taskDetailRecyclerView.getLayoutManager().smoothScrollToPosition(((ActivityTaskDetailBinding) this.binding).taskDetailRecyclerView, new RecyclerView.State(), i);
        }
        this.messageAdapter.highLightBackground(i, true);
    }

    @Override
    public void onShareClick(GroupModel chatModel, int position) {
        if (chatModel.getMessageType().equals(Constants.CHAT_TYPE.TEXT.name())) {
            Helper.shareText(chatModel.getMessage(), getContext());
            return;
        }
        if (chatModel.getMessageType().equals(Constants.CHAT_TYPE.LOCATION.name())) {
            return;
        }
        if (chatModel.getMessageType().equals(Constants.CHAT_TYPE.DOCUMENT.name())) {
            this.chatViewModel.createDownload(getContext(), chatModel, true, true, false);
        } else if (this.chatViewModel.isFileExists(getContext(), chatModel, false)) {
            shareFile(chatModel);
        } else {
            this.chatViewModel.createDownload(getContext(), chatModel, false, true, false);
        }
    }

    @Override
    public void onCopyClick(GroupModel chatModel, int position) {
        Helper.copyToClipboard(getContext(), chatModel.getMessage());
    }

    @Override
    public void setActionMode(int position) {
        enableActionMode(position);
    }

    @Override
    public void onForward(GroupModel groupModel, int position) {
        if (this.messageAdapter != null) {
            enableActionMode(position);
        }
    }

    @Override
    public void onRetryClick(GroupModel chatModel, int position) {
        if (Helper.isConnected(getContext())) {
            this.chatViewModel.syncChat(chatModel);
        } else {
            Toast.makeText((Context) this, (CharSequence) getString(2131952366), 0).show();
        }
    }

    @Override
    public void onGiftSent(final GiftModel giftModel, final Long messageId) {
        super.onGiftSent(giftModel, messageId);
        DialogHelper.showReasonDialog((Context) this, "", "This gift will cost " + Helper.getSign(false) + giftModel.getAmount() + ". Do you want to continue?", true, new DialogHelper.ConfirmationListener() {
            @Override
            public final void onPositiveClick() {
                ChatActivity.this.m1011lambda$onGiftSent$54$appcallpeuichatChatActivity(giftModel, messageId);
            }
        });
    }

    private void shareFile(GroupModel chatModel) {
        try {
            File file = new File(this.chatViewModel.getFilePath(getContext(), chatModel, false));
            if (chatModel.getMessageType().equals(Constants.CHAT_TYPE.IMAGE.name())) {
                Uri uriForFile = FileProvider.getUriForFile(getApplicationContext(), "app.b1k0.provider", file);
                Intent addFlags = ShareCompat.IntentBuilder.from(this).setStream(uriForFile).setType("image/*").setChooserTitle("Share image...").getIntent().setDataAndType(uriForFile, "image/*").addFlags(1);
                Iterator<ResolveInfo> it = getPackageManager().queryIntentActivities(addFlags, NativeProtocol.MESSAGE_GET_ACCESS_TOKEN_REQUEST).iterator();
                while (it.hasNext()) {
                    grantUriPermission(it.next().activityInfo.packageName, uriForFile, 3);
                }
                startActivity(addFlags);
                return;
            }
            if (chatModel.getMessageType().equals(Constants.CHAT_TYPE.VIDEO.name())) {
                Uri uriForFile2 = FileProvider.getUriForFile(getApplicationContext(), "app.b1k0.provider", file);
                Intent addFlags2 = ShareCompat.IntentBuilder.from(this).setStream(uriForFile2).setType("video/*").setChooserTitle("Share audio...").getIntent().setDataAndType(uriForFile2, "audio/*").addFlags(1);
                Iterator<ResolveInfo> it2 = getPackageManager().queryIntentActivities(addFlags2, NativeProtocol.MESSAGE_GET_ACCESS_TOKEN_REQUEST).iterator();
                while (it2.hasNext()) {
                    grantUriPermission(it2.next().activityInfo.packageName, uriForFile2, 3);
                }
                startActivity(addFlags2);
                return;
            }
            if (chatModel.getMessageType().equals(Constants.CHAT_TYPE.AUDIO.name())) {
                Uri uriForFile3 = FileProvider.getUriForFile(getApplicationContext(), "app.b1k0.provider", file);
                Intent addFlags3 = ShareCompat.IntentBuilder.from(this).setStream(uriForFile3).setType("audio/*").setChooserTitle("Share audio...").getIntent().setDataAndType(uriForFile3, "audio/*").addFlags(1);
                Iterator<ResolveInfo> it3 = getPackageManager().queryIntentActivities(addFlags3, NativeProtocol.MESSAGE_GET_ACCESS_TOKEN_REQUEST).iterator();
                while (it3.hasNext()) {
                    grantUriPermission(it3.next().activityInfo.packageName, uriForFile3, 3);
                }
                startActivity(addFlags3);
                return;
            }
            Uri uriForFile4 = FileProvider.getUriForFile(getApplicationContext(), "app.b1k0.provider", new File(this.chatViewModel.getFilePath(getContext(), chatModel, true)));
            Intent addFlags4 = ShareCompat.IntentBuilder.from(this).setStream(uriForFile4).setType("application/pdf").setChooserTitle("Share pdf...").getIntent().setDataAndType(uriForFile4, "application/pdf").addFlags(1);
            Iterator<ResolveInfo> it4 = getPackageManager().queryIntentActivities(addFlags4, NativeProtocol.MESSAGE_GET_ACCESS_TOKEN_REQUEST).iterator();
            while (it4.hasNext()) {
                grantUriPermission(it4.next().activityInfo.packageName, uriForFile4, 3);
            }
            startActivity(addFlags4);
        } catch (Exception e) {
            Toast.makeText((Context) this, (CharSequence) ("" + e.getMessage()), 0).show();
        }
    }

    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        new Handler(Looper.myLooper()).postDelayed(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.handleIntents();
            }
        }, 1000L);
        if (!intent.hasExtra("notification_clicked") || !intent.getBooleanExtra("notification_clicked", false)) {
            Timber.e("onNewIntent: not this %s", new Object[]{Boolean.valueOf(intent.hasExtra("notification_clicked"))});
            return;
        }
        long longExtra = intent.getLongExtra("chatId", -1L);
        String stringExtra = intent.getStringExtra("chatName");
        String stringExtra2 = intent.getStringExtra("profilePic");
        App.chatTitle = stringExtra;
        App.profile = stringExtra2;
        Timber.e("onNewIntent:  int %s", new Object[]{Long.valueOf(longExtra)});
        Timber.e("onNewIntent: act %s", new Object[]{Long.valueOf(chatId)});
        if (longExtra == -1) {
            onBackPressed();
        }
        if (chatId == longExtra) {
            setToolbar();
            reset();
            getChatResponse(true, false);
        } else {
            chatId = longExtra;
            App.chatId = longExtra;
            App.chatTitle = stringExtra;
            finish();
            startActivity(intent);
        }
        clearNotificationCount(Long.valueOf(longExtra));
        App.notificationAvailable = false;
    }

    @Override
    public void menuOnClick(final GridMenuAdapter.Menu menu) {
        SoftKeyBoardPopup softKeyBoardPopup = this.menuKeyboard;
        if (softKeyBoardPopup != null) {
            softKeyBoardPopup.dismiss();
        }
        new Handler(Looper.myLooper()).postDelayed(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.m992lambda$menuOnClick$55$appcallpeuichatChatActivity(menu);
            }
        }, 300L);
    }

    void m992lambda$menuOnClick$55$appcallpeuichatChatActivity(GridMenuAdapter.Menu menu) {
        if (menu.getName().equals(getString(2131952965))) {
            openDocuments();
            return;
        }
        if (menu.getName().equals(getString(2131952989))) {
            openCamera();
            return;
        }
        if (menu.getName().equals(getString(2131952979))) {
            if (!PermissionHelper.permissionArrayGranted(this, this.cameraPermission)) {
                ActivityCompat.requestPermissions(this, this.cameraPermission, 200);
                return;
            }
            try {
                startActivityForResult(new Intent("android.media.action.VIDEO_CAPTURE"), 1000);
                return;
            } catch (Exception e) {
                Toast.makeText((Context) this, (CharSequence) ("" + e.getMessage()), 0).show();
                return;
            }
        }
        if (menu.getName().equals(getString(2131952967))) {
            openGallery();
        } else if (menu.getName().equals(getString(2131952186))) {
            showPlacePicker();
        } else {
            menu.getName().equals(getString(2131951910));
        }
    }

    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 1000) {
            if (resultCode == -1 && data != null) {
                try {
                    canCompress(data.getData());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        } else if ((requestCode != 5000 || resultCode != -1) && ((requestCode != 500 || resultCode != -1) && requestCode == 401 && resultCode == -1 && data != null)) {
            submitChatResponse(new File(data.getStringExtra("imagePath")).getPath(), Constants.CHAT_TYPE.IMAGE.name(), 0L);
        }
        if (requestCode == 301 && resultCode == -1) {
            reset();
            getChatResponse(true, false);
        }
        if (requestCode == 301 && resultCode == 1005) {
            reset();
            getChatResponse(true, false);
            setToolbar();
        }
        if (requestCode == 301 && resultCode == 1006) {
            onBackPressed();
        }
        if (requestCode == 301 && resultCode == 1007 && data != null) {
            this.adminOnly = data.getBooleanExtra("adminOnly", false);
            getIntent().putExtra("adminOnly", this.adminOnly);
        }
    }

    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        boolean z;
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        if (requestCode == 200) {
            if (grantResults.length == 0) {
                return;
            }
            if (Build.VERSION.SDK_INT >= 30) {
                this.permissionAccepted = grantResults[0] == 0;
            } else if (Build.VERSION.SDK_INT == 29) {
                this.permissionAccepted = grantResults[0] == 0;
            } else {
                this.permissionAccepted = grantResults[0] == 0 && grantResults[1] == 0;
            }
            if (this.permissionAccepted) {
                return;
            }
            DialogHelper.showPermissionDialog(getContext(), this, getString(2131952428), getString(2131952439), MEDIA_PERMISSION);
            return;
        }
        if (requestCode == 0) {
            if (grantResults.length == 0) {
                return;
            }
            z = grantResults[0] == 0;
            this.permissionAccepted = z;
            if (z) {
                return;
            }
            DialogHelper.showPermissionDialog(getContext(), this, getString(2131952428), getString(2131952509), RECORD_PERMISSION);
            return;
        }
        if (requestCode != 8002 || grantResults.length == 0) {
            return;
        }
        z = grantResults[0] == 0 && grantResults[1] == 0;
        this.permissionAccepted = z;
        if (z) {
            return;
        }
        DialogHelper.showPermissionDialog(getContext(), this, getString(2131952428), "Camera Permission required", CAMERA_PERMISSION);
    }

    class AnonymousClass19 extends BroadcastReceiver {
        AnonymousClass19() {
        }

        @Override
        public void onReceive(final Context context, Intent intent) {
            String stringExtra;
            GiftRequestModel giftRequestModel;
            String stringExtra2;
            SuccessModel successModel;
            if (intent.getAction().equals(Constants.NOTIFICATION_REFRESH)) {
                intent.setAction("");
                Timber.e("NOTIFICATION_REFRESH %s", new Object[]{Boolean.valueOf(ChatActivity.this.isCurrentSender)});
                ChatActivity.this.isCurrentSender = false;
                long longExtra = intent.getLongExtra("chat_id", 0L);
                String stringExtra3 = intent.getStringExtra("chat_message");
                final GroupModel groupModel = null;
                if (stringExtra3 != null && !stringExtra3.isEmpty()) {
                    groupModel = (GroupModel) new Gson().fromJson(stringExtra3, GroupModel.class);
                    groupModel.setCreatedAt(DateHelper.formatDateByPattern(groupModel.getCreatedAt(), "MMM dd, yyyy, hh:mm:ss a", "yyyy-MM-dd HH:mm:ss", "Asia/Kolkata"));
                    groupModel.setCreationDate(DateHelper.formatDateByPattern(groupModel.getCreatedAt(), "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd"));
                }
                if (ChatActivity.chatId == longExtra) {
                    App.notificationAvailable = false;
                    ChatActivity.this.clearNotificationCount(Long.valueOf(longExtra));
                    new Handler(Looper.myLooper()).postDelayed(new Runnable() {
                        @Override
                        public final void run() {
                            ChatActivity.AnonymousClass19.this.m1043lambda$onReceive$1$appcallpeuichatChatActivity$19(groupModel, context);
                        }
                    }, 100L);
                    return;
                }
                return;
            }
            if (intent.getAction().equals(Constants.GIFT_RECEIVE)) {
                if (!ChatActivity.this.isStreamer || (stringExtra2 = intent.getStringExtra("gift")) == null || stringExtra2.isEmpty() || (successModel = (SuccessModel) new Gson().fromJson(stringExtra2, SuccessModel.class)) == null || successModel.getChatId() == null || successModel.getChatId().longValue() != ChatActivity.chatId) {
                    return;
                }
                ChatActivity.this.reset();
                Toast.makeText(context, "Gift received", 0).show();
                ChatActivity.this.getChatResponse(true, false);
                return;
            }
            if (intent.getAction().equals(Constants.GIFT_REQUEST)) {
                if (ChatActivity.this.isStreamer || (stringExtra = intent.getStringExtra("gift")) == null || (giftRequestModel = (GiftRequestModel) new Gson().fromJson(stringExtra, GiftRequestModel.class)) == null) {
                    return;
                }
                ChatActivity.this.showGiftRequestDialog(giftRequestModel);
                return;
            }
            if (intent.getAction().equals(Constants.MESSAGE_UNLOCKED)) {
                ChatActivity.this.reset();
                ChatActivity.this.getChatResponse(true, false);
            } else if (intent.getAction().equals(Constants.CALL_INITIALIZED) && ChatActivity.this.isRecording) {
                ChatActivity.this.isForceFinished = true;
                try {
                    ChatActivity.this.viewMessageInputBinding.recordView.finishRecord();
                } catch (Exception e) {
                    Timber.e(e);
                }
            }
        }

        void m1043lambda$onReceive$1$appcallpeuichatChatActivity$19(GroupModel groupModel, Context context) {
            if (groupModel != null) {
                if (groupModel.getSenderType().equals(ChatActivity.this.role) && String.valueOf(groupModel.getSenderId()).equals(ChatActivity.this.accountId)) {
                    return;
                }
                if (!Helper.isAwake(ChatActivity.this.getContext())) {
                    ChatActivity.this.playSound(context);
                }
                if (ChatActivity.this.messageAdapter != null) {
                    if (ChatActivity.this.isVisible) {
                        if (ChatActivity.this.soundManager != null) {
                            ChatActivity.this.soundManager.playSound(2131886132);
                        } else {
                            Helper.playSound(ChatActivity.this.getContext(), 2131886132);
                        }
                    }
                    if (ChatActivity.this.chatViewModel == null || !ChatActivity.this.chatViewModel.fromSearch) {
                        ChatActivity.this.messageAdapter.addItem(groupModel, true);
                        ChatActivity.this.scrollRv();
                        ChatActivity.this.notifyCall();
                        return;
                    } else {
                        ChatActivity.this.chatViewModel.fromSearch = false;
                        ChatActivity.this.chatViewModel.messageId = -1L;
                        ChatActivity.this.searchMessageId = -1L;
                        ChatActivity.this.reset();
                        ChatActivity.this.getChatResponse(true, false);
                        return;
                    }
                }
                return;
            }
            Timber.e("reset ", new Object[0]);
            ChatActivity.this.reset();
            new Handler(Looper.myLooper()).postDelayed(new Runnable() {
                @Override
                public final void run() {
                    ChatActivity.AnonymousClass19.this.m1042lambda$onReceive$0$appcallpeuichatChatActivity$19();
                }
            }, 300L);
        }

        void m1042lambda$onReceive$0$appcallpeuichatChatActivity$19() {
            ChatActivity.this.getChatResponse(true, false);
        }
    }

    private void registerReceiver() {
        LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(this);
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(Constants.NOTIFICATION_REFRESH);
        intentFilter.addAction(Constants.GIFT_REQUEST);
        intentFilter.addAction(Constants.GIFT_RECEIVE);
        intentFilter.addAction(Constants.MESSAGE_UNLOCKED);
        intentFilter.addAction(Constants.CALL_INITIALIZED);
        localBroadcastManager.registerReceiver(this.broadcastReceiver, intentFilter);
    }

    private void unRegisterReceiver() {
        if (this.broadcastReceiver != null) {
            LocalBroadcastManager.getInstance(this).unregisterReceiver(this.broadcastReceiver);
        }
    }

    public void onBackPressed() {
        if (isTaskRoot()) {
            Intent intent = new Intent((Context) this, (Class<?>) HomeActivity.class);
            if (this.isStreamer) {
                intent = new Intent((Context) this, (Class<?>) StreamerHomeActivity.class);
            }
            intent.addFlags(268468224);
            finish();
            startActivity(intent);
        } else {
            GroupViewModel groupViewModel = this.chatViewModel;
            if (groupViewModel != null && groupViewModel.forward) {
                Intent intent2 = new Intent((Context) this, (Class<?>) HomeActivity.class);
                if (this.isStreamer) {
                    intent2 = new Intent((Context) this, (Class<?>) StreamerHomeActivity.class);
                }
                intent2.addFlags(268468224);
                finish();
                startActivity(intent2);
                overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
            }
        }
        App.chatTitle = "";
        finish();
    }

    @Override
    protected void onStart() {
        super.onStart();
        registerReceiver();
    }

    protected void onPause() {
        this.isVisible = false;
        releasePlayer();
        super.onPause();
    }

    protected void onStop() {
        if (!Helper.isAwake(getContext())) {
            App.isChatScreen = true;
        } else {
            unRegisterReceiver();
        }
        super.onStop();
    }

    protected void onResume() {
        this.isVisible = true;
        super.onResume();
        if (refresh) {
            getMetaDataResponse();
            refresh = false;
        }
        Timber.e("App.notificationAvailable %s", new Object[]{Boolean.valueOf(App.notificationAvailable)});
        if (App.notificationAvailable) {
            reset();
            getChatResponse(true, false);
            handleNotification();
            App.notificationAvailable = false;
        }
    }

    public void resetFreeChatOverLayoutAndRv() {
        if (this.isStreamer) {
            return;
        }
        boolean z = SharedPref.getBoolean(getContext(), PrefKeys.FIRST_RECHARGE_DONE);
        boolean z2 = SharedPref.getBoolean(getContext(), PrefKeys.UNLOCK_CHAT);
        boolean z3 = SharedPref.getBoolean(getContext(), PrefKeys.LOCK_CHAT_MESSAGES_AFTER_FREE_PERIOD);
        MessageAdapter messageAdapter = this.messageAdapter;
        if (messageAdapter != null) {
            messageAdapter.allMessagesLocked = z3 && z && z2;
            this.messageAdapter.notifyDataSetChanged();
        }
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putLong("chatId", chatId);
        outState.putString("taskTitle", App.chatTitle);
        outState.putString(FacebookRequestErrorClassification.KEY_NAME, this.name);
        outState.putString("userId", this.accountId);
        outState.putBoolean("isCurrentSender", this.isCurrentSender);
        outState.putBoolean("adminOnly", this.adminOnly);
        outState.putBoolean("important", this.important);
    }

    @Override
    public void onAudioReady(String audioUri) {
        if (audioUri == null || audioUri.isEmpty()) {
            return;
        }
        submitChatResponse(audioUri, Constants.CHAT_TYPE.AUDIO.name(), 0L);
    }

    private void releasePlayer() {
        MessageAdapter messageAdapter = this.messageAdapter;
        if (messageAdapter != null) {
            try {
                messageAdapter.stopPlayer();
            } catch (Exception e) {
                Timber.e(e, "releasePlayer: ", new Object[0]);
            }
        }
    }

    public void playSound(Context context) {
        if (SharedPref.getBoolean(getApplicationContext(), "mute")) {
            return;
        }
        MediaPlayer.create(context, 2131886113).start();
    }

    private void scrollAndHighlightBackground(long messageId) {
        boolean z;
        MessageAdapter messageAdapter = this.messageAdapter;
        if (messageAdapter == null) {
            return;
        }
        Iterator<GroupModel> it = messageAdapter.getUserMessagesList().iterator();
        int i = 0;
        while (true) {
            if (!it.hasNext()) {
                z = false;
                break;
            } else {
                if (it.next().getId().equals(Long.valueOf(messageId))) {
                    z = true;
                    break;
                }
                i++;
            }
        }
        if (z) {
            Timber.e("scroll position %s", new Object[]{Integer.valueOf(i)});
            if (((ActivityTaskDetailBinding) this.binding).taskDetailRecyclerView.getLayoutManager() != null) {
                CenterSmoothScroller centerSmoothScroller = new CenterSmoothScroller(((ActivityTaskDetailBinding) this.binding).taskDetailRecyclerView.getContext());
                centerSmoothScroller.setTargetPosition(i);
                ((ActivityTaskDetailBinding) this.binding).taskDetailRecyclerView.getLayoutManager().startSmoothScroll(centerSmoothScroller);
                ((ActivityTaskDetailBinding) this.binding).taskDetailRecyclerView.getLayoutManager().scrollToPosition(i);
            }
            this.messageAdapter.highLightBackground(i, true);
        }
    }

    public void scrollRv() {
        ((ActivityTaskDetailBinding) this.binding).taskDetailRecyclerView.postDelayed(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.m1019lambda$scrollRv$56$appcallpeuichatChatActivity();
            }
        }, 100L);
    }

    void m1019lambda$scrollRv$56$appcallpeuichatChatActivity() {
        try {
            if (this.messageAdapter != null) {
                ((ActivityTaskDetailBinding) this.binding).taskDetailRecyclerView.scrollToPosition(this.messageAdapter.getItemCount() - 1);
            }
        } catch (Exception unused) {
        }
    }

    public void reset() {
        this.currentPage = -1L;
        this.bottomPage = -1L;
        this.idMapper.clear();
        this.chatModelArrayList.clear();
        if (this.messageAdapter != null) {
            releasePlayer();
            this.messageAdapter.clear();
        }
    }

    private void playVideo(GroupModel chatModel) {
        if (this.chatViewModel.isFileExists(getContext(), chatModel, false)) {
            Helper.openPlayer(getContext(), this.chatViewModel.getFilePath(getContext(), chatModel, false));
        }
    }

    private void canCompress(Uri uri) throws IOException {
        String pathFromURI = Files.getPathFromURI(getContext(), uri);
        if (pathFromURI != null) {
            if (Helper.isFileGreaterThan(new File(pathFromURI), 5)) {
                runOnUiThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.this.m972lambda$canCompress$58$appcallpeuichatChatActivity();
                    }
                });
                return;
            } else {
                compression(uri);
                return;
            }
        }
        compression(uri);
    }

    void m972lambda$canCompress$58$appcallpeuichatChatActivity() {
        DialogHelper.showReasonDialog(getContext(), getString(2131952988), getString(2131952253), new DialogHelper.ConfirmationListener() {
            @Override
            public final void onPositiveClick() {
                ChatActivity.lambda$canCompress$57();
            }
        });
    }

    public void stopRecording(boolean deleteFile) {
        AudioRecorder audioRecorder = this.audioRecorder;
        if (audioRecorder != null) {
            audioRecorder.stop();
        }
        File file = this.recordFile;
        if (file == null || !deleteFile) {
            return;
        }
        file.delete();
    }

    public void clearNotificationCount(final Long chatId2) {
        LocalDB.databaseWriteExecutor.execute(new Runnable() {
            @Override
            public final void run() {
                ChatActivity.this.m978lambda$clearNotificationCount$59$appcallpeuichatChatActivity(chatId2);
            }
        });
    }

    void m978lambda$clearNotificationCount$59$appcallpeuichatChatActivity(Long l) {
        try {
            this.chatDao.dropNotificationChat(l);
            SharedPref.setInt(getApplicationContext(), PrefKeys.CHAT_COUNT, 0);
            this.notificationDAO.resetNotificationCount(l);
            this.notificationDAO.resetMessageCount(l);
            handleNotification();
        } catch (Exception unused) {
        }
    }

    private void observerMessageText() {
        this.viewMessageInputBinding.messageInput.addTextChangedListener(new TextWatcher() {
            @Override
            public void afterTextChanged(Editable s) {
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                if (ChatActivity.this.viewMessageInputBinding.messageInput.getText() != null) {
                    if (!ChatActivity.this.viewMessageInputBinding.messageInput.getText().toString().trim().isEmpty()) {
                        ChatActivity.this.recordButton.setListenForRecord(false);
                        ChatActivity.this.viewMessageInputBinding.recordMessageBtn.setImageResource(2131231720);
                    } else {
                        ChatActivity.this.recordButton.setListenForRecord(true);
                        ChatActivity.this.viewMessageInputBinding.recordMessageBtn.setImageResource(2131232060);
                    }
                }
            }
        });
    }

    void observeSyncResponse() {
        CompositeDisposable compositeDisposable = new CompositeDisposable();
        this.disposable = compositeDisposable;
        compositeDisposable.add(SyncRxBus.getInstance().toObservable().subscribe(new Consumer() {
            public final void accept(Object obj) {
                ChatActivity.this.handleSyncResponse((SyncResponse) obj);
            }
        }, new Consumer() {
            public final void accept(Object obj) {
                Timber.e((Throwable) obj, "error handling sync response", new Object[0]);
            }
        }));
        this.disposable.add(this.rxBus.toObservable().subscribe(new Consumer() {
            public final void accept(Object obj) {
                ChatActivity.this.m993lambda$observeSyncResponse$61$appcallpeuichatChatActivity(obj);
            }
        }, new Consumer() {
            public final void accept(Object obj) {
                ChatActivity.this.m994lambda$observeSyncResponse$62$appcallpeuichatChatActivity((Throwable) obj);
            }
        }));
    }

    void m993lambda$observeSyncResponse$61$appcallpeuichatChatActivity(Object obj) throws Exception {
        if (obj instanceof Progress) {
            Progress progress = (Progress) obj;
            progressDialogPercent((progress.currentBytes * 100.0f) / progress.totalBytes);
            return;
        }
        if (obj instanceof DownloadStatus) {
            DownloadStatus downloadStatus = (DownloadStatus) obj;
            if (downloadStatus.getState().equals(DownloadStatus.STATE.ENQUEUED)) {
                showDownloadProgressDialog();
                return;
            }
            if (downloadStatus.getState().equals(DownloadStatus.STATE.FINISHED)) {
                hideProgressDialog();
                GroupModel groupModel = downloadStatus.getGroupModel();
                if (groupModel != null) {
                    if (downloadStatus.isShare()) {
                        shareFile(groupModel);
                    } else if (groupModel.getMessageType().equals(Constants.CHAT_TYPE.DOCUMENT.name())) {
                        onDocumentClick(groupModel);
                    } else {
                        playVideo(groupModel);
                    }
                }
                Toast.makeText(getContext(), "" + getString(2131951960), 0).show();
                return;
            }
            if (downloadStatus.getState().equals(DownloadStatus.STATE.FAILED)) {
                hideProgressDialog();
                Toast.makeText(getContext(), "" + getString(2131952996), 0).show();
                return;
            }
            if (downloadStatus.getState().equals(DownloadStatus.STATE.ERROR)) {
                hideProgressDialog();
                Toast.makeText(getContext(), "" + downloadStatus.getError().getServerErrorMessage(), 0).show();
                return;
            }
            return;
        }
        if (obj instanceof Error) {
            Toast.makeText(getContext(), "" + ((Error) obj).getServerErrorMessage(), 0).show();
        }
    }

    void m994lambda$observeSyncResponse$62$appcallpeuichatChatActivity(Throwable th) throws Exception {
        Timber.e("error handling sync response %s", new Object[]{th.getMessage()});
        Toast.makeText((Context) this, (CharSequence) ("" + th.getMessage()), 0).show();
    }

    private void handleNotification() {
        try {
            StatusBarNotification[] activeNotifications = ((NotificationManager) getApplicationContext().getSystemService("notification")).getActiveNotifications();
            ArrayList arrayList = new ArrayList();
            for (StatusBarNotification statusBarNotification : activeNotifications) {
                Timber.e("group key %s", new Object[]{statusBarNotification.getGroupKey()});
                if (statusBarNotification.getGroupKey().contains(FirebaseNotificationService.CHAT_GROUP_KEY_CHAT)) {
                    Timber.e("notification id %s", new Object[]{Integer.valueOf(statusBarNotification.getId())});
                    arrayList.add(statusBarNotification);
                }
            }
            if (arrayList.size() == 2) {
                Helper.cancelNotification(this, Math.toIntExact(chatId));
                Helper.cancelNotification(this, Math.toIntExact(FirebaseNotificationService.groupChatNotificationId));
            } else {
                Helper.cancelNotification(this, Math.toIntExact(chatId));
            }
        } catch (Exception unused) {
            Helper.cancelNotification(this, Math.toIntExact(chatId));
            Helper.cancelNotification(this, Math.toIntExact(FirebaseNotificationService.groupChatNotificationId));
        }
    }

    public void handleSyncResponse(final SyncResponse response) {
        if (response.responseType == SyncRxBus.ResponseType.GROUP) {
            if (response.eventType == SyncResponseEventType.PROGRESS) {
                if (response.groupOfflineModel.getMessageType().equals(Constants.CHAT_TYPE.VIDEO.name())) {
                    return;
                }
                response.groupOfflineModel.getMessageType().equals(Constants.CHAT_TYPE.IMAGE.name());
                return;
            }
            if (response.eventType == SyncResponseEventType.SUCCESS) {
                if (this.replyId != null) {
                    this.replyId = null;
                    this.replyMessage = null;
                    this.replyType = null;
                    AnimatorHelper.collapse(((ActivityTaskDetailBinding) this.binding).replyViewParent);
                }
                runOnUiThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.this.m988lambda$handleSyncResponse$63$appcallpeuichatChatActivity(response);
                    }
                });
                notifyCall();
                return;
            }
            if (response.eventType == SyncResponseEventType.MESSAGE_ADDED) {
                if (this.replyId != null) {
                    this.replyId = null;
                    this.replyMessage = null;
                    this.replyType = null;
                }
                if (((ActivityTaskDetailBinding) this.binding).replyViewParent.getVisibility() == 0) {
                    ((ActivityTaskDetailBinding) this.binding).replyViewParent.setVisibility(8);
                }
                runOnUiThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.this.m989lambda$handleSyncResponse$64$appcallpeuichatChatActivity(response);
                    }
                });
                return;
            }
            if (response.eventType == SyncResponseEventType.FAILED_MESSAGE_DELETED) {
                reset();
                getChatResponse(true, false);
            } else if (response.eventType == SyncResponseEventType.FAILED) {
                runOnUiThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.this.m990lambda$handleSyncResponse$65$appcallpeuichatChatActivity(response);
                    }
                });
            } else if (response.eventType == SyncResponseEventType.MESSAGE_SYNC) {
                runOnUiThread(new Runnable() {
                    @Override
                    public final void run() {
                        ChatActivity.this.m991lambda$handleSyncResponse$66$appcallpeuichatChatActivity(response);
                    }
                });
            }
        }
    }

    void m988lambda$handleSyncResponse$63$appcallpeuichatChatActivity(SyncResponse syncResponse) {
        GroupViewModel groupViewModel;
        StrangerChatListActivity.setRefreshScreen(true);
        SoundManager soundManager = this.soundManager;
        if (soundManager != null) {
            soundManager.playSound(2131886129);
        } else {
            Helper.playSound(getContext(), 2131886129);
        }
        if (this.messageAdapter == null || syncResponse.groupModel == null || this.messageAdapter.updateItem(syncResponse.groupModel) || (groupViewModel = this.chatViewModel) == null) {
            return;
        }
        groupViewModel.groupMessage = syncResponse.groupModel;
    }

    void m989lambda$handleSyncResponse$64$appcallpeuichatChatActivity(SyncResponse syncResponse) {
        if (this.messageAdapter != null) {
            GroupViewModel groupViewModel = this.chatViewModel;
            if (groupViewModel != null && groupViewModel.fromSearch) {
                this.chatViewModel.fromSearch = false;
                this.chatViewModel.messageId = -1L;
                this.searchMessageId = -1L;
                reset();
                getChatResponse(true, false);
                return;
            }
            Timber.e("Message Added UUID --- %s", new Object[]{syncResponse.groupOfflineModel.getUuid()});
            this.messageAdapter.addItem(GroupUtils.mapToGroupModel(syncResponse.groupOfflineModel));
            scrollRv();
        }
    }

    void m990lambda$handleSyncResponse$65$appcallpeuichatChatActivity(SyncResponse syncResponse) {
        if (this.messageAdapter == null || syncResponse.groupOfflineModel == null) {
            return;
        }
        GroupModel mapToGroupModel = GroupUtils.mapToGroupModel(syncResponse.groupOfflineModel);
        this.messageAdapter.removeItem(mapToGroupModel);
        Toast.makeText((Context) this, (CharSequence) ("" + mapToGroupModel.getMessage()), 0).show();
    }

    void m991lambda$handleSyncResponse$66$appcallpeuichatChatActivity(SyncResponse syncResponse) {
        if (this.messageAdapter == null || syncResponse.groupOfflineModel == null) {
            return;
        }
        this.messageAdapter.updateItem(GroupUtils.mapToGroupModel(syncResponse.groupOfflineModel));
    }

    @Override
    public ActivityTaskDetailBinding inflateLayout(LayoutInflater layoutInflater) {
        return ActivityTaskDetailBinding.inflate(getLayoutInflater());
    }

    private void showEmojiIcon(boolean showEmoji) {
        if (showEmoji) {
            Glide.with(getContext()).load(2131231587).into(this.viewMessageInputBinding.emoji);
        } else {
            Glide.with(getContext()).load(2131231625).into(this.viewMessageInputBinding.emoji);
        }
    }

    private void enableActionMode(int position) {
        if (this.actionMode == null) {
            this.actionMode = startSupportActionMode(this.actionModeCallback);
        }
        toggleSelection(position);
    }

    private void toggleSelection(int position) {
        MessageAdapter messageAdapter = this.messageAdapter;
        if (messageAdapter == null) {
            return;
        }
        messageAdapter.toggleSelection(position);
        int selectedItemCount = this.messageAdapter.getSelectedItemCount();
        if (selectedItemCount == 0) {
            androidx.appcompat.view.ActionMode actionMode = this.actionMode;
            if (actionMode != null) {
                actionMode.finish();
                return;
            }
            return;
        }
        this.actionMode.setTitle(String.valueOf(selectedItemCount));
        this.actionMode.invalidate();
    }

    private class ActionModeCallback implements ActionMode.Callback {
        private ActionModeCallback() {
        }

        public boolean onCreateActionMode(androidx.appcompat.view.ActionMode mode, Menu menu) {
            mode.getMenuInflater().inflate(2131689472, menu);
            return true;
        }

        public boolean onPrepareActionMode(androidx.appcompat.view.ActionMode mode, Menu menu) {
            MenuItem findItem = menu.findItem(2131364350);
            MenuItem findItem2 = menu.findItem(2131362638);
            MenuItem findItem3 = menu.findItem(2131363276);
            MenuItem findItem4 = menu.findItem(2131364587);
            MenuItem findItem5 = menu.findItem(2131362539);
            boolean z = true;
            if (ChatActivity.this.messageAdapter != null && ChatActivity.this.messageAdapter.getSelectedItems().size() > 1) {
                findItem.setVisible(false);
                findItem2.setVisible(false);
                findItem3.setVisible(false);
                findItem4.setVisible(false);
                findItem5.setVisible(false);
            } else {
                findItem.setVisible(true);
                if (ChatActivity.this.messageAdapter != null) {
                    if (ChatActivity.this.messageAdapter.getSelectedItems().size() == 1) {
                        GroupModel groupModel = ChatActivity.this.messageAdapter.getSelectedItems().get(0);
                        if ((groupModel.getSenderId() + groupModel.getSenderType()).equals(ChatActivity.this.accountId + "")) {
                            findItem3.setVisible(true);
                            findItem2.setVisible(true);
                        } else {
                            findItem2.setVisible(false);
                            findItem3.setVisible(false);
                        }
                        findItem3.setVisible(false);
                        findItem.setVisible(false);
                        String messageType = ChatActivity.this.messageAdapter.getSelectedItems().get(0).getMessageType();
                        if (!messageType.equals(Constants.CHAT_TYPE.AUDIO.name()) && !messageType.equals(Constants.CHAT_TYPE.IMAGE.name()) && !messageType.equals(Constants.CHAT_TYPE.VIDEO.name()) && !messageType.equals(Constants.CHAT_TYPE.DOCUMENT.name()) && !messageType.equals(Constants.CHAT_TYPE.TEXT.name()) && !messageType.equals(Constants.CHAT_TYPE.LOCATION.name())) {
                            z = false;
                        }
                        findItem4.setVisible(z);
                        findItem5.setVisible(messageType.equals(Constants.CHAT_TYPE.TEXT.name()));
                    } else {
                        findItem4.setVisible(false);
                    }
                }
            }
            return false;
        }

        public boolean onActionItemClicked(androidx.appcompat.view.ActionMode mode, MenuItem item) {
            int itemId = item.getItemId();
            if (itemId == 2131361941) {
                ChatActivity.this.forwardMessage();
                return true;
            }
            if (itemId == 2131364350) {
                if (ChatActivity.this.messageAdapter != null && ChatActivity.this.messageAdapter.getSelectedItems().size() == 1) {
                    ChatActivity chatActivity = ChatActivity.this;
                    chatActivity.onReplyClick(chatActivity.messageAdapter.getSelectedItems().get(0), 0);
                    mode.finish();
                    onDestroyActionMode(mode);
                }
                return true;
            }
            if (itemId == 2131362638) {
                if (ChatActivity.this.messageAdapter != null && ChatActivity.this.messageAdapter.getSelectedItems().size() == 1) {
                    ChatActivity chatActivity2 = ChatActivity.this;
                    chatActivity2.onLongClick(chatActivity2.messageAdapter.getSelectedItems().get(0), 0);
                }
                return true;
            }
            if (itemId == 2131363276) {
                if (ChatActivity.this.messageAdapter != null && ChatActivity.this.messageAdapter.getSelectedItems().size() == 1) {
                    ChatActivity chatActivity3 = ChatActivity.this;
                    chatActivity3.onInfoClick(chatActivity3.messageAdapter.getSelectedItems().get(0), 0);
                    mode.finish();
                    onDestroyActionMode(mode);
                }
                return true;
            }
            if (itemId == 2131364587) {
                if (ChatActivity.this.messageAdapter != null && ChatActivity.this.messageAdapter.getSelectedItems().size() == 1) {
                    ChatActivity chatActivity4 = ChatActivity.this;
                    chatActivity4.onShareClick(chatActivity4.messageAdapter.getSelectedItems().get(0), 0);
                    mode.finish();
                    onDestroyActionMode(mode);
                }
                return true;
            }
            if (itemId == 2131361936) {
                ChatActivity.this.messageAdapter.clearSelections();
                if (ChatActivity.this.actionMode != null) {
                    ChatActivity.this.actionMode.finish();
                }
                return true;
            }
            if (itemId != 2131362539) {
                return false;
            }
            if (ChatActivity.this.messageAdapter != null && ChatActivity.this.messageAdapter.getSelectedItems().size() == 1) {
                ?? r5 = ChatActivity.this;
                Helper.copyToClipboard(r5, ((ChatActivity) r5).messageAdapter.getSelectedItems().get(0).getMessage());
                mode.finish();
                onDestroyActionMode(mode);
            }
            return true;
        }

        public void onDestroyActionMode(androidx.appcompat.view.ActionMode mode) {
            ChatActivity.this.messageAdapter.clearSelections();
            ChatActivity.this.actionMode = null;
        }
    }

    public void forwardMessage() {
        ArrayList<GroupModel> selectedItems;
        if (this.messageAdapter.getSelectedItemCount() == 0) {
            Toast.makeText((Context) this, (CharSequence) getString(2131953004), 0).show();
            return;
        }
        MessageAdapter messageAdapter = this.messageAdapter;
        if (messageAdapter == null || (selectedItems = messageAdapter.getSelectedItems()) == null) {
            return;
        }
        selectedItems.isEmpty();
    }

    public void showGiftRequestDialog(final GiftRequestModel model) {
        try {
            Dialog dialog = this.alertDialog;
            if (dialog == null || !dialog.isShowing()) {
                this.alertDialog = new Dialog(this);
                GiftPopupBinding inflate = GiftPopupBinding.inflate(LayoutInflater.from(this));
                this.alertDialog.setContentView(inflate.getRoot());
                this.alertDialog.setCancelable(false);
                inflate.popupClose.setVisibility(8);
                inflate.popupClose.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        ChatActivity.this.alertDialog.dismiss();
                    }
                });
                Glide.with(getContext()).load(model.getGift().getUrl()).into(inflate.giftImage);
                CircularTimerView circularTimerView = inflate.progressCircular;
                circularTimerView.setProgress(0.0f);
                circularTimerView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        ChatActivity.this.alertDialog.dismiss();
                    }
                });
                circularTimerView.setCircularTimerListener(new CircularTimerListener() {
                    public String updateDataOnTick(long remainingTimeInMs) {
                        return "X";
                    }

                    public void onTimerFinished() {
                        ChatActivity.this.alertDialog.dismiss();
                    }
                }, 15L, TimeFormatEnum.SECONDS, 10L);
                circularTimerView.startTimer();
                inflate.coinPrice.setText(Helper.getSign(false) + model.getGift().getAmount());
                inflate.sendGift.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public final void onClick(View view) {
                        ChatActivity.this.m1024lambda$showGiftRequestDialog$67$appcallpeuichatChatActivity(model, view);
                    }
                });
                ((Window) Objects.requireNonNull(this.alertDialog.getWindow())).clearFlags(131080);
                this.alertDialog.show();
                this.alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
            }
        } catch (Exception e) {
            Timber.e(e, "showChangePasswordDialog", new Object[0]);
        }
    }

    void m1024lambda$showGiftRequestDialog$67$appcallpeuichatChatActivity(GiftRequestModel giftRequestModel, View view) {
        sendGift(giftRequestModel.getGift());
        this.alertDialog.dismiss();
    }

    public void showGiftReceivedDialog(GiftRequestModel model) {
        try {
            Dialog dialog = this.alertDialog;
            if (dialog == null || !dialog.isShowing()) {
                this.alertDialog = new Dialog(this);
                GiftReceivedPopupBinding inflate = GiftReceivedPopupBinding.inflate(LayoutInflater.from(this));
                this.alertDialog.setContentView(inflate.getRoot());
                this.alertDialog.setCancelable(false);
                inflate.popupClose.setVisibility(8);
                inflate.popupClose.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        ChatActivity.this.alertDialog.dismiss();
                    }
                });
                inflate.cancel.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        ChatActivity.this.alertDialog.dismiss();
                    }
                });
                Glide.with(this).load(model.getGift().getUrl()).into(inflate.giftImage);
                inflate.coinPrice.setText(Helper.getSign(false) + model.getGift().getAmount());
                ((Window) Objects.requireNonNull(this.alertDialog.getWindow())).clearFlags(131080);
                this.alertDialog.show();
                this.alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
            }
        } catch (Exception e) {
            Timber.e(e, "showChangePasswordDialog", new Object[0]);
        }
    }
}