Commit baf0cc48 authored by wangfugui's avatar wangfugui

修复先行卡页面图片加载时缓存机制存在的问题

parent 305f65ec
......@@ -166,6 +166,10 @@ public interface Constants {
String URL_YGO233_ADVANCE = "";//"https://ygo233.com/pre#pre_release_cards";//关闭233先行卡服务器,但不要删除该字段,许多未调用的遗留代码使用该contant
String URL_YGO233_DATAVER = "https://cdn02.moecube.com:444/ygopro-super-pre/data/version.txt";
String URL_PRE_CARD = "https://cdn02.moecube.com:444/ygopro-super-pre/data/test-release.json";
// String URL_YGO233_DATAVER = "http://192.168.0.103:8006/ygo/version.txt";
// String URL_PRE_CARD = "http://192.168.0.103:8006/ygo/test-release.json";
String URL_YGO233_FILE = "https://cdn02.moecube.com:444/ygopro-super-pre/archive/ygopro-super-pre.ypk";
String URL_YGO233_FILE_ALT = "https://cdn02.moecube.com:444/ygopro-super-pre/archive/ygopro-super-pre.ypk";
String URL_YGO233_BUG_REPORT = "https://ygo233.com/pre#faq";
......
......@@ -26,6 +26,7 @@ import cn.garymb.ygomobile.utils.LogUtil;
import cn.garymb.ygomobile.utils.OkhttpUtil;
import cn.garymb.ygomobile.utils.ServerUtil;
import cn.garymb.ygomobile.utils.glide.GlideCompat;
import cn.garymb.ygomobile.utils.glide.StringSignature;
import okhttp3.Response;
public class ExCardListAdapter extends BaseQuickAdapter<ExCardData, BaseViewHolder> {
......@@ -117,9 +118,12 @@ public class ExCardListAdapter extends BaseQuickAdapter<ExCardData, BaseViewHold
/* 如果能查到版本号,则显示图片,利用glide的signature,将版本号和url作为signature,由glide判断是否使用缓存 */
if (ServerUtil.exCardState == ServerUtil.ExCardState.NEED_UPDATE
|| ServerUtil.exCardState == ServerUtil.ExCardState.UPDATED) {
//ServerUtil.serverExCardVersion = "1701569942";
StringSignature signature = new StringSignature(ServerUtil.serverExCardVersion);
ObjectKey key = new ObjectKey(ServerUtil.serverExCardVersion);
RequestBuilder<Drawable> resource = GlideCompat.with(imageview.getContext()).
load(item.getPicUrl())
.signature(new ObjectKey(ServerUtil.serverExCardVersion + item.getPicUrl()));
.signature(signature);
resource.placeholder(R.drawable.unknown);
resource.error(R.drawable.unknown);
resource.into(imageview);
......
......@@ -78,7 +78,7 @@ public class ServerUtil {
String newVer = response.body().string();
/* 服务器有点怪,返回的版本号带个\n,要去掉 */
if (newVer.endsWith("\n")) {
newVer = newVer.substring(0, newVer.length() - 2);
newVer = newVer.substring(0, newVer.length() - 1);
}
serverExCardVersion = newVer;
......@@ -218,7 +218,6 @@ public class ServerUtil {
mServerInfo.setPlayerName(playerName);
boolean hasServer = false;
if (list != null) {
serverInfos.clear();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment