Open VAdaihiep opened 11 years ago
public class ImageLoader{
//xxx
ImgLoadListener loadListener;
//xxx
//Used to display bitmap in the UI thread
class BitmapDisplayer implements Runnable
{
//xxx
if(bitmap!=null){
loadListener.onFinished();
photoToLoad.imageView.setImageBitmap(bitmap);
}
//xxx
}
public void setImgLoadListenerListener(ImgLoadListener load){
this.loadListener = load;
}
public interface ImgLoadListener {
public void onFinished() ;
}
}
//LazyAdapter.java
public View getView(int position, View convertView, ViewGroup parent) {
View vi=convertView;
if(convertView==null)
vi = inflater.inflate(R.layout.item, null);
TextView text=(TextView)vi.findViewById(R.id.text);;
ImageView image=(ImageView)vi.findViewById(R.id.image);
text.setText("item "+position);
imageLoader.DisplayImage(data[position], image);
imageLoader.setImgLoadListenerListener(new ImgLoadListener() {
@Override
public void onFinished() {
// TODO Auto-generated method stub
Toast.makeText(activity, "finsh", Toast.LENGTH_SHORT).show();
}
});
return vi;
}
Hi Fedor, Thank for your project, it's simple but awesome. I have small question that: How can I show a Toast or do somethings else when finished load image from internet or cache?