package com.vinfast.companion.core.utils.gallery;

/* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
/* JADX INFO: loaded from: E:\ios\vf_dex\classes15.dex */
@kotlin.Metadata(d1 = {"\u0000|\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\t\n\u0002\b\u0007\n\u0002\u0010\u000b\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\n\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0007\u0018\u0000 M2\b\u0012\u0004\u0012\u00020\u00020\u0001:\u0001NB\u0007¢\u0006\u0004\b\u0003\u0010\u0004J\u000f\u0010\u0006\u001a\u00020\u0005H\u0002¢\u0006\u0004\b\u0006\u0010\u0004J\u0017\u0010\t\u001a\u00020\u00052\u0006\u0010\b\u001a\u00020\u0007H\u0002¢\u0006\u0004\b\t\u0010\nJ\u000f\u0010\u000b\u001a\u00020\u0005H\u0002¢\u0006\u0004\b\u000b\u0010\u0004J\u000f\u0010\f\u001a\u00020\u0005H\u0002¢\u0006\u0004\b\f\u0010\u0004J\u000f\u0010\r\u001a\u00020\u0005H\u0002¢\u0006\u0004\b\r\u0010\u0004J\u000f\u0010\u000e\u001a\u00020\u0005H\u0002¢\u0006\u0004\b\u000e\u0010\u0004J\u000f\u0010\u000f\u001a\u00020\u0005H\u0002¢\u0006\u0004\b\u000f\u0010\u0004J\u0017\u0010\u0012\u001a\u00020\u00052\u0006\u0010\u0011\u001a\u00020\u0010H\u0002¢\u0006\u0004\b\u0012\u0010\u0013J\u000f\u0010\u0014\u001a\u00020\u0005H\u0002¢\u0006\u0004\b\u0014\u0010\u0004J\u000f\u0010\u0016\u001a\u00020\u0015H\u0016¢\u0006\u0004\b\u0016\u0010\u0017J\u000f\u0010\u0018\u001a\u00020\u0005H\u0016¢\u0006\u0004\b\u0018\u0010\u0004J!\u0010\u001d\u001a\u00020\u00052\u0006\u0010\u001a\u001a\u00020\u00192\b\u0010\u001c\u001a\u0004\u0018\u00010\u001bH\u0016¢\u0006\u0004\b\u001d\u0010\u001eJ\u000f\u0010 \u001a\u00020\u001fH\u0016¢\u0006\u0004\b \u0010!R\u001b\u0010'\u001a\u00020\"8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b#\u0010$\u001a\u0004\b%\u0010&R\"\u0010/\u001a\u00020(8\u0006@\u0006X\u0086\u000e¢\u0006\u0012\n\u0004\b)\u0010*\u001a\u0004\b+\u0010,\"\u0004\b-\u0010.R\u0016\u00103\u001a\u0002008\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b1\u00102R\u0016\u00105\u001a\u0002008\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b4\u00102R2\u0010?\u001a\u0012\u0012\u0004\u0012\u00020706j\b\u0012\u0004\u0012\u000207`88\u0006@\u0006X\u0086\u000e¢\u0006\u0012\n\u0004\b9\u0010:\u001a\u0004\b;\u0010<\"\u0004\b=\u0010>R\u0016\u0010B\u001a\u00020\u00078\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b@\u0010AR\u001b\u0010G\u001a\u00020C8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\bD\u0010$\u001a\u0004\bE\u0010FR\u001b\u0010L\u001a\u00020H8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\bI\u0010$\u001a\u0004\bJ\u0010K¨\u0006O"}, d2 = {"Lcom/vinfast/companion/core/utils/gallery/GalleryFragment;", "Lcom/vinfast/companion/core/base/fragment/BaseFragment;", "Lcom/vinfast/companion/core/databinding/FragmentGalleryBinding;", "<init>", "()V", "", "F2", "", "position", "y2", "(I)V", "t2", "r2", "j2", "B2", "A2", "Lcom/vinfast/companion/core/utils/imagedowloader/ImageDownloadMetadata;", "metadata", "D2", "(Lcom/vinfast/companion/core/utils/imagedowloader/ImageDownloadMetadata;)V", "z2", "Lcom/vinfast/companion/core/base/BaseViewModel;", "U1", "()Lcom/vinfast/companion/core/base/BaseViewModel;", "onDestroy", "Landroid/view/View;", "view", "Landroid/os/Bundle;", "savedInstanceState", "y1", "(Landroid/view/View;Landroid/os/Bundle;)V", "Lcom/vinfast/companion/core/base/fragment/ToolbarConfiguration;", "T0", "()Lcom/vinfast/companion/core/base/fragment/ToolbarConfiguration;", "Lcom/vinfast/companion/core/utils/gallery/GalleryViewModel;", "x", "Lkotlin/Lazy;", "q2", "()Lcom/vinfast/companion/core/utils/gallery/GalleryViewModel;", "mViewModel", "", "y", "J", "getIdentifier", "()J", "setIdentifier", "(J)V", "identifier", "", "z", "Z", "isShowImageInfo", "A", "isContainRemove", "Ljava/util/ArrayList;", "Lcom/vinfast/companion/core/utils/gallery/GalleryItem;", "Lkotlin/collections/ArrayList;", "B", "Ljava/util/ArrayList;", "getGallery", "()Ljava/util/ArrayList;", "setGallery", "(Ljava/util/ArrayList;)V", "gallery", "C", "I", "defaultPosition", "Lcom/vinfast/companion/core/utils/gallery/GalleryPreviewAdapter;", "D", "o2", "()Lcom/vinfast/companion/core/utils/gallery/GalleryPreviewAdapter;", "galleryPreviewAdapter", "Lcom/vinfast/companion/core/utils/gallery/GallerySwipeAdapter;", "E", "p2", "()Lcom/vinfast/companion/core/utils/gallery/GallerySwipeAdapter;", "gallerySwipeAdapter", "F", "Companion", "core_release"}, k = 1, mv = {2, 2, 0}, xi = 48)
@kotlin.jvm.internal.SourceDebugExtension
public final class GalleryFragment extends com.vinfast.companion.core.base.fragment.BaseFragment<com.vinfast.companion.core.databinding.FragmentGalleryBinding> {

