Files
assistant-android/app/src/main/java/com/gh/common/util/DialogUtils.java

1335 lines
58 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.gh.common.util;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.CountDownTimer;
import android.provider.Settings;
import android.text.Html;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.facebook.drawee.view.SimpleDraweeView;
import com.gh.common.constant.Config;
import com.gh.common.filter.RegionSetting;
import com.gh.common.xapk.XapkDialogHelper;
import com.gh.gamecenter.R;
import com.gh.gamecenter.ShellActivity;
import com.gh.gamecenter.adapter.ReportReasonAdapter;
import com.gh.gamecenter.common.base.TrackableDialog;
import com.gh.gamecenter.common.callback.CancelListener;
import com.gh.gamecenter.common.callback.ConfirmListener;
import com.gh.gamecenter.common.databinding.DialogAlertDefaultBinding;
import com.gh.gamecenter.common.entity.SimpleGameEntity;
import com.gh.gamecenter.common.entity.SuggestType;
import com.gh.gamecenter.common.utils.DialogHelper;
import com.gh.gamecenter.common.utils.ExtensionsKt;
import com.gh.gamecenter.common.utils.ImageUtils;
import com.gh.gamecenter.common.utils.NetworkUtils;
import com.gh.gamecenter.common.utils.SensorsBridge;
import com.gh.gamecenter.common.view.DrawableView;
import com.gh.gamecenter.common.view.MaxHeightLinearLayout;
import com.gh.gamecenter.common.view.MaxHeightNestedScrollView;
import com.gh.gamecenter.common.view.VerticalItemDecoration;
import com.gh.gamecenter.core.AppExecutor;
import com.gh.gamecenter.core.utils.DisplayUtils;
import com.gh.gamecenter.core.utils.EmptyCallback;
import com.gh.gamecenter.core.utils.MtaHelper;
import com.gh.gamecenter.core.utils.SPUtils;
import com.gh.gamecenter.core.utils.SpanBuilder;
import com.gh.gamecenter.core.utils.ToastUtils;
import com.gh.gamecenter.databinding.DialogAddressConfirmationBinding;
import com.gh.gamecenter.databinding.DialogBindPhoneBinding;
import com.gh.gamecenter.databinding.DialogPackageParseErrorBinding;
import com.gh.gamecenter.databinding.DialogRelievePhoneBinding;
import com.gh.gamecenter.databinding.DialogReportReasonBinding;
import com.gh.gamecenter.databinding.DialogWechatReserveSuccessBinding;
import com.gh.gamecenter.databinding.ImprintContentItemBinding;
import com.gh.gamecenter.entity.BadgeEntity;
import com.gh.gamecenter.entity.ReserveReminderEntity;
import com.gh.gamecenter.entity.TrackableEntity;
import com.gh.gamecenter.feature.entity.ApkEntity;
import com.gh.gamecenter.feature.entity.Badge;
import com.gh.gamecenter.feature.entity.GameEntity;
import com.gh.gamecenter.feature.entity.SettingsEntity;
import com.gh.gamecenter.help.HelpAndFeedbackBridge;
import com.gh.gamecenter.setting.SettingBridge;
import com.halo.assistant.fragment.reserve.ReserveReminderContainerFragment;
import com.lightgame.download.DownloadEntity;
import com.lightgame.utils.AppManager;
import com.lightgame.utils.Util_System_Keyboard;
import com.lightgame.utils.Utils;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
import kotlin.Unit;
import kotlin.collections.CollectionsKt;
import kotlin.jvm.functions.Function0;
public class DialogUtils {
public static Dialog showWaitDialog(Context context, String msg) {
context = checkDialogContext(context);
Dialog dialog = new Dialog(context);
View view = View.inflate(context, com.gh.gamecenter.common.R.layout.set_wait_dialog, null);
TextView message = view.findViewById(com.gh.gamecenter.common.R.id.set_wait_message);
message.setText(msg);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(view);
dialog.setCanceledOnTouchOutside(false);
dialog.getWindow().setBackgroundDrawableResource(com.gh.gamecenter.common.R.drawable.background_shape_white_radius_8);
WindowManager.LayoutParams layoutParams = dialog.getWindow().getAttributes();
layoutParams.width = DisplayUtils.dip2px(160);
dialog.getWindow().setAttributes(layoutParams);
dialog.show();
return dialog;
}
public static void checkDownload(Context context, String size, String gameId, String gameName, String gameCategoryChinese, CheckDownloadCallBack callBack) {
if (!NetworkUtils.isNetworkConnected(context)) {
showNoConnectionDownloadDialog(context, () -> {
},
() -> callBack.onResponse(true));
} else if (NetworkUtils.isWifiConnected(context)
|| filter4GorSize(context, size)) {
callBack.onResponse(false);
} else if (!SPUtils.getBoolean(getTrafficDownloadHintKey(), true)) {
AppExecutor.getUiExecutor().executeWithDelay(() -> Utils.toast(context, "当前使用移动网络下载,请注意流量消耗"), 500);
callBack.onResponse(false);
} else {
// MtaHelper.onEvent("移动网络下载", NetworkUtils.getMobileNetworkType(context), "出现弹窗提示");
showDownloadDialog(context,
() -> callBack.onResponse(false),
() -> callBack.onResponse(true),
gameId,
gameName,
gameCategoryChinese);
}
}
private static String getTrafficDownloadHintKey() {
return PackageUtils.getGhVersionName() + "traffic_download_hint";
}
private static boolean filter4GorSize(Context context, String size) {
try {
if (TextUtils.isEmpty(size)) {
return false;
}
String mb = size.toUpperCase().replace("MB", "").trim();
Float i = Float.valueOf(mb);
if (NetworkUtils.isWifiOr4GConnected(context) && i <= 50) {
AppExecutor.getUiExecutor().executeWithDelay(() -> Utils.toast(context, "当前使用移动网络下载,请注意流量消耗"), 500);
return true;
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
public static void showNoConnectionDownloadDialog(Context context, ConfirmListener listener, CancelListener cancelListener) {
DialogHelper.showDialog(context, "下载提示", "网络异常,请检查手机网络状态", "知道了", "WiFi自动下载", listener::onConfirm, cancelListener::onCancel, false, "", "");
}
public static void showDownloadDialog(Context context, ConfirmListener listener, CancelListener cancelListener, String gameId, String gameName, String gameCategoryChinese) {
SensorsBridge.trackDownloadMobileDataDialogShow(gameId, gameName, gameCategoryChinese);
context = checkDialogContext(context);
NewFlatLogUtils.logDownloadMobileDataDialogShow(gameId, gameName);
final Dialog dialog = new Dialog(context, com.gh.gamecenter.common.R.style.GhAlertDialog);
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_download_traffic, null);
View allowOnce = contentView.findViewById(R.id.allow_once);
View allowAlways = contentView.findViewById(R.id.allow_always);
View wifiAuto = contentView.findViewById(R.id.wifi_auto);
Context finalContext = context;
allowOnce.setOnClickListener(v -> {
NewFlatLogUtils.logDownloadMobileDataDialogClick(gameId, gameName, "允许一次");
SensorsBridge.trackDownloadMobileDataDialogClick("允许一次", gameId, gameName, gameCategoryChinese);
AppExecutor.getUiExecutor().executeWithDelay(() -> {
Utils.toast(finalContext, "已使用移动网络下载,请注意流量消耗");
}, 500);
listener.onConfirm();
dialog.dismiss();
// MtaHelper.onEvent("移动网络下载", NetworkUtils.getMobileNetworkType(finalContext), "本次允许");
});
wifiAuto.setOnClickListener(v -> {
NewFlatLogUtils.logDownloadMobileDataDialogClick(gameId, gameName, "WiFi自动下载");
SensorsBridge.trackDownloadMobileDataDialogClick("WiFi自动下载", gameId, gameName, gameCategoryChinese);
cancelListener.onCancel();
dialog.dismiss();
// MtaHelper.onEvent("移动网络下载", NetworkUtils.getMobileNetworkType(finalContext), "连上WiFi后自动下载");
});
allowAlways.setOnClickListener(v -> {
NewFlatLogUtils.logDownloadMobileDataDialogClick(gameId, gameName, "总是允许");
SensorsBridge.trackDownloadMobileDataDialogClick("总是允许", gameId, gameName, gameCategoryChinese);
SPUtils.setBoolean(getTrafficDownloadHintKey(), false);
AppExecutor.getUiExecutor().executeWithDelay(() -> {
// 显示了弹窗以后,即便下面这个 toast 放在 listener.onConfirm 后调用也是显示 listener.onConfirm 里的 toast
// 喷了,延时包治疑难杂症
Utils.toast(finalContext, "已使用移动网络下载,请注意流量消耗");
}, 500);
listener.onConfirm();
dialog.dismiss();
// MtaHelper.onEvent("移动网络下载", NetworkUtils.getMobileNetworkType(finalContext), "总是允许");
});
dialog.setOnCancelListener(downloadDialog -> {
NewFlatLogUtils.logDownloadMobileDataDialogClick(gameId, gameName, "关闭弹窗");
SensorsBridge.trackDownloadMobileDataDialogClick("关闭弹窗", gameId, gameName, gameCategoryChinese);
});
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(contentView);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.show();
}
public static void showSignDialog(Context context, String title, CharSequence message, CharSequence message2
, String positive, final ConfirmListener cmListener) {
context = checkDialogContext(context);
final Dialog dialog = new Dialog(context);
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_sign, null);
TextView contentTv = contentView.findViewById(R.id.dialog_content);
TextView titleTv = contentView.findViewById(R.id.dialog_title);
TextView negativeTv = contentView.findViewById(R.id.dialog_negative);
TextView positiveTv = contentView.findViewById(R.id.dialog_positive);
TextView content2Tv = contentView.findViewById(R.id.dialog_content2);
contentTv.setText(Html.fromHtml(message.toString()));
content2Tv.setText(Html.fromHtml(message2.toString()));
titleTv.setText(Html.fromHtml(title));
positiveTv.setText(positive);
negativeTv.setOnClickListener(view -> dialog.dismiss());
positiveTv.setOnClickListener(view -> {
if (cmListener != null) {
cmListener.onConfirm();
}
dialog.dismiss();
});
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(contentView);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.show();
}
/**
* 特殊:目前只在提交问题错误返回时弹出
*/
public static Dialog showCommunityDialog(Context context,
String title,
String contentTitle,
String contentDes,
String negative,
String positive,
final CancelListener clListener,
final ConfirmListener cmListener) {
context = checkDialogContext(context);
final Dialog dialog = new Dialog(context, com.gh.gamecenter.common.R.style.GhAlertDialog);
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_community, null);
View contentContainer = contentView.findViewById(R.id.content_container);
TextView titleTv = contentView.findViewById(R.id.title);
TextView contentTitleTv = contentView.findViewById(R.id.content_title);
TextView contentDesTv = contentView.findViewById(R.id.content_des);
TextView negativeTv = contentView.findViewById(R.id.negative);
TextView positiveTv = contentView.findViewById(R.id.positive);
titleTv.setText(title);
contentTitleTv.setText(contentTitle);
contentDesTv.setText(contentDes);
if (TextUtils.isEmpty(negative)) {
negativeTv.setVisibility(View.GONE);
} else {
negativeTv.setVisibility(View.VISIBLE);
negativeTv.setText(negative);
}
if (TextUtils.isEmpty(positive)) {
positiveTv.setVisibility(View.GONE);
} else {
positiveTv.setText(positive);
positiveTv.setVisibility(View.VISIBLE);
}
negativeTv.setOnClickListener(view -> {
if (clListener != null) {
clListener.onCancel();
}
dialog.dismiss();
});
positiveTv.setOnClickListener(view -> {
if (cmListener != null) {
cmListener.onConfirm();
}
dialog.dismiss();
});
contentContainer.setOnClickListener(v -> {
if (cmListener != null) {
cmListener.onConfirm();
}
dialog.dismiss();
});
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(contentView);
dialog.show();
return dialog;
}
public static void showPrivacyPolicyDisallowDialog(Context context,
EmptyCallback callback) {
final Context activityContext = checkDialogContext(context);
final Dialog dialog = new Dialog(activityContext, com.gh.gamecenter.common.R.style.DialogWindowTransparent);
View contentView = LayoutInflater.from(activityContext).inflate(R.layout.dialog_disallow_privacy_policy, null);
View backButton = contentView.findViewById(R.id.back_button);
View reviewButton = contentView.findViewById(R.id.review_button);
backButton.setOnClickListener(v -> {
// 用户未同意隐私策略不应该触发 MTA 事件
// MtaHelper.onEvent("隐私政策弹窗", "退出提示弹窗", "退出应用");
dialog.dismiss();
AppManager.getInstance().appExit(activityContext);
});
reviewButton.setOnClickListener(v -> {
// MtaHelper.onEvent("隐私政策弹窗", "退出提示弹窗", "再次查看");
callback.onCallback();
dialog.dismiss();
//showPrivacyPolicyDialog(activityContext, entity, callback);
});
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCancelable(false);
dialog.setContentView(contentView);
try {
dialog.show();
} catch (Exception ignored) {
}
}
/**
* 特殊:目前只在提交问题错误返回时弹出
*/
public static Dialog showUploadDraftDialog(Context context,
final CancelListener clListener,
final ConfirmListener cmListener) {
context = checkDialogContext(context);
final Dialog dialog = new Dialog(context, com.gh.gamecenter.common.R.style.GhAlertDialog);
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_video_upload_draft, null);
TextView negativeTv = contentView.findViewById(R.id.negative);
TextView positiveTv = contentView.findViewById(R.id.positive);
TextView content = contentView.findViewById(R.id.content);
positiveTv.setBackground(DrawableView.getOvalDrawable(com.gh.gamecenter.common.R.color.ui_background, 999));
negativeTv.setBackground(DrawableView.getOvalDrawable(com.gh.gamecenter.common.R.color.primary_theme, 999));
content.setText(Html.fromHtml(context.getString(R.string.video_upload_draft_dialog_content)));
negativeTv.setOnClickListener(view -> {
if (clListener != null) {
clListener.onCancel();
}
dialog.dismiss();
});
positiveTv.setOnClickListener(view -> {
if (cmListener != null) {
cmListener.onConfirm();
}
dialog.dismiss();
});
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(contentView);
dialog.show();
return dialog;
}
public static Dialog showTrackableDialog(Context context,
String title,
CharSequence message,
String positive,
String negative,
final ConfirmListener cmListener,
final CancelListener clListener,
TrackableEntity trackableEntity) {
return showTrackableDialog(context, false, title, message, positive, negative, cmListener, clListener, trackableEntity);
}
/**
* @param useRoundedCornerStyle 使用圆角样式
*/
public static Dialog showTrackableDialog(Context context,
boolean useRoundedCornerStyle,
String title,
CharSequence message,
String positive,
String negative,
final ConfirmListener cmListener,
final CancelListener clListener,
TrackableEntity trackableEntity) {
context = checkDialogContext(context);
final TrackableDialog dialog = new TrackableDialog(context,
com.gh.gamecenter.common.R.style.GhAlertDialog,
trackableEntity.getEvent(),
trackableEntity.getKey(),
trackableEntity.getValue(),
trackableEntity.getCancelValue(),
trackableEntity.getKeyBackValue(),
trackableEntity.getLogShowEvent());
View contentView;
if (useRoundedCornerStyle) {
contentView = LayoutInflater.from(context).inflate(R.layout.dialog_alert_with_rounded_corner, null);
Window window = dialog.getWindow();
if (window != null) {
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
} else {
contentView = LayoutInflater.from(context).inflate(com.gh.gamecenter.common.R.layout.dialog_alert, null);
}
TextView contentTv = contentView.findViewById(R.id.dialog_content);
TextView titleTv = contentView.findViewById(R.id.dialog_title);
TextView negativeTv = contentView.findViewById(R.id.dialog_negative);
TextView positiveTv = contentView.findViewById(R.id.dialog_positive);
if (message.toString().contains("红包奖励")) {//将红包奖励四个字标红
String str = message.toString().substring(0, message.toString().indexOf("红包奖励")) + "<font color='#FF0000'>红包奖励</font>";
contentTv.setText(Html.fromHtml(str));
} else {
contentTv.setText(message);
}
titleTv.setText(title);
negativeTv.setText(negative);
positiveTv.setText(positive);
negativeTv.setOnClickListener(view -> {
if (clListener != null) {
clListener.onCancel();
}
dialog.dismiss();
});
positiveTv.setOnClickListener(view -> {
if (cmListener != null) {
cmListener.onConfirm();
}
dialog.dismiss();
});
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(contentView);
dialog.show();
return dialog;
}
public static Dialog fixWebViewKeyboardNotWorking(Activity activity) {
final Dialog dialog = new Dialog(activity, R.style.TransparentDialog);
View view = new View(activity);
view.setOnClickListener(v -> dialog.dismiss());
view.postDelayed(() -> {
if (!activity.isFinishing()) {
dialog.show();
dialog.dismiss();
}
}, 500);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(view);
return dialog;
}
public static Dialog showUsageStatsDialog(Context context, final ConfirmListener cmListener, final CancelListener clListener) {
context = checkDialogContext(context);
final Dialog dialog = new Dialog(context, com.gh.gamecenter.common.R.style.GhAlertDialog);
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_usage_stats, null);
TextView negativeTv = contentView.findViewById(R.id.dialog_negative);
TextView positiveTv = contentView.findViewById(R.id.dialog_positive);
Window window = dialog.getWindow();
if (window != null) {
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
negativeTv.setOnClickListener(view -> {
if (clListener != null) {
clListener.onCancel();
}
dialog.dismiss();
});
positiveTv.setOnClickListener(view -> {
if (cmListener != null) {
cmListener.onConfirm();
}
dialog.dismiss();
});
dialog.setOnDismissListener(dialog1 -> {
if (clListener != null) {
clListener.onCancel();
}
});
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(contentView);
dialog.show();
return dialog;
}
public static void showDownloadMutexDialog(Context context) {
context = checkDialogContext(context);
final Dialog dialog = new Dialog(context, com.gh.gamecenter.common.R.style.GhAlertDialog);
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_downlaod_mutex, null);
TextView positive = contentView.findViewById(R.id.dialog_positive);
CountDownTimer timer = new CountDownTimer(6000, 1000) {
public void onTick(long millisUntilFinished) {
positive.setText(("我知道了(" + millisUntilFinished / 1000 + ""));
}
public void onFinish() {
dialog.dismiss();
}
};
timer.start();
positive.setOnClickListener(v -> {
dialog.dismiss();
});
Window window = dialog.getWindow();
if (window != null) {
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(contentView);
dialog.show();
}
// 海外下载地址弹窗
public static void showOverseaDownloadDialog(Context context, GameEntity gameEntity, @NonNull ConfirmListener listener) {
SensorsBridge.trackOverseasAddressDialogShow(
gameEntity.getId(),
gameEntity.getName() != null ? gameEntity.getName() : "",
gameEntity.getCategoryChinese()
);
context = checkDialogContext(context);
final Dialog dialog = new Dialog(context, com.gh.gamecenter.common.R.style.GhAlertDialog);
DialogAddressConfirmationBinding binding = DialogAddressConfirmationBinding.inflate(LayoutInflater.from(context), null, false);
View contentView = binding.getRoot();
binding.gameIcon.displayGameIcon(gameEntity);
AtomicBoolean dismissByTouchInside = new AtomicBoolean(false);
binding.closeIv.setOnClickListener(v -> {
dismissByTouchInside.set(true);
SensorsBridge.trackOverseasAddressDialogClick(
"取消",
gameEntity.getId(),
gameEntity.getName() != null ? gameEntity.getName() : "",
gameEntity.getCategoryChinese()
);
dialog.dismiss();
});
ApkEntity apkEntity = CollectionsKt.firstOrNull(gameEntity.getApk());
String size = apkEntity == null ? "" : apkEntity.getSize();
if ("show&download".equals(gameEntity.getOverseasAddressDialog().getStatus())) {
if (apkEntity != null) {
apkEntity.setUrl(gameEntity.getOverseasAddressDialog().getLink());
}
}
binding.urlTv.setText(gameEntity.getOverseasAddressDialog().getLink());
binding.downloadBtn.setText("下载(" + size + "");
binding.downloadBtn.setOnClickListener(v -> {
dismissByTouchInside.set(true);
SensorsBridge.trackOverseasAddressDialogClick(
"下载",
gameEntity.getId(),
gameEntity.getName() != null ? gameEntity.getName() : "",
gameEntity.getCategoryChinese()
);
listener.onConfirm();
dialog.dismiss();
});
Window window = dialog.getWindow();
if (window != null) {
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
dialog.setOnDismissListener(dialog1 -> {
if (!dismissByTouchInside.get()) {
SensorsBridge.trackOverseasAddressDialogClick(
"关闭弹窗",
gameEntity.getId(),
gameEntity.getName() != null ? gameEntity.getName() : "",
gameEntity.getCategoryChinese()
);
}
});
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(contentView);
dialog.show();
}
// 跳转第三方落地页下载弹窗
public static void showLandPageAddressDialog(Context context, GameEntity gameEntity, @NonNull ConfirmListener listener) {
context = checkDialogContext(context);
final Dialog dialog = new Dialog(context, com.gh.gamecenter.common.R.style.GhAlertDialog);
DialogAddressConfirmationBinding binding = DialogAddressConfirmationBinding.inflate(LayoutInflater.from(context), null, false);
View contentView = binding.getRoot();
binding.gameIcon.displayGameIcon(gameEntity);
binding.gameNameTv.setText(context.getString(R.string.dialog_land_page_address_hint, gameEntity.getName()));
AtomicBoolean dismissByButton = new AtomicBoolean(false);
binding.closeIv.setOnClickListener(v -> {
dismissByButton.set(true);
SensorsBridge.INSTANCE.trackJumpLandPageAddressDialogClick(
"取消",
gameEntity.getId(),
gameEntity.getName() != null ? gameEntity.getName() : "",
gameEntity.getCategoryChinese()
);
dialog.dismiss();
});
binding.urlTv.setText(gameEntity.getLandPageAddressDialog().getLink());
String downloadText = gameEntity.isLandPageAddressDialogShowOnly()
? "下载(" + gameEntity.getApk().get(0).getSize() + ""
: context.getString(R.string.dialog_land_page_address_confirm);
binding.downloadBtn.setText(downloadText);
binding.downloadBtn.setOnClickListener(v -> {
dismissByButton.set(true);
SensorsBridge.INSTANCE.trackJumpLandPageAddressDialogClick(
"前往第三方网站下载游戏",
gameEntity.getId(),
gameEntity.getName() != null ? gameEntity.getName() : "",
gameEntity.getCategoryChinese()
);
listener.onConfirm();
dialog.dismiss();
});
dialog.setOnDismissListener(dialog1 -> {
if (!dismissByButton.get()) {
SensorsBridge.INSTANCE.trackJumpLandPageAddressDialogClick(
"关闭弹窗",
gameEntity.getId(),
gameEntity.getName() != null ? gameEntity.getName() : "",
gameEntity.getCategoryChinese()
);
}
});
Window window = dialog.getWindow();
if (window != null) {
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(contentView);
dialog.show();
SensorsBridge.INSTANCE.trackJumpLandPageAddressDialogShow(
gameEntity.getId(),
gameEntity.getName() != null ? gameEntity.getName() : "",
gameEntity.getCategoryChinese()
);
}
public static void showGameH5DownloadDialog(Context context, GameEntity gameEntity, RegionSetting.GameH5Download gameH5Download) {
context = checkDialogContext(context);
final Dialog dialog = new Dialog(context, com.gh.gamecenter.common.R.style.GhAlertDialog);
DialogAddressConfirmationBinding binding = DialogAddressConfirmationBinding.inflate(LayoutInflater.from(context), null, false);
View contentView = binding.getRoot();
binding.gameIcon.displayGameIcon(gameEntity);
binding.gameNameTv.setText(context.getString(R.string.dialog_oversea_hint, gameEntity.getName()));
binding.closeIv.setOnClickListener(v -> dialog.dismiss());
Context finalContext = context;
binding.urlTv.setText(gameH5Download.getDownloadLink());
binding.downloadBtn.setText(gameH5Download.getButtonText());
binding.downloadBtn.setOnClickListener(v -> {
DirectUtils.directToExternalBrowser(finalContext, gameH5Download.getH5Link());
dialog.dismiss();
});
Window window = dialog.getWindow();
if (window != null) {
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(contentView);
dialog.show();
}
public static void showImprintDialog(Context context, GameEntity gameEntity, String titleName) {
context = checkDialogContext(context);
Dialog dialog = new Dialog(context, R.style.full_dialog);
View inflate = LayoutInflater.from(context).inflate(R.layout.imprint_dialog, null);
dialog.setContentView(inflate);
dialog.show();
Window window = dialog.getWindow();
WindowManager.LayoutParams params;
if (window != null) {
params = window.getAttributes();
params.width = (int) (context.getResources().getDisplayMetrics().widthPixels * 0.9);
window.setAttributes(params);
window.setBackgroundDrawableResource(com.gh.gamecenter.common.R.drawable.textview_white_up);
}
inflate.findViewById(R.id.imprint_close).setOnClickListener(v -> dialog.dismiss());
LinearLayout content = inflate.findViewById(R.id.imprint_content);
((TextView) inflate.findViewById(R.id.imprint_title)).setText(titleName);
View head = LayoutInflater.from(context).inflate(R.layout.imprint_content_item, null);
content.addView(head, LinearLayout.LayoutParams.MATCH_PARENT, DisplayUtils.dip2px(30));
MaxHeightLinearLayout imprintContainer = inflate.findViewById(R.id.imprint_container);
imprintContainer.setMaxHeight((int) (context.getResources().getDisplayMetrics().heightPixels * 0.8));
ArrayList<ApkEntity> list = gameEntity.getApk();
SettingsEntity settings = Config.getSettings();
for (int i = 0; i < list.size(); i++) {
ApkEntity apk = gameEntity.getApk().get(i);
if (settings != null && settings.getGameDownloadBlackList().contains(apk.getPackageName())) {
continue;
}
View item = LayoutInflater.from(context).inflate(R.layout.imprint_content_item, null);
ImprintContentItemBinding bind = ImprintContentItemBinding.bind(item);
String platform = TextUtils.isEmpty(apk.getRemark()) ? apk.getPlatformName() : apk.getPlatformName() + "\n" + apk.getRemark();
bind.imprintPlatform.setText(platform);
bind.imprintVersion.setText(apk.getVersion());
bind.imprintTime.setText(NewsUtils.getFormattedTime(apk.getTime() != null ? apk.getTime() : 0));
content.addView(item, LinearLayout.LayoutParams.MATCH_PARENT, DisplayUtils.dip2px(40));
}
// close line
View view = new View(context);
view.setBackgroundColor(context.getResources().getColor(com.gh.gamecenter.common.R.color.text_5d5d5d));
view.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, DisplayUtils.dip2px(1)));
content.addView(view);
}
public static void showKaifuRemindDialog(Context context, String content, String gameName) {
context = checkDialogContext(context);
final Dialog dialog = new TrackableDialog(context, com.gh.gamecenter.common.R.style.GhAlertDialog, "开服说明弹窗", "弹窗", gameName, null, null, true);
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_kaifu_remind, null);
TextView contentTv = contentView.findViewById(R.id.contentTv);
MaxHeightNestedScrollView scrollView = contentView.findViewById(R.id.scrollView);
contentTv.setText(Html.fromHtml(content));
TextView ok = contentView.findViewById(R.id.dialog_ok);
scrollView.setScrollChangedListener((l, t, oldl, oldt) -> {
MtaHelper.onEvent("开服说明弹窗", "滑动内容", gameName);
});
ok.setOnClickListener(v -> {
MtaHelper.onEvent("开服说明弹窗", "弹窗", "点击我知道了");
MtaHelper.onEvent("开服说明弹窗", "点击我知道了", gameName);
dialog.dismiss();
});
Window window = dialog.getWindow();
if (window != null) {
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(contentView);
dialog.show();
}
public static void showStopServerExplanationDialog(Context context, String content, String gameName) {
context = checkDialogContext(context);
final Dialog dialog = new TrackableDialog(context, com.gh.gamecenter.common.R.style.GhAlertDialog, "评论说明弹窗", "弹窗", gameName, null, null, true);
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_stop_service_explanation, null);
TextView contentTv = contentView.findViewById(R.id.contentTv);
MaxHeightNestedScrollView scrollView = contentView.findViewById(R.id.scrollView);
if (TextUtils.isEmpty(content)) {
content = context.getString(R.string.rating_protection);
}
contentTv.setText(content);
TextView ok = contentView.findViewById(R.id.dialog_ok);
scrollView.setScrollChangedListener((l, t, oldl, oldt) -> {
MtaHelper.onEvent("评论说明弹窗", "滑动内容", gameName);
});
ok.setOnClickListener(v -> {
MtaHelper.onEvent("评论说明弹窗", "弹窗", "点击我知道了");
MtaHelper.onEvent("评论说明弹窗", "点击我知道了", gameName);
dialog.dismiss();
});
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(contentView);
dialog.show();
Window window = dialog.getWindow();
if (window != null) {
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
WindowManager.LayoutParams params = window.getAttributes();
params.width = context.getResources().getDisplayMetrics().widthPixels - DisplayUtils.dip2px(60f);
window.setAttributes(params);
}
}
public static void showPluggableNeverRemindDialog(Context context, String nameAndPlatform, @NonNull ConfirmListener listener) {
String content = "助手首页将不再提示《" + nameAndPlatform + "》的所有插件化消息,确定吗?";
DialogHelper.showDialog(context, "温馨提醒", content, "确定", "取消", listener::onConfirm, () -> {
}, false, "", "");
}
public static void showRegulationTestDialog(Context context, @NonNull ConfirmListener confirmListener, @NonNull CancelListener cancelListener) {
context = checkDialogContext(context);
SensorsBridge.trackEvent("EtiquetteTestDialogShow");
final Dialog dialog = new TrackableDialog(
context,
com.gh.gamecenter.common.R.style.GhAlertDialog,
"礼仪考试",
"礼仪考试弹窗",
null, null, null,
true);
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_regulation_test, null);
View cancelBtn = contentView.findViewById(R.id.cancel);
View confirmBtn = contentView.findViewById(R.id.confirm);
View linkTv = contentView.findViewById(R.id.link);
Context finalContext = context;
linkTv.setOnClickListener(v -> {
MtaHelper.onEvent("礼仪考试", "礼仪考试弹窗", "了解更多");
DirectUtils.directToArticle(finalContext, "5f4477be25e07e19be4e2a22", "(礼仪测试弹窗)");
});
cancelBtn.setOnClickListener(v -> {
cancelListener.onCancel();
MtaHelper.onEvent("礼仪考试", "礼仪考试弹窗", "跳过");
SensorsBridge.trackEvent("EtiquetteTestDialogClick", "button_name", "跳过");
dialog.dismiss();
});
Context finalContext1 = context;
confirmBtn.setOnClickListener(v -> {
Util_System_Keyboard.hideSoftKeyboard((Activity) finalContext1);
MtaHelper.onEvent("礼仪考试", "礼仪考试弹窗", "确定");
SensorsBridge.trackEvent("EtiquetteTestDialogClick", "button_name", "进入考试");
confirmListener.onConfirm();
dialog.dismiss();
});
Window window = dialog.getWindow();
if (window != null) {
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(contentView);
dialog.show();
}
public static void showUnzipFailureDialog(Context context, DownloadEntity downloadEntity) {
XapkDialogHelper.INSTANCE.showUnzipFailureDialog(context, downloadEntity, false);
}
public static void showNoticeDialog(Context context, String title, String content, @NonNull ConfirmListener listener) {
context = checkDialogContext(context);
final Dialog dialog = new Dialog(context, com.gh.gamecenter.common.R.style.DialogWindowTransparent);
View contentView = LayoutInflater.from(context).inflate(com.gh.gamecenter.common.R.layout.dialog_notice, null);
TextView titleTv = contentView.findViewById(R.id.dialog_title);
TextView contentTv = contentView.findViewById(R.id.dialog_content);
if (title == null) {
titleTv.setVisibility(View.GONE);
} else {
titleTv.setVisibility(View.VISIBLE);
titleTv.setText(title);
}
contentTv.setText(content);
contentView.findViewById(R.id.dialog_ok).setOnClickListener(v -> {
listener.onConfirm();
dialog.dismiss();
});
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(contentView);
dialog.show();
}
public static void showViewBadgeDialog(Context context, Badge badge, ConfirmListener listener) {
context = checkDialogContext(context);
final Dialog dialog = new Dialog(context, com.gh.gamecenter.common.R.style.DialogWindowTransparent);
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_view_badge, null);
TextView titleTv = contentView.findViewById(R.id.dialog_title);
TextView contentTv = contentView.findViewById(R.id.dialog_content);
SimpleDraweeView badgeView = contentView.findViewById(R.id.dialog_badge);
ImageView badgeLightBg = contentView.findViewById(R.id.dialog_badge_light_bg);
ImageUtils.display(badgeView, badge.getMIcon());
titleTv.setText(badge.getName());
// 领取条件文本超过一行就不显示
if (badge.getActions() == null || badge.getActions().isEmpty() || badge.getActions().size() > 1) {
contentTv.setVisibility(View.INVISIBLE);
} else {
contentTv.setText(badge.getActions().get(0).getText());
contentTv.post(() -> {
if (contentTv.getLineCount() > 1) contentTv.setVisibility(View.INVISIBLE);
});
}
Animation animation = AnimationUtils.loadAnimation(context, com.gh.gamecenter.common.R.anim.anim_badge_light_bg);
badgeLightBg.startAnimation(animation);
contentView.findViewById(R.id.dialog_ok).setOnClickListener(v -> {
listener.onConfirm();
badgeLightBg.clearAnimation();
dialog.dismiss();
});
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(contentView);
dialog.show();
}
public static void showReceiveBadgeDialog(Context context, BadgeEntity badge, ConfirmListener listener) {
context = checkDialogContext(context);
final Dialog dialog = new Dialog(context, com.gh.gamecenter.common.R.style.DialogWindowTransparent);
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_receive_badge, null);
TextView titleTv = contentView.findViewById(R.id.dialog_title);
TextView contentTv = contentView.findViewById(R.id.dialog_content);
SimpleDraweeView badgeView = contentView.findViewById(R.id.dialog_badge);
ImageView badgeLightBg = contentView.findViewById(R.id.dialog_badge_light_bg);
TextView receiveTv = contentView.findViewById(R.id.dialog_ok);
ImageUtils.display(badgeView, badge.getIcon());
titleTv.setText(badge.getName());
// 领取条件文本超过一行就不显示
if (badge.getActions() == null || badge.getActions().isEmpty() || badge.getActions().size() > 1) {
contentTv.setVisibility(View.INVISIBLE);
} else {
contentTv.setText(badge.getActions().get(0).getText());
contentTv.post(() -> {
if (contentTv.getLineCount() > 1) contentTv.setVisibility(View.INVISIBLE);
});
}
if ("self".equals(badge.getReceive().getType())) {
receiveTv.setText(R.string.receive_badge);
} else if ("auto".equals(badge.getReceive().getType())) {
receiveTv.setText(R.string.view_badge);
} else {
receiveTv.setText(R.string.apply_badge);
}
Animation animation = AnimationUtils.loadAnimation(context, com.gh.gamecenter.common.R.anim.anim_badge_light_bg);
badgeLightBg.startAnimation(animation);
contentView.findViewById(R.id.dialog_ok).setOnClickListener(v -> {
listener.onConfirm();
badgeLightBg.clearAnimation();
dialog.dismiss();
});
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(contentView);
dialog.show();
}
public static void showPassRegulationDialog(Context context, String icon) {
context = checkDialogContext(context);
final Dialog dialog = new Dialog(context, com.gh.gamecenter.common.R.style.DialogWindowTransparent);
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_pass_regulation, null);
SimpleDraweeView userIcon = contentView.findViewById(R.id.dialog_icon);
ImageUtils.display(userIcon, icon);
contentView.findViewById(R.id.dialog_ok).setOnClickListener(v -> {
dialog.dismiss();
});
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(contentView);
dialog.show();
}
public static void showShortCutPermissionDialog(Context context) {
context = checkDialogContext(context);
final Dialog dialog = new Dialog(context, com.gh.gamecenter.common.R.style.DialogWindowTransparent);
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_shortcut_permission, null);
Context finalContext = context;
contentView.findViewById(R.id.dialog_positive).setOnClickListener(v -> {
dialog.dismiss();
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setData(Uri.parse("package:" + finalContext.getPackageName()));
finalContext.startActivity(intent);
});
contentView.findViewById(R.id.dialog_negative).setOnClickListener(v -> {
dialog.dismiss();
});
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(contentView);
dialog.show();
}
public static Dialog showCancelOrDeleteReservationDialog(Context context, String title, String message
, String positive, String negative, final ConfirmListener cmListener, final CancelListener clListener) {
context = checkDialogContext(context);
final Dialog dialog = new Dialog(context, com.gh.gamecenter.common.R.style.GhAlertDialog);
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_cancel_reservation, null);
TextView contentTv = contentView.findViewById(R.id.dialog_content);
TextView titleTv = contentView.findViewById(R.id.dialog_title);
TextView negativeTv = contentView.findViewById(R.id.dialog_negative);
TextView positiveTv = contentView.findViewById(R.id.dialog_positive);
contentTv.setText(message);
titleTv.setText(title);
negativeTv.setText(negative);
positiveTv.setText(positive);
negativeTv.setOnClickListener(view -> {
if (clListener != null) {
clListener.onCancel();
}
dialog.dismiss();
});
positiveTv.setOnClickListener(view -> {
if (cmListener != null) {
cmListener.onConfirm();
}
dialog.dismiss();
});
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(contentView);
dialog.show();
Window window = dialog.getWindow();
if (window != null) {
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
WindowManager.LayoutParams params = window.getAttributes();
params.width = context.getResources().getDisplayMetrics().widthPixels - DisplayUtils.dip2px(60f);
window.setAttributes(params);
}
return dialog;
}
public static void showSimulatorParseErrorDialog(Context context, String gameId, String gameName, ConfirmListener confirmListener) {
context = checkDialogContext(context);
final Dialog dialog = new Dialog(context, com.gh.gamecenter.common.R.style.GhAlertDialog);
DialogPackageParseErrorBinding binding = DialogPackageParseErrorBinding.inflate(LayoutInflater.from(context), null, false);
Context finalContext = context;
SpannableStringBuilder builder = new SpanBuilder("您也可以点击提交反馈跟我们联系").click(context, 6, 10, com.gh.gamecenter.common.R.color.text_theme, true, new Function0<Unit>() {
@Override
public Unit invoke() {
SimpleGameEntity entity = new SimpleGameEntity(gameId, gameName, "", "");
HelpAndFeedbackBridge.startSuggestionActivity(finalContext, SuggestType.GAME, "notfound", "模拟器安装包解析错误", entity);
dialog.dismiss();
return null;
}
}).build();
binding.feedbackTv.setText(builder);
binding.feedbackTv.setMovementMethod(new LinkMovementMethod());
binding.cancel.setOnClickListener(v -> {
dialog.dismiss();
});
binding.confirm.setOnClickListener(v -> {
confirmListener.onConfirm();
dialog.dismiss();
});
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(binding.getRoot());
dialog.show();
Window window = dialog.getWindow();
if (window != null) {
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
WindowManager.LayoutParams params = window.getAttributes();
params.width = context.getResources().getDisplayMetrics().widthPixels - DisplayUtils.dip2px(60f);
window.setAttributes(params);
}
}
public static void showReportReasonDialog(Context context, ArrayList<String> items, ReportReasonCallBack callBack) {
showReportReasonDialog(context, items, "", callBack);
}
@SuppressLint("SetTextI18n")
public static void showReportReasonDialog(Context context, ArrayList<String> items, String title, ReportReasonCallBack callBack) {
context = checkDialogContext(context);
final Dialog dialog = new Dialog(context, com.gh.gamecenter.common.R.style.DialogWindowTransparent);
DialogReportReasonBinding binding = DialogReportReasonBinding.inflate(LayoutInflater.from(context));
if (!title.isEmpty()) {
binding.reasonTitle.setText(title);
}
ReportReasonAdapter reportReasonAdapter = new ReportReasonAdapter(context, items, reason -> {
if (reason.equals("其他原因")) {
binding.reasonTitle.setText(R.string.report_reason_other_title);
binding.normalReasonContainer.setVisibility(View.GONE);
binding.otherReasonContainer.setVisibility(View.VISIBLE);
} else {
dialog.dismiss();
callBack.onResponse(reason, "");
}
return null;
});
binding.reasonRv.setLayoutManager(new LinearLayoutManager(context));
binding.reasonRv.addItemDecoration(new VerticalItemDecoration(context, 1F, false, com.gh.gamecenter.common.R.color.ui_background));
binding.reasonRv.setAdapter(reportReasonAdapter);
binding.negativeBtn.setOnClickListener(v -> {
binding.reasonTitle.setText(R.string.report_reason_title);
binding.normalReasonContainer.setVisibility(View.VISIBLE);
binding.otherReasonContainer.setVisibility(View.GONE);
});
binding.positiveBtn.setOnClickListener(v -> {
if (TextUtils.isEmpty(binding.otherReasonEt.getText().toString().trim())) {
ToastUtils.showToast("请填写举报原因");
} else {
dialog.dismiss();
callBack.onResponse("其他原因", binding.otherReasonEt.getText().toString());
}
});
Context finalContext = context;
ExtensionsKt.setTextChangedListener(binding.otherReasonEt, (s, start, before, count) -> {
int tvCount = s.length();
if (tvCount >= 500) {
binding.tvCount.setTextColor(ContextCompat.getColor(finalContext, com.gh.gamecenter.common.R.color.secondary_red));
}
binding.tvCount.setText(tvCount + "/500");
return null;
});
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(binding.getRoot());
dialog.show();
}
public static Dialog showBindPhoneDialog(Context context, ConfirmListener listener) {
context = checkDialogContext(context);
final Dialog dialog = new Dialog(context, com.gh.gamecenter.common.R.style.DialogWindowTransparent);
DialogBindPhoneBinding binding = DialogBindPhoneBinding.inflate(LayoutInflater.from(context));
binding.positiveTv.setOnClickListener(v -> {
dialog.dismiss();
listener.onConfirm();
});
binding.closeIv.setOnClickListener(v -> {
dialog.dismiss();
});
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(binding.getRoot());
dialog.show();
return dialog;
}
public static void showReserveOrVoteSuccess2WechatBindDialog(Context context, Boolean isReserve, ConfirmListener confirmListener, CancelListener cancelListener) {
context = checkDialogContext(context);
final Dialog dialog = new Dialog(context, com.gh.gamecenter.common.R.style.DialogWindowTransparent);
DialogWechatReserveSuccessBinding binding = DialogWechatReserveSuccessBinding.inflate(LayoutInflater.from(context));
binding.titleIv.setImageResource(isReserve ? R.drawable.bg_reserve_success : R.drawable.bg_vote_success);
binding.contentTv.setText(isReserve ? "游戏上线时,您将在消息中心收到通知。为了避免错过通知,建议您开启微信公众号提醒" : "版本上线时,您将在消息中心收到通知。为了避免错过通知,亦建议您开启微信公众号提醒");
binding.closeBtn.setOnClickListener(v -> {
cancelListener.onCancel();
dialog.dismiss();
});
binding.openBtn.setOnClickListener(v -> {
confirmListener.onConfirm();
dialog.dismiss();
});
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(binding.getRoot());
dialog.show();
Window window = dialog.getWindow();
if (window != null) {
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
WindowManager.LayoutParams params = window.getAttributes();
params.width = DisplayUtils.dip2px(300f);
window.setAttributes(params);
}
}
public static void showReserveOrVoteSuccessDialog(Context context, Boolean isReserve) {
context = checkDialogContext(context);
final Dialog dialog = new Dialog(context, com.gh.gamecenter.common.R.style.DialogWindowTransparent);
DialogAlertDefaultBinding binding = DialogAlertDefaultBinding.inflate(LayoutInflater.from(context));
binding.titleTv.setText(isReserve ? "游戏预约成功" : "版本投票成功");
binding.contentTv.setText(isReserve ? "游戏上线时,您将在消息中心和微信公众号收到通知,不会错过任何预约的游戏" : "版本上线时,您将在消息中心和微信公众号收到通知,不会错过任何投票的版本");
binding.confirmTv.setText("我知道了");
binding.centerDivider.setVisibility(View.GONE);
binding.cancelTv.setVisibility(View.GONE);
ExtensionsKt.setDrawableStart(binding.titleTv, R.drawable.ic_reserve_success, null, null);
binding.confirmTv.setOnClickListener(v -> dialog.dismiss());
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(binding.getRoot());
dialog.show();
Window window = dialog.getWindow();
if (window != null) {
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
WindowManager.LayoutParams params = window.getAttributes();
params.width = DisplayUtils.dip2px(300f);
window.setAttributes(params);
}
}
public static void showReserveReminderDialog(Context context, GameEntity gameEntity, ReserveReminderEntity reserveReminder) {
ReserveReminderContainerFragment.show(context, gameEntity, reserveReminder);
}
public static void showRelievePhoneDialog(Context context) {
context = checkDialogContext(context);
final Dialog dialog = new Dialog(context, com.gh.gamecenter.common.R.style.DialogWindowTransparent);
DialogRelievePhoneBinding binding = DialogRelievePhoneBinding.inflate(LayoutInflater.from(context));
Context finalContext = context;
binding.realNameBtn.setOnClickListener(v -> {
dialog.dismiss();
Intent intent = ShellActivity.getIntent(finalContext, ShellActivity.Type.REAL_NAME_INFO);
finalContext.startActivity(intent);
});
binding.bindPhoneBtn.setOnClickListener(v -> {
dialog.dismiss();
Intent intent = SettingBridge.INSTANCE.getBindPhoneNormalIntent(finalContext, false);
finalContext.startActivity(intent);
});
binding.cancelBtn.setOnClickListener(v -> dialog.dismiss());
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(binding.getRoot());
dialog.show();
}
/**
* @param context may be is application context
* @return activity context
*/
public static Context checkDialogContext(Context context) {
if (context == null) {
throw new NullPointerException("dialog context is null");
}
if (context instanceof Activity) {
return context;
}
// currentActivity 是否存在 isDestroyed 的情况?
return AppManager.getInstance().currentActivity();
}
public interface OptionCallback {
void onClicked(String text);
}
public interface CheckDownloadCallBack {
void onResponse(boolean isSubscribe);
}
public interface ReportReasonCallBack {
void onResponse(String reason, String desc);
}
}