| | |
| | | package cn.flightfeather.thirdapp.module.nightwork |
| | | |
| | | import android.arch.lifecycle.ViewModelProviders |
| | | import android.content.Intent |
| | | import android.os.Bundle |
| | | import android.support.v7.widget.LinearLayoutManager |
| | | import android.support.v7.widget.RecyclerView |
| | | import android.view.LayoutInflater |
| | | import android.view.View |
| | | import cn.flightfeather.thirdapp.R |
| | | import cn.flightfeather.thirdapp.common.net.ResultCallBack |
| | | import cn.flightfeather.thirdapp.model.bean.NightWorkFileVo |
| | | import cn.flightfeather.thirdapp.module.base.BaseActivity |
| | | import cn.flightfeather.thirdapp.module.common.OfficeFileManageActivity |
| | | import cn.flightfeather.thirdapp.util.CommonUtils |
| | | import cn.flightfeather.thirdapp.view.recyclerview.BaseCustomViewHolder |
| | | import cn.flightfeather.thirdapp.view.recyclerview.EmptyLoadMoreView |
| | | import cn.flightfeather.thirdapp.view.recyclerview.MySection |
| | | import cn.flightfeather.thirdapp.view.recyclerview.RecyclerViewPanel |
| | | import com.chad.library.adapter.base.BaseQuickAdapter |
| | | import com.chad.library.adapter.base.BaseViewHolder |
| | | import com.chad.library.adapter.base.loadmore.LoadMoreView |
| | | import kotlinx.android.synthetic.main.activity_night_work.* |
| | | import kotlinx.android.synthetic.main.layout_toolbar_2.* |
| | | |
| | |
| | | * @author riku |
| | | * Date: 2020/12/24 |
| | | */ |
| | | class NightWorkRecordActivity : BaseActivity(), View.OnClickListener { |
| | | override fun getLayoutId(): Int = R.layout.activity_night_work |
| | | class NightWorkRecordActivity : BaseActivity() { |
| | | |
| | | inner class FileLoadMoreView : LoadMoreView() { |
| | | override fun getLayoutId(): Int = R.layout.item_night_work_no_more |
| | | |
| | | override fun getLoadingViewId(): Int = R.id.no_more |
| | | |
| | | override fun getLoadFailViewId(): Int = R.id.no_more |
| | | |
| | | override fun getLoadEndViewId(): Int = R.id.no_more |
| | | } |
| | | |
| | | lateinit var viewModel: NightWorkViewModel |
| | | |
| | | private lateinit var recyclerViewPanel1: RecyclerViewPanel<NightWorkFileVo> |
| | | |
| | | private lateinit var recyclerViewPanel2: RecyclerViewPanel<NightWorkFileVo> |
| | | |
| | | override fun getLayoutId(): Int = R.layout.activity_night_work |
| | | |
| | | override fun onCreate(savedInstanceState: Bundle?) { |
| | | super.onCreate(savedInstanceState) |
| | |
| | | } |
| | | |
| | | private fun initToolbar() { |
| | | img_back.setOnClickListener(this) |
| | | img_back.setOnClickListener { finish() } |
| | | tv_main_title.text = "夜间施工许可" |
| | | } |
| | | |
| | | /** |
| | | * 最新未读文件 |
| | | */ |
| | | private fun initRecyclerView1() { |
| | | recycler_view |
| | | recyclerViewPanel1 = object : RecyclerViewPanel<NightWorkFileVo>(viewModel.dataLoadModel1, recycler_view, this) { |
| | | private val TYPE_ITEM = 1 |
| | | private val TYPE_EMPTY = 2 |
| | | |
| | | override fun getItemLayoutId(): Int? = R.layout.item_night_work |
| | | |
| | | // override fun getItemLayoutIdMap(): Map<Int, Int> = mapOf( |
| | | // Pair(TYPE_ITEM, R.layout.item_night_work), |
| | | // Pair(TYPE_EMPTY, R.layout.item_night_work_no_more) |
| | | // ) |
| | | |
| | | // override fun convertToSection(list: List<NightWorkFileVo>): MutableList<MySection<NightWorkFileVo>> { |
| | | // val resultList = mutableListOf<MySection<NightWorkFileVo>>() |
| | | // list.forEach { |
| | | // if (it.id != null) { |
| | | // resultList.add(MySection(it, TYPE_ITEM)) |
| | | // } |
| | | // } |
| | | // resultList.add(MySection(NightWorkFileVo(), TYPE_EMPTY)) |
| | | // return resultList |
| | | // } |
| | | |
| | | override fun onBindView(holder: BaseCustomViewHolder, item: MySection<NightWorkFileVo>?) { |
| | | item?.t?.let { vo -> |
| | | // when (holder.itemViewType) { |
| | | // TYPE_ITEM -> { |
| | | // |
| | | // } |
| | | // TYPE_EMPTY -> Unit |
| | | // else -> Unit |
| | | // } |
| | | val time = CommonUtils.getStartEndDate(vo.startDate, vo.endDate) |
| | | holder.setText(R.id.txt_night_work_num, vo.num) |
| | | .setText(R.id.txt_content, vo.applyContent) |
| | | .setText(R.id.txt_time, time) |
| | | .addOnClickListener(R.id.txt_sign) |
| | | } |
| | | } |
| | | |
| | | override fun onItemClick(adapter: BaseQuickAdapter<Any?, BaseViewHolder>, view: View, position: Int, dataList: List<NightWorkFileVo>) { |
| | | super.onItemClick(adapter, view, position, dataList) |
| | | val d = dataList[position] |
| | | openDetail(d) |
| | | d.id?.let { id -> |
| | | d.num?.let { num -> |
| | | viewModel.signFile(id, num, object : ResultCallBack<Int> { |
| | | override fun onSuccess(result: Int?) { |
| | | adapter.remove(position) |
| | | recyclerViewPanel2.addData(0, listOf(d)) |
| | | } |
| | | |
| | | override fun onFailure() { |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | |
| | | override fun onItemChildClick(adapter: BaseQuickAdapter<Any?, BaseViewHolder>, view: View, position: Int, dataList: List<NightWorkFileVo>) { |
| | | super.onItemChildClick(adapter, view, position, dataList) |
| | | val d = dataList[position] |
| | | when (view.id) { |
| | | R.id.txt_sign -> { |
| | | d.id?.let { id -> |
| | | d.num?.let { num -> |
| | | viewModel.signFile(id, num, object : ResultCallBack<Int> { |
| | | override fun onSuccess(result: Int?) { |
| | | adapter.remove(position) |
| | | recyclerViewPanel2.addData(0, listOf(d)) |
| | | } |
| | | |
| | | override fun onFailure() { |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | override fun getMyLayoutManager(): RecyclerView.LayoutManager = LinearLayoutManager(this@NightWorkRecordActivity, LinearLayoutManager.HORIZONTAL, false) |
| | | |
| | | override fun needSwipeRefresh(): Boolean = false |
| | | |
| | | override fun getLoadMoreView(): LoadMoreView? = FileLoadMoreView() |
| | | |
| | | override fun getMyEmptyView(): View? = LayoutInflater.from(this@NightWorkRecordActivity).inflate(R.layout.layout_night_work_empty, null) |
| | | |
| | | }.also { |
| | | it.init() |
| | | it.startRefresh() |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 历史文件 |
| | | */ |
| | | private fun initRecyclerView2() { |
| | | recyclerViewPanel2 = object : RecyclerViewPanel<NightWorkFileVo>(viewModel.dataLoadModel2, recycler_view_2, this) { |
| | | override fun getItemLayoutId(): Int? = R.layout.item_night_work_2 |
| | | |
| | | override fun onBindView(holder: BaseCustomViewHolder, item: MySection<NightWorkFileVo>?) { |
| | | item?.t?.let { vo -> |
| | | val time = CommonUtils.getStartEndDate(vo.startDate, vo.endDate) |
| | | holder.setText(R.id.txt_content, vo.applyContent) |
| | | .setText(R.id.txt_time, time) |
| | | } |
| | | } |
| | | |
| | | override fun onItemClick(adapter: BaseQuickAdapter<Any?, BaseViewHolder>, view: View, position: Int, dataList: List<NightWorkFileVo>) { |
| | | super.onItemClick(adapter, view, position, dataList) |
| | | openDetail(dataList[position]) |
| | | } |
| | | }.also { |
| | | it.init() |
| | | it.startRefresh() |
| | | } |
| | | } |
| | | |
| | | private fun initObserver() { |
| | | |
| | | } |
| | | |
| | | override fun onClick(v: View?) { |
| | | TODO("Not yet implemented") |
| | | private fun openDetail(nightWorkFileVo: NightWorkFileVo) { |
| | | val intent = Intent(this, OfficeFileManageActivity::class.java) |
| | | intent.putExtra("filePath", nightWorkFileVo.url) |
| | | intent.putExtra("fileName", nightWorkFileVo.fileName) |
| | | intent.putExtra("isRemoteFile", nightWorkFileVo.url?.contains("http") == true) |
| | | startActivity(intent) |
| | | } |
| | | } |