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

import X.4Ms;
import X.C42016kJ;
import X.OZG;
import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import com.bytedance.covode.number.Covode;
import com.google.gson.a.c;
import com.ss.android.ugc.aweme.draft.model.DraftEditTransferModel;
import com.ss.android.ugc.aweme.editSticker.model.CoverPublishModel;
import com.ss.android.ugc.aweme.shortvideo.BaseShortVideoContext;
import com.ss.android.ugc.aweme.shortvideo.edit.model.EditVideoSegment;
import com.ss.android.ugc.aweme.shortvideo.model.AVUploadSaveModel;
import com.ss.android.ugc.aweme.shortvideo.model.ExtractFramesModel;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;

public class PhotoMovieContext extends BaseShortVideoContext implements Parcelable {
    public static final Parcelable.Creator<PhotoMovieContext> CREATOR = new Parcelable.Creator<PhotoMovieContext>() {
        static {
            Covode.recordClassIndex(96875);
        }

        public final /* bridge */ /* synthetic */ Object[] newArray(int i) {
            return new PhotoMovieContext[i];
        }

        public final /* synthetic */ Object createFromParcel(Parcel parcel) {
            return new PhotoMovieContext(parcel);
        }
    };
    @c(LIZ = "coverPublishModel")
    public CoverPublishModel coverPublishModel;
    @c(LIZ = "creationId")
    public String creationId;
    @c(LIZ = "creative_version")
    public int creativeVersion;
    @c(LIZ = "draftId")
    public int draftId;
    @c(LIZ = "extract_model")
    public ExtractFramesModel extractFramesModel;
    @c(LIZ = "is_background_publish")
    public boolean isBackgroundPublish;
    @c(LIZ = "isMusicIllegal")
    public boolean isMusicIllegal;
    @c(LIZ = "is_open_foreground_publish")
    public boolean isOpenForegroundPublish;
    @c(LIZ = "mCoverStartTm")
    public float mCoverStartTm;
    @c(LIZ = "mFilterId")
    public int mFilterId;
    @c(LIZ = "mFilterName")
    public String mFilterName;
    @c(LIZ = "mFilterPath")
    public String mFilterPath;
    @c(LIZ = "mFinalVideoTmpPath")
    public String mFinalVideoTmpPath;
    @c(LIZ = "mFrom")
    public int mFrom;
    @c(LIZ = "mHeight")
    public int mHeight;
    @c(LIZ = "mImageList")
    public List<String> mImageList;
    @c(LIZ = "mInputAudioPath")
    public String mInputAudioPath;
    @c(LIZ = "mMusic")
    public OZG mMusic;
    @c(LIZ = "mMusicList")
    public List<OZG> mMusicList;
    @c(LIZ = "mMusicPath")
    public String mMusicPath;
    @c(LIZ = "mOutputVideoPath")
    public String mOutputVideoPath;
    @c(LIZ = "mPlayType")
    public int mPlayType;
    @c(LIZ = "mRealImageCount")
    public int mRealImageCount;
    @c(LIZ = "save_model")
    public AVUploadSaveModel mSaveModel;
    @c(LIZ = "mWidth")
    public int mWidth;
    @c(LIZ = "music_origin")
    public String musicOrigin;
    @c(LIZ = "newDraftId")
    public String newDraftId;
    @c(LIZ = "photo_time")
    public int photoTime;
    @c(LIZ = "shop_draft_id")
    public String shopDraftId;
    @c(LIZ = "startTime")
    public long startTime;
    @c(LIZ = "trans_time")
    public int transTime;
    @c(LIZ = "video_cover_path")
    public String videoCoverPath;

    public int describeContents() {
        return 0;
    }

    public String getCreationId() {
        return this.creationId;
    }

    public int getCreativeVersion() {
        return this.creativeVersion;
    }

    static {
        Covode.recordClassIndex(96874);
    }

    public CoverPublishModel getCoverPublishModel() {
        if (this.coverPublishModel == null) {
            this.coverPublishModel = new CoverPublishModel();
        }
        return this.coverPublishModel;
    }