    /* JADX INFO: renamed from: F, reason: from kotlin metadata */
    public static final com.vinfast.companion.core.utils.gallery.GalleryFragment.Companion INSTANCE = new com.vinfast.companion.core.utils.gallery.GalleryFragment.Companion(null);

    /* JADX INFO: renamed from: A, reason: from kotlin metadata */
    private boolean isContainRemove;

    /* JADX INFO: renamed from: B, reason: from kotlin metadata */
    private java.util.ArrayList gallery;

    /* JADX INFO: renamed from: C, reason: from kotlin metadata */
    private int defaultPosition;

    /* JADX INFO: renamed from: D, reason: from kotlin metadata */
    private final kotlin.Lazy galleryPreviewAdapter;

    /* JADX INFO: renamed from: E, reason: from kotlin metadata */
    private final kotlin.Lazy gallerySwipeAdapter;

    /* JADX INFO: renamed from: x, reason: from kotlin metadata */
    private final kotlin.Lazy mViewModel;

    /* JADX INFO: renamed from: y, reason: from kotlin metadata */
    private long identifier;

    /* JADX INFO: renamed from: z, reason: from kotlin metadata */
    private boolean isShowImageInfo;

    /* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
    @kotlin.Metadata(d1 = {"\u00002\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\t\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\b\u0086\u0003\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u0002\u0010\u0003JN\u0010\u000f\u001a\u00020\u000e2\n\b\u0002\u0010\u0005\u001a\u0004\u0018\u00010\u00042\u0006\u0010\u0007\u001a\u00020\u00062\u0006\u0010\b\u001a\u00020\u00062#\b\u0002\u0010\r\u001a\u001d\u0012\u0013\u0012\u00110\u0004¢\u0006\f\b\n\u0012\b\b\u000b\u0012\u0004\b\b(\u0005\u0012\u0004\u0012\u00020\f0\t¢\u0006\u0004\b\u000f\u0010\u0010¨\u0006\u0011"}, d2 = {"Lcom/vinfast/companion/core/utils/gallery/GalleryFragment$Companion;", "", "<init>", "()V", "", "identifier", "", "isContainRemove", "isShowImageInfo", "Lkotlin/Function1;", "Lkotlin/ParameterName;", "name", "", "getId", "Lcom/vinfast/companion/core/utils/gallery/GalleryFragment;", "b", "(Ljava/lang/Long;ZZLkotlin/jvm/functions/Function1;)Lcom/vinfast/companion/core/utils/gallery/GalleryFragment;", "core_release"}, k = 1, mv = {2, 2, 0}, xi = 48)
    public static final class Companion {
        public /* synthetic */ Companion(kotlin.jvm.internal.DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        public static /* synthetic */ com.vinfast.companion.core.utils.gallery.GalleryFragment c(com.vinfast.companion.core.utils.gallery.GalleryFragment.Companion companion, java.lang.Long l, boolean z, boolean z2, kotlin.jvm.functions.Function1 function1, int i, java.lang.Object obj) {
            if ((i & 1) != 0) {
                l = null;
            }
            if ((i & 8) != 0) {
                function1 = new kotlin.jvm.functions.Function1() { // from class: com.vinfast.companion.core.utils.gallery.n
                    public final java.lang.Object invoke(java.lang.Object obj2) {
                        return com.vinfast.companion.core.utils.gallery.GalleryFragment.Companion.d(((java.lang.Long) obj2).longValue());
                    }
                };
            }
            return companion.b(l, z, z2, function1);
        }

        /* JADX INFO: Access modifiers changed from: private */
        public static final kotlin.Unit d(long j) {
            return kotlin.Unit.a;
        }

        public final com.vinfast.companion.core.utils.gallery.GalleryFragment b(java.lang.Long identifier, boolean isContainRemove, boolean isShowImageInfo, kotlin.jvm.functions.Function1 getId) {
            kotlin.jvm.internal.Intrinsics.l(getId, "getId");
            android.os.Bundle bundle = new android.os.Bundle();
            long jLongValue = identifier != null ? identifier.longValue() : com.vinfast.companion.core.utils.gallery.GalleryManager.a.b();
            bundle.putLong("GALLERY_IDENTIFIER", jLongValue);
            bundle.putBoolean("GALLERY_IS_CONTAIN_REMOVE", isContainRemove);
            bundle.putBoolean("GALLERY_IS_SHOW_INFO", isShowImageInfo);
            com.vinfast.companion.core.utils.gallery.GalleryFragment galleryFragment = new com.vinfast.companion.core.utils.gallery.GalleryFragment();
            galleryFragment.setArguments(bundle);
            getId.invoke(java.lang.Long.valueOf(jLongValue));
            return galleryFragment;
        }

        private Companion() {
        }
    }

