Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fallenstardust
YGOMobile
Commits
852f2fe2
Commit
852f2fe2
authored
Dec 01, 2023
by
wangfugui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复先行卡页面图片加载时缓存机制带来的图片不更新问题。
parent
5bdfc7af
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
6 deletions
+22
-6
mobile/src/main/java/cn/garymb/ygomobile/ex_card/ExCardListAdapter.java
...n/java/cn/garymb/ygomobile/ex_card/ExCardListAdapter.java
+17
-6
mobile/src/main/java/cn/garymb/ygomobile/utils/glide/GlideCompat.java
...ain/java/cn/garymb/ygomobile/utils/glide/GlideCompat.java
+5
-0
No files found.
mobile/src/main/java/cn/garymb/ygomobile/ex_card/ExCardListAdapter.java
View file @
852f2fe2
...
@@ -2,13 +2,13 @@ package cn.garymb.ygomobile.ex_card;
...
@@ -2,13 +2,13 @@ package cn.garymb.ygomobile.ex_card;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
URL_PRE_CARD
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
URL_PRE_CARD
;
import
static
cn
.
garymb
.
ygomobile
.
utils
.
StringUtils
.
mergeListDelimeter
;
import
android.graphics.drawable.Drawable
;
import
android.graphics.drawable.Drawable
;
import
android.util.Log
;
import
android.util.Log
;
import
android.widget.ImageView
;
import
android.widget.ImageView
;
import
com.bumptech.glide.RequestBuilder
;
import
com.bumptech.glide.RequestBuilder
;
import
com.bumptech.glide.signature.ObjectKey
;
import
com.chad.library.adapter.base.BaseQuickAdapter
;
import
com.chad.library.adapter.base.BaseQuickAdapter
;
import
com.chad.library.adapter.base.viewholder.BaseViewHolder
;
import
com.chad.library.adapter.base.viewholder.BaseViewHolder
;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
...
@@ -24,6 +24,7 @@ import cn.garymb.ygomobile.ui.plus.DialogPlus;
...
@@ -24,6 +24,7 @@ import cn.garymb.ygomobile.ui.plus.DialogPlus;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.utils.LogUtil
;
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.glide.GlideCompat
;
import
cn.garymb.ygomobile.utils.glide.GlideCompat
;
import
okhttp3.Response
;
import
okhttp3.Response
;
...
@@ -106,16 +107,26 @@ public class ExCardListAdapter extends BaseQuickAdapter<ExCardData, BaseViewHold
...
@@ -106,16 +107,26 @@ public class ExCardListAdapter extends BaseQuickAdapter<ExCardData, BaseViewHold
protected
void
convert
(
BaseViewHolder
helper
,
ExCardData
item
)
{
protected
void
convert
(
BaseViewHolder
helper
,
ExCardData
item
)
{
helper
.
setText
(
R
.
id
.
ex_card_name
,
item
.
getName
());
helper
.
setText
(
R
.
id
.
ex_card_name
,
item
.
getName
());
helper
.
setText
(
R
.
id
.
ex_card_description
,
item
.
getDesc
());
helper
.
setText
(
R
.
id
.
ex_card_description
,
item
.
getDesc
());
helper
.
setText
(
R
.
id
.
ex_card_overall
,
item
.
getOverallString
());
helper
.
setText
(
R
.
id
.
ex_card_overall
,
item
.
getOverallString
());
ImageView
imageview
=
helper
.
getView
(
R
.
id
.
ex_card_image
);
ImageView
imageview
=
helper
.
getView
(
R
.
id
.
ex_card_image
);
//the function cn.garymb.ygomobile.loader.ImageLoader.bindT(...)
//the function cn.garymb.ygomobile.loader.ImageLoader.bindT(...)
//cn.garymb.ygomobile.loader.ImageLoader.setDefaults(...)
//cn.garymb.ygomobile.loader.ImageLoader.setDefaults(...)
//is a private function,so I copied the content of it to here
//is a private function,so I copied the content of it to here
RequestBuilder
<
Drawable
>
resource
=
GlideCompat
.
with
(
imageview
.
getContext
()).
load
(
item
.
getPicUrl
());
/* 如果查不到版本号,则不显示图片 */
resource
.
placeholder
(
R
.
drawable
.
unknown
);
/* 如果能查到版本号,则显示图片,利用glide的signature,将版本号和url作为signature,由glide判断是否使用缓存 */
resource
.
error
(
R
.
drawable
.
unknown
);
if
(
ServerUtil
.
exCardState
==
ServerUtil
.
ExCardState
.
NEED_UPDATE
resource
.
into
(
imageview
);
||
ServerUtil
.
exCardState
==
ServerUtil
.
ExCardState
.
UPDATED
)
{
RequestBuilder
<
Drawable
>
resource
=
GlideCompat
.
with
(
imageview
.
getContext
()).
load
(
item
.
getPicUrl
())
.
signature
(
new
ObjectKey
(
ServerUtil
.
serverExCardVersion
+
item
.
getPicUrl
()));
resource
.
placeholder
(
R
.
drawable
.
unknown
);
resource
.
error
(
R
.
drawable
.
unknown
);
resource
.
into
(
imageview
);
}
else
if
(
ServerUtil
.
exCardState
==
ServerUtil
.
ExCardState
.
UNCHECKED
||
ServerUtil
.
exCardState
==
ServerUtil
.
ExCardState
.
ERROR
)
{
/* 版本号都拿不到,就不显示图片了 */
}
}
}
}
}
mobile/src/main/java/cn/garymb/ygomobile/utils/glide/GlideCompat.java
View file @
852f2fe2
...
@@ -10,6 +10,11 @@ import androidx.fragment.app.FragmentActivity;
...
@@ -10,6 +10,11 @@ import androidx.fragment.app.FragmentActivity;
import
com.bumptech.glide.Glide
;
import
com.bumptech.glide.Glide
;
import
com.bumptech.glide.RequestManager
;
import
com.bumptech.glide.RequestManager
;
/**
* Glide工具类
* 注意对缓存的处理,后端更新图片后,要有合理机制更新缓存:
* https://bumptech.github.io/glide/doc/caching.html
*/
public
class
GlideCompat
{
public
class
GlideCompat
{
public
static
RequestManager
with
(
Context
context
)
{
public
static
RequestManager
with
(
Context
context
)
{
return
Glide
.
with
(
context
);
return
Glide
.
with
(
context
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment