| | |
| | | package cn.flightfeather.thirdapp.adapter; |
| | | |
| | | import android.content.Context; |
| | | import android.graphics.Bitmap; |
| | | import android.graphics.drawable.BitmapDrawable; |
| | | import android.support.v4.view.PagerAdapter; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | |
| | | import com.bm.library.PhotoView; |
| | | import com.bumptech.glide.Glide; |
| | | |
| | | import java.io.File; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import cn.flightfeather.thirdapp.util.ScreenUtils; |
| | | import cn.flightfeather.thirdapp.util.photo.PhotoUtil; |
| | | |
| | | /** |
| | | * Created by hyhb01 on 2018/3/26. |
| | |
| | | @Override |
| | | public Object instantiateItem(ViewGroup container, int position) { |
| | | |
| | | Bitmap bm = PhotoUtil.decodeSampledBitmapFromResource(fileList.get(position).getAbsolutePath(), ScreenUtils.getScreenWidth(context), ScreenUtils.getScreenHeight(context)); |
| | | viewList.get(position).setImageBitmap(bm); |
| | | // Bitmap bm = PhotoUtil.decodeSampledBitmapFromResource(fileList.get(position).getAbsolutePath(), ScreenUtils.getScreenWidth(context), ScreenUtils.getScreenHeight(context)); |
| | | // viewList.get(position).setImageBitmap(bm); |
| | | |
| | | Glide.with(container) |
| | | .load(fileList.get(position)) |
| | | .into(viewList.get(position)); |
| | | container.addView(viewList.get(position)); |
| | | |
| | | return viewList.get(position); |
| | |
| | | |
| | | @Override |
| | | public void destroyItem(ViewGroup container, int position, Object object) { |
| | | BitmapDrawable bitmapDrawable = (BitmapDrawable) viewList.get(position).getDrawable(); |
| | | viewList.get(position).setImageDrawable(null); |
| | | if (bitmapDrawable != null) { |
| | | Bitmap bitmap = bitmapDrawable.getBitmap(); |
| | | if (bitmap != null) { |
| | | bitmap.recycle(); |
| | | System.gc(); |
| | | } |
| | | } |
| | | // BitmapDrawable bitmapDrawable = (BitmapDrawable) viewList.get(position).getDrawable(); |
| | | // viewList.get(position).setImageDrawable(null); |
| | | // if (bitmapDrawable != null) { |
| | | // Bitmap bitmap = bitmapDrawable.getBitmap(); |
| | | // if (bitmap != null) { |
| | | // bitmap.recycle(); |
| | | // System.gc(); |
| | | // } |
| | | // } |
| | | |
| | | container.removeView(viewList.get(position)); |
| | | } |