parent
556f37b1c9
commit
c8fcba483f
@ -1,30 +0,0 @@ |
|||||||
package top.niunaijun.blackdex.util |
|
||||||
|
|
||||||
import android.view.KeyEvent |
|
||||||
import androidx.fragment.app.FragmentManager |
|
||||||
import com.roger.catloadinglibrary.CatLoadingView |
|
||||||
import top.niunaijun.blackdex.R |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @Description: |
|
||||||
* @Author: wukaicheng |
|
||||||
* @CreateDate: 2021/4/30 23:04 |
|
||||||
*/ |
|
||||||
object LoadingUtil { |
|
||||||
|
|
||||||
fun showLoading(loadingView: CatLoadingView, fragmentManager: FragmentManager) { |
|
||||||
if (!loadingView.isAdded) { |
|
||||||
loadingView.setBackgroundColor(R.color.primary) |
|
||||||
loadingView.show(fragmentManager, "") |
|
||||||
fragmentManager.executePendingTransactions() |
|
||||||
loadingView.setClickCancelAble(false) |
|
||||||
loadingView.dialog?.setOnKeyListener { _, keyCode, _ -> |
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_ESCAPE) { |
|
||||||
return@setOnKeyListener true |
|
||||||
} |
|
||||||
false |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,53 @@ |
|||||||
|
package top.niunaijun.blackdex.view.widget |
||||||
|
|
||||||
|
import android.app.Dialog |
||||||
|
import android.os.Bundle |
||||||
|
import android.util.Log |
||||||
|
import android.view.KeyEvent |
||||||
|
import android.view.View |
||||||
|
import androidx.appcompat.app.AlertDialog |
||||||
|
import androidx.fragment.app.DialogFragment |
||||||
|
import top.niunaijun.blackdex.R |
||||||
|
import top.niunaijun.blackdex.databinding.DialogProgressBinding |
||||||
|
import top.niunaijun.blackdex.util.inflate |
||||||
|
|
||||||
|
/** |
||||||
|
* |
||||||
|
* @Description: progress dialog |
||||||
|
* @Author: wukaicheng |
||||||
|
* @CreateDate: 2021/6/7 21:16 |
||||||
|
*/ |
||||||
|
class ProgressDialog : DialogFragment() { |
||||||
|
|
||||||
|
private val TAG = "ProgressDialog" |
||||||
|
|
||||||
|
private val viewBinding: DialogProgressBinding by inflate() |
||||||
|
|
||||||
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { |
||||||
|
val dialog = AlertDialog.Builder(requireContext()) |
||||||
|
.setView(viewBinding.root) |
||||||
|
.setTitle(getString(R.string.classes_progress,1,1)) |
||||||
|
.setCancelable(false) |
||||||
|
.show() |
||||||
|
|
||||||
|
dialog.setCanceledOnTouchOutside(false) |
||||||
|
dialog.setOnKeyListener { _, keyCode, _ -> |
||||||
|
return@setOnKeyListener keyCode == KeyEvent.KEYCODE_BACK |
||||||
|
} |
||||||
|
|
||||||
|
return dialog |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
fun setProgress(progress: Int, maxProgress: Int) { |
||||||
|
requireActivity().runOnUiThread { |
||||||
|
if (progress == 0) { |
||||||
|
viewBinding.progress.max = maxProgress |
||||||
|
} |
||||||
|
viewBinding.progress.progress = progress |
||||||
|
dialog?.setTitle(getString(R.string.classes_progress,progress,maxProgress)) |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:paddingStart="24dp" |
||||||
|
android:paddingEnd="24dp" |
||||||
|
android:paddingTop="12dp" |
||||||
|
android:paddingBottom="12dp" |
||||||
|
android:orientation="vertical" |
||||||
|
android:layout_height="wrap_content"> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:id="@+id/title" |
||||||
|
android:text="@string/dumping" |
||||||
|
android:layout_width="wrap_content" |
||||||
|
android:layout_height="wrap_content"/> |
||||||
|
<ProgressBar |
||||||
|
android:id="@+id/progress" |
||||||
|
style="?android:attr/progressBarStyleHorizontal" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_marginTop="12dp" |
||||||
|
android:layout_marginBottom="12dp"/> |
||||||
|
|
||||||
|
</LinearLayout> |
Loading…
Reference in new issue