导航菜单

页面标题

页面副标题

Rilo v2.0.21 - OnboardActivity.java 源代码

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

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


package app.callpe.ui.onboarding;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.widget.Toast;
import androidx.activity.ComponentActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.ViewModelLazy;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelStore;
import androidx.lifecycle.viewmodel.CreationExtras;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager2.adapter.FragmentStateAdapter;
import androidx.viewpager2.widget.ViewPager2;
import app.callpe.common.utils.helper_functions.LocationUtils;
import app.callpe.common.utils.sharedpref.PrefKeys;
import app.callpe.common.utils.sharedpref.SharedPref;
import app.callpe.data.model.OnboardModel;
import app.callpe.data.model.User;
import app.callpe.databinding.ActivityOnboardingBinding;
import app.callpe.ui.home.BaseActivity;
import app.callpe.ui.onboarding.OnboardActivity;
import app.callpe.ui.onboarding.fragments.AddInterestFragment;
import app.callpe.ui.onboarding.fragments.AddLanguageFragment;
import app.callpe.ui.onboarding.fragments.AgeProofFragment;
import app.callpe.ui.onboarding.fragments.BirthdayFragment;
import app.callpe.ui.onboarding.fragments.GenderSelectorFragment;
import app.callpe.ui.onboarding.fragments.IntroVideoFragment;
import app.callpe.ui.onboarding.fragments.NickNameAvatarFragment;
import app.callpe.ui.onboarding.fragments.ProfilePicFragment;
import app.callpe.ui.onboarding.fragments.ReferralFragment;
import app.callpe.ui.onboarding.fragments.SelfieFragment;
import app.callpe.ui.user.UserViewModel;
import com.facebook.internal.NativeProtocol;
import com.facebook.internal.Utility;
import com.google.gson.Gson;
import dagger.hilt.android.AndroidEntryPoint;
import kotlin.Lazy;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Reflection;
import timber.log.Timber;

