diff --git a/Quick/src/main/java/com/wpf/app/quick/ability/QuickView.kt b/Quick/src/main/java/com/wpf/app/quick/ability/QuickView.kt index bb1fd7be..05bcd534 100644 --- a/Quick/src/main/java/com/wpf/app/quick/ability/QuickView.kt +++ b/Quick/src/main/java/com/wpf/app/quick/ability/QuickView.kt @@ -1,3 +1,5 @@ +@file:Suppress("LeakingThis") + package com.wpf.app.quick.ability import android.content.Context @@ -59,10 +61,6 @@ open class QuickView @JvmOverloads constructor( childView = it.generateContentView(this, childView!!) } addView(childView) - } - - override fun onAttachedToWindow() { - super.onAttachedToWindow() abilityList.filterIsInstance().forEach { it.afterGenerateContentView(this, childView!!) } diff --git a/QuickUtil/src/main/java/com/wpf/app/quickutil/helper/ViewHelper.kt b/QuickUtil/src/main/java/com/wpf/app/quickutil/helper/ViewHelper.kt index 5a17f1c7..c6ce0ab3 100644 --- a/QuickUtil/src/main/java/com/wpf/app/quickutil/helper/ViewHelper.kt +++ b/QuickUtil/src/main/java/com/wpf/app/quickutil/helper/ViewHelper.kt @@ -146,14 +146,14 @@ fun T.marginBottom(margin: Int): T { return this } -fun T.widget(widget: Float): T { +fun T.weight(weight: Float): T { parent()?.forceTo()?.let { if (it.orientation == LinearLayout.VERTICAL) { - this@widget.layoutParams.height = 0 + this@weight.layoutParams.height = 0 } else { - this@widget.layoutParams.width = 0 + this@weight.layoutParams.width = 0 } - this@widget.layoutParams.forceTo().weight = widget + this@weight.layoutParams.forceTo().weight = weight } return this } diff --git a/app/src/main/java/com/wpf/app/quick/demo/BottomSheetDialogTestActivity.kt b/app/src/main/java/com/wpf/app/quick/demo/BottomSheetDialogTestActivity.kt index 05da444d..3308cb00 100644 --- a/app/src/main/java/com/wpf/app/quick/demo/BottomSheetDialogTestActivity.kt +++ b/app/src/main/java/com/wpf/app/quick/demo/BottomSheetDialogTestActivity.kt @@ -18,7 +18,7 @@ import com.wpf.app.quickutil.helper.paddingHorizontal import com.wpf.app.quickutil.helper.reset import com.wpf.app.quickutil.helper.sp import com.wpf.app.quickutil.helper.toColor -import com.wpf.app.quickutil.helper.widget +import com.wpf.app.quickutil.helper.weight import com.wpf.app.quickwidget.wheel.WheelItemData import com.wpf.app.quickwidget.wheel.WheelView import com.wpf.app.quickwork.ability.helper.text @@ -59,7 +59,7 @@ class BottomSheetDialogTestActivity : QuickActivity( textSize = 18f.sp, text = "", textColor = R.color.colorPrimary.toColor() - ).widget(1f) + ).weight(1f) text( textSize = 16f.sp, text = "取消", diff --git a/app/src/main/java/com/wpf/app/quick/demo/WheelViewTestActivity.kt b/app/src/main/java/com/wpf/app/quick/demo/WheelViewTestActivity.kt index 46f786e9..27b61682 100644 --- a/app/src/main/java/com/wpf/app/quick/demo/WheelViewTestActivity.kt +++ b/app/src/main/java/com/wpf/app/quick/demo/WheelViewTestActivity.kt @@ -9,7 +9,7 @@ import com.wpf.app.base.ability.helper.viewGroupCreate import com.wpf.app.quickutil.helper.dp import com.wpf.app.quickutil.helper.matchWrapMarginLayoutParams import com.wpf.app.quickutil.helper.padding -import com.wpf.app.quickutil.helper.widget +import com.wpf.app.quickutil.helper.weight import com.wpf.app.quickwidget.wheel.WheelItemData import com.wpf.app.quickwidget.wheel.WheelView import com.wpf.app.quickwork.ability.helper.title @@ -24,7 +24,7 @@ class WheelViewTestActivity: QuickActivity( } addView(self.wheelView!!, matchWrapMarginLayoutParams()) - }.widget(1f) + }.weight(1f) } ) {