Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Callback for finished load image? #29

Open
VAdaihiep opened this issue Dec 21, 2012 · 1 comment
Open

[Question] Callback for finished load image? #29

VAdaihiep opened this issue Dec 21, 2012 · 1 comment

Comments

@VAdaihiep
Copy link

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?

@jovisayhehe
Copy link

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;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants