导航菜单

页面标题

页面副标题

Biko v2.0.23 - UserLevelDetailsActivity.java 源代码

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

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


package app.callpe.ui.user;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.LinearLayout;
import androidx.activity.ComponentActivity;
import androidx.activity.result.ActivityResult;
import androidx.activity.result.ActivityResultCallback;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContract;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.appcompat.app.ActionBar;
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 app.callpe.adapters.UserLevelDetailsAdapter;
import app.callpe.common.utils.custom.CustomLinearLayoutManager;
import app.callpe.common.utils.extensions.NumberExtKt;
import app.callpe.data.model.LevelDetails;
import app.callpe.data.model.User;
import app.callpe.databinding.ActivityUserLevelDetailsBinding;
import app.callpe.ui.home.BaseActivity;
import dagger.hilt.android.AndroidEntryPoint;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import kotlin.Lazy;
import kotlin.Metadata;
import kotlin.collections.CollectionsKt;
import kotlin.comparisons.ComparisonsKt;
import kotlin.coroutines.CoroutineContext;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Reflection;
import kotlinx.coroutines.BuildersKt;
import kotlinx.coroutines.CoroutineStart;
import kotlinx.coroutines.Job;
import timber.log.Timber;

@Metadata(d1 = {"\u0000h\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\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\b\u0007\u0018\u00002\b\u0012\u0004\u0012\u00020\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0003J\u0010\u0010\u0010\u001a\u00020\u00022\u0006\u0010\u0011\u001a\u00020\u0012H\u0016J\b\u0010\u0013\u001a\u00020\u0014H\u0003J\b\u0010\u0015\u001a\u00020\u0016H\u0002J\u0012\u0010\u0017\u001a\u00020\u00162\b\u0010\u0018\u001a\u0004\u0018\u00010\u0019H\u0014J\u0010\u0010\u001a\u001a\u00020\u001b2\u0006\u0010\u001c\u001a\u00020\u001dH\u0016J\b\u0010\u001e\u001a\u00020\u0016H\u0002J \u0010\u001f\u001a\u00020\u00162\u0016\u0010 \u001a\u0012\u0012\u0004\u0012\u00020\"0!j\b\u0012\u0004\u0012\u00020\"`#H\u0002J\b\u0010$\u001a\u00020\u0016H\u0002J\u0010\u0010%\u001a\u00020\u00162\u0006\u0010&\u001a\u00020'H\u0002R\u0010\u0010\u0004\u001a\u0004\u0018\u00010\u0005X\u0082\u000e¢\u0006\u0002\n\u0000R\u001c\u0010\u0006\u001a\u0010\u0012\f\u0012\n \t*\u0004\u0018\u00010\b0\b0\u0007X\u0082\u0004¢\u0006\u0002\n\u0000R\u001b\u0010\n\u001a\u00020\u000b8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\u000e\u0010\u000f\u001a\u0004\b\f\u0010\r¨\u0006("}, d2 = {"Lapp/callpe/ui/user/UserLevelDetailsActivity;", "Lapp/callpe/ui/home/BaseActivity;", "Lapp/callpe/databinding/ActivityUserLevelDetailsBinding;", "()V", "adapter", "Lapp/callpe/adapters/UserLevelDetailsAdapter;", "startWalletActivityLauncher", "Landroidx/activity/result/ActivityResultLauncher;", "Landroid/content/Intent;", "kotlin.jvm.PlatformType", "viewModel", "Lapp/callpe/ui/user/UserViewModel;", "getViewModel", "()Lapp/callpe/ui/user/UserViewModel;", "viewModel$delegate", "Lkotlin/Lazy;", "inflateLayout", "layoutInflater", "Landroid/view/LayoutInflater;", "observeEvent", "Lkotlinx/coroutines/Job;", "onClicks", "", "onCreate", "savedInstanceState", "Landroid/os/Bundle;", "onOptionsItemSelected", "", "item", "Landroid/view/MenuItem;", "setRv", "setUpLevel", "level", "Ljava/util/ArrayList;", "Lapp/callpe/data/model/LevelDetails;", "Lkotlin/collections/ArrayList;", "setUpToolbar", "setValues", "user", "Lapp/callpe/data/model/User;", "app_bikoRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
@AndroidEntryPoint
public final class UserLevelDetailsActivity extends BaseActivity<ActivityUserLevelDetailsBinding> {
    private UserLevelDetailsAdapter adapter;
    private final ActivityResultLauncher<Intent> startWalletActivityLauncher;

    private final Lazy viewModel;

    private final void onClicks() {
    }

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

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

            public final CreationExtras m2308invoke() {
                CreationExtras creationExtras;
                Function0 function02 = function0;
                return (function02 == null || (creationExtras = (CreationExtras) function02.invoke()) == null) ? componentActivity.getDefaultViewModelCreationExtras() : creationExtras;
            }
        });
        ActivityResultLauncher<Intent> registerForActivityResult = registerForActivityResult((ActivityResultContract) new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback() {
            public final void onActivityResult(Object obj) {
                UserLevelDetailsActivity.startWalletActivityLauncher$lambda$0(UserLevelDetailsActivity.this, (ActivityResult) obj);
            }
        });
        Intrinsics.checkNotNullExpressionValue(registerForActivityResult, "registerForActivityResul…etUserDetails(true)\n    }");
        this.startWalletActivityLauncher = registerForActivityResult;
    }

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

    public static final void startWalletActivityLauncher$lambda$0(UserLevelDetailsActivity userLevelDetailsActivity, ActivityResult activityResult) {
        Intrinsics.checkNotNullParameter(userLevelDetailsActivity, "this$0");
        userLevelDetailsActivity.getViewModel().getUserDetails(true);
    }

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

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView((View) getBinding().getRoot());
        setUpToolbar();
        getViewModel().getUserDetails(true);
        observeEvent();
        setRv();
        onClicks();
    }

    private final void setRv() {
        ((ActivityUserLevelDetailsBinding) getBinding()).rv.setLayoutManager(new CustomLinearLayoutManager((Context) this));
        this.adapter = new UserLevelDetailsAdapter(new ArrayList());
        ((ActivityUserLevelDetailsBinding) getBinding()).rv.setAdapter(this.adapter);
    }

    private final void setUpToolbar() {
        try {
            setSupportActionBar(getBinding().toolbar);
            ActionBar supportActionBar = getSupportActionBar();
            if (supportActionBar != null) {
                supportActionBar.setDisplayHomeAsUpEnabled(true);
            }
        } catch (Exception e) {
            Timber.e(e, "setUpToolbar: Error ", new Object[0]);
        }
    }

    public final void setValues(User user) {
        String str = "Total Recharge Amount: ₹" + Long.valueOf(user.getTotalRechargeAmount());
        StringBuilder sb = new StringBuilder();
        sb.append("Level ");
        String levelName = user.getLevelName();
        if (levelName == null) {
            levelName = "0";
        }
        sb.append(levelName);
        String sb2 = sb.toString();
        getBinding().totalRechargeAmount.setText(str);
        getBinding().level.setText(sb2);
        String levelName2 = user.getLevelName();
        if (levelName2 == null || levelName2.length() == 0) {
            getBinding().level.setVisibility(8);
        }
    }

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

    public final void setUpLevel(ArrayList<LevelDetails> level) {
        String name;
        User user = getViewModel().getUser();
        if (user != null) {
            try {
                String levelName = user.getLevelName();
                if (levelName != null) {
                    int parseInt = Integer.parseInt(levelName);
                    List<LevelDetails> sortedWith = CollectionsKt.sortedWith(level, new Comparator() {
                        @Override
                        public final int compare(T t, T t2) {
                            return ComparisonsKt.compareValues(Integer.valueOf(Integer.parseInt(((LevelDetails) t).getName())), Integer.valueOf(Integer.parseInt(((LevelDetails) t2).getName())));
                        }
                    });
                    LevelDetails levelDetails = (LevelDetails) CollectionsKt.lastOrNull(sortedWith);
                    if ((levelDetails == null || (name = levelDetails.getName()) == null || parseInt != Integer.parseInt(name)) ? false : true) {
                        View view = getBinding().maxLevelBox;
                        Intrinsics.checkNotNullExpressionValue(view, "binding.maxLevelBox");
                        view.setVisibility(0);
                        LinearLayout linearLayout = getBinding().levelListTitle;
                        Intrinsics.checkNotNullExpressionValue(linearLayout, "binding.levelListTitle");
                        linearLayout.setVisibility(8);
                        View view2 = getBinding().rv;
                        Intrinsics.checkNotNullExpressionValue(view2, "binding.rv");
                        view2.setVisibility(8);
                        return;
                    }
                    View view3 = getBinding().maxLevelBox;
                    Intrinsics.checkNotNullExpressionValue(view3, "binding.maxLevelBox");
                    view3.setVisibility(8);
                    LinearLayout linearLayout2 = getBinding().levelListTitle;
                    Intrinsics.checkNotNullExpressionValue(linearLayout2, "binding.levelListTitle");
                    linearLayout2.setVisibility(0);
                    View view4 = getBinding().rv;
                    Intrinsics.checkNotNullExpressionValue(view4, "binding.rv");
                    view4.setVisibility(0);
                    UserLevelDetailsAdapter userLevelDetailsAdapter = this.adapter;
                    if (userLevelDetailsAdapter != null) {
                        userLevelDetailsAdapter.clear();
                    }
                    UserLevelDetailsAdapter userLevelDetailsAdapter2 = this.adapter;
                    if (userLevelDetailsAdapter2 != null) {
                        userLevelDetailsAdapter2.addItems(level);
                    }
                    for (LevelDetails levelDetails2 : sortedWith) {
                        if (Integer.parseInt(levelDetails2.getName()) > parseInt) {
                            Timber.d("Lvl name " + levelDetails2.getName() + " dp " + levelDetails2.getDeposit() + " amt " + user.getTotalRechargeAmount(), new Object[0]);
                            Integer deposit = levelDetails2.getDeposit();
                            getBinding().requiredRechargeTitle.setText("Recharge " + NumberExtKt.formatByNumberRupee$default((Number) Integer.valueOf((deposit != null ? deposit.intValue() : 0) - ((int) user.getTotalRechargeAmount())), false, 1, (Object) null) + " to reach next level.");
                            return;
                        }
                    }
                }
            } catch (Exception e) {
                Timber.e(e);
            }
        }
    }

    public boolean onOptionsItemSelected(MenuItem item) {
        Intrinsics.checkNotNullParameter(item, "item");
        if (item.getItemId() != 16908332) {
            return true;
        }
        finish();
        return true;
    }
}