导入书源添加等待框

pull/862/head
gedoor 4 years ago
parent 7482cf8a96
commit bdb96c9629
  1. 4
      app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt
  2. 28
      app/src/main/java/io/legado/app/ui/widget/dialog/WaitDialog.kt
  3. 25
      app/src/main/res/layout/dialog_wait.xml

@ -24,6 +24,7 @@ import io.legado.app.databinding.DialogRecyclerViewBinding
import io.legado.app.databinding.ItemSourceImportBinding import io.legado.app.databinding.ItemSourceImportBinding
import io.legado.app.help.AppConfig import io.legado.app.help.AppConfig
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.alert
import io.legado.app.ui.widget.dialog.WaitDialog
import io.legado.app.utils.dp import io.legado.app.utils.dp
import io.legado.app.utils.putPrefBoolean import io.legado.app.utils.putPrefBoolean
import io.legado.app.utils.splitNotBlank import io.legado.app.utils.splitNotBlank
@ -70,7 +71,10 @@ class ImportBookSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickList
} }
binding.tvOk.visible() binding.tvOk.visible()
binding.tvOk.setOnClickListener { binding.tvOk.setOnClickListener {
val waitDialog = WaitDialog(requireContext())
waitDialog.show()
viewModel.importSelect { viewModel.importSelect {
waitDialog.dismiss()
dismissAllowingStateLoss() dismissAllowingStateLoss()
} }
} }

@ -0,0 +1,28 @@
package io.legado.app.ui.widget.dialog
import android.app.Dialog
import android.content.Context
import io.legado.app.databinding.DialogWaitBinding
@Suppress("unused")
class WaitDialog(context: Context) : Dialog(context) {
val binding = DialogWaitBinding.inflate(layoutInflater)
init {
setCanceledOnTouchOutside(false)
setContentView(binding.root)
}
fun setText(text: String): WaitDialog {
binding.tvMsg.text = text
return this
}
fun setText(res: Int): WaitDialog {
binding.tvMsg.setText(res)
return this
}
}

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/background"
android:gravity="center"
android:padding="20dp"
android:orientation="horizontal">
<ProgressBar
android:id="@+id/pb"
android:layout_width="30dp"
android:layout_height="30dp"
android:indeterminateBehavior="repeat"
android:indeterminateOnly="true" />
<TextView
android:id="@+id/tv_msg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="6dp"
android:gravity="center"
android:text="执行中......"
android:textColor="@color/primaryText" />
</LinearLayout>
Loading…
Cancel
Save