Skip to content

Commit

Permalink
日常提交:2022-10-28.
Browse files Browse the repository at this point in the history
Signed-off-by: 王朋飞 <walgr1010>
  • Loading branch information
王朋飞 committed Oct 28, 2022
1 parent 35a6115 commit 993a4eb
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,67 +14,79 @@ import com.wpf.app.quick.helper.attribute.base.AutoGetAttributeHelper
* Created by 王朋飞 on 2022/5/7.
*
*/
class MultiFunctionAttributeHelper
(context: Context,
attributeSet: AttributeSet
): AutoGetAttributeHelper(context, attributeSet, R.styleable.MultiFunctionView) {
class MultiFunctionAttributeHelper(
context: Context,
attributeSet: AttributeSet
) : AutoGetAttributeHelper(context, attributeSet, R.styleable.MultiFunctionView) {

var showCheckBox: Boolean? = null
var isCheck: Boolean? = null

//CheckBox大小
var checkBoxWidth: Int? = null

//CheckBox背景
@DrawableRes var checkboxBackground: Int? = null
@DrawableRes
var checkboxBackground: Int? = null
var checkboxBackgroundColor: Color? = null

//CheckBox左右边距
var checkboxLeftMarge: Int? = 0
var checkboxRightMarge: Int? = 0

var title: String? = null
@DrawableRes var titleBackground: Int? = null
@DrawableRes
var titleBackground: Int? = null
var titleSize: Int? = null
@ColorRes var titleColor: Int? = null
@ColorRes
var titleColor: Int? = null
var titleWpfStyle: Int? = null
var titleMaxLine: Int? = null

var subTitle: String? = null
@DrawableRes var subTitleBackground: Int? = null
@DrawableRes
var subTitleBackground: Int? = null
var subTitleSize: Int? = null
@ColorRes var subTitleColor: Int? = null
@ColorRes
var subTitleColor: Int? = null
var subTitleWpfStyle: Int? = null
var subTitleMarginTop: Int? = null
var subTitleMaxLine: Int? = null

var showLeftImage: Boolean? = null
@DrawableRes var leftImageBackground: Int? = null
@DrawableRes var leftImageSrc: Int? = null
@DrawableRes
var leftImageBackground: Int? = null
@DrawableRes
var leftImageSrc: Int? = null
var leftImageWidth: Int? = null
get() = field ?: ViewGroup.LayoutParams.WRAP_CONTENT
var leftImageScaleType: Int = 3
var leftImageLeftMarge: Int? = 0
var leftImageRightMarge: Int? = 0

var showRightImage: Boolean? = null
@DrawableRes var rightImageBackground: Int? = null
@DrawableRes var rightImageSrc: Int? = null
@DrawableRes
var rightImageBackground: Int? = null
@DrawableRes
var rightImageSrc: Int? = null
var rightImageWidth: Int? = null
get() = field ?: ViewGroup.LayoutParams.WRAP_CONTENT
var rightImageScaleType: Int = 3
var rightImageLeftMarge: Int? = 0
var rightImageRightMarge: Int? = 0

var clickView: Int? = null
get() {
return when(field) {
0 -> ItemView
1 -> CheckBox
2 -> LeftImage
3 -> Title
4 -> SubTitle
5 -> RightImage
else -> ItemView
get() {
return when (field) {
0 -> ItemView
1 -> CheckBox
2 -> LeftImage
3 -> Title
4 -> SubTitle
5 -> RightImage
else -> ItemView
}
}
}

var clickOnlyCheckBox: Boolean? = null
}
21 changes: 8 additions & 13 deletions Quick/src/main/java/com/wpf/app/quick/widgets/MultiFunctionView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ class MultiFunctionView @JvmOverloads constructor(

override fun onAttachedToWindow() {
super.onAttachedToWindow()
attributes?.let {
attributeHelper = MultiFunctionAttributeHelper(context, attributes)
}
//预览时会报错
// attributes?.let {
// attributeHelper = MultiFunctionAttributeHelper(context, attributes)
// }
mLifecycleRegistry.currentState = Lifecycle.State.RESUMED
}

Expand Down Expand Up @@ -99,9 +100,7 @@ class MultiFunctionView @JvmOverloads constructor(
}

private fun loadCheckBoxAttribute() {
attributeHelper.showCheckBox?.let {
showCheckBox(it)
}
showCheckBox(attributeHelper.showCheckBox ?: false)
attributeHelper.checkboxBackground?.let {
setCheckBoxBackground(it)
}
Expand Down Expand Up @@ -145,9 +144,7 @@ class MultiFunctionView @JvmOverloads constructor(
}

private fun loadTitleAttribute() {
attributeHelper.title?.let {
setTitle(it)
}
setTitle(attributeHelper.title ?: "")
attributeHelper.titleBackground?.let {
setTitleBackground(it)
}
Expand All @@ -166,9 +163,7 @@ class MultiFunctionView @JvmOverloads constructor(
}

private fun loadSubTitleAttribute() {
attributeHelper.subTitle?.let {
setSubTitle(it)
}
setSubTitle(attributeHelper.subTitle ?: "")
attributeHelper.subTitleBackground?.let {
setSubTitleBackground(it)
}
Expand Down Expand Up @@ -418,7 +413,7 @@ class MultiFunctionView @JvmOverloads constructor(
}
}

interface CheckView: Checkable {
interface CheckView : Checkable {

fun setOnCheckedChangeListener(listener: CompoundButton.OnCheckedChangeListener?)
}

0 comments on commit 993a4eb

Please sign in to comment.