package com.wdkl.app.ncs.callingbed.fragment

import android.support.v7.widget.LinearLayoutManager
import com.enation.javashop.net.engine.model.NetState
import com.wdkl.app.ncs.callingbed.R
import com.wdkl.app.ncs.callingbed.adapter.CostItemAdapter
import com.wdkl.app.ncs.callingbed.databinding.CostViewBinding
import com.wdkl.app.ncs.callingbed.launch.CallingbedLaunch
import com.wdkl.ncs.android.lib.base.BaseFragment
import com.wdkl.ncs.android.lib.utils.debugLog
import com.wdkl.ncs.android.lib.utils.errorLog
import com.wdkl.ncs.android.lib.utils.showMessage
import com.wdkl.ncs.android.lib.vo.filter
import com.wdkl.ncs.android.middleware.common.Constant
import com.wdkl.ncs.android.middleware.logic.contract.callingbed.CostFragmentContract
import com.wdkl.ncs.android.middleware.logic.presenter.callingbed.CostFragmentPresenter
import com.wdkl.ncs.android.middleware.model.vo.CustomerFeeConfigByGroupNameVO
import kotlinx.android.synthetic.main.cost_view.*

class CostFragment : BaseFragment<CostFragmentPresenter, CostViewBinding>(), CostFragmentContract.View {
    val TAG = "CostFragment"

    override fun getLayId(): Int {
        return R.layout.cost_view
    }

    override fun bindDagger() {
        CallingbedLaunch.component.inject(this)
    }

    override fun init() {
        if (Constant.CUSTOM_ID != -1) {
            presenter.loadCustomCost(Constant.CUSTOM_ID)
        } else {
            showMessage("No custom id")
        }
    }

    override fun bindEvent() {
        //
    }

    override fun destory() {
        //
    }

    override fun showCustomCost(cost: ArrayList<CustomerFeeConfigByGroupNameVO>) {
        val layoutManager = LinearLayoutManager(activity)
        rv_cost_main_view.layoutManager = layoutManager
        rv_cost_main_view.adapter = CostItemAdapter(activity, cost)
    }

    override fun onError(message: String, type: Int) {
        showMessage(message)
    }

    override fun complete(message: String, type: Int) {
        //
    }

    override fun start() {
        //
    }

    override fun onNoNet() {
        showMessage("No network")
    }

    override fun networkMonitor(state: NetState) {
        state.filter(onWifi = {

        },onMobile = {

        },offline = {

        })
    }
}