导航菜单

页面标题

页面副标题

Biko v2.0.23 - ZegoVideoCallActivity.java 源代码

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

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


package app.callpe.ui.call;

import android.app.Activity;
import android.app.Application;
import android.app.Dialog;
import android.app.PictureInPictureParams;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.media.AudioManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.text.Editable;
import android.util.Rational;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.TextureView;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.activity.ComponentActivity;
import androidx.activity.result.ActivityResult;
import androidx.activity.result.ActivityResultCallback;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContract;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.AppCompatEditText;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LifecycleOwnerKt;
import androidx.lifecycle.ViewModelLazy;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelStore;
import androidx.lifecycle.viewmodel.CreationExtras;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.recyclerview.widget.RecyclerView;
import app.callpe.App;
import app.callpe.adapters.VideoMessageAdapter;
import app.callpe.common.agora.VideoCallEvent;
import app.callpe.common.agora.VideoCallEventType;
import app.callpe.common.utils.Constants;
import app.callpe.common.utils.Helper;
import app.callpe.common.utils.RxBus;
import app.callpe.common.utils.ZEGOSDKConstants;
import app.callpe.common.utils.custom.BackPressEditText;
import app.callpe.common.utils.custom.CustomLinearLayoutManager;
import app.callpe.common.utils.extensions.ActivityExtKt;
import app.callpe.common.utils.extensions.NumberExtKt;
import app.callpe.common.utils.extensions.ViewExtKt;
import app.callpe.common.utils.helper_functions.CrashLogHelper;
import app.callpe.common.utils.helper_functions.DialogHelper;
import app.callpe.common.utils.helper_functions.Utils;
import app.callpe.common.utils.helper_functions.VolumeManager;
import app.callpe.common.utils.sharedpref.PrefKeys;
import app.callpe.common.utils.sharedpref.SharedPref;
import app.callpe.data.model.GiftRequestModel;
import app.callpe.data.model.StreamerModel;
import app.callpe.data.model.VideoCallGameRequestModel;
import app.callpe.data.model.VideoDetailModel;
import app.callpe.data.model.VideoMessageModel;
import app.callpe.databinding.ActivityZegoVideoCallBinding;
import app.callpe.databinding.GiftPopupBinding;
import app.callpe.rtc.RtcManagerFactory;
import app.callpe.rtc.components.LocalRtcVideoView;
import app.callpe.rtc.components.RemoteRtcVideoView;
import app.callpe.service.HeadsUpNotificationService;
import app.callpe.service.VideoCallService;
import app.callpe.ui.bottomsheet.GiftBottomSheet;
import app.callpe.ui.dialog.RechargeDialog;
import app.callpe.ui.livestreaming.bottomsheet.GameRequestDialog;
import app.callpe.ui.login.LoginActivity;
import app.callpe.ui.payment.PaymentDetailsActivity;
import app.callpe.ui.payment.WalletActivity;
import app.callpe.ui.user.StreamerReviewActivity;
import app.callpe.ui.user.UserDetailsActivity;
import app.callpe.ui.user.games.common.GameUtils;
import app.module.common.interfaces.FaceDetectionHandler;
import app.module.common.interfaces.SDKInitialise;
import app.module.common.model.RtcStream;
import app.module.common.model.rtc.RtcRoomDetails;
import app.module.common.rtcmanager.RtcManager;
import app.module.common.rtcmanager.handlers.RtcEventHandler;
import app.module.common.utils.RtcUpdateType;
import com.airbnb.lottie.LottieAnimationView;
import com.asynctaskcoffee.audiorecorder.R;
import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;
import com.facebook.internal.NativeProtocol;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.permissionx.guolindev.databinding.PermissionxDefaultDialogLayoutBinding;
import com.permissionx.guolindev.databinding.PermissionxPermissionItemBinding;
import com.uzairiqbal.circulartimerview.CircularTimerListener;
import com.uzairiqbal.circulartimerview.CircularTimerView;
import com.uzairiqbal.circulartimerview.TimeFormatEnum;
import com.vdx.sud.SudGameActivity;
import com.zegocloud.zegosdk.ZegoSdkManager;
import com.zegocloud.zegosdk.beauty.components.BeautyDialog;
import dagger.hilt.android.AndroidEntryPoint;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CancellationException;
import javax.inject.Inject;
import kotlin.Lazy;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.collections.ArraysKt;
import kotlin.collections.CollectionsKt;
import kotlin.coroutines.CoroutineContext;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Reflection;
import kotlin.text.StringsKt;
import kotlinx.coroutines.BuildersKt;
import kotlinx.coroutines.CompletableJob;
import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.CoroutineScopeKt;
import kotlinx.coroutines.CoroutineStart;
import kotlinx.coroutines.Dispatchers;
import kotlinx.coroutines.Job;
import kotlinx.coroutines.JobKt;
import kotlinx.coroutines.SupervisorKt;
import org.json.JSONObject;
import timber.log.Timber;

