feat: 【光环助手V_5.11.0】国际服游戏下载弹窗优化 https://git.shanqu.cc/pm/halo/halo-app-issues/-/issues/1933

This commit is contained in:
张玉久
2022-06-30 11:06:12 +08:00
parent 3f7996f523
commit e5de70af66
2 changed files with 44 additions and 13 deletions

View File

@ -41,6 +41,7 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.ContextCompat;
@ -59,6 +60,7 @@ import com.gh.gamecenter.common.callback.CancelListener;
import com.gh.gamecenter.common.callback.ConfirmListener;
import com.gh.gamecenter.common.callback.SimpleCallback;
import com.gh.gamecenter.common.databinding.DialogAlertDefaultBinding;
import com.gh.gamecenter.common.retrofit.Response;
import com.gh.gamecenter.common.utils.ExtensionsKt;
import com.gh.gamecenter.common.utils.ImageUtils;
import com.gh.gamecenter.common.utils.NetworkUtils;
@ -94,8 +96,10 @@ import com.gh.gamecenter.entity.PrivacyPolicyEntity;
import com.gh.gamecenter.entity.SettingsEntity;
import com.gh.gamecenter.entity.SimpleGameEntity;
import com.gh.gamecenter.entity.TrackableEntity;
import com.gh.gamecenter.retrofit.RetrofitManager;
import com.gh.gamecenter.setting.GameDownloadSettingFragment;
import com.gh.gamecenter.suggest.SuggestType;
import com.google.gson.JsonObject;
import com.halo.assistant.HaloApp;
import com.lightgame.adapter.BaseRecyclerAdapter;
import com.lightgame.download.DownloadEntity;
@ -112,6 +116,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import retrofit2.HttpException;
public class DialogUtils {
@ -210,8 +215,6 @@ public class DialogUtils {
}
public static void checkDownload(Context context, String size, CheckDownloadCallBack callBack) {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance().getApplication());
if (!NetworkUtils.isNetworkConnected(context)) {
@ -412,7 +415,6 @@ public class DialogUtils {
}
public static Dialog showDialogWithHtmlContent(Context context, String title, String content
, String positive, String negative, final ConfirmListener cmListener, final CancelListener clListener) {
context = checkDialogContext(context);
@ -1310,17 +1312,41 @@ public class DialogUtils {
binding.gameIcon.displayGameIcon(gameEntity);
binding.gameNameTv.setText(context.getString(R.string.dialog_oversea_hint, gameEntity.getName()));
binding.urlTv.setText(gameEntity.getOverseasAddressDialog().getLink());
binding.closeIv.setOnClickListener(v -> dialog.dismiss());
binding.downloadBtn.setText("下载(" + gameEntity.getApk().get(0).getSize() + "");
binding.downloadBtn.setOnClickListener(v -> {
listener.onConfirm();
dialog.dismiss();
});
if ("show&download".equals(gameEntity.getOverseasAddressDialog().getStatus())) {
gameEntity.getApk().get(0).setUrl(gameEntity.getOverseasAddressDialog().getLink());
}
Context finalContext = context;
RetrofitManager.getInstance().getApi().getThirdPartyAddress(gameEntity.getId())
.compose(ExtensionsKt.observableToMain())
.subscribe(new Response<JsonObject>() {
@Override
public void onResponse(@Nullable JsonObject response) {
super.onResponse(response);
if (response == null) return;
String h5Link = response.get("h5_link").getAsString();
String downloadLink = response.get("download_link").getAsString();
String buttonText = response.get("button_text").getAsString();
binding.urlTv.setText(downloadLink);
binding.downloadBtn.setText(buttonText);
binding.downloadBtn.setOnClickListener(v -> {
DirectUtils.directToExternalBrowser(finalContext, h5Link);
dialog.dismiss();
});
}
@Override
public void onFailure(@Nullable HttpException e) {
super.onFailure(e);
if ("show&download".equals(gameEntity.getOverseasAddressDialog().getStatus())) {
gameEntity.getApk().get(0).setUrl(gameEntity.getOverseasAddressDialog().getLink());
}
binding.urlTv.setText(gameEntity.getOverseasAddressDialog().getLink());
binding.downloadBtn.setText("下载(" + gameEntity.getApk().get(0).getSize() + "");
binding.downloadBtn.setOnClickListener(v -> {
listener.onConfirm();
dialog.dismiss();
});
}
});
Window window = dialog.getWindow();
if (window != null) {