当前位置: 首页>>代码示例>>Java>>正文


Java RequestCreator.resize方法代码示例

本文整理汇总了Java中com.squareup.picasso.RequestCreator.resize方法的典型用法代码示例。如果您正苦于以下问题:Java RequestCreator.resize方法的具体用法?Java RequestCreator.resize怎么用?Java RequestCreator.resize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.squareup.picasso.RequestCreator的用法示例。


在下文中一共展示了RequestCreator.resize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadOptions

import com.squareup.picasso.RequestCreator; //导入方法依赖的package包/类
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;
}
 
开发者ID:AweiLoveAndroid,项目名称:ImageLoaderProcessor,代码行数:27,代码来源:PicassoLoaderProcessor.java

示例2: getDrawable

import com.squareup.picasso.RequestCreator; //导入方法依赖的package包/类
@Override
public Drawable getDrawable(String source) {
    RichTextView.URLDrawable urlDrawable = new RichTextView.URLDrawable();
    RichTextView.ImageTarget target = new RichTextView.ImageTarget(urlDrawable);
    RichTextView.this.addTarget(target);
    RichTextView.ImageHolder holder = mImages.get(source);
    RequestCreator load = Picasso.with(getContext()).load(source);
    if ((onImageFixListener != null) && (holder != null)) {
        onImageFixListener.onFix(holder);
        if ((holder.width != -1) && (holder != null))
            load.resize(holder.width, holder.height);
        if (holder.scaleType == 1) load.centerCrop();
        else load.centerInside();
    }
    load.placeholder(placeImage).error(errorImage).into(target);
    return urlDrawable;
}
 
开发者ID:shenhuanet,项目名称:OpenEyesReading-android,代码行数:18,代码来源:RichTextView.java

示例3: display

import com.squareup.picasso.RequestCreator; //导入方法依赖的package包/类
@Override
    public void display(Context context, String path, ImageView imageView, Drawable defaultDrawable,
                        Bitmap.Config config, boolean resize, int width, int height) {
        RequestCreator creator = Picasso.with(context)
                .load(new File(path))
                .placeholder(defaultDrawable)
                .error(defaultDrawable)
//                .rotate(rotate)
                .networkPolicy(NetworkPolicy.NO_STORE)
                .config(config)
                .tag(context);
        if (resize) {
            creator = creator.resize(width, height);
        }
        creator.into(imageView);
    }
 
开发者ID:loshine,项目名称:GalleryPicker,代码行数:17,代码来源:PicassoImageLoader.java

示例4: displayCenterCrop

import com.squareup.picasso.RequestCreator; //导入方法依赖的package包/类
@Override
    public void displayCenterCrop(Context context, String path, ImageView imageView, Drawable defaultDrawable,
                                  Bitmap.Config config, boolean resize, int width, int height) {
        RequestCreator creator = Picasso.with(context)
                .load(new File(path))
                .placeholder(defaultDrawable)
                .error(defaultDrawable)
//                .rotate(rotate)
                .networkPolicy(NetworkPolicy.NO_STORE)
                .config(config)
                .tag(context);
        if (resize) {
            creator = creator.resize(width, height);
        }
        creator.centerCrop();
        creator.into(imageView);
    }
 
开发者ID:loshine,项目名称:GalleryPicker,代码行数:18,代码来源:PicassoImageLoader.java

示例5: getDrawable

import com.squareup.picasso.RequestCreator; //导入方法依赖的package包/类
@Override
public Drawable getDrawable(String source) {
  final URLDrawable urlDrawable = new URLDrawable();
  ImageTarget target = new ImageTarget(urlDrawable);
  addTarget(target);
  ImageHolder holder = mImages.get(source);
  RequestCreator load = Picasso.with(getContext())
      .load(source);
  if (mImageFixListener != null && holder != null) {
    mImageFixListener.onFix(holder);
    if (holder.width != -1 && holder.height != -1) {
      load.resize(holder.width, holder.height);
    }

    if (holder.scaleType == ImageHolder.CENTER_CROP) {
      load.centerCrop();
    } else if (holder.scaleType == ImageHolder.CENTER_INSIDE) {
      load.centerInside();
    }
  }
  load.placeholder(placeHolder)
      .error(errorImage).into(target);
  return urlDrawable;
}
 
开发者ID:fancysherry,项目名称:shr,代码行数:25,代码来源:RichText.java

示例6: loadSimpleView

import com.squareup.picasso.RequestCreator; //导入方法依赖的package包/类
private void loadSimpleView() {
	RequestCreator requestCreator = Picasso.with(getActivity()).load(mImageEntry.getSrc());

	switch (mImageScale) {
		case DOUBLE:
			Display display = getActivity().getWindowManager().getDefaultDisplay();
			Point size = new Point();
			display.getSize(size);
			int width = size.x * 2;
			int height = size.y * 2;
			requestCreator.resize(width, height);
			break;
		case FIT_TO_SCREEN:
			requestCreator.fit().centerInside();
			break;
	}

	requestCreator.into(mImageView, this);
}
 
开发者ID:Ecchilon,项目名称:SadPanda,代码行数:20,代码来源:ScreenSlidePageFragment.java

示例7: show

import com.squareup.picasso.RequestCreator; //导入方法依赖的package包/类
@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);
  }
}
 
开发者ID:tonilopezmr,项目名称:Game-of-Thrones,代码行数:32,代码来源:PicassoImageLoader.java

示例8: into

import com.squareup.picasso.RequestCreator; //导入方法依赖的package包/类
@Override
public void into(@NonNull ImageView imageView) {
    RequestCreator requestCreator = Picasso.with(imageView.getContext())
            .load(mResource)
            .centerInside();

    if (mWidth != 0 && mHeight != 0) {
        requestCreator = requestCreator.resize(mWidth, mHeight);
    }

    requestCreator
            .into(imageView, new com.squareup.picasso.Callback() {
                @Override
                public void onSuccess() {
                    if (mCallback != null) {
                        mCallback.onSuccess();
                    }
                }

                @Override
                public void onError() {
                    if (mCallback != null) {
                        mCallback.onError();
                    }
                }
            });
}
 
开发者ID:francescocervone,项目名称:OpenRatingView,代码行数:28,代码来源:PicassoRequestBuilder.java

示例9: bindCellHolder

import com.squareup.picasso.RequestCreator; //导入方法依赖的package包/类
@Override
public void bindCellHolder(final CellHolder cellHolder, PartId index, Message message, CellHolderSpecs specs) {
    cellHolder.mImageView.setTag(index);
    cellHolder.mImageView.setOnClickListener(this);
    cellHolder.mProgressBar.show();
    RequestCreator requestCreator = mPicasso.load(index.mId).tag(PICASSO_TAG).placeholder(PLACEHOLDER)
            .centerInside();
    if (specs.maxWidth > 0 && specs.maxHeight > 0) {
        requestCreator.resize(specs.maxWidth, specs.maxHeight);
    } else if (Log.isLoggable(Log.ERROR)) {
        Log.e("Width or Height of image passed into SinglePartImageCellFactory.bindCellHolder should be > 0");
    }
    requestCreator.onlyScaleDown()
            .transform(getTransform(cellHolder.mImageView.getContext()));

    requestCreator.into(cellHolder.mImageView, new Callback() {
        @Override
        public void onSuccess() {
            cellHolder.mProgressBar.hide();
        }

        @Override
        public void onError() {
            cellHolder.mProgressBar.hide();
        }
    });
}
 
开发者ID:layerhq,项目名称:Atlas-Android,代码行数:28,代码来源:SinglePartImageCellFactory.java

示例10: bindCellHolder

