package com.adealink.weparty.commonui.mediapicker.imageselect.model

import android.os.Parcelable
import com.adealink.weparty.commonui.mediapicker.imageselect.util.PictureMimeType
import kotlinx.parcelize.IgnoredOnParcel
import kotlinx.parcelize.Parcelize

sealed class MediaInfo

@Parcelize
class LocalMedia(
    /** original uri  */
    var uri: String? = null,
    /** original path  */
    var path: String? = null,
    /** video duration  */
    var duration: Long = 0,
    /** If the selected  */
    var isChecked: Boolean = false,
    /** media position of list  */
    var position: Int = 0,
    /** The media number of qq choose styles  */
    var num: Int = 0,
    /** The media resource type  */
    var mimeType: String? = null,
    /** type  */
    var ofAllType: Int = -1,
    /** image or video width  */
    var width: Int = 0,
    /** image or video height  */
    var height: Int = 0,
    /** file size  */
    var size: Long = 0,
    /** Whether the original image is displayed  */
    var isOriginal: Boolean = false,
): MediaInfo(), Parcelable {

    fun isImage(): Boolean {
        return mimeType?.startsWith("image") == true
    }

    fun isGIF(): Boolean {
        return PictureMimeType.isGif(mimeType)
    }

    fun isVideo(): Boolean {
        return mimeType?.startsWith("video") == true
    }

    fun isAudio(): Boolean {
        return mimeType?.startsWith("audio") == true
    }
}

@Parcelize
data class LocalMediaFolder(
    /** Folder name  */
    var name: String? = null,

    /** Folder first path  */
    var firstImagePath: String? = null,

    /** Folder first uri  */
    var firstImageUri: String? = null,

    /** Folder media num  */
    var imageNum: Int = 0,

    /** If the selected num  */
    var checkedNum: Int = 0,

    /** If the selected  */
    var isChecked: Boolean = false,

    /** type  */
    var ofAllType: Int = -1,

    /** Whether or not the camera  */
    var isCameraFolder: Boolean = false,

    ): Parcelable {
    @IgnoredOnParcel
    private var _images: ArrayList<LocalMedia>? = ArrayList()

    fun getImages(): ArrayList<LocalMedia> {
        if (_images == null) {
            _images = ArrayList()
        }
        return _images ?: arrayListOf()
    }

    fun setImages(images: ArrayList<LocalMedia>?) {
        this._images = images
    }
}

/**
 * 添加入口占位
 */
data class AddInfo(
    val mediaType: MediaType
) : MediaInfo()