    public GalleryFragment() {
        super(new kotlin.jvm.functions.Function1() { // from class: com.vinfast.companion.core.utils.gallery.b
            public final java.lang.Object invoke(java.lang.Object obj) {
                return com.vinfast.companion.core.utils.gallery.GalleryFragment.h2((android.view.LayoutInflater) obj);
            }
        });
        final kotlin.jvm.functions.Function0<androidx.fragment.app.Fragment> function0 = new kotlin.jvm.functions.Function0<androidx.fragment.app.Fragment>() { // from class: com.vinfast.companion.core.utils.gallery.GalleryFragment$special$$inlined$viewModels$default$1
            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            {
                super(0);
            }

            /* JADX INFO: renamed from: a, reason: merged with bridge method [inline-methods] */
            public final androidx.fragment.app.Fragment invoke() {
                return this;
            }
        };
        final kotlin.Lazy lazyA = kotlin.LazyKt.a(kotlin.LazyThreadSafetyMode.NONE, new kotlin.jvm.functions.Function0<androidx.lifecycle.ViewModelStoreOwner>() { // from class: com.vinfast.companion.core.utils.gallery.GalleryFragment$special$$inlined$viewModels$default$2
            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            {
                super(0);
            }

            /* JADX INFO: renamed from: a, reason: merged with bridge method [inline-methods] */
            public final androidx.lifecycle.ViewModelStoreOwner invoke() {
                return (androidx.lifecycle.ViewModelStoreOwner) function0.invoke();
            }
        });
        final kotlin.jvm.functions.Function0 function1 = null;
        this.mViewModel = androidx.fragment.app.FragmentViewModelLazyKt.c(this, kotlin.jvm.internal.Reflection.b(com.vinfast.companion.core.utils.gallery.GalleryViewModel.class), new kotlin.jvm.functions.Function0<androidx.lifecycle.ViewModelStore>() { // from class: com.vinfast.companion.core.utils.gallery.GalleryFragment$special$$inlined$viewModels$default$3
            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            {
                super(0);
            }

            /* JADX INFO: renamed from: a, reason: merged with bridge method [inline-methods] */
            public final androidx.lifecycle.ViewModelStore invoke() {
                return androidx.fragment.app.FragmentViewModelLazyKt.b(lazyA).getViewModelStore();
            }
        }, new kotlin.jvm.functions.Function0<androidx.lifecycle.viewmodel.CreationExtras>() { // from class: com.vinfast.companion.core.utils.gallery.GalleryFragment$special$$inlined$viewModels$default$4
            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            {
                super(0);
            }

            /* JADX INFO: renamed from: a, reason: merged with bridge method [inline-methods] */
            public final androidx.lifecycle.viewmodel.CreationExtras invoke() {
                androidx.lifecycle.viewmodel.CreationExtras creationExtras;
                kotlin.jvm.functions.Function0 function2 = function1;
                if (function2 != null && (creationExtras = (androidx.lifecycle.viewmodel.CreationExtras) function2.invoke()) != null) {
                    return creationExtras;
                }
                androidx.lifecycle.HasDefaultViewModelProviderFactory hasDefaultViewModelProviderFactoryB = androidx.fragment.app.FragmentViewModelLazyKt.b(lazyA);
                androidx.lifecycle.HasDefaultViewModelProviderFactory hasDefaultViewModelProviderFactory = hasDefaultViewModelProviderFactoryB instanceof androidx.lifecycle.HasDefaultViewModelProviderFactory ? hasDefaultViewModelProviderFactoryB : null;
                return hasDefaultViewModelProviderFactory != null ? hasDefaultViewModelProviderFactory.getDefaultViewModelCreationExtras() : androidx.lifecycle.viewmodel.CreationExtras.Empty.c;
            }
        }, new kotlin.jvm.functions.Function0<androidx.lifecycle.ViewModelProvider.Factory>() { // from class: com.vinfast.companion.core.utils.gallery.GalleryFragment$special$$inlined$viewModels$default$5
            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            {
                super(0);
            }

            /* JADX INFO: renamed from: a, reason: merged with bridge method [inline-methods] */
            public final androidx.lifecycle.ViewModelProvider.Factory invoke() {
                androidx.lifecycle.ViewModelProvider.Factory defaultViewModelProviderFactory;
                androidx.lifecycle.HasDefaultViewModelProviderFactory hasDefaultViewModelProviderFactoryB = androidx.fragment.app.FragmentViewModelLazyKt.b(lazyA);
                androidx.lifecycle.HasDefaultViewModelProviderFactory hasDefaultViewModelProviderFactory = hasDefaultViewModelProviderFactoryB instanceof androidx.lifecycle.HasDefaultViewModelProviderFactory ? hasDefaultViewModelProviderFactoryB : null;
                return (hasDefaultViewModelProviderFactory == null || (defaultViewModelProviderFactory = hasDefaultViewModelProviderFactory.getDefaultViewModelProviderFactory()) == null) ? this.getDefaultViewModelProviderFactory() : defaultViewModelProviderFactory;
            }
        });
        this.isShowImageInfo = true;
        this.gallery = new java.util.ArrayList();
        this.galleryPreviewAdapter = kotlin.LazyKt.b(new kotlin.jvm.functions.Function0() { // from class: com.vinfast.companion.core.utils.gallery.e
            public final java.lang.Object invoke() {
                return com.vinfast.companion.core.utils.gallery.GalleryFragment.k2(this.a);
            }
        });
        this.gallerySwipeAdapter = kotlin.LazyKt.b(new kotlin.jvm.functions.Function0() { // from class: com.vinfast.companion.core.utils.gallery.f
            public final java.lang.Object invoke() {
                return com.vinfast.companion.core.utils.gallery.GalleryFragment.m2(this.a);
            }
        });
    }

