Skip to content

Commit 3f47be7

Browse files
committed
修正查看大图
1 parent f14d3e6 commit 3f47be7

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

diycode-app/src/main/java/com/gcssloop/diycode/activity/ImageActivity.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,13 @@
3434
import com.gcssloop.diycode.R;
3535
import com.gcssloop.diycode.base.app.BaseImageActivity;
3636
import com.gcssloop.diycode.base.app.ViewHolder;
37+
import com.gcssloop.diycode.base.webview.DiskImageCache;
3738
import com.gcssloop.diycode_sdk.log.Logger;
3839

3940
public class ImageActivity extends BaseImageActivity {
4041

42+
DiskImageCache mCache;
43+
4144
@Override
4245
protected int getLayoutId() {
4346
return R.layout.activity_image;
@@ -52,6 +55,7 @@ protected int getLayoutId() {
5255
@Override
5356
protected void initViews(ViewHolder holder, View root) {
5457
setTitle("查看图片");
58+
mCache = new DiskImageCache(this);
5559
if (mCurrentMode == MODE_ERROR) {
5660
//TODO 显示错误视图
5761
return;
@@ -78,7 +82,13 @@ public boolean isViewFromObject(View view, Object object) {
7882
public Object instantiateItem(ViewGroup container, int position) {
7983
PhotoView photoView = (PhotoView) inflater.inflate(R.layout.item_image, container, false);
8084
photoView.enable();
81-
Glide.with(ImageActivity.this).load(images.get(position)).into(photoView);
85+
String url = images.get(position);
86+
if (mCache.hasCache(url)){
87+
String file = mCache.getDiskPath(url);
88+
Glide.with(ImageActivity.this).load(file).into(photoView);
89+
} else {
90+
Glide.with(ImageActivity.this).load(images.get(position)).into(photoView);
91+
}
8292
container.addView(photoView);
8393
Logger.e("添加Item");
8494
return photoView;

diycode-app/src/main/res/layout/item_image.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222

2323
<com.bm.library.PhotoView
2424
xmlns:android="http://schemas.android.com/apk/res/android"
25+
xmlns:tools="http://schemas.android.com/tools"
2526
android:id="@+id/photo_view"
2627
android:layout_width="match_parent"
2728
android:layout_height="match_parent"
2829
android:scaleType="fitCenter"
29-
android:src="@mipmap/ic_launcher"/>
30+
tools:src="@mipmap/ic_launcher"/>

0 commit comments

Comments
 (0)