package rasel.lunar.launcher.model

import rasel.lunar.launcher.utils.JamoUtils

open class RssItem : RssDataInterface {
    var model : String = ""
    var title : String = ""
    var pageLink : String = ""
    var image : String = ""
    var tags : String = ""
    var date : Long = 0L

    constructor(
        model: String,
        title: String,
        pageLink: String,
        image: String,
        tags: String,
        date: Long
    ) {
        this.model = model
        this.title = title
        this.pageLink = pageLink
        this.image = image
        this.tags = tags
        this.date = date
    }

    constructor()

    override fun title(): String {
        return title
    }

    override fun thumbnailUrl(): String {
        return image
    }

    override fun originPage(): String {
        return pageLink
    }

    override fun description(): String {
        return tags.plus(", ").plus(model).plus(", ").plus(category())
    }

    override fun pubDate(): Long {
        return date
    }

    override fun category(): RssDataType {
        return RssDataType.GURU
    }

    fun isValid() = (((pageLink.length ?:0) > 0) && ((title.length ?:0) > 0)&& ((image.length ?:0) > 0))

    override fun getCho(): String? {
        return JamoUtils.split(title!!).joinToString("")
    }
}

class MostItem : RssItem , RssDataInterface {

    constructor() : super()

    override fun title(): String {
        return title
    }

    override fun thumbnailUrl(): String {
        return image
    }

    override fun originPage(): String {
        return pageLink
    }

    override fun description(): String {
        return tags.plus(", ").plus(model).plus(", ").plus(category())
    }

    override fun pubDate(): Long {
        return date
    }

    override fun category(): RssDataType {
        return RssDataType.Most
    }

    override fun getCho(): String? {
        return JamoUtils.split(title!!).joinToString("")
    }
}
