package com.quansu.heifengwuliu.activity

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.view.View
import com.quansu.heifengwuliu.R
import com.quansu.heifengwuliu.adapter.InvoiceAdapter
import com.quansu.heifengwuliu.base.MBRActivity
import com.quansu.heifengwuliu.config.MIntentAction
import com.quansu.heifengwuliu.databinding.ActivityInvoiceBinding
import com.quansu.heifengwuliu.utils.net.NetEngine
import com.quansu.heifengwuliu.vmodel.InvoiceVModel
import com.ysnows.base.net.IResponse
import com.ysnows.base.utils.UiSwitch
import io.reactivex.Observable

class InvoiceActivity : MBRActivity<InvoiceVModel, InvoiceAdapter, ActivityInvoiceBinding>() {

    var k:String=""

    override fun initView(view: View?) {
        super.initView(view)
        titleBar()?.setRightText(getString(R.string.invoice_title))
        titleBar()?.tvRight!!.setOnClickListener {
            //发票抬头

        }
    }


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

    }

    override fun listeners() {
        super.listeners()

    }


    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (MIntentAction.REQUEST_CODE_ONE == requestCode && resultCode == Activity.RESULT_OK) {
            //刷新列表
            onRefresh()
        }
    }

    override fun binding(): ActivityInvoiceBinding {
        return ActivityInvoiceBinding.inflate(layoutInflater)
    }


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

    override fun api(): Observable<out IResponse<*>> {
        return NetEngine.service.myDriver(k, vm?.repository()?.autoPage()!!)
    }

    override fun title(): String? {
        return getString(R.string.invoice)
    }
    override fun vmClass(): Class<InvoiceVModel> {
        return InvoiceVModel::class.java
    }
}
