Skip to content

Commit a37277c

Browse files
committed
更改Kotlin调用方式
1 parent 125ef15 commit a37277c

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

photoviewer/src/main/java/com/wanglu/photoviewerlibrary/PhotoViewer.kt

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.animation.LayoutTransition
44
import android.animation.ObjectAnimator
55
import android.annotation.SuppressLint
66
import android.app.Fragment
7+
import android.app.ProgressDialog.show
78
import android.content.pm.ActivityInfo
89
import android.graphics.Color
910
import android.os.Build
@@ -29,10 +30,6 @@ import android.view.View.SYSTEM_UI_FLAG_LAYOUT_STABLE
2930
import android.view.View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
3031

3132

32-
33-
34-
35-
3633
@SuppressLint("StaticFieldLeak")
3734
/**
3835
* Created by WangLu on 2018/7/15.
@@ -56,21 +53,32 @@ object PhotoViewer {
5653

5754
private var indicatorType = INDICATOR_TYPE_DOT // 默认type为小圆点
5855

59-
interface OnPhotoViewerCreatedListener{
56+
interface OnPhotoViewerCreatedListener {
6057
fun onCreated()
6158
}
6259

6360

64-
interface OnPhotoViewerDestroyListener{
61+
interface OnPhotoViewerDestroyListener {
6562
fun onDestroy()
6663
}
6764

68-
fun setOnPhotoViewerCreatedListener(l: OnPhotoViewerCreatedListener): PhotoViewer{
69-
mCreatedInterface = l
65+
fun setOnPhotoViewerCreatedListener(l: () -> Unit): PhotoViewer {
66+
67+
mCreatedInterface = object : OnPhotoViewerCreatedListener {
68+
override fun onCreated() {
69+
l()
70+
}
71+
72+
}
7073
return this
7174
}
72-
fun setOnPhotoViewerDestroyListener(l : OnPhotoViewerDestroyListener): PhotoViewer{
73-
mDestroyInterface = l
75+
76+
fun setOnPhotoViewerDestroyListener(l: () -> Unit): PhotoViewer {
77+
mDestroyInterface = object : OnPhotoViewerDestroyListener {
78+
override fun onDestroy() {
79+
l()
80+
}
81+
}
7482
return this
7583
}
7684

@@ -249,7 +257,7 @@ object PhotoViewer {
249257
fragments.clear()
250258

251259

252-
if(mDestroyInterface != null){
260+
if (mDestroyInterface != null) {
253261
mDestroyInterface!!.onDestroy()
254262
}
255263
}
@@ -414,7 +422,7 @@ object PhotoViewer {
414422
}
415423
decorView.addView(frameLayout, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
416424

417-
if(mCreatedInterface != null){
425+
if (mCreatedInterface != null) {
418426
mCreatedInterface!!.onCreated()
419427
}
420428
}

0 commit comments

Comments
 (0)