导航菜单

页面标题

页面副标题

Biko v2.0.23 - MediaSliderActivity.java 源代码

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

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


package app.callpe.common.utils.custom.mediaslider;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
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 androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.PagerSnapHelper;
import androidx.recyclerview.widget.RecyclerView;
import app.callpe.adapters.GalleryAdapter;
import app.callpe.common.utils.Constants;
import app.callpe.common.utils.custom.CustomLinearLayoutManager;
import app.callpe.common.utils.custom.GalleryRecyclerView;
import app.callpe.common.utils.helper_functions.DialogHelper;
import app.callpe.common.utils.listeners.PaginationListener;
import app.callpe.data.model.MediaFile;
import app.callpe.databinding.ActivitySliderBinding;
import app.callpe.ui.home.BaseActivity;
import app.callpe.ui.home.ImageVideoUploadActivity;
import app.callpe.ui.login.LoginActivity;
import app.callpe.ui.user.UserViewModel;
import dagger.hilt.android.AndroidEntryPoint;
import java.util.ArrayList;
import java.util.Objects;
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 timber.log.Timber;

@Metadata(d1 = {"\u0000f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\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\u0007\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\b\b\u0007\u0018\u0000 32\b\u0012\u0004\u0012\u00020\u00020\u0001:\u00013B\u0005¢\u0006\u0002\u0010\u0003J\u0010\u0010\u001c\u001a\u00020\u00022\u0006\u0010\u001d\u001a\u00020\u001eH\u0016J\b\u0010\u001f\u001a\u00020 H\u0002J\b\u0010!\u001a\u00020 H\u0002J\b\u0010\"\u001a\u00020 H\u0002J\u0012\u0010#\u001a\u00020 2\b\u0010$\u001a\u0004\u0018\u00010%H\u0015J\u0012\u0010&\u001a\u00020\u00072\b\u0010'\u001a\u0004\u0018\u00010(H\u0016J\b\u0010)\u001a\u00020 H\u0014J\u0010\u0010*\u001a\u00020\u00072\u0006\u0010+\u001a\u00020,H\u0016J\b\u0010-\u001a\u00020 H\u0014J\b\u0010.\u001a\u00020 H\u0014J\u0012\u0010/\u001a\u00020 2\b\b\u0002\u00100\u001a\u00020\u0007H\u0002J\b\u00101\u001a\u00020 H\u0002J\b\u00102\u001a\u00020 H\u0002R\u0010\u0010\u0004\u001a\u0004\u0018\u00010\u0005X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R \u0010\b\u001a\b\u0012\u0004\u0012\u00020\n0\tX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u000b\u0010\f\"\u0004\b\r\u0010\u000eR\u0010\u0010\u000f\u001a\u0004\u0018\u00010\u0010X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0011\u001a\u00020\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0012\u001a\u00020\u0013X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0014\u001a\u00020\u0013X\u0082\u000e¢\u0006\u0002\n\u0000R\u001b\u0010\u0015\u001a\u00020\u00168BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\u0019\u0010\u001a\u001a\u0004\b\u0017\u0010\u0018R\u000e\u0010\u001b\u001a\u00020\u0013X\u0082\u000e¢\u0006\u0002\n\u0000¨\u00064"}, d2 = {"Lapp/callpe/common/utils/custom/mediaslider/MediaSliderActivity;", "Lapp/callpe/ui/home/BaseActivity;", "Lapp/callpe/databinding/ActivitySliderBinding;", "()V", "adapter", "Lapp/callpe/adapters/GalleryAdapter;", "firstRechargeDone", "", "launcher", "Landroidx/activity/result/ActivityResultLauncher;", "Landroid/content/Intent;", "getLauncher", "()Landroidx/activity/result/ActivityResultLauncher;", "setLauncher", "(Landroidx/activity/result/ActivityResultLauncher;)V", "rv", "Lapp/callpe/common/utils/custom/GalleryRecyclerView;", "showDelete", "startPosition", "", "unlockedPicsCount", "viewModel", "Lapp/callpe/ui/user/UserViewModel;", "getViewModel", "()Lapp/callpe/ui/user/UserViewModel;", "viewModel$delegate", "Lkotlin/Lazy;", "visibleItemPosition", "inflateLayout", "layoutInflater", "Landroid/view/LayoutInflater;", "loadMediaSliderView", "", "observeEvent", "onClick", "onCreate", "savedInstanceState", "Landroid/os/Bundle;", "onCreateOptionsMenu", "menu", "Landroid/view/Menu;", "onDestroy", "onOptionsItemSelected", "item", "Landroid/view/MenuItem;", "onPause", "onResume", "refresh", "forceRefresh", "setAdapter", "setUpToolbar", "Companion", "app_bikoRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
@AndroidEntryPoint
public final class MediaSliderActivity extends BaseActivity<ActivitySliderBinding> {
    public static final int PAGE_SIZE = 5;
    private GalleryAdapter adapter;
    private boolean firstRechargeDone;
    private ActivityResultLauncher<Intent> launcher;
    private GalleryRecyclerView rv;
    private boolean showDelete;

    private final Lazy viewModel;
    private int startPosition = -1;
    private int visibleItemPosition = -1;
    private int unlockedPicsCount = -1;

    public boolean onCreateOptionsMenu(Menu menu) {
        return true;
    }

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

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

            public final CreationExtras m248invoke() {
                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) {
                MediaSliderActivity.launcher$lambda$0(MediaSliderActivity.this, (ActivityResult) obj);
            }
        });
        Intrinsics.checkNotNullExpressionValue(registerForActivityResult, "registerForActivityResul…h = true)\n        }\n    }");
        this.launcher = registerForActivityResult;
    }

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

    public final ActivityResultLauncher<Intent> getLauncher() {
        return this.launcher;
    }

    public final void setLauncher(ActivityResultLauncher<Intent> activityResultLauncher) {
        Intrinsics.checkNotNullParameter(activityResultLauncher, "<set-?>");
        this.launcher = activityResultLauncher;
    }

    public static final void launcher$lambda$0(MediaSliderActivity mediaSliderActivity, ActivityResult activityResult) {
        Intrinsics.checkNotNullParameter(mediaSliderActivity, "this$0");
        Intrinsics.checkNotNullParameter(activityResult, "result");
        if (activityResult.getResultCode() == -1) {
            mediaSliderActivity.refresh(true);
        }
    }

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

    @Override
    protected void onCreate(android.os.Bundle r12) {
        throw new UnsupportedOperationException("Method not decompiled: app.callpe.common.utils.custom.mediaslider.MediaSliderActivity.onCreate(android.os.Bundle):void");
    }

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

    private final void loadMediaSliderView() {
        setAdapter();
    }

    private final void onClick() {
        getBinding().imageBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                MediaSliderActivity.onClick$lambda$2(MediaSliderActivity.this, view);
            }
        });
        getBinding().videoBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                MediaSliderActivity.onClick$lambda$4(MediaSliderActivity.this, view);
            }
        });
    }

    public static final void onClick$lambda$2(MediaSliderActivity mediaSliderActivity, View view) {
        Intrinsics.checkNotNullParameter(mediaSliderActivity, "this$0");
        Intent intent = new Intent((Context) mediaSliderActivity, (Class<?>) ImageVideoUploadActivity.class);
        intent.putExtra("type", Constants.IMAGE);
        mediaSliderActivity.launcher.launch(intent);
    }

    public static final void onClick$lambda$4(MediaSliderActivity mediaSliderActivity, View view) {
        Intrinsics.checkNotNullParameter(mediaSliderActivity, "this$0");
        Intent intent = new Intent((Context) mediaSliderActivity, (Class<?>) ImageVideoUploadActivity.class);
        intent.putExtra("type", Constants.VIDEO);
        mediaSliderActivity.launcher.launch(intent);
    }

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

    static void refresh$default(MediaSliderActivity mediaSliderActivity, boolean z, int i, Object obj) {
        if ((i & 1) != 0) {
            z = false;
        }
        mediaSliderActivity.refresh(z);
    }

    private final void refresh(boolean forceRefresh) {
        getViewModel().setLastPage(false);
        getViewModel().setLoading(false);
        getViewModel().setFromId(-1L);
        getViewModel().getMediaList().clear();
        GalleryAdapter galleryAdapter = this.adapter;
        if (galleryAdapter != null) {
            galleryAdapter.clear();
        }
        UserViewModel.getMediaList$default(getViewModel(), false, true, false, forceRefresh, null, 21, null);
    }

    private final void setAdapter() {
        GalleryRecyclerView galleryRecyclerView;
        RecyclerView.LayoutManager layoutManager;
        try {
            new PagerSnapHelper().attachToRecyclerView(this.rv);
            final RecyclerView.LayoutManager customLinearLayoutManager = new CustomLinearLayoutManager((Context) this, 0, false);
            GalleryRecyclerView galleryRecyclerView2 = this.rv;
            if (galleryRecyclerView2 != null) {
                galleryRecyclerView2.setLayoutManager(customLinearLayoutManager);
            }
            ArrayList arrayList = null;
            GalleryAdapter galleryAdapter = new GalleryAdapter(arrayList, new GalleryAdapter.ItemClickListener() {
                @Override
                public void onItemClick(MediaFile streamer) {
                    Intrinsics.checkNotNullParameter(streamer, "streamer");
                }

                @Override
                public void onDeleteClicked(final MediaFile mediaFile) {
                    Intrinsics.checkNotNullParameter(mediaFile, "mediaFile");
                    Context context = (Context) MediaSliderActivity.this;
                    final MediaSliderActivity mediaSliderActivity = MediaSliderActivity.this;
                    DialogHelper.showReasonDialog(context, "", "Are you sure you want to delete this media ?", true, new DialogHelper.Listener() {
                        @Override
                        public void onNegativeClick() {
                        }

                        @Override
                        public void onPositiveClick() {
                            UserViewModel viewModel;
                            viewModel = MediaSliderActivity.this.getViewModel();
                            viewModel.deleteMedia(mediaFile);
                        }
                    });
                }
            }, 1, arrayList);
            this.adapter = galleryAdapter;
            GalleryRecyclerView galleryRecyclerView3 = this.rv;
            if (galleryRecyclerView3 != null) {
                galleryRecyclerView3.setAdapter(galleryAdapter);
            }
            GalleryRecyclerView galleryRecyclerView4 = this.rv;
            if (galleryRecyclerView4 != null) {
                galleryRecyclerView4.addOnScrollListener(new PaginationListener(customLinearLayoutManager, this) {
                    final MediaSliderActivity this$0;

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

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

                    @Override
                    protected void loadMoreItems() {
                        UserViewModel viewModel;
                        UserViewModel viewModel2;
                        boolean z;
                        UserViewModel viewModel3;
                        int i;
                        UserViewModel viewModel4;
                        int i2;
                        UserViewModel viewModel5;
                        UserViewModel viewModel6;
                        UserViewModel viewModel7;
                        if (!LoginActivity.INSTANCE.isVitok()) {
                            z = this.this$0.firstRechargeDone;
                            if (!z) {
                                viewModel3 = this.this$0.getViewModel();
                                int size = viewModel3.getMediaList().size();
                                i = this.this$0.unlockedPicsCount;
                                if (size >= i) {
                                    viewModel7 = this.this$0.getViewModel();
                                    viewModel7.setLastPage(true);
                                    return;
                                }
                                viewModel4 = this.this$0.getViewModel();
                                viewModel4.setLoading(true);
                                i2 = this.this$0.unlockedPicsCount;
                                viewModel5 = this.this$0.getViewModel();
                                int min = Math.min(i2 - viewModel5.getMediaList().size(), 5);
                                viewModel6 = this.this$0.getViewModel();
                                UserViewModel.getMediaList$default(viewModel6, false, true, false, false, Integer.valueOf(min), 13, null);
                                return;
                            }
                        }
                        viewModel = this.this$0.getViewModel();
                        viewModel.setLoading(true);
                        viewModel2 = this.this$0.getViewModel();
                        UserViewModel.getMediaList$default(viewModel2, false, true, false, false, null, 29, null);
                    }

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

                    @Override
                    public boolean isLoading() {
                        UserViewModel viewModel;
                        viewModel = this.this$0.getViewModel();
                        return viewModel.getIsLoading();
                    }
                });
            }
            if (!getViewModel().getMediaList().isEmpty()) {
                GalleryAdapter galleryAdapter2 = this.adapter;
                if (galleryAdapter2 != null) {
                    galleryAdapter2.addItems(getViewModel().getMediaList());
                }
                if (this.startPosition == -1 || (galleryRecyclerView = this.rv) == null || (layoutManager = galleryRecyclerView.getLayoutManager()) == null) {
                    return;
                }
                layoutManager.scrollToPosition(this.startPosition);
            }
        } catch (Exception e) {
            Timber.e(e);
        }
    }

    protected void onPause() {
        super.onPause();
        GalleryRecyclerView galleryRecyclerView = this.rv;
        if (galleryRecyclerView != null) {
            galleryRecyclerView.changePlayingState(false);
        }
    }

    protected void onResume() {
        super.onResume();
        GalleryRecyclerView galleryRecyclerView = this.rv;
        if (galleryRecyclerView != null) {
            galleryRecyclerView.changePlayingState(true);
        }
    }

    protected void onDestroy() {
        GalleryRecyclerView galleryRecyclerView = this.rv;
        if (galleryRecyclerView != null) {
            galleryRecyclerView.clearActivity();
        }
        super.onDestroy();
    }

    public boolean onOptionsItemSelected(MenuItem item) {
        Intrinsics.checkNotNullParameter(item, "item");
        int itemId = item.getItemId();
        if (itemId == 16908332) {
            onBackPressed();
        }
        if (itemId == 2131363976) {
            GalleryRecyclerView galleryRecyclerView = this.rv;
            RecyclerView.LayoutManager layoutManager = galleryRecyclerView != null ? galleryRecyclerView.getLayoutManager() : null;
            LinearLayoutManager linearLayoutManager = layoutManager instanceof LinearLayoutManager ? (LinearLayoutManager) layoutManager : null;
            final Integer valueOf = linearLayoutManager != null ? Integer.valueOf(linearLayoutManager.findFirstCompletelyVisibleItemPosition()) : null;
            if (valueOf == null || valueOf.intValue() != -1) {
                DialogHelper.showReasonDialog((Context) this, "", "Are you sure you want to delete this media ?", true, new DialogHelper.Listener() {
                    @Override
                    public void onNegativeClick() {
                    }

                    @Override
                    public void onPositiveClick() {
                        throw new UnsupportedOperationException("Method not decompiled: app.callpe.common.utils.custom.mediaslider.MediaSliderActivity$onOptionsItemSelected$1.onPositiveClick():void");
                    }
                });
            } else {
                Toast.makeText((Context) this, "No item is visible", 0).show();
            }
        }
        return true;
    }
}