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


Java Request类代码示例

本文整理汇总了Java中com.squareup.picasso.Request的典型用法代码示例。如果您正苦于以下问题:Java Request类的具体用法?Java Request怎么用?Java Request使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: load

import com.squareup.picasso.Request; //导入依赖的package包/类
@Override
public Result load(Request request, int networkPolicy) throws IOException {
    JcifsFileEditor editor = new JcifsFileEditor(request.uri);

    InputStream inputStream = null;
    try {
        inputStream = editor.getInputStream();
    } catch (IOException e) {
        Log.e(TAG, "Failed to get the input stream for "+request.uri, e);
        return null;
    }

    Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
    inputStream.close();
    if (bitmap==null) {
        return null;
    }
    else {
        return new Result(bitmap, Picasso.LoadedFrom.NETWORK);
    }
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:22,代码来源:SmbRequestHandler.java

示例2: calculateInSampleSize

import com.squareup.picasso.Request; //导入依赖的package包/类
/**
 * Copy/Paste of com.squareup.picasso.RequestHandler.calculateInSampleSize()...
 */
static void calculateInSampleSize(int reqWidth, int reqHeight, int width, int height,
                                  BitmapFactory.Options options, Request request) {
    int sampleSize = 1;
    if (height > reqHeight || width > reqWidth) {
        final int heightRatio;
        final int widthRatio;
        if (reqHeight == 0) {
            sampleSize = (int) Math.floor((float) width / (float) reqWidth);
        } else if (reqWidth == 0) {
            sampleSize = (int) Math.floor((float) height / (float) reqHeight);
        } else {
            heightRatio = (int) Math.floor((float) height / (float) reqHeight);
            widthRatio = (int) Math.floor((float) width / (float) reqWidth);
            sampleSize = request.centerInside
                    ? Math.max(heightRatio, widthRatio)
                    : Math.min(heightRatio, widthRatio);
        }
    }
    options.inSampleSize = sampleSize;
    options.inJustDecodeBounds = false;
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:25,代码来源:ThumbnailRequestHandler.java

示例3: load

import com.squareup.picasso.Request; //导入依赖的package包/类
@Override
public Result load(Request request, int networkPolicy) throws IOException {

    String cardId = request.uri.getHost();
    Picasso.LoadedFrom loadedFrom = Picasso.LoadedFrom.DISK;

    InputStream inputStream = ArcaneTrackerApplication.getContext().getAssets().open("bars/" + cardId + ".webp");
    if (inputStream == null) {
        throw  new IOException();
    }

    Bitmap b = BitmapFactory.decodeStream(inputStream);
    inputStream.close();

    return new Result(b, loadedFrom);
}
 
开发者ID:HearthSim,项目名称:arcane_tracker,代码行数:17,代码来源:PicassoBarRequestHandler.java

示例4: load

import com.squareup.picasso.Request; //导入依赖的package包/类
@Override
public Result load(Request request, int networkPolicy) throws IOException {
    // do whatever is necessary here to load the image
    // important: you can only return a Result object
    // the constructor takes either a Bitmap or InputStream object, nothing else!

    // get the key for the requested image
    // if the schema is "eatfoody://cupcake", it'd return "cupcake"
    String imageKey = request.uri.getHost();

    Bitmap bitmap;
    if (imageKey.contentEquals("cupcake")) {
        bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.cupcake);
    }
    else if (imageKey.contentEquals("full_cake")) {
        bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.full_cake);
    }
    else {
        // fallback image
        bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
    }

    // return the result with the bitmap and the source info
    return new Result(bitmap, Picasso.LoadedFrom.DISK);
}
 
开发者ID:fs-opensource,项目名称:android-tutorials-picasso,代码行数:26,代码来源:UsageExamplePicassoBuilderRequestHandler.java

示例5: transformRequest

