package bums.lunatic.launcher.model

import android.view.View
import bums.lunatic.launcher.R
import bums.lunatic.launcher.helpers.PrefHelper

enum class RssDataType {
    NO_DATA,
    YOUTUBE,
    NEWSFEED,
    GURU,
    MOST,
    TAGS,
    REDDIT,
    REDDIT_NSFW,
    DOTAX,
    FMKORAE,
    DCINSIDE,
    RULIWEB,
    CLIEN,
    THEQOO,
    ARCA;

    fun getResId() = when (this) {
        YOUTUBE -> R.drawable.youtube
        REDDIT, REDDIT_NSFW -> R.drawable.reddit
        DOTAX -> R.drawable.daum
        FMKORAE -> R.drawable.fmk
        DCINSIDE -> R.drawable.dcinside
        ARCA -> R.drawable.arca
        else -> {
            0
        }
    }

    fun defaultImgSize() = when (this) {
        YOUTUBE -> 200
        REDDIT_NSFW,GURU,MOST -> 360
        else -> { 120 }
    }

    fun getDefaultVisibiliy() = when (this) {
        REDDIT_NSFW,GURU,MOST,NEWSFEED -> View.GONE
        else -> { View.VISIBLE }
    }

    fun isOn(block : ()->Unit) {
        if(PrefHelper.getBoolean(name,false)) {
            block.invoke()
        }
    }
}

interface RssDataInterface {
    fun title() : String
    fun thumbnailUrl() : String
    fun originPage() : String
    fun description() : String
    fun pubDate() : Long
    fun category() : RssDataType
    fun getCho() : String?

}