Commit 924228be authored by fallenstardust's avatar fallenstardust Committed by GitHub

Merge pull request #132 from zhuhongbozhuhongbo/master

修复先行卡页面图片加载时缓存机制存在的问题
parents 07817c16 8589eb75
...@@ -166,6 +166,10 @@ public interface Constants { ...@@ -166,6 +166,10 @@ public interface Constants {
String URL_YGO233_ADVANCE = "";//"https://ygo233.com/pre#pre_release_cards";//关闭233先行卡服务器,但不要删除该字段,许多未调用的遗留代码使用该contant 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_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_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 = "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_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"; String URL_YGO233_BUG_REPORT = "https://ygo233.com/pre#faq";
......
...@@ -26,6 +26,7 @@ import cn.garymb.ygomobile.utils.LogUtil; ...@@ -26,6 +26,7 @@ import cn.garymb.ygomobile.utils.LogUtil;
import cn.garymb.ygomobile.utils.OkhttpUtil; import cn.garymb.ygomobile.utils.OkhttpUtil;
import cn.garymb.ygomobile.utils.ServerUtil; import cn.garymb.ygomobile.utils.ServerUtil;
import cn.garymb.ygomobile.utils.glide.GlideCompat; import cn.garymb.ygomobile.utils.glide.GlideCompat;
import cn.garymb.ygomobile.utils.glide.StringSignature;
import okhttp3.Response; import okhttp3.Response;
public class ExCardListAdapter extends BaseQuickAdapter<ExCardData, BaseViewHolder> { public class ExCardListAdapter extends BaseQuickAdapter<ExCardData, BaseViewHolder> {
...@@ -117,9 +118,12 @@ public class ExCardListAdapter extends BaseQuickAdapter<ExCardData, BaseViewHold ...@@ -117,9 +118,12 @@ public class ExCardListAdapter extends BaseQuickAdapter<ExCardData, BaseViewHold
/* 如果能查到版本号,则显示图片,利用glide的signature,将版本号和url作为signature,由glide判断是否使用缓存 */ /* 如果能查到版本号,则显示图片,利用glide的signature,将版本号和url作为signature,由glide判断是否使用缓存 */
if (ServerUtil.exCardState == ServerUtil.ExCardState.NEED_UPDATE if (ServerUtil.exCardState == ServerUtil.ExCardState.NEED_UPDATE
|| ServerUtil.exCardState == ServerUtil.ExCardState.UPDATED) { || 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()). RequestBuilder<Drawable> resource = GlideCompat.with(imageview.getContext()).
load(item.getPicUrl()) load(item.getPicUrl())
.signature(new ObjectKey(ServerUtil.serverExCardVersion + item.getPicUrl())); .signature(signature);
resource.placeholder(R.drawable.unknown); resource.placeholder(R.drawable.unknown);
resource.error(R.drawable.unknown); resource.error(R.drawable.unknown);
resource.into(imageview); resource.into(imageview);
......
...@@ -12,7 +12,6 @@ import cn.garymb.ygomobile.AppsSettings; ...@@ -12,7 +12,6 @@ import cn.garymb.ygomobile.AppsSettings;
import cn.garymb.ygomobile.YGOStarter; import cn.garymb.ygomobile.YGOStarter;
import cn.garymb.ygomobile.lite.R; import cn.garymb.ygomobile.lite.R;
import cn.garymb.ygomobile.ui.home.MainActivity; import cn.garymb.ygomobile.ui.home.MainActivity;
import cn.garymb.ygomobile.utils.ServerUtil;
public class LogoActivity extends Activity { public class LogoActivity extends Activity {
Handler handler; Handler handler;
...@@ -42,7 +41,6 @@ public class LogoActivity extends Activity { ...@@ -42,7 +41,6 @@ public class LogoActivity extends Activity {
handler.postDelayed(runnable, 1000); handler.postDelayed(runnable, 1000);
Toast.makeText(LogoActivity.this, R.string.logo_text, Toast.LENGTH_SHORT).show(); Toast.makeText(LogoActivity.this, R.string.logo_text, Toast.LENGTH_SHORT).show();
} }
ServerUtil.initExCardState();//检查扩展卡版本
if (!isTaskRoot()) { if (!isTaskRoot()) {
finish(); finish();
} }
......
...@@ -105,7 +105,7 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat ...@@ -105,7 +105,7 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
//showNewbieGuide("homePage"); //showNewbieGuide("homePage");
initBottomNavigationBar(); initBottomNavigationBar();
onNewIntent(getIntent()); onNewIntent(getIntent());
ServerUtil.initExCardState();//检查扩展卡版本
} }
@Override @Override
......
...@@ -78,7 +78,7 @@ public class ServerUtil { ...@@ -78,7 +78,7 @@ public class ServerUtil {
String newVer = response.body().string(); String newVer = response.body().string();
/* 服务器有点怪,返回的版本号带个\n,要去掉 */ /* 服务器有点怪,返回的版本号带个\n,要去掉 */
if (newVer.endsWith("\n")) { if (newVer.endsWith("\n")) {
newVer = newVer.substring(0, newVer.length() - 2); newVer = newVer.substring(0, newVer.length() - 1);
} }
serverExCardVersion = newVer; serverExCardVersion = newVer;
...@@ -218,7 +218,6 @@ public class ServerUtil { ...@@ -218,7 +218,6 @@ public class ServerUtil {
mServerInfo.setPlayerName(playerName); mServerInfo.setPlayerName(playerName);
boolean hasServer = false; boolean hasServer = false;
if (list != null) { if (list != null) {
serverInfos.clear(); 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