导航菜单

页面标题

页面副标题

Biko v2.0.23 - MyFollowersActivity.java 源代码

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

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


package app.callpe.ui.user;

import android.app.Activity;
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 androidx.activity.ComponentActivity;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
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.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import app.callpe.adapters.MyFollowersAdapter;
import app.callpe.adapters.TopFanAdapter;
import app.callpe.common.utils.custom.CustomLinearLayoutManager;
import app.callpe.common.utils.listeners.PaginationListener;
import app.callpe.data.model.StreamerModel;
import app.callpe.databinding.ActivityMyFollowersBinding;
import app.callpe.ui.home.AccountViewModel;
import app.callpe.ui.home.BaseActivity;
import dagger.hilt.android.AndroidEntryPoint;
import kotlin.Lazy;
import kotlin.Metadata;
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 = {"\u0000b\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\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0007\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\u0010\u0010\u0014\u001a\u00020\u00022\u0006\u0010\u0015\u001a\u00020\u0016H\u0016J\b\u0010\u0017\u001a\u00020\u0018H\u0002J\b\u0010\u0019\u001a\u00020\u001aH\u0002J\b\u0010\u001b\u001a\u00020\u0018H\u0002J\u0012\u0010\u001c\u001a\u00020\u00182\b\u0010\u001d\u001a\u0004\u0018\u00010\u001eH\u0014J\b\u0010\u001f\u001a\u00020\u0018H\u0014J\u0010\u0010 \u001a\u00020!2\u0006\u0010\"\u001a\u00020#H\u0016J\b\u0010$\u001a\u00020\u0018H\u0002J\b\u0010%\u001a\u00020\u0018H\u0002J\b\u0010&\u001a\u00020\u0018H\u0002J\b\u0010'\u001a\u00020\u0018H\u0002J\b\u0010(\u001a\u00020\u0018H\u0002R\u0010\u0010\u0004\u001a\u0004\u0018\u00010\u0005X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u0006\u001a\u0004\u0018\u00010\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\b\u001a\u00020\tX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\u000bX\u0082.¢\u0006\u0002\n\u0000R\u001b\u0010\f\u001a\u00020\r8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\u0010\u0010\u0011\u001a\u0004\b\u000e\u0010\u000f¨\u0006*"}, d2 = {"Lapp/callpe/ui/user/MyFollowersActivity;", "Lapp/callpe/ui/home/BaseActivity;", "Lapp/callpe/databinding/ActivityMyFollowersBinding;", "()V", "adapter", "Lapp/callpe/adapters/MyFollowersAdapter;", "adapterTopFan", "Lapp/callpe/adapters/TopFanAdapter;", "currentTab", "Lapp/callpe/ui/user/MyFollowersActivity$CurrentTab;", "toolbar", "Landroidx/appcompat/widget/Toolbar;", "viewModel", "Lapp/callpe/ui/home/AccountViewModel;", "getViewModel", "()Lapp/callpe/ui/home/AccountViewModel;", "viewModel$delegate", "Lkotlin/Lazy;", "getContext", "Landroid/content/Context;", "inflateLayout", "layoutInflater", "Landroid/view/LayoutInflater;", "initViews", "", "observeEvent", "Lkotlinx/coroutines/Job;", "onClicks", "onCreate", "savedInstanceState", "Landroid/os/Bundle;", "onDestroy", "onOptionsItemSelected", "", "item", "Landroid/view/MenuItem;", "refresh", "setUpToolbar", "setupRv", "setupTopFanRv", "swipeRefresh", "CurrentTab", "app_bikoRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
@AndroidEntryPoint
public final class MyFollowersActivity extends BaseActivity<ActivityMyFollowersBinding> {
    private MyFollowersAdapter adapter;
    private TopFanAdapter adapterTopFan;
    private CurrentTab currentTab = CurrentTab.MY_FOLLOWERS;
    private Toolbar toolbar;

    private final Lazy viewModel;

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

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

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

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

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

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

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

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setWindowFlag((Activity) this, 67108864, false);
        getWindow().setStatusBarColor(ContextCompat.getColor((Context) this, 2131100053));
        initViews();
        setUpToolbar();
        setupRv();
        setupTopFanRv();
        swipeRefresh();
        observeEvent();
        onClicks();
        refresh();
    }

    private final void setupRv() {
        final RecyclerView.LayoutManager customLinearLayoutManager = new CustomLinearLayoutManager((Context) this);
        ((ActivityMyFollowersBinding) getBinding()).rvMyFollowers.setLayoutManager(customLinearLayoutManager);
        this.adapter = new MyFollowersAdapter(null, new MyFollowersAdapter.ItemClickListener() {
            @Override
            public void onItemClick(StreamerModel streamer) {
                Intrinsics.checkNotNullParameter(streamer, "streamer");
                MyFollowersActivity myFollowersActivity = MyFollowersActivity.this;
                Intent intent = new Intent((Context) MyFollowersActivity.this, (Class<?>) UserDetailsActivity.class);
                intent.putExtra("userId", streamer.getId());
                myFollowersActivity.startActivity(intent);
            }
        }, 1, null);
        ((ActivityMyFollowersBinding) getBinding()).rvMyFollowers.setAdapter(this.adapter);
        ((ActivityMyFollowersBinding) getBinding()).rvMyFollowers.addOnScrollListener(new PaginationListener(customLinearLayoutManager, this) {
            final MyFollowersActivity this$0;

            @Override
            public void isScrolled(int dx, int dy) {
            }

            {
                super(customLinearLayoutManager, 30);
                this.this$0 = this;
            }

            @Override
            protected void loadMoreItems() {
                AccountViewModel viewModel;
                AccountViewModel viewModel2;
                viewModel = this.this$0.getViewModel();
                viewModel.setLoadingMyFollower(true);
                viewModel2 = this.this$0.getViewModel();
                viewModel2.getMyFollowers();
            }

            @Override
            public boolean isLastPage() {
                AccountViewModel viewModel;
                viewModel = this.this$0.getViewModel();
                return viewModel.getIsLastMyFollowerPage();
            }

            @Override
            public boolean isLoading() {
                AccountViewModel viewModel;
                viewModel = this.this$0.getViewModel();
                return viewModel.getIsLoadingMyFollower();
            }
        });
    }

    private final void setupTopFanRv() {
        final RecyclerView.LayoutManager customLinearLayoutManager = new CustomLinearLayoutManager((Context) this);
        ((ActivityMyFollowersBinding) getBinding()).rvTopFans.setLayoutManager(customLinearLayoutManager);
        this.adapterTopFan = new TopFanAdapter(null, new TopFanAdapter.ItemClickListener() {
            @Override
            public void onItemClick(StreamerModel streamer) {
                Intrinsics.checkNotNullParameter(streamer, "streamer");
                MyFollowersActivity myFollowersActivity = MyFollowersActivity.this;
                Intent intent = new Intent((Context) MyFollowersActivity.this, (Class<?>) UserDetailsActivity.class);
                intent.putExtra("userId", streamer.getId());
                myFollowersActivity.startActivity(intent);
            }
        }, 1, null);
        ((ActivityMyFollowersBinding) getBinding()).rvTopFans.addOnScrollListener(new PaginationListener(customLinearLayoutManager, this) {
            final MyFollowersActivity this$0;

            @Override
            public void isScrolled(int dx, int dy) {
            }

            {
                super(customLinearLayoutManager, 30);
                this.this$0 = this;
            }

            @Override
            protected void loadMoreItems() {
                AccountViewModel viewModel;
                AccountViewModel viewModel2;
                viewModel = this.this$0.getViewModel();
                viewModel.setLoadingTopFan(true);
                viewModel2 = this.this$0.getViewModel();
                viewModel2.getTopFan();
            }

            @Override
            public boolean isLastPage() {
                AccountViewModel viewModel;
                viewModel = this.this$0.getViewModel();
                return viewModel.getIsLastTopFanPage();
            }

            @Override
            public boolean isLoading() {
                AccountViewModel viewModel;
                viewModel = this.this$0.getViewModel();
                return viewModel.getIsLoadingTopFan();
            }
        });
        ((ActivityMyFollowersBinding) getBinding()).rvTopFans.setAdapter(this.adapterTopFan);
    }

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

    private final void swipeRefresh() {
        getBinding().swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            public final void onRefresh() {
                MyFollowersActivity.swipeRefresh$lambda$0(MyFollowersActivity.this);
            }
        });
    }

    public static final void swipeRefresh$lambda$0(MyFollowersActivity myFollowersActivity) {
        Intrinsics.checkNotNullParameter(myFollowersActivity, "this$0");
        myFollowersActivity.getBinding().swipeRefresh.setRefreshing(false);
        myFollowersActivity.refresh();
    }

    private final void refresh() {
        if (this.currentTab == CurrentTab.MY_FOLLOWERS) {
            MyFollowersAdapter myFollowersAdapter = this.adapter;
            if (myFollowersAdapter != null) {
                myFollowersAdapter.clear();
            }
            getViewModel().setMyFollowerPage(0);
            getViewModel().setLastMyFollowerPage(false);
            getViewModel().getMyFollowers();
            return;
        }
        TopFanAdapter topFanAdapter = this.adapterTopFan;
        if (topFanAdapter != null) {
            topFanAdapter.clear();
        }
        getViewModel().setTopFanPage(0);
        getViewModel().setLastTopFanPage(false);
        getViewModel().getTopFan();
    }

    private final void onClicks() {
        getBinding().myFollowerBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                MyFollowersActivity.onClicks$lambda$1(MyFollowersActivity.this, view);
            }
        });
        getBinding().myTopFansBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                MyFollowersActivity.onClicks$lambda$2(MyFollowersActivity.this, view);
            }
        });
    }

    public static final void onClicks$lambda$1(MyFollowersActivity myFollowersActivity, View view) {
        Intrinsics.checkNotNullParameter(myFollowersActivity, "this$0");
        myFollowersActivity.getBinding().myFollowerBtn.setChecked(true);
        myFollowersActivity.getBinding().myTopFansBtn.setChecked(false);
        if (myFollowersActivity.currentTab == CurrentTab.MY_FOLLOWERS) {
            return;
        }
        View view2 = myFollowersActivity.getBinding().rvMyFollowers;
        Intrinsics.checkNotNullExpressionValue(view2, "binding.rvMyFollowers");
        view2.setVisibility(0);
        View view3 = myFollowersActivity.getBinding().rvTopFans;
        Intrinsics.checkNotNullExpressionValue(view3, "binding.rvTopFans");
        view3.setVisibility(8);
        myFollowersActivity.currentTab = CurrentTab.MY_FOLLOWERS;
        myFollowersActivity.refresh();
    }

    public static final void onClicks$lambda$2(MyFollowersActivity myFollowersActivity, View view) {
        Intrinsics.checkNotNullParameter(myFollowersActivity, "this$0");
        myFollowersActivity.getBinding().myFollowerBtn.setChecked(false);
        myFollowersActivity.getBinding().myTopFansBtn.setChecked(true);
        if (myFollowersActivity.currentTab == CurrentTab.TOP_FANS) {
            return;
        }
        View view2 = myFollowersActivity.getBinding().rvTopFans;
        Intrinsics.checkNotNullExpressionValue(view2, "binding.rvTopFans");
        view2.setVisibility(0);
        View view3 = myFollowersActivity.getBinding().rvMyFollowers;
        Intrinsics.checkNotNullExpressionValue(view3, "binding.rvMyFollowers");
        view3.setVisibility(8);
        myFollowersActivity.currentTab = CurrentTab.TOP_FANS;
        myFollowersActivity.refresh();
    }

    private final void initViews() {
        Toolbar toolbar = getBinding().toolbar;
        Intrinsics.checkNotNullExpressionValue(toolbar, "binding.toolbar");
        this.toolbar = toolbar;
    }

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

    private final Context getContext() {
        return (Context) this;
    }

    protected void onDestroy() {
        super.onDestroy();
    }

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