Skip to content

Commit 68e2f6c

Browse files
committed
refactor(layers): 规范类名方法名
1 parent 9c73b8f commit 68e2f6c

File tree

18 files changed

+320
-207
lines changed

18 files changed

+320
-207
lines changed

anylayer-ext/src/main/java/per/goweii/anylayer/ext/DefaultOnVisibleChangedListener.java renamed to anylayer-ext/src/main/java/per/goweii/anylayer/ext/DefaultOnVisibleChangeListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import per.goweii.anylayer.Layer;
66

7-
public class DefaultOnVisibleChangedListener implements Layer.OnVisibleChangedListener {
7+
public class DefaultOnVisibleChangeListener implements Layer.OnVisibleChangeListener {
88
@Override
99
public void onShow(@NonNull Layer layer) {
1010
}

anylayer-ktx/src/main/java/per/goweii/anylayer/ktx/DialogLayer.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ fun <T : DialogLayer> T.swipeTransformer(swipeTransformer: DialogLayer.SwipeTran
3939
this.setSwipeTransformer(swipeTransformer)
4040
}
4141

42-
fun <T : DialogLayer> T.onSwipeStart(onStart: T.() -> Unit) = this.apply {
42+
fun <T : DialogLayer> T.doOnSwipeStart(onStart: T.() -> Unit) = this.apply {
4343
this.addOnSwipeListener(object : DefaultDialogOnSwipeListener() {
4444
override fun onStart(layer: DialogLayer) {
4545
this@apply.onStart()
4646
}
4747
})
4848
}
4949

50-
fun <T : DialogLayer> T.onSwiping(onSwiping: T.(direction: Int, fraction: Float) -> Unit) = this.apply {
50+
fun <T : DialogLayer> T.doOnSwiping(onSwiping: T.(direction: Int, fraction: Float) -> Unit) = this.apply {
5151
this.addOnSwipeListener(object : DefaultDialogOnSwipeListener() {
5252
override fun onSwiping(layer: DialogLayer,
5353
@SwipeLayout.Direction direction: Int,
@@ -57,7 +57,7 @@ fun <T : DialogLayer> T.onSwiping(onSwiping: T.(direction: Int, fraction: Float)
5757
})
5858
}
5959

60-
fun <T : DialogLayer> T.onSwipeEnd(onEnd: T.(direction: Int) -> Unit) = this.apply {
60+
fun <T : DialogLayer> T.doOnSwipeEnd(onEnd: T.(direction: Int) -> Unit) = this.apply {
6161
this.addOnSwipeListener(object : DefaultDialogOnSwipeListener() {
6262
override fun onEnd(layer: DialogLayer, @SwipeLayout.Direction direction: Int) {
6363
this@apply.onEnd(direction)
@@ -183,10 +183,10 @@ fun <T : DialogLayer> T.outsideInterceptTouchEvent(enable: Boolean) = this.apply
183183
this.setOutsideInterceptTouchEvent(enable)
184184
}
185185

186-
fun <T : DialogLayer> T.onOutsideTouch(onOutsideTouched: T.() -> Unit) = this.apply {
186+
fun <T : DialogLayer> T.doOnOutsideTouch(onOutsideTouched: T.() -> Unit) = this.apply {
187187
this.setOnOutsideTouchListener { this@apply.onOutsideTouched() }
188188
}
189189

190-
fun <T : DialogLayer> T.outsideTouchToDismiss(enable: Boolean) = this.apply {
190+
fun <T : DialogLayer> T.dismissOnOutsideTouch(enable: Boolean) = this.apply {
191191
this.setOutsideTouchToDismiss(enable)
192192
}

anylayer-ktx/src/main/java/per/goweii/anylayer/ktx/GuideLayer.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ fun <T : GuideLayer> T.mapping(init: GuideLayer.Mapping.() -> Unit) = this.apply
2323
this.addMapping(GuideLayer.Mapping().apply { init() })
2424
}
2525

26-
fun GuideLayer.Mapping.onClick(@IdRes viewId: Int, onClickListener: GuideLayer.Mapping.(view: View) -> Unit) = this.apply {
27-
this.addOnClickListener(Layer.OnClickListener { _, v -> this.onClickListener(v) }, viewId)
26+
fun GuideLayer.Mapping.doOnClick(@IdRes viewId: Int, onClickListener: GuideLayer.Mapping.(view: View) -> Unit) = this.apply {
27+
this.addOnClickListener({ _, v -> this.onClickListener(v) }, viewId)
2828
}

anylayer-ktx/src/main/java/per/goweii/anylayer/ktx/Layer.kt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,77 +6,77 @@ import androidx.annotation.IdRes
66
import per.goweii.anylayer.Layer
77
import per.goweii.anylayer.ext.DefaultOnDismissListener
88
import per.goweii.anylayer.ext.DefaultOnShowListener
9-
import per.goweii.anylayer.ext.DefaultOnVisibleChangedListener
9+
import per.goweii.anylayer.ext.DefaultOnVisibleChangeListener
1010

11-
fun <T : Layer> T.onClick(@IdRes viewId: Int, onClickListener: T.(view: View) -> Unit) = this.apply {
11+
fun <T : Layer> T.doOnClick(@IdRes viewId: Int, onClickListener: T.(view: View) -> Unit) = this.apply {
1212
this.addOnClickListener(Layer.OnClickListener { _, v -> this.onClickListener(v) }, viewId)
1313
}
1414

15-
fun <T : Layer> T.onClickToDismiss(@IdRes viewId: Int, onClickListener: (T.(view: View) -> Unit)? = null) = this.apply {
15+
fun <T : Layer> T.dismissOnClick(@IdRes viewId: Int, onClickListener: (T.(view: View) -> Unit)? = null) = this.apply {
1616
onClickListener?.let {
1717
this.addOnClickToDismissListener(Layer.OnClickListener { _, v -> this.it(v) }, viewId)
1818
} ?: addOnClickToDismissListener(null, viewId)
1919
}
2020

21-
fun <T : Layer> T.onLongClick(@IdRes viewId: Int, onLongClickListener: T.(view: View) -> Boolean) = this.apply {
21+
fun <T : Layer> T.doOnLongClick(@IdRes viewId: Int, onLongClickListener: T.(view: View) -> Boolean) = this.apply {
2222
this.addOnLongClickListener(Layer.OnLongClickListener { _, v -> this.onLongClickListener(v) }, viewId)
2323
}
2424

25-
fun <T : Layer> T.onLongClickToDismiss(@IdRes viewId: Int, onLongClickListener: (T.(view: View) -> Boolean)? = null) = this.apply {
25+
fun <T : Layer> T.dismissOnLongClick(@IdRes viewId: Int, onLongClickListener: (T.(view: View) -> Boolean)? = null) = this.apply {
2626
onLongClickListener?.let {
2727
this.addOnLongClickToDismissListener(Layer.OnLongClickListener { _, v -> this.it(v) }, viewId)
2828
} ?: addOnLongClickToDismissListener(null, viewId)
2929
}
3030

31-
fun <T : Layer> T.onBindData(dataBinder: T.() -> Unit) = this.apply {
32-
this.addOnBindDataListener { this.dataBinder() }
31+
fun <T : Layer> T.doBindData(dataBinder: T.() -> Unit) = this.apply {
32+
this.addDataBindCallback { this.dataBinder() }
3333
}
3434

35-
fun <T : Layer> T.onInitialize(onInitialize: T.() -> Unit) = this.apply {
35+
fun <T : Layer> T.doOnInitialize(onInitialize: T.() -> Unit) = this.apply {
3636
this.addOnInitializeListener { this.onInitialize() }
3737
}
3838

39-
fun <T : Layer> T.onShow(onShow: T.() -> Unit) = this.apply {
40-
this.addOnVisibleChangeListener(object : DefaultOnVisibleChangedListener() {
39+
fun <T : Layer> T.doOnShow(onShow: T.() -> Unit) = this.apply {
40+
this.addOnVisibleChangeListener(object : DefaultOnVisibleChangeListener() {
4141
override fun onShow(layer: Layer) {
4242
onShow.invoke(this@apply)
4343
}
4444
})
4545
}
4646

47-
fun <T : Layer> T.onDismiss(onDismiss: T.() -> Unit) = this.apply {
48-
this.addOnVisibleChangeListener(object : DefaultOnVisibleChangedListener() {
47+
fun <T : Layer> T.doOnDismiss(onDismiss: T.() -> Unit) = this.apply {
48+
this.addOnVisibleChangeListener(object : DefaultOnVisibleChangeListener() {
4949
override fun onDismiss(layer: Layer) {
5050
onDismiss.invoke(this@apply)
5151
}
5252
})
5353
}
5454

55-
fun <T : Layer> T.onPreShow(onPreShow: T.() -> Unit) = this.apply {
55+
fun <T : Layer> T.doOnPreShow(onPreShow: T.() -> Unit) = this.apply {
5656
this.addOnShowListener(object : DefaultOnShowListener() {
5757
override fun onPreShow(layer: Layer) {
5858
this@apply.onPreShow()
5959
}
6060
})
6161
}
6262

63-
fun <T : Layer> T.onPostShow(onPostShow: T.() -> Unit) = this.apply {
63+
fun <T : Layer> T.doOnPostShow(onPostShow: T.() -> Unit) = this.apply {
6464
this.addOnShowListener(object : DefaultOnShowListener() {
6565
override fun onPostShow(layer: Layer) {
6666
this@apply.onPostShow()
6767
}
6868
})
6969
}
7070

71-
fun <T : Layer> T.onPreDismiss(onPreDismiss: T.() -> Unit) = this.apply {
71+
fun <T : Layer> T.doOnPreDismiss(onPreDismiss: T.() -> Unit) = this.apply {
7272
this.addOnDismissListener(object : DefaultOnDismissListener() {
7373
override fun onPreDismiss(layer: Layer) {
7474
this@apply.onPreDismiss()
7575
}
7676
})
7777
}
7878

79-
fun <T : Layer> T.onPostDismiss(onPostDismiss: T.() -> Unit) = this.apply {
79+
fun <T : Layer> T.doOnPostDismiss(onPostDismiss: T.() -> Unit) = this.apply {
8080
this.addOnDismissListener(object : DefaultOnDismissListener() {
8181
override fun onPostDismiss(layer: Layer) {
8282
this@apply.onPostDismiss()

anylayer-ktx/src/main/java/per/goweii/anylayer/ktx/NotificationLayer.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ fun <T : NotificationLayer> T.duration(duration: Long) = this.apply {
100100
}
101101

102102
fun <T : NotificationLayer> T.onNotificationClick(onNotificationClick: T.(view: View) -> Unit) = this.apply {
103-
this.setOnNotificationClickListener { _, view -> this.onNotificationClick(view) }
103+
this.addOnNotificationClickListener { _, view -> this.onNotificationClick(view) }
104104
}
105105

106-
fun <T : NotificationLayer> T.onNotificationLongClick(onNotificationClick: T.(view: View) -> Boolean) = this.apply {
107-
this.setOnNotificationLongClickListener { _, view -> this.onNotificationClick(view) }
106+
fun <T : NotificationLayer> T.doOnNotificationLongClick(onNotificationClick: T.(view: View) -> Boolean) = this.apply {
107+
this.addOnNotificationLongClickListener { _, view -> this.onNotificationClick(view) }
108108
}
109109

110110
fun <T : NotificationLayer> T.autoDismiss(autoDismiss: Boolean) = this.apply {
@@ -115,15 +115,15 @@ fun <T : NotificationLayer> T.swipeTransformer(swipeTransformer: NotificationLay
115115
this.setSwipeTransformer(swipeTransformer)
116116
}
117117

118-
fun <T : NotificationLayer> T.onSwipeStart(onStart: T.() -> Unit) = this.apply {
118+
fun <T : NotificationLayer> T.doOnSwipeStart(onStart: T.() -> Unit) = this.apply {
119119
this.addOnSwipeListener(object : DefaultNotificationOnSwipeListener() {
120120
override fun onStart(layer: NotificationLayer) {
121121
this@apply.onStart()
122122
}
123123
})
124124
}
125125

126-
fun <T : NotificationLayer> T.onSwiping(onSwiping: T.(direction: Int, fraction: Float) -> Unit) = this.apply {
126+
fun <T : NotificationLayer> T.doOnSwiping(onSwiping: T.(direction: Int, fraction: Float) -> Unit) = this.apply {
127127
this.addOnSwipeListener(object : DefaultNotificationOnSwipeListener() {
128128
override fun onSwiping(layer: NotificationLayer,
129129
@SwipeLayout.Direction direction: Int,
@@ -133,7 +133,7 @@ fun <T : NotificationLayer> T.onSwiping(onSwiping: T.(direction: Int, fraction:
133133
})
134134
}
135135

136-
fun <T : NotificationLayer> T.onSwipeEnd(onEnd: T.(direction: Int) -> Unit) = this.apply {
136+
fun <T : NotificationLayer> T.doOnSwipeEnd(onEnd: T.(direction: Int) -> Unit) = this.apply {
137137
this.addOnSwipeListener(object : DefaultNotificationOnSwipeListener() {
138138
override fun onEnd(layer: NotificationLayer, @SwipeLayout.Direction direction: Int) {
139139
this@apply.onEnd(direction)

anylayer-ktx/src/main/java/per/goweii/anylayer/ktx/OverlayLayer.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ fun <T : OverlayLayer> T.paddingBottom(padding: Int) = this.apply {
100100
this.setPaddingBottom(padding)
101101
}
102102

103-
fun <T : OverlayLayer> T.doOnFloatClick(onFloatClick: T.(view: View) -> Unit) = this.apply {
103+
fun <T : OverlayLayer> T.doOnOverlayClick(onFloatClick: T.(view: View) -> Unit) = this.apply {
104104
this.addOnOverlayClickListener { _, view -> this.onFloatClick(view) }
105105
}
106106

107-
fun <T : OverlayLayer> T.onFloatLongClick(onFloatClick: T.(view: View) -> Boolean) = this.apply {
107+
fun <T : OverlayLayer> T.doOnOverlayLongClick(onFloatClick: T.(view: View) -> Boolean) = this.apply {
108108
this.setOnOverlayLongClickListener { _, view -> this.onFloatClick(view) }
109109
}

anylayer-ktx/src/main/java/per/goweii/anylayer/ktx/PopupLayer.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ fun <T : PopupLayer> T.updateLocationInterceptor(interceptor: PopupLayer.UpdateL
88
this.setUpdateLocationInterceptor(interceptor)
99
}
1010

11-
fun <T : PopupLayer> T.onViewTreeScrollChanged(onScrollChanged: T.() -> Unit) = this.apply {
11+
fun <T : PopupLayer> T.doOnViewTreeScrollChanged(onScrollChanged: T.() -> Unit) = this.apply {
1212
this.setOnViewTreeScrollChangedListener { this.onScrollChanged() }
1313
}
1414

15-
fun <T : PopupLayer> T.scrollChangedToDismiss(enable: Boolean) = this.apply {
15+
fun <T : PopupLayer> T.dismissOnScrollChanged(enable: Boolean) = this.apply {
1616
this.setScrollChangedToDismiss(enable)
1717
}
1818

anylayer/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ android {
66

77
dependencies {
88
compileOnly 'androidx.appcompat:appcompat:1.2.0'
9+
implementation 'androidx.cardview:cardview:1.0.0'
910
implementation 'per.goweii.visualeffect:visualeffect-core:1.0.3'
1011
implementation 'per.goweii.visualeffect:visualeffect-blur:1.0.3'
1112
implementation 'per.goweii.visualeffect:visualeffect-view:1.0.3'

0 commit comments

Comments
 (0)