1

How can I trigger spinner.setVisibility(View.GONE); after SmartImageView is loaded?

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity);
    mUrl = getIntent().getStringExtra(URL);
    Image = (SmartImageView) findViewById(R.id.ivP);
    final ProgressBar spinner = (ProgressBar) findViewById(R.id.loading);
    spinner.setVisibility(View.VISIBLE);
    Image.setImageUrl(mUrl);
    spinner.setVisibility(View.GONE);
}
Dan
  • 3,246
  • 1
  • 32
  • 52
user3245604
  • 79
  • 1
  • 6

2 Answers2

1

You can have OnCompleteListener() on smartImageView

So use it like this.

// start the progress dialog

    smartImageView.setImageUrl("Your image url", new OnCompleteListener() {

                @Override
                public void onComplete() {
                    // TODO Auto-generated method stub

                    // end the progress dialog

                }
            });
NullPointerException
  • 3,978
  • 4
  • 34
  • 52
  • 1
    hi, think you , i try it before , but I could not do it. can you please write all code ? ^_^ – user3245604 Jan 28 '14 at 22:35
  • Has anyone found out how to do this yet? There doesn't seem to be a handler. Doesn't seem to have the option at add this in the parameters. – Garbit Mar 09 '15 at 22:22
0

I'm not familiar with SmartImageView, but what you probably want is to set a place holder image into the SmartImageView and then replace it after the image is done downloading. alternately you want to display a loading view over the imageView while you download the image, and get a listener that will let you know when it's done downloading.

Take a look at the Picasso library as it does exactly that and it is extremely easy to use (1 line) and lets you define a placeholder image, error image, fade animation, and listener to have custom actions based on download result.

Or Bar
  • 1,566
  • 11
  • 12