mirror of
https://github.com/BetterAndroid/Hikage.git
synced 2026-02-04 12:07:07 +08:00
refactor: non-inline all layout content for black-box problem
This commit is contained in:
@@ -206,7 +206,8 @@ class HikageViewGenerator(override val environment: SymbolProcessorEnvironment)
|
|||||||
addParameter(
|
addParameter(
|
||||||
ParameterSpec.builder(
|
ParameterSpec.builder(
|
||||||
name = "init",
|
name = "init",
|
||||||
ViewLambdaClass.parameterizedBy(viewClass.second)
|
type = ViewLambdaClass.parameterizedBy(viewClass.second),
|
||||||
|
modifiers = listOf(KModifier.NOINLINE)
|
||||||
).apply {
|
).apply {
|
||||||
if (!performer.annotation.requireInit) defaultValue("{}")
|
if (!performer.annotation.requireInit) defaultValue("{}")
|
||||||
}.build()
|
}.build()
|
||||||
@@ -215,7 +216,8 @@ class HikageViewGenerator(override val environment: SymbolProcessorEnvironment)
|
|||||||
addParameter(
|
addParameter(
|
||||||
ParameterSpec.builder(
|
ParameterSpec.builder(
|
||||||
name = "performer",
|
name = "performer",
|
||||||
PerformerLambdaClass.parameterizedBy(it)
|
type = PerformerLambdaClass.parameterizedBy(it),
|
||||||
|
modifiers = listOf(KModifier.NOINLINE)
|
||||||
).apply {
|
).apply {
|
||||||
if (!performer.annotation.requirePerformer) defaultValue("{}")
|
if (!performer.annotation.requirePerformer) defaultValue("{}")
|
||||||
}.build()
|
}.build()
|
||||||
|
|||||||
@@ -19,10 +19,7 @@
|
|||||||
*
|
*
|
||||||
* This file is created by fankes on 2025/2/25.
|
* This file is created by fankes on 2025/2/25.
|
||||||
*/
|
*/
|
||||||
@file:Suppress(
|
@file:Suppress("unused", "FunctionName", "PropertyName", "ConstPropertyName", "UNCHECKED_CAST", "MemberVisibilityCanBePrivate")
|
||||||
"unused", "FunctionName", "PropertyName", "ConstPropertyName", "UNCHECKED_CAST",
|
|
||||||
"MemberVisibilityCanBePrivate", "TOPLEVEL_TYPEALIASES_ONLY", "NON_PUBLIC_CALL_FROM_PUBLIC_INLINE"
|
|
||||||
)
|
|
||||||
|
|
||||||
package com.highcapable.hikage.core
|
package com.highcapable.hikage.core
|
||||||
|
|
||||||
@@ -40,6 +37,7 @@ import androidx.annotation.StringRes
|
|||||||
import androidx.core.graphics.drawable.toBitmap
|
import androidx.core.graphics.drawable.toBitmap
|
||||||
import androidx.viewbinding.ViewBinding
|
import androidx.viewbinding.ViewBinding
|
||||||
import com.highcapable.betterandroid.ui.extension.binding.ViewBinding
|
import com.highcapable.betterandroid.ui.extension.binding.ViewBinding
|
||||||
|
import com.highcapable.betterandroid.ui.extension.binding.ViewBindingBuilder
|
||||||
import com.highcapable.betterandroid.ui.extension.component.base.DisplayDensity
|
import com.highcapable.betterandroid.ui.extension.component.base.DisplayDensity
|
||||||
import com.highcapable.betterandroid.ui.extension.component.base.getColorCompat
|
import com.highcapable.betterandroid.ui.extension.component.base.getColorCompat
|
||||||
import com.highcapable.betterandroid.ui.extension.component.base.getColorStateListCompat
|
import com.highcapable.betterandroid.ui.extension.component.base.getColorStateListCompat
|
||||||
@@ -57,6 +55,7 @@ import com.highcapable.hikage.core.base.HikageFactory
|
|||||||
import com.highcapable.hikage.core.base.HikageFactoryBuilder
|
import com.highcapable.hikage.core.base.HikageFactoryBuilder
|
||||||
import com.highcapable.hikage.core.base.HikagePerformer
|
import com.highcapable.hikage.core.base.HikagePerformer
|
||||||
import com.highcapable.hikage.core.base.HikageView
|
import com.highcapable.hikage.core.base.HikageView
|
||||||
|
import com.highcapable.hikage.core.base.LayoutParamsBody
|
||||||
import com.highcapable.hikage.core.base.PerformerException
|
import com.highcapable.hikage.core.base.PerformerException
|
||||||
import com.highcapable.hikage.core.base.ProvideException
|
import com.highcapable.hikage.core.base.ProvideException
|
||||||
import com.highcapable.hikage.core.extension.ResourcesScope
|
import com.highcapable.hikage.core.extension.ResourcesScope
|
||||||
@@ -119,8 +118,8 @@ class Hikage private constructor(private val factories: List<HikageFactory>) {
|
|||||||
context: Context,
|
context: Context,
|
||||||
parent: ViewGroup? = null,
|
parent: ViewGroup? = null,
|
||||||
attachToParent: Boolean = parent != null,
|
attachToParent: Boolean = parent != null,
|
||||||
factory: HikageFactoryBuilder.() -> Unit = {},
|
noinline factory: HikageFactoryBuilder.() -> Unit = {},
|
||||||
performer: HikagePerformer<LP>
|
noinline performer: HikagePerformer<LP>
|
||||||
) = create(classOf<LP>(), context, parent, attachToParent, factory, performer)
|
) = create(classOf<LP>(), context, parent, attachToParent, factory, performer)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -132,7 +131,7 @@ class Hikage private constructor(private val factories: List<HikageFactory>) {
|
|||||||
* @param performer the performer body.
|
* @param performer the performer body.
|
||||||
* @return [Hikage]
|
* @return [Hikage]
|
||||||
*/
|
*/
|
||||||
inline fun create(
|
fun create(
|
||||||
context: Context,
|
context: Context,
|
||||||
parent: ViewGroup? = null,
|
parent: ViewGroup? = null,
|
||||||
attachToParent: Boolean = parent != null,
|
attachToParent: Boolean = parent != null,
|
||||||
@@ -150,7 +149,7 @@ class Hikage private constructor(private val factories: List<HikageFactory>) {
|
|||||||
* @param performer the performer body.
|
* @param performer the performer body.
|
||||||
* @return [Hikage]
|
* @return [Hikage]
|
||||||
*/
|
*/
|
||||||
inline fun <LP : ViewGroup.LayoutParams> create(
|
fun <LP : ViewGroup.LayoutParams> create(
|
||||||
lpClass: Class<LP>,
|
lpClass: Class<LP>,
|
||||||
context: Context,
|
context: Context,
|
||||||
parent: ViewGroup? = null,
|
parent: ViewGroup? = null,
|
||||||
@@ -208,9 +207,6 @@ class Hikage private constructor(private val factories: List<HikageFactory>) {
|
|||||||
) = Delegate(lpClass, factory, performer)
|
) = Delegate(lpClass, factory, performer)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The [Hikage] layout params body type. */
|
|
||||||
private typealias LayoutParamsBody<LP> = LP.() -> Unit
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The [Hikage.Performer] scope interface.
|
* The [Hikage.Performer] scope interface.
|
||||||
*/
|
*/
|
||||||
@@ -434,19 +430,6 @@ class Hikage private constructor(private val factories: List<HikageFactory>) {
|
|||||||
*/
|
*/
|
||||||
private fun createAttributeSet(context: Context): AttributeSet = XmlBlockBypass.newParser(context)
|
private fun createAttributeSet(context: Context): AttributeSet = XmlBlockBypass.newParser(context)
|
||||||
|
|
||||||
/**
|
|
||||||
* Start a new performer [LP].
|
|
||||||
* @param parent the parent view group.
|
|
||||||
* @param attachToParent whether to attach the layout to the parent when the [parent] is filled.
|
|
||||||
* @param context the context, priority is given to [parent]'s context.
|
|
||||||
* @return [Performer]
|
|
||||||
*/
|
|
||||||
private inline fun <reified LP : ViewGroup.LayoutParams> newPerformer(
|
|
||||||
parent: ViewGroup? = null,
|
|
||||||
attachToParent: Boolean = parent != null,
|
|
||||||
context: Context? = null
|
|
||||||
) = newPerformer(classOf<LP>(), parent, attachToParent, context)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start a new performer [LP].
|
* Start a new performer [LP].
|
||||||
* @param lpClass the layout params type.
|
* @param lpClass the layout params type.
|
||||||
@@ -548,6 +531,32 @@ class Hikage private constructor(private val factories: List<HikageFactory>) {
|
|||||||
/** The count of providing views. */
|
/** The count of providing views. */
|
||||||
private var provideCount = 0
|
private var provideCount = 0
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provide a new [View] instance [V].
|
||||||
|
* @param viewClass the view class.
|
||||||
|
* @param lparams the view layout params.
|
||||||
|
* @param id the view id, generated by default.
|
||||||
|
* @param init the view initialization body.
|
||||||
|
* @return [V]
|
||||||
|
*/
|
||||||
|
@Hikageable
|
||||||
|
fun <V : View> View(
|
||||||
|
viewClass: Class<V>,
|
||||||
|
lparams: LayoutParams? = null,
|
||||||
|
id: String? = null,
|
||||||
|
init: HikageView<V> = {}
|
||||||
|
): V {
|
||||||
|
val lpDelegate = LayoutParams.from(current, lpClass, parent, lparams)
|
||||||
|
val view = createView(viewClass, id, context)
|
||||||
|
view.layoutParams = lpDelegate.create()
|
||||||
|
|
||||||
|
requireNoPerformers(viewClass.name) { view.init() }
|
||||||
|
startProvide(id, viewClass)
|
||||||
|
addToParentIfRequired(view)
|
||||||
|
|
||||||
|
return view
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide a new [View] instance [V].
|
* Provide a new [View] instance [V].
|
||||||
* @param lparams the view layout params.
|
* @param lparams the view layout params.
|
||||||
@@ -560,18 +569,8 @@ class Hikage private constructor(private val factories: List<HikageFactory>) {
|
|||||||
inline fun <reified V : View> View(
|
inline fun <reified V : View> View(
|
||||||
lparams: LayoutParams? = null,
|
lparams: LayoutParams? = null,
|
||||||
id: String? = null,
|
id: String? = null,
|
||||||
init: HikageView<V> = {}
|
noinline init: HikageView<V> = {}
|
||||||
): V {
|
) = View(classOf<V>(), lparams, id, init)
|
||||||
val lpDelegate = LayoutParams.from(current, lpClass, parent, lparams)
|
|
||||||
val view = createView(classOf<V>(), id, context)
|
|
||||||
view.layoutParams = lpDelegate.create()
|
|
||||||
|
|
||||||
requireNoPerformers(classOf<V>().name) { view.init() }
|
|
||||||
startProvide(id, classOf<V>())
|
|
||||||
addToParentIfRequired(view)
|
|
||||||
|
|
||||||
return view
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide a new [View] instance.
|
* Provide a new [View] instance.
|
||||||
@@ -581,12 +580,67 @@ class Hikage private constructor(private val factories: List<HikageFactory>) {
|
|||||||
* @return [View]
|
* @return [View]
|
||||||
*/
|
*/
|
||||||
@Hikageable
|
@Hikageable
|
||||||
inline fun View(
|
fun View(
|
||||||
lparams: LayoutParams? = null,
|
lparams: LayoutParams? = null,
|
||||||
id: String? = null,
|
id: String? = null,
|
||||||
init: HikageView<View> = {}
|
init: HikageView<View> = {}
|
||||||
) = View<View>(lparams, id, init)
|
) = View<View>(lparams, id, init)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provide a new [ViewGroup] instance [VG].
|
||||||
|
*
|
||||||
|
* Provide the new type of [ViewGroup.LayoutParams] down via [LP].
|
||||||
|
*
|
||||||
|
* - Note: The [VG] must be inherited from [ViewGroup].
|
||||||
|
* @param viewClass the view class.
|
||||||
|
* @param lpClass the layout params class.
|
||||||
|
* @param lparams the view layout params.
|
||||||
|
* @param id the view id, generated by default.
|
||||||
|
* @param init the view initialization body.
|
||||||
|
* @param performer the performer body.
|
||||||
|
* @return [VG]
|
||||||
|
*/
|
||||||
|
@Hikageable
|
||||||
|
fun <VG : ViewGroup, LP : ViewGroup.LayoutParams> ViewGroup(
|
||||||
|
viewClass: Class<VG>,
|
||||||
|
lpClass: Class<LP>,
|
||||||
|
lparams: LayoutParams? = null,
|
||||||
|
id: String? = null,
|
||||||
|
init: HikageView<VG> = {},
|
||||||
|
performer: HikagePerformer<LP> = {}
|
||||||
|
): VG {
|
||||||
|
val lpDelegate = LayoutParams.from(current, lpClass, parent, lparams)
|
||||||
|
val view = createView(viewClass, id, context)
|
||||||
|
view.layoutParams = lpDelegate.create()
|
||||||
|
|
||||||
|
requireNoPerformers(viewClass.name) { view.init() }
|
||||||
|
startProvide(id, viewClass)
|
||||||
|
addToParentIfRequired(view)
|
||||||
|
newPerformer(lpClass, view).apply(performer)
|
||||||
|
|
||||||
|
return view
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provide a new [ViewGroup] instance [VG].
|
||||||
|
*
|
||||||
|
* - Note: The [VG] must be inherited from [ViewGroup].
|
||||||
|
* @param viewClass the view class.
|
||||||
|
* @param lparams the view layout params.
|
||||||
|
* @param id the view id, generated by default.
|
||||||
|
* @param init the view initialization body.
|
||||||
|
* @param performer the performer body.
|
||||||
|
* @return [VG]
|
||||||
|
*/
|
||||||
|
@Hikageable
|
||||||
|
fun <VG : ViewGroup> ViewGroup(
|
||||||
|
viewClass: Class<VG>,
|
||||||
|
lparams: LayoutParams? = null,
|
||||||
|
id: String? = null,
|
||||||
|
init: HikageView<VG> = {},
|
||||||
|
performer: HikagePerformer<ViewGroup.LayoutParams> = {}
|
||||||
|
) = ViewGroup(viewClass, classOf<ViewGroup.LayoutParams>(), lparams, id, init, performer)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide a new [ViewGroup] instance [VG].
|
* Provide a new [ViewGroup] instance [VG].
|
||||||
*
|
*
|
||||||
@@ -604,20 +658,9 @@ class Hikage private constructor(private val factories: List<HikageFactory>) {
|
|||||||
inline fun <reified VG : ViewGroup, reified LP : ViewGroup.LayoutParams> ViewGroup(
|
inline fun <reified VG : ViewGroup, reified LP : ViewGroup.LayoutParams> ViewGroup(
|
||||||
lparams: LayoutParams? = null,
|
lparams: LayoutParams? = null,
|
||||||
id: String? = null,
|
id: String? = null,
|
||||||
init: HikageView<VG> = {},
|
noinline init: HikageView<VG> = {},
|
||||||
performer: HikagePerformer<LP> = {}
|
noinline performer: HikagePerformer<LP> = {}
|
||||||
): VG {
|
) = ViewGroup(classOf<VG>(), classOf<LP>(), lparams, id, init, performer)
|
||||||
val lpDelegate = LayoutParams.from(current, lpClass, parent, lparams)
|
|
||||||
val view = createView(classOf<VG>(), id, context)
|
|
||||||
view.layoutParams = lpDelegate.create()
|
|
||||||
|
|
||||||
requireNoPerformers(classOf<VG>().name) { view.init() }
|
|
||||||
startProvide(id, classOf<VG>())
|
|
||||||
addToParentIfRequired(view)
|
|
||||||
newPerformer<LP>(view).apply(performer)
|
|
||||||
|
|
||||||
return view
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide a new [ViewGroup] instance [VG].
|
* Provide a new [ViewGroup] instance [VG].
|
||||||
@@ -633,9 +676,9 @@ class Hikage private constructor(private val factories: List<HikageFactory>) {
|
|||||||
inline fun <reified VG : ViewGroup> ViewGroup(
|
inline fun <reified VG : ViewGroup> ViewGroup(
|
||||||
lparams: LayoutParams? = null,
|
lparams: LayoutParams? = null,
|
||||||
id: String? = null,
|
id: String? = null,
|
||||||
init: HikageView<VG> = {},
|
noinline init: HikageView<VG> = {},
|
||||||
performer: HikagePerformer<ViewGroup.LayoutParams> = {}
|
noinline performer: HikagePerformer<ViewGroup.LayoutParams> = {}
|
||||||
) = ViewGroup<VG, ViewGroup.LayoutParams>(lparams, id, init, performer)
|
) = ViewGroup(classOf<VG>(), lparams, id, init, performer)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide layout from [resId].
|
* Provide layout from [resId].
|
||||||
@@ -661,16 +704,18 @@ class Hikage private constructor(private val factories: List<HikageFactory>) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide layout from [ViewBinding].
|
* Provide layout from [ViewBinding].
|
||||||
|
* @param bindingBuilder the view binding builder.
|
||||||
* @param lparams the view layout params.
|
* @param lparams the view layout params.
|
||||||
* @param id the view id, generated by default.
|
* @param id the view id, generated by default.
|
||||||
* @return [VB]
|
* @return [VB]
|
||||||
*/
|
*/
|
||||||
@Hikageable
|
@Hikageable
|
||||||
inline fun <reified VB : ViewBinding> Layout(
|
fun <VB : ViewBinding> Layout(
|
||||||
|
bindingBuilder: ViewBindingBuilder<VB>,
|
||||||
lparams: LayoutParams? = null,
|
lparams: LayoutParams? = null,
|
||||||
id: String? = null
|
id: String? = null
|
||||||
): VB {
|
): VB {
|
||||||
val viewBinding = ViewBinding<VB>().inflate(context.layoutInflater, parent, attachToParent = false)
|
val viewBinding = bindingBuilder.inflate(context.layoutInflater, parent, attachToParent = false)
|
||||||
val view = viewBinding.root
|
val view = viewBinding.root
|
||||||
|
|
||||||
startProvide(id, view.javaClass, view)
|
startProvide(id, view.javaClass, view)
|
||||||
@@ -686,6 +731,18 @@ class Hikage private constructor(private val factories: List<HikageFactory>) {
|
|||||||
return viewBinding
|
return viewBinding
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provide layout from [ViewBinding].
|
||||||
|
* @param lparams the view layout params.
|
||||||
|
* @param id the view id, generated by default.
|
||||||
|
* @return [VB]
|
||||||
|
*/
|
||||||
|
@Hikageable
|
||||||
|
inline fun <reified VB : ViewBinding> Layout(
|
||||||
|
lparams: LayoutParams? = null,
|
||||||
|
id: String? = null
|
||||||
|
) = Layout(ViewBinding<VB>(), lparams, id)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide layout from exists [View].
|
* Provide layout from exists [View].
|
||||||
* @param view the view instance.
|
* @param view the view instance.
|
||||||
@@ -702,7 +759,7 @@ class Hikage private constructor(private val factories: List<HikageFactory>) {
|
|||||||
if (view.parent != null) throw ProvideException("The view $view already has a parent, cannot be provided.")
|
if (view.parent != null) throw ProvideException("The view $view already has a parent, cannot be provided.")
|
||||||
|
|
||||||
startProvide(id, view.javaClass, view)
|
startProvide(id, view.javaClass, view)
|
||||||
val lpDelegate = LayoutParams.from(current = this@Hikage, lpClass, parent, lparams, view.layoutParams)
|
val lpDelegate = LayoutParams.from(current, lpClass, parent, lparams, view.layoutParams)
|
||||||
view.layoutParams = lpDelegate.create()
|
view.layoutParams = lpDelegate.create()
|
||||||
|
|
||||||
provideView(view, id)
|
provideView(view, id)
|
||||||
@@ -984,7 +1041,6 @@ class Hikage private constructor(private val factories: List<HikageFactory>) {
|
|||||||
* @param attachToParent whether to attach the layout to the parent when the [parent] is filled.
|
* @param attachToParent whether to attach the layout to the parent when the [parent] is filled.
|
||||||
* @return [Hikage]
|
* @return [Hikage]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fun create(context: Context, parent: ViewGroup? = null, attachToParent: Boolean = parent != null) =
|
fun create(context: Context, parent: ViewGroup? = null, attachToParent: Boolean = parent != null) =
|
||||||
create(lpClass, context, parent, attachToParent, factory, performer)
|
create(lpClass, context, parent, attachToParent, factory, performer)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,10 +27,12 @@ package com.highcapable.hikage.core.base
|
|||||||
* The exception of performing view.
|
* The exception of performing view.
|
||||||
* @param message the exception message.
|
* @param message the exception message.
|
||||||
*/
|
*/
|
||||||
|
@PublishedApi
|
||||||
internal class PerformerException(message: String) : Exception(message)
|
internal class PerformerException(message: String) : Exception(message)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The exception of providing view.
|
* The exception of providing view.
|
||||||
* @param message the exception message.
|
* @param message the exception message.
|
||||||
*/
|
*/
|
||||||
|
@PublishedApi
|
||||||
internal class ProvideException(message: String) : Exception(message)
|
internal class ProvideException(message: String) : Exception(message)
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
*
|
*
|
||||||
* This file is created by fankes on 2025/2/25.
|
* This file is created by fankes on 2025/2/25.
|
||||||
*/
|
*/
|
||||||
@file:Suppress("unused", "FunctionName", "NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
|
@file:Suppress("unused", "FunctionName")
|
||||||
@file:JvmName("HikageableUtils")
|
@file:JvmName("HikageableUtils")
|
||||||
|
|
||||||
package com.highcapable.hikage.core.base
|
package com.highcapable.hikage.core.base
|
||||||
@@ -38,6 +38,9 @@ typealias HikagePerformer<LP> = Hikage.Performer<LP>.() -> Unit
|
|||||||
*/
|
*/
|
||||||
typealias HikageView<V> = V.() -> Unit
|
typealias HikageView<V> = V.() -> Unit
|
||||||
|
|
||||||
|
/** The [Hikage] layout params body type. */
|
||||||
|
internal typealias LayoutParamsBody<LP> = LP.() -> Unit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start performing a [Hikage] layout [LP].
|
* Start performing a [Hikage] layout [LP].
|
||||||
* @param context the context to create the layout.
|
* @param context the context to create the layout.
|
||||||
@@ -47,14 +50,13 @@ typealias HikageView<V> = V.() -> Unit
|
|||||||
* @param performer the performer body.
|
* @param performer the performer body.
|
||||||
* @return [Hikage]
|
* @return [Hikage]
|
||||||
*/
|
*/
|
||||||
@JvmSynthetic
|
|
||||||
@JvmName("HikageableTyped")
|
@JvmName("HikageableTyped")
|
||||||
inline fun <reified LP : ViewGroup.LayoutParams> Hikageable(
|
inline fun <reified LP : ViewGroup.LayoutParams> Hikageable(
|
||||||
context: Context,
|
context: Context,
|
||||||
parent: ViewGroup? = null,
|
parent: ViewGroup? = null,
|
||||||
attachToParent: Boolean = parent != null,
|
attachToParent: Boolean = parent != null,
|
||||||
factory: HikageFactoryBuilder.() -> Unit = {},
|
noinline factory: HikageFactoryBuilder.() -> Unit = {},
|
||||||
performer: HikagePerformer<LP>
|
noinline performer: HikagePerformer<LP>
|
||||||
) = Hikage.create(context, parent, attachToParent, factory, performer)
|
) = Hikage.create(context, parent, attachToParent, factory, performer)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -67,7 +69,7 @@ inline fun <reified LP : ViewGroup.LayoutParams> Hikageable(
|
|||||||
* @return [Hikage]
|
* @return [Hikage]
|
||||||
*/
|
*/
|
||||||
@JvmSynthetic
|
@JvmSynthetic
|
||||||
inline fun Hikageable(
|
fun Hikageable(
|
||||||
context: Context,
|
context: Context,
|
||||||
parent: ViewGroup? = null,
|
parent: ViewGroup? = null,
|
||||||
attachToParent: Boolean = parent != null,
|
attachToParent: Boolean = parent != null,
|
||||||
@@ -81,7 +83,6 @@ inline fun Hikageable(
|
|||||||
* @param performer the performer body.
|
* @param performer the performer body.
|
||||||
* @return [Hikage.Delegate]<[LP]>
|
* @return [Hikage.Delegate]<[LP]>
|
||||||
*/
|
*/
|
||||||
@JvmSynthetic
|
|
||||||
@JvmName("HikageableTyped")
|
@JvmName("HikageableTyped")
|
||||||
inline fun <reified LP : ViewGroup.LayoutParams> Hikageable(
|
inline fun <reified LP : ViewGroup.LayoutParams> Hikageable(
|
||||||
noinline factory: HikageFactoryBuilder.() -> Unit = {},
|
noinline factory: HikageFactoryBuilder.() -> Unit = {},
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import com.highcapable.hikage.core.base.Hikageable
|
|||||||
* @see Hikageable
|
* @see Hikageable
|
||||||
* @return [Hikage]
|
* @return [Hikage]
|
||||||
*/
|
*/
|
||||||
inline fun Activity.setContentView(
|
fun Activity.setContentView(
|
||||||
factory: HikageFactoryBuilder.() -> Unit = {},
|
factory: HikageFactoryBuilder.() -> Unit = {},
|
||||||
performer: HikagePerformer<FrameLayout.LayoutParams>
|
performer: HikagePerformer<FrameLayout.LayoutParams>
|
||||||
) = Hikageable(context = this, factory = factory, performer = performer).apply { setContentView(root) }
|
) = Hikageable(context = this, factory = factory, performer = performer).apply { setContentView(root) }
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ import androidx.appcompat.app.AlertDialog as AndroidXAlertDialog
|
|||||||
* @see Hikageable
|
* @see Hikageable
|
||||||
* @return [Hikage]
|
* @return [Hikage]
|
||||||
*/
|
*/
|
||||||
inline fun AlertDialog.setView(
|
fun AlertDialog.setView(
|
||||||
factory: HikageFactoryBuilder.() -> Unit = {},
|
factory: HikageFactoryBuilder.() -> Unit = {},
|
||||||
performer: HikagePerformer<FrameLayout.LayoutParams>
|
performer: HikagePerformer<FrameLayout.LayoutParams>
|
||||||
) = Hikageable(context = context, factory = factory, performer = performer).apply { setView(root) }
|
) = Hikageable(context = context, factory = factory, performer = performer).apply { setView(root) }
|
||||||
@@ -62,7 +62,7 @@ fun AlertDialog.setView(delegate: Hikage.Delegate<*>) =
|
|||||||
* @see Hikageable
|
* @see Hikageable
|
||||||
* @return [AlertDialog.Builder]
|
* @return [AlertDialog.Builder]
|
||||||
*/
|
*/
|
||||||
inline fun AlertDialog.Builder.setView(
|
fun AlertDialog.Builder.setView(
|
||||||
factory: HikageFactoryBuilder.() -> Unit = {},
|
factory: HikageFactoryBuilder.() -> Unit = {},
|
||||||
performer: HikagePerformer<FrameLayout.LayoutParams>
|
performer: HikagePerformer<FrameLayout.LayoutParams>
|
||||||
): AlertDialog.Builder = setView(Hikageable(context = context, factory = factory, performer = performer).root)
|
): AlertDialog.Builder = setView(Hikageable(context = context, factory = factory, performer = performer).root)
|
||||||
@@ -87,7 +87,7 @@ fun AlertDialog.Builder.setView(delegate: Hikage.Delegate<*>): AlertDialog.Build
|
|||||||
* @see Hikageable
|
* @see Hikageable
|
||||||
* @return [Hikage]
|
* @return [Hikage]
|
||||||
*/
|
*/
|
||||||
inline fun AndroidXAlertDialog.setView(
|
fun AndroidXAlertDialog.setView(
|
||||||
factory: HikageFactoryBuilder.() -> Unit = {},
|
factory: HikageFactoryBuilder.() -> Unit = {},
|
||||||
performer: HikagePerformer<FrameLayout.LayoutParams>
|
performer: HikagePerformer<FrameLayout.LayoutParams>
|
||||||
) = Hikageable(context = context, factory = factory, performer = performer).apply { setView(root) }
|
) = Hikageable(context = context, factory = factory, performer = performer).apply { setView(root) }
|
||||||
@@ -111,7 +111,7 @@ fun AndroidXAlertDialog.setView(delegate: Hikage.Delegate<*>) =
|
|||||||
* @see Hikageable
|
* @see Hikageable
|
||||||
* @return [AndroidXAlertDialog.Builder]
|
* @return [AndroidXAlertDialog.Builder]
|
||||||
*/
|
*/
|
||||||
inline fun AndroidXAlertDialog.Builder.setView(
|
fun AndroidXAlertDialog.Builder.setView(
|
||||||
factory: HikageFactoryBuilder.() -> Unit = {},
|
factory: HikageFactoryBuilder.() -> Unit = {},
|
||||||
performer: HikagePerformer<FrameLayout.LayoutParams>
|
performer: HikagePerformer<FrameLayout.LayoutParams>
|
||||||
): AndroidXAlertDialog.Builder = setView(Hikageable(context = context, factory = factory, performer = performer).root)
|
): AndroidXAlertDialog.Builder = setView(Hikageable(context = context, factory = factory, performer = performer).root)
|
||||||
@@ -136,7 +136,7 @@ fun AndroidXAlertDialog.Builder.setView(delegate: Hikage.Delegate<*>): AndroidXA
|
|||||||
* @see Hikageable
|
* @see Hikageable
|
||||||
* @return [Hikage]
|
* @return [Hikage]
|
||||||
*/
|
*/
|
||||||
inline fun Dialog.setContentView(
|
fun Dialog.setContentView(
|
||||||
factory: HikageFactoryBuilder.() -> Unit = {},
|
factory: HikageFactoryBuilder.() -> Unit = {},
|
||||||
performer: HikagePerformer<FrameLayout.LayoutParams>
|
performer: HikagePerformer<FrameLayout.LayoutParams>
|
||||||
) = Hikageable(context = context, factory = factory, performer = performer).apply { setContentView(root) }
|
) = Hikageable(context = context, factory = factory, performer = performer).apply { setContentView(root) }
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
*
|
*
|
||||||
* This file is created by fankes on 2025/2/27.
|
* This file is created by fankes on 2025/2/27.
|
||||||
*/
|
*/
|
||||||
@file:Suppress("unused", "NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
|
@file:Suppress("unused")
|
||||||
@file:JvmName("PopupWindowUtils")
|
@file:JvmName("PopupWindowUtils")
|
||||||
|
|
||||||
package com.highcapable.hikage.extension
|
package com.highcapable.hikage.extension
|
||||||
@@ -38,7 +38,7 @@ import com.highcapable.kavaref.KavaRef.Companion.asResolver
|
|||||||
* @see Hikageable
|
* @see Hikageable
|
||||||
* @return [Hikage]
|
* @return [Hikage]
|
||||||
*/
|
*/
|
||||||
inline fun PopupWindow.setContentView(
|
fun PopupWindow.setContentView(
|
||||||
context: Context = requireContext(),
|
context: Context = requireContext(),
|
||||||
factory: HikageFactoryBuilder.() -> Unit = {},
|
factory: HikageFactoryBuilder.() -> Unit = {},
|
||||||
performer: HikagePerformer<FrameLayout.LayoutParams>
|
performer: HikagePerformer<FrameLayout.LayoutParams>
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ import com.highcapable.hikage.core.base.Hikageable
|
|||||||
@JvmName("addViewTyped")
|
@JvmName("addViewTyped")
|
||||||
inline fun <reified LP : ViewGroup.LayoutParams> ViewGroup.addView(
|
inline fun <reified LP : ViewGroup.LayoutParams> ViewGroup.addView(
|
||||||
index: Int = -1,
|
index: Int = -1,
|
||||||
factory: HikageFactoryBuilder.() -> Unit = {},
|
noinline factory: HikageFactoryBuilder.() -> Unit = {},
|
||||||
performer: HikagePerformer<LP>
|
noinline performer: HikagePerformer<LP>
|
||||||
) = Hikageable<LP>(context = context, factory = factory, performer = performer).apply { addView(root, index) }
|
) = Hikageable<LP>(context = context, factory = factory, performer = performer).apply { addView(root, index) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,7 +47,7 @@ inline fun <reified LP : ViewGroup.LayoutParams> ViewGroup.addView(
|
|||||||
* @see Hikageable
|
* @see Hikageable
|
||||||
* @return [Hikage]
|
* @return [Hikage]
|
||||||
*/
|
*/
|
||||||
inline fun ViewGroup.addView(
|
fun ViewGroup.addView(
|
||||||
index: Int = -1,
|
index: Int = -1,
|
||||||
factory: HikageFactoryBuilder.() -> Unit = {},
|
factory: HikageFactoryBuilder.() -> Unit = {},
|
||||||
performer: HikagePerformer<ViewGroup.LayoutParams>
|
performer: HikagePerformer<ViewGroup.LayoutParams>
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import com.highcapable.hikage.core.base.Hikageable
|
|||||||
* @see Hikageable
|
* @see Hikageable
|
||||||
* @return [Hikage]
|
* @return [Hikage]
|
||||||
*/
|
*/
|
||||||
inline fun Window.setContentView(
|
fun Window.setContentView(
|
||||||
factory: HikageFactoryBuilder.() -> Unit = {},
|
factory: HikageFactoryBuilder.() -> Unit = {},
|
||||||
performer: HikagePerformer<FrameLayout.LayoutParams>
|
performer: HikagePerformer<FrameLayout.LayoutParams>
|
||||||
) = Hikageable(context = context, factory = factory, performer = performer).apply { setContentView(root) }
|
) = Hikageable(context = context, factory = factory, performer = performer).apply { setContentView(root) }
|
||||||
|
|||||||
Reference in New Issue
Block a user