导航菜单

页面标题

页面副标题

Rilo v2.0.21 - CallActivity.java 源代码

正在查看: Rilo v2.0.21 应用的 CallActivity.java JAVA 源代码文件

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


package app.callpe.ui.call;

import android.R;
import android.app.Activity;
import android.app.Application;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.media.MediaPlayer;
import android.os.Build;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.View;
import android.view.Window;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.activity.ComponentActivity;
import androidx.activity.result.ActivityResultLauncher;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentActivity;
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 app.callpe.App;
import app.callpe.common.utils.Constants;
import app.callpe.common.utils.ZEGOSDKConstants;
import app.callpe.common.utils.extensions.ActivityExtKt;
import app.callpe.common.utils.extensions.NumberExtKt;
import app.callpe.common.utils.extensions.StringExtKt;
import app.callpe.common.utils.sharedpref.PrefKeys;
import app.callpe.common.utils.sharedpref.SharedPref;
import app.callpe.data.model.PriorityCallConfig;
import app.callpe.data.model.StreamerModel;
import app.callpe.data.model.VideoDetailModel;
import app.callpe.databinding.ActivityCallBinding;
import app.callpe.databinding.PriceSurgeAlertDialogBinding;
import app.callpe.rtc.RtcManagerFactory;
import app.callpe.service.HeadsUpNotificationService;
import app.callpe.service.LiveStreamingService;
import app.callpe.ui.SplashActivity;
import app.callpe.ui.call.CallViewModel;
import app.callpe.ui.dialog.RechargeDialog;
import app.callpe.ui.livestreaming.LiveStreamingActivity;
import app.callpe.ui.login.LoginActivity;
import app.callpe.ui.misc.FakeVideoCallActivity;
import app.module.common.interfaces.SDKInitialise;
import app.module.common.interfaces.SignOutListener;
import app.module.common.rtcmanager.RtcManager;
import com.bumptech.glide.Glide;
import com.facebook.internal.FacebookRequestErrorClassification;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.gson.Gson;
import com.techiness.progressdialoglibrary.ProgressDialog;
import dagger.hilt.android.AndroidEntryPoint;
import java.util.concurrent.CancellationException;
import javax.inject.Inject;
import kotlin.Lazy;
import kotlin.LazyKt;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.coroutines.CoroutineContext;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Ref;
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.SupervisorKt;
import timber.log.Timber;

