本文整理匯總了Java中com.squareup.picasso.Target類的典型用法代碼示例。如果您正苦於以下問題:Java Target類的具體用法?Java Target怎麽用?Java Target使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Target類屬於com.squareup.picasso包,在下文中一共展示了Target類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: displayCommunityCover
import com.squareup.picasso.Target; //導入依賴的package包/類
@Override
public void displayCommunityCover(boolean enabled, String resource) {
if (enabled) {
PicassoInstance.with()
.load(resource)
.into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
Drawable drawable = new BitmapDrawable(getResources(), bitmap);
mHeaderHolder.vgCover.setBackground(drawable);
}
@Override
public void onBitmapFailed(Exception e, Drawable errorDrawable) {
//do nothing
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
//do nothing
}
});
}
}
示例2: setAvatar
import com.squareup.picasso.Target; //導入依賴的package包/類
private void setAvatar() {
String s = mTeacher.getTeacher_avatar();
if (FunctionHelper.isEmpty(s)) {
img_avatar.setImageResource(R.drawable.person_placeholder);
} else {
Picasso.with(mContext)
.load("file://" + s)
.error(R.drawable.person_placeholder)
.into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
img_avatar.setImageBitmap(bitmap);
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
img_avatar.setImageDrawable(errorDrawable);
FunctionHelper.makeLToast(mContext, mResources.getString(R.string.error_load_image));
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
});
}
}
示例3: saveToGallery
import com.squareup.picasso.Target; //導入依賴的package包/類
private void saveToGallery() {
Picasso.with(getActivity()).load(mImage).into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
final String uri = MediaStore.Images.Media.insertImage(Inject.contentResolver(), bitmap, "", "");
final ContentValues values = new ContentValues();
values.put(MediaStore.Images.Media.DATE_TAKEN, System.currentTimeMillis());
Inject.contentResolver().update(Uri.parse(uri), values, null, null);
getActivity().sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse(uri)));
Snackbar.make(getActivity().findViewById(R.id.coordinator),
R.string.image_saved, Snackbar.LENGTH_SHORT).show();
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
});
}
示例4: getNightThemeTarget
import com.squareup.picasso.Target; //導入依賴的package包/類
private Target getNightThemeTarget() {
return new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
streamerImage.setImageBitmap(bitmap);
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
};
}
示例5: loadStreamerInfoAlbumArt
import com.squareup.picasso.Target; //導入依賴的package包/類
private void loadStreamerInfoAlbumArt() {
Target loadArtTarget = new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
if (mediaSession != null && mediaSession.isActive()) {
mediaSession.setMetadata(getMediaSessionData(bitmap));
}
mChannelInfo.setLogoImage(bitmap);
if (lastNotificationAction != null) {
buildNotification(lastNotificationAction);
}
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
};
Picasso.with(this).load(mChannelInfo.getLogoURLString()).into(loadArtTarget);
}
示例6: loadLoadingUrl
import com.squareup.picasso.Target; //導入依賴的package包/類
private void loadLoadingUrl(@NonNull final String url, @NonNull final String loadingUrl, final boolean loadingBlur) {
final List<Transformation> transformations = new ArrayList<>();
if (loadingBlur) {
transformations.add(new BlurTransformation(getContext()));
}
Picasso.with(getContext()).load(loadingUrl).transform(transformations).into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
loadUrl(url, bitmap);
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
});
}
示例7: loadFromUrlToBitmap
import com.squareup.picasso.Target; //導入依賴的package包/類
public static void loadFromUrlToBitmap(ViewContext context, String url,
LoadBitmapCallback callback)
{
if (url.isEmpty()) {
callback.onLoaded(null);
return;
}
Target target = new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
callback.onLoaded(bitmap);
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
callback.onLoaded(null);
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
};
Picasso.with(context.getInstance()).load(url).into(target);
}
示例8: showImage
import com.squareup.picasso.Target; //導入依賴的package包/類
public void showImage(final Picasso picasso, final Uri uri, CalculatedDimensions dimensions) {
if(uri == null || uri.equals(this.uri)) {
L.d(LOG_TAG, "Image already loaded. " + uri);
return;
}
// cancel running picasso operations
if(this.picasso != null) {
this.picasso.cancelRequest((Target) this);
this.picasso.cancelRequest((ImageView) this);
}
this.uri = uri;
this.picasso = picasso;
this.rawImageWidth = dimensions.rawImageWidth;
this.rawImageHeight = dimensions.rawImageHeight;
this.viewHeight = dimensions.viewHeight;
this.viewWidth = dimensions.viewWidth;
startImageLoading(picasso, uri, viewWidth, rawImageWidth, rawImageHeight);
}
示例9: setupForTaxon
import com.squareup.picasso.Target; //導入依賴的package包/類
public void setupForTaxon(final Taxon taxon) {
Target target = new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
icon.setImageBitmap(Blender.blendDrawable(bitmap, ContextCompat.getColor(icon.getContext(), R.color.googleYellow)));
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {}
};
icon.setTag(target);
Picasso.with(icon.getContext()).load(taxon.getIconUrl()).into(target);
label.setText(taxon.getName());
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
drawerActionListener.onTaxonSelected(taxon);
}
});
}
示例10: setupForTaxon
import com.squareup.picasso.Target; //導入依賴的package包/類
private void setupForTaxon(Taxon taxon) {
Target target = new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
icon.setImageBitmap(Blender.blendDrawable(bitmap, ContextCompat.getColor(getContext(), R.color.googleYellow)));
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {}
};
icon.setTag(target);
Picasso.with(icon.getContext())
.load(taxon.getIconUrl())
.into(target);
label.setText(taxon.getName());
}
示例11: createDetailsOverviewRow
import com.squareup.picasso.Target; //導入依賴的package包/類
private DetailsOverviewRow createDetailsOverviewRow() {
final DetailsOverviewRow detailsRow = new DetailsOverviewRow(mItem);
Picasso.with(getActivity()).load(mHeroImage).into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
detailsRow.setImageBitmap(getActivity(), bitmap);
mAdapter.notifyArrayItemRangeChanged(0, mAdapter.size());
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void onBitmapFailed(Drawable errorDrawable) {
if(VersionUtils.isLollipop())
getActivity().startPostponedEnterTransition();
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
});
return detailsRow;
}
示例12: getTargetForPois
import com.squareup.picasso.Target; //導入依賴的package包/類
private Target getTargetForPois(final Place place, final int idPlaceToGo) {
return new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
bitmap = bitmapHelper.getTintedBitmap(bitmap, ContextCompat.getColor(getContext(), R.color.orange));
bitmap = bitmapHelper.getScaledBitmap(bitmap, (int) getResources().getDimension(R.dimen._30dp));
markersMap.put(addMarkerPoi(place, BitmapDescriptorFactory.fromBitmap(bitmap), idPlaceToGo), place);
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
markersMap.put(addMarkerPoi(place, getIconPoi(), idPlaceToGo), place);
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
};
}
示例13: loadImage
import com.squareup.picasso.Target; //導入依賴的package包/類
private void loadImage(Uri uri, final MD360BitmapTexture.Callback callback){
mTarget = new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
// notify if size changed
getVRLibrary().onTextureResize(bitmap.getWidth(),bitmap.getHeight());
// texture
callback.texture(bitmap);
cancelBusy();
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
};
Picasso.with(getApplicationContext()).load(uri).resize(3072,2048).centerInside().memoryPolicy(NO_CACHE, NO_STORE).into(mTarget);
}
示例14: onProvideBitmap
import com.squareup.picasso.Target; //導入依賴的package包/類
@Override
public void onProvideBitmap(final MD360BitmapTexture.Callback callback) {
if (model == null) {
return;
}
Picasso.with(itemView.getContext()).load(model.uri).into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
vrlib.onTextureResize(bitmap.getWidth(), bitmap.getHeight());
callback.texture(bitmap);
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
});
}
示例15: onProvideBitmap
import com.squareup.picasso.Target; //導入依賴的package包/類
@Override
public void onProvideBitmap(final Uri uri, final MD360BitmapTexture.Callback callback) {
final Target target = new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
// texture
callback.texture(bitmap);
targetMap.remove(uri);
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
targetMap.remove(uri);
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
};
targetMap.put(uri, target);
Picasso.with(getApplicationContext()).load(uri).resize(callback.getMaxTextureSize(),callback.getMaxTextureSize()).onlyScaleDown().centerInside().memoryPolicy(NO_CACHE, NO_STORE).into(target);
}