Merge pull request #182 from hingbong/master

feature: TextDialog 添加倒数完自动关闭功能, changelog 倒数完自动关闭
pull/190/head
kunfei 5 years ago committed by GitHub
commit af385b71e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt
  2. 8
      app/src/main/java/io/legado/app/ui/widget/dialog/TextDialog.kt

@ -78,7 +78,7 @@ class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main),
putPrefInt(PreferKey.versionCode, App.INSTANCE.versionCode)
if (!BuildConfig.DEBUG) {
val log = String(assets.open("updateLog.md").readBytes())
TextDialog.show(supportFragmentManager, log, TextDialog.MD, 5000)
TextDialog.show(supportFragmentManager, log, TextDialog.MD, 5000, true)
}
}
}

@ -23,7 +23,8 @@ class TextDialog : BaseDialogFragment() {
fragmentManager: FragmentManager,
content: String?,
mode: Int = 0,
time: Long = 0
time: Long = 0,
autoClose: Boolean = false
) {
TextDialog().apply {
val bundle = Bundle()
@ -32,6 +33,7 @@ class TextDialog : BaseDialogFragment() {
bundle.putLong("time", time)
arguments = bundle
isCancelable = false
this.autoClose = autoClose
}.show(fragmentManager, "textDialog")
}
@ -39,6 +41,8 @@ class TextDialog : BaseDialogFragment() {
private var time = 0L
private var autoClose: Boolean = false
override fun onStart() {
super.onStart()
val dm = DisplayMetrics()
@ -79,6 +83,7 @@ class TextDialog : BaseDialogFragment() {
if (time <= 0) {
view.post {
dialog?.setCancelable(true)
if (autoClose) dialog?.cancel()
}
}
}
@ -86,6 +91,7 @@ class TextDialog : BaseDialogFragment() {
} else {
view.post {
dialog?.setCancelable(true)
if (autoClose) dialog?.cancel()
}
}
}

Loading…
Cancel
Save