import com.squareup.picasso.RequestCreator; //导入方法依赖的package包/类
@Override
public void bindCellHolder(final CellHolder cellHolder, final Location location, Message message, CellHolderSpecs specs) {
    cellHolder.mImageView.setTag(location);
    cellHolder.mImageView.setOnClickListener(this);

    // Google Static Map API has max dimension 640
    int mapWidth = Math.min(640, specs.maxWidth);
    int mapHeight = (int) Math.round((double) mapWidth / GOLDEN_RATIO);
    int[] cellDims = Util.scaleDownInside(specs.maxWidth, (int) Math.round((double) specs.maxWidth / GOLDEN_RATIO), specs.maxWidth, specs.maxHeight);
    ViewGroup.LayoutParams params = cellHolder.mImageView.getLayoutParams();
    params.width = cellDims[0];
    params.height = cellDims[1];
    cellHolder.mProgressBar.show();
    RequestCreator requestCreator = mPicasso.load("https://maps.googleapis.com/maps/api/staticmap?zoom=16&maptype=roadmap&scale=2&center=" + location.mLatitude + "," + location.mLongitude + "&markers=color:red%7C" + location.mLatitude + "," + location.mLongitude + "&size=" + mapWidth + "x" + mapHeight)
            .tag(PICASSO_TAG).placeholder(PLACEHOLDER);
    if (cellDims[0] > 0 && cellDims[1] > 0) {
        requestCreator.resize(cellDims[0], cellDims[1]);
    } else if (Log.isLoggable(Log.ERROR)) {
        Log.e("Width or Height of image passed into LocationCellFactory is invalid");
    }

    requestCreator.transform(getTransform(cellHolder.mImageView.getContext())).into(cellHolder.mImageView, new Callback() {
        @Override
        public void onSuccess() {
            cellHolder.mProgressBar.hide();
        }

        @Override
        public void onError() {
            cellHolder.mProgressBar.hide();
        }
    });
}
 
开发者ID:layerhq,项目名称:Atlas-Android,代码行数:34,代码来源:LocationCellFactory.java

示例11: display

import com.squareup.picasso.RequestCreator; //导入方法依赖的package包/类
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);
}
 
开发者ID:jonathangerbaud,项目名称:Klyph,代码行数:35,代码来源:ImageLoader.java

示例12: build

import com.squareup.picasso.RequestCreator; //导入方法依赖的package包/类
private RequestCreator build() {
  RequestCreator requestCreator;

  if (!TextUtils.isEmpty(url)) {
    requestCreator = picasso.load(url);
  } else if (resourceId != 0) {
    requestCreator = picasso.load(resourceId);
  } else {
    return null;
  }

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

  if (error != null) {
    requestCreator = requestCreator.error(error);
  }

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

  if (bitmapTransformation != null) {
    for (int i = 0; i < bitmapTransformation.size(); i++) {
      requestCreator = requestCreator.transform(bitmapTransformation.get(i));
    }
  }

  if (centerCrop) {
    requestCreator = requestCreator.centerCrop();
  }

  if (fitCenter) {
    requestCreator = requestCreator.centerInside();
  }
  if (degrees > 0) {
    requestCreator = requestCreator.rotate(degrees);
  }

  return requestCreator;
}
 
开发者ID:Gigigo-Android-Devs,项目名称:gigigo-imageLoader-library-android,代码行数:43,代码来源:ImageLoaderBuilderImp.java

示例13: addShortCut

import com.squareup.picasso.RequestCreator; //导入方法依赖的package包/类
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 MainActivity
                    //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();
}
 
开发者ID:pvarry,项目名称:intra42,代码行数:51,代码来源:UserActivity.java

示例14: render