import com.squareup.picasso.Request; //导入依赖的package包/类
@Override public Request transformRequest(Request request) {
  if (request.resourceId != 0) {
    return request; // Don't transform resource requests.
  }
  Uri uri = request.uri;
  String scheme = uri.getScheme();
  if (!"https".equals(scheme) && !"http".equals(scheme)) {
    return request; // Thumbor only supports remote images.
  }
  if (!request.hasSize()) {
    return request; // Thumbor only works with resizing images.
  }

  // Start building a new request for us to mutate.
  Request.Builder newRequest = request.buildUpon();

  // Create the url builder to use.
  ThumborUrlBuilder urlBuilder = thumbor.buildImage(uri.toString());

  // Resize the image to the target size.
  urlBuilder.resize(request.targetWidth, request.targetHeight);
  newRequest.clearResize();

  // If the center inside flag is set, perform that with Thumbor as well.
  if (request.centerInside) {
    urlBuilder.fitIn();
    newRequest.clearCenterInside();
  }

  // If the Android version is modern enough use WebP for downloading.
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
    urlBuilder.filter(format(ImageFormat.WEBP));
  }

  // Update the request with the completed Thumbor URL.
  newRequest.setUri(Uri.parse(urlBuilder.toUrl()));

  return newRequest.build();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:40,代码来源:PollexorRequestTransformer.java

示例6: simpleResize

