57 lines
2.0 KiB
Java
57 lines
2.0 KiB
Java
package com.xscm.moduleutil.utils;
|
|
|
|
|
|
import android.app.Activity;
|
|
|
|
import androidx.fragment.app.DialogFragment;
|
|
import androidx.fragment.app.FragmentActivity;
|
|
import androidx.fragment.app.FragmentManager;
|
|
|
|
import com.blankj.utilcode.util.ActivityUtils;
|
|
import com.xscm.moduleutil.widget.dialog.CommonDialog;
|
|
|
|
public class DialogUtils {
|
|
public static void showNoBalance() {
|
|
Activity activity = ActivityUtils.getTopActivity();
|
|
if (!(activity instanceof FragmentActivity)) {
|
|
return;
|
|
}
|
|
CommonDialog commonDialog = new CommonDialog(activity);
|
|
commonDialog.setContent("您的余额已不足,请及时充值");
|
|
commonDialog.setLeftText("再想想");
|
|
commonDialog.setRightText("去充值");
|
|
commonDialog.setmOnClickListener(new CommonDialog.OnClickListener() {
|
|
@Override
|
|
public void onLeftClick() {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onRightClick() {
|
|
// DialogFragment navigation = (DialogFragment) ARouter.getInstance().build(ARouteConstants.RECHARGE_DIALOG).navigation();
|
|
// navigation.show(((FragmentActivity) activity).getSupportFragmentManager(), "RechargeDialogFragment");
|
|
}
|
|
});
|
|
commonDialog.show();
|
|
}
|
|
|
|
public static void showDialogFragment(Object object) {
|
|
showDialogFragment(object, null);
|
|
}
|
|
|
|
public static void showDialogFragment(Object object, FragmentManager fragmentManager) {
|
|
if (object instanceof DialogFragment) {
|
|
Activity topActivity = ActivityUtils.getTopActivity();
|
|
if (fragmentManager == null && topActivity instanceof FragmentActivity) {
|
|
fragmentManager = ((FragmentActivity) topActivity).getSupportFragmentManager();
|
|
}
|
|
if (fragmentManager != null && !fragmentManager.isStateSaved()) {
|
|
((DialogFragment) object).show(fragmentManager, object.getClass().getSimpleName());
|
|
} else {
|
|
ActivityUtils.finishActivity(topActivity);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|