import com.squareup.picasso.RequestCreator; //导入方法依赖的package包/类
public void render(Context c, Canvas canvas, int width, int height, String typeface, int fg, int bg, boolean blocking) {
    TextPaint textPaint = new TextPaint();
    canvas.drawColor(bg);
    textPaint.setColor(fg);
    textPaint.setAntiAlias(true);
    textPaint.setTypeface(Typeface.create(typeface, 0));

    for (Background img: backgrounds) {
        if (img.url != null) {
            Bitmap b = null;
            CacheTarget cacheTarget = new CacheTarget();
            bitmaps.put(img.url, cacheTarget);
            RequestCreator request = Picasso.with(c)
                    .load(img.url);
            if (img.scale > 0) {
                request = request.resize((int) (width * img.scale), (int) (height * img.scale));
            } else {
                request = request.resize(width, height);
            }
            request = request.centerInside();
            if (blocking) {
                try {
                    b = request.get();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            } else {
                request.into(cacheTarget);
                b = cacheTarget.getCacheBitmap();
            }
            if (b != null) {
                Rect r = new Rect();
                Gravity.apply(img.gravity, b.getWidth(), b.getHeight(),
                        new Rect(0, 0, width, height), r);
                canvas.drawBitmap(b, r.left, r.top, textPaint);
            }
        }
    }

    float margin = 0.1f;

    int w = (int) (width * (1 - margin * 2));
    int h = (int) (height * (1 - margin * 2));


    for (int textSize = height; textSize > 1 ; textSize--) {
        textPaint.setTextSize(textSize);
        if (StaticLayout.getDesiredWidth(text, textPaint) <= w) {
            StaticLayout layout = new StaticLayout(text, textPaint, w, Layout.Alignment.ALIGN_NORMAL, 1, 0, false);
            if (layout.getHeight() >= h) {
                continue;
            }
            int l = 0;
            for (int i = 0; i < layout.getLineCount(); i++) {
                int m = (int) (width - layout.getLineWidth(i))/2;
                if (i == 0 || m < l) {
                    l = m;
                }
            }
            canvas.translate(l, (height - layout.getHeight())/2);

            textPaint.setColor(bg);
            textPaint.setStyle(Paint.Style.STROKE);
            textPaint.setStrokeWidth(8);
            layout = new StaticLayout(text, textPaint, w, Layout.Alignment.ALIGN_NORMAL, 1, 0, false);
            layout.draw(canvas);
            textPaint.setColor(fg);
            textPaint.setStyle(Paint.Style.FILL);
            textPaint.setStrokeWidth(0);
            layout = new StaticLayout(text, textPaint, w, Layout.Alignment.ALIGN_NORMAL, 1, 0, false);
            layout.draw(canvas);
            return;
        }
    }
}
 
开发者ID:trikita,项目名称:slide,代码行数:76,代码来源:Slide.java

示例15: onSetUpdateScale

import com.squareup.picasso.RequestCreator; //导入方法依赖的package包/类
@UiThread
protected void onSetUpdateScale(@NonNull final RequestCreator update, @NonNull final Dimension size) {
    // TODO: add some android integration tests for this behavior

    // is the view layout set to wrap content? if so we should just resize and not crop the image
    final ViewGroup.LayoutParams lp = mView.getLayoutParams();
    if (lp.width == WRAP_CONTENT || lp.height == WRAP_CONTENT) {
        if (lp.width == WRAP_CONTENT && lp.height == WRAP_CONTENT) {
            // Don't resize, let the view determine the size from the original image
        } else if (lp.width == WRAP_CONTENT && size.height > 0) {
            update.resize(0, size.height).onlyScaleDown();
        } else if (lp.height == WRAP_CONTENT && size.width > 0) {
            update.resize(size.width, 0).onlyScaleDown();
        }
        return;
    }

    // if we are planning on cropping the image when displaying it, lets crop it in Picasso first
    switch (mView.getScaleType()) {
        case CENTER_CROP:
            // centerCrop crops the image to the exact size specified by resize. So, if a dimension is 0 we
            // can't crop the image anyways.
            if (size.width > 0 && size.height > 0) {
                update.resize(size.width, size.height);
                update.onlyScaleDown();
                update.centerCrop();
            }
            break;
        case CENTER_INSIDE:
        case FIT_CENTER:
        case FIT_START:
        case FIT_END:
            update.resize(size.width, size.height);
            update.onlyScaleDown();
            update.centerInside();
            break;
        default:
            update.transform(new ScaleTransformation(size.width, size.height));
            break;
    }
}
 
开发者ID:CruGlobal,项目名称:android-gto-support,代码行数:42,代码来源:PicassoImageView.java


注:本文中的com.squareup.picasso.RequestCreator.resize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。