Skip to content

Commit

Permalink
图片加载失败提示
Browse files Browse the repository at this point in the history
  • Loading branch information
albert-lii committed Sep 27, 2017
1 parent 33d2339 commit 88ecf9f
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestBuilder;
Expand All @@ -32,6 +33,7 @@
import com.liyi.viewer.data.ViewData;

import java.util.ArrayList;
import java.util.LinkedList;

import uk.co.senab.photoview.PhotoView;
import uk.co.senab.photoview.PhotoViewAttacher;
Expand All @@ -53,6 +55,7 @@ public class ImagePreviewActivity extends Activity implements IImagePreview {
private int mIndexPos;
// Determine if the first picture you need to display is loaded
private boolean isBeginLoaded;
private LinkedList<String> mLoadFailArray;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
Expand Down Expand Up @@ -93,6 +96,9 @@ public void onViewTap(View view, float x, float y) {
}
});
tv_index.setText((position + 1) + "/" + mImageList.size());
if (mLoadFailArray.contains(position + "")) {
Toast.makeText(ImagePreviewActivity.this, "图片加载失败", Toast.LENGTH_SHORT).show();
}
}

@Override
Expand All @@ -116,10 +122,9 @@ public void handleIntent(Intent intent) {
mCurViewData = mViewDataList.get(mBeginIndex);
isBeginLoaded = false;

if (mPhotoViewList == null) {
mPhotoViewList = new ArrayList<PhotoView>();
}
mPhotoViewList.clear();
mLoadFailArray = new LinkedList<String>();
mPhotoViewList = new ArrayList<PhotoView>();

for (int i = 0; i < mImageList.size(); i++) {
final PhotoView photoView = new PhotoView(this);
loadImage(i, mImageList.get(i), photoView, false);
Expand Down Expand Up @@ -334,7 +339,7 @@ public void onLoadFailed(@Nullable Drawable errorDrawable) {
isBeginLoaded = true;
}
}
// Toast.makeText(ImagePreviewActivity.this, "图片加载失败", Toast.LENGTH_SHORT).show();
mLoadFailArray.add(index + "");
}

@Override
Expand All @@ -352,6 +357,9 @@ public void onResourceReady(Bitmap resource, @Nullable Transition transition) {
isBeginLoaded = true;
}
}
if (mLoadFailArray.contains(index + "")) {
mLoadFailArray.remove(index + "");
}
}
});
}
Expand Down

0 comments on commit 88ecf9f

Please sign in to comment.