package com.ss.android.ugc.aweme.services;

import X.1hK;
import X.2HN;
import X.2Pr;
import X.6if;
import X.6pN;
import X.C3243Ndm;
import X.C5906Ofd;
import X.C5924Ofv;
import X.D0R;
import X.DVG;
import X.Ls2;
import X.M12;
import X.NB5;
import X.ODZ;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import com.bytedance.covode.number.Covode;
import com.bytedance.jedi.arch.BaseJediViewModel;
import com.ss.android.ugc.aweme.mediachoose.helper.MediaModel;
import com.ss.android.ugc.aweme.shortvideo.ShortVideoContext;
import com.ss.android.ugc.aweme.shortvideo.mvtemplate.choosemedia.ChooseMediaViewModel;
import com.ss.android.ugc.aweme.shortvideo.mvtemplate.choosemedia.an;
import java.util.List;
import kotlin.h.b.n;

public final class AlbumServiceImpl implements 6if {
    public static final Companion Companion = new Companion((2HN) null);

    static {
        Covode.recordClassIndex(105005);
    }

    public static final class Companion {
        static {
            Covode.recordClassIndex(105006);
        }

        public Companion() {
        }

        public /* synthetic */ Companion(2HN r1) {
            this();
        }
    }

    public final void subscribeAlbumClose(1hK r4, Ls2<2Pr> ls2) {
        M12.LIZ(r4, ls2);
        ChooseMediaViewModel LIZ = DVG.LIZ(r4).LIZ(ChooseMediaViewModel.class);
        n.LIZIZ(LIZ, "");
        BaseJediViewModel.LIZIZ(LIZ, r4, AlbumServiceImpl$subscribeAlbumClose$1.INSTANCE, new AlbumServiceImpl$subscribeAlbumClose$2(ls2));
    }

    public final void subscribeAlbumOpen(1hK r4, Ls2<2Pr> ls2) {
        M12.LIZ(r4, ls2);
        ChooseMediaViewModel LIZ = DVG.LIZ(r4).LIZ(ChooseMediaViewModel.class);
        n.LIZIZ(LIZ, "");
        BaseJediViewModel.LIZIZ(LIZ, r4, AlbumServiceImpl$subscribeAlbumOpen$1.INSTANCE, new AlbumServiceImpl$subscribeAlbumOpen$2(ls2));
    }

    private final Bundle generateAlbumBundle(ShortVideoContext shortVideoContext, Bundle bundle) {
        Bundle bundle2 = new Bundle();
        bundle2.putInt("key_support_flag", 5);
        bundle2.putLong("Key_min_duration", 1000);
        bundle2.putInt("key_photo_select_min_count", 1);
        bundle2.putInt("key_photo_select_max_count", 10);
        bundle2.putInt("key_video_select_min_count", 1);
        bundle2.putInt("key_video_select_max_count", 10);
        bundle2.putInt("key_choose_scene", 11);
        bundle2.putParcelable("key_short_video_context", shortVideoContext);
        bundle2.putInt("key_choose_request_code", 1);
        bundle2.putBoolean("from_upload_btn_click", true);
        bundle2.putLong("invoke_uploadpage_time", System.currentTimeMillis());
        bundle2.putAll(bundle);
        return bundle2;
    }

    public final D0R<Boolean, Integer, Long> checkMediaDurationValid(Context context, List<? extends MediaModel> list, long j, long j2) {
        List<? extends MediaModel> list2 = list;
        Context context2 = context;
        M12.LIZ(context2, list2);
        return 6pN.LIZ.LIZ(context2, list2, j, j2);
    }

    public final C3243Ndm openAlbum(ShortVideoContext shortVideoContext, 1hK r6, int i, NB5 nb5, Bundle bundle) {
        M12.LIZ(shortVideoContext, r6, nb5, bundle);
        an anVar = new an();
        anVar.LJIJ = generateAlbumBundle(shortVideoContext, bundle);
        anVar.LJJLIIIJILLIZJL = nb5;
        anVar.LJJLIIIJ = true;
        ODZ LIZ = C5906Ofd.LIZ((Activity) r6, (Class<? extends C5924Ofv>) an.class);
        LIZ.LJ = false;
        LIZ.LIZ("attachMvChoosePhotoScene");
        LIZ.LJFF = new AlbumServiceImpl$openAlbum$delegate$1(anVar);
        LIZ.LIZIZ = false;
        LIZ.LIZJ = false;
        LIZ.LIZLLL = i;
        C3243Ndm LIZ2 = LIZ.LIZ();
        n.LIZIZ(LIZ2, "");
        return LIZ2;
    }
}
