package com.gh.download.simple

import androidx.room.TypeConverter
import com.lg.download.DownloadStatus

class DownloadStatusConverter {
    @TypeConverter
    fun fromGameStatus(status: DownloadStatus): Int {
        return when (status) {
            DownloadStatus.UNKNOWN -> 0
            DownloadStatus.DOWNLOADING -> 1
            DownloadStatus.PAUSED -> 2
            DownloadStatus.COMPLETED -> 3
            DownloadStatus.CANCELLED -> 4
            DownloadStatus.AUTOPAUSED -> 5
            DownloadStatus.WAITINGWIFI -> 6
            DownloadStatus.QUEUED -> 7
        }
    }

    @TypeConverter
    fun toGameStatus(status: Int): DownloadStatus {
        return when (status) {
            0 -> DownloadStatus.UNKNOWN
            1 -> DownloadStatus.DOWNLOADING
            2 -> DownloadStatus.PAUSED
            3 -> DownloadStatus.COMPLETED
            4 -> DownloadStatus.CANCELLED
            5 -> DownloadStatus.AUTOPAUSED
            6 -> DownloadStatus.WAITINGWIFI
            7 -> DownloadStatus.QUEUED
            else -> DownloadStatus.UNKNOWN
        }
    }
}