|
|
@@ -11,15 +11,18 @@ import com.mita.module_me.view.dressup.shop.ShopVm
|
|
|
import com.mita.module_me.view.dressup.shop.chat.dialog.PrettyIdBuySuccessDialog
|
|
|
import com.mita.module_me.view.dressup.shop.chat.dialog.PrettyIdDialog
|
|
|
import com.mita.module_me.view.dressup.shop.prettyId.cell.PrettyIdVH
|
|
|
+import com.scwang.smart.refresh.layout.SmartRefreshLayout
|
|
|
import com.xueyu.kotlinextlibrary.toGone
|
|
|
import com.xueyu.kotlinextlibrary.toVisible
|
|
|
import com.yc.baselibrary.adapter.viewHolder.MutableAdapter
|
|
|
import com.yc.baselibrary.ext.bind
|
|
|
import com.yc.baselibrary.ext.threadUnsafeLazy
|
|
|
import com.yc.baselibrary.view.base.BaseActivity
|
|
|
+import com.yc.refreshlibrary.annotation.RefreshType
|
|
|
import kotlinx.android.synthetic.main.module_me_more_dress.ivDressImage
|
|
|
import kotlinx.android.synthetic.main.module_me_more_dress.llPretty
|
|
|
import kotlinx.android.synthetic.main.module_me_more_dress.recyclerView
|
|
|
+import kotlinx.android.synthetic.main.module_me_more_dress.refreshLayout
|
|
|
import kotlinx.android.synthetic.main.module_me_more_dress.titleBar
|
|
|
import kotlinx.android.synthetic.main.module_me_more_dress.tvBuy
|
|
|
import kotlinx.android.synthetic.main.module_me_more_dress.tvCoin
|
|
|
@@ -28,6 +31,9 @@ import kotlinx.android.synthetic.main.module_me_more_dress.tvPretty
|
|
|
class PrettyIdListActivity : BaseActivity<ShopVm>() {
|
|
|
override fun getLayoutId() = R.layout.module_me_more_dress
|
|
|
override fun isSupportLoading() = false
|
|
|
+ override fun getRegisterLoading(): Any = refreshLayout
|
|
|
+ override fun getLoadMoreAble() = adapter
|
|
|
+ override fun getRefreshLayout(): SmartRefreshLayout? = refreshLayout
|
|
|
|
|
|
private var selectItem: PrettyId? = null
|
|
|
|
|
|
@@ -41,8 +47,7 @@ class PrettyIdListActivity : BaseActivity<ShopVm>() {
|
|
|
tvBuy.setOnClickListener {
|
|
|
wantBuy()
|
|
|
}
|
|
|
-
|
|
|
- viewModel.loadPrettyIdList()
|
|
|
+ viewModel.loadPrettyIdList(normal = true, refresh = true)
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -82,35 +87,18 @@ class PrettyIdListActivity : BaseActivity<ShopVm>() {
|
|
|
|
|
|
override fun observe() {
|
|
|
viewModel.listState.observe(this) {
|
|
|
- adapter.selectedItemPosition = 0
|
|
|
- adapter.notifyItemChanged(0)
|
|
|
- selectItem = viewModel.list[0] as PrettyId?
|
|
|
- ivDressImage.toGone()
|
|
|
- llPretty.toVisible()
|
|
|
- tvPretty.text = selectItem?.prettyId.toString()
|
|
|
- tvCoin.text = selectItem?.coin.toString()
|
|
|
+ if (viewModel.listState.value == RefreshType.REFRESH_FINISH) {
|
|
|
+ adapter.selectedItemPosition = 0
|
|
|
+ adapter.notifyItemChanged(0)
|
|
|
+ selectItem = viewModel.list[0] as PrettyId?
|
|
|
+ ivDressImage.toGone()
|
|
|
+ llPretty.toVisible()
|
|
|
+ tvPretty.text = selectItem?.prettyId.toString()
|
|
|
+ tvCoin.text = selectItem?.coin.toString()
|
|
|
+ }
|
|
|
}
|
|
|
viewModel.buyPrettyIdSuccess.observe(this) {
|
|
|
-// val position = viewModel.list.indexOf(viewModel.buyPrettyId)
|
|
|
-// if (position != -1) {
|
|
|
-// viewModel.list.removeAt(position)
|
|
|
-// adapter.notifyItemRemoved(position)
|
|
|
-//
|
|
|
-// // 如果移除的是当前选中的项,重置选择状态
|
|
|
-// if (position > 0) {
|
|
|
-// adapter.selectedItemPosition = position - 1
|
|
|
-// } else {
|
|
|
-// adapter.selectedItemPosition = 0
|
|
|
-// }
|
|
|
-// adapter.notifyItemChanged(adapter.selectedItemPosition)
|
|
|
-// selectItem = viewModel.list[adapter.selectedItemPosition] as PrettyId?
|
|
|
-// ivDressImage.toGone()
|
|
|
-// llPretty.toVisible()
|
|
|
-// tvPretty.text = selectItem?.prettyId.toString()
|
|
|
-// tvCoin.text = selectItem?.coin.toString()
|
|
|
-// }
|
|
|
- viewModel.loadPrettyIdList()
|
|
|
-
|
|
|
+ viewModel.loadPrettyIdList(normal = true, refresh = true)
|
|
|
val bugPrettyIdSuccessDialog =
|
|
|
PrettyIdBuySuccessDialog(this, viewModel.buyPrettyId)
|
|
|
showDialogBottom(
|
|
|
@@ -127,4 +115,8 @@ class PrettyIdListActivity : BaseActivity<ShopVm>() {
|
|
|
infoDialog
|
|
|
)
|
|
|
}
|
|
|
+
|
|
|
+ override fun loadData(isNormal: Boolean, isRefresh: Boolean) {
|
|
|
+ viewModel.loadPrettyIdList(normal = isNormal, refresh = isRefresh)
|
|
|
+ }
|
|
|
}
|