
20/06/13, 17:29:42
|
|
Miembro del foro
|
|
Fecha de registro: jun 2013
Localización: en la barcelona media
Mensajes: 224
Modelo de smartphone: LG-E610
Tu operador: Orange
|
|
Bueno al final he pasado todos los valores por un hashmap y no soluciona el problema de memoria al redibujar , ahora estoy con pasar el hash de la imagen por un softreference , pero no e funciona.. de la manera que lo hago no carga la imagen los demas valores del hash sin problemas , algo no he entendido bien todavia de este tema ;(
Codigo de carga:
Código:
ArrayList<HashMap<String,Object>> arr = db.GetAllRecipes();
lt=(ListView)findViewById(R.id.listRecetas);
String[] from={"NAME","TAG","DATE","IMG"};
int[] to={R.id.textView1,R.id.textView2,R.id.time, R.id.imgEdit};
adp = new SimpleAdapter(context, arr, R.layout.item_list, from, to);
lt.setAdapter(adp);
y asi monto los hashmap mas el softreference:
Código:
public ArrayList<HashMap<String,Object>> GetAllRecipes(){
ArrayList<HashMap<String,Object>> arr = new ArrayList<HashMap<String,Object>>();
arr.clear();
Cursor cur = this.getReadableDatabase().query(TABLE_NAME, new String[]{KEY_ID,KEY_NAME,KEY_TAG,KEY_DATE,KEY_INGREDIENTES,KEY_COMO,KEY_RUTAIMG}, null, null, null, null, null);
cur.moveToFirst();
while(!cur.isAfterLast()){
try{
HashMap<String,Object> re = CursorToHashMap(cur);
arr.add(re);
cur.moveToNext();
}catch(Exception e){
e.printStackTrace();}
}
cur.close();
return arr;
}
public HashMap<String,Object> CursorToHashMap(Cursor cur) {
HashMap<String,Object> re = new HashMap<String,Object>();
re.put("ID",String.valueOf(cur.getInt(cur.getColumnIndex(RecetasSQLiteHelper.KEY_ID))));
re.put("NAME",cur.getString(cur.getColumnIndex(RecetasSQLiteHelper.KEY_NAME)));
re.put("TAG",cur.getString(cur.getColumnIndex(RecetasSQLiteHelper.KEY_TAG)));
re.put("DATE",cur.getString(cur.getColumnIndex(RecetasSQLiteHelper.KEY_DATE)));
re.put("IGREDIENTES",cur.getString(cur.getColumnIndex(RecetasSQLiteHelper.KEY_INGREDIENTES)));
re.put("COMO",cur.getString(cur.getColumnIndex(RecetasSQLiteHelper.KEY_COMO)));
//-9Uri uri = Uri.parse(cur.getString(cur.getColumnIndex(RecetasSQLiteHelper.KEY_RUTAIMG)));
try{
//ContentResolver cr = con.getContentResolver();
//InputStream in = cr.openInputStream(uri);
//Bitmap bm = BitmapFactory.decodeFile(uri.getPath());
re.put("IMG",new SoftReference<Uri>(Uri.parse(cur.getString(cur.getColumnIndex(RecetasSQLiteHelper.KEY_RUTAIMG)))));
}catch(Exception e)
{
Log.e("error","no rula",e);
}
ret
|