Java Code Examples for com.squareup.picasso.RequestCreator#resize()

The following examples show how to use com.squareup.picasso.RequestCreator#resize() . 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: PicassoLoaderProcessor.java    From ImageLoaderProcessor with Apache License 2.0 6 votes vote down vote up
private RequestCreator loadOptions(RequestCreator requestCreator) {
    if (options == null) {
        return requestCreator;
    }
    if (options.targetHeight > 0 && options.targetWidth > 0) {
        requestCreator.resize(options.targetWidth, options.targetHeight);
    }
    if (options.isCenterInside) {
        requestCreator.centerInside();
    } else if (options.isCenterCrop) {
        requestCreator.centerCrop();
    }
    if (options.config != null) {
        requestCreator.config(options.config);
    }
    if (options.errorResId != 0) {
        requestCreator.error(options.errorResId);
    }
    if (options.placeholderResId != 0) {
        requestCreator.placeholder(options.placeholderResId);
    }
    if (options.bitmapAngle != 0) {
        requestCreator.transform(new PicassoTransformation(options.bitmapAngle));
    }
    return requestCreator;
}
 
Example 2
Source File: VirtualViewRenderService.java    From Tangram-Android with MIT License 5 votes vote down vote up
@Override
public void bindImage(String uri, final ImageBase imageBase, int reqWidth, int reqHeight) {
    RequestCreator requestCreator = Picasso.with(tangramEngine.getContext()).load(uri);
    Log.d("TangramActivity", "bindImage request width height " + reqHeight + " " + reqWidth);
    if (reqHeight > 0 || reqWidth > 0) {
        requestCreator.resize(reqWidth, reqHeight);
    }
    ImageTarget imageTarget = new ImageTarget(imageBase);
    cache.add(imageTarget);
    requestCreator.into(imageTarget);
}
 
Example 3
Source File: VirtualViewRenderService.java    From Tangram-Android with MIT License 5 votes vote down vote up
@Override
public void getBitmap(String uri, int reqWidth, int reqHeight, final ImageLoader.Listener lis) {
    RequestCreator requestCreator = Picasso.with(tangramEngine.getContext()).load(uri);
    Log.d("TangramActivity", "getBitmap request width height " + reqHeight + " " + reqWidth);
    if (reqHeight > 0 || reqWidth > 0) {
        requestCreator.resize(reqWidth, reqHeight);
    }
    ImageTarget imageTarget = new ImageTarget(lis);
    cache.add(imageTarget);
    requestCreator.into(imageTarget);
}
 
Example 4
Source File: PicassoImageLoader.java    From Game-of-Thrones with Apache License 2.0 5 votes vote down vote up
@Override
public void show() {
  RequestCreator creator = Picasso.with(imageView != null ? imageView.getContext() : context)
      .load(url);

  if (transformation != null) {
    creator.transform(transformation);
  }

  if (placeholder != null) {
    creator.placeholder(placeholder);
  }

  if (with > 0 && height > 0) {
    creator.resize(with, height);
  }

  if (centerCrop) {
    creator.centerCrop();
  }

  if (fit) {
    creator.fit();
  }

  if (target != null) {
    creator.into(target);
  } else {
    creator.into(imageView);
  }
}
 