@Metadata(d1 = {"\u0000È\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010!\n\u0002\u0010\u0007\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\n\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\n\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0006\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010 \n\u0002\b\t\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0014\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\u0002\n\u0002\b$\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0011\n\u0000\n\u0002\u0010\u0015\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0011\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0014\b\u0007\u0018\u0000 û\u00012\u00020\u00012\u00020\u0002:\u0004û\u0001ü\u0001B\u0005¢\u0006\u0002\u0010\u0003J\n\u0010\u0085\u0001\u001a\u00030\u0086\u0001H\u0002J\u0013\u0010\u0087\u0001\u001a\u00030\u0086\u00012\u0007\u0010\u0088\u0001\u001a\u00020\u0012H\u0002J\u0013\u0010\u0089\u0001\u001a\u00030\u0086\u00012\u0007\u0010\u008a\u0001\u001a\u00020$H\u0002J\n\u0010\u008b\u0001\u001a\u00030\u0086\u0001H\u0002J\n\u0010\u008c\u0001\u001a\u00030\u0086\u0001H\u0002J\n\u0010\u008d\u0001\u001a\u00030\u0086\u0001H\u0016J\n\u0010\u008e\u0001\u001a\u00030\u0086\u0001H\u0002J\n\u0010\u008f\u0001\u001a\u00030\u0086\u0001H\u0002J\n\u0010\u0090\u0001\u001a\u00030\u0086\u0001H\u0002J\u0015\u0010\u0091\u0001\u001a\u00030\u0086\u00012\t\u0010\u0092\u0001\u001a\u0004\u0018\u00010MH\u0002J\n\u0010\u0093\u0001\u001a\u00030\u0086\u0001H\u0003J\n\u0010\u0094\u0001\u001a\u00030\u0086\u0001H\u0002J\u0013\u0010\u0095\u0001\u001a\u00030\u0086\u00012\u0007\u0010\u0096\u0001\u001a\u00020PH\u0002J\u0013\u0010\u0097\u0001\u001a\u00030\u0086\u00012\u0007\u0010\u0098\u0001\u001a\u00020$H\u0002J\n\u0010\u0099\u0001\u001a\u00030\u0086\u0001H\u0002J\n\u0010\u009a\u0001\u001a\u00030\u0086\u0001H\u0002J\u0012\u0010\u009b\u0001\u001a\u00030\u0086\u00012\u0006\u0010\u001d\u001a\u00020\u0007H\u0002J\n\u0010\u009c\u0001\u001a\u00030\u0086\u0001H\u0002J\n\u0010\u009d\u0001\u001a\u00030\u0086\u0001H\u0002J\n\u0010\u009e\u0001\u001a\u00030\u0086\u0001H\u0002J\t\u0010\u009f\u0001\u001a\u00020$H\u0002J\n\u0010 \u0001\u001a\u00030\u0086\u0001H\u0002J\n\u0010¡\u0001\u001a\u00030\u0086\u0001H\u0002J\n\u0010¢\u0001\u001a\u00030\u0086\u0001H\u0002J\t\u0010£\u0001\u001a\u00020\u0017H\u0002J\t\u0010¤\u0001\u001a\u00020\u0017H\u0002J\n\u0010¥\u0001\u001a\u00030\u0086\u0001H\u0017J\n\u0010¦\u0001\u001a\u00030\u0086\u0001H\u0016J\n\u0010§\u0001\u001a\u00030\u0086\u0001H\u0002J\n\u0010¨\u0001\u001a\u00030\u0086\u0001H\u0003J\u0016\u0010©\u0001\u001a\u00030\u0086\u00012\n\u0010ª\u0001\u001a\u0005\u0018\u00010«\u0001H\u0016J\n\u0010¬\u0001\u001a\u00030\u0086\u0001H\u0014J\u0014\u0010\u00ad\u0001\u001a\u00030\u0086\u00012\b\u0010®\u0001\u001a\u00030¯\u0001H\u0016J\u0014\u0010°\u0001\u001a\u00030\u0086\u00012\b\u0010®\u0001\u001a\u00030¯\u0001H\u0016J\n\u0010±\u0001\u001a\u00030\u0086\u0001H\u0014J\u001d\u0010²\u0001\u001a\u00030\u0086\u00012\u0007\u0010³\u0001\u001a\u00020$2\b\u0010´\u0001\u001a\u00030µ\u0001H\u0017J2\u0010¶\u0001\u001a\u00030\u0086\u00012\u0007\u0010·\u0001\u001a\u00020\u00122\r\u0010V\u001a\t\u0012\u0004\u0012\u00020\u00070¸\u00012\b\u0010¹\u0001\u001a\u00030º\u0001H\u0016¢\u0006\u0003\u0010»\u0001J\n\u0010¼\u0001\u001a\u00030\u0086\u0001H\u0014J\n\u0010½\u0001\u001a\u00030\u0086\u0001H\u0016JD\u0010¾\u0001\u001a\u00030\u0086\u00012\u0007\u0010¿\u0001\u001a\u00020\u00072\b\u0010À\u0001\u001a\u00030Á\u00012\u001b\u0010Â\u0001\u001a\u0016\u0012\u0005\u0012\u00030Ä\u00010Ã\u0001j\n\u0012\u0005\u0012\u00030Ä\u0001`Å\u00012\b\u0010Æ\u0001\u001a\u00030Ç\u0001H\u0002J\n\u0010È\u0001\u001a\u00030\u0086\u0001H\u0014J\u0013\u0010É\u0001\u001a\u00030\u0086\u00012\u0007\u0010Ê\u0001\u001a\u00020\u0007H\u0002J\n\u0010Ë\u0001\u001a\u00030\u0086\u0001H\u0002J\u0017\u0010Ì\u0001\u001a\u00020$2\f\u0010V\u001a\b\u0012\u0004\u0012\u00020\u00070WH\u0002J\u0013\u0010Í\u0001\u001a\u00030\u0086\u00012\u0007\u0010Î\u0001\u001a\u00020$H\u0002J\n\u0010Ï\u0001\u001a\u00030\u0086\u0001H\u0002J\u0018\u0010Ð\u0001\u001a\u00030\u0086\u00012\f\u0010V\u001a\b\u0012\u0004\u0012\u00020\u00070WH\u0002J\n\u0010Ñ\u0001\u001a\u00030\u0086\u0001H\u0002J\n\u0010Ò\u0001\u001a\u00030\u0086\u0001H\u0002J\n\u0010Ó\u0001\u001a\u00030\u0086\u0001H\u0002J\n\u0010Ô\u0001\u001a\u00030\u0086\u0001H\u0002J\n\u0010Õ\u0001\u001a\u00030\u0086\u0001H\u0002J\u0017\u0010Ö\u0001\u001a\u00020$2\f\u0010V\u001a\b\u0012\u0004\u0012\u00020\u00070WH\u0002J\u0014\u0010×\u0001\u001a\u00030\u0086\u00012\b\u0010Ø\u0001\u001a\u00030Ù\u0001H\u0002J\u0014\u0010Ú\u0001\u001a\u00030\u0086\u00012\b\u0010Û\u0001\u001a\u00030¯\u0001H\u0002J\u0012\u0010Ü\u0001\u001a\u00030\u0086\u00012\b\u0010Û\u0001\u001a\u00030Ý\u0001J\u0012\u0010Þ\u0001\u001a\u00030\u0086\u00012\b\u0010Û\u0001\u001a\u00030Ý\u0001J\n\u0010ß\u0001\u001a\u00030\u0086\u0001H\u0002J\u0013\u0010k\u001a\u00030\u0086\u00012\b\u0010Ø\u0001\u001a\u00030Ù\u0001H\u0002J\n\u0010à\u0001\u001a\u00030\u0086\u0001H\u0002J\u001f\u0010á\u0001\u001a\u00030\u0086\u00012\r\u0010V\u001a\t\u0012\u0004\u0012\u00020\u00070¸\u0001H\u0002¢\u0006\u0003\u0010â\u0001J2\u0010ã\u0001\u001a\u00030\u0086\u00012\n\u0010ä\u0001\u001a\u0005\u0018\u00010å\u00012\u0007\u0010æ\u0001\u001a\u00020\u00072\u0007\u0010ç\u0001\u001a\u00020\u00072\n\u0010è\u0001\u001a\u0005\u0018\u00010é\u0001J\n\u0010ê\u0001\u001a\u00030\u0086\u0001H\u0002J\n\u0010ë\u0001\u001a\u00030\u0086\u0001H\u0002J#\u0010ì\u0001\u001a\u00030\u0086\u00012\u0006\u0010{\u001a\u00020|2\u0006\u0010\"\u001a\u00020|2\u0007\u0010í\u0001\u001a\u00020\u0007H\u0002J\u0013\u0010î\u0001\u001a\u00030\u0086\u00012\u0007\u0010ï\u0001\u001a\u00020\u0007H\u0002J\n\u0010ð\u0001\u001a\u00030\u0086\u0001H\u0002J\n\u0010ñ\u0001\u001a\u00030\u0086\u0001H\u0002J\u0015\u0010ò\u0001\u001a\u00030\u0086\u00012\t\u0010ï\u0001\u001a\u0004\u0018\u00010\u0007H\u0002J\n\u0010ó\u0001\u001a\u00030\u0086\u0001H\u0002J\n\u0010ô\u0001\u001a\u00030\u0086\u0001H\u0002J\n\u0010õ\u0001\u001a\u00030\u0086\u0001H\u0002J\n\u0010ö\u0001\u001a\u00030\u0086\u0001H\u0002J\n\u0010÷\u0001\u001a\u00030\u0086\u0001H\u0002J\n\u0010ø\u0001\u001a\u00030\u0086\u0001H\u0002J\n\u0010ù\u0001\u001a\u00030\u0086\u0001H\u0002J\n\u0010ú\u0001\u001a\u00030\u0086\u0001H\u0002J\t\u0010w\u001a\u00030\u0086\u0001H\u0002R\u0010\u0010\u0004\u001a\u0004\u0018\u00010\u0005X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u0006\u001a\u0004\u0018\u00010\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\b\u001a\u00020\tX\u0082.¢\u0006\u0002\n\u0000R\u0010\u0010\n\u001a\u0004\u0018\u00010\u000bX\u0082\u000e¢\u0006\u0002\n\u0000R\u0014\u0010\f\u001a\u00020\u00058BX\u0082\u0004¢\u0006\u0006\u001a\u0004\b\r\u0010\u000eR\u000e\u0010\u000f\u001a\u00020\u0010X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0011\u001a\u00020\u0012X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0013\u001a\u00020\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u0014\u001a\u0004\u0018\u00010\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0015\u001a\u00020\u0012X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u0016\u001a\u0004\u0018\u00010\u0017X\u0082\u000e¢\u0006\u0002\n\u0000R\u0014\u0010\u0018\u001a\b\u0012\u0004\u0012\u00020\u001a0\u0019X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u001b\u001a\u00020\u0012X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u001c\u001a\u0004\u0018\u00010\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u001d\u001a\u00020\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u001e\u001a\u00020\u0012X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u001f\u001a\u0004\u0018\u00010\tX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010 \u001a\u0004\u0018\u00010!X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\"\u001a\u00020\u0012X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010#\u001a\u00020$X\u0082\u000e¢\u0006\u0002\n\u0000R\u001a\u0010%\u001a\u00020\u0012X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b&\u0010'\"\u0004\b(\u0010)R\u001a\u0010*\u001a\u00020\u0012X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b+\u0010'\"\u0004\b,\u0010)R\u0010\u0010-\u001a\u0004\u0018\u00010\u0017X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010.\u001a\u0004\u0018\u00010/X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u00100\u001a\u000201X\u0082\u0004¢\u0006\u0002\n\u0000R\u0010\u00102\u001a\u0004\u0018\u000103X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u00104\u001a\u0004\u0018\u00010\u0017X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u00105\u001a\u0004\u0018\u000106X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u00107\u001a\u00020$X\u0082\u000e¢\u0006\u0002\n\u0000R\u001a\u00108\u001a\u00020$X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b8\u00109\"\u0004\b:\u0010;R\u000e\u0010<\u001a\u00020$X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010=\u001a\u00020$X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010>\u001a\u00020$X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010?\u001a\u00020$X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010@\u001a\u00020AX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010B\u001a\u00020$X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010C\u001a\u00020\u0012X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010D\u001a\u0004\u0018\u00010\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010E\u001a\u0004\u0018\u00010FX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010G\u001a\u0004\u0018\u00010HX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010I\u001a\u00020\u0012X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010J\u001a\u0004\u0018\u00010KX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010L\u001a\u0004\u0018\u00010MX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010N\u001a\u00020$X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010O\u001a\u00020PX\u0082\u000e¢\u0006\u0002\n\u0000R\u001c\u0010Q\u001a\u0010\u0012\f\u0012\n S*\u0004\u0018\u00010M0M0RX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010T\u001a\u00020\u001aX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010U\u001a\u00020\u001aX\u0082\u000e¢\u0006\u0002\n\u0000R\u0017\u0010V\u001a\b\u0012\u0004\u0012\u00020\u00070W¢\u0006\b\n\u0000\u001a\u0004\bX\u0010YR\u000e\u0010Z\u001a\u00020\u0012X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010[\u001a\u00020\u0012X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\\\u001a\u00020\u0012X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010]\u001a\u0004\u0018\u00010\u0017X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010^\u001a\u000201X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010_\u001a\u00020\u0012X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010`\u001a\u0004\u0018\u00010aX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010b\u001a\u0004\u0018\u00010cX\u0082\u000e¢\u0006\u0002\n\u0000R\u001e\u0010d\u001a\u00020e8\u0006@\u0006X\u0087.¢\u0006\u000e\n\u0000\u001a\u0004\bf\u0010g\"\u0004\bh\u0010iR\u000e\u0010j\u001a\u000201X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010k\u001a\u00020$X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010l\u001a\u00020\u0012X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010m\u001a\u000201X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010n\u001a\u00020AX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010o\u001a\u00020\u0012X\u0082D¢\u0006\u0002\n\u0000R\u000e\u0010p\u001a\u00020\u0012X\u0082\u000e¢\u0006\u0002\n\u0000R$\u0010q\u001a\u00020\u00078\u0006@\u0006X\u0087.¢\u0006\u0014\n\u0000\u0012\u0004\br\u0010\u0003\u001a\u0004\bs\u0010t\"\u0004\bu\u0010vR\u0010\u0010w\u001a\u0004\u0018\u00010\u0017X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010x\u001a\u000201X\u0082\u0004¢\u0006\u0002\n\u0000R\u0010\u0010y\u001a\u0004\u0018\u00010zX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010{\u001a\u00020|X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010}\u001a\u0004\u0018\u00010~X\u0082\u000e¢\u0006\u0002\n\u0000R \u0010\u007f\u001a\u00030\u0080\u00018BX\u0082\u0084\u0002¢\u0006\u0010\n\u0006\b\u0083\u0001\u0010\u0084\u0001\u001a\u0006\b\u0081\u0001\u0010\u0082\u0001¨\u0006ý\u0001"}, d2 = {"Lapp/callpe/ui/call/ZegoVideoCallActivity;", "Lapp/callpe/ui/call/BaseZegoCallActivity;", "Lapp/callpe/ui/livestreaming/bottomsheet/GameRequestDialog$RequestDialogListener;", "()V", "_binding", "Lapp/callpe/databinding/ActivityZegoVideoCallBinding;", "accessToken", "", "alertDialog", "Landroid/app/Dialog;", "beautyDialog", "Lcom/zegocloud/zegosdk/beauty/components/BeautyDialog;", "binding", "getBinding", "()Lapp/callpe/databinding/ActivityZegoVideoCallBinding;", "broadcastReceiver", "Landroid/content/BroadcastReceiver;", "callPingDuration", "", "callType", "caller", "closeDurationCount", "confidenceScoreTimer", "Lkotlinx/coroutines/Job;", "confidenceScores", "", "", "consecutiveFailedAttempts", "currentGameRoomId", "currentSDK", "delayInSeconds", "dialog", "disposable", "Lio/reactivex/disposables/Disposable;", "egressFrequency", "ended", "", "faceDetectionDuration", "getFaceDetectionDuration", "()I", "setFaceDetectionDuration", "(I)V", "faceDetectionFrequency", "getFaceDetectionFrequency", "setFaceDetectionFrequency", "gameJob", "gameRequestDialog", "Lapp/callpe/ui/livestreaming/bottomsheet/GameRequestDialog;", "gameScope", "Lkotlinx/coroutines/CoroutineScope;", "imageUploadHandler", "Landroid/os/Handler;", "imageUploadJob", "imageUploadRunnable", "Ljava/lang/Runnable;", "isBroadCastScreen", "isFaceDetectionEnabled", "()Z", "setFaceDetectionEnabled", "(Z)V", "isLudoGameEnabled", "isPlayScreenView", "isPopUpShown", "isScreenshotsEnabled", "job", "Lkotlinx/coroutines/CompletableJob;", "ludoButtonTimerFinished", "ludoTimerLeft", "mChannel", "mLocalPreviewLayout", "Lapp/callpe/rtc/components/LocalRtcVideoView;", "mMuteBtn", "Landroidx/appcompat/widget/AppCompatImageView;", "mPeerUid", "mRemotePreviewLayout", "Lapp/callpe/rtc/components/RemoteRtcVideoView;", "mServiceIntent", "Landroid/content/Intent;", "moderating", "netWinning", "", "openSettingsLauncher", "Landroidx/activity/result/ActivityResultLauncher;", "kotlin.jvm.PlatformType", "originalLocalLayoutX", "originalLocalLayoutY", NativeProtocol.RESULT_ARGS_PERMISSIONS, "", "getPermissions", "()Ljava/util/List;", "pipDenominator", "pipNumerator", "reconnectingTime", "reconnectionJob", "reconnectionScope", "retryCount", "rtcEventHandler", "Lapp/module/common/rtcmanager/handlers/RtcEventHandler;", "rtcManager", "Lapp/module/common/rtcmanager/RtcManager;", "rxBus", "Lapp/callpe/common/utils/RxBus;", "getRxBus", "()Lapp/callpe/common/utils/RxBus;", "setRxBus", "(Lapp/callpe/common/utils/RxBus;)V", "scope", "showLudoButtonForStreamer", "showLudoCount", "timeScope", "timerJob", "touchThreshold", "userCallRetryCount", "userId", "getUserId$annotations", "getUserId", "()Ljava/lang/String;", "setUserId", "(Ljava/lang/String;)V", "userJoinJob", "userJoinScope", "videoCallService", "Lapp/callpe/service/VideoCallService;", "videoId", "", "videoMessageAdapter", "Lapp/callpe/adapters/VideoMessageAdapter;", "viewModel", "Lapp/callpe/ui/call/CallViewModel;", "getViewModel", "()Lapp/callpe/ui/call/CallViewModel;", "viewModel$delegate", "Lkotlin/Lazy;", "adjustLocalLayoutPosition", "", "closeScreen", "randomCallDuration", "enableMicrophone", "enableMic", "enablePip", "endCall", "finish", "fromCallNotification", "fromNotification", "getSharedPrefValues", "getVideoDetails", "intent", "handleDragging", "handleLudoGameBtnVisibility", "handleLudoGameClicks", "actualBalance", "handlePipModel", "inPictureInPictureMode", "hideBottomBar", "initRtcSDK", "initStreamerBeauty", "initUI", "initVideo", "initVideoStopLayout", "isAudioCall", "listenFaceDetectionEvent", "listenRtcEventHandler", "observeCallEndFromNotification", "observeEvent", "observePreviewSwitchEvent", "onBackPressed", "onBottomSheetDismissed", "onButtonClicked", "onClicks", "onCreate", "savedInstanceState", "Landroid/os/Bundle;", "onDestroy", "onGameRequestAccepted", "requestModel", "Lapp/callpe/data/model/VideoCallGameRequestModel;", "onGameRequestRejected", "onGlobalLayoutCompleted", "onPictureInPictureModeChanged", "isInPictureInPictureMode", "newConfig", "Landroid/content/res/Configuration;", "onRequestPermissionsResult", "requestCode", "", "grantResults", "", "(I[Ljava/lang/String;[I)V", "onResume", "onStart", "onStreamUpdate", "roomID", "updateType", "Lapp/module/common/utils/RtcUpdateType;", "streamList", "Ljava/util/ArrayList;", "Lapp/module/common/model/RtcStream;", "Lkotlin/collections/ArrayList;", "extendedData", "Lorg/json/JSONObject;", "onUserLeaveHint", "openGameScreen", "gameRoomId", "openRechargePopup", "permissionsGranted", "reconnectingBox", "reconnecting", "registerReceiver", "requestPermissionsIfNeeded", "resetBeauty", "resetToOriginalPosition", "sendAverageConfidenceScore", "setupLocalPreview", "setupRv", "shouldShowRationaleForPermissions", "showCallInfo", "data", "Lapp/callpe/data/model/VideoDetailModel;", "showGameRequestPopup", "model", "showGiftReceivedDialog", "Lapp/callpe/data/model/GiftRequestModel;", "showGiftRequestDialog", "showLowBalancePopup", "showOnLockScreen", "showOpenSettingDialog", "([Ljava/lang/String;)V", "showReasonDialog", "context", "Landroid/content/Context;", "title", "message", "listener", "Lapp/callpe/common/utils/helper_functions/DialogHelper$ConfirmationListener;", "starServiceFunc", "startConfidenceScoreTimer", "startImageUploadLoop", "source", "startPlayScreenStream", "streamID", "startPublishScreen", "stopImageUploadLoop", "stopPlayScreenStream", "stopPublishScreen", "stopServiceFunc", "stopSudGameIfRunning", "switchNonCameraView", "switchNonCameraViewForStreamer", "switchPreview", "touchEventClicked", "unRegisterReceiver", "Companion", "VideoCallStatus", "app_bikoRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
@AndroidEntryPoint
public final class ZegoVideoCallActivity extends Hilt_ZegoVideoCallActivity implements GameRequestDialog.RequestDialogListener {
    public static final int MAX_RETRY_COUNT = 2;
    public static final int PERMISSION_RQUESTED = 1010;
    public static final int STREAMER_UID = 1;
    public static final String STREAMER_USER_GAME_JOIN_REQUEST = "STREAMER_USER_GAME_JOIN_REQUEST";
    public static final String STREAMER_USER_GAME_REQUEST_ACCEPT = "STREAMER_USER_GAME_REQUEST_ACCEPT";
    public static final String STREAMER_USER_GAME_REQUEST_REJECT = "STREAMER_USER_GAME_REQUEST_REJECT";
    public static final int USER_UID = 2;
    private ActivityZegoVideoCallBinding _binding;
    private String accessToken;
    private Dialog alertDialog;
    private BeautyDialog beautyDialog;
    private final BroadcastReceiver broadcastReceiver;
    private String caller;
    private int closeDurationCount;
    private Job confidenceScoreTimer;
    private int consecutiveFailedAttempts;
    private String currentGameRoomId;
    private String currentSDK;
    private Dialog dialog;
    private Disposable disposable;
    private int egressFrequency;
    private boolean ended;
    private int faceDetectionDuration;
    private int faceDetectionFrequency;
    private Job gameJob;
    private GameRequestDialog gameRequestDialog;
    private final CoroutineScope gameScope;
    private Handler imageUploadHandler;
    private Job imageUploadJob;
    private Runnable imageUploadRunnable;
    private boolean isBroadCastScreen;
    private boolean isFaceDetectionEnabled;
    private boolean isLudoGameEnabled;
    private boolean isPlayScreenView;
    private boolean isPopUpShown;
    private boolean isScreenshotsEnabled;
    private final CompletableJob job;
    private boolean ludoButtonTimerFinished;
    private int ludoTimerLeft;
    private String mChannel;
    private LocalRtcVideoView mLocalPreviewLayout;
    private AppCompatImageView mMuteBtn;
    private int mPeerUid;
    private RemoteRtcVideoView mRemotePreviewLayout;
    private Intent mServiceIntent;
    private boolean moderating;
    private double netWinning;
    private final ActivityResultLauncher<Intent> openSettingsLauncher;
    private float originalLocalLayoutX;
    private float originalLocalLayoutY;
    private final List<String> permissions;
    private int reconnectingTime;
    private Job reconnectionJob;
    private final CoroutineScope reconnectionScope;
    private int retryCount;
    private RtcEventHandler rtcEventHandler;
    private RtcManager rtcManager;

    @Inject
    public RxBus rxBus;
    private final CoroutineScope scope;
    private boolean showLudoButtonForStreamer;
    private int showLudoCount;
    private CoroutineScope timeScope;
    private final CompletableJob timerJob;
    private final int touchThreshold;
    private int userCallRetryCount;

    @Inject
    public String userId;
    private Job userJoinJob;
    private final CoroutineScope userJoinScope;
    private VideoCallService videoCallService;
    private VideoMessageAdapter videoMessageAdapter;

    private final Lazy viewModel;
    private static final String TAG = "ZegoVideoCallActivity";
    private String callType = Constants.VIDEO_CALL;
    private long videoId = -1;
    private int delayInSeconds = 5;
    private int callPingDuration = 2;
    private final List<Float> confidenceScores = new ArrayList();
    private int pipNumerator = 3;
    private int pipDenominator = 4;

    @Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0010\u0010\n\u0002\b\u0005\b\u0086\u0001\u0018\u00002\b\u0012\u0004\u0012\u00020\u00000\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002j\u0002\b\u0003j\u0002\b\u0004j\u0002\b\u0005¨\u0006\u0006"}, d2 = {"Lapp/callpe/ui/call/ZegoVideoCallActivity$VideoCallStatus;", "", "(Ljava/lang/String;I)V", "FAILED", "COMPLETED", "CREATED", "app_bikoRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
    public enum VideoCallStatus {
        FAILED,
        COMPLETED,
        CREATED
    }

    public static void getUserId$annotations() {
    }

    public void onBackPressed() {
    }

    @Override
    public void onBottomSheetDismissed() {
    }

    @Override
    protected void onGlobalLayoutCompleted() {
    }

    public ZegoVideoCallActivity() {
        final ComponentActivity componentActivity = (ComponentActivity) this;
        final Function0 function0 = null;
        this.viewModel = new ViewModelLazy(Reflection.getOrCreateKotlinClass(CallViewModel.class), new Function0<ViewModelStore>() {
            {
                super(0);
            }

            public final ViewModelStore m913invoke() {
                return componentActivity.getViewModelStore();
            }
        }, new Function0<ViewModelProvider.Factory>() {
            {
                super(0);
            }

            public final ViewModelProvider.Factory m912invoke() {
                return componentActivity.getDefaultViewModelProviderFactory();
            }
        }, new Function0<CreationExtras>() {
            {
                super(0);
            }

            public final CreationExtras m914invoke() {
                CreationExtras creationExtras;
                Function0 function02 = function0;
                return (function02 == null || (creationExtras = (CreationExtras) function02.invoke()) == null) ? componentActivity.getDefaultViewModelCreationExtras() : creationExtras;
            }
        });
        CoroutineContext SupervisorJob$default = SupervisorKt.SupervisorJob$default((Job) null, 1, (Object) null);
        this.job = SupervisorJob$default;
        this.scope = CoroutineScopeKt.CoroutineScope(Dispatchers.getMain().plus(SupervisorJob$default));
        this.userJoinScope = CoroutineScopeKt.CoroutineScope(Dispatchers.getMain());
        this.reconnectionScope = CoroutineScopeKt.CoroutineScope(Dispatchers.getMain());
        this.gameScope = CoroutineScopeKt.CoroutineScope(Dispatchers.getMain());
        CoroutineContext SupervisorJob$default2 = SupervisorKt.SupervisorJob$default((Job) null, 1, (Object) null);
        this.timerJob = SupervisorJob$default2;
        this.timeScope = CoroutineScopeKt.CoroutineScope(Dispatchers.getMain().plus(SupervisorJob$default2));
        this.touchThreshold = 10;
        this.currentSDK = "";
        this.permissions = CollectionsKt.listOf(new String[]{"android.permission.CAMERA", "android.permission.RECORD_AUDIO"});
        this.broadcastReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(android.content.Context r13, android.content.Intent r14) {
                throw new UnsupportedOperationException("Method not decompiled: app.callpe.ui.call.ZegoVideoCallActivity$broadcastReceiver$1.onReceive(android.content.Context, android.content.Intent):void");
            }
        };
        ActivityResultLauncher<Intent> registerForActivityResult = registerForActivityResult((ActivityResultContract) new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback() {
            public final void onActivityResult(Object obj) {
                ZegoVideoCallActivity.openSettingsLauncher$lambda$58(ZegoVideoCallActivity.this, (ActivityResult) obj);
            }
        });
        Intrinsics.checkNotNullExpressionValue(registerForActivityResult, "registerForActivityResul…missions)\n        }\n    }");
        this.openSettingsLauncher = registerForActivityResult;
    }

    public final ActivityZegoVideoCallBinding getBinding() {
        ActivityZegoVideoCallBinding activityZegoVideoCallBinding = this._binding;
        Intrinsics.checkNotNull(activityZegoVideoCallBinding);
        return activityZegoVideoCallBinding;
    }

    public final CallViewModel getViewModel() {
        return (CallViewModel) this.viewModel.getValue();
    }

    public final boolean getIsFaceDetectionEnabled() {
        return this.isFaceDetectionEnabled;
    }

    public final void setFaceDetectionEnabled(boolean z) {
        this.isFaceDetectionEnabled = z;
    }

    public final int getFaceDetectionFrequency() {
        return this.faceDetectionFrequency;
    }

    public final void setFaceDetectionFrequency(int i) {
        this.faceDetectionFrequency = i;
    }

    public final int getFaceDetectionDuration() {
        return this.faceDetectionDuration;
    }

    public final void setFaceDetectionDuration(int i) {
        this.faceDetectionDuration = i;
    }

    public final RxBus getRxBus() {
        RxBus rxBus = this.rxBus;
        if (rxBus != null) {
            return rxBus;
        }
        Intrinsics.throwUninitializedPropertyAccessException("rxBus");
        return null;
    }

    public final void setRxBus(RxBus rxBus) {
        Intrinsics.checkNotNullParameter(rxBus, "<set-?>");
        this.rxBus = rxBus;
    }

    public final String getUserId() {
        String str = this.userId;
        if (str != null) {
            return str;
        }
        Intrinsics.throwUninitializedPropertyAccessException("userId");
        return null;
    }

    public final void setUserId(String str) {
        Intrinsics.checkNotNullParameter(str, "<set-?>");
        this.userId = str;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this._binding = ActivityZegoVideoCallBinding.inflate(getLayoutInflater());
        fromCallNotification();
        showOnLockScreen();
        setContentView(getBinding().getRoot());
        initRtcSDK();
        this.mPeerUid = this.isStreamer ? 1 : 2;
        observeCallEndFromNotification();
        getSharedPrefValues();
        getVideoDetails(getIntent());
        observeEvent();
        observePreviewSwitchEvent();
        initUI();
        initVideo();
        userJoinJob();
        onClicks();
        handleDragging();
        hideBottomBar();
        onButtonClicked();
        if (this.videoId != -1) {
            getViewModel().getVideoDetails(this.videoId, true);
        }
        listenFaceDetectionEvent();
    }

    private final void initRtcSDK() {
        listenRtcEventHandler();
        RtcManager currentRtcInstance = RtcManagerFactory.getCurrentRtcInstance();
        this.rtcManager = currentRtcInstance;
        if (currentRtcInstance != null) {
            currentRtcInstance.setEventHandler(this.rtcEventHandler);
        }
        if (this.rtcManager == null) {
            finish();
        }
        RtcManager rtcManager = this.rtcManager;
        if (rtcManager != null) {
            Application application = getApplication();
            Intrinsics.checkNotNullExpressionValue(application, "application");
            long j = ZEGOSDKConstants.appID;
            String str = ZEGOSDKConstants.appSign;
            Intrinsics.checkNotNullExpressionValue(str, "appSign");
            rtcManager.initSDK(application, j, str, "app.b1k0", new SDKInitialise() {
                @Override
                public final void initialised() {
                    ZegoVideoCallActivity.initRtcSDK$lambda$1(ZegoVideoCallActivity.this);
                }
            });
        }
    }

    public static final void initRtcSDK$lambda$1(ZegoVideoCallActivity zegoVideoCallActivity) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        ZegoSdkManager zegoSdkManager = zegoVideoCallActivity.rtcManager;
        if (zegoSdkManager == null || !(zegoSdkManager instanceof ZegoSdkManager)) {
            return;
        }
        zegoSdkManager.setSdkInitialized(false);
    }

    public final void showLudoButtonForStreamer(VideoDetailModel data) {
        if (this.isStreamer && this.showLudoCount <= 5) {
            Boolean showLudoButton = data.getShowLudoButton();
            this.showLudoButtonForStreamer = showLudoButton != null ? showLudoButton.booleanValue() : false;
            LinearLayout linearLayout = getBinding().btnGameRequest;
            Intrinsics.checkNotNullExpressionValue(linearLayout, "binding.btnGameRequest");
            linearLayout.setVisibility(this.showLudoButtonForStreamer ? 0 : 8);
            this.showLudoCount++;
        }
    }

    private final void listenRtcEventHandler() {
        this.rtcEventHandler = new ZegoVideoCallActivity$listenRtcEventHandler$1(this);
    }

    private final void listenFaceDetectionEvent() {
        RtcManager rtcManager;
        if (this.isStreamer && !isAudioCall()) {
            RtcManager rtcManager2 = this.rtcManager;
            if ((rtcManager2 == null || rtcManager2.isAIEffectsEnabled((Context) this)) ? false : true) {
                return;
            }
            Context context = (Context) this;
            this.isFaceDetectionEnabled = SharedPref.getBoolean(context, PrefKeys.FACE_DETECTION_ENABLED, false);
            Integer num = SharedPref.getInt(context, PrefKeys.FACE_DETECTION_FREQUENCY, 0);
            Intrinsics.checkNotNullExpressionValue(num, "getInt(this, PrefKeys.FACE_DETECTION_FREQUENCY, 0)");
            this.faceDetectionFrequency = num.intValue();
            Integer num2 = SharedPref.getInt(context, PrefKeys.FACE_DETECTION_DURATION, 0);
            Intrinsics.checkNotNullExpressionValue(num2, "getInt(this, PrefKeys.FACE_DETECTION_DURATION, 0)");
            this.faceDetectionDuration = num2.intValue();
            Timber.i("Face Detection Event: " + this.isFaceDetectionEnabled + ' ' + this.faceDetectionDuration + ' ' + this.faceDetectionFrequency, new Object[0]);
            if (!this.isFaceDetectionEnabled || this.faceDetectionFrequency == 0 || this.faceDetectionDuration == 0 || (rtcManager = this.rtcManager) == null) {
                return;
            }
            rtcManager.setFaceDetectionHandler(new FaceDetectionHandler() {
                @Override
                public final void faceConfidenceLevelScore(float f) {
                    ZegoVideoCallActivity.listenFaceDetectionEvent$lambda$2(ZegoVideoCallActivity.this, f);
                }
            });
        }
    }

    public static final void listenFaceDetectionEvent$lambda$2(ZegoVideoCallActivity zegoVideoCallActivity, float f) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        if (zegoVideoCallActivity.getViewModel().getStartTime() != -1) {
            zegoVideoCallActivity.confidenceScores.add(Float.valueOf(f));
        }
    }

    public final void startConfidenceScoreTimer() {
        if (this.isStreamer && !isAudioCall()) {
            RtcManager rtcManager = this.rtcManager;
            boolean z = false;
            if (rtcManager != null && !rtcManager.isAIEffectsEnabled((Context) this)) {
                z = true;
            }
            if (z || !this.isFaceDetectionEnabled || this.faceDetectionFrequency == 0 || this.faceDetectionDuration == 0) {
                return;
            }
            this.confidenceScoreTimer = BuildersKt.launch$default(CoroutineScopeKt.CoroutineScope(Dispatchers.getIO()), (CoroutineContext) null, (CoroutineStart) null, new ZegoVideoCallActivity$startConfidenceScoreTimer$1(this, null), 3, (Object) null);
        }
    }

    public final void sendAverageConfidenceScore() {
        if (!this.confidenceScores.isEmpty()) {
            try {
                getViewModel().sendAvgConfidenceScore((float) CollectionsKt.averageOfFloat(CollectionsKt.toList(this.confidenceScores)));
                this.confidenceScores.clear();
            } catch (Exception e) {
                Timber.e(e);
            }
        }
    }

    private final void observeCallEndFromNotification() {
        try {
            Observable observeOn = getRxBus().toObservable().observeOn(AndroidSchedulers.mainThread());
            Consumer consumer = new Consumer() {
                public final void accept(Object obj) {
                    ZegoVideoCallActivity.observeCallEndFromNotification$lambda$3(ZegoVideoCallActivity.this, obj);
                }
            };
            final ZegoVideoCallActivity$observeCallEndFromNotification$2 zegoVideoCallActivity$observeCallEndFromNotification$2 = new Function1<Throwable, Unit>() {
                public Object invoke(Object obj) {
                    invoke((Throwable) obj);
                    return Unit.INSTANCE;
                }

                public final void invoke(Throwable th) {
                    Timber.e(th, "Error in RxBus subscription", new Object[0]);
                }
            };
            this.disposable = observeOn.subscribe(consumer, new Consumer() {
                public final void accept(Object obj) {
                    ZegoVideoCallActivity.observeCallEndFromNotification$lambda$4(zegoVideoCallActivity$observeCallEndFromNotification$2, obj);
                }
            });
        } catch (Exception e) {
            Timber.e(e.toString(), new Object[0]);
        }
    }

    public static final void observeCallEndFromNotification$lambda$3(ZegoVideoCallActivity zegoVideoCallActivity, Object obj) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        if ((obj instanceof VideoCallEvent) && ((VideoCallEvent) obj).getEvent() == VideoCallEventType.CALL_ENDED_FROM_NOTIFICATION) {
            zegoVideoCallActivity.getViewModel().videoCallEnd(zegoVideoCallActivity.videoId);
            zegoVideoCallActivity.getViewModel().setEgressActive(false);
            zegoVideoCallActivity.endCall();
        }
    }

    public static final void observeCallEndFromNotification$lambda$4(Function1 function1, Object obj) {
        Intrinsics.checkNotNullParameter(function1, "$tmp0");
        function1.invoke(obj);
    }

    private final void getSharedPrefValues() {
        this.isScreenshotsEnabled = SharedPref.getBoolean((Context) this, PrefKeys.ENABLE_SCREENSHOTS);
    }

    private final void showOnLockScreen() {
        try {
            if (Build.VERSION.SDK_INT == 30) {
                SharedPref.setInt((Context) this, PrefKeys.USER_COUNT_IN_ROOM, 0);
            }
            getWindow().addFlags(69730304);
        } catch (Exception e) {
            Timber.e(e);
        }
    }

    private final void hideBottomBar() {
        BuildersKt.launch$default(CoroutineScopeKt.CoroutineScope(Dispatchers.getMain()), (CoroutineContext) null, (CoroutineStart) null, new ZegoVideoCallActivity$hideBottomBar$1(this, null), 3, (Object) null);
    }

    private final void fromCallNotification() {
        SharedPref.setString((Context) this, PrefKeys.START_TIME, "");
        boolean z = false;
        HeadsUpNotificationService.INSTANCE.setServiceRunning(false);
        try {
            Intent intent = getIntent();
            if (intent != null && intent.getBooleanExtra(Constants.CALL_SCREEN_NOTIFICATION, false)) {
                z = true;
            }
            if (z) {
                LocalBroadcastManager.getInstance((Context) this).sendBroadcast(new Intent(Constants.CALL_SCREEN_NOTIFICATION));
            }
        } catch (Exception e) {
            Timber.e(e);
        }
    }

    public final void enablePip() {
        try {
            Rational rational = new Rational(this.pipNumerator, this.pipDenominator);
            if (Build.VERSION.SDK_INT >= 26) {
                if (getPackageManager().hasSystemFeature("android.software.picture_in_picture")) {
                    Timber.tag("PIP").e("*** Picture-in-Picture ***", new Object[0]);
                    enterPictureInPictureMode(new PictureInPictureParams.Builder().setAspectRatio(rational).setSourceRectHint(new Rect()).build());
                } else {
                    Timber.tag("PIP").e("*** No support Picture-in-Picture ***", new Object[0]);
                }
            }
        } catch (Exception e) {
            Activity activity = (Activity) this;
            String message = e.getMessage();
            if (message == null) {
                message = "";
            }
            ActivityExtKt.toast(activity, message);
        }
    }

    private final Job observeEvent() {
        return BuildersKt.launch$default(LifecycleOwnerKt.getLifecycleScope((LifecycleOwner) this), (CoroutineContext) null, (CoroutineStart) null, new ZegoVideoCallActivity$observeEvent$1(this, null), 3, (Object) null);
    }

    public final void handleLudoGameClicks(final double actualBalance) {
        LinearLayout linearLayout;
        ActivityZegoVideoCallBinding activityZegoVideoCallBinding = this._binding;
        if (activityZegoVideoCallBinding == null || (linearLayout = activityZegoVideoCallBinding.btnGameRequest) == null) {
            return;
        }
        linearLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ZegoVideoCallActivity.handleLudoGameClicks$lambda$10(ZegoVideoCallActivity.this, actualBalance, view);
            }
        });
    }

    public static final void handleLudoGameClicks$lambda$10(final ZegoVideoCallActivity zegoVideoCallActivity, double d, View view) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        Context context = (Context) zegoVideoCallActivity;
        Integer num = SharedPref.getInt(context, PrefKeys.MIN_LEVEL_TO_PLAY_LUDO_GAME_IN_VIDEO_CALL, 0);
        Integer num2 = SharedPref.getInt(context, PrefKeys.DURATION_IN_SECONDS_TO_ENABLE_LUDO_GAME, 0);
        Intrinsics.checkNotNullExpressionValue(num2, "durationInSecondsToEnableLudoGame");
        zegoVideoCallActivity.ludoTimerLeft = num2.intValue();
        Integer num3 = SharedPref.getInt(context, PrefKeys.CURRENT_USER_LEVEL, 0);
        try {
            VideoDetailModel videoDetails = zegoVideoCallActivity.getViewModel().getVideoDetails();
            Dialog dialog = null;
            if (videoDetails != null) {
                if (d < 5 * videoDetails.getRate()) {
                    AlertDialog.Builder builder = new AlertDialog.Builder((Context) zegoVideoCallActivity);
                    builder.setCancelable(true);
                    builder.setTitle("Insufficient Balance!").setMessage("You need atleast 5 minutes of talktime to play LUDO game.").setPositiveButton("Recharge Now", new DialogInterface.OnClickListener() {
                        @Override
                        public final void onClick(DialogInterface dialogInterface, int i) {
                            ZegoVideoCallActivity.handleLudoGameClicks$lambda$10$lambda$6$lambda$5(ZegoVideoCallActivity.this, dialogInterface, i);
                        }
                    });
                    AlertDialog create = builder.create();
                    Intrinsics.checkNotNullExpressionValue(create, "builder.create()");
                    Dialog dialog2 = (Dialog) create;
                    zegoVideoCallActivity.alertDialog = dialog2;
                    if (dialog2 == null) {
                        Intrinsics.throwUninitializedPropertyAccessException("alertDialog");
                    } else {
                        dialog = dialog2;
                    }
                    dialog.show();
                    return;
                }
            }
            Intrinsics.checkNotNullExpressionValue(num3, "currentUserLevel");
            int intValue = num3.intValue();
            Intrinsics.checkNotNullExpressionValue(num, "minLevelRequiredForLudo");
            if (intValue < num.intValue()) {
                AlertDialog.Builder builder2 = new AlertDialog.Builder((Context) zegoVideoCallActivity);
                builder2.setCancelable(true);
                builder2.setTitle("Upgrade Your Level").setMessage("You can play Ludo after you reach Level " + num + ".\nYour current level is " + num3 + '.').setPositiveButton("OKAY", new DialogInterface.OnClickListener() {
                    @Override
                    public final void onClick(DialogInterface dialogInterface, int i) {
                        ZegoVideoCallActivity.handleLudoGameClicks$lambda$10$lambda$7(dialogInterface, i);
                    }
                });
                AlertDialog create2 = builder2.create();
                Intrinsics.checkNotNullExpressionValue(create2, "builder.create()");
                Dialog dialog3 = (Dialog) create2;
                zegoVideoCallActivity.alertDialog = dialog3;
                if (dialog3 == null) {
                    Intrinsics.throwUninitializedPropertyAccessException("alertDialog");
                } else {
                    dialog = dialog3;
                }
                dialog.show();
                return;
            }
            if (!zegoVideoCallActivity.ludoButtonTimerFinished) {
                ActivityExtKt.toast((Activity) zegoVideoCallActivity, "Please wait. The option will be enabled in " + zegoVideoCallActivity.ludoTimerLeft + " seconds.");
                return;
            }
            AlertDialog.Builder builder3 = new AlertDialog.Builder((Context) zegoVideoCallActivity);
            builder3.setCancelable(true);
            builder3.setTitle("Ludo Game").setMessage("Do you want to play ludo game?").setPositiveButton(zegoVideoCallActivity.getString(2131953093), new DialogInterface.OnClickListener() {
                @Override
                public final void onClick(DialogInterface dialogInterface, int i) {
                    ZegoVideoCallActivity.handleLudoGameClicks$lambda$10$lambda$8(ZegoVideoCallActivity.this, dialogInterface, i);
                }
            }).setNegativeButton(zegoVideoCallActivity.getString(2131952360), new DialogInterface.OnClickListener() {
                @Override
                public final void onClick(DialogInterface dialogInterface, int i) {
                    ZegoVideoCallActivity.handleLudoGameClicks$lambda$10$lambda$9(dialogInterface, i);
                }
            });
            AlertDialog create3 = builder3.create();
            Intrinsics.checkNotNullExpressionValue(create3, "builder.create()");
            Dialog dialog4 = (Dialog) create3;
            zegoVideoCallActivity.alertDialog = dialog4;
            if (dialog4 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("alertDialog");
            } else {
                dialog = dialog4;
            }
            dialog.show();
        } catch (Exception e) {
            Timber.e(e, "Error: ", new Object[0]);
        }
    }

    public static final void handleLudoGameClicks$lambda$10$lambda$6$lambda$5(final ZegoVideoCallActivity zegoVideoCallActivity, DialogInterface dialogInterface, int i) {
        RechargeDialog rechargeDialog;
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        try {
            rechargeDialog = new RechargeDialog(null, null, null, zegoVideoCallActivity.getString(2131953109), null, new Function0<Unit>() {
                public final void m915invoke() {
                }

                public Object invoke() {
                    m915invoke();
                    return Unit.INSTANCE;
                }
            }, new Function0<Unit>() {
                public final void m916invoke() {
                }

                public Object invoke() {
                    m916invoke();
                    return Unit.INSTANCE;
                }
            }, new Function0<Unit>() {
                {
                    super(0);
                }

                public Object invoke() {
                    m917invoke();
                    return Unit.INSTANCE;
                }

                public final void m917invoke() {
                    ZegoVideoCallActivity.this.enablePip();
                }
            });
            rechargeDialog.setCancelable(true);
        } catch (Exception unused) {
            Activity activity = (Activity) zegoVideoCallActivity;
            String string = zegoVideoCallActivity.getString(2131951993);
            Intrinsics.checkNotNullExpressionValue(string, "getString(R.string.error_unknown)");
            ActivityExtKt.toast(activity, string);
        }
        if (!rechargeDialog.isAdded() && !rechargeDialog.isVisible()) {
            rechargeDialog.setFromZegoScreen(true);
            rechargeDialog.show(zegoVideoCallActivity.getSupportFragmentManager(), "RechargeDialog");
            if (dialogInterface != null) {
                dialogInterface.dismiss();
            }
        }
    }

    public static final void handleLudoGameClicks$lambda$10$lambda$7(DialogInterface dialogInterface, int i) {
        if (dialogInterface != null) {
            dialogInterface.dismiss();
        }
    }

    public static final void handleLudoGameClicks$lambda$10$lambda$8(ZegoVideoCallActivity zegoVideoCallActivity, DialogInterface dialogInterface, int i) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        zegoVideoCallActivity.getViewModel().createSudGame(zegoVideoCallActivity.videoId, GameUtils.GameNames.LUDO);
        if (dialogInterface != null) {
            dialogInterface.dismiss();
        }
    }

    public static final void handleLudoGameClicks$lambda$10$lambda$9(DialogInterface dialogInterface, int i) {
        if (dialogInterface != null) {
            dialogInterface.dismiss();
        }
    }

    public final void startImageUploadLoop(long videoId, long egressFrequency, String source) {
        if (this.imageUploadJob != null) {
            return;
        }
        this.imageUploadJob = BuildersKt.launch$default(LifecycleOwnerKt.getLifecycleScope((LifecycleOwner) this), (CoroutineContext) null, (CoroutineStart) null, new ZegoVideoCallActivity$startImageUploadLoop$1(this, source, egressFrequency, videoId, null), 3, (Object) null);
    }

    public final void stopImageUploadLoop() {
        Handler handler = this.imageUploadHandler;
        if (handler != null) {
            Runnable runnable = this.imageUploadRunnable;
            Intrinsics.checkNotNull(runnable);
            handler.removeCallbacks(runnable);
        }
        this.imageUploadHandler = null;
        this.imageUploadRunnable = null;
    }

    public final void openGameScreen(String gameRoomId) {
        Timber.e("Game room id " + gameRoomId, new Object[0]);
        Context context = (Context) this;
        String string = SharedPref.getString(context, PrefKeys.AUTH_TOKEN);
        this.pipNumerator = 2;
        this.pipDenominator = 2;
        SudGameActivity.start(context, gameRoomId, 1468180338417074177L, getUserId(), string, Long.valueOf(this.videoId));
        Job job = this.gameJob;
        if (job != null) {
            if (!((job == null || job.isActive()) ? false : true)) {
                return;
            }
        }
        Timber.e("Game Job is null starting ping", new Object[0]);
        this.gameJob = BuildersKt.launch$default(this.gameScope, (CoroutineContext) null, (CoroutineStart) null, new ZegoVideoCallActivity$openGameScreen$1(this, null), 3, (Object) null);
    }

    public final void endCall() {
        stopServiceFunc();
        getViewModel().setEnded(true);
        getViewModel().getRxBus().send(new VideoCallEvent(VideoCallEventType.CALL_ENDED, null, this.caller, 2, null));
        if (this.isStreamer || this.ended) {
            Job.DefaultImpls.cancel$default(this.job, (CancellationException) null, 1, (Object) null);
            getViewModel().getRxBus().send(new VideoCallEvent(VideoCallEventType.CALL_ENDED, null, this.caller, 2, null));
            finish();
            return;
        }
        Job.DefaultImpls.cancel$default(this.job, (CancellationException) null, 1, (Object) null);
        VideoDetailModel videoDetails = getViewModel().getVideoDetails();
        if (videoDetails != null) {
            this.ended = true;
            Intent intent = new Intent((Context) this, (Class<?>) StreamerReviewActivity.class);
            intent.putExtra(Constants.FCM_DATA, new Gson().toJson(videoDetails));
            startActivity(intent);
            finish();
            return;
        }
        finish();
    }

    private final Job observePreviewSwitchEvent() {
        return BuildersKt.launch$default(LifecycleOwnerKt.getLifecycleScope((LifecycleOwner) this), (CoroutineContext) null, (CoroutineStart) null, new ZegoVideoCallActivity$observePreviewSwitchEvent$1(this, null), 3, (Object) null);
    }

    private final void userJoinJob() {
        if (LoginActivity.INSTANCE.isVitok()) {
            return;
        }
        try {
            this.userJoinJob = BuildersKt.launch$default(this.userJoinScope, (CoroutineContext) null, (CoroutineStart) null, new ZegoVideoCallActivity$userJoinJob$1(this, null), 3, (Object) null);
        } catch (Exception e) {
            Timber.e(e);
        }
    }

    public final void reconnectingBox(boolean reconnecting) {
        if (reconnecting) {
            ActivityZegoVideoCallBinding activityZegoVideoCallBinding = this._binding;
            LinearLayout linearLayout = activityZegoVideoCallBinding != null ? activityZegoVideoCallBinding.connectionBreakLayout : null;
            if (linearLayout != null) {
                linearLayout.setVisibility(0);
            }
            ActivityZegoVideoCallBinding activityZegoVideoCallBinding2 = this._binding;
            AppCompatTextView appCompatTextView = activityZegoVideoCallBinding2 != null ? activityZegoVideoCallBinding2.timerLeft : null;
            if (appCompatTextView != null) {
                ((View) appCompatTextView).setVisibility(8);
            }
            BuildersKt.launch$default(this.timeScope, (CoroutineContext) null, (CoroutineStart) null, new ZegoVideoCallActivity$reconnectingBox$1(this, null), 3, (Object) null);
            return;
        }
        ActivityZegoVideoCallBinding activityZegoVideoCallBinding3 = this._binding;
        LinearLayout linearLayout2 = activityZegoVideoCallBinding3 != null ? activityZegoVideoCallBinding3.connectionBreakLayout : null;
        if (linearLayout2 != null) {
            linearLayout2.setVisibility(8);
        }
        CoroutineScopeKt.cancel$default(this.timeScope, (CancellationException) null, 1, (Object) null);
        this.timeScope = CoroutineScopeKt.CoroutineScope(Dispatchers.getMain().plus(this.timerJob));
        this.reconnectingTime = 0;
        ActivityZegoVideoCallBinding activityZegoVideoCallBinding4 = this._binding;
        AppCompatTextView appCompatTextView2 = activityZegoVideoCallBinding4 != null ? activityZegoVideoCallBinding4.timerLeft : null;
        if (appCompatTextView2 == null) {
            return;
        }
        ((View) appCompatTextView2).setVisibility(0);
    }

    private final void initUI() {
        this.mLocalPreviewLayout = getBinding().localPreviewLayout;
        this.mRemotePreviewLayout = getBinding().remotePreviewLayout;
        FrameLayout frameLayout = getBinding().localLayoutParent;
        Intrinsics.checkNotNullExpressionValue(frameLayout, "binding.localLayoutParent");
        ViewExtKt.addRightMargin(frameLayout, NumberExtKt.dpToPx((Number) 10));
        getBinding().localLayoutParent.setElevation(4.0f);
        AppCompatImageView appCompatImageView = getBinding().btnMute;
        this.mMuteBtn = appCompatImageView;
        if (appCompatImageView != null) {
            appCompatImageView.setActivated(false);
        }
        if (!this.isStreamer) {
            LinearLayout linearLayout = getBinding().btnGameRequest;
            Intrinsics.checkNotNullExpressionValue(linearLayout, "binding.btnGameRequest");
            linearLayout.setVisibility(0);
        }
        handleLudoGameBtnVisibility();
        setupRv();
    }

    private final void handleLudoGameBtnVisibility() {
        if (this.isStreamer) {
            LinearLayout linearLayout = getBinding().ludoGameBtnParent;
            Intrinsics.checkNotNullExpressionValue(linearLayout, "binding.ludoGameBtnParent");
            linearLayout.setVisibility(8);
            return;
        }
        Context context = (Context) this;
        ArrayList arrayList = (ArrayList) new Gson().fromJson(SharedPref.getString(context, PrefKeys.ACTIVE_GAMES_IN_VIDEO_CALL, "[]"), new TypeToken<ArrayList<String>>() {
        }.getType());
        if (arrayList == null) {
            arrayList = new ArrayList();
        }
        Iterator it = arrayList.iterator();
        while (true) {
            int i = 0;
            if (!it.hasNext()) {
                break;
            }
            String str = (String) it.next();
            LinearLayout linearLayout2 = getBinding().ludoGameBtnParent;
            Intrinsics.checkNotNullExpressionValue(linearLayout2, "binding.ludoGameBtnParent");
            LinearLayout linearLayout3 = linearLayout2;
            if (!Intrinsics.areEqual(str, "LUDO")) {
                i = 8;
            }
            linearLayout3.setVisibility(i);
            this.isLudoGameEnabled = Intrinsics.areEqual(str, "LUDO");
        }
        if (this.isLudoGameEnabled) {
            Integer num = SharedPref.getInt(context, PrefKeys.MIN_LEVEL_TO_PLAY_LUDO_GAME_IN_VIDEO_CALL, 0);
            Integer num2 = SharedPref.getInt(context, PrefKeys.DURATION_IN_SECONDS_TO_ENABLE_LUDO_GAME, 0);
            Intrinsics.checkNotNullExpressionValue(num2, "durationInSecondsToEnableLudoGame");
            this.ludoTimerLeft = num2.intValue();
            Integer num3 = SharedPref.getInt(context, PrefKeys.CURRENT_USER_LEVEL, 0);
            Intrinsics.checkNotNullExpressionValue(num3, "currentUserLevel");
            int intValue = num3.intValue();
            Intrinsics.checkNotNullExpressionValue(num, "minLevelRequiredForLudo");
            if (intValue < num.intValue()) {
                TextView textView = getBinding().ludoTimer;
                Intrinsics.checkNotNullExpressionValue(textView, "binding.ludoTimer");
                textView.setVisibility(8);
            } else {
                this.ludoButtonTimerFinished = false;
                TextView textView2 = getBinding().ludoTimer;
                Intrinsics.checkNotNullExpressionValue(textView2, "binding.ludoTimer");
                textView2.setVisibility(0);
                BuildersKt.launch$default(LifecycleOwnerKt.getLifecycleScope((LifecycleOwner) this), (CoroutineContext) null, (CoroutineStart) null, new ZegoVideoCallActivity$handleLudoGameBtnVisibility$1(num2, this, null), 3, (Object) null);
            }
            VideoDetailModel videoDetails = getViewModel().getVideoDetails();
            if (videoDetails != null) {
                handleLudoGameClicks(videoDetails.getBalanceDto().getBalance());
            }
        }
    }

    private final void getVideoDetails(Intent intent) {
        String stringExtra;
        Context context = (Context) this;
        Integer num = SharedPref.getInt(context, PrefKeys.CALL_PING_DURATION, 2);
        Intrinsics.checkNotNullExpressionValue(num, "getInt(this, PrefKeys.CALL_PING_DURATION, 2)");
        this.callPingDuration = num.intValue();
        Helper.cancelNotification(context, VolumeManager.ON_DO_NOT_DISTURB_CALLBACK_CODE);
        Integer num2 = SharedPref.getInt(context, PrefKeys.VIDEO_SCREEN_MESSAGE_TIME, 5);
        Intrinsics.checkNotNullExpressionValue(num2, "getInt(this, PrefKeys.VI…O_SCREEN_MESSAGE_TIME, 5)");
        int intValue = num2.intValue();
        this.delayInSeconds = intValue;
        if (intValue == 0) {
            this.delayInSeconds = 5;
        }
        if (intent == null || intent.getExtras() == null || (stringExtra = intent.getStringExtra(Constants.FCM_DATA)) == null) {
            return;
        }
        VideoDetailModel videoDetailModel = (VideoDetailModel) new Gson().fromJson(stringExtra, VideoDetailModel.class);
        getViewModel().setVideoDetails(videoDetailModel);
        if (videoDetailModel != null) {
            this.videoId = videoDetailModel.getId();
            if (videoDetailModel.getId() != -1) {
                intent.putExtra(Constants.KEY_CALLING_VIDEO_ID, videoDetailModel.getId());
            }
            if (Intrinsics.areEqual(String.valueOf(videoDetailModel.getStreamerId()), getUserId())) {
                this.isStreamer = true;
                this.mPeerUid = 1;
            } else {
                this.isStreamer = false;
                this.mPeerUid = 2;
            }
            if (Intrinsics.areEqual(videoDetailModel.getCallType(), "RANDOM") && videoDetailModel.getCardType() == null) {
                closeScreen(videoDetailModel.getRandomCallDuration());
            }
        }
        initVideoStopLayout();
        BuildersKt.launch$default(this.scope, (CoroutineContext) null, (CoroutineStart) null, new ZegoVideoCallActivity$getVideoDetails$1(this, null), 3, (Object) null);
    }

    public final void initVideoStopLayout() {
        String str;
        String str2;
        String name;
        String name2;
        String str3;
        String str4;
        String str5;
        String str6;
        String name3;
        String name4;
        String name5;
        String name6;
        final VideoDetailModel videoDetails = getViewModel().getVideoDetails();
        if (videoDetails != null) {
            View view = getBinding().rv;
            Intrinsics.checkNotNullExpressionValue(view, "binding.rv");
            view.setVisibility(videoDetails.getChatDetails() != null ? 0 : 8);
            View view2 = getBinding().btnMessageHost;
            Intrinsics.checkNotNullExpressionValue(view2, "binding.btnMessageHost");
            view2.setVisibility(videoDetails.getChatDetails() != null ? 0 : 8);
            CallViewModel viewModel = getViewModel();
            StreamerModel userDetails = videoDetails.getUserDetails();
            viewModel.setCallpeAdmin(userDetails != null ? userDetails.getCallpeAdmin() : false);
            if (this.isStreamer) {
                FragmentActivity fragmentActivity = (FragmentActivity) this;
                RequestManager with = Glide.with(fragmentActivity);
                StreamerModel userDetails2 = videoDetails.getUserDetails();
                if (userDetails2 == null || (str3 = userDetails2.getAvatar()) == null) {
                    str3 = "";
                }
                with.load(str3).into(getBinding().peerImage);
                TextView textView = getBinding().name;
                StreamerModel userDetails3 = videoDetails.getUserDetails();
                textView.setText((userDetails3 == null || (name6 = userDetails3.getName()) == null) ? "" : name6);
                RequestManager with2 = Glide.with(fragmentActivity);
                StreamerModel streamerDetails = videoDetails.getStreamerDetails();
                if (streamerDetails == null || (str4 = StreamerModel.getProfile$default(streamerDetails, false, 1, null)) == null) {
                    str4 = "";
                }
                with2.load(str4).into(getBinding().userImage);
                TextView textView2 = getBinding().userName;
                StreamerModel streamerDetails2 = videoDetails.getStreamerDetails();
                textView2.setText((streamerDetails2 == null || (name5 = streamerDetails2.getName()) == null) ? "" : name5);
                RequestManager with3 = Glide.with(fragmentActivity);
                StreamerModel userDetails4 = videoDetails.getUserDetails();
                if (userDetails4 == null || (str5 = userDetails4.getAvatar()) == null) {
                    str5 = "";
                }
                with3.load(str5).into(getBinding().userPicImg);
                TextView textView3 = getBinding().userNameTv;
                StreamerModel userDetails5 = videoDetails.getUserDetails();
                textView3.setText((userDetails5 == null || (name4 = userDetails5.getName()) == null) ? "" : name4);
                RequestManager with4 = Glide.with(fragmentActivity);
                StreamerModel userDetails6 = videoDetails.getUserDetails();
                if (userDetails6 == null || (str6 = userDetails6.getAvatar()) == null) {
                    str6 = "";
                }
                with4.load(str6).into(getBinding().remoteUserImage);
                TextView textView4 = getBinding().remoteUserName;
                StreamerModel userDetails7 = videoDetails.getUserDetails();
                textView4.setText((userDetails7 == null || (name3 = userDetails7.getName()) == null) ? "" : name3);
                LinearLayout linearLayout = getBinding().userInfoParent;
                Intrinsics.checkNotNullExpressionValue(linearLayout, "binding.userInfoParent");
                linearLayout.setVisibility(0);
                AppCompatImageView appCompatImageView = getBinding().btnGiftHost;
                Intrinsics.checkNotNullExpressionValue(appCompatImageView, "binding.btnGiftHost");
                ViewExtKt.showOrInvisible((View) appCompatImageView, getViewModel().getCanShowGift());
                AppCompatImageView appCompatImageView2 = getBinding().btnGiftUser;
                Intrinsics.checkNotNullExpressionValue(appCompatImageView2, "binding.btnGiftUser");
                ((View) appCompatImageView2).setVisibility(8);
                View view3 = getBinding().hideUserBtn;
                Intrinsics.checkNotNullExpressionValue(view3, "binding.hideUserBtn");
                view3.setVisibility(isAudioCall() ^ true ? 0 : 8);
                if (!this.isScreenshotsEnabled) {
                    App.Companion.setFlagSecureDisabled(getViewModel().getCallpeAdmin());
                }
                StreamerModel userDetails8 = videoDetails.getUserDetails();
                if (userDetails8 != null) {
                    if (userDetails8.getLevelName() != null) {
                        getViewModel().setCanShowLevelTag(true);
                        getBinding().userLevel.setText("Lvl " + userDetails8.getLevelName());
                    } else {
                        View view4 = getBinding().levelParent;
                        Intrinsics.checkNotNullExpressionValue(view4, "binding.levelParent");
                        view4.setVisibility(8);
                    }
                }
                getBinding().userInfoParent.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public final void onClick(View view5) {
                        ZegoVideoCallActivity.initVideoStopLayout$lambda$18$lambda$17(ZegoVideoCallActivity.this, videoDetails, view5);
                    }
                });
                return;
            }
            AppCompatImageView appCompatImageView3 = getBinding().rechargeBtn;
            Intrinsics.checkNotNullExpressionValue(appCompatImageView3, "binding.rechargeBtn");
            ((View) appCompatImageView3).setVisibility(0);
            FragmentActivity fragmentActivity2 = (FragmentActivity) this;
            RequestManager with5 = Glide.with(fragmentActivity2);
            StreamerModel streamerDetails3 = videoDetails.getStreamerDetails();
            if (streamerDetails3 == null || (str = StreamerModel.getProfile$default(streamerDetails3, false, 1, null)) == null) {
                str = "";
            }
            with5.load(str).into(getBinding().peerImage);
            TextView textView5 = getBinding().name;
            StreamerModel streamerDetails4 = videoDetails.getStreamerDetails();
            textView5.setText((streamerDetails4 == null || (name2 = streamerDetails4.getName()) == null) ? "" : name2);
            RequestManager with6 = Glide.with(fragmentActivity2);
            StreamerModel userDetails9 = videoDetails.getUserDetails();
            if (userDetails9 == null || (str2 = userDetails9.getAvatar()) == null) {
                str2 = "";
            }
            with6.load(str2).into(getBinding().userImage);
            TextView textView6 = getBinding().userName;
            StreamerModel userDetails10 = videoDetails.getUserDetails();
            textView6.setText((userDetails10 == null || (name = userDetails10.getName()) == null) ? "" : name);
        }
    }

    public static final void initVideoStopLayout$lambda$18$lambda$17(ZegoVideoCallActivity zegoVideoCallActivity, VideoDetailModel videoDetailModel, View view) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        Intrinsics.checkNotNullParameter(videoDetailModel, "$model");
        Intent intent = new Intent(zegoVideoCallActivity.getApplicationContext(), (Class<?>) UserDetailsActivity.class);
        intent.addFlags(805306368);
        intent.putExtra("userId", videoDetailModel.getUserId());
        zegoVideoCallActivity.startActivity(intent);
    }

    private final void setupRv() {
        RecyclerView.LayoutManager customLinearLayoutManager = new CustomLinearLayoutManager((Context) this);
        customLinearLayoutManager.setStackFromEnd(true);
        getBinding().rv.setLayoutManager(customLinearLayoutManager);
        this.videoMessageAdapter = new VideoMessageAdapter(null, new VideoMessageAdapter.ItemClickListener() {
            @Override
            public void onItemClick(VideoMessageModel host) {
                Intrinsics.checkNotNullParameter(host, "host");
            }
        }, 1, null);
        getBinding().rv.setAdapter(this.videoMessageAdapter);
    }

    private final void onClicks() {
        getBinding().touch.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ZegoVideoCallActivity.onClicks$lambda$19(ZegoVideoCallActivity.this, view);
            }
        });
        getBinding().rootLayout.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public final boolean onTouch(View view, MotionEvent motionEvent) {
                boolean onClicks$lambda$20;
                onClicks$lambda$20 = ZegoVideoCallActivity.onClicks$lambda$20(ZegoVideoCallActivity.this, view, motionEvent);
                return onClicks$lambda$20;
            }
        });
        getBinding().videoInput.btnSendMessage.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ZegoVideoCallActivity.onClicks$lambda$21(ZegoVideoCallActivity.this, view);
            }
        });
        getBinding().btnGiftHost.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ZegoVideoCallActivity.onClicks$lambda$22(ZegoVideoCallActivity.this, view);
            }
        });
        getBinding().btnGiftUser.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ZegoVideoCallActivity.onClicks$lambda$23(ZegoVideoCallActivity.this, view);
            }
        });
        getBinding().videoInput.messageInput.setListener(new BackPressEditText.EditTextListener() {
            @Override
            public final void callback() {
                ZegoVideoCallActivity.onClicks$lambda$24(ZegoVideoCallActivity.this);
            }
        });
    }

    public static final void onClicks$lambda$19(ZegoVideoCallActivity zegoVideoCallActivity, View view) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        zegoVideoCallActivity.touchEventClicked();
    }

    public static final boolean onClicks$lambda$20(ZegoVideoCallActivity zegoVideoCallActivity, View view, MotionEvent motionEvent) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        if (motionEvent.getAction() != 0) {
            return false;
        }
        zegoVideoCallActivity.touchEventClicked();
        return true;
    }

    public static final void onClicks$lambda$21(ZegoVideoCallActivity zegoVideoCallActivity, View view) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        if (zegoVideoCallActivity._binding == null) {
            CrashLogHelper.INSTANCE.logError("Binding is null action: binding.videoInput.btnSendMessage.setOnClickListener");
            return;
        }
        if (String.valueOf(zegoVideoCallActivity.getBinding().videoInput.messageInput.getText()).length() > 0) {
            zegoVideoCallActivity.getViewModel().sendMessage(String.valueOf(zegoVideoCallActivity.getBinding().videoInput.messageInput.getText()), zegoVideoCallActivity.isStreamer);
            Editable text = zegoVideoCallActivity.getBinding().videoInput.messageInput.getText();
            if (text != null) {
                text.clear();
            }
            LinearLayout root = zegoVideoCallActivity.getBinding().videoInput.getRoot();
            Intrinsics.checkNotNullExpressionValue(root, "binding.videoInput.root");
            ViewExtKt.showOrGone(root, false);
            AppCompatEditText appCompatEditText = zegoVideoCallActivity.getBinding().videoInput.messageInput;
            Intrinsics.checkNotNullExpressionValue(appCompatEditText, "binding.videoInput.messageInput");
            ViewExtKt.hideSoftKeyboard((View) appCompatEditText);
            zegoVideoCallActivity.adjustLocalLayoutPosition();
        }
    }

    public static final void onClicks$lambda$22(ZegoVideoCallActivity zegoVideoCallActivity, View view) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        ArrayList gifts = App.Companion.getGifts();
        if (gifts == null) {
            gifts = new ArrayList();
        }
        ArrayList arrayList = gifts;
        ArrayList giftBrackets = App.Companion.getGiftBrackets();
        if (giftBrackets == null) {
            giftBrackets = new ArrayList();
        }
        GiftBottomSheet giftBottomSheet = new GiftBottomSheet(arrayList, giftBrackets, zegoVideoCallActivity.isStreamer, false, null, null, 56, null);
        giftBottomSheet.setUserId(zegoVideoCallActivity.getViewModel().getVideoDetails() != null ? r0.getUserId() : -1L);
        if (giftBottomSheet.isAdded() || giftBottomSheet.isVisible()) {
            return;
        }
        giftBottomSheet.show(zegoVideoCallActivity.getSupportFragmentManager(), "GiftBottomSheet");
    }

    public static final void onClicks$lambda$23(ZegoVideoCallActivity zegoVideoCallActivity, View view) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        ArrayList gifts = App.Companion.getGifts();
        if (gifts == null) {
            gifts = new ArrayList();
        }
        ArrayList arrayList = gifts;
        ArrayList giftBrackets = App.Companion.getGiftBrackets();
        if (giftBrackets == null) {
            giftBrackets = new ArrayList();
        }
        GiftBottomSheet giftBottomSheet = new GiftBottomSheet(arrayList, giftBrackets, zegoVideoCallActivity.isStreamer, false, null, null, 56, null);
        if (zegoVideoCallActivity.isStreamer) {
            giftBottomSheet.setUserId(zegoVideoCallActivity.getViewModel().getVideoDetails() != null ? r0.getUserId() : -1L);
        } else {
            VideoDetailModel videoDetails = zegoVideoCallActivity.getViewModel().getVideoDetails();
            giftBottomSheet.setStreamerId(videoDetails != null ? videoDetails.getStreamerId() : -1L);
        }
        if (giftBottomSheet.isAdded() || giftBottomSheet.isVisible()) {
            return;
        }
        giftBottomSheet.show(zegoVideoCallActivity.getSupportFragmentManager(), "GiftBottomSheet");
    }

    public static final void onClicks$lambda$24(ZegoVideoCallActivity zegoVideoCallActivity) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        LinearLayout root = zegoVideoCallActivity.getBinding().videoInput.getRoot();
        Intrinsics.checkNotNullExpressionValue(root, "binding.videoInput.root");
        ViewExtKt.showOrGone(root, false);
    }

    private final void handleDragging() {
        ActivityZegoVideoCallBinding activityZegoVideoCallBinding = this._binding;
        final RelativeLayout relativeLayout = activityZegoVideoCallBinding != null ? activityZegoVideoCallBinding.rootLayout : null;
        ActivityZegoVideoCallBinding activityZegoVideoCallBinding2 = this._binding;
        FrameLayout frameLayout = activityZegoVideoCallBinding2 != null ? activityZegoVideoCallBinding2.localLayoutParent : null;
        ActivityZegoVideoCallBinding activityZegoVideoCallBinding3 = this._binding;
        FrameLayout frameLayout2 = activityZegoVideoCallBinding3 != null ? activityZegoVideoCallBinding3.remoteParentLayout : null;
        ActivityZegoVideoCallBinding activityZegoVideoCallBinding4 = this._binding;
        final RecyclerView recyclerView = activityZegoVideoCallBinding4 != null ? activityZegoVideoCallBinding4.rv : null;
        if (frameLayout != null) {
            frameLayout.setOnTouchListener(new View.OnTouchListener() {
                private float dx;
                private float dy;
                private boolean isClickAction;
                private boolean isDragging;
                private long touchStartTime;

                @Override
                public boolean onTouch(android.view.View r10, android.view.MotionEvent r11) {
                    throw new UnsupportedOperationException("Method not decompiled: app.callpe.ui.call.ZegoVideoCallActivity$handleDragging$1.onTouch(android.view.View, android.view.MotionEvent):boolean");
                }
            });
        }
        if (!this.isStreamer || frameLayout2 == null) {
            return;
        }
        frameLayout2.setOnTouchListener(new View.OnTouchListener() {
            private float dx;
            private float dy;
            private boolean isClickAction;
            private boolean isDragging;
            private long touchStartTime;

            @Override
            public boolean onTouch(android.view.View r9, android.view.MotionEvent r10) {
                throw new UnsupportedOperationException("Method not decompiled: app.callpe.ui.call.ZegoVideoCallActivity$handleDragging$2.onTouch(android.view.View, android.view.MotionEvent):boolean");
            }
        });
    }

    public final void resetToOriginalPosition() {
        FrameLayout frameLayout;
        Timber.e("original position " + this.originalLocalLayoutX + ',' + this.originalLocalLayoutY, new Object[0]);
        if (getViewModel().getStreamerPreviewSwitched()) {
            ActivityZegoVideoCallBinding activityZegoVideoCallBinding = this._binding;
            frameLayout = activityZegoVideoCallBinding != null ? activityZegoVideoCallBinding.localLayoutParent : null;
            if (frameLayout != null) {
                frameLayout.setX(this.originalLocalLayoutX);
                frameLayout.setY(this.originalLocalLayoutY);
                return;
            }
            return;
        }
        ActivityZegoVideoCallBinding activityZegoVideoCallBinding2 = this._binding;
        frameLayout = activityZegoVideoCallBinding2 != null ? activityZegoVideoCallBinding2.remoteParentLayout : null;
        if (frameLayout != null) {
            frameLayout.setX(this.originalLocalLayoutX);
            frameLayout.setY(this.originalLocalLayoutY);
        }
    }

    public final void touchEventClicked() {
        if (this._binding == null) {
            return;
        }
        LinearLayout root = getBinding().videoInput.getRoot();
        Intrinsics.checkNotNullExpressionValue(root, "binding.videoInput.root");
        if (root.getVisibility() == 0) {
            LinearLayout root2 = getBinding().videoInput.getRoot();
            Intrinsics.checkNotNullExpressionValue(root2, "binding.videoInput.root");
            ViewExtKt.showOrGone(root2, false);
            AppCompatEditText appCompatEditText = getBinding().videoInput.messageInput;
            Intrinsics.checkNotNullExpressionValue(appCompatEditText, "binding.videoInput.messageInput");
            ViewExtKt.hideSoftKeyboard((View) appCompatEditText);
        } else {
            LinearLayout linearLayout = getBinding().buttonLayout;
            Intrinsics.checkNotNullExpressionValue(linearLayout, "binding.buttonLayout");
            if (linearLayout.getVisibility() == 0) {
                LinearLayout linearLayout2 = getBinding().buttonLayout;
                Intrinsics.checkNotNullExpressionValue(linearLayout2, "binding.buttonLayout");
                ViewExtKt.showOrGone(linearLayout2, false);
                getBinding().buttonLayout.startAnimation(AnimationUtils.loadAnimation((Context) this, 2130772036));
                LinearLayout linearLayout3 = getBinding().encryptionLayout;
                Intrinsics.checkNotNullExpressionValue(linearLayout3, "binding.encryptionLayout");
                ViewExtKt.showOrGone(linearLayout3, false);
                if (getViewModel().getShowBalanceCard()) {
                    LinearLayout linearLayout4 = getBinding().freeCardLayout;
                    Intrinsics.checkNotNullExpressionValue(linearLayout4, "binding.freeCardLayout");
                    linearLayout4.setVisibility(0);
                }
            } else {
                LinearLayout linearLayout5 = getBinding().buttonLayout;
                Intrinsics.checkNotNullExpressionValue(linearLayout5, "binding.buttonLayout");
                ViewExtKt.showOrGone(linearLayout5, true);
                getBinding().buttonLayout.startAnimation(AnimationUtils.loadAnimation((Context) this, 2130772039));
                LinearLayout linearLayout6 = getBinding().encryptionLayout;
                Intrinsics.checkNotNullExpressionValue(linearLayout6, "binding.encryptionLayout");
                ViewExtKt.showOrGone(linearLayout6, true);
                LinearLayout linearLayout7 = getBinding().freeCardLayout;
                Intrinsics.checkNotNullExpressionValue(linearLayout7, "binding.freeCardLayout");
                linearLayout7.setVisibility(8);
            }
        }
        if (getViewModel().getFaceUnityViewVisible()) {
            getViewModel().setFaceUnityViewVisible(false);
            View view = getBinding().faceUnityView;
            Intrinsics.checkNotNullExpressionValue(view, "binding.faceUnityView");
            view.setVisibility(8);
            getBinding().beautyBtn.setActivated(!getBinding().beautyBtn.isActivated());
        }
        adjustLocalLayoutPosition();
    }

    private final void adjustLocalLayoutPosition() {
        if (this._binding == null) {
            return;
        }
        try {
            if (this.isStreamer || getViewModel().getLocalLayoutPositionChanged()) {
                return;
            }
            if (getBinding().buttonLayout.getVisibility() == 0) {
                ViewGroup.LayoutParams layoutParams = getBinding().localLayoutParent.getLayoutParams();
                Intrinsics.checkNotNull(layoutParams, "null cannot be cast to non-null type android.widget.RelativeLayout.LayoutParams");
                RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) layoutParams;
                layoutParams2.bottomMargin = getResources().getDimensionPixelSize(2131166619);
                getBinding().localLayoutParent.setLayoutParams(layoutParams2);
            } else {
                LinearLayout root = getBinding().videoInput.getRoot();
                Intrinsics.checkNotNullExpressionValue(root, "binding.videoInput.root");
                if (root.getVisibility() == 0) {
                    ViewGroup.LayoutParams layoutParams3 = getBinding().localLayoutParent.getLayoutParams();
                    Intrinsics.checkNotNull(layoutParams3, "null cannot be cast to non-null type android.widget.RelativeLayout.LayoutParams");
                    RelativeLayout.LayoutParams layoutParams4 = (RelativeLayout.LayoutParams) layoutParams3;
                    layoutParams4.bottomMargin = getResources().getDimensionPixelSize(2131166619);
                    getBinding().localLayoutParent.setLayoutParams(layoutParams4);
                } else {
                    ViewGroup.LayoutParams layoutParams5 = getBinding().localLayoutParent.getLayoutParams();
                    Intrinsics.checkNotNull(layoutParams5, "null cannot be cast to non-null type android.widget.RelativeLayout.LayoutParams");
                    RelativeLayout.LayoutParams layoutParams6 = (RelativeLayout.LayoutParams) layoutParams5;
                    layoutParams6.bottomMargin = getResources().getDimensionPixelSize(2131166620);
                    getBinding().localLayoutParent.setLayoutParams(layoutParams6);
                }
            }
        } catch (Exception e) {
            Timber.e(e);
        }
    }

    public final List<String> getPermissions() {
        return this.permissions;
    }

    public final void initVideo() {
        Object valueOf;
        String str;
        StreamerModel userDetails;
        String str2;
        LocalRtcVideoView localRtcVideoView;
        View view;
        String str3;
        StreamerModel streamerDetails;
        Intent intent = getIntent();
        this.videoId = intent.getLongExtra(Constants.KEY_CALLING_VIDEO_ID, -1L);
        Timber.e("video Id " + this.videoId, new Object[0]);
        getViewModel().submitVideoCallErrorByVideoId(this.videoId, "Video Call screen started for Id " + this.videoId);
        if (permissionsGranted(this.permissions)) {
            this.mChannel = intent.getStringExtra(Constants.KEY_CALLING_CHANNEL);
            String stringExtra = intent.getStringExtra(Constants.KEY_CALL_TYPE);
            if (stringExtra == null) {
                stringExtra = Constants.VIDEO_CALL;
            }
            this.callType = stringExtra;
            getViewModel().submitVideoCallErrorByVideoId(this.videoId, "Permissions granted.");
            String str4 = this.mChannel;
            if ((str4 == null || str4.length() == 0) && this.videoId != -1) {
                if (this.retryCount <= 2) {
                    Timber.i("Retrying  " + this.retryCount, new Object[0]);
                    getViewModel().getVideoRetryInfo(this.videoId, this.retryCount);
                    return;
                }
                getViewModel().submitVideoCallError("Video call failed Room Id is empty");
                ActivityExtKt.toast((Activity) this, "Video call failed Room Id is empty");
                finish();
                return;
            }
            Timber.e("Room Id " + this.mChannel, new Object[0]);
            this.caller = intent.getStringExtra(Constants.KEY_CALLER);
            getViewModel().setCaller(this.caller);
            this.accessToken = intent.getStringExtra(Constants.KEY_AGORA_ACCESS_TOKEN);
            if (this.isStreamer) {
                VideoDetailModel videoDetails = getViewModel().getVideoDetails();
                if (videoDetails != null) {
                    valueOf = Long.valueOf(videoDetails.getStreamerId());
                }
                valueOf = null;
            } else {
                VideoDetailModel videoDetails2 = getViewModel().getVideoDetails();
                if (videoDetails2 != null) {
                    valueOf = Integer.valueOf(videoDetails2.getUserId());
                }
                valueOf = null;
            }
            if (this.isStreamer) {
                VideoDetailModel videoDetails3 = getViewModel().getVideoDetails();
                str = (videoDetails3 == null || (streamerDetails = videoDetails3.getStreamerDetails()) == null) ? null : streamerDetails.getName();
            } else {
                VideoDetailModel videoDetails4 = getViewModel().getVideoDetails();
                if (videoDetails4 == null || (userDetails = videoDetails4.getUserDetails()) == null || (str = userDetails.getName()) == null) {
                    str = "user";
                }
            }
            String str5 = str;
            if (str5 == null || str5.length() == 0) {
                str = "user_" + valueOf;
            }
            if (!this.isStreamer) {
                resetBeauty();
            }
            enableMicrophone(true);
            ActivityZegoVideoCallBinding activityZegoVideoCallBinding = this._binding;
            AppCompatImageView appCompatImageView = activityZegoVideoCallBinding != null ? activityZegoVideoCallBinding.btnSpeaker : null;
            if (appCompatImageView != null) {
                appCompatImageView.setActivated(true);
            }
            Timber.e("USER Id " + valueOf, new Object[0]);
            Timber.e("USER name " + str, new Object[0]);
            VideoDetailModel videoDetails5 = getViewModel().getVideoDetails();
            if (videoDetails5 == null || (str2 = videoDetails5.getRtcProvider()) == null) {
                str2 = "ZEGO";
            }
            initStreamerBeauty(str2);
            Timber.i("userCallRetryCount " + this.userCallRetryCount, new Object[0]);
            getViewModel().submitVideoCallError("Connecting to zego server");
            String str6 = this.mChannel;
            if (str6 != null && (str3 = this.accessToken) != null) {
                RtcRoomDetails rtcRoomDetails = new RtcRoomDetails(str6, str3, String.valueOf(valueOf), str.toString(), false, 0L, 48, null);
                RtcManager rtcManager = this.rtcManager;
                if (rtcManager != null) {
                    rtcManager.joinRtcRoom(rtcRoomDetails);
                }
            }
            RtcManager rtcManager2 = this.rtcManager;
            if (rtcManager2 != null) {
                rtcManager2.openMicrophone(true);
            }
            RtcManager rtcManager3 = this.rtcManager;
            if (rtcManager3 != null) {
                rtcManager3.audioRouteToSpeaker(true);
            }
            if (isAudioCall()) {
                RtcManager rtcManager4 = this.rtcManager;
                if (rtcManager4 != null) {
                    rtcManager4.enableCamera(false);
                }
                ActivityZegoVideoCallBinding activityZegoVideoCallBinding2 = this._binding;
                ConstraintLayout constraintLayout = activityZegoVideoCallBinding2 != null ? activityZegoVideoCallBinding2.blurLocalPreviewLayout : null;
                if (constraintLayout != null) {
                    ((View) constraintLayout).setVisibility(0);
                }
                RemoteRtcVideoView remoteRtcVideoView = this.mRemotePreviewLayout;
                if (remoteRtcVideoView != null) {
                    ViewExtKt.showOrGone(remoteRtcVideoView, false);
                }
                ActivityZegoVideoCallBinding activityZegoVideoCallBinding3 = this._binding;
                if (activityZegoVideoCallBinding3 != null && (view = activityZegoVideoCallBinding3.videoStopLayout) != null) {
                    ViewExtKt.showOrGone(view, true);
                }
                ActivityZegoVideoCallBinding activityZegoVideoCallBinding4 = this._binding;
                if (activityZegoVideoCallBinding4 != null && (localRtcVideoView = activityZegoVideoCallBinding4.localPreviewLayout) != null) {
                    ViewExtKt.setHeightToZero(localRtcVideoView);
                }
                ActivityZegoVideoCallBinding activityZegoVideoCallBinding5 = this._binding;
                AppCompatImageView appCompatImageView2 = activityZegoVideoCallBinding5 != null ? activityZegoVideoCallBinding5.btnPauseVideo : null;
                if (appCompatImageView2 != null) {
                    ((View) appCompatImageView2).setVisibility(8);
                }
                ActivityZegoVideoCallBinding activityZegoVideoCallBinding6 = this._binding;
                AppCompatImageView appCompatImageView3 = activityZegoVideoCallBinding6 != null ? activityZegoVideoCallBinding6.btnSwitchCamera : null;
                if (appCompatImageView3 != null) {
                    ((View) appCompatImageView3).setVisibility(8);
                }
            } else {
                RtcManager rtcManager5 = this.rtcManager;
                if (rtcManager5 != null) {
                    rtcManager5.enableCamera(true);
                }
                RtcManager rtcManager6 = this.rtcManager;
                if (rtcManager6 != null) {
                    rtcManager6.useFrontCamera(true);
                }
            }
            starServiceFunc();
            getViewModel().getGifts();
            fromNotification();
            return;
        }
        Job job = this.userJoinJob;
        if (job != null) {
            JobKt.cancel$default(job, "Permission are not granted.", (Throwable) null, 2, (Object) null);
        }
        getViewModel().submitVideoCallErrorByVideoId(this.videoId, "Permission are not granted.");
        requestPermissionsIfNeeded(this.permissions);
    }

    private final void initStreamerBeauty(String currentSDK) {
        if (this.isStreamer) {
            BuildersKt.launch$default(LifecycleOwnerKt.getLifecycleScope((LifecycleOwner) this), (CoroutineContext) null, (CoroutineStart) null, new ZegoVideoCallActivity$initStreamerBeauty$1(currentSDK, this, null), 3, (Object) null);
        }
    }

    private final void fromNotification() {
        View view;
        Intent intent = getIntent();
        if (intent != null && intent.getBooleanExtra(Constants.FROM_NOTIFICATION_CLICK, false)) {
            Context context = (Context) this;
            getBinding().btnPauseVideo.setActivated(SharedPref.getBoolean(context, PrefKeys.VIDEO_MUTE_BTN_CLICK));
            if (!isAudioCall()) {
                if (!getBinding().btnPauseVideo.isActivated()) {
                    LocalRtcVideoView localRtcVideoView = getBinding().localPreviewLayout;
                    Intrinsics.checkNotNullExpressionValue(localRtcVideoView, "binding.localPreviewLayout");
                    ViewExtKt.setHeightMatchParent(localRtcVideoView);
                } else {
                    LocalRtcVideoView localRtcVideoView2 = getBinding().localPreviewLayout;
                    Intrinsics.checkNotNullExpressionValue(localRtcVideoView2, "binding.localPreviewLayout");
                    ViewExtKt.setHeightToZero(localRtcVideoView2);
                }
                View view2 = getBinding().blurLocalPreviewLayout;
                Intrinsics.checkNotNullExpressionValue(view2, "binding.blurLocalPreviewLayout");
                view2.setVisibility(getBinding().btnPauseVideo.isActivated() ? 0 : 8);
            } else {
                LocalRtcVideoView localRtcVideoView3 = getBinding().localPreviewLayout;
                Intrinsics.checkNotNullExpressionValue(localRtcVideoView3, "binding.localPreviewLayout");
                ViewExtKt.setHeightToZero(localRtcVideoView3);
                View view3 = getBinding().blurLocalPreviewLayout;
                Intrinsics.checkNotNullExpressionValue(view3, "binding.blurLocalPreviewLayout");
                view3.setVisibility(0);
            }
            boolean z = SharedPref.getBoolean(context, PrefKeys.MUTE_BTN_CLICK);
            AppCompatImageView appCompatImageView = this.mMuteBtn;
            if (appCompatImageView != null) {
                appCompatImageView.setActivated(z);
            }
            getBinding().btnSwitchCamera.setActivated(SharedPref.getBoolean(context, PrefKeys.CAMERA_SWITCH_BTN_CLICK));
            if (SharedPref.getBoolean(context, PrefKeys.REMOTE_USER_CAMERA_STATE)) {
                RemoteRtcVideoView remoteRtcVideoView = this.mRemotePreviewLayout;
                if (remoteRtcVideoView != null) {
                    ViewExtKt.showOrGone(remoteRtcVideoView, false);
                }
                ActivityZegoVideoCallBinding activityZegoVideoCallBinding = this._binding;
                if (activityZegoVideoCallBinding != null && (view = activityZegoVideoCallBinding.videoStopLayout) != null) {
                    ViewExtKt.showOrGone(view, true);
                }
            }
            switchNonCameraView();
        }
    }

    public final void setupLocalPreview() {
        if (this.isStreamer) {
            LocalRtcVideoView localRtcVideoView = this.mLocalPreviewLayout;
            if (localRtcVideoView != null) {
                VideoDetailModel videoDetails = getViewModel().getVideoDetails();
                localRtcVideoView.setUserID(String.valueOf(videoDetails != null ? Long.valueOf(videoDetails.getStreamerId()) : null), false, this.currentSDK);
            }
            RemoteRtcVideoView remoteRtcVideoView = this.mRemotePreviewLayout;
            if (remoteRtcVideoView != null) {
                VideoDetailModel videoDetails2 = getViewModel().getVideoDetails();
                remoteRtcVideoView.setUserID(String.valueOf(videoDetails2 != null ? Integer.valueOf(videoDetails2.getUserId()) : null), true, this.currentSDK);
                return;
            }
            return;
        }
        RemoteRtcVideoView remoteRtcVideoView2 = this.mRemotePreviewLayout;
        if (remoteRtcVideoView2 != null) {
            VideoDetailModel videoDetails3 = getViewModel().getVideoDetails();
            remoteRtcVideoView2.setUserID(String.valueOf(videoDetails3 != null ? Long.valueOf(videoDetails3.getStreamerId()) : null), false, this.currentSDK);
        }
        LocalRtcVideoView localRtcVideoView2 = this.mLocalPreviewLayout;
        if (localRtcVideoView2 != null) {
            VideoDetailModel videoDetails4 = getViewModel().getVideoDetails();
            localRtcVideoView2.setUserID(String.valueOf(videoDetails4 != null ? Integer.valueOf(videoDetails4.getUserId()) : null), true, this.currentSDK);
        }
    }

    private final void resetBeauty() {
        try {
            RtcManager rtcManager = this.rtcManager;
            if (rtcManager != null) {
                rtcManager.disableFilter();
            }
        } catch (Exception e) {
            Timber.e(e);
        }
    }

    private final void openRechargePopup() {
        LottieAnimationView lottieAnimationView;
        ActivityZegoVideoCallBinding activityZegoVideoCallBinding = this._binding;
        if (activityZegoVideoCallBinding == null || (lottieAnimationView = activityZegoVideoCallBinding.rechargeBtn) == null) {
            return;
        }
        lottieAnimationView.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ZegoVideoCallActivity.openRechargePopup$lambda$29(ZegoVideoCallActivity.this, view);
            }
        });
    }

    public static final void openRechargePopup$lambda$29(final ZegoVideoCallActivity zegoVideoCallActivity, View view) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        try {
            RechargeDialog rechargeDialog = new RechargeDialog(null, null, null, zegoVideoCallActivity.getString(2131953109), null, new Function0<Unit>() {
                public final void m919invoke() {
                }

                public Object invoke() {
                    m919invoke();
                    return Unit.INSTANCE;
                }
            }, new Function0<Unit>() {
                public final void m920invoke() {
                }

                public Object invoke() {
                    m920invoke();
                    return Unit.INSTANCE;
                }
            }, new Function0<Unit>() {
                {
                    super(0);
                }

                public Object invoke() {
                    m921invoke();
                    return Unit.INSTANCE;
                }

                public final void m921invoke() {
                    ZegoVideoCallActivity.this.enablePip();
                }
            });
            rechargeDialog.setCancelable(true);
            if (!rechargeDialog.isAdded() && !rechargeDialog.isVisible()) {
                rechargeDialog.setFromZegoScreen(true);
                rechargeDialog.show(zegoVideoCallActivity.getSupportFragmentManager(), "RechargeDialog");
            }
        } catch (Exception unused) {
            Activity activity = (Activity) zegoVideoCallActivity;
            String string = zegoVideoCallActivity.getString(2131951993);
            Intrinsics.checkNotNullExpressionValue(string, "getString(R.string.error_unknown)");
            ActivityExtKt.toast(activity, string);
        }
    }

    private final void onButtonClicked() {
        throw new UnsupportedOperationException("Method not decompiled: app.callpe.ui.call.ZegoVideoCallActivity.onButtonClicked():void");
    }

    public static final void onButtonClicked$lambda$30(ZegoVideoCallActivity zegoVideoCallActivity, View view) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        if (zegoVideoCallActivity.videoId == -1) {
            zegoVideoCallActivity.finish();
            return;
        }
        zegoVideoCallActivity.getViewModel().videoCallEnd(zegoVideoCallActivity.videoId);
        zegoVideoCallActivity.getViewModel().setEgressActive(false);
        zegoVideoCallActivity.endCall();
    }

    public static final void onButtonClicked$lambda$31(ZegoVideoCallActivity zegoVideoCallActivity, View view) {
        AppCompatImageView appCompatImageView;
        AppCompatImageView appCompatImageView2;
        AppCompatImageView appCompatImageView3;
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        ActivityZegoVideoCallBinding activityZegoVideoCallBinding = zegoVideoCallActivity._binding;
        Boolean bool = null;
        AppCompatImageView appCompatImageView4 = activityZegoVideoCallBinding != null ? activityZegoVideoCallBinding.btnSpeaker : null;
        if (appCompatImageView4 != null) {
            ActivityZegoVideoCallBinding activityZegoVideoCallBinding2 = zegoVideoCallActivity._binding;
            if (activityZegoVideoCallBinding2 != null && (appCompatImageView3 = activityZegoVideoCallBinding2.btnSpeaker) != null) {
                bool = Boolean.valueOf(appCompatImageView3.isActivated());
            }
            Intrinsics.checkNotNull(bool);
            appCompatImageView4.setActivated(!bool.booleanValue());
        }
        Context context = (Context) zegoVideoCallActivity;
        ActivityZegoVideoCallBinding activityZegoVideoCallBinding3 = zegoVideoCallActivity._binding;
        SharedPref.setBoolean(context, PrefKeys.SPEAKER_BTN, (activityZegoVideoCallBinding3 == null || (appCompatImageView2 = activityZegoVideoCallBinding3.btnSpeaker) == null || !appCompatImageView2.isActivated()) ? false : true);
        RtcManager rtcManager = zegoVideoCallActivity.rtcManager;
        if (rtcManager != null) {
            ActivityZegoVideoCallBinding activityZegoVideoCallBinding4 = zegoVideoCallActivity._binding;
            rtcManager.audioRouteToSpeaker((activityZegoVideoCallBinding4 == null || (appCompatImageView = activityZegoVideoCallBinding4.btnSpeaker) == null || !appCompatImageView.isActivated()) ? false : true);
        }
    }

    public static final void onButtonClicked$lambda$32(ZegoVideoCallActivity zegoVideoCallActivity, View view) {
        View view2;
        View view3;
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        zegoVideoCallActivity.getBinding().btnPauseVideo.setActivated(!zegoVideoCallActivity.getBinding().btnPauseVideo.isActivated());
        if (zegoVideoCallActivity.getViewModel().getPreviewSwitched()) {
            RemoteRtcVideoView remoteRtcVideoView = zegoVideoCallActivity.getBinding().remotePreviewLayout;
            Intrinsics.checkNotNullExpressionValue(remoteRtcVideoView, "binding.remotePreviewLayout");
            remoteRtcVideoView.setVisibility(zegoVideoCallActivity.getBinding().btnPauseVideo.isActivated() ^ true ? 0 : 8);
            ActivityZegoVideoCallBinding activityZegoVideoCallBinding = zegoVideoCallActivity._binding;
            if (activityZegoVideoCallBinding != null && (view3 = activityZegoVideoCallBinding.videoStopLayout) != null) {
                ViewExtKt.showOrGone(view3, zegoVideoCallActivity.getBinding().btnPauseVideo.isActivated());
            }
        } else {
            View view4 = zegoVideoCallActivity.getBinding().blurLocalPreviewLayout;
            Intrinsics.checkNotNullExpressionValue(view4, "binding.blurLocalPreviewLayout");
            view4.setVisibility(zegoVideoCallActivity.getBinding().btnPauseVideo.isActivated() ? 0 : 8);
            if (zegoVideoCallActivity.getViewModel().getStreamerPreviewSwitched()) {
                View view5 = zegoVideoCallActivity.getBinding().blurLocalPreviewLayout;
                Intrinsics.checkNotNullExpressionValue(view5, "binding.blurLocalPreviewLayout");
                view5.setVisibility(8);
                ActivityZegoVideoCallBinding activityZegoVideoCallBinding2 = zegoVideoCallActivity._binding;
                if (activityZegoVideoCallBinding2 != null && (view2 = activityZegoVideoCallBinding2.videoStopLayout) != null) {
                    ViewExtKt.showOrGone(view2, zegoVideoCallActivity.getBinding().btnPauseVideo.isActivated());
                }
            }
            if (!zegoVideoCallActivity.getBinding().btnPauseVideo.isActivated()) {
                LocalRtcVideoView localRtcVideoView = zegoVideoCallActivity.getBinding().localPreviewLayout;
                Intrinsics.checkNotNullExpressionValue(localRtcVideoView, "binding.localPreviewLayout");
                ViewExtKt.setHeightMatchParent(localRtcVideoView);
                LocalRtcVideoView localRtcVideoView2 = zegoVideoCallActivity.getBinding().localPreviewLayout;
                Intrinsics.checkNotNullExpressionValue(localRtcVideoView2, "binding.localPreviewLayout");
                ViewExtKt.showOrGone(localRtcVideoView2, true);
            } else {
                LocalRtcVideoView localRtcVideoView3 = zegoVideoCallActivity.getBinding().localPreviewLayout;
                Intrinsics.checkNotNullExpressionValue(localRtcVideoView3, "binding.localPreviewLayout");
                ViewExtKt.setHeightToZero(localRtcVideoView3);
            }
        }
        SharedPref.setBoolean((Context) zegoVideoCallActivity, PrefKeys.VIDEO_MUTE_BTN_CLICK, zegoVideoCallActivity.getBinding().btnPauseVideo.isActivated());
        RtcManager rtcManager = zegoVideoCallActivity.rtcManager;
        if (rtcManager != null) {
            rtcManager.enableCamera(!zegoVideoCallActivity.getBinding().btnPauseVideo.isActivated());
        }
    }

    public static final void onButtonClicked$lambda$33(ZegoVideoCallActivity zegoVideoCallActivity, View view) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        if (zegoVideoCallActivity._binding == null) {
            CrashLogHelper.INSTANCE.logError("Binding is null action: _binding?.beautyBtn?.setOnClickListener");
            return;
        }
        zegoVideoCallActivity.getViewModel().setFaceUnityViewVisible(!zegoVideoCallActivity.getViewModel().getFaceUnityViewVisible());
        zegoVideoCallActivity.getBinding().beautyBtn.setActivated(!zegoVideoCallActivity.getBinding().beautyBtn.isActivated());
        View view2 = zegoVideoCallActivity.getBinding().faceUnityView;
        Intrinsics.checkNotNullExpressionValue(view2, "binding.faceUnityView");
        view2.setVisibility(zegoVideoCallActivity.getViewModel().getFaceUnityViewVisible() ? 0 : 8);
    }

    public static final void onButtonClicked$lambda$34(ZegoVideoCallActivity zegoVideoCallActivity, View view) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        if (zegoVideoCallActivity._binding == null) {
            CrashLogHelper.INSTANCE.logError("Binding is null action: _binding?.btnMute?.setOnClickListener");
            return;
        }
        AppCompatImageView appCompatImageView = zegoVideoCallActivity.mMuteBtn;
        if (appCompatImageView != null) {
            Intrinsics.checkNotNull(appCompatImageView != null ? Boolean.valueOf(appCompatImageView.isActivated()) : null);
            appCompatImageView.setActivated(!r1.booleanValue());
        }
        SharedPref.setBoolean((Context) zegoVideoCallActivity, PrefKeys.MUTE_BTN_CLICK, zegoVideoCallActivity.getBinding().btnMute.isActivated());
        RtcManager rtcManager = zegoVideoCallActivity.rtcManager;
        if (rtcManager != null) {
            rtcManager.openMicrophone(!zegoVideoCallActivity.getBinding().btnMute.isActivated());
        }
        if (zegoVideoCallActivity.getBinding().btnMute.isActivated()) {
            return;
        }
        zegoVideoCallActivity.enableMicrophone(true);
    }

    public static final void onButtonClicked$lambda$35(ZegoVideoCallActivity zegoVideoCallActivity, View view) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        if (zegoVideoCallActivity._binding == null) {
            CrashLogHelper.INSTANCE.logError("Binding is null action: _binding?.btnSwitchCamera?.setOnClickListener");
            return;
        }
        zegoVideoCallActivity.getBinding().btnSwitchCamera.setActivated(!zegoVideoCallActivity.getBinding().btnSwitchCamera.isActivated());
        SharedPref.setBoolean((Context) zegoVideoCallActivity, PrefKeys.CAMERA_SWITCH_BTN_CLICK, zegoVideoCallActivity.getBinding().btnSwitchCamera.isActivated());
        RtcManager rtcManager = zegoVideoCallActivity.rtcManager;
        if (rtcManager != null) {
            rtcManager.useFrontCamera(!zegoVideoCallActivity.getBinding().btnSwitchCamera.isActivated());
        }
    }

    public static final void onButtonClicked$lambda$36(ZegoVideoCallActivity zegoVideoCallActivity, View view) {
        RemoteRtcVideoView remoteRtcVideoView;
        View view2;
        View view3;
        View view4;
        View view5;
        RemoteRtcVideoView remoteRtcVideoView2;
        View view6;
        RemoteRtcVideoView remoteRtcVideoView3;
        RemoteRtcVideoView remoteRtcVideoView4;
        View view7;
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        if (zegoVideoCallActivity.isBroadCastScreen || zegoVideoCallActivity.isAudioCall()) {
            return;
        }
        zegoVideoCallActivity.getBinding().hideUserBtn.setActivated(!zegoVideoCallActivity.getBinding().hideUserBtn.isActivated());
        zegoVideoCallActivity.getViewModel().setUserPreviewBlocked(zegoVideoCallActivity.getBinding().hideUserBtn.isActivated());
        if (zegoVideoCallActivity.getViewModel().getStreamerPreviewSwitched()) {
            if (!zegoVideoCallActivity.getViewModel().getRemoteCameraEnabled()) {
                ActivityZegoVideoCallBinding activityZegoVideoCallBinding = zegoVideoCallActivity._binding;
                if (activityZegoVideoCallBinding == null || (view7 = activityZegoVideoCallBinding.blurRemotePreviewLayout) == null) {
                    return;
                }
                ViewExtKt.showOrGone(view7, true);
                return;
            }
            if (!zegoVideoCallActivity.getBinding().hideUserBtn.isActivated()) {
                ActivityZegoVideoCallBinding activityZegoVideoCallBinding2 = zegoVideoCallActivity._binding;
                if (activityZegoVideoCallBinding2 != null && (remoteRtcVideoView4 = activityZegoVideoCallBinding2.remotePreviewLayout) != null) {
                    ViewExtKt.setHeightMatchParent(remoteRtcVideoView4);
                }
                ActivityZegoVideoCallBinding activityZegoVideoCallBinding3 = zegoVideoCallActivity._binding;
                if (activityZegoVideoCallBinding3 != null && (remoteRtcVideoView3 = activityZegoVideoCallBinding3.remotePreviewLayout) != null) {
                    ViewExtKt.showOrGone(remoteRtcVideoView3, true);
                }
                ActivityZegoVideoCallBinding activityZegoVideoCallBinding4 = zegoVideoCallActivity._binding;
                if (activityZegoVideoCallBinding4 == null || (view6 = activityZegoVideoCallBinding4.blurRemotePreviewLayout) == null) {
                    return;
                }
                ViewExtKt.showOrGone(view6, false);
                return;
            }
            ActivityZegoVideoCallBinding activityZegoVideoCallBinding5 = zegoVideoCallActivity._binding;
            if (activityZegoVideoCallBinding5 != null && (remoteRtcVideoView2 = activityZegoVideoCallBinding5.remotePreviewLayout) != null) {
                ViewExtKt.setHeightToZero(remoteRtcVideoView2);
            }
            ActivityZegoVideoCallBinding activityZegoVideoCallBinding6 = zegoVideoCallActivity._binding;
            if (activityZegoVideoCallBinding6 == null || (view5 = activityZegoVideoCallBinding6.blurRemotePreviewLayout) == null) {
                return;
            }
            ViewExtKt.showOrGone(view5, true);
            return;
        }
        if (!zegoVideoCallActivity.getViewModel().getRemoteCameraEnabled()) {
            ActivityZegoVideoCallBinding activityZegoVideoCallBinding7 = zegoVideoCallActivity._binding;
            remoteRtcVideoView = activityZegoVideoCallBinding7 != null ? activityZegoVideoCallBinding7.remotePreviewLayout : null;
            if (remoteRtcVideoView != null) {
                remoteRtcVideoView.setVisibility(8);
            }
            ActivityZegoVideoCallBinding activityZegoVideoCallBinding8 = zegoVideoCallActivity._binding;
            if (activityZegoVideoCallBinding8 == null || (view4 = activityZegoVideoCallBinding8.videoStopLayout) == null) {
                return;
            }
            ViewExtKt.showOrGone(view4, true);
            return;
        }
        if (!zegoVideoCallActivity.getBinding().hideUserBtn.isActivated()) {
            ActivityZegoVideoCallBinding activityZegoVideoCallBinding9 = zegoVideoCallActivity._binding;
            if (activityZegoVideoCallBinding9 != null && (view3 = activityZegoVideoCallBinding9.videoStopLayout) != null) {
                ViewExtKt.showOrGone(view3, false);
            }
            ActivityZegoVideoCallBinding activityZegoVideoCallBinding10 = zegoVideoCallActivity._binding;
            remoteRtcVideoView = activityZegoVideoCallBinding10 != null ? activityZegoVideoCallBinding10.remotePreviewLayout : null;
            if (remoteRtcVideoView == null) {
                return;
            }
            remoteRtcVideoView.setVisibility(0);
            return;
        }
        ActivityZegoVideoCallBinding activityZegoVideoCallBinding11 = zegoVideoCallActivity._binding;
        remoteRtcVideoView = activityZegoVideoCallBinding11 != null ? activityZegoVideoCallBinding11.remotePreviewLayout : null;
        if (remoteRtcVideoView != null) {
            remoteRtcVideoView.setVisibility(8);
        }
        ActivityZegoVideoCallBinding activityZegoVideoCallBinding12 = zegoVideoCallActivity._binding;
        if (activityZegoVideoCallBinding12 == null || (view2 = activityZegoVideoCallBinding12.videoStopLayout) == null) {
            return;
        }
        ViewExtKt.showOrGone(view2, true);
    }

    public static final void onButtonClicked$lambda$37(ZegoVideoCallActivity zegoVideoCallActivity, View view) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        if (zegoVideoCallActivity.isBroadCastScreen) {
            zegoVideoCallActivity.stopPublishScreen();
        } else {
            zegoVideoCallActivity.startPublishScreen();
        }
    }

    public static final void onButtonClicked$lambda$38(ZegoVideoCallActivity zegoVideoCallActivity, View view) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        if (zegoVideoCallActivity._binding == null) {
            return;
        }
        LinearLayout root = zegoVideoCallActivity.getBinding().videoInput.getRoot();
        Intrinsics.checkNotNullExpressionValue(root, "binding.videoInput.root");
        if (root.getVisibility() == 0) {
            LinearLayout root2 = zegoVideoCallActivity.getBinding().videoInput.getRoot();
            Intrinsics.checkNotNullExpressionValue(root2, "binding.videoInput.root");
            ViewExtKt.showOrGone(root2, false);
            AppCompatEditText appCompatEditText = zegoVideoCallActivity.getBinding().videoInput.messageInput;
            Intrinsics.checkNotNullExpressionValue(appCompatEditText, "binding.videoInput.messageInput");
            ViewExtKt.hideSoftKeyboard((View) appCompatEditText);
        } else {
            LinearLayout linearLayout = zegoVideoCallActivity.getBinding().buttonLayout;
            Intrinsics.checkNotNullExpressionValue(linearLayout, "binding.buttonLayout");
            if (linearLayout.getVisibility() == 0) {
                LinearLayout linearLayout2 = zegoVideoCallActivity.getBinding().buttonLayout;
                Intrinsics.checkNotNullExpressionValue(linearLayout2, "binding.buttonLayout");
                ViewExtKt.showOrGone(linearLayout2, false);
                zegoVideoCallActivity.getBinding().buttonLayout.startAnimation(AnimationUtils.loadAnimation((Context) zegoVideoCallActivity, 2130772036));
            }
            LinearLayout root3 = zegoVideoCallActivity.getBinding().videoInput.getRoot();
            Intrinsics.checkNotNullExpressionValue(root3, "binding.videoInput.root");
            ViewExtKt.showOrGone(root3, true);
            zegoVideoCallActivity.getBinding().videoInput.messageInput.requestFocus();
            AppCompatEditText appCompatEditText2 = zegoVideoCallActivity.getBinding().videoInput.messageInput;
            Intrinsics.checkNotNullExpressionValue(appCompatEditText2, "binding.videoInput.messageInput");
            ViewExtKt.showSoftKeyboard((View) appCompatEditText2);
        }
        zegoVideoCallActivity.adjustLocalLayoutPosition();
    }

    public static final void onButtonClicked$lambda$39(ZegoVideoCallActivity zegoVideoCallActivity, View view) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        zegoVideoCallActivity.stopPublishScreen();
    }

    public static final void onButtonClicked$lambda$41(ZegoVideoCallActivity zegoVideoCallActivity, View view) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        if (SudGameActivity.isSudGameActivityOpen) {
            String str = zegoVideoCallActivity.currentGameRoomId;
            if (!(str == null || str.length() == 0)) {
                String str2 = zegoVideoCallActivity.currentGameRoomId;
                if (str2 != null) {
                    zegoVideoCallActivity.openGameScreen(str2);
                    return;
                }
                return;
            }
        }
        zegoVideoCallActivity.getViewModel().createSudGame(zegoVideoCallActivity.videoId, GameUtils.GameNames.LUDO);
    }

    public final void switchPreview() {
        if (this.isBroadCastScreen || isAudioCall()) {
            return;
        }
        if (this.isStreamer) {
            if (!getViewModel().getStreamerPreviewSwitched()) {
                getViewModel().setStreamerPreviewSwitched(true);
                getViewModel().switchPreview(false);
            } else {
                getViewModel().setStreamerPreviewSwitched(false);
                getViewModel().switchPreview(true);
            }
            switchNonCameraViewForStreamer();
            return;
        }
        if (!getViewModel().getPreviewSwitched()) {
            getViewModel().setPreviewSwitched(true);
            getViewModel().switchPreview(false);
        } else {
            getViewModel().setPreviewSwitched(false);
            getViewModel().switchPreview(true);
        }
        switchNonCameraView();
    }

    private final void switchNonCameraView() {
        String str;
        String str2;
        String name;
        String name2;
        String str3;
        String str4;
        String name3;
        String name4;
        String str5;
        String str6;
        String name5;
        String name6;
        String str7;
        String str8;
        String name7;
        String name8;
        VideoDetailModel videoDetails = getViewModel().getVideoDetails();
        if (videoDetails != null) {
            if (this.isStreamer) {
                if (getViewModel().getPreviewSwitched()) {
                    FragmentActivity fragmentActivity = (FragmentActivity) this;
                    RequestManager with = Glide.with(fragmentActivity);
                    StreamerModel userDetails = videoDetails.getUserDetails();
                    if (userDetails == null || (str7 = userDetails.getAvatar()) == null) {
                        str7 = "";
                    }
                    with.load(str7).into(getBinding().userImage);
                    TextView textView = getBinding().userName;
                    StreamerModel userDetails2 = videoDetails.getUserDetails();
                    textView.setText((userDetails2 == null || (name8 = userDetails2.getName()) == null) ? "" : name8);
                    RequestManager with2 = Glide.with(fragmentActivity);
                    StreamerModel streamerDetails = videoDetails.getStreamerDetails();
                    if (streamerDetails == null || (str8 = StreamerModel.getProfile$default(streamerDetails, false, 1, null)) == null) {
                        str8 = "";
                    }
                    with2.load(str8).into(getBinding().peerImage);
                    TextView textView2 = getBinding().name;
                    StreamerModel streamerDetails2 = videoDetails.getStreamerDetails();
                    textView2.setText((streamerDetails2 == null || (name7 = streamerDetails2.getName()) == null) ? "" : name7);
                    return;
                }
                FragmentActivity fragmentActivity2 = (FragmentActivity) this;
                RequestManager with3 = Glide.with(fragmentActivity2);
                StreamerModel userDetails3 = videoDetails.getUserDetails();
                if (userDetails3 == null || (str5 = userDetails3.getAvatar()) == null) {
                    str5 = "";
                }
                with3.load(str5).into(getBinding().peerImage);
                TextView textView3 = getBinding().name;
                StreamerModel userDetails4 = videoDetails.getUserDetails();
                textView3.setText((userDetails4 == null || (name6 = userDetails4.getName()) == null) ? "" : name6);
                RequestManager with4 = Glide.with(fragmentActivity2);
                StreamerModel streamerDetails3 = videoDetails.getStreamerDetails();
                if (streamerDetails3 == null || (str6 = StreamerModel.getProfile$default(streamerDetails3, false, 1, null)) == null) {
                    str6 = "";
                }
                with4.load(str6).into(getBinding().userImage);
                TextView textView4 = getBinding().userName;
                StreamerModel streamerDetails4 = videoDetails.getStreamerDetails();
                textView4.setText((streamerDetails4 == null || (name5 = streamerDetails4.getName()) == null) ? "" : name5);
                return;
            }
            if (getViewModel().getPreviewSwitched()) {
                FragmentActivity fragmentActivity3 = (FragmentActivity) this;
                RequestManager with5 = Glide.with(fragmentActivity3);
                StreamerModel streamerDetails5 = videoDetails.getStreamerDetails();
                if (streamerDetails5 == null || (str3 = StreamerModel.getProfile$default(streamerDetails5, false, 1, null)) == null) {
                    str3 = "";
                }
                with5.load(str3).into(getBinding().userImage);
                TextView textView5 = getBinding().userName;
                StreamerModel streamerDetails6 = videoDetails.getStreamerDetails();
                textView5.setText((streamerDetails6 == null || (name4 = streamerDetails6.getName()) == null) ? "" : name4);
                RequestManager with6 = Glide.with(fragmentActivity3);
                StreamerModel userDetails5 = videoDetails.getUserDetails();
                if (userDetails5 == null || (str4 = userDetails5.getAvatar()) == null) {
                    str4 = "";
                }
                with6.load(str4).into(getBinding().peerImage);
                TextView textView6 = getBinding().name;
                StreamerModel userDetails6 = videoDetails.getUserDetails();
                textView6.setText((userDetails6 == null || (name3 = userDetails6.getName()) == null) ? "" : name3);
                return;
            }
            FragmentActivity fragmentActivity4 = (FragmentActivity) this;
            RequestManager with7 = Glide.with(fragmentActivity4);
            StreamerModel streamerDetails7 = videoDetails.getStreamerDetails();
            if (streamerDetails7 == null || (str = StreamerModel.getProfile$default(streamerDetails7, false, 1, null)) == null) {
                str = "";
            }
            with7.load(str).into(getBinding().peerImage);
            TextView textView7 = getBinding().name;
            StreamerModel streamerDetails8 = videoDetails.getStreamerDetails();
            textView7.setText((streamerDetails8 == null || (name2 = streamerDetails8.getName()) == null) ? "" : name2);
            RequestManager with8 = Glide.with(fragmentActivity4);
            StreamerModel userDetails7 = videoDetails.getUserDetails();
            if (userDetails7 == null || (str2 = userDetails7.getAvatar()) == null) {
                str2 = "";
            }
            with8.load(str2).into(getBinding().userImage);
            TextView textView8 = getBinding().userName;
            StreamerModel userDetails8 = videoDetails.getUserDetails();
            textView8.setText((userDetails8 == null || (name = userDetails8.getName()) == null) ? "" : name);
        }
    }

    private final void switchNonCameraViewForStreamer() {
        String str;
        String name;
        String str2;
        String name2;
        VideoDetailModel videoDetails = getViewModel().getVideoDetails();
        if (videoDetails == null || !this.isStreamer) {
            return;
        }
        if (this._binding == null) {
            CrashLogHelper.INSTANCE.logError("Binding is null action: switchNonCameraViewForStreamer");
            return;
        }
        if (getViewModel().getStreamerPreviewSwitched()) {
            RequestManager with = Glide.with((FragmentActivity) this);
            StreamerModel streamerDetails = videoDetails.getStreamerDetails();
            if (streamerDetails == null || (str2 = StreamerModel.getProfile$default(streamerDetails, false, 1, null)) == null) {
                str2 = "";
            }
            with.load(str2).into(getBinding().peerImage);
            TextView textView = getBinding().name;
            StreamerModel streamerDetails2 = videoDetails.getStreamerDetails();
            textView.setText((streamerDetails2 == null || (name2 = streamerDetails2.getName()) == null) ? "" : name2);
            return;
        }
        RequestManager with2 = Glide.with((FragmentActivity) this);
        StreamerModel userDetails = videoDetails.getUserDetails();
        if (userDetails == null || (str = userDetails.getAvatar()) == null) {
            str = "";
        }
        with2.load(str).into(getBinding().peerImage);
        TextView textView2 = getBinding().name;
        StreamerModel userDetails2 = videoDetails.getUserDetails();
        textView2.setText((userDetails2 == null || (name = userDetails2.getName()) == null) ? "" : name);
    }

    private final void enableMicrophone(boolean enableMic) {
        try {
            if (getPackageManager().hasSystemFeature("android.hardware.microphone")) {
                Object systemService = getSystemService("audio");
                Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.media.AudioManager");
                ((AudioManager) systemService).setMicrophoneMute(!enableMic);
            }
        } catch (Exception e) {
            Timber.e(e);
        }
    }

    public void finish() {
        getViewModel().getRxBus().send(new VideoCallEvent(VideoCallEventType.CALL_ENDED, null, this.caller, 2, null));
        stopServiceFunc();
        RtcManager rtcManager = this.rtcManager;
        if (rtcManager != null) {
            rtcManager.disconnectUser(true);
        }
        if (LoginActivity.INSTANCE.isVitok()) {
            LocalRtcVideoView localRtcVideoView = this.mLocalPreviewLayout;
            if (localRtcVideoView != null) {
                localRtcVideoView.onDestroy();
            }
            if (this.isFaceDetectionEnabled) {
                try {
                    this.confidenceScores.clear();
                    Job job = this.confidenceScoreTimer;
                    if (job != null) {
                        Job.DefaultImpls.cancel$default(job, (CancellationException) null, 1, (Object) null);
                    }
                    this.confidenceScoreTimer = null;
                    RtcManager rtcManager2 = this.rtcManager;
                    if (rtcManager2 != null) {
                        rtcManager2.setFaceDetectionHandler(null);
                    }
                } catch (Exception e) {
                    Timber.e(e);
                }
            }
            this.mLocalPreviewLayout = null;
            this.mRemotePreviewLayout = null;
            this.mMuteBtn = null;
            this.mChannel = null;
            this.caller = null;
            this.accessToken = null;
            this.isPopUpShown = false;
            this.videoCallService = null;
            this.mServiceIntent = null;
        }
        super.finish();
    }

    @Override
    protected void onDestroy() {
        Dialog dialog;
        BeautyDialog beautyDialog;
        super.onDestroy();
        Job.DefaultImpls.cancel$default(this.job, (CancellationException) null, 1, (Object) null);
        Job.DefaultImpls.cancel$default(this.timerJob, (CancellationException) null, 1, (Object) null);
        Job job = this.userJoinJob;
        if (job != null) {
            Job.DefaultImpls.cancel$default(job, (CancellationException) null, 1, (Object) null);
        }
        Job job2 = this.gameJob;
        if (job2 != null) {
            Job.DefaultImpls.cancel$default(job2, (CancellationException) null, 1, (Object) null);
        }
        Disposable disposable = this.disposable;
        if (disposable != null) {
            disposable.dispose();
        }
        BeautyDialog beautyDialog2 = this.beautyDialog;
        if (beautyDialog2 != null) {
            if ((beautyDialog2 != null && beautyDialog2.isShowing()) && (beautyDialog = this.beautyDialog) != null) {
                beautyDialog.dismiss();
            }
        }
        Dialog dialog2 = this.dialog;
        if (dialog2 != null) {
            if ((dialog2 != null && dialog2.isShowing()) && (dialog = this.dialog) != null) {
                dialog.dismiss();
            }
        }
        Dialog dialog3 = this.alertDialog;
        if (dialog3 != null) {
            if (dialog3 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("alertDialog");
                dialog3 = null;
            }
            dialog3.dismiss();
        }
        if (isFinishing()) {
            unRegisterReceiver();
            stopSudGameIfRunning();
            RtcManager rtcManager = this.rtcManager;
            if (rtcManager != null) {
                rtcManager.stopLocalPreview();
            }
            RtcManager rtcManager2 = this.rtcManager;
            if (rtcManager2 != null) {
                rtcManager2.leaveRtcRoom(null);
            }
            RtcManager rtcManager3 = this.rtcManager;
            if (rtcManager3 != null) {
                rtcManager3.setEventHandler(null);
            }
            stopPublishScreen();
            if (!this.isScreenshotsEnabled) {
                App.Companion.setFlagSecureDisabled(false);
            }
            App.Companion.setVideoCallScreen(false);
            getViewModel().videoCallEnd(this.videoId);
            getViewModel().setEgressActive(false);
            finish();
        }
    }

    private final void stopSudGameIfRunning() {
        if (App.Companion.isSudScreen()) {
            Intent intent = new Intent(Constants.LUDO_GAME_ENDED);
            intent.putExtra("videoId", this.videoId);
            LocalBroadcastManager.getInstance((Context) this).sendBroadcast(intent);
        }
    }

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

    private final void registerReceiver() {
        LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance((Context) this);
        Intrinsics.checkNotNullExpressionValue(localBroadcastManager, "getInstance(this)");
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(Constants.VIDEO_CALL_FAILED);
        intentFilter.addAction(Constants.MESSAGE_RECEIVED);
        intentFilter.addAction(Constants.GIFT_REQUEST);
        intentFilter.addAction(Constants.GIFT_RECEIVE);
        intentFilter.addAction(Constants.KILL_SCREEN);
        intentFilter.addAction(Constants.ENABLE_POPUP);
        intentFilter.addAction(PaymentDetailsActivity.PAYMENT_SUCCESS_EVENT);
        intentFilter.addAction(STREAMER_USER_GAME_JOIN_REQUEST);
        intentFilter.addAction(STREAMER_USER_GAME_REQUEST_REJECT);
        intentFilter.addAction(STREAMER_USER_GAME_REQUEST_ACCEPT);
        intentFilter.addAction(Constants.LUDO_GAME_ENDED);
        localBroadcastManager.registerReceiver(this.broadcastReceiver, intentFilter);
    }

    private final void unRegisterReceiver() {
        LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance((Context) this);
        Intrinsics.checkNotNullExpressionValue(localBroadcastManager, "getInstance(this)");
        localBroadcastManager.unregisterReceiver(this.broadcastReceiver);
    }

    public final void showGameRequestPopup(VideoCallGameRequestModel model) {
        try {
            Dialog dialog = this.alertDialog;
            if (dialog != null) {
                if (dialog == null) {
                    Intrinsics.throwUninitializedPropertyAccessException("alertDialog");
                    dialog = null;
                }
                dialog.dismiss();
            }
            GameRequestDialog newInstance = GameRequestDialog.INSTANCE.newInstance(model);
            this.gameRequestDialog = newInstance;
            if (newInstance != null) {
                newInstance.setListener(this);
            }
            GameRequestDialog gameRequestDialog = this.gameRequestDialog;
            if (gameRequestDialog != null) {
                FragmentManager supportFragmentManager = getSupportFragmentManager();
                GameRequestDialog gameRequestDialog2 = this.gameRequestDialog;
                gameRequestDialog.show(supportFragmentManager, gameRequestDialog2 != null ? gameRequestDialog2.getTag() : null);
            }
        } catch (Exception e) {
            Timber.e(e);
        }
    }

    protected void onUserLeaveHint() {
        super.onUserLeaveHint();
        enablePip();
    }

    public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode, Configuration newConfig) {
        Intrinsics.checkNotNullParameter(newConfig, "newConfig");
        super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig);
        getViewModel().setInPictureInPictureMode(isInPictureInPictureMode);
        if (!isInPictureInPictureMode) {
            this.pipNumerator = 3;
            this.pipDenominator = 4;
        }
        handlePipModel(isInPictureInPictureMode);
    }

    private final void handlePipModel(boolean inPictureInPictureMode) {
        int i;
        if (this._binding == null) {
            CrashLogHelper.INSTANCE.logError("Binding is null action:  handlePipModel");
            return;
        }
        if (inPictureInPictureMode) {
            if (getViewModel().getStreamerPreviewSwitched()) {
                FrameLayout frameLayout = getBinding().remoteParentLayout;
                Intrinsics.checkNotNullExpressionValue(frameLayout, "binding.remoteParentLayout");
                ViewExtKt.showOrGone(frameLayout, false);
            } else {
                FrameLayout frameLayout2 = getBinding().localLayoutParent;
                Intrinsics.checkNotNullExpressionValue(frameLayout2, "binding.localLayoutParent");
                ViewExtKt.showOrGone(frameLayout2, false);
            }
            LinearLayout linearLayout = getBinding().buttonLayout;
            Intrinsics.checkNotNullExpressionValue(linearLayout, "binding.buttonLayout");
            ViewExtKt.showOrGone(linearLayout, false);
            LinearLayout linearLayout2 = getBinding().giftMessageLayout;
            Intrinsics.checkNotNullExpressionValue(linearLayout2, "binding.giftMessageLayout");
            ViewExtKt.showOrGone(linearLayout2, false);
            FrameLayout frameLayout3 = getBinding().rvParent;
            Intrinsics.checkNotNullExpressionValue(frameLayout3, "binding.rvParent");
            ViewExtKt.showOrGone(frameLayout3, false);
            AppCompatTextView appCompatTextView = getBinding().timerLeft;
            Intrinsics.checkNotNullExpressionValue(appCompatTextView, "binding.timerLeft");
            ViewExtKt.showOrGone((View) appCompatTextView, false);
            LinearLayout linearLayout3 = getBinding().encryptionLayout;
            Intrinsics.checkNotNullExpressionValue(linearLayout3, "binding.encryptionLayout");
            ViewExtKt.showOrGone(linearLayout3, false);
            LinearLayout linearLayout4 = getBinding().freeCardLayout;
            Intrinsics.checkNotNullExpressionValue(linearLayout4, "binding.freeCardLayout");
            linearLayout4.setVisibility(8);
            LinearLayout linearLayout5 = getBinding().userInfoParent;
            Intrinsics.checkNotNullExpressionValue(linearLayout5, "binding.userInfoParent");
            ViewExtKt.showOrInvisible(linearLayout5, false);
            AppCompatImageView appCompatImageView = getBinding().btnGiftHost;
            Intrinsics.checkNotNullExpressionValue(appCompatImageView, "binding.btnGiftHost");
            ViewExtKt.showOrInvisible((View) appCompatImageView, false);
            View view = getBinding().hideUserBtn;
            Intrinsics.checkNotNullExpressionValue(view, "binding.hideUserBtn");
            view.setVisibility(8);
            TextView textView = getBinding().admin;
            Intrinsics.checkNotNullExpressionValue(textView, "binding.admin");
            textView.setVisibility(8);
            LinearLayout linearLayout6 = getBinding().poorConnectionLayout;
            Intrinsics.checkNotNullExpressionValue(linearLayout6, "binding.poorConnectionLayout");
            linearLayout6.setVisibility(8);
            View view2 = getBinding().castBtn;
            Intrinsics.checkNotNullExpressionValue(view2, "binding.castBtn");
            view2.setVisibility(8);
            View view3 = getBinding().stopScreenShareBtn;
            Intrinsics.checkNotNullExpressionValue(view3, "binding.stopScreenShareBtn");
            view3.setVisibility(8);
            View view4 = getBinding().callType;
            Intrinsics.checkNotNullExpressionValue(view4, "binding.callType");
            view4.setVisibility(8);
            View view5 = getBinding().levelParent;
            Intrinsics.checkNotNullExpressionValue(view5, "binding.levelParent");
            view5.setVisibility(8);
            View view6 = getBinding().faceUnityView;
            Intrinsics.checkNotNullExpressionValue(view6, "binding.faceUnityView");
            view6.setVisibility(8);
            LinearLayout linearLayout7 = getBinding().ludoGamePlayingLayout;
            Intrinsics.checkNotNullExpressionValue(linearLayout7, "binding.ludoGamePlayingLayout");
            linearLayout7.setVisibility(8);
            LinearLayout linearLayout8 = getBinding().btnGameRequest;
            Intrinsics.checkNotNullExpressionValue(linearLayout8, "binding.btnGameRequest");
            linearLayout8.setVisibility(8);
            return;
        }
        LinearLayout linearLayout9 = getBinding().btnGameRequest;
        Intrinsics.checkNotNullExpressionValue(linearLayout9, "binding.btnGameRequest");
        linearLayout9.setVisibility(!this.isStreamer || this.showLudoButtonForStreamer ? 0 : 8);
        if (getViewModel().getStreamerPreviewSwitched()) {
            FrameLayout frameLayout4 = getBinding().remoteParentLayout;
            Intrinsics.checkNotNullExpressionValue(frameLayout4, "binding.remoteParentLayout");
            ViewExtKt.showOrGone(frameLayout4, true);
        } else {
            FrameLayout frameLayout5 = getBinding().localLayoutParent;
            Intrinsics.checkNotNullExpressionValue(frameLayout5, "binding.localLayoutParent");
            ViewExtKt.showOrGone(frameLayout5, true);
        }
        LinearLayout linearLayout10 = getBinding().buttonLayout;
        Intrinsics.checkNotNullExpressionValue(linearLayout10, "binding.buttonLayout");
        ViewExtKt.showOrGone(linearLayout10, true);
        FrameLayout frameLayout6 = getBinding().rvParent;
        Intrinsics.checkNotNullExpressionValue(frameLayout6, "binding.rvParent");
        ViewExtKt.showOrGone(frameLayout6, true);
        LinearLayout linearLayout11 = getBinding().giftMessageLayout;
        Intrinsics.checkNotNullExpressionValue(linearLayout11, "binding.giftMessageLayout");
        ViewExtKt.showOrGone(linearLayout11, true);
        AppCompatTextView appCompatTextView2 = getBinding().timerLeft;
        Intrinsics.checkNotNullExpressionValue(appCompatTextView2, "binding.timerLeft");
        ViewExtKt.showOrGone((View) appCompatTextView2, true);
        LinearLayout linearLayout12 = getBinding().encryptionLayout;
        Intrinsics.checkNotNullExpressionValue(linearLayout12, "binding.encryptionLayout");
        ViewExtKt.showOrGone(linearLayout12, true);
        if (this.isStreamer) {
            LinearLayout linearLayout13 = getBinding().userInfoParent;
            Intrinsics.checkNotNullExpressionValue(linearLayout13, "binding.userInfoParent");
            linearLayout13.setVisibility(0);
            if (isAudioCall()) {
                AppCompatImageView appCompatImageView2 = getBinding().btnGiftUser;
                Intrinsics.checkNotNullExpressionValue(appCompatImageView2, "binding.btnGiftUser");
                ViewExtKt.showOrGone((View) appCompatImageView2, getViewModel().getCanShowGift());
            } else {
                AppCompatImageView appCompatImageView3 = getBinding().btnGiftHost;
                Intrinsics.checkNotNullExpressionValue(appCompatImageView3, "binding.btnGiftHost");
                ViewExtKt.showOrInvisible((View) appCompatImageView3, getViewModel().getCanShowGift());
            }
            View view7 = getBinding().hideUserBtn;
            Intrinsics.checkNotNullExpressionValue(view7, "binding.hideUserBtn");
            view7.setVisibility(isAudioCall() ^ true ? 0 : 8);
            if (getViewModel().getCallpeAdmin() && this.isBroadCastScreen) {
                View view8 = getBinding().stopScreenShareBtn;
                Intrinsics.checkNotNullExpressionValue(view8, "binding.stopScreenShareBtn");
                i = 0;
                view8.setVisibility(0);
            } else {
                i = 0;
            }
            View view9 = getBinding().callType;
            Intrinsics.checkNotNullExpressionValue(view9, "binding.callType");
            view9.setVisibility(getViewModel().getCanShowDirectCallTag() ? i : 8);
            View view10 = getBinding().levelParent;
            Intrinsics.checkNotNullExpressionValue(view10, "binding.levelParent");
            view10.setVisibility(((!getViewModel().getCanShowDirectCallTag() || !getViewModel().getCanShowLevelTag()) ? i : 1) != 0 ? i : 8);
        } else {
            i = 0;
        }
        TextView textView2 = getBinding().admin;
        Intrinsics.checkNotNullExpressionValue(textView2, "binding.admin");
        TextView textView3 = textView2;
        if (((getViewModel().getCallpeAdmin() && getViewModel().getCanShowAdminTag() && this.isStreamer) ? 1 : i) == 0) {
            i = 8;
        }
        textView3.setVisibility(i);
        if (getViewModel().getCallpeAdmin() && getViewModel().getCanShowAdminTag() && this.isStreamer) {
            isAudioCall();
        }
    }

    private final void closeScreen(int randomCallDuration) {
        Timber.d("randomCallDuration " + randomCallDuration, new Object[0]);
        if (randomCallDuration == 0) {
            return;
        }
        BuildersKt.launch$default(CoroutineScopeKt.CoroutineScope(Dispatchers.getMain()), (CoroutineContext) null, (CoroutineStart) null, new ZegoVideoCallActivity$closeScreen$1(randomCallDuration, this, null), 3, (Object) null);
        BuildersKt.launch$default(CoroutineScopeKt.CoroutineScope(Dispatchers.getMain()), (CoroutineContext) null, (CoroutineStart) null, new ZegoVideoCallActivity$closeScreen$2(randomCallDuration, this, null), 3, (Object) null);
    }

    public final void showGiftRequestDialog(final GiftRequestModel model) {
        Intrinsics.checkNotNullParameter(model, "model");
        try {
            Dialog dialog = this.alertDialog;
            Dialog dialog2 = null;
            if (dialog != null) {
                if (dialog == null) {
                    Intrinsics.throwUninitializedPropertyAccessException("alertDialog");
                    dialog = null;
                }
                if (dialog.isShowing()) {
                    return;
                }
            }
            Integer num = SharedPref.getInt((Context) this, PrefKeys.RUPEE_TO_BEAN, 1);
            this.alertDialog = new Dialog((Context) this);
            GiftPopupBinding inflate = GiftPopupBinding.inflate(LayoutInflater.from((Context) this));
            Intrinsics.checkNotNullExpressionValue(inflate, "inflate(\n               …          )\n            )");
            Dialog dialog3 = this.alertDialog;
            if (dialog3 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("alertDialog");
                dialog3 = null;
            }
            dialog3.setContentView(inflate.getRoot());
            Dialog dialog4 = this.alertDialog;
            if (dialog4 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("alertDialog");
                dialog4 = null;
            }
            dialog4.setCancelable(false);
            ImageView imageView = inflate.popupClose;
            Intrinsics.checkNotNullExpressionValue(imageView, "binding.popupClose");
            imageView.setVisibility(8);
            inflate.popupClose.setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    ZegoVideoCallActivity.showGiftRequestDialog$lambda$45(ZegoVideoCallActivity.this, view);
                }
            });
            Glide.with((FragmentActivity) this).load(model.getGift().getUrl()).into(inflate.giftImage);
            CircularTimerView circularTimerView = inflate.progressCircular;
            Intrinsics.checkNotNullExpressionValue(circularTimerView, "binding.progressCircular");
            circularTimerView.setProgress(0.0f);
            circularTimerView.setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    ZegoVideoCallActivity.showGiftRequestDialog$lambda$46(ZegoVideoCallActivity.this, view);
                }
            });
            circularTimerView.setCircularTimerListener(new CircularTimerListener() {
                public String updateDataOnTick(long remainingTimeInMs) {
                    return "X";
                }

                public void onTimerFinished() {
                    Dialog dialog5;
                    dialog5 = ZegoVideoCallActivity.this.alertDialog;
                    if (dialog5 == null) {
                        Intrinsics.throwUninitializedPropertyAccessException("alertDialog");
                        dialog5 = null;
                    }
                    dialog5.dismiss();
                }
            }, 15L, TimeFormatEnum.SECONDS, 10L);
            circularTimerView.startTimer();
            inflate.coinPrice.setText(NumberExtKt.formatByNumberRupee$default(model.getGift().getAmount(), false, 1, (Object) null));
            if (this.isStreamer) {
                inflate.coinPrice.setText(String.valueOf(num.intValue() * model.getGift().getStreamerAmount()));
                ImageView imageView2 = inflate.beanIcon;
                Intrinsics.checkNotNullExpressionValue(imageView2, "binding.beanIcon");
                imageView2.setVisibility(0);
            }
            inflate.sendGift.setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    ZegoVideoCallActivity.showGiftRequestDialog$lambda$47(ZegoVideoCallActivity.this, model, view);
                }
            });
            Dialog dialog5 = this.alertDialog;
            if (dialog5 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("alertDialog");
                dialog5 = null;
            }
            Window window = (Window) Objects.requireNonNull(dialog5.getWindow());
            if (window != null) {
                window.clearFlags(131080);
            }
            Dialog dialog6 = this.alertDialog;
            if (dialog6 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("alertDialog");
                dialog6 = null;
            }
            dialog6.show();
            Dialog dialog7 = this.alertDialog;
            if (dialog7 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("alertDialog");
            } else {
                dialog2 = dialog7;
            }
            Window window2 = dialog2.getWindow();
            Intrinsics.checkNotNull(window2);
            window2.setBackgroundDrawable(new ColorDrawable(0));
        } catch (Exception e) {
            Timber.e(e, "", new Object[0]);
        }
    }

    public static final void showGiftRequestDialog$lambda$45(ZegoVideoCallActivity zegoVideoCallActivity, View view) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        Dialog dialog = zegoVideoCallActivity.alertDialog;
        if (dialog == null) {
            Intrinsics.throwUninitializedPropertyAccessException("alertDialog");
            dialog = null;
        }
        dialog.dismiss();
    }

    public static final void showGiftRequestDialog$lambda$46(ZegoVideoCallActivity zegoVideoCallActivity, View view) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        Dialog dialog = zegoVideoCallActivity.alertDialog;
        if (dialog == null) {
            Intrinsics.throwUninitializedPropertyAccessException("alertDialog");
            dialog = null;
        }
        dialog.dismiss();
    }

    public static final void showGiftRequestDialog$lambda$47(ZegoVideoCallActivity zegoVideoCallActivity, GiftRequestModel giftRequestModel, View view) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        Intrinsics.checkNotNullParameter(giftRequestModel, "$model");
        CallViewModel.sendGift$default(zegoVideoCallActivity.getViewModel(), giftRequestModel.getGift().getId(), null, 2, null);
        Dialog dialog = zegoVideoCallActivity.alertDialog;
        if (dialog == null) {
            Intrinsics.throwUninitializedPropertyAccessException("alertDialog");
            dialog = null;
        }
        dialog.dismiss();
    }

    public final void showGiftReceivedDialog(app.callpe.data.model.GiftRequestModel r10) {
        throw new UnsupportedOperationException("Method not decompiled: app.callpe.ui.call.ZegoVideoCallActivity.showGiftReceivedDialog(app.callpe.data.model.GiftRequestModel):void");
    }

    public static final void showGiftReceivedDialog$lambda$48(ZegoVideoCallActivity zegoVideoCallActivity, View view) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        Dialog dialog = zegoVideoCallActivity.alertDialog;
        if (dialog == null) {
            Intrinsics.throwUninitializedPropertyAccessException("alertDialog");
            dialog = null;
        }
        dialog.dismiss();
    }

    public static final void showGiftReceivedDialog$lambda$49(ZegoVideoCallActivity zegoVideoCallActivity, View view) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        Dialog dialog = zegoVideoCallActivity.alertDialog;
        if (dialog == null) {
            Intrinsics.throwUninitializedPropertyAccessException("alertDialog");
            dialog = null;
        }
        dialog.dismiss();
    }

    public final void showLowBalancePopup() {
        try {
            Dialog dialog = new Dialog((Context) this);
            this.dialog = dialog;
            dialog.setContentView(2131558836);
            Dialog dialog2 = this.dialog;
            ImageView imageView = dialog2 != null ? (ImageView) dialog2.findViewById(2131362585) : null;
            if (imageView != null) {
                imageView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public final void onClick(View view) {
                        ZegoVideoCallActivity.showLowBalancePopup$lambda$50(ZegoVideoCallActivity.this, view);
                    }
                });
            }
            Dialog dialog3 = this.dialog;
            Button button = dialog3 != null ? (Button) dialog3.findViewById(2131364291) : null;
            if (this.netWinning > 0.0d) {
                Dialog dialog4 = this.dialog;
                LinearLayout linearLayout = dialog4 != null ? (LinearLayout) dialog4.findViewById(2131365472) : null;
                Dialog dialog5 = this.dialog;
                TextView textView = dialog5 != null ? (TextView) dialog5.findViewById(2131363977) : null;
                if (textView != null) {
                    textView.setVisibility(0);
                }
                Dialog dialog6 = this.dialog;
                TextView textView2 = dialog6 != null ? (TextView) dialog6.findViewById(2131365106) : null;
                String str = "(Available " + NumberExtKt.formatByNumberRupee$default(this.netWinning, false, 1, (Object) null) + ')';
                if (textView2 != null) {
                    textView2.setText(str);
                }
                if (linearLayout != null) {
                    linearLayout.setVisibility(0);
                }
                if (linearLayout != null) {
                    linearLayout.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public final void onClick(View view) {
                            ZegoVideoCallActivity.showLowBalancePopup$lambda$51(ZegoVideoCallActivity.this, view);
                        }
                    });
                }
            }
            if (button != null) {
                button.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public final void onClick(View view) {
                        ZegoVideoCallActivity.showLowBalancePopup$lambda$53(ZegoVideoCallActivity.this, view);
                    }
                });
            }
            Dialog dialog7 = this.dialog;
            if (dialog7 != null) {
                dialog7.show();
            }
            Dialog dialog8 = this.dialog;
            if (dialog8 != null) {
                dialog8.setCancelable(false);
            }
            Dialog dialog9 = this.dialog;
            if (dialog9 != null) {
                dialog9.setOnDismissListener(new DialogInterface.OnDismissListener() {
                    @Override
                    public final void onDismiss(DialogInterface dialogInterface) {
                        dialogInterface.dismiss();
                    }
                });
            }
        } catch (Exception e) {
            Timber.e(e);
        }
    }

    public static final void showLowBalancePopup$lambda$50(ZegoVideoCallActivity zegoVideoCallActivity, View view) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        Dialog dialog = zegoVideoCallActivity.dialog;
        if (dialog != null) {
            dialog.dismiss();
        }
    }

    public static final void showLowBalancePopup$lambda$51(ZegoVideoCallActivity zegoVideoCallActivity, View view) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        zegoVideoCallActivity.getViewModel().purchaseTalkTime(zegoVideoCallActivity.netWinning);
        Dialog dialog = zegoVideoCallActivity.dialog;
        if (dialog != null) {
            dialog.dismiss();
        }
    }

    public static final void showLowBalancePopup$lambda$53(ZegoVideoCallActivity zegoVideoCallActivity, View view) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        Dialog dialog = zegoVideoCallActivity.dialog;
        if (dialog != null) {
            dialog.dismiss();
        }
        Intent intent = new Intent(zegoVideoCallActivity.getApplicationContext(), (Class<?>) WalletActivity.class);
        intent.addFlags(268435456);
        intent.putExtra("video_call_screen", true);
        zegoVideoCallActivity.startActivity(intent);
    }

    private final void starServiceFunc() {
        Intent intent;
        try {
            VideoCallService videoCallService = new VideoCallService();
            this.videoCallService = videoCallService;
            Intent intent2 = new Intent((Context) this, videoCallService.getClass());
            this.mServiceIntent = intent2;
            intent2.putExtra(Constants.KEY_CALLING_CHANNEL, this.mChannel);
            Intent intent3 = this.mServiceIntent;
            if (intent3 != null) {
                intent3.putExtra(Constants.KEY_CALLING_VIDEO_ID, this.videoId);
            }
            Intent intent4 = this.mServiceIntent;
            if (intent4 != null) {
                intent4.putExtra(Constants.KEY_AGORA_ACCESS_TOKEN, this.accessToken);
            }
            Intent intent5 = this.mServiceIntent;
            if (intent5 != null) {
                intent5.putExtra(Constants.KEY_CALLER, this.caller);
            }
            String stringExtra = getIntent().getStringExtra(Constants.KEY_CALL_TYPE);
            if (stringExtra == null) {
                stringExtra = Constants.VIDEO_CALL;
            } else {
                Intrinsics.checkNotNullExpressionValue(stringExtra, "intent.getStringExtra(Co…_CALL_TYPE) ?: VIDEO_CALL");
            }
            this.callType = stringExtra;
            Intent intent6 = this.mServiceIntent;
            if (intent6 != null) {
                intent6.putExtra(Constants.KEY_CALL_TYPE, stringExtra);
            }
            VideoDetailModel videoDetails = getViewModel().getVideoDetails();
            if (videoDetails != null && (intent = this.mServiceIntent) != null) {
                intent.putExtra(Constants.FCM_DATA, new Gson().toJson(videoDetails));
            }
            if (!Utils.isMyServiceRunning(videoCallService.getClass(), (Activity) this)) {
                startService(this.mServiceIntent);
                Timber.d("Service started successfully", new Object[0]);
            } else {
                Timber.d("Service is already running", new Object[0]);
            }
        } catch (Exception e) {
            getViewModel().submitVideoCallError("Video call service error " + e.getMessage());
            Timber.e(e);
        }
    }

    public final void stopServiceFunc() {
        VideoCallService videoCallService = this.videoCallService;
        if (videoCallService != null) {
            this.mServiceIntent = new Intent((Context) this, videoCallService.getClass());
            if (Utils.isMyServiceRunning(videoCallService.getClass(), (Activity) this)) {
                stopService(this.mServiceIntent);
                Timber.d("Service stopped!!", new Object[0]);
            } else {
                Timber.d("Service is already stopped!!", new Object[0]);
            }
        }
    }

    public final boolean isAudioCall() {
        return Intrinsics.areEqual(this.callType, "AUDIO");
    }

    public final void showCallInfo(app.callpe.data.model.VideoDetailModel r4) {
        throw new UnsupportedOperationException("Method not decompiled: app.callpe.ui.call.ZegoVideoCallActivity.showCallInfo(app.callpe.data.model.VideoDetailModel):void");
    }

    private final boolean permissionsGranted(List<String> permissions) {
        boolean z = true;
        for (String str : permissions) {
            StringBuilder sb = new StringBuilder();
            sb.append("permission name ");
            sb.append(str);
            sb.append(" isgranted ");
            Context context = (Context) this;
            sb.append(ContextCompat.checkSelfPermission(context, str) != 0);
            Timber.e(sb.toString(), new Object[0]);
            if (ContextCompat.checkSelfPermission(context, str) != 0) {
                z = false;
            }
        }
        return z;
    }

    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        Intrinsics.checkNotNullParameter(permissions, NativeProtocol.RESULT_ARGS_PERMISSIONS);
        Intrinsics.checkNotNullParameter(grantResults, "grantResults");
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        if (requestCode == 1010) {
            boolean permissionsGranted = permissionsGranted(this.permissions);
            Timber.e("permission granted --- " + permissionsGranted, new Object[0]);
            if (permissionsGranted) {
                initVideo();
                return;
            }
            if (grantResults.length == 0) {
                return;
            }
            ArrayList arrayList = new ArrayList();
            int length = permissions.length;
            for (int i = 0; i < length; i++) {
                if (grantResults[i] != 0) {
                    arrayList.add(permissions[i]);
                }
            }
            showOpenSettingDialog((String[]) arrayList.toArray(new String[0]));
        }
    }

    private final void requestPermissionsIfNeeded(List<String> permissions) {
        ActivityCompat.requestPermissions((Activity) this, (String[]) permissions.toArray(new String[0]), 1010);
    }

    private final boolean shouldShowRationaleForPermissions(List<String> permissions) {
        Iterator<String> it = permissions.iterator();
        while (it.hasNext()) {
            if (ActivityCompat.shouldShowRequestPermissionRationale((Activity) this, it.next())) {
                return true;
            }
        }
        return false;
    }

    public static final void openSettingsLauncher$lambda$58(ZegoVideoCallActivity zegoVideoCallActivity, ActivityResult activityResult) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        Intrinsics.checkNotNullParameter(activityResult, "<anonymous parameter 0>");
        if (zegoVideoCallActivity.permissionsGranted(CollectionsKt.toList(zegoVideoCallActivity.permissions))) {
            zegoVideoCallActivity.initVideo();
        } else {
            zegoVideoCallActivity.requestPermissionsIfNeeded(zegoVideoCallActivity.permissions);
        }
    }

    private final void showOpenSettingDialog(String[] permissions) {
        Window window;
        try {
            Dialog dialog = this.dialog;
            if (dialog != null) {
                if (dialog != null && dialog.isShowing()) {
                    return;
                }
            }
            getViewModel().submitVideoCallErrorByVideoId(this.videoId, "Permission are not granted.");
            this.dialog = new Dialog((Context) this);
            PermissionxDefaultDialogLayoutBinding inflate = PermissionxDefaultDialogLayoutBinding.inflate(LayoutInflater.from((Context) this));
            Intrinsics.checkNotNullExpressionValue(inflate, "inflate(\n               …      )\n                )");
            Dialog dialog2 = this.dialog;
            if (dialog2 != null) {
                dialog2.setContentView(inflate.getRoot());
            }
            Dialog dialog3 = this.dialog;
            if (dialog3 != null) {
                dialog3.setCancelable(false);
            }
            String string = getString(2131952424);
            Intrinsics.checkNotNullExpressionValue(string, "getString(R.string.permission_explain_camera_mic)");
            if (permissions.length == 1) {
                if (ArraysKt.contains(permissions, "android.permission.CAMERA")) {
                    string = getString(2131952423);
                    Intrinsics.checkNotNullExpressionValue(string, "this.getString(R.string.permission_explain_camera)");
                } else if (ArraysKt.contains(permissions, "android.permission.RECORD_AUDIO")) {
                    string = getString(2131952425);
                    Intrinsics.checkNotNullExpressionValue(string, "this.getString(R.string.permission_explain_mic)");
                }
            }
            inflate.positiveBtn.setText(getString(2131952579));
            Button button = inflate.negativeBtn;
            Intrinsics.checkNotNullExpressionValue(button, "binding.negativeBtn");
            button.setVisibility(8);
            inflate.messageText.setText(string);
            for (String str : permissions) {
                PermissionxPermissionItemBinding inflate2 = PermissionxPermissionItemBinding.inflate(getLayoutInflater(), inflate.permissionsLayout, false);
                Intrinsics.checkNotNullExpressionValue(inflate2, "inflate(\n               …, false\n                )");
                if (Intrinsics.areEqual(str, "android.permission.CAMERA")) {
                    inflate2.permissionText.setText(getString(2131952989));
                    inflate2.permissionIcon.setImageResource(2131231551);
                } else if (Intrinsics.areEqual(str, "android.permission.RECORD_AUDIO")) {
                    inflate2.permissionText.setText("Microphone");
                    inflate2.permissionIcon.setImageResource(R.drawable.ic_mic);
                }
                inflate2.permissionIcon.setColorFilter(ContextCompat.getColor((Context) this, 2131100837), PorterDuff.Mode.SRC_ATOP);
                inflate.permissionsLayout.addView(inflate2.getRoot());
            }
            inflate.positiveBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    ZegoVideoCallActivity.showOpenSettingDialog$lambda$59(ZegoVideoCallActivity.this, view);
                }
            });
            Dialog dialog4 = this.dialog;
            if (dialog4 != null) {
                dialog4.show();
            }
            Dialog dialog5 = this.dialog;
            if (dialog5 == null || (window = dialog5.getWindow()) == null) {
                return;
            }
            window.setBackgroundDrawable(new ColorDrawable(0));
        } catch (Exception e) {
            Timber.e(e);
        }
    }

    public static final void showOpenSettingDialog$lambda$59(ZegoVideoCallActivity zegoVideoCallActivity, View view) {
        Intrinsics.checkNotNullParameter(zegoVideoCallActivity, "this$0");
        Intent intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS");
        intent.setData(Uri.fromParts("package", zegoVideoCallActivity.getPackageName(), null));
        zegoVideoCallActivity.openSettingsLauncher.launch(intent);
        Dialog dialog = zegoVideoCallActivity.dialog;
        if (dialog != null) {
            dialog.dismiss();
        }
    }

    private final void startPublishScreen() {
        Object valueOf;
        if (this.rtcManager == null || this.isBroadCastScreen) {
            return;
        }
        getBinding().castBtn.setActivated(true);
        if (this.isStreamer) {
            VideoDetailModel videoDetails = getViewModel().getVideoDetails();
            if (videoDetails != null) {
                valueOf = Long.valueOf(videoDetails.getStreamerId());
            }
            valueOf = null;
        } else {
            VideoDetailModel videoDetails2 = getViewModel().getVideoDetails();
            if (videoDetails2 != null) {
                valueOf = Integer.valueOf(videoDetails2.getUserId());
            }
            valueOf = null;
        }
        RtcManager rtcManager = this.rtcManager;
        if (rtcManager != null) {
            rtcManager.startPublishScreenSharing(String.valueOf(valueOf));
        }
        getBinding().btnPauseVideo.setEnabled(false);
        ActivityZegoVideoCallBinding activityZegoVideoCallBinding = this._binding;
        LinearLayout linearLayout = activityZegoVideoCallBinding != null ? activityZegoVideoCallBinding.screenShareParent : null;
        if (linearLayout != null) {
            linearLayout.setVisibility(0);
        }
        this.isBroadCastScreen = true;
    }

    public final void onStreamUpdate(String roomID, RtcUpdateType updateType, ArrayList<RtcStream> streamList, JSONObject extendedData) {
        if (streamList.isEmpty()) {
            return;
        }
        Timber.e("streamList size " + streamList.size(), new Object[0]);
        if (streamList.size() > 1) {
            Iterator<RtcStream> it = streamList.iterator();
            while (it.hasNext()) {
                RtcStream next = it.next();
                if (StringsKt.endsWith$default(next.getStreamID(), "share", false, 2, (Object) null)) {
                    if (updateType == RtcUpdateType.ADD) {
                        if (!this.isStreamer) {
                            this.isBroadCastScreen = true;
                        }
                        getBinding().btnPauseVideo.setEnabled(false);
                        startPlayScreenStream(next.getStreamID());
                    } else if (updateType == RtcUpdateType.DELETE) {
                        if (!this.isStreamer) {
                            this.isBroadCastScreen = true;
                        }
                        getBinding().btnPauseVideo.setEnabled(true);
                        stopPlayScreenStream(next.getStreamID());
                        stopPublishScreen();
                        if (this.isStreamer) {
                            RemoteRtcVideoView remoteRtcVideoView = this.mRemotePreviewLayout;
                            if (remoteRtcVideoView != null) {
                                VideoDetailModel videoDetails = getViewModel().getVideoDetails();
                                remoteRtcVideoView.setUserID(String.valueOf(videoDetails != null ? Integer.valueOf(videoDetails.getUserId()) : null), true, this.currentSDK);
                            }
                        } else {
                            RemoteRtcVideoView remoteRtcVideoView2 = this.mRemotePreviewLayout;
                            if (remoteRtcVideoView2 != null) {
                                VideoDetailModel videoDetails2 = getViewModel().getVideoDetails();
                                remoteRtcVideoView2.setUserID(String.valueOf(videoDetails2 != null ? Long.valueOf(videoDetails2.getStreamerId()) : null), false, this.currentSDK);
                            }
                        }
                    }
                } else {
                    RemoteRtcVideoView remoteRtcVideoView3 = this.mRemotePreviewLayout;
                    if (remoteRtcVideoView3 != null) {
                        remoteRtcVideoView3.onRoomStreamUpdate(roomID, updateType, streamList, extendedData);
                    }
                }
            }
            return;
        }
        RtcStream rtcStream = streamList.get(0);
        Intrinsics.checkNotNullExpressionValue(rtcStream, "streamList[0]");
        RtcStream rtcStream2 = rtcStream;
        if (StringsKt.endsWith$default(rtcStream2.getStreamID(), "share", false, 2, (Object) null)) {
            if (updateType == RtcUpdateType.ADD) {
                if (!this.isStreamer) {
                    this.isBroadCastScreen = true;
                }
                getBinding().btnPauseVideo.setEnabled(false);
                startPlayScreenStream(rtcStream2.getStreamID());
                return;
            }
            if (updateType == RtcUpdateType.DELETE) {
                if (!this.isStreamer) {
                    this.isBroadCastScreen = true;
                }
                getBinding().btnPauseVideo.setEnabled(true);
                stopPlayScreenStream(rtcStream2.getStreamID());
                stopPublishScreen();
                if (this.isStreamer) {
                    RemoteRtcVideoView remoteRtcVideoView4 = this.mRemotePreviewLayout;
                    if (remoteRtcVideoView4 != null) {
                        VideoDetailModel videoDetails3 = getViewModel().getVideoDetails();
                        remoteRtcVideoView4.setUserID(String.valueOf(videoDetails3 != null ? Integer.valueOf(videoDetails3.getUserId()) : null), true, this.currentSDK);
                        return;
                    }
                    return;
                }
                RemoteRtcVideoView remoteRtcVideoView5 = this.mRemotePreviewLayout;
                if (remoteRtcVideoView5 != null) {
                    VideoDetailModel videoDetails4 = getViewModel().getVideoDetails();
                    remoteRtcVideoView5.setUserID(String.valueOf(videoDetails4 != null ? Long.valueOf(videoDetails4.getStreamerId()) : null), false, this.currentSDK);
                    return;
                }
                return;
            }
            return;
        }
        RemoteRtcVideoView remoteRtcVideoView6 = this.mRemotePreviewLayout;
        if (remoteRtcVideoView6 != null) {
            remoteRtcVideoView6.onRoomStreamUpdate(roomID, updateType, streamList, extendedData);
        }
    }

    private final void startPlayScreenStream(String streamID) {
        RtcManager rtcManager = this.rtcManager;
        if (rtcManager == null) {
            return;
        }
        if (rtcManager != null) {
            TextureView textureView = getBinding().screenShareView;
            Intrinsics.checkNotNullExpressionValue(textureView, "binding.screenShareView");
            rtcManager.startPlaySharedScreenStream(streamID, textureView);
        }
        getBinding().screenShareView.setVisibility(0);
        this.isPlayScreenView = true;
    }

    public final void stopPublishScreen() {
        if (this.rtcManager != null && this.isBroadCastScreen) {
            getBinding().castBtn.setActivated(false);
            View view = getBinding().castBtn;
            Intrinsics.checkNotNullExpressionValue(view, "binding.castBtn");
            view.setVisibility(this.isStreamer && getViewModel().getCallpeAdmin() ? 0 : 8);
            RtcManager rtcManager = this.rtcManager;
            if (rtcManager != null) {
                rtcManager.stopPublishScreenSharing();
            }
            TextureView textureView = getBinding().screenShareView;
            Intrinsics.checkNotNullExpressionValue(textureView, "binding.screenShareView");
            textureView.setVisibility(8);
            getBinding().btnPauseVideo.setEnabled(true);
            ActivityZegoVideoCallBinding activityZegoVideoCallBinding = this._binding;
            LinearLayout linearLayout = activityZegoVideoCallBinding != null ? activityZegoVideoCallBinding.screenShareParent : null;
            if (linearLayout != null) {
                linearLayout.setVisibility(8);
            }
            this.isBroadCastScreen = false;
        }
    }

    private final void stopPlayScreenStream(String streamID) {
        RtcManager rtcManager = this.rtcManager;
        if (rtcManager == null) {
            return;
        }
        if (streamID != null && rtcManager != null) {
            rtcManager.stopSharedScreenStream(streamID);
        }
        getBinding().screenShareView.setVisibility(8);
        this.isPlayScreenView = false;
    }

    public final void showReasonDialog(Context context, String title, String message, final DialogHelper.ConfirmationListener listener) {
        Intrinsics.checkNotNullParameter(title, "title");
        Intrinsics.checkNotNullParameter(message, "message");
        if (context != null) {
            try {
                Dialog dialog = this.alertDialog;
                Dialog dialog2 = null;
                if (dialog != null) {
                    if (dialog == null) {
                        Intrinsics.throwUninitializedPropertyAccessException("alertDialog");
                        dialog = null;
                    }
                    if (dialog.isShowing()) {
                        return;
                    }
                }
                AlertDialog.Builder builder = new AlertDialog.Builder(context);
                builder.setTitle(title).setMessage(message).setCancelable(false).setPositiveButton(context.getString(2131952378), new DialogInterface.OnClickListener() {
                    @Override
                    public final void onClick(DialogInterface dialogInterface, int i) {
                        ZegoVideoCallActivity.showReasonDialog$lambda$60(DialogHelper.ConfirmationListener.this, dialogInterface, i);
                    }
                });
                AlertDialog create = builder.create();
                Intrinsics.checkNotNullExpressionValue(create, "builder.create()");
                Dialog dialog3 = (Dialog) create;
                this.alertDialog = dialog3;
                if (dialog3 == null) {
                    Intrinsics.throwUninitializedPropertyAccessException("alertDialog");
                } else {
                    dialog2 = dialog3;
                }
                dialog2.show();
            } catch (Exception e) {
                Timber.e(e, "Error: ", new Object[0]);
            }
        }
    }

    public static final void showReasonDialog$lambda$60(DialogHelper.ConfirmationListener confirmationListener, DialogInterface dialogInterface, int i) {
        Intrinsics.checkNotNullParameter(dialogInterface, "dialogInterface");
        dialogInterface.dismiss();
        if (confirmationListener != null) {
            confirmationListener.onPositiveClick();
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        RtcManager rtcManager = this.rtcManager;
        if (rtcManager != null) {
            rtcManager.onResume();
        }
    }

    @Override
    public void onGameRequestAccepted(VideoCallGameRequestModel requestModel) {
        Intrinsics.checkNotNullParameter(requestModel, "requestModel");
        getViewModel().joinSudGame(requestModel.getStreamerUserGameId(), this.videoId, GameUtils.GameNames.LUDO);
    }

    @Override
    public void onGameRequestRejected(VideoCallGameRequestModel requestModel) {
        Intrinsics.checkNotNullParameter(requestModel, "requestModel");
        getViewModel().rejectSudGame(requestModel.getStreamerUserGameId(), GameUtils.GameNames.LUDO);
    }
}