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


Java RequestCreator.centerCrop方法代码示例

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


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

示例1: loadImage

import com.squareup.picasso.RequestCreator; //导入方法依赖的package包/类
/**
 * Loads an image into a target view.
 * @param context context
 * @param image image
 * @param centerCrop boolean
 * @param errorResourceId image of error
 * @param target imageView
 * @param callback callback
 */
public static void loadImage(final Context context, final String image,
                             final boolean centerCrop, final int errorResourceId,
                             final ImageView target, final Callback callback) {
    Picasso pic = Picasso.with(context);
    RequestCreator request;
    int errorRId = errorResourceId;

    if (image != null )
        request = pic.load(image).fit();
    else {
        request = pic.load(errorResourceId).fit();
        errorRId = 0;
    }

    if (centerCrop)
        request = request.centerCrop();
    if (errorRId != 0)
        request = request.error(errorResourceId);

    if (callback != null)
        request.into(target, callback);
    else
        request.into(target);
}
 
开发者ID:an-garcia,项目名称:MovieGuide,代码行数:34,代码来源:ActivityUtils.java

示例2: 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

示例3: 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

示例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: 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

示例7: loadImageWithHolder

import com.squareup.picasso.RequestCreator; //导入方法依赖的package包/类
/**
 * 加载图片
 *
 * @param url              the url of image
 * @param iv               ImageView
 * @param placeholderResID default image
 */
public void loadImageWithHolder(String url, ImageView iv, int placeholderResID, boolean isCenterCrop) {
    Picasso.with(SolidApplication.getInstance()).load(url).placeholder(placeholderResID).fit().into(iv);
    RequestCreator creator = Picasso.with(SolidApplication.getInstance()).load(url).placeholder(R.drawable.default_load_img);
    if (isCenterCrop) {
        creator.centerCrop();
    }
    creator.fit().into(iv);
}
 
开发者ID:XinRan5312,项目名称:QxChangeThemeSkin,代码行数:16,代码来源:HttpUtils.java

示例8: 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

示例9: 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

示例10: loadThumbnailForAssetWithSize

import com.squareup.picasso.RequestCreator; //导入方法依赖的package包/类
/**
 * Loads a thumbnail of an Asset to a given ImageView.
 * If explicit dimensions are specified ({@code width} and {@code height}) those will be
 * passed as URL parameters to allow server-side scaling of the image.
 */
public static void loadThumbnailForAssetWithSize(Context context, CDAAsset asset,
    ImageView imageView, @Nullable Integer width, @Nullable Integer height,
    boolean centerCropRemoteImages) {

  Integer thumbnailResId = Utils.getThumbnailResIdForAsset(asset);
  RequestCreator rc;
  Picasso picasso = Picasso.with(context);
  boolean hasExplicitDimensions = width != null && height != null;

  if (thumbnailResId == null) {
    String url = "http:" + asset.url();

    if (hasExplicitDimensions) {
      if (url.contains("?")) {
        url += "&";
      } else {
        url += "?";
      }
      url += "w=" + width + "&h=" + height;
    }

    rc = picasso.load(url);

    if (hasExplicitDimensions) {
      rc.resize(width, height);
    } else {
      rc.fit();
    }

    if (centerCropRemoteImages) {
      rc.centerCrop();
    } else {
      rc.centerInside();
    }
  } else {
    rc = picasso.load(thumbnailResId).fit().centerCrop();
  }

  rc.into(imageView);
}
 
开发者ID:contentful,项目名称:discovery-app-android,代码行数:46,代码来源:Utils.java


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