package com.quansu.heifengwuliu.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.ViewGroup
import com.quansu.heifengwuliu.adapter.OrderListAdapter
import com.quansu.heifengwuliu.base.MBRFragment
import com.quansu.heifengwuliu.databinding.FragmentOrderListBinding
import com.quansu.heifengwuliu.model.Order
import com.quansu.heifengwuliu.utils.net.NetEngine
import com.quansu.heifengwuliu.vmodel.OrderListVModel
import com.ysnows.base.net.IResponse
import io.reactivex.Observable

class OrderListFragment : MBRFragment<OrderListVModel, OrderListAdapter, FragmentOrderListBinding>() {

    override fun init(savedInstanceState: Bundle?) {
        super.init(savedInstanceState)

        adapter().setList(arrayListOf(Order(1), Order(1), Order(1), Order(1), Order(1), Order(1), Order(1), Order(1), Order(1), Order(1), Order(1), Order(1), Order(1), Order(1), Order(1), Order(1)
        ))

    }

    override fun initAdapter(): OrderListAdapter {
        return OrderListAdapter()
    }

    override fun api(): Observable<out IResponse<*>> {
        return NetEngine.service.taskList("", vm.repository().autoPage())
    }

    override fun binding(inflater: LayoutInflater, container: ViewGroup?): FragmentOrderListBinding {
        return FragmentOrderListBinding.inflate(layoutInflater, container, false)
    }

    override fun title(): String? {
        return null
    }

    override fun vmClass(): Class<OrderListVModel> {
        return OrderListVModel::class.java
    }
}