@Metadata(d1 = {"\u0000`\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0011\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\u0015\n\u0002\b\u0005\b\u0007\u0018\u00002\b\u0012\u0004\u0012\u00020\u00020\u0001:\u0001-B\u0005¢\u0006\u0002\u0010\u0003J\b\u0010\u0012\u001a\u00020\u0013H\u0002J\b\u0010\u0014\u001a\u00020\u0013H\u0002J\b\u0010\u0015\u001a\u00020\u0013H\u0002J\b\u0010\u0016\u001a\u00020\u0013H\u0002J\u0010\u0010\u0017\u001a\u00020\u00022\u0006\u0010\u0018\u001a\u00020\u0019H\u0016J\"\u0010\u001a\u001a\u00020\u00132\u0006\u0010\u001b\u001a\u00020\u001c2\u0006\u0010\u001d\u001a\u00020\u001c2\b\u0010\u001e\u001a\u0004\u0018\u00010\u001fH\u0014J\b\u0010 \u001a\u00020\u0013H\u0016J\u0012\u0010!\u001a\u00020\u00132\b\u0010\"\u001a\u0004\u0018\u00010#H\u0014J+\u0010$\u001a\u00020\u00132\u0006\u0010\u001b\u001a\u00020\u001c2\f\u0010%\u001a\b\u0012\u0004\u0012\u00020'0&2\u0006\u0010(\u001a\u00020)H\u0016¢\u0006\u0002\u0010*J\b\u0010+\u001a\u00020\u0013H\u0014J\b\u0010,\u001a\u00020\u0013H\u0002R\u0012\u0010\u0004\u001a\u00060\u0005R\u00020\u0000X\u0082.¢\u0006\u0002\n\u0000R\u001b\u0010\u0006\u001a\u00020\u00078BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\n\u0010\u000b\u001a\u0004\b\b\u0010\tR\u001c\u0010\f\u001a\u0004\u0018\u00010\rX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u000e\u0010\u000f\"\u0004\b\u0010\u0010\u0011¨\u0006."}, d2 = {"Lapp/callpe/ui/onboarding/OnboardActivity;", "Lapp/callpe/ui/home/BaseActivity;", "Lapp/callpe/databinding/ActivityOnboardingBinding;", "()V", "mViewPagerAdapter", "Lapp/callpe/ui/onboarding/OnboardActivity$ViewPager2Adapter;", "viewModel", "Lapp/callpe/ui/user/UserViewModel;", "getViewModel", "()Lapp/callpe/ui/user/UserViewModel;", "viewModel$delegate", "Lkotlin/Lazy;", "viewPager", "Landroidx/viewpager2/widget/ViewPager2;", "getViewPager", "()Landroidx/viewpager2/widget/ViewPager2;", "setViewPager", "(Landroidx/viewpager2/widget/ViewPager2;)V", "askLocationPermission", "", "checkLocationPermission", "fetchLocation", "getIntentValues", "inflateLayout", "layoutInflater", "Landroid/view/LayoutInflater;", "onActivityResult", "requestCode", "", "resultCode", "data", "Landroid/content/Intent;", "onBackPressed", "onCreate", "savedInstanceState", "Landroid/os/Bundle;", "onRequestPermissionsResult", NativeProtocol.RESULT_ARGS_PERMISSIONS, "", "", "grantResults", "", "(I[Ljava/lang/String;[I)V", "onResume", "setUpNavigation", "ViewPager2Adapter", "app_riloRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
@AndroidEntryPoint
public final class OnboardActivity extends BaseActivity<ActivityOnboardingBinding> {
    private ViewPager2Adapter mViewPagerAdapter;

    private final Lazy viewModel;
    private ViewPager2 viewPager;

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

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

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

            public final CreationExtras m2052invoke() {
                CreationExtras creationExtras;
                Function0 function02 = function0;
                return (function02 == null || (creationExtras = (CreationExtras) function02.invoke()) == null) ? componentActivity.getDefaultViewModelCreationExtras() : creationExtras;
            }
        });
    }

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

    public final ViewPager2 getViewPager() {
        return this.viewPager;
    }

    public final void setViewPager(ViewPager2 viewPager2) {
        this.viewPager = viewPager2;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setWindowFlag((Activity) this, 67108864, false);
        getWindow().getDecorView().setSystemUiVisibility(Utility.DEFAULT_STREAM_BUFFER_SIZE);
        getWindow().setStatusBarColor(ContextCompat.getColor((Context) this, 2131101146));
        getIntentValues();
        setUpNavigation();
        askLocationPermission();
    }

    private final void getIntentValues() {
        String str;
        String stringExtra = getIntent().getStringExtra("user");
        String str2 = stringExtra;
        if (!(str2 == null || str2.length() == 0)) {
            User user = (User) new Gson().fromJson(stringExtra, User.class);
            UserViewModel viewModel = getViewModel();
            if (user == null || (str = user.getCountryCode()) == null) {
                str = "IN";
            }
            viewModel.setCountryCode(str);
            OnboardModel onboardModel = null;
            Context context = (Context) this;
            String string = SharedPref.getString(context, PrefKeys.ON_BOARD);
            if (!(string == null || string.length() == 0)) {
                String string2 = SharedPref.getString(context, PrefKeys.ON_BOARD);
                OnboardModel onboardModel2 = (OnboardModel) new Gson().fromJson(string2, OnboardModel.class);
                Timber.e("onboard " + string2, new Object[0]);
                onboardModel = onboardModel2;
            }
            if (user != null) {
                getViewModel().getOnBoardModel().fillValues(user, onboardModel);
                getViewModel().setAvatar(user.getAvatar());
                getViewModel().setUser(user);
                getViewModel().setRejected(user.getStreamerStatus() != null && Intrinsics.areEqual(user.getStreamerStatus(), "REJECTED"));
            }
        }
        if (getIntent().getBooleanExtra("streamerScreen", false)) {
            getViewModel().setBecomeStreamer(true);
        }
    }

    private final void setUpNavigation() {
        this.viewPager = getBinding().viewPager;
        FragmentManager supportFragmentManager = getSupportFragmentManager();
        Intrinsics.checkNotNullExpressionValue(supportFragmentManager, "supportFragmentManager");
        Lifecycle lifecycle = getLifecycle();
        Intrinsics.checkNotNullExpressionValue(lifecycle, "lifecycle");
        RecyclerView.Adapter viewPager2Adapter = new ViewPager2Adapter(this, supportFragmentManager, lifecycle);
        this.mViewPagerAdapter = viewPager2Adapter;
        ViewPager2 viewPager2 = this.viewPager;
        if (viewPager2 != null) {
            viewPager2.setAdapter(viewPager2Adapter);
        }
        ViewPager2 viewPager22 = this.viewPager;
        if (viewPager22 != null) {
            viewPager22.setUserInputEnabled(false);
        }
        ViewPager2 viewPager23 = this.viewPager;
        if (viewPager23 != null) {
            viewPager23.setOffscreenPageLimit(12);
        }
        ViewPager2 viewPager24 = this.viewPager;
        if (viewPager24 != null) {
            viewPager24.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
                public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
                }

                public void onPageSelected(int position) {
                    OnboardActivity.ViewPager2Adapter viewPager2Adapter2;
                    ActivityOnboardingBinding binding;
                    viewPager2Adapter2 = OnboardActivity.this.mViewPagerAdapter;
                    if (viewPager2Adapter2 == null) {
                        Intrinsics.throwUninitializedPropertyAccessException("mViewPagerAdapter");
                        viewPager2Adapter2 = null;
                    }
                    float itemCount = ((position + 1) / viewPager2Adapter2.getItemCount()) * 100;
                    binding = OnboardActivity.this.getBinding();
                    binding.simpleProgressBar.setProgress((int) itemCount);
                }
            });
        }
    }

    @Metadata(d1 = {"\u0000&\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0004\b\u0086\u0004\u0018\u00002\u00020\u0001B\u0015\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0005¢\u0006\u0002\u0010\u0006J\u0010\u0010\u0007\u001a\u00020\b2\u0006\u0010\t\u001a\u00020\nH\u0016J\u000e\u0010\u000b\u001a\u00020\b2\u0006\u0010\f\u001a\u00020\nJ\b\u0010\r\u001a\u00020\nH\u0016R\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\u000e"}, d2 = {"Lapp/callpe/ui/onboarding/OnboardActivity$ViewPager2Adapter;", "Landroidx/viewpager2/adapter/FragmentStateAdapter;", "fm", "Landroidx/fragment/app/FragmentManager;", "lifecycle", "Landroidx/lifecycle/Lifecycle;", "(Lapp/callpe/ui/onboarding/OnboardActivity;Landroidx/fragment/app/FragmentManager;Landroidx/lifecycle/Lifecycle;)V", "createFragment", "Landroidx/fragment/app/Fragment;", "position", "", "getItem", "currentItem", "getItemCount", "app_riloRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
    public final class ViewPager2Adapter extends FragmentStateAdapter {
        private final FragmentManager fm;
        final OnboardActivity this$0;

        public ViewPager2Adapter(OnboardActivity onboardActivity, FragmentManager fragmentManager, Lifecycle lifecycle) {
            super(fragmentManager, lifecycle);
            Intrinsics.checkNotNullParameter(fragmentManager, "fm");
            Intrinsics.checkNotNullParameter(lifecycle, "lifecycle");
            this.this$0 = onboardActivity;
            this.fm = fragmentManager;
        }

        public Fragment createFragment(int position) {
            if (!BaseActivity.isUser) {
                if (!this.this$0.getViewModel().getBecomeStreamer()) {
                    if (this.this$0.getViewModel().getIsRejected()) {
                        switch (position) {
                            case 0:
                                return new BirthdayFragment();
                            case 1:
                                return new GenderSelectorFragment();
                            case 2:
                                return new NickNameAvatarFragment();
                            case 3:
                                return new AddInterestFragment();
                            case 4:
                                return new AddLanguageFragment();
                            case 5:
                                return new ReferralFragment();
                            case 6:
                                return new AgeProofFragment();
                            case 7:
                                return new ProfilePicFragment();
                            case 8:
                                return new SelfieFragment();
                            case 9:
                                return new IntroVideoFragment();
                        }
                    }
                    switch (position) {
                        case 0:
                            return new BirthdayFragment();
                        case 1:
                            return new GenderSelectorFragment();
                        case 2:
                            return new NickNameAvatarFragment();
                        case 3:
                            return new AddInterestFragment();
                        case 4:
                            return new AddLanguageFragment();
                        case 5:
                            return new ReferralFragment();
                        case 6:
                            return new AgeProofFragment();
                        case 7:
                            return new ProfilePicFragment();
                        case 8:
                            return new SelfieFragment();
                        case 9:
                            return new IntroVideoFragment();
                    }
                }
                switch (position) {
                    case 0:
                        return new BirthdayFragment();
                    case 1:
                        return new GenderSelectorFragment();
                    case 2:
                        return new NickNameAvatarFragment();
                    case 3:
                        return new AddInterestFragment();
                    case 4:
                        return new AddLanguageFragment();
                    case 5:
                        return new ReferralFragment();
                    case 6:
                        return new ProfilePicFragment();
                    case 7:
                        return new SelfieFragment();
                    case 8:
                        return new IntroVideoFragment();
                }
            }
            if (position == 0) {
                return new BirthdayFragment();
            }
            if (position == 1) {
                return new NickNameAvatarFragment();
            }
            if (position == 2) {
                return new AddLanguageFragment();
            }
            return new GenderSelectorFragment();
        }

        public int getItemCount() {
            return BaseActivity.isUser ? 3 : 9;
        }

        public final Fragment getItem(int currentItem) {
            Object obj = this.fm.getFragments().get(currentItem);
            Intrinsics.checkNotNull(obj, "null cannot be cast to non-null type androidx.fragment.app.Fragment");
            return (Fragment) obj;
        }
    }

    public void onBackPressed() {
        int currentItem = getBinding().viewPager.getCurrentItem();
        if (currentItem == 0) {
            super.onBackPressed();
        } else {
            getBinding().viewPager.setCurrentItem(currentItem - 1);
        }
    }

    @Override
    public ActivityOnboardingBinding inflateLayout(LayoutInflater layoutInflater) {
        Intrinsics.checkNotNullParameter(layoutInflater, "layoutInflater");
        ActivityOnboardingBinding inflate = ActivityOnboardingBinding.inflate(layoutInflater);
        Intrinsics.checkNotNullExpressionValue(inflate, "inflate(layoutInflater)");
        return inflate;
    }

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        Activity activity = (Activity) this;
        LocationUtils.handleActivityResult$default(LocationUtils.INSTANCE, activity, requestCode, resultCode, data, false, new Function0<Unit>() {
            {
                super(0);
            }

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

            public final void m2054invoke() {
                OnboardActivity.this.fetchLocation();
            }
        }, 16, null);
        if (requestCode == 100132) {
            if (LocationUtils.INSTANCE.isGpsEnabled((Context) this)) {
                fetchLocation();
            } else {
                Timber.d("XXXXXX_TEST: GPS still disabled after returning", new Object[0]);
                LocationUtils.showGpsManualEnableDialog$default(LocationUtils.INSTANCE, activity, false, 2, null);
            }
        }
    }

    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        Intrinsics.checkNotNullParameter(permissions, NativeProtocol.RESULT_ARGS_PERMISSIONS);
        Intrinsics.checkNotNullParameter(grantResults, "grantResults");
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        boolean z = false;
        Timber.e("requestCode == " + requestCode, new Object[0]);
        if (requestCode == 100123) {
            if (!(grantResults.length == 0)) {
                int length = grantResults.length;
                int i = 0;
                while (true) {
                    if (i >= length) {
                        z = true;
                        break;
                    } else {
                        if (!(grantResults[i] == 0)) {
                            break;
                        } else {
                            i++;
                        }
                    }
                }
                if (z) {
                    fetchLocation();
                }
            }
        }
    }

    public final void fetchLocation() {
        LocationUtils.INSTANCE.getStreamerState((Context) this, new Function1<String, Unit>() {
            {
                super(1);
            }

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

            public final void invoke(String str) {
                Timber.d("Received state: " + str, new Object[0]);
                OnboardActivity.this.getViewModel().setStreamerState(str);
            }
        });
    }

    private final void checkLocationPermission() {
        Context context = (Context) this;
        if (LocationUtils.INSTANCE.isGpsEnabled(context) && LocationUtils.INSTANCE.getGpsPermissionAsked()) {
            boolean z = ActivityCompat.checkSelfPermission(context, "android.permission.ACCESS_FINE_LOCATION") == 0;
            boolean z2 = ActivityCompat.checkSelfPermission(context, "android.permission.ACCESS_COARSE_LOCATION") == 0;
            if (z || z2) {
                fetchLocation();
            } else {
                Toast.makeText(context, "Location permission needed!", 1).show();
                LocationUtils.INSTANCE.showLocationPermissionDialog(context);
            }
        }
    }

    private final void askLocationPermission() {
        LocationUtils.INSTANCE.showPermissionRationaleDialog(true, (Activity) this, new Function0<Unit>() {
            {
                super(0);
            }

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

            public final void m2053invoke() {
                OnboardActivity.this.fetchLocation();
            }
        });
    }

    protected void onResume() {
        super.onResume();
        checkLocationPermission();
    }
}