    public int getImageCount() {
        List<String> list = this.mImageList;
        if (list == null) {
            return 0;
        }
        return list.size();
    }

    public String getLocalTempPath() {
        AVUploadSaveModel aVUploadSaveModel = this.mSaveModel;
        if (aVUploadSaveModel == null) {
            return null;
        }
        return aVUploadSaveModel.getLocalTempPath();
    }

    public boolean isSaveLocal() {
        AVUploadSaveModel aVUploadSaveModel = this.mSaveModel;
        if (aVUploadSaveModel == null || !aVUploadSaveModel.isSaveLocal()) {
            return false;
        }
        return true;
    }

    public boolean isSaveLocalWithWaterMark() {
        AVUploadSaveModel aVUploadSaveModel = this.mSaveModel;
        if (aVUploadSaveModel == null || !aVUploadSaveModel.isSaveLocalWithWaterMark()) {
            return false;
        }
        return true;
    }

    public boolean isSaveLocalWithoutWaterMark() {
        AVUploadSaveModel aVUploadSaveModel = this.mSaveModel;
        if (aVUploadSaveModel == null || aVUploadSaveModel.isWaterMark()) {
            return false;
        }
        return true;
    }

    public boolean isSaveToAlbum() {
        AVUploadSaveModel aVUploadSaveModel = this.mSaveModel;
        if (aVUploadSaveModel == null || !aVUploadSaveModel.getSaveToAlbum()) {
            return false;
        }
        return true;
    }

    public boolean isSaveToLocalPathInsteadOfAlbum() {
        AVUploadSaveModel aVUploadSaveModel = this.mSaveModel;
        if (aVUploadSaveModel == null || !aVUploadSaveModel.isSaveToAppPathInsteadOfAlbum()) {
            return false;
        }
        return true;
    }

    public PhotoMovieContext() {
        this.mMusicList = new ArrayList();
        this.creativeVersion = 0;
        this.newDraftId = "";
    }

    public void setCoverPublishModel(CoverPublishModel coverPublishModel2) {
        this.coverPublishModel = coverPublishModel2;
    }

    public static File INVOKEVIRTUAL_com_ss_android_ugc_aweme_photomovie_PhotoMovieContext_com_ss_android_ugc_aweme_lancet_ContextLancet_getCacheDir(Context context) {
        if (4Ms.LIZIZ != null && 4Ms.LJ) {
            return 4Ms.LIZIZ;
        }
        File cacheDir = context.getCacheDir();
        4Ms.LIZIZ = cacheDir;
        return cacheDir;
    }

    private String generateTempCoverPath(Context context) {
        return getCacheDir(context) + getRandomFileName("_cover.png");
    }

    private String getCacheDir(Context context) {
        return INVOKEVIRTUAL_com_ss_android_ugc_aweme_photomovie_PhotoMovieContext_com_ss_android_ugc_aweme_lancet_ContextLancet_getCacheDir(context).getPath() + File.separator;
    }

    public String getVideoCoverPath(Context context) {
        if (TextUtils.isEmpty(this.videoCoverPath)) {
            this.videoCoverPath = generateTempCoverPath(context);
        }
        return this.videoCoverPath;
    }

