Android Open Source - android-utils Network Image View






From Project

Back to project page android-utils.

License

The source code is released under:

Apache License

If you think the Android project android-utils listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.omegar.android.utils.components;
/*from   www .j  a  v a  2  s  .  c o  m*/
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;

import android.content.Context;
import android.graphics.Bitmap;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.FailReason;
import com.nostra13.universalimageloader.core.assist.SimpleImageLoadingListener;
import com.omegar.android.utils.R;

@EViewGroup(R.layout.component_network_image_view)
public class NetworkImageView extends LinearLayout {
  @ViewById(R.id.image)
  ImageView mImage;

  @ViewById(R.id.spinner)
  ProgressBar mSpinner;

  public NetworkImageView(Context context) {
    super(context);
  }
  
  public NetworkImageView(Context context, AttributeSet attrs) {
    super(context, attrs);
  }
  
  @AfterViews
  protected void init() {
    mImage.setVisibility(View.GONE);
    mSpinner.setVisibility(View.VISIBLE);
  }
  
  public void displayImage(String imageUrl, ImageLoader imageLoader) {
    init();
    
    imageLoader.displayImage(imageUrl, mImage, new SimpleImageLoadingListener() {
      @Override
      public void onLoadingFailed(String arg0, View arg1, FailReason arg2) {
        onImageLoadEnded();
      }
      
      @Override
      public void onLoadingComplete(String arg0, View arg1, Bitmap arg2) {
        onImageLoadEnded();
      }
      
      @Override
      public void onLoadingCancelled(String arg0, View arg1) {
        onImageLoadEnded();
      }
      
      private void onImageLoadEnded() {
        mImage.setVisibility(View.VISIBLE);
        mSpinner.setVisibility(View.GONE);
      }
    });
  }
}




Java Source Code List

com.omegar.android.utils.BaseDialog.java
com.omegar.android.utils.Logger.java
com.omegar.android.utils.PhotoHelper.java
com.omegar.android.utils.components.DividedLinearLayout.java
com.omegar.android.utils.components.NetworkImageView.java
com.omegar.android.utils.components.NonScrollableGridView.java
com.omegar.android.utils.components.NonScrollableListView.java
com.omegar.android.utils.components.ProportionalLinearLayout.java
com.omegar.android.utils.components.UnderlineTextView.java