Skip to content

Commit 997f892

Browse files
committed
feat:局部浮窗增加泛型,增强可读性
1 parent 9360bda commit 997f892

3 files changed

Lines changed: 9 additions & 11 deletions

File tree

floatingx/src/main/java/com/petterp/floatingx/assist/helper/ScopeHelper.kt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,35 @@ import com.petterp.floatingx.util.contentView
1212
class ScopeHelper : BasisHelper() {
1313

1414
/** 插入到Activity中 */
15-
fun toControl(activity: Activity): IFxScopeControl {
15+
fun toControl(activity: Activity): IFxScopeControl<Activity> {
1616
initLog(FxScopeEnum.ACTIVITY_SCOPE.tag)
17-
val control = initScopeControl()
17+
val control = FxScopeControl<Activity>(this)
1818
activity.contentView?.let {
1919
control.setContainerGroup(it)
2020
} ?: fxLog?.e("install to Activity the Error,current contentView(R.id.content) = null!")
2121
return control
2222
}
2323

2424
/** 插入到Fragment中 */
25-
fun toControl(fragment: Fragment): IFxScopeControl {
25+
fun toControl(fragment: Fragment): IFxScopeControl<Fragment> {
2626
initLog(FxScopeEnum.FRAGMENT_SCOPE.tag)
2727
val rootView = fragment.view as? FrameLayout
2828
checkNotNull(rootView) {
2929
"Check if your root layout is FrameLayout, or if the init call timing is after onCreateView()!"
3030
}
31-
val control = initScopeControl()
31+
val control = FxScopeControl<Fragment>(this)
3232
control.setContainerGroup(rootView)
3333
return control
3434
}
3535

3636
/** 插入到ViewGroup中 */
37-
fun toControl(group: FrameLayout): IFxScopeControl {
37+
fun toControl(group: FrameLayout): IFxScopeControl<FrameLayout> {
3838
initLog(FxScopeEnum.VIEW_GROUP_SCOPE.tag)
39-
val control = initScopeControl()
39+
val control = FxScopeControl<FrameLayout>(this)
4040
control.setContainerGroup(group)
4141
return control
4242
}
4343

44-
private fun initScopeControl() = FxScopeControl(this)
45-
4644
companion object {
4745
@JvmStatic
4846
fun builder(): Builder = Builder()

floatingx/src/main/java/com/petterp/floatingx/impl/control/FxScopeControl.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import com.petterp.floatingx.assist.helper.BasisHelper
66
import com.petterp.floatingx.listener.control.IFxScopeControl
77

88
/** Fx普通View控制器 */
9-
class FxScopeControl(helper: BasisHelper) :
9+
class FxScopeControl<T>(helper: BasisHelper) :
1010
FxBasisControlImpl(helper),
11-
IFxScopeControl {
11+
IFxScopeControl<T> {
1212

1313
override fun show() {
1414
if (isShow()) return
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.petterp.floatingx.listener.control
22

33
/** Fx局部控制器 */
4-
interface IFxScopeControl : IFxControl {
4+
interface IFxScopeControl<T> : IFxControl {
55
/** 显示浮窗 */
66
fun show()
77
}

0 commit comments

Comments
 (0)