Skip to content

Commit

Permalink
日常提交:2022-10-19。
Browse files Browse the repository at this point in the history
Signed-off-by: 王朋飞 <walgr1010>
  • Loading branch information
王朋飞 committed Oct 19, 2022
1 parent 25fc1c7 commit 016684f
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ package com.wpf.app.quick.widgets.selectview.data

import android.view.View
import androidx.annotation.LayoutRes
import com.wpf.app.quick.annotations.BindData2View
import com.wpf.app.quickbind.helper.binddatahelper.ItemClick
import com.wpf.app.quickbind.interfaces.RunItemClickWithSelf
import com.wpf.app.quickbind.interfaces.itemClickRun
import com.wpf.app.quickbind.interfaces.itemClickWithSelf

/**
* Created by 王朋飞 on 2022/7/13.
Expand All @@ -17,7 +13,7 @@ open class QuickChildSelectData(
open var parent: QuickParentSelectData? = null,
override val isSuspension: Boolean = false, //View是否悬浮置顶
open var childList: MutableList<out QuickChildSelectData>? = null,
onChildClick: RunItemClickWithSelf<QuickChildSelectData>? = null,
open val onChildClick: RunItemClickWithSelf<QuickChildSelectData>? = null,
override var id: String? = null,
override var name: String? = null,
override var defaultSelect: Boolean = false,
Expand All @@ -30,11 +26,7 @@ open class QuickChildSelectData(
override val maxLimitListener: MaxLimitListener? = null, //超出反馈
@LayoutRes override val layoutId: Int = 0,
override val layoutView: View? = null,
) : QuickMultiSelectData(
layoutId = layoutId,
layoutView = layoutView,
isSuspension = isSuspension
) {
) : QuickMultiSelectData() {

fun getChildSelectSize(): Int {
return getChildSelectList()?.size ?: 0
Expand All @@ -44,29 +36,28 @@ open class QuickChildSelectData(
return childList?.filter { it.isSelect }
}

private val childClick = itemClickWithSelf<QuickChildSelectData> { self ->
itemClickRun {
onClick()
if (self is QuickParentSelectData) {
if (!self.canClick) {
return@itemClickRun
}
getAdapter()?.onChildClick(self)
getAdapter()?.onParentChild(self)
} else {
getAdapter()?.onChildClick(self)
override fun onClick() {
super.onClick()
onItemClick()
if (this is QuickParentSelectData) {
if (!canClick) {
return
}
getAdapter()?.onChildClick(this)
getAdapter()?.onParentChild(this)
} else {
getAdapter()?.onChildClick(this)
}
getViewHolder()?.itemView?.let {
onChildClick?.run(it, this)?.onClick(it)
}
}

@BindData2View(helper = ItemClick::class)
open val itemClick = onChildClick ?: childClick

override fun onSelectChange(isSelect: Boolean) {
open fun onItemClick() {

}

fun performClick() {
childClick.run(this)
override fun onSelectChange(isSelect: Boolean) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ open class QuickMultiSelectData(
@LayoutRes override val layoutId: Int = 0,
override val layoutView: View? = null,
override val isSuspension: Boolean = false, //View是否悬浮置顶
) : QuickSelectData(
layoutId = layoutId,
layoutView = layoutView,
isSuspension = isSuspension
)
) : QuickSelectData()

interface MaxLimitListener {
fun beyondLimit(limitSize: Int)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,10 @@ open class QuickParentSelectData(
override val layoutView: View? = null,
) : QuickChildSelectData(
onChildClick = onParentClick as? RunItemClickWithSelf<QuickChildSelectData>,
layoutId = layoutId,
layoutView = layoutView,
isSuspension = isSuspension
) {

@SuppressLint("NotifyDataSetChanged")
override fun onClick() {
override fun onItemClick() {
if (getView() != null) {
if (getAdapter()?.curClickData != this) {
val oldClickPos = getAdapter()?.getDataPos(getAdapter()?.curClickData) ?: -1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import androidx.annotation.LayoutRes
import com.wpf.app.quick.widgets.selectview.QuickSelectAdapter
import com.wpf.app.quickrecyclerview.QuickAdapter
import com.wpf.app.quickrecyclerview.data.QuickBindData
import com.wpf.app.quickrecyclerview.data.QuickClickData
import com.wpf.app.quickrecyclerview.data.QuickStateData
import com.wpf.app.quickrecyclerview.holder.QuickViewHolder

/**
Expand All @@ -20,7 +22,10 @@ open class QuickSelectData(
@LayoutRes override val layoutId: Int = 0,
override val layoutView: View? = null,
override val isSuspension: Boolean = false, //View是否悬浮置顶
) : QuickBindData(layoutId, layoutView, isSuspension = isSuspension) {
) : QuickClickData() {
override fun onClick() {

}

@CallSuper
override fun onBindViewHolder(
Expand All @@ -44,13 +49,6 @@ open class QuickSelectData(
return super.getAdapter() as? QuickSelectAdapter
}

/**
* 当前点击
*/
open fun onClick() {

}

/**
* 选择状态变化
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ open class QuickBindData(
return getAdapter()?.getData()?.indexOf(this) ?: 0
}

open fun getViewPos(): Int {
return getViewHolder()?.bindingAdapterPosition ?: 0
}

override fun getView(): View? {
return mView
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.wpf.app.quick.widgets.selectview.data
package com.wpf.app.quickrecyclerview.data

import android.view.View
import com.wpf.app.quick.annotations.BindData2View
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.wpf.app.quickrecyclerview.data

import android.view.View

abstract class QuickStateData(
open var state: Boolean = false,
override val layoutId: Int = 0,
override val layoutView: View? = null,
override val isSuspension: Boolean = false,
): QuickClickData() {

override fun onClick() {
state = !state
stateChange(state)
}

abstract fun stateChange(state: Boolean)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package com.wpf.app.quick.demo.model
import android.annotation.SuppressLint
import com.wpf.app.quick.demo.R
import com.wpf.app.quick.annotations.BindData2View
import com.wpf.app.quickrecyclerview.data.QuickClickData
import com.wpf.app.quickbind.helper.binddatahelper.Url2ImageView
import com.wpf.app.quickrecyclerview.data.QuickBindData
import com.wpf.app.quickbind.interfaces.runOnHolder
import com.wpf.app.quickutil.LogUtil

/**
* Created by 王朋飞 on 2022/7/5.
*/
class BindDataTestModel : QuickBindData(R.layout.holder_test_bind_data) {
class BindDataTestModel : QuickClickData(R.layout.holder_test_bind_data) {
@SuppressLint("NonConstantResourceId")
@BindData2View(id = R.id.img, helper = Url2ImageView::class)
var img =
Expand All @@ -19,4 +20,8 @@ class BindDataTestModel : QuickBindData(R.layout.holder_test_bind_data) {
val title = runOnHolder {
"Title:${getViewHolder()?.bindingAdapterPosition}"
}

override fun onClick() {
LogUtil.e("点击了第${getViewPos() + 1}")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ class SelectResultItem(
onChildClick = itemClickWithSelf { self ->
itemClickRun {
self.isSelect = false
val index = self.getAdapter()?.getData()?.indexOf(self) ?: 0
self.getAdapter()?.getData()?.remove(self)
self.getAdapter()?.notifyItemRemoved(index)
self.getAdapter()?.notifyItemRemoved(self.getDataPos())
self.getAdapter()?.getOnSelectChangeListener()?.onSelectChange()
}
}) {
Expand Down

0 comments on commit 016684f

Please sign in to comment.