import com.squareup.picasso.Request; //导入依赖的package包/类
@Test public void simpleResize() {
  Request input = new Request.Builder(IMAGE_URI).resize(50, 50).build();
  Request output = transformer.transformRequest(input);
  assertThat(output).isNotSameAs(input);
  assertThat(output.hasSize()).isFalse();

  String expected = Thumbor.create(HOST).buildImage(IMAGE).resize(50, 50).toUrl();
  assertThat(output.uri.toString()).isEqualTo(expected);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:PollexorRequestTransformerTest.java

示例7: simpleResizeOnJbMr2UsesWebP

import com.squareup.picasso.Request; //导入依赖的package包/类
@Config(sdk = 18)
@Test public void simpleResizeOnJbMr2UsesWebP() {
  Request input = new Request.Builder(IMAGE_URI).resize(50, 50).build();
  Request output = transformer.transformRequest(input);
  assertThat(output).isNotSameAs(input);
  assertThat(output.hasSize()).isFalse();

  String expected = Thumbor.create(HOST)
      .buildImage(IMAGE)
      .resize(50, 50)
      .filter(format(ImageFormat.WEBP))
      .toUrl();
  assertThat(output.uri.toString()).isEqualTo(expected);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:PollexorRequestTransformerTest.java

示例8: simpleResizeWithCenterCrop

import com.squareup.picasso.Request; //导入依赖的package包/类
@Test public void simpleResizeWithCenterCrop() {
  Request input = new Request.Builder(IMAGE_URI).resize(50, 50).centerCrop().build();
  Request output = transformer.transformRequest(input);
  assertThat(output).isNotSameAs(input);
  assertThat(output.hasSize()).isFalse();
  assertThat(output.centerCrop).isFalse();

  String expected = Thumbor.create(HOST).buildImage(IMAGE).resize(50, 50).toUrl();
  assertThat(output.uri.toString()).isEqualTo(expected);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:PollexorRequestTransformerTest.java

示例9: simpleResizeWithCenterInside

import com.squareup.picasso.Request; //导入依赖的package包/类
@Test public void simpleResizeWithCenterInside() {
  Request input = new Request.Builder(IMAGE_URI).resize(50, 50).centerInside().build();
  Request output = transformer.transformRequest(input);
  assertThat(output).isNotSameAs(input);
  assertThat(output.hasSize()).isFalse();
  assertThat(output.centerInside).isFalse();

  String expected = Thumbor.create(HOST).buildImage(IMAGE).resize(50, 50).fitIn().toUrl();
  assertThat(output.uri.toString()).isEqualTo(expected);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:PollexorRequestTransformerTest.java

示例10: simpleResizeWithEncryption

import com.squareup.picasso.Request; //导入依赖的package包/类
@Test public void simpleResizeWithEncryption() {
  Request input = new Request.Builder(IMAGE_URI).resize(50, 50).build();
  Request output = secureTransformer.transformRequest(input);
  assertThat(output).isNotSameAs(input);
  assertThat(output.hasSize()).isFalse();

  String expected = Thumbor.create(HOST, KEY).buildImage(IMAGE).resize(50, 50).toUrl();
  assertThat(output.uri.toString()).isEqualTo(expected);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:PollexorRequestTransformerTest.java

示例11: simpleResizeWithCenterInsideAndEncryption

import com.squareup.picasso.Request; //导入依赖的package包/类
@Test public void simpleResizeWithCenterInsideAndEncryption() {
  Request input = new Request.Builder(IMAGE_URI).resize(50, 50).centerInside().build();
  Request output = secureTransformer.transformRequest(input);
  assertThat(output).isNotSameAs(input);
  assertThat(output.hasSize()).isFalse();
  assertThat(output.centerInside).isFalse();

  String expected = Thumbor.create(HOST, KEY).buildImage(IMAGE).resize(50, 50).fitIn().toUrl();
  assertThat(output.uri.toString()).isEqualTo(expected);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:PollexorRequestTransformerTest.java

示例12: load

import com.squareup.picasso.Request; //导入依赖的package包/类
@Override
public RequestHandler.Result load(Request data, int arg1) throws IOException {
    long imageId = Long.parseLong(data.uri.getLastPathSegment());

    Bitmap bm = Stores.getInstance()
            .localPhotos()
            .getImageThumbnail(imageId);

    return new RequestHandler.Result(bm, Picasso.LoadedFrom.DISK);
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:11,代码来源:LocalPhotoRequestHandler.java

示例13: load

import com.squareup.picasso.Request; //导入依赖的package包/类
@Override
public Result load(Request request, int networkPolicy) throws IOException {
    final long videoId = Long.parseLong(request.uri.getHost());
    if (videoId<0) {
        return null;
    }
    Bitmap thumbnail = VideoStore.Video.Thumbnails.getThumbnail(mContext.getContentResolver(), videoId, VideoStore.Video.Thumbnails.MINI_KIND, null, !"1".equals(request.uri.getQueryParameter("nothumbcreation")));
    if (thumbnail==null) {
        return null;
    }
    return new RequestHandler.Result(thumbnail, Picasso.LoadedFrom.DISK);
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:13,代码来源:ThumbnailRequestHandler.java

示例14: decodeResource

import com.squareup.picasso.Request; //导入依赖的package包/类
private static Bitmap decodeResource(Resources resources, int id, Request data) {
    final BitmapFactory.Options options = createBitmapOptions(data);
    if (requiresInSampleSize(options)) {
        BitmapFactory.decodeResource(resources, id, options);
        calculateInSampleSize(data.targetWidth, data.targetHeight, options, data);
    }
    return BitmapFactory.decodeResource(resources, id, options);
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:9,代码来源:ThumbnailRequestHandler.java

示例15: createBitmapOptions

import com.squareup.picasso.Request; //导入依赖的package包/类
/**
 * Copy/Paste of com.squareup.picasso.RequestHandler.createBitmapOptions()...
 */
static BitmapFactory.Options createBitmapOptions(Request data) {
    final boolean justBounds = data.hasSize();
    final boolean hasConfig = data.config != null;
    BitmapFactory.Options options = null;
    if (justBounds || hasConfig) {
        options = new BitmapFactory.Options();
        options.inJustDecodeBounds = justBounds;
        if (hasConfig) {
            options.inPreferredConfig = data.config;
        }
    }
    return options;
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:17,代码来源:ThumbnailRequestHandler.java


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