Example 5
Source File: ImageHelper.java    From AndroidPicker with MIT License 5 votes vote down vote up
@Override
public void display(String urlOrPath, ImageView view, int width, int height) {
    LogUtils.verbose("Image>>>" + urlOrPath);
    if (null == context) {
        context = view.getContext();
    }
    RequestCreator creator = Picasso.with(context).load(urlOrPath);
    creator.placeholder(PLACEHOLDER_LOADING);
    creator.error(PLACEHOLDER_FAILURE);
    creator.config(urlOrPath.endsWith(".png") ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
    if (width > 0 && height > 0) {
        creator.resize(width, height);
    }
    creator.into(view);
}
 
Example 6
Source File: ImageLoader.java    From Contacts with MIT License 5 votes vote down vote up
public static void display(ImageView imageView, Uri uri, boolean fadeIn, int stubImage, ImageLoaderListener listener)
{
	/*if (uri == null || uri.length() == 0)
		uri = FAKE_URI;
	
	//uri = Uri.encode(uri, ALLOWED_URI_CHARS);*/

	Picasso picasso = Picasso.with(imageView.getContext());
	RequestCreator requestCreator = picasso.load(uri);

	if (stubImage != 0)
	{
		requestCreator.placeholder(stubImage);
		requestCreator.error(stubImage);
	}

	if (!(fadeIn && FADE_ENABLED))
		requestCreator.noFade();

	LayoutParams params = imageView.getLayoutParams();

	if (params.width > 0 && params.height > 0)
	{
		requestCreator.resize(params.width, params.height, true);
	}

	requestCreator.inSampleSize(true);
	requestCreator.into(imageView, listener);
}
 
Example 7
Source File: ImageLoader.java    From Contacts with MIT License 5 votes vote down vote up
public static void display(ImageView imageView, String uri, boolean fadeIn, int stubImage, ImageLoaderListener listener)
{
	if (uri == null || uri.length() == 0)
		uri = FAKE_URI;
	
	uri = Uri.encode(uri, ALLOWED_URI_CHARS);

	Picasso picasso = Picasso.with(imageView.getContext());
	RequestCreator requestCreator = picasso.load(uri);

	if (stubImage != 0)
	{
		requestCreator.placeholder(stubImage);
		requestCreator.error(stubImage);
	}

	if (!(fadeIn && FADE_ENABLED))
		requestCreator.noFade();

	LayoutParams params = imageView.getLayoutParams();

	if (params.width > 0 && params.height > 0)
	{
		requestCreator.resize(params.width, params.height, true);
	}

	requestCreator.inSampleSize(true);
	requestCreator.into(imageView, listener);
}
 
Example 8
Source File: ImageLoader.java    From Klyph with MIT License 5 votes vote down vote up
public static void display(ImageView imageView, String uri, boolean fadeIn, int stubImage, ImageLoaderListener listener)
{
	if (uri == null || uri.length() == 0)
		uri = FAKE_URI;
	
	/*uri = uri.replace("�", URLEncoder.encode("�"));
	uri = uri.replace("�", URLEncoder.encode("�"));
	uri = uri.replace("'", URLEncoder.encode("'"));
	uri = uri.replace("�", URLEncoder.encode("�"));*/
	
	uri = Uri.encode(uri, ALLOWED_URI_CHARS);

	Picasso picasso = Picasso.with(imageView.getContext());
	RequestCreator requestCreator = picasso.load(uri);

	if (stubImage != 0)
	{
		requestCreator.placeholder(stubImage);
		requestCreator.error(stubImage);
	}

	if (!(fadeIn && FADE_ENABLED))
		requestCreator.noFade();

	LayoutParams params = imageView.getLayoutParams();

	if (params.width > 0 && params.height > 0)
	{
		requestCreator.resize(params.width, params.height, true);
	}

	requestCreator.inSampleSize(true);
	requestCreator.into(imageView, listener);
}
 
Example 9
Source File: ImageLoader.java    From KlyphMessenger with MIT License 5 votes vote down vote up
public static void display(ImageView imageView, String uri, boolean fadeIn, int stubImage, ImageLoaderListener listener)
{
	if (uri == null || uri.length() == 0)
		uri = FAKE_URI;
	
	/*uri = uri.replace("�", URLEncoder.encode("�"));
	uri = uri.replace("�", URLEncoder.encode("�"));
	uri = uri.replace("'", URLEncoder.encode("'"));
	uri = uri.replace("�", URLEncoder.encode("�"));*/
	
	uri = Uri.encode(uri, ALLOWED_URI_CHARS);

	Picasso picasso = Picasso.with(imageView.getContext());
	RequestCreator requestCreator = picasso.load(uri);

	if (stubImage != 0)
	{
		requestCreator.placeholder(stubImage);
		requestCreator.error(stubImage);
	}

	if (!(fadeIn && FADE_ENABLED))
		requestCreator.noFade();

	LayoutParams params = imageView.getLayoutParams();

	if (params.width > 0 && params.height > 0)
	{
		requestCreator.resize(params.width, params.height, true);
	}

	requestCreator.inSampleSize(true);
	requestCreator.into(imageView, listener);
}
 
Example 10
Source File: UserActivity.java    From intra42 with Apache License 2.0 4 votes vote down vote up
private void addShortCut() {
    if (user == null)
        return;

    final Intent addIntent = new Intent();
    final RequestCreator p = UserImage.getPicassoCorned(UserActivity.this, user);
    if (p == null)
        return;
    p.resize(200, 240);

    new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                Bitmap bitmap = p.get();
                addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON, bitmap);
            } catch (final IOException e) {
                e.printStackTrace();

                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(UserActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
                    }
                });

            }

            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    //Adding shortcut for LaunchActivity
                    //on Home screen
                    Intent shortcutIntent = new Intent(getApplicationContext(), UserActivity.class);

                    shortcutIntent.setAction(Intent.ACTION_MAIN);
                    shortcutIntent.putExtra(INTENT_LOGIN, user.login);


                    addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
                    addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, user.login);

                    addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
                    addIntent.putExtra("duplicate", false);  //may it's already there so don't duplicate
                    getApplicationContext().sendBroadcast(addIntent);
                }
            });
        }
    }).start();
}