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


Java RequestCreator类代码示例

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


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

示例1: displayRaw

import com.squareup.picasso.RequestCreator; //导入依赖的package包/类
@Override
public void displayRaw(@NonNull ImageView img, @NonNull String absPath, int width, int height, final IBoxingCallback callback) {
    String path = "file://" + absPath;
    RequestCreator creator = Picasso.with(img.getContext())
            .load(path);
    if (width > 0 && height > 0) {
        creator.transform(new BitmapTransform(width, height));
    }
    creator.into(img, new Callback() {
        @Override
        public void onSuccess() {
            if (callback != null) {
                callback.onSuccess();
            }
        }

        @Override
        public void onError() {
            if (callback != null) {
                callback.onFail(null);
            }
        }
    });
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:BoxingPicassoLoader.java

示例2: displayAvatar

import com.squareup.picasso.RequestCreator; //导入依赖的package包/类
public static void displayAvatar(@NonNull ImageView dest, Transformation transformation, String url, String tag, @DrawableRes int ifEmpty) {
    Picasso picasso = PicassoInstance.with();

    RequestCreator requestCreator;

    if (nonEmpty(url)) {
        requestCreator = picasso.load(url);
    } else {
        requestCreator = picasso.load(ifEmpty);
    }

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

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

    requestCreator.into(dest);
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:22,代码来源:ViewUtils.java

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

示例4: getView

import com.squareup.picasso.RequestCreator; //导入依赖的package包/类
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View entry = convertView != null ? convertView : inflater.inflate(R.layout.flair_entry, parent, false);

    String id = ids[position];

    ((TextView) entry.findViewById(R.id.flairText)).setText(id);

    ImageView imageView = (ImageView) entry.findViewById(R.id.flair);

    Picasso.with(context).cancelRequest(imageView);
    RequestCreator request = flairStylesheet.loadFlairById(id, context);
    if(request != null) request.into(imageView);

    imageView.getLayoutParams().width = (int) (flairStylesheet.prevDimension.width * context.getResources().getDisplayMetrics().density);
    imageView.getLayoutParams().height = (int) (flairStylesheet.prevDimension.height * context.getResources().getDisplayMetrics().density);

    return entry;
}
 
开发者ID:derek1906,项目名称:FlairTest,代码行数:22,代码来源:MainActivity.java

示例5: displayImage

import com.squareup.picasso.RequestCreator; //导入依赖的package包/类
@Override
public void displayImage(Context context, String path, FixImageView imageView, Drawable defaultDrawable, Bitmap.Config config, boolean resize, boolean isGif, int width, int height, int rotate) {
    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)
                .centerCrop();
    }
    creator.into(imageView);
}
 
开发者ID:Loofer,项目名称:Watermark,代码行数:17,代码来源:PicassoImageLoader.java

示例6: loadImage

import com.squareup.picasso.RequestCreator; //导入依赖的package包/类
@Override
public ILoaderProxy loadImage(View view, String path) {
    if (view instanceof ImageView) {
        ImageView imageView = (ImageView) view;
        //判断缓存中是否已经缓存过该图片,有则直接拿Bitmap,没有则直接调用Glide加载并缓存Bitmap
        Bitmap bitmap = LruCacheUtils.getInstance().getBitmapFromMemCache(path);
        if (bitmap != null) {
            imageView.setImageBitmap(bitmap);
        } else {
            RequestCreator requestCreator = getPicasso().load(path);
            loadOptions(requestCreator).into(imageView);
        }
    }

    return obtain();
}
 
开发者ID:AweiLoveAndroid,项目名称:ImageLoaderProcessor,代码行数:17,代码来源:PicassoLoaderProcessor.java

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

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

示例9: loadAvatarImage

import com.squareup.picasso.RequestCreator; //导入依赖的package包/类
/**
 * Load an agent's or visitor's avatar into an {@link ImageView}.
 * <br>
 * Images get transformed into circular shaped. If there's no or no valid
 * url to the image {@code R.drawable.ic_chat_default_avatar} will be displayed.
 *
 * @param imageView the {@link ImageView}
 * @param avatarUri uri as a {@link String} to avatar image
 */
static void loadAvatarImage(@NonNull final ImageView imageView, @Nullable final String avatarUri) {
    final Picasso picasso = Picasso.with(imageView.getContext());

    final RequestCreator requestCreator;
    if(StringUtils.hasLength(avatarUri)) {
        requestCreator = picasso
                .load(avatarUri).error(DEFAULT_AVATAR)
                .error(DEFAULT_AVATAR)
                .placeholder(DEFAULT_AVATAR);
    } else {
        requestCreator = picasso
                .load(DEFAULT_AVATAR);
    }

    requestCreator
            .transform(new CircleTransform())
            .into(imageView);
}
 
开发者ID:zendesk,项目名称:android_sdk_demo_apps,代码行数:28,代码来源:PicassoHelper.java

示例10: setPicasso

import com.squareup.picasso.RequestCreator; //导入依赖的package包/类
public static void setPicasso(Context context, Uri url, ImageView imageView, @DrawableRes int placeHolder) {

        Picasso picasso = Picasso.with(context);

        if (BuildConfig.DEBUG)
            picasso.setLoggingEnabled(true);

        RequestCreator requestCreator = picasso.load(url);

        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            requestCreator.placeholder(placeHolder);
            requestCreator.error(placeHolder);
        } else {
            Drawable drawable = AppCompatDrawableManager.get().getDrawable(context, placeHolder);
            requestCreator.placeholder(drawable);
            requestCreator.error(drawable);
        }

        requestCreator.into(imageView);
    }
 
