package com.base.datarecovery.utils

import com.base.datarecovery.activity.newfunction.WeatherUtils
import com.base.datarecovery.bean.ConstObject

object WeatherInfoStringManager {
    private val functionCopyMap: HashMap<Int, ArrayList<String>> = hashMapOf()
    private var currentIndexMap: HashMap<Int, Int> = hashMapOf()

    private fun getCopyList(actionId: Int): ArrayList<String> {

        if (functionCopyMap[actionId] == null) {
            functionCopyMap[actionId] = arrayListOf()
        }
        val list = functionCopyMap[actionId] ?: arrayListOf()
        when (actionId) {
            ConstObject.ID_WEATHER ->{
                val city = WeatherUtils.getWeatherEntity()?.city ?: ""
                list.add("Sunny skies for many, but rain or snow for some over the next few days. How about ${city}? Tap to check!")
                list.add("Sunshine for many, but rain or snow forecast for some in the next few days. What’s ${city}’s forecast? Tap to find out!")
                list.add("Sunny days for many, but rain or snow for some in the next few days. What’s ${city} like? Tap to check!")
                list.add("Sun for many, but rain or snow for some in the next few days. How about ${city}? Tap to discover!")
            }
        }
        return list
    }

    fun getNextCopy(actionId: Int): String {

        val currentIndex = currentIndexMap[actionId] ?: 0
        val copyList = getCopyList(actionId)
        val copy = copyList[currentIndex]
        currentIndexMap[actionId] = (currentIndex + 1) % copyList.size
        return copy
    }
}