Java Code Examples for com.nostra13.universalimageloader.core.ImageLoader#displayImage()

The following examples show how to use com.nostra13.universalimageloader.core.ImageLoader#displayImage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FragmentSlidingMenu.java    From BigApp_WordPress_Android with Apache License 2.0 6 votes vote down vote up
private void freshLoginStatus(String userName) {
    ImageLoader mImageLoader = ImageLoader.getInstance();
    DisplayImageOptions options = ImageLoaderOptions.getOptionsCachedDisk(true);
    if (userName == null) {
        userName = new SpTool(getActivity(), SpTool.SP_USER).getString("userName", null);
    }
    if (userName == null) {
        v_line_bottom.setVisibility(View.GONE);
        tv_logout.setVisibility(View.GONE);
        mTv_username.setText(getString(R.string.v_left_menu_login));
        return;
    }
    mImageLoader.displayImage(new SpTool(getActivity(), SpTool.SP_USER).getString("avatar", null), mIv_user, options);
    v_line_bottom.setVisibility(View.VISIBLE);
    tv_logout.setVisibility(View.VISIBLE);
    mTv_username.setText(userName);
}
 
Example 2
Source File: ChatMsgAdapter.java    From LoveTalkClient with Apache License 2.0 5 votes vote down vote up
public static void displayImageByUri(ImageView imageView,
									 String localPath, String url) {
	File file = new File(localPath);
	ImageLoader imageLoader = UserService.imageLoader;
	if (file.exists()) {
		imageLoader.displayImage("file://" + localPath, imageView, PhotoUtil.normalImageOptions);
	} else {
		imageLoader.displayImage(url, imageView, PhotoUtil.normalImageOptions);
	}
}
 
Example 3
Source File: ThumbViewActivity.java    From PinchImageView with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_thumb_view);

    final DisplayImageOptions thumbOptions = new DisplayImageOptions.Builder().cacheInMemory(true).build();
    final ImageLoader imageLoader = Global.getImageLoader(getApplicationContext());

    final ViewGroup root = (ViewGroup) findViewById(R.id.root);
    int l = root.getChildCount();
    for (int i = 0; i < l; i++) {
        final int fi = i;
        final ImageView thumb = (ImageView) ((ViewGroup) root.getChildAt(i)).getChildAt(0);
        final ImageViewAware thumbAware = new ImageViewAware(thumb);
        final String url = Global.getTestImage(i).getThumb(100, 100).url;
        imageLoader.displayImage(url, thumbAware, thumbOptions);
        thumb.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(ThumbViewActivity.this, PicViewActivity.class);
                intent.putExtra("image", Global.getTestImage(fi));
                ImageSize targetSize = new ImageSize(thumbAware.getWidth(), thumbAware.getHeight());
                String memoryCacheKey = MemoryCacheUtils.generateKey(url, targetSize);
                intent.putExtra("cache_key", memoryCacheKey);
                Rect rect = new Rect();
                thumb.getGlobalVisibleRect(rect);
                intent.putExtra("rect", rect);
                intent.putExtra("scaleType", thumb.getScaleType());
                startActivity(intent);
            }
        });
    }
}
 
Example 4
Source File: PicViewActivity.java    From PinchImageView with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //获取参数
    ImageSource image = (ImageSource) getIntent().getSerializableExtra("image");
    String memoryCacheKey =  getIntent().getStringExtra("cache_key");
    final Rect rect = getIntent().getParcelableExtra("rect");
    final ImageView.ScaleType scaleType = (ImageView.ScaleType) getIntent().getSerializableExtra("scaleType");

    final ImageObject thumb = image.getThumb(100, 100);

    ImageLoader imageLoader = Global.getImageLoader(getApplicationContext());
    DisplayImageOptions originOptions = new DisplayImageOptions.Builder().build();

    //view初始化
    setContentView(R.layout.activity_pic_view);
    mImageView = (PinchImageView) findViewById(R.id.pic);
    mBackground = findViewById(R.id.background);
    Bitmap bitmap = imageLoader.getMemoryCache().get(memoryCacheKey);
    if (bitmap != null && !bitmap.isRecycled()) {
        mImageView.setImageBitmap(bitmap);
    }
    imageLoader.displayImage(image.getThumb(1000, 1000).url, mImageView, originOptions);

    mImageView.post(new Runnable() {
        @Override
        public void run() {
            mImageView.setAlpha(1f);

            //背景动画
            mBackgroundAnimator = ObjectAnimator.ofFloat(mBackground, "alpha", 0f, 1f);
            mBackgroundAnimator.setDuration(ANIM_TIME);
            mBackgroundAnimator.start();

            //status bar高度修正
            Rect tempRect = new Rect();
            mImageView.getGlobalVisibleRect(tempRect);
            rect.top = rect.top - tempRect.top;
            rect.bottom = rect.bottom - tempRect.top;

            //mask动画
            mThumbMaskRect = new RectF(rect);
            RectF bigMaskRect = new RectF(0, 0, mImageView.getWidth(), mImageView.getHeight());
            mImageView.zoomMaskTo(mThumbMaskRect, 0);
            mImageView.zoomMaskTo(bigMaskRect, ANIM_TIME);


            //图片放大动画
            RectF thumbImageMatrixRect = new RectF();
            PinchImageView.MathUtils.calculateScaledRectInContainer(new RectF(rect), thumb.width, thumb.height, scaleType, thumbImageMatrixRect);
            RectF bigImageMatrixRect = new RectF();
            PinchImageView.MathUtils.calculateScaledRectInContainer(new RectF(0, 0, mImageView.getWidth(), mImageView.getHeight()), thumb.width, thumb.height, ImageView.ScaleType.FIT_CENTER, bigImageMatrixRect);
            mThumbImageMatrix = new Matrix();
            PinchImageView.MathUtils.calculateRectTranslateMatrix(bigImageMatrixRect, thumbImageMatrixRect, mThumbImageMatrix);
            mImageView.outerMatrixTo(mThumbImageMatrix, 0);
            mImageView.outerMatrixTo(new Matrix(), ANIM_TIME);
        }
    });
    mImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mImageView.playSoundEffect(SoundEffectConstants.CLICK);
            finish();
        }
    });
}
 
Example 5
Source File: BaseAdapterHelper.java    From BigApp_WordPress_Android with Apache License 2.0 3 votes vote down vote up
/**
     * Will download an image from a URL and put it in an ImageView.<br/>
     * It uses Square's Picasso library to download the image asynchronously and
     * put the result into the ImageView.<br/>
     * Picasso manages recycling of views in a ListView.<br/>
     * If you need more control over the Picasso settings, use
     * {BaseAdapterHelper#setImageBuilder}.
     *
     * @param viewId   The view id.
     * @param imageUrl The image URL.
     * @return The BaseAdapterHelper for chaining.
     */
    public BaseAdapterHelper setImageUrl(int viewId, String imageUrl, ImageLoader imageLoader, DisplayImageOptions options) {
        // TODO
        ImageView view = retrieveView(viewId);
        imageLoader.displayImage(imageUrl, view, options);
//		ViewerImageLoader.getInstance().displayImageAndCachedMemory(imageUrl,
//				view);
        return this;
    }