开发者ID:pvarry,项目名称:intra42,代码行数:21,代码来源:mImage.java

示例11: processScaleType

import com.squareup.picasso.RequestCreator; //导入依赖的package包/类
/**
 * 处理ScaleType
 *
 * @param uri
 * @param view
 * @return
 */
private static RequestCreator processScaleType(String uri, ImageView view) {
    if (view.getScaleType() == ImageView.ScaleType.CENTER) {
        view.setScaleType(ImageView.ScaleType.CENTER);
        return initWithResize(uri, view);
    } else if (view.getScaleType() == ImageView.ScaleType.CENTER_INSIDE) {
        return initWithResize(uri, view).centerInside();
    } else if (view.getScaleType() == ImageView.ScaleType.CENTER_CROP) {
        return initWithResize(uri, view).centerCrop();
    } else if (view.getScaleType() == ImageView.ScaleType.FIT_CENTER) {
        view.setScaleType(ImageView.ScaleType.FIT_CENTER);
        return init(uri, view);
    } else if (view.getScaleType() == ImageView.ScaleType.FIT_START) {
        view.setScaleType(ImageView.ScaleType.FIT_START);
        return init(uri, view);
    } else if (view.getScaleType() == ImageView.ScaleType.FIT_END) {
        view.setScaleType(ImageView.ScaleType.FIT_END);
        return init(uri, view);
    } else {
        return init(uri, view).fit();
    }
}
 
开发者ID:Jay-Y,项目名称:yApp,代码行数:29,代码来源:ImageLoader.java

示例12: fetchBitmap

import com.squareup.picasso.RequestCreator; //导入依赖的package包/类
private @Nullable Bitmap fetchBitmap(final @Nullable String url, final boolean transformIntoCircle) {
  if (url == null) {
    return null;
  }

  try {
    RequestCreator requestCreator = Picasso.with(this.context).load(url).transform(new CropSquareTransformation());
    if (transformIntoCircle) {
      requestCreator = requestCreator.transform(new CircleTransformation());
    }
    return requestCreator.get();
  } catch (IOException e) {
    Timber.e("Failed to load large icon: %s",  e);
    return null;
  }
}
 
开发者ID:kickstarter,项目名称:android-oss,代码行数:17,代码来源:PushNotifications.java

示例13: bind

import com.squareup.picasso.RequestCreator; //导入依赖的package包/类
@Override
public void bind(@NonNull final RepoEntity poRepo) {
    mTextView.setText(poRepo.url);

    final RequestCreator loRequest = mPicasso.load(poRepo.avatarUrl);
    if (loRequest != null) {
        loRequest
                .placeholder(R.drawable.git_icon)
                .error(R.drawable.git_icon)
                .into(mImageViewAvatar);
    }

    setOnClickListener((final View poView) ->
            notifyItemAction(ROW_PRESSED)
    );
}
 
开发者ID:RoRoche,项目名称:AndroidStarter,代码行数:17,代码来源:CellRepo.java

示例14: loadWallpaperFromSD

import com.squareup.picasso.RequestCreator; //导入依赖的package包/类
private void loadWallpaperFromSD() {
    String path = ThemeManager.getWallpaperPath(this);
    ImageView ivWallpaper = (ImageView) findViewById(R.id.ivWallpaper);
    if (!TextUtils.isEmpty(path)) {

        int blurRadius = PrefManager.getInt(SettingsFragment.KEY_BLUR_RADIUS);
        boolean applyBlur = PrefManager.getBoolean(SettingsFragment.KEY_BLUR_WALLPAPER);
        ivWallpaper.setVisibility(View.VISIBLE);
        final RequestCreator creator = Picasso.with(this)
                .load(new File(path));
        if (applyBlur) {
            creator.transform(new AndroidUtils.PicassoBlurTransform(blurRadius));
        }
        creator.into(ivWallpaper);
    } else {
        ivWallpaper.setVisibility(View.GONE);
    }
}
 
开发者ID:EuphoriaDev,项目名称:euphoria-vk-client,代码行数:19,代码来源:MessageHistoryActivity.java

示例15: loadWallpaper

import com.squareup.picasso.RequestCreator; //导入依赖的package包/类
private void loadWallpaper() {
    String wallpaperPath = ThemeManager.getWallpaperPath(this);
    if (TextUtils.isEmpty(wallpaperPath)) {
        return;
    }
    ImageView ivWallpaper = (ImageView) findViewById(R.id.ivWallpaper);
    ivWallpaper.setVisibility(View.VISIBLE);

    boolean applyBlur = PrefManager.getBoolean(SettingsFragment.KEY_BLUR_WALLPAPER);
    RequestCreator creator = Picasso.with(this)
            .load(new File(wallpaperPath));
    if (applyBlur) {
        creator.transform(new AndroidUtils.PicassoBlurTransform(PrefManager.getInt(SettingsFragment.KEY_BLUR_RADIUS)));
    }
    creator.into(ivWallpaper);
}
 
开发者ID:EuphoriaDev,项目名称:euphoria-vk-client,代码行数:17,代码来源:BasicActivity.java


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