|
|
|
|
@ -2,6 +2,7 @@ package com.fongmi.bear.utils; |
|
|
|
|
|
|
|
|
|
import android.content.Context; |
|
|
|
|
import android.content.DialogInterface; |
|
|
|
|
import android.view.LayoutInflater; |
|
|
|
|
import android.view.View; |
|
|
|
|
import android.widget.Toast; |
|
|
|
|
|
|
|
|
|
@ -9,11 +10,13 @@ import androidx.appcompat.app.AlertDialog; |
|
|
|
|
|
|
|
|
|
import com.fongmi.bear.App; |
|
|
|
|
import com.fongmi.bear.R; |
|
|
|
|
import com.fongmi.bear.databinding.DialogProgressBinding; |
|
|
|
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder; |
|
|
|
|
|
|
|
|
|
public class Notify { |
|
|
|
|
|
|
|
|
|
private Toast mToast; |
|
|
|
|
private AlertDialog mProgress; |
|
|
|
|
|
|
|
|
|
private static class Loader { |
|
|
|
|
static volatile Notify INSTANCE = new Notify(); |
|
|
|
|
@ -32,14 +35,26 @@ public class Notify { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void show(Context context, View view, DialogInterface.OnClickListener listener) { |
|
|
|
|
AlertDialog dialog = new MaterialAlertDialogBuilder(context).setView(view).setNegativeButton(R.string.dialog_negative, null).setPositiveButton(R.string.dialog_positive, listener).show(); |
|
|
|
|
AlertDialog dialog = new MaterialAlertDialogBuilder(context).setView(view).setNegativeButton(R.string.dialog_negative, null).setPositiveButton(R.string.dialog_positive, listener).create(); |
|
|
|
|
dialog.getWindow().setDimAmount(0); |
|
|
|
|
dialog.show(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void progress(Context context) { |
|
|
|
|
DialogProgressBinding binding = DialogProgressBinding.inflate(LayoutInflater.from(context)); |
|
|
|
|
get().mProgress = new MaterialAlertDialogBuilder(context).setView(binding.getRoot()).create(); |
|
|
|
|
get().mProgress.getWindow().setBackgroundDrawableResource(android.R.color.transparent); |
|
|
|
|
get().mProgress.show(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void dismiss() { |
|
|
|
|
if (get().mProgress != null && get().mProgress.isShowing()) get().mProgress.dismiss(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void makeText(String message) { |
|
|
|
|
if (mToast != null) mToast.cancel(); |
|
|
|
|
mToast = Toast.makeText(App.get(), message, Toast.LENGTH_LONG); |
|
|
|
|
mToast.show(); |
|
|
|
|
dismiss(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|