@Metadata(d1 = {"\u0000´\u0001\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0010\b\n\u0002\b\u0007\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0011\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0010\u0006\n\u0002\b\u0011\b\u0007\u0018\u0000 |2\u00020\u00012\u00020\u0002:\u0002|}B\u0005¢\u0006\u0002\u0010\u0003J\u0012\u0010A\u001a\u00020B2\b\u0010C\u001a\u0004\u0018\u00010DH\u0002J\u0010\u0010E\u001a\u00020B2\u0006\u0010F\u001a\u00020GH\u0002J\b\u0010H\u001a\u00020BH\u0002J\b\u0010I\u001a\u00020BH\u0016J\u0012\u0010J\u001a\u00020B2\b\u0010C\u001a\u0004\u0018\u00010DH\u0002J\b\u0010K\u001a\u00020BH\u0002J)\u0010L\u001a\u00020B2\u0006\u0010M\u001a\u00020\u00102\u0006\u0010F\u001a\u00020G2\u0006\u0010N\u001a\u00020\u0010H\u0082@ø\u0001\u0000¢\u0006\u0002\u0010OJ \u0010P\u001a\u00020B2\u0006\u0010M\u001a\u00020\u00102\u0006\u0010F\u001a\u00020G2\u0006\u0010N\u001a\u00020\u0010H\u0002J)\u0010Q\u001a\u00020B2\u0006\u0010M\u001a\u00020\u00102\u0006\u0010F\u001a\u00020G2\u0006\u0010N\u001a\u00020\u0010H\u0082@ø\u0001\u0000¢\u0006\u0002\u0010OJ)\u0010R\u001a\u00020B2\u0006\u0010M\u001a\u00020\u00102\u0006\u0010F\u001a\u00020G2\u0006\u0010N\u001a\u00020\u0010H\u0082@ø\u0001\u0000¢\u0006\u0002\u0010OJ\b\u0010S\u001a\u00020BH\u0002J\b\u0010T\u001a\u00020BH\u0002J.\u0010U\u001a\u00020B2\u0006\u0010V\u001a\u00020\u00102\b\b\u0002\u0010W\u001a\u00020\u00122\u0012\b\u0002\u0010X\u001a\f\u0012\u0006\u0012\u0004\u0018\u00010B\u0018\u00010YH\u0002J\b\u0010Z\u001a\u00020BH\u0002J\b\u0010[\u001a\u00020\\H\u0002J\b\u0010]\u001a\u00020BH\u0017J\u0010\u0010^\u001a\u00020B2\u0006\u0010_\u001a\u00020`H\u0002J\u0010\u0010a\u001a\u00020B2\u0006\u0010b\u001a\u00020cH\u0016J\u0012\u0010d\u001a\u00020B2\b\u0010e\u001a\u0004\u0018\u00010fH\u0016J\b\u0010g\u001a\u00020BH\u0014J\b\u0010h\u001a\u00020BH\u0014J\u0012\u0010i\u001a\u00020B2\b\u0010C\u001a\u0004\u0018\u00010DH\u0015J\b\u0010j\u001a\u00020BH\u0014J\u0018\u0010k\u001a\u00020B2\u0006\u0010l\u001a\u00020m2\u0006\u0010n\u001a\u00020mH\u0002J\n\u0010o\u001a\u0004\u0018\u00010\u001eH\u0002J\n\u0010p\u001a\u0004\u0018\u00010\u001eH\u0002J\b\u0010q\u001a\u00020BH\u0002J\u0018\u0010r\u001a\u00020B2\u0006\u0010s\u001a\u00020\u00102\u0006\u0010t\u001a\u00020GH\u0002J\b\u0010u\u001a\u00020BH\u0002J\u0012\u0010v\u001a\u00020B2\b\u0010t\u001a\u0004\u0018\u00010GH\u0002J\b\u0010w\u001a\u00020BH\u0002J\b\u0010x\u001a\u00020BH\u0002J\u0012\u0010x\u001a\u0004\u0018\u00010\u001e2\u0006\u0010y\u001a\u000203H\u0002J\b\u0010z\u001a\u00020BH\u0002J\b\u0010{\u001a\u00020BH\u0002R\u0010\u0010\u0004\u001a\u0004\u0018\u00010\u0005X\u0082\u000e¢\u0006\u0002\n\u0000R\u0014\u0010\u0006\u001a\u00020\u00058BX\u0082\u0004¢\u0006\u0006\u001a\u0004\b\u0007\u0010\bR\u000e\u0010\t\u001a\u00020\nX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u000b\u001a\u00020\fX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\r\u001a\u00020\u000eX\u0082\u0004¢\u0006\u0002\n\u0000R\u0010\u0010\u000f\u001a\u0004\u0018\u00010\u0010X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0011\u001a\u00020\u0012X\u0082\u000e¢\u0006\u0002\n\u0000R\u0014\u0010\u0013\u001a\u00020\u00128BX\u0082\u0004¢\u0006\u0006\u001a\u0004\b\u0013\u0010\u0014R\u0014\u0010\u0015\u001a\u00020\u00128BX\u0082\u0004¢\u0006\u0006\u001a\u0004\b\u0015\u0010\u0014R\u000e\u0010\u0016\u001a\u00020\u0012X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0017\u001a\u00020\u0012X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0018\u001a\u00020\nX\u0082\u0004¢\u0006\u0002\n\u0000R\u0010\u0010\u0019\u001a\u0004\u0018\u00010\u001aX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u001b\u001a\u0004\u0018\u00010\u0010X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u001c\u001a\u0004\u0018\u00010\u001aX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u001d\u001a\u0004\u0018\u00010\u001eX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u001f\u001a\u0004\u0018\u00010\u0010X\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\u001b\u0010\"\u001a\u00020#8FX\u0086\u0084\u0002¢\u0006\f\n\u0004\b&\u0010'\u001a\u0004\b$\u0010%R\u001b\u0010(\u001a\u00020#8FX\u0086\u0084\u0002¢\u0006\f\n\u0004\b*\u0010'\u001a\u0004\b)\u0010%R\u0010\u0010+\u001a\u0004\u0018\u00010,X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010-\u001a\u00020\fX\u0082\u0004¢\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\u000e\u00100\u001a\u00020\u0012X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u00101\u001a\u00020\u0012X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u00102\u001a\u000203X\u0082\u000e¢\u0006\u0002\n\u0000R$\u00104\u001a\u00020\u00108\u0006@\u0006X\u0087.¢\u0006\u0014\n\u0000\u0012\u0004\b5\u0010\u0003\u001a\u0004\b6\u00107\"\u0004\b8\u00109R\u000e\u0010:\u001a\u00020;X\u0082\u000e¢\u0006\u0002\n\u0000R\u001b\u0010<\u001a\u00020=8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b@\u0010'\u001a\u0004\b>\u0010?\u0082\u0002\u0004\n\u0002\b\u0019¨\u0006~"}, d2 = {"Lapp/callpe/ui/call/CallActivity;", "Lapp/callpe/ui/call/BaseZegoCallActivity;", "Landroid/view/View$OnClickListener;", "()V", "_binding", "Lapp/callpe/databinding/ActivityCallBinding;", "binding", "getBinding", "()Lapp/callpe/databinding/ActivityCallBinding;", "botJob", "Lkotlinx/coroutines/CompletableJob;", "botScope", "Lkotlinx/coroutines/CoroutineScope;", "broadcastReceiver", "Landroid/content/BroadcastReceiver;", "caller", "", "initialized", "", "isCallee", "()Z", "isCaller", "isFreeTrialCall", "isPromotionalCall", "job", "mAcceptBtn", "Landroidx/appcompat/widget/AppCompatImageView;", "mChannel", "mHangupBtn", "mPlayer", "Landroid/media/MediaPlayer;", "mRole", "priceSurgeAlertAlreadyShown", "priceSurgeTimerFinished", "progressDialog", "Lcom/techiness/progressdialoglibrary/ProgressDialog;", "getProgressDialog", "()Lcom/techiness/progressdialoglibrary/ProgressDialog;", "progressDialog$delegate", "Lkotlin/Lazy;", "progressDialogForCall", "getProgressDialogForCall", "progressDialogForCall$delegate", "rtcManager", "Lapp/module/common/rtcmanager/RtcManager;", "scope", "sdkinitialized", "sendInfo", "shown", "streamerJoined", "userCountInRoom", "", "userId", "getUserId$annotations", "getUserId", "()Ljava/lang/String;", "setUserId", "(Ljava/lang/String;)V", "videoId", "", "viewModel", "Lapp/callpe/ui/call/CallViewModel;", "getViewModel", "()Lapp/callpe/ui/call/CallViewModel;", "viewModel$delegate", "callAccepted", "", "intent", "Landroid/content/Intent;", "checkPriceSurgeAndShowAlert", "videoDetailModel", "Lapp/callpe/data/model/VideoDetailModel;", "closeScreen", "finish", "getVideoDetails", "handleLiveIfLiveStreaming", "handlePriorityCallChanges", "call", "callType", "(Ljava/lang/String;Lapp/callpe/data/model/VideoDetailModel;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "handleScreenChange", "handleScreenChangesForCall", "handleScreenChangesFromLivestream", "handleScreenClose", "handleUserJoin", "initRtcSDK", "sdkName", "escapeRtcInit", "success", "Lkotlin/Function0;", "initUI", "observeEvent", "Lkotlinx/coroutines/Job;", "onBackPressed", "onCallerJoin", "event", "Lapp/callpe/ui/call/CallViewModel$CallEvent$VideoDetailSuccess;", "onClick", "view", "Landroid/view/View;", "onCreate", "savedInstanceState", "Landroid/os/Bundle;", "onDestroy", "onGlobalLayoutCompleted", "onNewIntent", "onResume", "openPriceSurgeDialog", "newRate", "", "oldRate", "playCalleeRing", "playCallerRing", "registerReceiver", "showFailedReason", "failureReason", "data", "showOnLockScreen", "showRechargePopup", "showUserInfo", "startRinging", "resource", "stopRinging", "unRegisterReceiver", "Companion", "VideoCallFailureReason", "app_riloRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
@AndroidEntryPoint
public final class CallActivity extends Hilt_CallActivity implements View.OnClickListener {
    public static final String ACCEPT = "ACCEPT";
    public static final String CARD_ID = "CARD_ID";

    public static final Companion INSTANCE = new Companion(null);
    public static final String IS_BOT = "IS_BOT";
    public static final String IS_BOT_VIDEO = "IS_BOT_VIDEO";
    public static final String IS_FREE_CALL = "IS_FREE_CALL";
    public static final String IS_FREE_TRIAL = "IS_FREE_TRIAL";
    public static final String IS_GOODESS_CALL = "IS_GOODESS_CALL";
    public static final String IS_PRIORITY_CALL = "IS_PRIORITY_CALL";
    public static final String IS_PROMOTIONAL = "IS_PROMOTIONAL";
    public static final String IS_PROMOTIONAL_RANDOM = "IS_PROMOTIONAL_RANDOM";
    public static final String IS_RANDOM = "IS_RANDOM";
    public static final String LIVESTREAM_ID = "LIVESTREAM_ID";
    public static final String NAME = "NAME";
    public static final String PROFILE_PIC = "PROFILE";
    public static final String RANDOM_CALL_DURATION = "RANDOM_CALL_DURATION";
    public static final String RATE = "RATE";
    public static final int REFRESH_SCREEN = 101010;
    public static final String SCREEN_CLOSED = "SCREEN_CLOSED";
    private ActivityCallBinding _binding;
    private final CompletableJob botJob;
    private final CoroutineScope botScope;
    private final BroadcastReceiver broadcastReceiver;
    private String caller;
    private boolean initialized;
    private boolean isFreeTrialCall;
    private boolean isPromotionalCall;
    private final CompletableJob job;
    private AppCompatImageView mAcceptBtn;
    private String mChannel;
    private AppCompatImageView mHangupBtn;
    private MediaPlayer mPlayer;
    private String mRole;
    private boolean priceSurgeAlertAlreadyShown;
    private boolean priceSurgeTimerFinished;

    private final Lazy progressDialog;

    private final Lazy progressDialogForCall;
    private RtcManager rtcManager;
    private final CoroutineScope scope;
    private boolean sdkinitialized;
    private boolean sendInfo;
    private boolean shown;
    private boolean streamerJoined;
    private int userCountInRoom;

    @Inject
    public String userId;
    private long videoId;

    private final Lazy viewModel;

    @Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0010\u0010\n\u0002\b\t\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\u0005j\u0002\b\u0006j\u0002\b\u0007j\u0002\b\bj\u0002\b\t¨\u0006\n"}, d2 = {"Lapp/callpe/ui/call/CallActivity$VideoCallFailureReason;", "", "(Ljava/lang/String;I)V", "INSUFFICIENT_BALANCE", "UNANSWERED", "BUSY", "OFFLINE", "REJECTED", "CANCELLED", "INVALID_CARD", "app_riloRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
    public enum VideoCallFailureReason {
        INSUFFICIENT_BALANCE,
        UNANSWERED,
        BUSY,
        OFFLINE,
        REJECTED,
        CANCELLED,
        INVALID_CARD
    }

    public static void getUserId$annotations() {
    }

    public static final void handleLiveIfLiveStreaming$lambda$11$lambda$10() {
    }

    public void onBackPressed() {
    }

    @Override
    protected void onGlobalLayoutCompleted() {
    }

    public CallActivity() {
        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 m879invoke() {
                return componentActivity.getViewModelStore();
            }
        }, new Function0<ViewModelProvider.Factory>() {
            {
                super(0);
            }

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

            public final CreationExtras m880invoke() {
                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));
        CoroutineContext SupervisorJob$default2 = SupervisorKt.SupervisorJob$default((Job) null, 1, (Object) null);
        this.botJob = SupervisorJob$default2;
        this.botScope = CoroutineScopeKt.CoroutineScope(Dispatchers.getMain().plus(SupervisorJob$default2));
        this.mRole = "";
        this.videoId = -1L;
        this.shown = true;
        this.progressDialog = LazyKt.lazy(new Function0<ProgressDialog>() {
            {
                super(0);
            }

            public final ProgressDialog m882invoke() {
                ProgressDialog progressDialog = new ProgressDialog((Context) CallActivity.this, 0, 2, (DefaultConstructorMarker) null);
                progressDialog.setMode(4);
                progressDialog.setTitle("Switching to Priority Call");
                progressDialog.setMessage("Please wait while we connect your call.");
                return progressDialog;
            }
        });
        this.progressDialogForCall = LazyKt.lazy(new Function0<ProgressDialog>() {
            {
                super(0);
            }

            public final ProgressDialog m883invoke() {
                ProgressDialog progressDialog = new ProgressDialog((Context) CallActivity.this, 0, 2, (DefaultConstructorMarker) null);
                progressDialog.setMode(4);
                progressDialog.setTitle("Connecting...");
                progressDialog.setMessage("Please wait while we connect your call.");
                return progressDialog;
            }
        });
        this.broadcastReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(android.content.Context r3, android.content.Intent r4) {
                throw new UnsupportedOperationException("Method not decompiled: app.callpe.ui.call.CallActivity$broadcastReceiver$1.onReceive(android.content.Context, android.content.Intent):void");
            }
        };
    }

    public final ActivityCallBinding getBinding() {
        ActivityCallBinding activityCallBinding = this._binding;
        Intrinsics.checkNotNull(activityCallBinding);
        return activityCallBinding;
    }

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

    public final ProgressDialog getProgressDialog() {
        return (ProgressDialog) this.progressDialog.getValue();
    }

    public final ProgressDialog getProgressDialogForCall() {
        return (ProgressDialog) this.progressDialogForCall.getValue();
    }

    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);
        showOnLockScreen();
        this._binding = ActivityCallBinding.inflate(getLayoutInflater());
        setContentView(getBinding().root);
        getVideoDetails(getIntent());
        showUserInfo();
        observeEvent();
        initUI();
        startRinging();
        callAccepted(getIntent());
        handleScreenClose();
        registerReceiver();
    }

    private final void showOnLockScreen() {
        try {
            if (Build.VERSION.SDK_INT == 30) {
                if (SharedPref.getBoolean((Context) this, PrefKeys.FIRST_RECHARGE_DONE) || LoginActivity.INSTANCE.isVitok()) {
                    if (SharedPref.getBoolean((Context) this, PrefKeys.TECNO_ISSUE_DETECTED)) {
                        setTurnScreenOn(true);
                        return;
                    }
                    Integer num = SharedPref.getInt((Context) this, PrefKeys.USER_COUNT_IN_ROOM, 0);
                    Intrinsics.checkNotNullExpressionValue(num, "userCountInRoom");
                    this.userCountInRoom = num.intValue();
                    if (num.intValue() == 2) {
                        SharedPref.setBoolean((Context) this, PrefKeys.TECNO_ISSUE_DETECTED, true);
                        return;
                    } else {
                        setShowWhenLocked(true);
                        setTurnScreenOn(true);
                        return;
                    }
                }
                return;
            }
            if (Build.VERSION.SDK_INT >= 27) {
                setShowWhenLocked(true);
                setTurnScreenOn(true);
            } else {
                getWindow().addFlags(69730304);
            }
        } catch (Exception e) {
            Timber.e(e);
        }
    }

    static void initRtcSDK$default(CallActivity callActivity, String str, boolean z, Function0 function0, int i, Object obj) {
        if ((i & 2) != 0) {
            z = false;
        }
        if ((i & 4) != 0) {
            function0 = null;
        }
        callActivity.initRtcSDK(str, z, function0);
    }

    private final void initRtcSDK(final String sdkName, boolean escapeRtcInit, final Function0<Unit> success) {
        Timber.e("Init RTC SDK escapeRtcInit=" + escapeRtcInit + " initialized=" + this.initialized, new Object[0]);
        if (escapeRtcInit || this.initialized) {
            return;
        }
        this.initialized = true;
        if (!LoginActivity.INSTANCE.isVitok()) {
            handleLiveIfLiveStreaming();
        }
        RtcManager createManager$default = RtcManagerFactory.createManager$default(null, sdkName, 1, null);
        this.rtcManager = createManager$default;
        if (createManager$default != null) {
            Application application = getApplication();
            Intrinsics.checkNotNullExpressionValue(application, "application");
            long j = ZEGOSDKConstants.appID;
            String str = ZEGOSDKConstants.appSign;
            Intrinsics.checkNotNullExpressionValue(str, "appSign");
            createManager$default.initSDK(application, j, str, "app.ri1l0", new SDKInitialise() {
                @Override
                public void initialised() {
                    CallActivity.this.sdkinitialized = true;
                    Timber.e("Init RTC SDK sdkinitialized=true", new Object[0]);
                    Function0<Unit> function0 = success;
                    if (function0 != null) {
                    }
                }

                @Override
                public void error(String errorMessage) {
                    super.error(errorMessage);
                    ActivityExtKt.toast((Activity) CallActivity.this, "Failed to create call Sdk " + sdkName + " error " + errorMessage);
                    CallActivity.this.finish();
                }
            });
        }
    }

    private final void initUI() {
        AppCompatImageView appCompatImageView;
        Intent intent = getIntent();
        this.mChannel = intent.getStringExtra(Constants.KEY_CALLING_CHANNEL);
        this.videoId = intent.getLongExtra(Constants.KEY_CALLING_VIDEO_ID, -1L);
        AppCompatImageView appCompatImageView2 = getBinding().hangUpBtn;
        this.mHangupBtn = appCompatImageView2;
        if (appCompatImageView2 != null) {
            appCompatImageView2.setVisibility(0);
        }
        if (!LoginActivity.INSTANCE.isVitok() && !getViewModel().getIsBot() && !getViewModel().getIsBotVideo() && (appCompatImageView = this.mHangupBtn) != null) {
            appCompatImageView.setVisibility(4);
        }
        AppCompatImageView appCompatImageView3 = this.mHangupBtn;
        if (appCompatImageView3 != null) {
            appCompatImageView3.setOnClickListener(this);
        }
        TextView textView = getBinding().callRole;
        Intrinsics.checkNotNullExpressionValue(textView, "binding.callRole");
        this.mAcceptBtn = getBinding().acceptCallBtn;
        this.mRole = intent.getStringExtra(Constants.KEY_CALLING_ROLE);
        this.caller = intent.getStringExtra(Constants.KEY_CALLER);
        this.isFreeTrialCall = intent.getBooleanExtra(IS_FREE_TRIAL, false);
        this.isPromotionalCall = intent.getBooleanExtra(IS_PROMOTIONAL, false);
        TextView textView2 = getBinding().priorityTag;
        Intrinsics.checkNotNullExpressionValue(textView2, "binding.priorityTag");
        textView2.setVisibility(getViewModel().getIsPriorityCall() ? 0 : 8);
        if (isCallee()) {
            textView.setText(2131952489);
            AppCompatImageView appCompatImageView4 = this.mAcceptBtn;
            if (appCompatImageView4 != null) {
                appCompatImageView4.setVisibility(0);
            }
            AppCompatImageView appCompatImageView5 = this.mAcceptBtn;
            if (appCompatImageView5 != null) {
                appCompatImageView5.setOnClickListener(this);
            }
            VideoDetailModel videoDetails = getViewModel().getVideoDetails();
            if (videoDetails != null) {
                CallViewModel.getVideoDetailsWithRetry$default(getViewModel(), videoDetails.getId(), false, 2, null);
            }
        } else if (isCaller()) {
            if (getViewModel().getIsRandom() && !getViewModel().getIsFreeTrial() && !getViewModel().getIsPromotional() && !getViewModel().getIsPriorityCall()) {
                textView.setVisibility(8);
                ActivityCallBinding activityCallBinding = this._binding;
                TextView textView3 = activityCallBinding != null ? activityCallBinding.randomCallText : null;
                if (textView3 != null) {
                    textView3.setVisibility(0);
                }
            }
            textView.setText(2131951768);
            if (getViewModel().getIsRandom()) {
                if (getViewModel().getIsPriorityCall()) {
                    long longExtra = intent.getLongExtra(Constants.KEY_CALLING_STREAMER_ID, -1L);
                    if (longExtra != -1) {
                        long longExtra2 = intent.getLongExtra(LIVESTREAM_ID, -1L);
                        if (longExtra2 != -1) {
                            getViewModel().startPriorityVideoCall(longExtra, Long.valueOf(longExtra2));
                        } else {
                            CallViewModel.startPriorityVideoCall$default(getViewModel(), longExtra, null, 2, null);
                        }
                    } else {
                        finish();
                        return;
                    }
                } else if (getViewModel().getIsFreeTrial()) {
                    long longExtra3 = intent.getLongExtra(Constants.KEY_CALLING_STREAMER_ID, -1L);
                    if (longExtra3 != -1) {
                        long longExtra4 = intent.getLongExtra(LIVESTREAM_ID, -1L);
                        if (longExtra4 != -1) {
                            getViewModel().startFreeTrialVideoCall(longExtra3, Long.valueOf(longExtra4));
                        } else {
                            CallViewModel.startFreeTrialVideoCall$default(getViewModel(), longExtra3, null, 2, null);
                        }
                    } else {
                        finish();
                        return;
                    }
                } else if (getViewModel().getIsPromotional()) {
                    long longExtra5 = intent.getLongExtra(Constants.KEY_CALLING_STREAMER_ID, -1L);
                    if (longExtra5 != -1) {
                        long longExtra6 = intent.getLongExtra(LIVESTREAM_ID, -1L);
                        if (longExtra6 != -1) {
                            getViewModel().startPromotionalVideoCall(longExtra5, Long.valueOf(longExtra6));
                        } else {
                            CallViewModel.startPromotionalVideoCall$default(getViewModel(), longExtra5, null, 2, null);
                        }
                    } else {
                        finish();
                        return;
                    }
                } else if (getViewModel().getIsFreeCall()) {
                    long longExtra7 = intent.getLongExtra(CARD_ID, -1L);
                    if (longExtra7 == -1) {
                        finish();
                        return;
                    }
                    getViewModel().startRandomVideoCall(longExtra7);
                } else if (getViewModel().getIsGoddessCall()) {
                    getViewModel().startGoddessVideoCall();
                } else if (getViewModel().getIsRandomPromotional()) {
                    getViewModel().startRandomPromotionalVideoCall();
                } else {
                    getViewModel().startRandomMatchVideoCall();
                }
            } else if (getViewModel().getIsAudioCall()) {
                long longExtra8 = intent.getLongExtra(Constants.KEY_CALLING_STREAMER_ID, -1L);
                long longExtra9 = intent.getLongExtra(LIVESTREAM_ID, -1L);
                if (longExtra8 != -1) {
                    if (longExtra9 != -1) {
                        getViewModel().startAudioCall(longExtra8, Long.valueOf(longExtra9));
                    } else {
                        CallViewModel.startAudioCall$default(getViewModel(), longExtra8, null, 2, null);
                    }
                }
            } else {
                long longExtra10 = intent.getLongExtra(Constants.KEY_CALLING_STREAMER_ID, -1L);
                long longExtra11 = intent.getLongExtra(LIVESTREAM_ID, -1L);
                if (longExtra10 != -1) {
                    if (longExtra11 != -1) {
                        getViewModel().startVideoCall(longExtra10, Long.valueOf(longExtra11));
                    } else {
                        CallViewModel.startVideoCall$default(getViewModel(), longExtra10, null, 2, null);
                    }
                }
            }
            AppCompatImageView appCompatImageView6 = this.mAcceptBtn;
            if (appCompatImageView6 != null) {
                appCompatImageView6.setVisibility(8);
            }
        }
        if (!getViewModel().getIsRandom() || getViewModel().getIsFreeTrial() || getViewModel().getIsPromotional() || getViewModel().getIsPriorityCall()) {
            return;
        }
        FrameLayout frameLayout = getBinding().frameParent;
        Intrinsics.checkNotNullExpressionValue(frameLayout, "binding.frameParent");
        frameLayout.setVisibility(8);
        RelativeLayout relativeLayout = getBinding().searchingParent;
        Intrinsics.checkNotNullExpressionValue(relativeLayout, "binding.searchingParent");
        relativeLayout.setVisibility(0);
        getBinding().root.setBackgroundColor(ContextCompat.getColor((Context) this, 2131099705));
    }

    private final void showUserInfo() {
        Intent intent = getIntent();
        if (intent != null) {
            String stringExtra = intent.getStringExtra(PROFILE_PIC);
            if (stringExtra != null) {
                FragmentActivity fragmentActivity = (FragmentActivity) this;
                Glide.with(fragmentActivity).load(stringExtra).into(getBinding().peerImage);
                Glide.with(fragmentActivity).load(stringExtra).into(getBinding().pic);
                getViewModel().setProfileIcon(stringExtra);
            }
            String stringExtra2 = intent.getStringExtra(NAME);
            if (stringExtra2 != null) {
                getBinding().name.setText(stringExtra2);
            }
            double doubleExtra = intent.getDoubleExtra(RATE, -1.0d);
            if (doubleExtra == -1.0d) {
                return;
            }
            getBinding().userCoin.setText(NumberExtKt.formatByNumberRupee$default(doubleExtra, false, 1, (Object) null) + '/' + getString(2131951652));
        }
    }

    private final void callAccepted(Intent intent) {
        if (this.isStreamer) {
            return;
        }
        if (intent != null && intent.getBooleanExtra(ACCEPT, false)) {
            showRechargePopup(null);
            stopRinging();
        }
    }

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

    public final void checkPriceSurgeAndShowAlert(VideoDetailModel videoDetailModel) {
        if (!Intrinsics.areEqual(videoDetailModel.getCallType(), "REAL")) {
            this.priceSurgeTimerFinished = true;
        } else {
            if (this.isStreamer || this.priceSurgeAlertAlreadyShown) {
                return;
            }
            if (videoDetailModel.getRate() > App.Companion.getLastCallRatePriceSeenByUser()) {
                openPriceSurgeDialog(videoDetailModel.getRate(), App.Companion.getLastCallRatePriceSeenByUser());
            }
            this.priceSurgeAlertAlreadyShown = true;
        }
    }

    private final void openPriceSurgeDialog(double newRate, double oldRate) {
        final PriceSurgeAlertDialogBinding inflate = PriceSurgeAlertDialogBinding.inflate(getLayoutInflater());
        Intrinsics.checkNotNullExpressionValue(inflate, "inflate(layoutInflater)");
        MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder((Context) this);
        materialAlertDialogBuilder.setView(inflate.getRoot());
        final AlertDialog create = materialAlertDialogBuilder.create();
        Intrinsics.checkNotNullExpressionValue(create, "builder.create()");
        create.setCancelable(false);
        String str = NumberExtKt.formatByNumberRupee$default(oldRate, false, 1, (Object) null) + "/min";
        String str2 = NumberExtKt.formatByNumberRupee$default(newRate, false, 1, (Object) null) + "/min";
        inflate.oldPrice.setText(str);
        inflate.newPrice.setText(str2);
        final Ref.ObjectRef objectRef = new Ref.ObjectRef();
        objectRef.element = new CountDownTimer() {
            {
                super(12000L, 1000L);
            }

            @Override
            public void onTick(long millisUntilFinished) {
                PriceSurgeAlertDialogBinding.this.dialogTimer.setText("Take action within " + ((int) (millisUntilFinished / 1000)) + " seconds");
            }

            @Override
            public void onFinish() {
                this.priceSurgeTimerFinished = true;
                create.dismiss();
            }
        }.start();
        inflate.dialogTimer.setText("");
        inflate.proceed.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                CallActivity.openPriceSurgeDialog$lambda$6$lambda$4(CallActivity.this, objectRef, create, view);
            }
        });
        inflate.cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                CallActivity.openPriceSurgeDialog$lambda$6$lambda$5(CallActivity.this, objectRef, create, view);
            }
        });
        Window window = create.getWindow();
        if (window != null) {
            window.setBackgroundDrawableResource(R.color.transparent);
        }
        create.show();
    }

    public static final void openPriceSurgeDialog$lambda$6$lambda$4(CallActivity callActivity, Ref.ObjectRef objectRef, AlertDialog alertDialog, View view) {
        Intrinsics.checkNotNullParameter(callActivity, "this$0");
        Intrinsics.checkNotNullParameter(objectRef, "$timer");
        Intrinsics.checkNotNullParameter(alertDialog, "$dialog");
        callActivity.priceSurgeTimerFinished = true;
        CountDownTimer countDownTimer = (CountDownTimer) objectRef.element;
        if (countDownTimer != null) {
            countDownTimer.cancel();
        }
        alertDialog.dismiss();
    }

    public static final void openPriceSurgeDialog$lambda$6$lambda$5(CallActivity callActivity, Ref.ObjectRef objectRef, AlertDialog alertDialog, View view) {
        Intrinsics.checkNotNullParameter(callActivity, "this$0");
        Intrinsics.checkNotNullParameter(objectRef, "$timer");
        Intrinsics.checkNotNullParameter(alertDialog, "$dialog");
        callActivity.priceSurgeTimerFinished = false;
        CountDownTimer countDownTimer = (CountDownTimer) objectRef.element;
        if (countDownTimer != null) {
            countDownTimer.cancel();
        }
        alertDialog.dismiss();
        if (callActivity.videoId != -1) {
            callActivity.getViewModel().cancelVideoCall(callActivity.videoId);
        } else if (callActivity.isTaskRoot()) {
            callActivity.closeScreen();
        } else {
            callActivity.finish();
        }
    }

    public final void onCallerJoin(CallViewModel.CallEvent.VideoDetailSuccess event) {
        String str = Intrinsics.areEqual(event.getData().getCallType(), "AUDIO") ? "AUDIO" : Constants.VIDEO_CALL;
        if (event.getData().getStreamerJoined()) {
            if (this.streamerJoined) {
                return;
            }
            this.streamerJoined = true;
            if (!this.isVisible) {
                stopRinging();
            }
            Timber.e("Streamer has joined the call", new Object[0]);
            VideoDetailModel data = event.getData();
            if (App.Companion.isVideoCallScreen()) {
                ActivityExtKt.toast((Activity) this, "Video screen is visible");
                finish();
                return;
            }
            int i = this.userCountInRoom + 1;
            this.userCountInRoom = i;
            Context context = (Context) this;
            SharedPref.setInt(context, PrefKeys.USER_COUNT_IN_ROOM, i);
            SharedPref.setString(context, "RTC_PROVIDER", data.getRtcProvider());
            String webViewUrl = data.getWebViewUrl();
            if (webViewUrl == null) {
                webViewUrl = "";
            }
            SharedPref.setString(context, PrefKeys.RTC_WEB_LINK, webViewUrl);
            gotoVideoActivity(data.getAgoraChannelName(), data.getAgoraUserToken(), Long.valueOf(data.getId()), data, this.caller, str);
            CoroutineScopeKt.cancel$default(this.scope, (CancellationException) null, 1, (Object) null);
            return;
        }
        if (event.getData().getUserJoined()) {
            Timber.e("User has joined the call", new Object[0]);
            VideoDetailModel data2 = event.getData();
            if (App.Companion.isVideoCallScreen()) {
                finish();
                return;
            }
            gotoVideoActivity(data2.getAgoraChannelName(), data2.getAgoraStreamerToken(), Long.valueOf(data2.getId()), data2, this.caller, str);
            if (this.isVisible || App.Companion.isVideoCallScreen()) {
                CoroutineScopeKt.cancel$default(this.scope, (CancellationException) null, 1, (Object) null);
            }
        }
    }

    public final void showFailedReason(String failureReason, VideoDetailModel data) {
        if (this._binding == null) {
            finish();
        }
        if (getViewModel().getIsBot()) {
            return;
        }
        AppCompatImageView appCompatImageView = this.mHangupBtn;
        if (appCompatImageView != null) {
            appCompatImageView.setVisibility(0);
        }
        switch (failureReason.hashCode()) {
            case -1421427592:
                if (failureReason.equals("INVALID_CARD")) {
                    getBinding().callRole.setText(StringExtKt.capitalizeFirstLetter(failureReason));
                    ActivityExtKt.toast((Activity) this, StringsKt.replace$default(StringExtKt.capitalizeFirstLetter(failureReason), "_", " ", false, 4, (Object) null));
                    stopRinging();
                    BuildersKt.launch$default(this.scope, (CoroutineContext) null, (CoroutineStart) null, new CallActivity$showFailedReason$7(this, null), 3, (Object) null);
                    break;
                }
                break;
            case -1031784143:
                if (failureReason.equals("CANCELLED")) {
                    getBinding().callRole.setText(StringExtKt.capitalizeFirstLetter(failureReason));
                    stopRinging();
                    BuildersKt.launch$default(this.scope, (CoroutineContext) null, (CoroutineStart) null, new CallActivity$showFailedReason$6(this, null), 3, (Object) null);
                    break;
                }
                break;
            case -830629437:
                if (failureReason.equals("OFFLINE")) {
                    getBinding().callRole.setText(getString(2131953048));
                    BuildersKt.launch$default(this.scope, (CoroutineContext) null, (CoroutineStart) null, new CallActivity$showFailedReason$2(this, null), 3, (Object) null);
                    break;
                }
                break;
            case 2050553:
                if (failureReason.equals("BUSY")) {
                    getBinding().callRole.setText(StringExtKt.capitalizeFirstLetter(failureReason));
                    stopRinging();
                    BuildersKt.launch$default(this.scope, (CoroutineContext) null, (CoroutineStart) null, new CallActivity$showFailedReason$4(this, null), 3, (Object) null);
                    break;
                }
                break;
            case 174130302:
                if (failureReason.equals("REJECTED")) {
                    getBinding().callRole.setText(getString(2131951757));
                    stopRinging();
                    BuildersKt.launch$default(this.scope, (CoroutineContext) null, (CoroutineStart) null, new CallActivity$showFailedReason$5(this, null), 3, (Object) null);
                    break;
                }
                break;
            case 1511761526:
                if (failureReason.equals("UNANSWERED")) {
                    getBinding().callRole.setText(getString(2131952369));
                    BuildersKt.launch$default(this.scope, (CoroutineContext) null, (CoroutineStart) null, new CallActivity$showFailedReason$3(this, null), 3, (Object) null);
                    break;
                }
                break;
            case 1517467264:
                if (failureReason.equals("INSUFFICIENT_BALANCE")) {
                    getBinding().callRole.setText(getString(2131951616));
                    stopRinging();
                    if (!this.isStreamer) {
                        showRechargePopup(data);
                        break;
                    } else {
                        BuildersKt.launch$default(this.scope, (CoroutineContext) null, (CoroutineStart) null, new CallActivity$showFailedReason$1(this, null), 3, (Object) null);
                        break;
                    }
                }
                break;
        }
    }

    private final void getVideoDetails(Intent intent) {
        if (intent == null || intent.getExtras() == null) {
            return;
        }
        getViewModel().setBot(intent.getBooleanExtra(IS_BOT, false));
        getViewModel().setRandom(intent.getBooleanExtra(IS_RANDOM, false));
        getViewModel().setFreeCall(intent.getBooleanExtra(IS_FREE_CALL, false));
        getViewModel().setGoddessCall(intent.getBooleanExtra(IS_GOODESS_CALL, false));
        getViewModel().setBotVideo(intent.getBooleanExtra(IS_BOT_VIDEO, false));
        getViewModel().setAudioCall(intent.getBooleanExtra(Constants.KEY_CALL_TYPE, false));
        getViewModel().setFreeTrial(intent.getBooleanExtra(IS_FREE_TRIAL, false));
        getViewModel().setPromotional(intent.getBooleanExtra(IS_PROMOTIONAL, false));
        getViewModel().setRandomPromotional(intent.getBooleanExtra(IS_PROMOTIONAL_RANDOM, false));
        getViewModel().setPriorityCall(intent.getBooleanExtra(IS_PRIORITY_CALL, false));
        String stringExtra = intent.getStringExtra(Constants.FCM_DATA);
        if (stringExtra != null) {
            VideoDetailModel videoDetailModel = (VideoDetailModel) new Gson().fromJson(stringExtra, VideoDetailModel.class);
            getViewModel().setVideoDetails(videoDetailModel);
            if (videoDetailModel != null) {
                this.isStreamer = Intrinsics.areEqual(String.valueOf(videoDetailModel.getStreamerId()), getUserId());
                getViewModel().setPriorityCall(videoDetailModel.isPriorityCall());
                if (this.isStreamer) {
                    CallViewModel viewModel = getViewModel();
                    String rtcProvider = videoDetailModel.getRtcProvider();
                    if (rtcProvider == null) {
                        rtcProvider = "ZEGO";
                    }
                    viewModel.setRtcProvider(rtcProvider);
                }
            }
        }
        if (getViewModel().getIsBot() || getViewModel().getIsBotVideo()) {
            AppCompatImageView appCompatImageView = this.mHangupBtn;
            if (appCompatImageView != null) {
                appCompatImageView.setVisibility(0);
            }
            BuildersKt.launch$default(this.botScope, (CoroutineContext) null, (CoroutineStart) null, new CallActivity$getVideoDetails$1(new Ref.IntRef(), this, null), 3, (Object) null);
        }
    }

    private final boolean isCaller() {
        return Intrinsics.areEqual(this.mRole, "USER");
    }

    private final boolean isCallee() {
        return Intrinsics.areEqual(this.mRole, "STREAMER");
    }

    private final void startRinging() {
        if (isCallee()) {
            this.mPlayer = playCalleeRing();
        } else if (isCaller()) {
            this.mPlayer = playCallerRing();
        }
    }

    private final MediaPlayer playCallerRing() {
        return startRinging(2131886126);
    }

    private final MediaPlayer playCalleeRing() {
        return startRinging(2131886126);
    }

    private final MediaPlayer startRinging(int resource) {
        MediaPlayer mediaPlayer;
        try {
            if (!LiveStreamingService.INSTANCE.isLiveStreamingRunning() && (!getViewModel().getIsPriorityCall() || !this.isStreamer)) {
                try {
                    mediaPlayer = MediaPlayer.create((Context) this, resource);
                } catch (Exception e) {
                    e.printStackTrace();
                    mediaPlayer = null;
                }
                if (mediaPlayer != null) {
                    mediaPlayer.setLooping(true);
                    mediaPlayer.start();
                }
                return mediaPlayer;
            }
        } catch (Exception unused) {
        }
        return null;
    }

    private final void stopRinging() {
        try {
            try {
                MediaPlayer mediaPlayer = this.mPlayer;
                if (mediaPlayer != null) {
                    boolean z = true;
                    if (mediaPlayer == null || !mediaPlayer.isPlaying()) {
                        z = false;
                    }
                    if (z) {
                        MediaPlayer mediaPlayer2 = this.mPlayer;
                        if (mediaPlayer2 != null) {
                            mediaPlayer2.stop();
                        }
                        MediaPlayer mediaPlayer3 = this.mPlayer;
                        if (mediaPlayer3 != null) {
                            mediaPlayer3.reset();
                        }
                        MediaPlayer mediaPlayer4 = this.mPlayer;
                        if (mediaPlayer4 != null) {
                            mediaPlayer4.release();
                        }
                        this.mPlayer = null;
                    }
                }
            } catch (Exception e) {
                Timber.e(e);
            }
        } finally {
            this.mPlayer = null;
        }
    }

    @Override
    public void onClick(View view) {
        String str;
        Intrinsics.checkNotNullParameter(view, "view");
        int id = view.getId();
        if (id != 2131361885) {
            if (id != 2131363099) {
                return;
            }
            if (getViewModel().getIsBot()) {
                if (isTaskRoot()) {
                    closeScreen();
                    return;
                } else {
                    finish();
                    return;
                }
            }
            if (isCaller()) {
                if (this.videoId != -1) {
                    getViewModel().cancelVideoCall(this.videoId);
                    return;
                } else if (isTaskRoot()) {
                    closeScreen();
                    return;
                } else {
                    finish();
                    return;
                }
            }
            if (isCallee()) {
                if (this.videoId != -1) {
                    getViewModel().rejectVideoCall(this.videoId);
                    return;
                } else if (isTaskRoot()) {
                    closeScreen();
                    return;
                } else {
                    finish();
                    return;
                }
            }
            return;
        }
        if (getViewModel().getIsBot()) {
            stopRinging();
            CoroutineScopeKt.cancel$default(this.botScope, (CancellationException) null, 1, (Object) null);
            showRechargePopup(getViewModel().getVideoDetails());
            return;
        }
        if (getViewModel().getIsBotVideo()) {
            stopRinging();
            CoroutineScopeKt.cancel$default(this.botScope, (CancellationException) null, 1, (Object) null);
            Intent intent = new Intent(getApplicationContext(), (Class<?>) FakeVideoCallActivity.class);
            intent.putExtra(Constants.KEY_CALLING_VIDEO_ID, this.videoId);
            intent.putExtra(Constants.FCM_DATA, new Gson().toJson(getViewModel().getVideoDetails()));
            startActivity(intent);
            finish();
            return;
        }
        VideoDetailModel videoDetails = getViewModel().getVideoDetails();
        if (videoDetails == null || (str = this.caller) == null) {
            return;
        }
        Ref.ObjectRef objectRef = new Ref.ObjectRef();
        objectRef.element = Constants.VIDEO_CALL;
        if (Intrinsics.areEqual(videoDetails.getCallType(), "AUDIO")) {
            objectRef.element = "AUDIO";
        }
        if (this.isStreamer) {
            int i = this.userCountInRoom + 1;
            this.userCountInRoom = i;
            SharedPref.setInt((Context) this, PrefKeys.USER_COUNT_IN_ROOM, i);
        }
        if (!LiveStreamingService.INSTANCE.isLiveStreamingRunning() && !this.sdkinitialized && !videoDetails.isPriorityCall()) {
            this.initialized = false;
            BuildersKt.launch$default(LifecycleOwnerKt.getLifecycleScope((LifecycleOwner) this), (CoroutineContext) null, (CoroutineStart) null, new CallActivity$onClick$1$1$1(this, str, videoDetails, objectRef, null), 3, (Object) null);
        } else if (LiveStreamingService.INSTANCE.isLiveStreamingRunning()) {
            this.initialized = false;
            BuildersKt.launch$default(LifecycleOwnerKt.getLifecycleScope((LifecycleOwner) this), (CoroutineContext) null, (CoroutineStart) null, new CallActivity$onClick$1$1$2(this, str, videoDetails, objectRef, null), 3, (Object) null);
        } else if (getViewModel().getIsPriorityCall()) {
            this.initialized = false;
            BuildersKt.launch$default(LifecycleOwnerKt.getLifecycleScope((LifecycleOwner) this), (CoroutineContext) null, (CoroutineStart) null, new CallActivity$onClick$1$1$3(this, str, videoDetails, objectRef, null), 3, (Object) null);
        } else {
            handleScreenChange(str, videoDetails, (String) objectRef.element);
        }
    }

    public final java.lang.Object handlePriorityCallChanges(final java.lang.String r7, final app.callpe.data.model.VideoDetailModel r8, final java.lang.String r9, kotlin.coroutines.Continuation<? super kotlin.Unit> r10) {
        throw new UnsupportedOperationException("Method not decompiled: app.callpe.ui.call.CallActivity.handlePriorityCallChanges(java.lang.String, app.callpe.data.model.VideoDetailModel, java.lang.String, kotlin.coroutines.Continuation):java.lang.Object");
    }

    public final java.lang.Object handleScreenChangesFromLivestream(java.lang.String r17, app.callpe.data.model.VideoDetailModel r18, java.lang.String r19, kotlin.coroutines.Continuation<? super kotlin.Unit> r20) {
        throw new UnsupportedOperationException("Method not decompiled: app.callpe.ui.call.CallActivity.handleScreenChangesFromLivestream(java.lang.String, app.callpe.data.model.VideoDetailModel, java.lang.String, kotlin.coroutines.Continuation):java.lang.Object");
    }

    public final java.lang.Object handleScreenChangesForCall(java.lang.String r11, app.callpe.data.model.VideoDetailModel r12, java.lang.String r13, kotlin.coroutines.Continuation<? super kotlin.Unit> r14) {
        throw new UnsupportedOperationException("Method not decompiled: app.callpe.ui.call.CallActivity.handleScreenChangesForCall(java.lang.String, app.callpe.data.model.VideoDetailModel, java.lang.String, kotlin.coroutines.Continuation):java.lang.Object");
    }

    public final void handleScreenChange(String call, VideoDetailModel videoDetailModel, String callType) {
        if (Intrinsics.areEqual(call, "USER")) {
            gotoVideoActivity(videoDetailModel.getAgoraChannelName(), videoDetailModel.getAgoraStreamerToken(), Long.valueOf(videoDetailModel.getId()), videoDetailModel, this.caller, callType);
        } else {
            gotoVideoActivity(videoDetailModel.getAgoraChannelName(), videoDetailModel.getAgoraUserToken(), Long.valueOf(videoDetailModel.getId()), videoDetailModel, this.caller, callType);
        }
    }

    private final void handleScreenClose() {
        if (getIntent().getBooleanExtra(SCREEN_CLOSED, false)) {
            closeScreen();
        }
        HeadsUpNotificationService.INSTANCE.setServiceRunning(false);
    }

    public final void handleLiveIfLiveStreaming() {
        try {
            if (LiveStreamingService.INSTANCE.isLiveStreamingRunning() || (LiveStreamingActivity.INSTANCE.isLiveStreamScreenOpen() && !LoginActivity.INSTANCE.isVitok())) {
                RtcManager currentRtcInstance = RtcManagerFactory.getCurrentRtcInstance();
                if (currentRtcInstance != null) {
                    currentRtcInstance.leaveRtcRoom(new SignOutListener() {
                        @Override
                        public final void signOut() {
                            CallActivity.handleLiveIfLiveStreaming$lambda$11$lambda$10();
                        }
                    });
                    currentRtcInstance.disconnectUser(true);
                    currentRtcInstance.stopLocalPreview();
                    currentRtcInstance.setEventHandler(null);
                }
                getViewModel().closeLiveScreen(this.isStreamer);
                if (!LiveStreamingActivity.INSTANCE.isLiveStreamScreenOpen() || LoginActivity.INSTANCE.isVitok()) {
                    return;
                }
                LocalBroadcastManager.getInstance((Context) this).sendBroadcast(new Intent(Constants.LIVESTREAM_KILL_SCREEN));
            }
        } catch (Exception e) {
            Timber.e(e);
        }
    }

    public final void closeScreen() {
        getIntent().putExtra(SCREEN_CLOSED, true);
        Intent intent = new Intent((Context) this, (Class<?>) SplashActivity.class);
        intent.addFlags(67141632);
        startActivity(intent);
        finish();
    }

    public void finish() {
        stopRinging();
        this._binding = null;
        Job.DefaultImpls.cancel$default(this.job, (CancellationException) null, 1, (Object) null);
        super.finish();
    }

    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        if (intent != null) {
            this.mChannel = intent.getStringExtra(Constants.KEY_CALLING_CHANNEL);
            this.videoId = intent.getLongExtra(Constants.KEY_CALLING_VIDEO_ID, -1L);
            this.caller = intent.getStringExtra(Constants.KEY_CALLER);
            getVideoDetails(intent);
            callAccepted(intent);
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        handleUserJoin();
    }

    private final void handleUserJoin() {
        try {
            if (LoginActivity.INSTANCE.isVitok() || App.Companion.isVideoCallScreen() || !this.streamerJoined) {
                return;
            }
            this.streamerJoined = false;
            CallViewModel.getVideoDetailsWithRetry$default(getViewModel(), this.videoId, false, 2, null);
        } catch (Exception e) {
            Timber.e(e);
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        unRegisterReceiver();
        Job.DefaultImpls.cancel$default(this.job, (CancellationException) null, 1, (Object) null);
        CoroutineScopeKt.cancel$default(this.botScope, (CancellationException) null, 1, (Object) null);
        if (getViewModel().getIsPriorityCall()) {
            getProgressDialog().dismiss();
        }
        if (LiveStreamingService.INSTANCE.isLiveStreamingRunning()) {
            getProgressDialogForCall().dismiss();
        }
        if (isFinishing()) {
            stopRinging();
        }
    }

    private final void showRechargePopup(VideoDetailModel data) {
        try {
            if (!(getIntent().getDoubleExtra(RATE, -1.0d) == -1.0d) && data != null) {
                data.setRate(getIntent().getDoubleExtra(RATE, -1.0d));
            }
            RechargeDialog rechargeDialog = new RechargeDialog(data, data != null ? data.getBalanceDto() : null, getViewModel().getProfileIcon(), null, null, new Function0<Unit>() {
                {
                    super(0);
                }

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

                public final void m884invoke() {
                    if (CallActivity.this.isTaskRoot()) {
                        CallActivity.this.closeScreen();
                    } else {
                        CallActivity.this.finish();
                    }
                }
            }, new Function0<Unit>() {
                {
                    super(0);
                }

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

                public final void m885invoke() {
                    if (CallActivity.this.isTaskRoot()) {
                        CallActivity.this.closeScreen();
                    } else {
                        CallActivity.this.finish();
                    }
                }
            }, 24, null);
            rechargeDialog.setCancelable(false);
            if (!rechargeDialog.isAdded() && !rechargeDialog.isVisible()) {
                rechargeDialog.show(getSupportFragmentManager(), "RechargeDialog");
            }
        } catch (Exception unused) {
            String string = getString(2131951993);
            Intrinsics.checkNotNullExpressionValue(string, "getString(R.string.error_unknown)");
            ActivityExtKt.toast((Activity) this, string);
        }
    }

    private final void registerReceiver() {
        try {
            LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance((Context) this);
            Intrinsics.checkNotNullExpressionValue(localBroadcastManager, "getInstance(this)");
            IntentFilter intentFilter = new IntentFilter();
            intentFilter.addAction(Constants.VIDEO_CALL_FAILED);
            intentFilter.addAction(Constants.CALL_SCREEN_NOTIFICATION);
            localBroadcastManager.registerReceiver(this.broadcastReceiver, intentFilter);
        } catch (Exception e) {
            Timber.e(e);
        }
    }

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

    @Metadata(d1 = {"\u0000^\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\u0010\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\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\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\t\n\u0002\b\n\n\u0002\u0018\u0002\n\u0002\b\u0007\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u0016\u0010\u0017\u001a\u00020\u00182\u0006\u0010\u0019\u001a\u00020\u001a2\u0006\u0010\u001b\u001a\u00020\u001cJW\u0010\u001d\u001a\u00020\u00182\u0006\u0010\u0019\u001a\u00020\u001a2\u0006\u0010\u001e\u001a\u00020\u001f2\b\b\u0002\u0010 \u001a\u00020!2\b\b\u0002\u0010\"\u001a\u00020#2\u0010\b\u0002\u0010$\u001a\n\u0012\u0004\u0012\u00020&\u0018\u00010%2\b\b\u0002\u0010'\u001a\u00020\u00042\n\b\u0002\u0010(\u001a\u0004\u0018\u00010)¢\u0006\u0002\u0010*J4\u0010\u001d\u001a\u00020\u00182\u0006\u0010\u0019\u001a\u00020\u001a2\u0006\u0010+\u001a\u00020)2\b\u0010,\u001a\u0004\u0018\u00010\u00042\b\u0010-\u001a\u0004\u0018\u00010\u00042\b\b\u0002\u0010 \u001a\u00020!Ja\u0010.\u001a\u00020\u00182\u0006\u0010\u0019\u001a\u00020\u001a2\u0006\u0010\u001e\u001a\u00020\u001f2\u0010\b\u0002\u0010$\u001a\n\u0012\u0004\u0012\u00020&\u0018\u00010%2\b\b\u0002\u0010'\u001a\u00020\u00042\b\b\u0002\u0010/\u001a\u00020#2\b\b\u0002\u00100\u001a\u00020#2\b\b\u0002\u0010 \u001a\u00020!2\n\b\u0002\u0010(\u001a\u0004\u0018\u00010)¢\u0006\u0002\u00101J\u0081\u0001\u00102\u001a\u00020\u00182\u0006\u0010\u0019\u001a\u00020\u001a2\u0006\u0010\u001e\u001a\u00020\u001f2\u0010\b\u0002\u0010$\u001a\n\u0012\u0004\u0012\u00020&\u0018\u00010%2\n\b\u0002\u00103\u001a\u0004\u0018\u0001042\b\b\u0002\u0010\"\u001a\u00020#2\b\b\u0002\u0010'\u001a\u00020\u00042\b\b\u0002\u00105\u001a\u00020#2\b\b\u0002\u0010/\u001a\u00020#2\b\b\u0002\u00100\u001a\u00020#2\b\b\u0002\u0010 \u001a\u00020!2\n\b\u0002\u0010(\u001a\u0004\u0018\u00010)¢\u0006\u0002\u00106J<\u00107\u001a\u00020\u00182\u0006\u0010\u0019\u001a\u00020\u001a2\u0006\u00108\u001a\u00020)2\u0006\u00109\u001a\u00020#2\b\b\u0002\u00100\u001a\u00020#2\b\b\u0002\u0010 \u001a\u00020!2\b\b\u0002\u0010:\u001a\u00020#R\u000e\u0010\u0003\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u0005\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u0007\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\b\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\t\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u000b\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\f\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\r\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u000e\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u000f\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u0010\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u0011\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u0012\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u0013\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u0014\u001a\u00020\u0015X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u0016\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000¨\u0006;"}, d2 = {"Lapp/callpe/ui/call/CallActivity$Companion;", "", "()V", CallActivity.ACCEPT, "", CallActivity.CARD_ID, CallActivity.IS_BOT, CallActivity.IS_BOT_VIDEO, CallActivity.IS_FREE_CALL, CallActivity.IS_FREE_TRIAL, CallActivity.IS_GOODESS_CALL, CallActivity.IS_PRIORITY_CALL, CallActivity.IS_PROMOTIONAL, CallActivity.IS_PROMOTIONAL_RANDOM, CallActivity.IS_RANDOM, CallActivity.LIVESTREAM_ID, CallActivity.NAME, "PROFILE_PIC", CallActivity.RANDOM_CALL_DURATION, CallActivity.RATE, "REFRESH_SCREEN", "", CallActivity.SCREEN_CLOSED, "gotoCallingActivity", "", "activity", "Landroidx/fragment/app/FragmentActivity;", "data", "Lapp/callpe/data/model/VideoDetailModel;", "userCall", "host", "Lapp/callpe/data/model/StreamerModel;", "caller", "Lapp/callpe/common/utils/Constants$ROLE;", "isVip", "", "launcher", "Landroidx/activity/result/ActivityResultLauncher;", "Landroid/content/Intent;", "callType", "livestreamId", "", "(Landroidx/fragment/app/FragmentActivity;Lapp/callpe/data/model/StreamerModel;Lapp/callpe/common/utils/Constants$ROLE;ZLandroidx/activity/result/ActivityResultLauncher;Ljava/lang/String;Ljava/lang/Long;)V", "hostId", "avatar", FacebookRequestErrorClassification.KEY_NAME, "userFreeTrialCall", "freeTrial", "goddessCall", "(Landroidx/fragment/app/FragmentActivity;Lapp/callpe/data/model/StreamerModel;Landroidx/activity/result/ActivityResultLauncher;Ljava/lang/String;ZZLapp/callpe/common/utils/Constants$ROLE;Ljava/lang/Long;)V", "userPriorityCall", "priorityCallConfig", "Lapp/callpe/data/model/PriorityCallConfig;", "priorityCall", "(Landroidx/fragment/app/FragmentActivity;Lapp/callpe/data/model/StreamerModel;Landroidx/activity/result/ActivityResultLauncher;Lapp/callpe/data/model/PriorityCallConfig;ZLjava/lang/String;ZZZLapp/callpe/common/utils/Constants$ROLE;Ljava/lang/Long;)V", "userRandomCall", "cardId", "freeCall", "isPromotionalRandom", "app_riloRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
    public static final class Companion {
        public Companion(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        private Companion() {
        }

        public final void userCall(FragmentActivity activity, StreamerModel host, Constants.ROLE caller, boolean isVip, ActivityResultLauncher<Intent> launcher, String callType, Long livestreamId) {
            double audioVipRate;
            Intrinsics.checkNotNullParameter(activity, "activity");
            Intrinsics.checkNotNullParameter(host, "host");
            Intrinsics.checkNotNullParameter(caller, "caller");
            Intrinsics.checkNotNullParameter(callType, "callType");
            Intent intent = new Intent((Context) activity, (Class<?>) CallActivity.class);
            intent.putExtra(Constants.KEY_CALLING_CHANNEL, "");
            intent.putExtra(Constants.KEY_AGORA_ACCESS_TOKEN, "");
            intent.putExtra(Constants.KEY_CALLING_VIDEO_ID, -1L);
            intent.putExtra(Constants.KEY_CALLING_STREAMER_ID, host.getId());
            intent.putExtra(Constants.KEY_CALLING_ROLE, "USER");
            intent.putExtra(Constants.KEY_CALLER, caller.name());
            intent.putExtra(Constants.FCM_DATA, "");
            intent.putExtra(CallActivity.NAME, host.getName());
            intent.putExtra(CallActivity.PROFILE_PIC, StreamerModel.getProfile$default(host, false, 1, null));
            intent.putExtra(CallActivity.LIVESTREAM_ID, livestreamId);
            intent.putExtra(CallActivity.IS_FREE_TRIAL, false);
            Boolean promotionalEnabled = host.getPromotionalEnabled();
            boolean booleanValue = promotionalEnabled != null ? promotionalEnabled.booleanValue() : false;
            intent.putExtra(CallActivity.IS_PROMOTIONAL, booleanValue);
            if (!Intrinsics.areEqual(callType, Constants.VIDEO_CALL)) {
                audioVipRate = isVip ? host.getAudioVipRate() : host.getAudioUserRate();
            } else if (booleanValue) {
                intent.putExtra(CallActivity.IS_RANDOM, true);
                audioVipRate = host.getPromotionalUserRate();
            } else if (isVip) {
                audioVipRate = host.getVipCallRate();
            } else {
                audioVipRate = host.getDisplayRate();
            }
            if (Intrinsics.areEqual(callType, Constants.VIDEO_CALL)) {
                intent.putExtra(CallActivity.RATE, audioVipRate);
            } else if (Intrinsics.areEqual(callType, "AUDIO")) {
                intent.putExtra(Constants.KEY_CALL_TYPE, true);
                intent.putExtra(CallActivity.RATE, audioVipRate);
            }
            if (launcher == null) {
                activity.startActivity(intent);
            } else {
                launcher.launch(intent);
            }
        }

        public final void userRandomCall(FragmentActivity activity, long cardId, boolean freeCall, boolean goddessCall, Constants.ROLE caller, boolean isPromotionalRandom) {
            Intrinsics.checkNotNullParameter(activity, "activity");
            Intrinsics.checkNotNullParameter(caller, "caller");
            Intent intent = new Intent((Context) activity, (Class<?>) CallActivity.class);
            intent.putExtra(Constants.KEY_CALLING_CHANNEL, "");
            intent.putExtra(Constants.KEY_AGORA_ACCESS_TOKEN, "");
            intent.putExtra(Constants.KEY_CALLING_VIDEO_ID, -1L);
            intent.putExtra(Constants.KEY_CALLING_ROLE, "USER");
            intent.putExtra(Constants.KEY_CALLER, caller.name());
            intent.putExtra(CallActivity.IS_RANDOM, true);
            intent.putExtra(CallActivity.IS_FREE_CALL, freeCall);
            intent.putExtra(CallActivity.IS_GOODESS_CALL, goddessCall);
            intent.putExtra(CallActivity.RANDOM_CALL_DURATION, 0);
            intent.putExtra(CallActivity.CARD_ID, cardId);
            intent.putExtra(Constants.FCM_DATA, "");
            intent.putExtra(CallActivity.IS_PROMOTIONAL_RANDOM, isPromotionalRandom);
            activity.startActivity(intent);
        }

        public final void userFreeTrialCall(FragmentActivity activity, StreamerModel host, ActivityResultLauncher<Intent> launcher, String callType, boolean freeTrial, boolean goddessCall, Constants.ROLE caller, Long livestreamId) {
            Intrinsics.checkNotNullParameter(activity, "activity");
            Intrinsics.checkNotNullParameter(host, "host");
            Intrinsics.checkNotNullParameter(callType, "callType");
            Intrinsics.checkNotNullParameter(caller, "caller");
            Intent intent = new Intent((Context) activity, (Class<?>) CallActivity.class);
            intent.putExtra(Constants.KEY_CALLING_CHANNEL, "");
            intent.putExtra(Constants.KEY_AGORA_ACCESS_TOKEN, "");
            intent.putExtra(Constants.KEY_CALLING_VIDEO_ID, -1L);
            intent.putExtra(Constants.KEY_CALLING_STREAMER_ID, host.getId());
            intent.putExtra(Constants.KEY_CALLING_ROLE, "USER");
            intent.putExtra(Constants.KEY_CALLER, caller.name());
            intent.putExtra(CallActivity.NAME, host.getName());
            intent.putExtra(CallActivity.PROFILE_PIC, StreamerModel.getProfile$default(host, false, 1, null));
            intent.putExtra(CallActivity.IS_RANDOM, true);
            intent.putExtra(CallActivity.IS_FREE_TRIAL, freeTrial);
            intent.putExtra(CallActivity.IS_GOODESS_CALL, goddessCall);
            intent.putExtra(CallActivity.RANDOM_CALL_DURATION, 0);
            intent.putExtra(Constants.FCM_DATA, "");
            intent.putExtra(CallActivity.LIVESTREAM_ID, livestreamId);
            if (launcher == null) {
                activity.startActivity(intent);
            } else {
                launcher.launch(intent);
            }
        }

        public final void userPriorityCall(FragmentActivity activity, StreamerModel host, ActivityResultLauncher<Intent> launcher, PriorityCallConfig priorityCallConfig, boolean isVip, String callType, boolean priorityCall, boolean freeTrial, boolean goddessCall, Constants.ROLE caller, Long livestreamId) {
            double displayRate;
            double rateMultiplierUser;
            Intrinsics.checkNotNullParameter(activity, "activity");
            Intrinsics.checkNotNullParameter(host, "host");
            Intrinsics.checkNotNullParameter(callType, "callType");
            Intrinsics.checkNotNullParameter(caller, "caller");
            Intent intent = new Intent((Context) activity, (Class<?>) CallActivity.class);
            intent.putExtra(Constants.KEY_CALLING_CHANNEL, "");
            intent.putExtra(Constants.KEY_AGORA_ACCESS_TOKEN, "");
            intent.putExtra(Constants.KEY_CALLING_VIDEO_ID, -1L);
            intent.putExtra(Constants.KEY_CALLING_STREAMER_ID, host.getId());
            intent.putExtra(Constants.KEY_CALLING_ROLE, "USER");
            intent.putExtra(Constants.KEY_CALLER, caller.name());
            intent.putExtra(CallActivity.NAME, host.getName());
            intent.putExtra(CallActivity.PROFILE_PIC, StreamerModel.getProfile$default(host, false, 1, null));
            intent.putExtra(CallActivity.IS_RANDOM, true);
            intent.putExtra(CallActivity.IS_FREE_TRIAL, freeTrial);
            intent.putExtra(CallActivity.IS_PRIORITY_CALL, priorityCall);
            intent.putExtra(CallActivity.IS_GOODESS_CALL, goddessCall);
            intent.putExtra(CallActivity.RANDOM_CALL_DURATION, 0);
            intent.putExtra(Constants.FCM_DATA, "");
            intent.putExtra(CallActivity.LIVESTREAM_ID, livestreamId);
            if (priorityCallConfig != null) {
                if (isVip) {
                    displayRate = host.getVipCallRate();
                    rateMultiplierUser = priorityCallConfig.getRateMultiplierUser();
                } else {
                    displayRate = host.getDisplayRate();
                    rateMultiplierUser = priorityCallConfig.getRateMultiplierUser();
                }
                intent.putExtra(CallActivity.RATE, displayRate * rateMultiplierUser);
            }
            if (launcher == null) {
                activity.startActivity(intent);
            } else {
                launcher.launch(intent);
            }
        }

        public static void userCall$default(Companion companion, FragmentActivity fragmentActivity, long j, String str, String str2, Constants.ROLE role, int i, Object obj) {
            if ((i & 16) != 0) {
                role = Constants.ROLE.USER;
            }
            companion.userCall(fragmentActivity, j, str, str2, role);
        }

        public final void userCall(FragmentActivity activity, long hostId, String avatar, String name, Constants.ROLE caller) {
            Intrinsics.checkNotNullParameter(activity, "activity");
            Intrinsics.checkNotNullParameter(caller, "caller");
            Intent intent = new Intent((Context) activity, (Class<?>) CallActivity.class);
            intent.putExtra(Constants.KEY_CALLING_CHANNEL, "");
            intent.putExtra(Constants.KEY_AGORA_ACCESS_TOKEN, "");
            intent.putExtra(Constants.KEY_CALLING_VIDEO_ID, -1L);
            intent.putExtra(Constants.KEY_CALLING_STREAMER_ID, hostId);
            intent.putExtra(Constants.KEY_CALLING_ROLE, "USER");
            intent.putExtra(Constants.KEY_CALLER, caller.name());
            intent.putExtra(Constants.FCM_DATA, "");
            intent.putExtra(CallActivity.NAME, name);
            intent.putExtra(CallActivity.PROFILE_PIC, avatar);
            activity.startActivity(intent);
        }

        public final void gotoCallingActivity(FragmentActivity activity, VideoDetailModel data) {
            Intrinsics.checkNotNullParameter(activity, "activity");
            Intrinsics.checkNotNullParameter(data, "data");
            Intent intent = new Intent((Context) activity, (Class<?>) CallActivity.class);
            intent.putExtra(Constants.KEY_CALLING_CHANNEL, data.getAgoraChannelName());
            intent.putExtra(Constants.KEY_AGORA_ACCESS_TOKEN, data.getAgoraUserToken());
            intent.putExtra(Constants.KEY_CALLING_VIDEO_ID, data.getId());
            intent.putExtra(Constants.KEY_CALLING_ROLE, "USER");
            intent.putExtra(Constants.FCM_DATA, new Gson().toJson(data));
            activity.startActivity(intent);
        }
    }
}