|
@@ -0,0 +1,144 @@
|
|
|
|
+package com.wdkl.app.ncs.callingbed.fragment
|
|
|
|
+
|
|
|
|
+import android.support.v7.widget.LinearLayoutManager
|
|
|
|
+import android.util.Log
|
|
|
|
+import com.enation.javashop.net.engine.model.NetState
|
|
|
|
+import com.wdkl.app.ncs.callingbed.R
|
|
|
|
+import com.wdkl.app.ncs.callingbed.adapter.CostItemAdapter2
|
|
|
|
+import com.wdkl.app.ncs.callingbed.databinding.CostViewLayBinding
|
|
|
|
+import com.wdkl.app.ncs.callingbed.launch.CallingbedLaunch
|
|
|
|
+import com.wdkl.ncs.android.lib.base.BaseFragment
|
|
|
|
+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.common.MessageEvent
|
|
|
|
+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.CustomerFeeConfig
|
|
|
|
+import com.wdkl.ncs.android.middleware.model.vo.CustomerFeeConfigByGroupNameVO
|
|
|
|
+import com.wdkl.ncs.android.middleware.model.vo.CustomerFeeConfigVO
|
|
|
|
+import kotlinx.android.synthetic.main.cost_view_lay.*
|
|
|
|
+import org.greenrobot.eventbus.EventBus
|
|
|
|
+import org.greenrobot.eventbus.Subscribe
|
|
|
|
+import org.greenrobot.eventbus.ThreadMode
|
|
|
|
+
|
|
|
|
+class CostFragment2 : BaseFragment<CostFragmentPresenter, CostViewLayBinding>(), CostFragmentContract.View {
|
|
|
|
+
|
|
|
|
+ private var pageNo = 1
|
|
|
|
+ private val pageSize = 2
|
|
|
|
+ private lateinit var adapter: CostItemAdapter2
|
|
|
|
+ private var totalSize = 0
|
|
|
|
+
|
|
|
|
+ override fun getLayId(): Int {
|
|
|
|
+ return R.layout.cost_view_lay
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun bindDagger() {
|
|
|
|
+ CallingbedLaunch.component.inject(this)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun init() {
|
|
|
|
+ adapter = CostItemAdapter2(activity, ArrayList())
|
|
|
|
+ val layoutManager = LinearLayoutManager(activity)
|
|
|
|
+ rv_cost_main_view.layoutManager = layoutManager
|
|
|
|
+ rv_cost_main_view.adapter = adapter
|
|
|
|
+
|
|
|
|
+ if (Constant.CUSTOM_ID != -1) {
|
|
|
|
+ presenter.loadCustomCostByPage(pageNo, pageSize, Constant.CUSTOM_ID)
|
|
|
|
+ } else {
|
|
|
|
+ showMessage("no custom id")
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun onStart() {
|
|
|
|
+ EventBus.getDefault().register(this)
|
|
|
|
+ super.onStart()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun onStop() {
|
|
|
|
+ EventBus.getDefault().unregister(this)
|
|
|
|
+ super.onStop()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun bindEvent() {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun destory() {
|
|
|
|
+ //
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun showCustomCost(cost: ArrayList<CustomerFeeConfigByGroupNameVO>) {
|
|
|
|
+ //
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun showCustomCost2(customFees: CustomerFeeConfig) {
|
|
|
|
+ totalSize = customFees.dataTotal
|
|
|
|
+ if (customFees.data.size > 0) {
|
|
|
|
+ tv_fees_page.text = "" + customFees.pageNo
|
|
|
|
+ adapter.updateCostData(customFees.data, true)
|
|
|
|
+ } else {
|
|
|
|
+ showMessage("No data!")
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun onError(message: String, type: Int) {
|
|
|
|
+ //errorLog("error",message)
|
|
|
|
+ showMessage(message)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun onNoNet() {
|
|
|
|
+ showMessage("none network")
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun complete(message: String, type: Int) {
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun start() {
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun networkMonitor(state: NetState) {
|
|
|
|
+ state.filter(onWifi = {
|
|
|
|
+
|
|
|
|
+ },onMobile = {
|
|
|
|
+
|
|
|
|
+ },offline = {
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
|
+ fun onMoonEvent(messageEvent: MessageEvent) {
|
|
|
|
+ if (messageEvent.type == Constant.EVENT_UPDATE_FEES) {
|
|
|
|
+ if (messageEvent.message is String) {
|
|
|
|
+ val action = messageEvent.message as String
|
|
|
|
+ if (action == "up") {
|
|
|
|
+ if (Constant.CUSTOM_ID != -1) {
|
|
|
|
+ //如果已经是第一页则提示
|
|
|
|
+ if (pageNo <= 1) {
|
|
|
|
+ pageNo = 1
|
|
|
|
+ showMessage(R.string.str_first_page)
|
|
|
|
+ } else {
|
|
|
|
+ pageNo--
|
|
|
|
+ presenter.loadCustomCostByPage(pageNo, pageSize, Constant.CUSTOM_ID)
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ showMessage("no custom id")
|
|
|
|
+ }
|
|
|
|
+ } else if (action == "down") {
|
|
|
|
+ if (Constant.CUSTOM_ID != -1) {
|
|
|
|
+ //如果是最后一页则提示
|
|
|
|
+ if (pageNo * pageSize >= totalSize) {
|
|
|
|
+ showMessage(R.string.str_last_page)
|
|
|
|
+ } else {
|
|
|
|
+ pageNo++
|
|
|
|
+ presenter.loadCustomCostByPage(pageNo, pageSize, Constant.CUSTOM_ID)
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ showMessage("no custom id")
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|