I am working with Bitmap in android.
In AsyncTask's doInBackgroud method I did the following code
protected Bitmap[] doInBackground(Object... params) {
hMap = new ConcurrentHashMap<String, ArrayList<AssetBean>>();
hMap = (ConcurrentHashMap<String, ArrayList<AssetBean>>) params[0];
myKeyList = (CopyOnWriteArrayList<String>) params[1];
if (Constants.DEBUG)
Log.i("MyKeylist", myKeyList.toString()+"myKeyList size :"+myKeyList.size());
myBitmap = new Bitmap[myKeyList.size()];
for (int i = 0; i < myKeyList.size(); i++) {
String name = myKeyList.get(i);
ArrayList<AssetBean> ab = hMap.get(name);
AssetBean b = ab.get(0);
File f = b.getThumbPath();
Bitmap bitmap;
if (null != f) {
bitmap = BitmapFactory.decodeFile(f.getAbsolutePath());
if (bitmap != null)
myBitmap[i] = bitmap;
else
myBitmap[i] = BitmapFactory.decodeResource(
mContext.getResources(),
R.drawable.brokenicon_new);
}
}
return myBitmap;
}
from the above code the
myBitmap = new Bitmap[myKeyList.size()];
myBitmap assigned null and myKeyList.size() is not zero.
How can I resolve this? Is I anything missed?