本文整理汇总了Java中com.squareup.picasso.RequestCreator.placeholder方法的典型用法代码示例。如果您正苦于以下问题:Java RequestCreator.placeholder方法的具体用法?Java RequestCreator.placeholder怎么用?Java RequestCreator.placeholder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.squareup.picasso.RequestCreator
的用法示例。
在下文中一共展示了RequestCreator.placeholder方法的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;
}
示例2: 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);
}
示例3: onViewCreated
import com.squareup.picasso.RequestCreator; //导入方法依赖的package包/类
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
boolean fitXY = getArguments().getBoolean(FIT_XY);
if (getActivity() instanceof HelloActivity) {
if (!((HelloActivity) getActivity()).isNetworkAvailable()) {
if (fitXY) {
Toast.makeText(getActivity(), R.string.network_unavailable, Toast.LENGTH_SHORT).show();
mFantasy.setImageResource(R.drawable.default_fantasy);
return; // 没有网络,直接结束第一张fantasy
}
}
}
RequestCreator creator = Picasso.with(getActivity()).load(mUrl);
if (fitXY) {
creator.placeholder(R.drawable.default_fantasy);
}
creator.error(R.drawable.error)
.into(target);
}
示例4: displayNoScaling
import com.squareup.picasso.RequestCreator; //导入方法依赖的package包/类
public static void displayNoScaling(ImageView imageView, String uri, boolean fadeIn, int stubImage, ImageLoaderListener listener)
{
if (uri == null || uri.length() == 0)
uri = FAKE_URI;
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();
requestCreator.into(imageView, listener);
}
示例5: processResId
import com.squareup.picasso.RequestCreator; //导入方法依赖的package包/类
private static RequestCreator processResId(RequestCreator taget, int placeholderResId, int errorResId) {
if (0 != placeholderResId && 0 != errorResId) {
return taget
.placeholder(placeholderResId)
.error(errorResId);
} else if (0 != placeholderResId) {
return taget.placeholder(placeholderResId);
} else if (0 != errorResId) {
return taget.error(errorResId);
}
return taget;
}
示例6: loadBitmap
import com.squareup.picasso.RequestCreator; //导入方法依赖的package包/类
/**
* Loads the bitmap at the provided url, but checks the cache first.
*
* @param view the view to where the bitmap shall be set.
* @param url the urk of the bitmap. This acts as a key for the cache.
* @param options the option bundle.
* @param callback an optional callback.
*/
public static void loadBitmap(@NonNull ImageView view, @Nullable String url,
@NonNull Options options,
@Nullable final Callback callback){
if (url == null || url.isEmpty()){
//view.setImageResource(R.drawable.ic_compass_white_50dp);
}
else{
Picasso picasso = Picasso.with(view.getContext());
picasso.setIndicatorsEnabled(BuildConfig.DEBUG);
RequestCreator request = picasso.load(url);
if (options.mUseDefaultPlaceholder){
//request.placeholder(R.drawable.ic_compass_white_50dp);
}
else if (options.mPlaceholder != 0){
request.placeholder(options.mPlaceholder);
}
if (options.mCropToCircle){
request.transform(new CircleCropTransformation());
}
request.into(view, new com.squareup.picasso.Callback(){
@Override
public void onSuccess(){
if (callback != null){
callback.onImageLoadSuccess();
}
}
@Override
public void onError(){
if (callback != null){
callback.onImageLoadFailure();
}
}
});
}
}
示例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);
}
}
示例8: onPrepareRequestCreator
import com.squareup.picasso.RequestCreator; //导入方法依赖的package包/类
/**
* Prepares loading request creator with configuration based on this task's parameters.
*
* @param loader Loader used to obtain the creator.
* @return Prepared image loading request creator to be executed.
*/
@NonNull
protected RequestCreator onPrepareRequestCreator(@NonNull Picasso loader) {
final RequestCreator creator = loader.load(mTarget);
if (mPlaceholderRes != NO_RESOURCE_ID) creator.error(mPlaceholderRes);
if (mPlaceholder != null) creator.error(mPlaceholder);
if (mErrorRes != NO_RESOURCE_ID) creator.placeholder(mErrorRes);
if (mError != null) creator.placeholder(mError);
if (mTransformation != null) creator.transform(mTransformation);
if (hasRequest(REQUEST_DO_NOT_ANIMATE)) creator.noFade();
return creator;
}
示例9: 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);
}
示例10: setUpPhotoFromUrl
import com.squareup.picasso.RequestCreator; //导入方法依赖的package包/类
private void setUpPhotoFromUrl(){
RequestCreator requestCreator = Picasso.with(this)
.load(pictureUrl);
if(!showLoadingProgress){
hideProgressView();
}
if(displayErrorDrawableNeeded()){
requestCreator.error(photoErrorDrawableResId);
}
if(displayPlaceHolderNeeded()){
requestCreator.placeholder(photoPlaceHolderResId);
}
requestCreator
.into(picturePhotoView, new Callback() {
@Override
public void onSuccess() {
hideProgressView();
addPhotoViewAttacherAndTapListener();
runHideActionBarTimer();
}
@Override
public void onError() {
hideProgressView();
}
});
}
示例11: 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
示例12: bindEventAndShow
import com.squareup.picasso.RequestCreator; //导入方法依赖的package包/类
private void bindEventAndShow(
@NonNull final ImageView targetImageView,
@NonNull final String mURI
) {
// mLoadListener.onStart(me);
final Picasso p = Picasso.with(mContext);
final RequestCreator mreq = p.load(mURI);
if (getEmpty() != 0) {
mreq.placeholder(getEmpty());
}
if (getError() != 0) {
mreq.error(getError());
}
if (mImageLocalStorageEnable) {
mreq.memoryPolicy(MemoryPolicy.NO_STORE, MemoryPolicy.NO_CACHE);
}
switch (mScaleType) {
case Fit:
mreq.fit();
break;
case CenterCrop:
mreq.fit().centerCrop();
break;
case CenterInside:
mreq.fit().centerInside();
break;
}
mreq.into(targetImageView, new Callback() {
@Override
public void onSuccess() {
// if (v.findViewById(R.id.ns_loading_progress) != null) {
// hideoutView(v.findViewById(R.id.ns_loading_progress));
// }
if (mLongClickSaveImage && fmg != null) {
targetImageView.setOnLongClickListener(new View.OnLongClickListener() {
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public boolean onLongClick(View v) {
prepare_request_save_image = mreq;
final saveImageDialog saveImageDial = new saveImageDialog();
saveImageDial.show(fmg.get(), "DESC_SAVE_IM");
return false;
}
});
}
}
@Override
public void onError() {
//if (mLoadListener != null) {
// mLoadListener.onEnd(false, me);
// }
}
});
}
示例13: bindCompatPicasso
import com.squareup.picasso.RequestCreator; //导入方法依赖的package包/类
protected void bindCompatPicasso(String mURI, final MiniSliderFrame Fr) {
final Picasso p = Picasso.with(mContext);
final RequestCreator mreq = p.load(mURI);
if (getEmpty() != 0) {
mreq.placeholder(getEmpty());
}
if (getError() != 0) {
mreq.error(getError());
}
if (mImageLocalStorageEnable) {
mreq.memoryPolicy(MemoryPolicy.NO_STORE, MemoryPolicy.NO_CACHE);
}
switch (mScaleType) {
case Fit:
mreq.fit();
break;
case CenterCrop:
mreq.fit().centerCrop();
break;
case CenterInside:
mreq.fit().centerInside();
break;
}
mreq.into(Fr.getImageTarget(), new Callback() {
@Override
public void onSuccess() {
hideoutView(Fr.getLoadingBar());
if (mLongClickSaveImage && fmg != null) {
Fr.getTouch().setOnLongClickListener(new View.OnLongClickListener() {
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public boolean onLongClick(View v) {
prepare_request_save_image = mreq;
final saveImageDialog saveImageDial = new saveImageDialog();
saveImageDial.show(fmg.get(), "DESC_SAVE_IM");
return false;
}
});
}
}
@Override
public void onError() {
//if (mLoadListener != null) {
// mLoadListener.onEnd(false, me);
// }
}
});
}
示例14: triggerUpdate
import com.squareup.picasso.RequestCreator; //导入方法依赖的package包/类
@UiThread
protected final void triggerUpdate() {
// short-circuit if we are in edit mode within a development tool
if (mView.isInEditMode()) {
return;
}
// if we are batching updates, track that we need an update, but don't trigger the update now
if (mBatching > 0) {
mNeedsUpdate = true;
return;
}
// if we are currently in a layout pass, track that we need an update once layout is complete
if (ViewCompat.isInLayout(mView) ||
// attempt to detect if we are currently being laid out for older versions of android
(Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2 && mView.isLayoutRequested())) {
mNeedsUpdate = true;
return;
}
// create base request
final RequestCreator update = onCreateUpdate(Picasso.with(mView.getContext()));
// set placeholder & any transform options
if (mPlaceholderResId != INVALID_DRAWABLE_RES) {
update.placeholder(mPlaceholderResId);
} else {
update.placeholder(mPlaceholder);
}
if (mSize.width > 0 || mSize.height > 0) {
onSetUpdateScale(update, mSize);
}
update.transform(mTransforms);
// fetch or load based on the target size
if (mSize.width > 0 || mSize.height > 0) {
update.into(mView);
} else {
update.fetch();
}
// clear the needs update flag
mNeedsUpdate = false;
}
示例15: loadByPicasso
import com.squareup.picasso.RequestCreator; //导入方法依赖的package包/类
protected void loadByPicasso(final View v, ImageView targetImageView) {
final BaseSliderView me = this;
Picasso p = Picasso.with(mContext);
RequestCreator rq;
if (mUrl != null) {
rq = p.load(mUrl);
} else if (mFile != null) {
rq = p.load(mFile);
} else if (mRes != 0) {
rq = p.load(mRes);
} else {
return;
}
if (rq == null) {
return;
}
if (getImageResForEmpty() != 0) {
rq.placeholder(getImageResForEmpty());
}
if (getImageResForError() != 0) {
rq.error(getImageResForError());
}
switch (mScaleType) {
case Fit:
rq.fit();
break;
case CenterCrop:
rq.fit().centerCrop();
break;
case CenterInside:
rq.fit().centerInside();
break;
}
rq.into(targetImageView, new Callback() {
@Override
public void onSuccess() {
if (v.findViewById(R.id.loading_bar) != null) {
v.findViewById(R.id.loading_bar).setVisibility(View.INVISIBLE);
}
if (mBitmapLoadListener != null) {
mBitmapLoadListener.onLoadComplete(me);
}
}
@Override
public void onError() {
if (mBitmapLoadListener != null) {
mBitmapLoadListener.onLoadFail(me);
}
}
});
}