0
我有一個畫廊視圖,與BaseAdapter,我從互聯網下載圖像,下載圖像,並設置爲畫廊異步。大約有2000張圖片。 當我旋轉屏幕,asyntask繼續,但畫廊設置爲空,不顯示任何現在或舊圖像。畫廊在屏幕上重置旋轉
這是BaseAdapter的代碼:
private class AdaptadorImagenes extends BaseAdapter {
private Context contexto = null;
private ArrayList<Integer> datos = new ArrayList<Integer>();
public AdaptadorImagenes(Context contexto) {
this.contexto = contexto;
}
public void addItem(Integer posicion) {
datos.add(posicion);
notifyDataSetChanged();
}
@Override
public int getCount() {
return datos.size();
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imagen = new ImageView(contexto);
imagen.setImageBitmap(getBitMapRedimensionado(position));
imagen.setScaleType(ScaleType.FIT_XY);
return imagen;
}
/**
* Metodo para redimensionar un bimap
*
* @param posicion
* del bitmap en una lista que contiene los path
* @return bitmap redimensionado
*/
private Bitmap getBitMapRedimensionado(int posicion) {
File fichero = new File(pathImagenes.get(posicion));
Bitmap bmOriginal = redondeaEsquinasBitmap(Bitmap
.createScaledBitmap(
BitmapFactory.decodeFile(fichero.toString()), 210,
210, true));
return bmOriginal;
}
/**
* Metodo para redondear las esquinas de un bitmap
*
* @param bitmap
* a redondear
* @return bitmap redondeado
*/
public Bitmap redondeaEsquinasBitmap(Bitmap bitmap) {
Bitmap salida = Bitmap.createBitmap(bitmap.getWidth(),
bitmap.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(salida);
final int color = 0xff424242;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, bitmap.getWidth(),
bitmap.getHeight());
final RectF rectF = new RectF(rect);
final float roundPx = 12;
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
return salida;
}
}
在Manifiest我設置android:configChanges="keyboardHidden|orientation"
我想保存在變量多少圖像已經下載但,當旋轉屏幕設置的所有圖像,但是當超過500時,這個過程非常緩慢。
任何想法?謝謝
我不能dissmis改變方向。 我會看到你的鏈接。謝謝 – colymore
我不能使用這個..任何其他的想法? – colymore