导航菜单

页面标题

页面副标题

Rilo v2.0.21 - BotCallActivity.java 源代码

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

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


package app.callpe.ui.call;

import android.app.Activity;
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.view.View;
import android.widget.TextView;
import androidx.activity.ComponentActivity;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.fragment.app.FragmentActivity;
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.extensions.ActivityExtKt;
import app.callpe.common.utils.sharedpref.PrefKeys;
import app.callpe.common.utils.sharedpref.SharedPref;
import app.callpe.data.model.StreamerModel;
import app.callpe.data.model.VideoDetailModel;
import app.callpe.databinding.ActivityBotCallBinding;
import app.callpe.service.HeadsUpNotificationService;
import app.callpe.service.LiveStreamingService;
import app.callpe.ui.SplashActivity;
import app.callpe.ui.dialog.RechargeDialog;
import app.callpe.ui.login.LoginActivity;
import app.callpe.ui.misc.FakeVideoCallActivity;
import com.bumptech.glide.Glide;
import com.google.gson.Gson;
import com.ncorti.slidetoact.SlideToActView;
import dagger.hilt.android.AndroidEntryPoint;
import java.util.concurrent.CancellationException;
import javax.inject.Inject;
import kotlin.Lazy;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.coroutines.CoroutineContext;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Ref;
import kotlin.jvm.internal.Reflection;
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 = {"\u0000p\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\u0005\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\u0005\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\n\n\u0002\u0018\u0002\n\u0002\b\u000b\n\u0002\u0018\u0002\n\u0002\b\u0006\b\u0007\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002J\u0012\u0010-\u001a\u00020.2\b\u0010/\u001a\u0004\u0018\u000100H\u0002J\b\u00101\u001a\u00020.H\u0002J\b\u00102\u001a\u00020.H\u0016J\u0012\u00103\u001a\u00020.2\b\u0010/\u001a\u0004\u0018\u000100H\u0002J\b\u00104\u001a\u00020.H\u0002J\b\u00105\u001a\u00020.H\u0002J\b\u00106\u001a\u00020.H\u0002J\b\u00107\u001a\u00020.H\u0016J\b\u00108\u001a\u00020.H\u0002J\u0012\u00109\u001a\u00020.2\b\u0010:\u001a\u0004\u0018\u00010;H\u0016J\b\u0010<\u001a\u00020.H\u0014J\u0012\u0010=\u001a\u00020.2\b\u0010/\u001a\u0004\u0018\u000100H\u0015J\b\u0010>\u001a\u00020.H\u0014J\b\u0010?\u001a\u00020.H\u0016J\b\u0010@\u001a\u00020.H\u0016J\n\u0010A\u001a\u0004\u0018\u00010\u0017H\u0002J\n\u0010B\u001a\u0004\u0018\u00010\u0017H\u0002J\b\u0010C\u001a\u00020.H\u0002J\b\u0010D\u001a\u00020.H\u0002J\u0012\u0010E\u001a\u00020.2\b\u0010F\u001a\u0004\u0018\u00010GH\u0002J\b\u0010H\u001a\u00020.H\u0002J\b\u0010I\u001a\u00020.H\u0002J\u0012\u0010I\u001a\u0004\u0018\u00010\u00172\u0006\u0010J\u001a\u00020\u001eH\u0002J\b\u0010K\u001a\u00020.H\u0002J\b\u0010L\u001a\u00020.H\u0002R\u0010\u0010\u0003\u001a\u0004\u0018\u00010\u0004X\u0082\u000e¢\u0006\u0002\n\u0000R\u0014\u0010\u0005\u001a\u00020\u00048BX\u0082\u0004¢\u0006\u0006\u001a\u0004\b\u0006\u0010\u0007R\u000e\u0010\b\u001a\u00020\tX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\u000bX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\f\u001a\u00020\rX\u0082\u0004¢\u0006\u0002\n\u0000R\u0010\u0010\u000e\u001a\u0004\u0018\u00010\u000fX\u0082\u000e¢\u0006\u0002\n\u0000R\u0014\u0010\u0010\u001a\u00020\u00118BX\u0082\u0004¢\u0006\u0006\u001a\u0004\b\u0010\u0010\u0012R\u0014\u0010\u0013\u001a\u00020\u00118BX\u0082\u0004¢\u0006\u0006\u001a\u0004\b\u0013\u0010\u0012R\u000e\u0010\u0014\u001a\u00020\tX\u0082\u0004¢\u0006\u0002\n\u0000R\u0010\u0010\u0015\u001a\u0004\u0018\u00010\u000fX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u0016\u001a\u0004\u0018\u00010\u0017X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u0018\u001a\u0004\u0018\u00010\u000fX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0019\u001a\u00020\u000bX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u001a\u001a\u00020\u0011X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u001b\u001a\u00020\u0011X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u001c\u001a\u00020\u0011X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u001d\u001a\u00020\u001eX\u0082\u000e¢\u0006\u0002\n\u0000R$\u0010\u001f\u001a\u00020\u000f8\u0006@\u0006X\u0087.¢\u0006\u0014\n\u0000\u0012\u0004\b \u0010\u0002\u001a\u0004\b!\u0010\"\"\u0004\b#\u0010$R\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*¨\u0006M"}, d2 = {"Lapp/callpe/ui/call/BotCallActivity;", "Lapp/callpe/ui/call/BaseZegoCallActivity;", "()V", "_binding", "Lapp/callpe/databinding/ActivityBotCallBinding;", "binding", "getBinding", "()Lapp/callpe/databinding/ActivityBotCallBinding;", "botJob", "Lkotlinx/coroutines/CompletableJob;", "botScope", "Lkotlinx/coroutines/CoroutineScope;", "broadcastReceiver", "Landroid/content/BroadcastReceiver;", "caller", "", "isCallee", "", "()Z", "isCaller", "job", "mChannel", "mPlayer", "Landroid/media/MediaPlayer;", "mRole", "scope", "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", "Lkotlin/Lazy;", "callAccepted", "", "intent", "Landroid/content/Intent;", "closeScreen", "finish", "getVideoDetails", "handleScreenClose", "handleUserJoin", "initUI", "onBackPressed", "onClicks", "onCreate", "savedInstanceState", "Landroid/os/Bundle;", "onDestroy", "onNewIntent", "onResume", "onStart", "onStop", "playCalleeRing", "playCallerRing", "registerReceiver", "showOnLockScreen", "showRechargePopup", "data", "Lapp/callpe/data/model/VideoDetailModel;", "showUserInfo", "startRinging", "resource", "stopRinging", "unRegisterReceiver", "app_riloRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
@AndroidEntryPoint
public final class BotCallActivity extends Hilt_BotCallActivity {
    private ActivityBotCallBinding _binding;
    private final CompletableJob botJob;
    private final CoroutineScope botScope;
    private final BroadcastReceiver broadcastReceiver;
    private String caller;
    private final CompletableJob job;
    private String mChannel;
    private MediaPlayer mPlayer;
    private String mRole;
    private final CoroutineScope scope;
    private boolean sendInfo;
    private boolean shown;
    private boolean streamerJoined;
    private int userCountInRoom;

    @Inject
    public String userId;
    private long videoId;

    private final Lazy viewModel;

    public static void getUserId$annotations() {
    }

    public void onBackPressed() {
    }

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

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

            public final CreationExtras m874invoke() {
                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.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.BotCallActivity$broadcastReceiver$1.onReceive(android.content.Context, android.content.Intent):void");
            }
        };
    }

    private final ActivityBotCallBinding getBinding() {
        ActivityBotCallBinding activityBotCallBinding = this._binding;
        Intrinsics.checkNotNull(activityBotCallBinding);
        return activityBotCallBinding;
    }

    public final CallViewModel getViewModel() {
        return (CallViewModel) this.viewModel.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 = ActivityBotCallBinding.inflate(getLayoutInflater());
        setContentView(getBinding().root);
        getVideoDetails(getIntent());
        showUserInfo();
        initUI();
        startRinging();
        callAccepted(getIntent());
        handleScreenClose();
        registerReceiver();
    }

    private final void showOnLockScreen() {
        try {
            if (Build.VERSION.SDK_INT == 30 && !LoginActivity.INSTANCE.isVitok()) {
                if (SharedPref.getBoolean((Context) this, PrefKeys.FIRST_RECHARGE_DONE)) {
                    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);
        }
    }

    private final void initUI() {
        Intent intent = getIntent();
        this.mChannel = intent.getStringExtra(Constants.KEY_CALLING_CHANNEL);
        this.videoId = intent.getLongExtra(Constants.KEY_CALLING_VIDEO_ID, -1L);
        getBinding().hangUpBtn.setVisibility(0);
        if (!LoginActivity.INSTANCE.isVitok() && !getViewModel().getIsBot() && !getViewModel().getIsBotVideo()) {
            getBinding().hangUpBtn.setVisibility(4);
        }
        TextView textView = getBinding().callRole;
        Intrinsics.checkNotNullExpressionValue(textView, "binding.callRole");
        this.mRole = intent.getStringExtra(Constants.KEY_CALLING_ROLE);
        this.caller = intent.getStringExtra(Constants.KEY_CALLER);
        if (isCallee()) {
            textView.setText(2131952489);
            getBinding().acceptCallBtn.setVisibility(0);
        }
        onClicks();
    }

    private final void showUserInfo() {
        Intent intent = getIntent();
        if (intent != null) {
            String stringExtra = intent.getStringExtra(CallActivity.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(CallActivity.NAME);
            if (stringExtra2 != null) {
                getBinding().name.setText(stringExtra2);
            }
        }
    }

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

    private final void getVideoDetails(Intent intent) {
        String str;
        if (intent == null || intent.getExtras() == null) {
            return;
        }
        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());
                TextView textView = getBinding().name;
                StreamerModel userDetails = videoDetailModel.getUserDetails();
                if (userDetails == null || (str = userDetails.getName()) == null) {
                    str = "";
                }
                textView.setText(str);
            }
        }
        getViewModel().setBot(intent.getBooleanExtra(CallActivity.IS_BOT, false));
        getViewModel().setRandom(intent.getBooleanExtra(CallActivity.IS_RANDOM, false));
        getViewModel().setFreeCall(intent.getBooleanExtra(CallActivity.IS_FREE_CALL, false));
        getViewModel().setGoddessCall(intent.getBooleanExtra(CallActivity.IS_GOODESS_CALL, false));
        getViewModel().setBotVideo(intent.getBooleanExtra(CallActivity.IS_BOT_VIDEO, false));
        getViewModel().setAudioCall(intent.getBooleanExtra(Constants.KEY_CALL_TYPE, false));
        if (getViewModel().getIsBot() || getViewModel().getIsBotVideo()) {
            AppCompatImageView appCompatImageView = getBinding().hangUpBtn;
            if (appCompatImageView != null) {
                appCompatImageView.setVisibility(0);
            }
            BuildersKt.launch$default(this.botScope, (CoroutineContext) null, (CoroutineStart) null, new BotCallActivity$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()) {
                return null;
            }
            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;
        }
    }

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

    private final void onClicks() {
        getBinding().swipeCallPicker.setOnSlideCompleteListener(new SlideToActView.OnSlideCompleteListener() {
            public void onSlideComplete(SlideToActView view) {
                CallViewModel viewModel;
                CoroutineScope coroutineScope;
                CallViewModel viewModel2;
                Intrinsics.checkNotNullParameter(view, "view");
                viewModel = BotCallActivity.this.getViewModel();
                if (viewModel.getIsBot()) {
                    BotCallActivity.this.stopRinging();
                    coroutineScope = BotCallActivity.this.botScope;
                    CoroutineScopeKt.cancel$default(coroutineScope, (CancellationException) null, 1, (Object) null);
                    BotCallActivity botCallActivity = BotCallActivity.this;
                    viewModel2 = botCallActivity.getViewModel();
                    botCallActivity.showRechargePopup(viewModel2.getVideoDetails());
                }
            }
        });
        getBinding().acceptCallBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                BotCallActivity.onClicks$lambda$4(BotCallActivity.this, view);
            }
        });
        getBinding().hangUpBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                BotCallActivity.onClicks$lambda$5(BotCallActivity.this, view);
            }
        });
    }

    public static final void onClicks$lambda$4(BotCallActivity botCallActivity, View view) {
        Intrinsics.checkNotNullParameter(botCallActivity, "this$0");
        if (botCallActivity.getViewModel().getIsBot()) {
            botCallActivity.stopRinging();
            CoroutineScopeKt.cancel$default(botCallActivity.botScope, (CancellationException) null, 1, (Object) null);
            botCallActivity.showRechargePopup(botCallActivity.getViewModel().getVideoDetails());
        } else if (botCallActivity.getViewModel().getIsBotVideo()) {
            botCallActivity.stopRinging();
            CoroutineScopeKt.cancel$default(botCallActivity.botScope, (CancellationException) null, 1, (Object) null);
            Intent intent = new Intent(botCallActivity.getApplicationContext(), (Class<?>) FakeVideoCallActivity.class);
            intent.putExtra(Constants.KEY_CALLING_VIDEO_ID, botCallActivity.videoId);
            intent.putExtra(Constants.FCM_DATA, new Gson().toJson(botCallActivity.getViewModel().getVideoDetails()));
            botCallActivity.startActivity(intent);
            botCallActivity.finish();
        }
    }

    public static final void onClicks$lambda$5(BotCallActivity botCallActivity, View view) {
        Intrinsics.checkNotNullParameter(botCallActivity, "this$0");
        if (botCallActivity.getViewModel().getIsBot()) {
            if (botCallActivity.isTaskRoot()) {
                botCallActivity.closeScreen();
                return;
            } else {
                botCallActivity.finish();
                return;
            }
        }
        if (botCallActivity.isCaller()) {
            if (botCallActivity.videoId != -1) {
                botCallActivity.getViewModel().cancelVideoCall(botCallActivity.videoId);
                return;
            } else if (botCallActivity.isTaskRoot()) {
                botCallActivity.closeScreen();
                return;
            } else {
                botCallActivity.finish();
                return;
            }
        }
        if (botCallActivity.isCallee()) {
            if (botCallActivity.videoId != -1) {
                botCallActivity.getViewModel().rejectVideoCall(botCallActivity.videoId);
            } else if (botCallActivity.isTaskRoot()) {
                botCallActivity.closeScreen();
            } else {
                botCallActivity.finish();
            }
        }
    }

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

    public final void closeScreen() {
        getIntent().putExtra(CallActivity.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
    public void onStart() {
        super.onStart();
    }

    @Override
    public void onStop() {
        super.onStop();
    }

    @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 (isFinishing()) {
            stopRinging();
        }
    }

    public final void showRechargePopup(VideoDetailModel data) {
        try {
            if (!(getIntent().getDoubleExtra(CallActivity.RATE, -1.0d) == -1.0d) && data != null) {
                data.setRate(getIntent().getDoubleExtra(CallActivity.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() {
                    m875invoke();
                    return Unit.INSTANCE;
                }

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

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

                public final void m876invoke() {
                    if (BotCallActivity.this.isTaskRoot()) {
                        BotCallActivity.this.closeScreen();
                    } else {
                        BotCallActivity.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);
        }
    }
}