Closed anjiao closed 6 years ago
when my gallary has lots of gif , in gridview it is flash like bellow picture ,two pictures flash,if I scroll ,other pictures alse flash
` private class MyPhotoAdapter extends BaseAdapter {
private Map<String, PhotoInfo> mSelectList; private List<PhotoInfo> photoList; private int mScreenWidth; private GalleryConfig mGalleryConfig; private int mRowWidth; public MyPhotoAdapter(Activity activity, List<PhotoInfo> list, Map<String, PhotoInfo> selectList, int screenWidth, GalleryConfig galleryConfig) { this.mSelectList = selectList; this.photoList = list; this.mScreenWidth = screenWidth; this.mGalleryConfig = galleryConfig; this.mRowWidth = mScreenWidth / 3; } @Override public int getCount() { return photoList.size(); } @Override public Object getItem(int position) { return photoList.get(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { Holder holder = null; if (convertView == null) { holder = new Holder(); convertView = LayoutInflater.from(PhotoSelectActivity.this).inflate(R.layout.row_photo_item, parent, false); holder.iv_photo_item = (ImageView) convertView.findViewById(R.id.iv_photo_item); holder.iv_photo_item_select_bg = (ImageView) convertView.findViewById(R.id.iv_photo_item_select_bg); convertView.setTag(holder); } else { holder = (Holder) convertView.getTag(); } setHeight(convertView); PhotoInfo photoInfo = photoList.get(position); String path = ""; if (photoInfo != null) { path = photoInfo.getPhotoPath(); } mGalleryConfig.getImageLoader().displayImage(mActivity, path, holder.iv_photo_item, mRowWidth, mRowWidth); if (mSelectList.get(photoInfo.getPhotoPath()) != null) { holder.iv_photo_item_select_bg.setVisibility(View.VISIBLE); } else { holder.iv_photo_item_select_bg.setVisibility(View.GONE); } return convertView; } private void setHeight(final View convertView) { int height = mScreenWidth / 3 - 8; convertView.setLayoutParams(new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, height)); } public final class Holder { ImageView iv_photo_item; ImageView iv_photo_item_select_bg; } }`
`public class GlideImageLoader implements cn.finalteam.galleryfinal.ImageLoader {
@Override public void displayImage(Activity activity, String path, ImageView imageView, int width, int height) { if (path.endsWith(".gif")) { imageView.setScaleType(ImageView.ScaleType.FIT_XY); Glide.with(activity) .load("file://" + path) .asGif() .placeholder(R.drawable.default_image) .error(R.drawable.default_image) .dontAnimate() .diskCacheStrategy(DiskCacheStrategy.NONE) .skipMemoryCache(true) .into(imageView); } else { imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); Glide.with(activity) .load("file://" + path) .dontAnimate() .placeholder(R.drawable.default_image) .error(R.drawable.default_image) .diskCacheStrategy(DiskCacheStrategy.NONE) .skipMemoryCache(true) .into(imageView); } } @Override public void clearMemoryCache() { }
}`
This issue has been automatically marked as stale because it has not had activity in the last seven days. It will be closed if no further activity occurs within the next seven days. Thank you for your contributions.
when my gallary has lots of gif , in gridview it is flash like bellow picture ,two pictures flash,if I scroll ,other pictures alse flash
` private class MyPhotoAdapter extends BaseAdapter {
`public class GlideImageLoader implements cn.finalteam.galleryfinal.ImageLoader {
}`