package com.adealink.weparty.imageselect.util

import android.text.TextUtils

object PictureMimeType {
    const val PNG = ".png"

    const val MIME_TYPE_IMAGE_JPEG: String = "image/jpeg"
    const val MIME_TYPE_VIDEO_MP4: String = "video/mp4"

    const val MIME_TYPE_PREFIX_IMAGE: String = "image"
    const val MIME_TYPE_PREFIX_VIDEO: String = "video"

    /**
     * 是否是gif
     *
     * @param mimeType
     * @return
     */
    fun isGif(mimeType: String?): Boolean {
        return mimeType != null && (mimeType == "image/gif" || mimeType == "image/GIF")
    }

    /**
     * 是否是视频
     *
     * @param mimeType
     * @return
     */
    fun eqVideo(mimeType: String?): Boolean {
        return mimeType != null && mimeType.startsWith(MIME_TYPE_PREFIX_VIDEO)
    }

    /**
     * 是否是图片
     *
     * @param mimeType
     * @return
     */
    fun eqImage(mimeType: String?): Boolean {
        return mimeType != null && mimeType.startsWith(MIME_TYPE_PREFIX_IMAGE)
    }

    /**
     * 是否是网络图片
     *
     * @param path
     * @return
     */
    fun isHttp(path: String): Boolean {
        return !TextUtils.isEmpty(path) && (path.startsWith("http") || path.startsWith("https"))
    }

}
