package com.zxhy.simplefilesmanager.simpledata

import java.io.File

abstract class JoFileJo(
    var fName: String = "",
    val jisd: String = "",
    var isSelected: Boolean = false,
    val sdadsd: Int = 0,
    val sdsadgb: Float = 0.2f,
    var path: String = ""
) {

    companion object {
        fun isDir(file: File): Boolean {
            return file.isDirectory
        }

        fun isEmptyFile(file: File): Boolean {
            return file.isFile && file.length() == 0L
        }

        fun isImage(file: File): Boolean {
            return file.name.contains(".jpg") or
                    file.name.contains(".png") or
                    file.name.contains(".gif")
        }

        fun isVideo(file: File): Boolean {
            return file.name.contains(".mp4") or
                    file.name.contains(".avi") or
                    file.name.contains(".flv") or
                    file.name.contains(".rmvb") or
                    file.name.contains(".mkv")
        }

        fun isAudio(file: File): Boolean {
            return file.name.contains(".mp3") or
                    file.name.contains(".aac") or
                    file.name.contains(".ogg") or
                    file.name.contains(".aac")
        }

        fun isLargeFile(file: File): Boolean {
            return file.length() >= 10 * 1024 * 1024
        }


        fun isZip(file: File): Boolean {
            return file.name.contains(".zip")
        }

        fun isApk(file: File): Boolean {
            return file.name.contains(".apk")
        }

        fun isDocument(file: File): Boolean {
            return file.name.contains(".doc") or
                    file.name.contains(".docx") or
                    file.name.contains(".ppt") or
                    file.name.contains(".pptx") or
                    file.name.contains(".xls") or
                    file.name.contains(".xlsx") or
                    file.name.contains(".txt") or
                    file.name.contains(".pdf")
        }
    }

    fun toFile(): File {
        return File(path)
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as JoFileJo

        if (fName != other.fName) return false
        if (jisd != other.jisd) return false
        if (isSelected != other.isSelected) return false
        if (sdadsd != other.sdadsd) return false
        if (sdsadgb != other.sdsadgb) return false

        return true
    }

    override fun hashCode(): Int {
        var result = fName.hashCode()
        result = 31 * result + jisd.hashCode()
        result = 31 * result + isSelected.hashCode()
        result = 31 * result + sdadsd
        result = 31 * result + sdsadgb.hashCode()
        return result
    }


}