    private String getRandomFileName(String str) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd-HHmmssSSS", Locale.US);
        Date time = Calendar.getInstance(TimeZone.getTimeZone("GMT+8")).getTime();
        return simpleDateFormat.format(time) + str;
    }

    public static PhotoMovieContext convertFromDraft(C42016kJ r4) {
        PhotoMovieContext photoMovieContext = r4.LIZLLL;
        if (photoMovieContext == null || r4.LIZJ == null) {
            return null;
        }
        photoMovieContext.challenges = r4.LIZJ.LIZJ;
        photoMovieContext.title = r4.LIZJ.LIZ;
        photoMovieContext.structList = r4.LIZJ.LIZIZ;
        photoMovieContext.isPrivate = r4.LJJIIZI;
        photoMovieContext.excludeUserList = r4.LJJJJZ.LLIFFJFJJ;
        photoMovieContext.allowRecommend = r4.LJJJJZ.LLIIII;
        photoMovieContext.geofencingSetting = r4.LJJJJZ.LLI;
        photoMovieContext.mIsFromDraft = true;
        photoMovieContext.mDraftToEditFrom = r4.LJIJJLI;
        photoMovieContext.isMusicIllegal = r4.LIZLLL.isMusicIllegal;
        photoMovieContext.mFrom = 1;
        photoMovieContext.mSaveModel = r4.LJJJJZ.LJJIIZI;
        photoMovieContext.draftEditTransferModel = new DraftEditTransferModel(r4.LJIJI(), (List<? extends EditVideoSegment>) null);
        return photoMovieContext;
    }

    public PhotoMovieContext(Parcel parcel) {
        super(parcel);
        this.mMusicList = new ArrayList();
        boolean z = false;
        this.creativeVersion = 0;
        this.newDraftId = "";
        this.mFinalVideoTmpPath = parcel.readString();
        this.mImageList = parcel.createStringArrayList();
        this.musicOrigin = parcel.readString();
        this.mMusicPath = parcel.readString();
        this.mHeight = parcel.readInt();
        this.mWidth = parcel.readInt();
        this.mPlayType = parcel.readInt();
        this.mOutputVideoPath = parcel.readString();
        this.mInputAudioPath = parcel.readString();
        this.mCoverStartTm = parcel.readFloat();
        this.mMusic = parcel.readSerializable();
        this.mFilterPath = parcel.readString();
        this.mFilterName = parcel.readString();
        this.mFilterId = parcel.readInt();
        this.mFrom = parcel.readInt();
        this.creationId = parcel.readString();
        this.creativeVersion = parcel.readInt();
        this.draftId = parcel.readInt();
        this.newDraftId = parcel.readString();
        this.shopDraftId = parcel.readString();
        this.mSaveModel = (AVUploadSaveModel) parcel.readParcelable(AVUploadSaveModel.class.getClassLoader());
        this.extractFramesModel = (ExtractFramesModel) parcel.readSerializable();
        this.photoTime = parcel.readInt();
        this.transTime = parcel.readInt();
        this.mRealImageCount = parcel.readInt();
        this.coverPublishModel = (CoverPublishModel) parcel.readParcelable(CoverPublishModel.class.getClassLoader());
        this.videoCoverPath = parcel.readString();
        this.mDraftToEditFrom = parcel.readInt();
        this.isMusicIllegal = parcel.readByte() != 0 ? true : z;
    }

    public void writeToParcel(Parcel parcel, int i) {
        super.writeToParcel(parcel, i);
        parcel.writeString(this.mFinalVideoTmpPath);
        parcel.writeStringList(this.mImageList);
        parcel.writeString(this.musicOrigin);
        parcel.writeString(this.mMusicPath);
        parcel.writeInt(this.mHeight);
        parcel.writeInt(this.mWidth);
        parcel.writeInt(this.mPlayType);
        parcel.writeString(this.mOutputVideoPath);
        parcel.writeString(this.mInputAudioPath);
        parcel.writeFloat(this.mCoverStartTm);
        parcel.writeSerializable(this.mMusic);
        parcel.writeString(this.mFilterPath);
        parcel.writeString(this.mFilterName);
        parcel.writeInt(this.mFilterId);
        parcel.writeInt(this.mFrom);
        parcel.writeString(this.creationId);
        parcel.writeInt(this.creativeVersion);
        parcel.writeInt(this.draftId);
        parcel.writeString(this.newDraftId);
        parcel.writeString(this.shopDraftId);
        parcel.writeParcelable(this.mSaveModel, i);
        parcel.writeSerializable(this.extractFramesModel);
        parcel.writeInt(this.photoTime);
        parcel.writeInt(this.transTime);
        parcel.writeInt(this.mRealImageCount);
        parcel.writeParcelable(this.coverPublishModel, i);
        parcel.writeString(this.videoCoverPath);
        parcel.writeInt(this.mDraftToEditFrom);
        parcel.writeByte(this.isMusicIllegal ? (byte) 1 : 0);
    }
}
