package com.develop.main.init.ui.adapter

import com.chad.library.adapter.base.BaseProviderMultiAdapter
import com.chad.library.adapter.base.module.LoadMoreModule
import com.develop.food.base.data.model.*
import com.develop.main.R
import com.develop.main.init.ui.provider.*

class RecipesMainAdapter : BaseProviderMultiAdapter<Any>(), LoadMoreModule {

    var homeBannerProvider = HomeBannerProvider()
    var functionProvider = FunctionProvider()
    var categoryTitleProvider = CategoryTitleProvider()
    var commonSearchProvider = CommonSearchProvider()
    var categoryTabProvider = CategoryTabProvider()
    var recipesContentProvider = RecipesContentProvider()

    init {
        addItemProvider(homeBannerProvider)
        addItemProvider(categoryTitleProvider)
        addItemProvider(functionProvider)
        addItemProvider(recipesContentProvider)
        addItemProvider(commonSearchProvider)
        addItemProvider(categoryTabProvider)
    }

    override fun getItemType(data: List<Any>, position: Int): Int {
        return when (data[position]) {
            is String -> {
                CATEGORY_TITLE_TAG
            }
            is FoodContentModel -> {
                CONTENT_TAG
            }
            is FilterSortModel -> {
                FUNCTION_TAG
            }
            is HomeBannerListModel -> {
                BANNER_TAG
            }

            is CommonSearchModel -> {
                SEARCH_TAG
            }
            is CategoryModel -> {
                CATEGORY_TAB_TAG
            }
            else -> {
                CONTENT_TAG
            }
        }
    }


    companion object {
        const val BANNER_TAG = 1
        const val FUNCTION_TAG = 2
        const val CATEGORY_TITLE_TAG = 3
        const val CONTENT_TAG = 4
        const val SEARCH_TAG = 5
        const val CATEGORY_TAB_TAG = 6
    }

}