    private final void A2() {
        java.lang.Object obj = this.gallery.get(o2().getSelectedPosition());
        kotlin.jvm.internal.Intrinsics.k(obj, "get(...)");
        com.vinfast.companion.core.utils.gallery.GalleryItem galleryItem = (com.vinfast.companion.core.utils.gallery.GalleryItem) obj;
        java.lang.String downloadName = galleryItem.getDownloadName();
        if (downloadName == null) {
            downloadName = com.vinfast.companion.core.utils.imagedowloader.ImageDownloadMetadata.INSTANCE.a();
        }
        java.lang.String url = galleryItem.getUrl();
        kotlin.jvm.internal.Intrinsics.i(url);
        D2(new com.vinfast.companion.core.utils.imagedowloader.ImageDownloadMetadata(downloadName, url, null, null, galleryItem.getTokenRequired(), false, 44, null));
    }

    private final void B2() {
        java.lang.Object obj = this.gallery.get(o2().getSelectedPosition());
        kotlin.jvm.internal.Intrinsics.k(obj, "get(...)");
        com.vinfast.companion.core.utils.gallery.GalleryItem galleryItem = (com.vinfast.companion.core.utils.gallery.GalleryItem) obj;
        java.lang.String url = galleryItem.getUrl();
        if (url == null) {
            return;
        }
        com.vinfast.companion.core.utils.imagesharer.ImageShareMetadata imageShareMetadata = new com.vinfast.companion.core.utils.imagesharer.ImageShareMetadata(url, galleryItem.getTokenRequired());
        android.content.Context contextRequireContext = requireContext();
        kotlin.jvm.internal.Intrinsics.k(contextRequireContext, "requireContext(...)");
        new com.vinfast.companion.core.utils.imagesharer.ImageSharer.Builder(contextRequireContext).e(com.vinfast.companion.core.R.string.CA60203_share_via).b(imageShareMetadata).d(new kotlin.jvm.functions.Function1() { // from class: com.vinfast.companion.core.utils.gallery.c
            public final java.lang.Object invoke(java.lang.Object obj2) {
                return com.vinfast.companion.core.utils.gallery.GalleryFragment.C2(this.a, (com.vinfast.companion.core.utils.imagesharer.ImageSharer.Progress) obj2);
            }
        }).a().h();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final kotlin.Unit C2(com.vinfast.companion.core.utils.gallery.GalleryFragment galleryFragment, com.vinfast.companion.core.utils.imagesharer.ImageSharer.Progress progress) {
        kotlin.jvm.internal.Intrinsics.l(progress, "progress");
        if (kotlin.jvm.internal.Intrinsics.g(progress, com.vinfast.companion.core.utils.imagesharer.ImageSharer.Progress.Started.a)) {
            galleryFragment.Q1(com.vinfast.companion.core.base.ProgressType.ProgressDialog.b);
        } else if ((progress instanceof com.vinfast.companion.core.utils.imagesharer.ImageSharer.Progress.Error) || kotlin.jvm.internal.Intrinsics.g(progress, com.vinfast.companion.core.utils.imagesharer.ImageSharer.Progress.Shared.a)) {
            galleryFragment.X0(com.vinfast.companion.core.base.ViewModelState.Idle.a);
        }
        return kotlin.Unit.a;
    }

    private final void D2(com.vinfast.companion.core.utils.imagedowloader.ImageDownloadMetadata metadata) {
        android.content.Context contextRequireContext = requireContext();
        kotlin.jvm.internal.Intrinsics.k(contextRequireContext, "requireContext(...)");
        new com.vinfast.companion.core.utils.imagedowloader.ImageDownloader.Builder(contextRequireContext).b(metadata).d(new kotlin.jvm.functions.Function1() { // from class: com.vinfast.companion.core.utils.gallery.d
            public final java.lang.Object invoke(java.lang.Object obj) {
                return com.vinfast.companion.core.utils.gallery.GalleryFragment.E2(this.a, (com.vinfast.companion.core.utils.imagedowloader.ImageDownloader.Progress) obj);
            }
        }).a().f();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final kotlin.Unit E2(com.vinfast.companion.core.utils.gallery.GalleryFragment galleryFragment, com.vinfast.companion.core.utils.imagedowloader.ImageDownloader.Progress progress) {
        kotlin.jvm.internal.Intrinsics.l(progress, "progress");
        if (kotlin.jvm.internal.Intrinsics.g(progress, com.vinfast.companion.core.utils.imagedowloader.ImageDownloader.Progress.Started.a)) {
            galleryFragment.Q1(com.vinfast.companion.core.base.ProgressType.ProgressDialog.b);
        } else if (kotlin.jvm.internal.Intrinsics.g(progress, com.vinfast.companion.core.utils.imagedowloader.ImageDownloader.Progress.Complete.a) || (progress instanceof com.vinfast.companion.core.utils.imagedowloader.ImageDownloader.Progress.Error)) {
            galleryFragment.X0(com.vinfast.companion.core.base.ViewModelState.Idle.a);
        }
        return kotlin.Unit.a;
    }

    private final void F2() {
        android.widget.FrameLayout frameLayout = ((com.vinfast.companion.core.databinding.FragmentGalleryBinding) T1()).b;
        kotlin.jvm.internal.Intrinsics.k(frameLayout, "gvBottom");
        com.vinfast.companion.core.extensions.ViewExtensionKt.Y(frameLayout, false, 1, null);
        if (this.isContainRemove) {
            android.widget.ImageButton imageButton = ((com.vinfast.companion.core.databinding.FragmentGalleryBinding) T1()).c;
            kotlin.jvm.internal.Intrinsics.k(imageButton, "icRemove");
            com.vinfast.companion.core.extensions.ViewExtensionKt.Y(imageButton, false, 1, null);
        }
        androidx.appcompat.widget.Toolbar toolbarS0 = com.vinfast.companion.core.base.fragment.BaseFragment.S0(this, null, 1, null);
        if (toolbarS0 != null) {
            com.vinfast.companion.core.extensions.ViewExtensionKt.X(toolbarS0, true);
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final com.vinfast.companion.core.databinding.FragmentGalleryBinding h2(android.view.LayoutInflater layoutInflater) {
        kotlin.jvm.internal.Intrinsics.l(layoutInflater, "it");
        com.vinfast.companion.core.databinding.FragmentGalleryBinding fragmentGalleryBindingC = com.vinfast.companion.core.databinding.FragmentGalleryBinding.c(layoutInflater);
        kotlin.jvm.internal.Intrinsics.k(fragmentGalleryBindingC, "inflate(...)");
        return fragmentGalleryBindingC;
    }

    private final void j2() {
        androidx.recyclerview.widget.RecyclerView recyclerView = ((com.vinfast.companion.core.databinding.FragmentGalleryBinding) T1()).f;
        recyclerView.setLayoutManager(new androidx.recyclerview.widget.LinearLayoutManager(recyclerView.getContext(), 0, false));
        androidx.recyclerview.widget.RecyclerView recyclerView2 = ((com.vinfast.companion.core.databinding.FragmentGalleryBinding) T1()).g;
        recyclerView2.setLayoutManager(new androidx.recyclerview.widget.LinearLayoutManager(recyclerView2.getContext(), 0, false));
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final com.vinfast.companion.core.utils.gallery.GalleryPreviewAdapter k2(final com.vinfast.companion.core.utils.gallery.GalleryFragment galleryFragment) {
        return new com.vinfast.companion.core.utils.gallery.GalleryPreviewAdapter(new kotlin.jvm.functions.Function2() { // from class: com.vinfast.companion.core.utils.gallery.m
            public final java.lang.Object invoke(java.lang.Object obj, java.lang.Object obj2) {
                return com.vinfast.companion.core.utils.gallery.GalleryFragment.l2(this.a, ((java.lang.Integer) obj).intValue(), (com.vinfast.companion.core.utils.gallery.GalleryItem) obj2);
            }
        });
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final kotlin.Unit l2(com.vinfast.companion.core.utils.gallery.GalleryFragment galleryFragment, int i, com.vinfast.companion.core.utils.gallery.GalleryItem galleryItem) {
        galleryFragment.y2(i);
        return kotlin.Unit.a;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final com.vinfast.companion.core.utils.gallery.GallerySwipeAdapter m2(final com.vinfast.companion.core.utils.gallery.GalleryFragment galleryFragment) {
        return new com.vinfast.companion.core.utils.gallery.GallerySwipeAdapter(new kotlin.jvm.functions.Function2() { // from class: com.vinfast.companion.core.utils.gallery.l
            public final java.lang.Object invoke(java.lang.Object obj, java.lang.Object obj2) {
                return com.vinfast.companion.core.utils.gallery.GalleryFragment.n2(this.a, ((java.lang.Integer) obj).intValue(), (com.vinfast.companion.core.utils.gallery.GalleryItem) obj2);
            }
        });
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final kotlin.Unit n2(com.vinfast.companion.core.utils.gallery.GalleryFragment galleryFragment, int i, com.vinfast.companion.core.utils.gallery.GalleryItem galleryItem) {
        galleryFragment.F2();
        return kotlin.Unit.a;
    }

    private final com.vinfast.companion.core.utils.gallery.GalleryPreviewAdapter o2() {
        return (com.vinfast.companion.core.utils.gallery.GalleryPreviewAdapter) this.galleryPreviewAdapter.getValue();
    }

    private final com.vinfast.companion.core.utils.gallery.GallerySwipeAdapter p2() {
        return (com.vinfast.companion.core.utils.gallery.GallerySwipeAdapter) this.gallerySwipeAdapter.getValue();
    }

    private final com.vinfast.companion.core.utils.gallery.GalleryViewModel q2() {
        return (com.vinfast.companion.core.utils.gallery.GalleryViewModel) this.mViewModel.getValue();
    }

    private final void r2() {
        com.vinfast.companion.core.databinding.FragmentGalleryBinding fragmentGalleryBinding = (com.vinfast.companion.core.databinding.FragmentGalleryBinding) T1();
        fragmentGalleryBinding.f.setAdapter(o2());
        fragmentGalleryBinding.g.setAdapter(p2());
        androidx.recyclerview.widget.RecyclerView recyclerView = fragmentGalleryBinding.g;
        kotlin.jvm.internal.Intrinsics.k(recyclerView, "rcvGallerySwipe");
        com.vinfast.companion.core.utils.gallery.SnapHelperExtensionKt.b(recyclerView, new androidx.recyclerview.widget.PagerSnapHelper(), null, new com.vinfast.companion.core.utils.gallery.OnSnapPositionChangeListener() { // from class: com.vinfast.companion.core.utils.gallery.GalleryFragment$initData$1$1
            @Override // com.vinfast.companion.core.utils.gallery.OnSnapPositionChangeListener
            public void a(int position) {
                this.a.y2(position);
            }
        }, 2, null);
        androidx.lifecycle.MutableLiveData mutableLiveDataA = com.vinfast.companion.core.utils.gallery.GalleryManager.a.a(this.identifier);
        if (mutableLiveDataA != null) {
            com.vinfast.companion.core.extensions.LiveDataExtensionsKt.c(mutableLiveDataA, this, new kotlin.jvm.functions.Function1() { // from class: com.vinfast.companion.core.utils.gallery.k
                public final java.lang.Object invoke(java.lang.Object obj) {
                    return com.vinfast.companion.core.utils.gallery.GalleryFragment.s2(this.a, (com.vinfast.companion.core.utils.gallery.GalleryManager.Data) obj);
                }
            });
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final kotlin.Unit s2(com.vinfast.companion.core.utils.gallery.GalleryFragment galleryFragment, com.vinfast.companion.core.utils.gallery.GalleryManager.Data data) {
        java.util.ArrayList gallery = data.getGallery();
        galleryFragment.gallery = gallery;
        if (galleryFragment.isContainRemove && gallery.isEmpty()) {
            com.vinfast.companion.core.base.fragment.BaseFragment.t1(galleryFragment, false, 1, null);
            return kotlin.Unit.a;
        }
        android.widget.LinearLayout linearLayout = ((com.vinfast.companion.core.databinding.FragmentGalleryBinding) galleryFragment.T1()).l;
        kotlin.jvm.internal.Intrinsics.k(linearLayout, "viewActionDown");
        linearLayout.setVisibility(galleryFragment.gallery.isEmpty() ? 8 : 0);
        galleryFragment.defaultPosition = data.getDefaultPosition();
        com.vinfast.companion.core.base.ui.widget.CommonToolbar commonToolbarS0 = com.vinfast.companion.core.base.fragment.BaseFragment.S0(galleryFragment, null, 1, null);
        if (commonToolbarS0 != null) {
            commonToolbarS0.setTitleText(data.getTitle());
        }
        galleryFragment.o2().j(kotlin.collections.CollectionsKt.n1(galleryFragment.gallery));
        galleryFragment.p2().j(kotlin.collections.CollectionsKt.n1(galleryFragment.gallery));
        int size = galleryFragment.gallery.size();
        int i = galleryFragment.defaultPosition;
        if (i >= 0 && i < size) {
            galleryFragment.y2(i);
        }
        return kotlin.Unit.a;
    }

    /* JADX WARN: Type inference fix 'apply assigned field type' failed
    java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$PrimitiveArg
    	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:596)
    	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
    	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
     */
    private final void t2() {
        com.vinfast.companion.core.databinding.FragmentGalleryBinding fragmentGalleryBinding = (com.vinfast.companion.core.databinding.FragmentGalleryBinding) T1();
        android.content.Context contextRequireContext = requireContext();
        kotlin.jvm.internal.Intrinsics.k(contextRequireContext, "requireContext(...)");
        fragmentGalleryBinding.i.setPadding(0, com.vinfast.companion.core.extensions.DeviceExtensionKt.c(contextRequireContext), 0, 0);
        com.vinfast.companion.core.extensions.ViewExtensionKt.i(fragmentGalleryBinding.e, 0.0f, 0.0f, 0.0f, 0.0f, 15, null);
        fragmentGalleryBinding.e.setOnClickListener(new android.view.View.OnClickListener() { // from class: com.vinfast.companion.core.utils.gallery.g
            @Override // android.view.View.OnClickListener
            public final void onClick(android.view.View view) {
                com.vinfast.companion.core.utils.gallery.GalleryFragment.u2(this.a, view);
            }
        });
        com.vinfast.companion.core.extensions.ViewExtensionKt.i(fragmentGalleryBinding.d, 0.0f, 0.0f, 0.0f, 0.0f, 15, null);
        fragmentGalleryBinding.d.setOnClickListener(new android.view.View.OnClickListener() { // from class: com.vinfast.companion.core.utils.gallery.h
            @Override // android.view.View.OnClickListener
            public final void onClick(android.view.View view) {
                com.vinfast.companion.core.utils.gallery.GalleryFragment.v2(this.a, view);
            }
        });
        if (this.isShowImageInfo) {
            android.widget.ImageButton imageButton = fragmentGalleryBinding.e;
            kotlin.jvm.internal.Intrinsics.k(imageButton, "ivShareTo");
            com.vinfast.companion.core.extensions.ViewExtensionKt.S(imageButton);
            android.widget.ImageButton imageButton2 = fragmentGalleryBinding.d;
            kotlin.jvm.internal.Intrinsics.k(imageButton2, "ivSaveToPhone");
            com.vinfast.companion.core.extensions.ViewExtensionKt.S(imageButton2);
        } else {
            android.widget.ImageButton imageButton3 = fragmentGalleryBinding.e;
            kotlin.jvm.internal.Intrinsics.k(imageButton3, "ivShareTo");
            com.vinfast.companion.core.extensions.ViewExtensionKt.m(imageButton3);
            android.widget.ImageButton imageButton4 = fragmentGalleryBinding.d;
            kotlin.jvm.internal.Intrinsics.k(imageButton4, "ivSaveToPhone");
            com.vinfast.companion.core.extensions.ViewExtensionKt.m(imageButton4);
        }
        android.widget.LinearLayout linearLayout = fragmentGalleryBinding.m;
        kotlin.jvm.internal.Intrinsics.k(linearLayout, "viewImageInfo");
        linearLayout.setVisibility(this.isShowImageInfo ? 0 : 8);
        android.widget.ImageButton imageButton5 = fragmentGalleryBinding.c;
        kotlin.jvm.internal.Intrinsics.k(imageButton5, "icRemove");
        imageButton5.setVisibility(this.isContainRemove ? 0 : 8);
        android.widget.ImageButton imageButton6 = fragmentGalleryBinding.c;
        kotlin.jvm.internal.Intrinsics.k(imageButton6, "icRemove");
        com.vinfast.companion.core.extensions.ViewExtensionKt.G(imageButton6, new kotlin.jvm.functions.Function1() { // from class: com.vinfast.companion.core.utils.gallery.i
            public final java.lang.Object invoke(java.lang.Object obj) {
                return com.vinfast.companion.core.utils.gallery.GalleryFragment.w2(this.a, (android.view.View) obj);
            }
        });
        fragmentGalleryBinding.h.setOnClickListener(new android.view.View.OnClickListener() { // from class: com.vinfast.companion.core.utils.gallery.j
            @Override // android.view.View.OnClickListener
            public final void onClick(android.view.View view) {
                com.vinfast.companion.core.utils.gallery.GalleryFragment.x2(this.a, view);
            }
        });
        j2();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void u2(com.vinfast.companion.core.utils.gallery.GalleryFragment galleryFragment, android.view.View view) {
        galleryFragment.B2();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void v2(com.vinfast.companion.core.utils.gallery.GalleryFragment galleryFragment, android.view.View view) {
        galleryFragment.A2();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final kotlin.Unit w2(com.vinfast.companion.core.utils.gallery.GalleryFragment galleryFragment, android.view.View view) {
        kotlin.jvm.internal.Intrinsics.l(view, "it");
        galleryFragment.z2();
        return kotlin.Unit.a;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void x2(com.vinfast.companion.core.utils.gallery.GalleryFragment galleryFragment, android.view.View view) {
        galleryFragment.F2();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void y2(int position) {
        if (position < 0 || position >= this.gallery.size()) {
            return;
        }
        ((com.vinfast.companion.core.databinding.FragmentGalleryBinding) T1()).g.scrollToPosition(position);
        o2().r(position);
        ((com.vinfast.companion.core.databinding.FragmentGalleryBinding) T1()).f.scrollToPosition(position);
        com.vinfast.companion.core.utils.gallery.GalleryItem galleryItem = (com.vinfast.companion.core.utils.gallery.GalleryItem) this.gallery.get(position);
        androidx.appcompat.widget.AppCompatTextView appCompatTextView = ((com.vinfast.companion.core.databinding.FragmentGalleryBinding) T1()).j;
        java.lang.String name = galleryItem.getName();
        appCompatTextView.setText((name == null || name.length() <= 0) ? "" : galleryItem.getName());
        android.content.Context contextRequireContext = requireContext();
        kotlin.jvm.internal.Intrinsics.k(contextRequireContext, "requireContext(...)");
        java.lang.String language = com.vinfast.companion.core.utils.localehelper.LocaleHelperExtensionsKt.b(contextRequireContext).getLanguage();
        androidx.appcompat.widget.AppCompatTextView appCompatTextView2 = ((com.vinfast.companion.core.databinding.FragmentGalleryBinding) T1()).k;
        com.vinfast.companion.core.utils.gallery.GalleryViewModel galleryViewModelQ2 = q2();
        java.lang.Long time = galleryItem.getTime();
        kotlin.jvm.internal.Intrinsics.i(language);
        java.lang.String strJ = galleryViewModelQ2.J(time, language);
        appCompatTextView2.setText(strJ != null ? strJ : "");
    }

    private final void z2() {
        java.lang.Object obj = this.gallery.get(o2().getSelectedPosition());
        kotlin.jvm.internal.Intrinsics.k(obj, "get(...)");
        q2().K(this.identifier, (com.vinfast.companion.core.utils.gallery.GalleryItem) obj);
    }

    @Override // com.vinfast.companion.core.base.fragment.BaseFragment
    public com.vinfast.companion.core.base.fragment.ToolbarConfiguration T0() {
        return new com.vinfast.companion.core.base.fragment.ToolbarConfiguration.Builder().r(false).q(java.lang.Integer.valueOf(com.vinfast.companion.core.R.id.toolbar)).t(false).s(true).a();
    }

    @Override // com.vinfast.companion.core.base.fragment.BaseFragment
    public com.vinfast.companion.core.base.BaseViewModel U1() {
        return q2();
    }

    @Override // com.vinfast.companion.core.base.fragment.HiltFragment
    public void onDestroy() {
        com.vinfast.companion.core.utils.gallery.GalleryManager.a.e(this.identifier);
        super.onDestroy();
    }

    @Override // com.vinfast.companion.core.base.fragment.BaseFragment
    public void y1(android.view.View view, android.os.Bundle savedInstanceState) {
        kotlin.jvm.internal.Intrinsics.l(view, "view");
        android.os.Bundle arguments = getArguments();
        this.identifier = arguments != null ? arguments.getLong("GALLERY_IDENTIFIER", 0L) : 0L;
        android.os.Bundle arguments2 = getArguments();
        this.isContainRemove = arguments2 != null ? arguments2.getBoolean("GALLERY_IS_CONTAIN_REMOVE", false) : false;
        android.os.Bundle arguments3 = getArguments();
        this.isShowImageInfo = arguments3 != null ? arguments3.getBoolean("GALLERY_IS_SHOW_INFO", true) : true;
        com.vinfast.companion.core.utils.gallery.GalleryManager.a.d(this.identifier);
        t2();
        r2();
    }
}
