Java 类com.squareup.picasso.Target 实例源码

项目:Phoenix-for-VK    文件:GroupWallFragment.java   
@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
                    }
                });
    }
}
项目:MyCalendar    文件:DetailTeacherActivity.java   
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) {
                    }
                });
    }
}
项目:robird-reborn    文件:ImageFragment.java   
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) {

        }
    });
}
项目:Pocket-Plays-for-Twitch    文件:ChannelActivity.java   
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) {

        }
    };
}
项目:Pocket-Plays-for-Twitch    文件:PlayerService.java   
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);
}
项目:DismissibleImageView    文件:FullScreenImageFragment.java   
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) {

        }
    });
}
项目:humaniq-android    文件:ImageTool.java   
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);
}
项目:belvedere    文件:FixedWidthImageView.java   
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);
    }
项目:belvedere    文件:FixedWidthImageView.java   
public void showImage(final Picasso picasso, final Uri uri, long rawImageWidth, long rawImageHeight,
                      DimensionsCallback dimensionsCallback) {

    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 = (int) rawImageWidth;
    this.rawImageHeight = (int) rawImageHeight;
    this.dimensionsCallback = dimensionsCallback;

    if(viewWidth > 0) {
        startImageLoading(picasso, uri, viewWidth, this.rawImageWidth, this.rawImageHeight);
    } else {
        imageWaiting.set(true);
    }
}
项目:spree-android    文件:DrawerPageItemRowLinearHolder.java   
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);
        }
    });
}
项目:spree-android    文件:BlockItem.java   
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());
}
项目:popcorn-android    文件:PTVBaseDetailsFragment.java   
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;
}
项目:RxGpsService    文件:PlaceMapFragment.java   
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) {

        }
    };
}
项目:md360    文件:BitmapPlayerActivity.java   
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);
}
项目:MD360Player4Android    文件:RecyclerViewActivity.java   
@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) {

        }
    });
}
项目:MD360Player4Android    文件:MD360PlayerActivity.java   
@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);
}
项目:Cheerleader    文件:NotificationManager.java   
/**
 * Initialize target used to load artwork asynchronously.
 */
private void initializeArtworkTarget() {
    mThumbnailArtworkTarget = new Target() {
        @Override
        public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
            mNotificationView.setImageViewBitmap(
                    R.id.simple_sound_cloud_notification_thumbnail, bitmap);
            mNotificationExpandedView.setImageViewBitmap(
                    R.id.simple_sound_cloud_notification_thumbnail, bitmap);
            mNotificationManager.notify(NOTIFICATION_ID, buildNotification());
        }

        @Override
        public void onBitmapFailed(Drawable errorDrawable) {

        }

        @Override
        public void onPrepareLoad(Drawable placeHolderDrawable) {
        }
    };
}
项目:os-mobilizer-android    文件:NavigationDrawerFragment.java   
public void setUserData(String user, String email, String image) {
    final ImageView avatarContainer = (ImageView) mFragmentContainerView.findViewById(R.id.imgAvatar);
    ((TextView) mFragmentContainerView.findViewById(R.id.txtUserEmail)).setText(email);
    ((TextView) mFragmentContainerView.findViewById(R.id.txtUsername)).setText(user);

    Target target = new Target() {
        @Override
        public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
            avatarContainer.setImageDrawable(new RoundImage(bitmap));
        }

        @Override
        public void onBitmapFailed(Drawable errorDrawable) {

        }

        @Override
        public void onPrepareLoad(Drawable placeHolderDrawable) {

        }
    };

    Picasso.with(getActivity()).load(image).into(target);
}
项目:getsocial-android-sdk    文件:UserManagementFragment.java   
@Override
protected void onImagePickedFromDevice(Uri imageUri, int requestCode) {
    if (requestCode == REQUEST_PICK_AVATAR) {
        with(getContext())
                .load(imageUri)
                .resize(MAX_WIDTH, 0)
                .memoryPolicy(MemoryPolicy.NO_CACHE)
                .into(new Target() {
                    @Override
                    public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
                        setAvatarBitmap(bitmap);
                    }

                    @Override
                    public void onBitmapFailed(Drawable errorDrawable) {
                        showAlert("Error", "Failed to load image");
                    }

                    @Override
                    public void onPrepareLoad(Drawable placeHolderDrawable) {

                    }
                });
    }
}
项目:ocara    文件:BaseActivity.java   
/**
 * To update the action bar logo from an Uri.
 *
 * @param uri logo uri
 */
void updateLogo(Uri uri) {
    Target target = new Target() {
        @Override
        public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
            getSupportActionBar().setLogo(new BitmapDrawable(getResources(), bitmap));
        }

        @Override
        public void onBitmapFailed(Drawable errorDrawable) {
        }

        @Override
        public void onPrepareLoad(Drawable placeHolderDrawable) {
        }
    };
    final int maxSize = getResources().getDimensionPixelSize(R.dimen.abc_action_button_min_height_material);
    picasso.load(uri).placeholder(android.R.color.black).resize(maxSize, maxSize).into(target);
}
项目:kickmaterial    文件:RewardsListActivity.java   
private void loadProjectData() {
    selectCategoryTv.setText(R.string.select_pledge);
    selectCategoryTv.setBackgroundColor(Color.TRANSPARENT);
    categoryCircleIv.setVisibility(View.GONE);
    Picasso.with(getApplicationContext()).load(project.getPhotoUrl()).into(new Target() {
        @Override
        public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
            selectedCategoryIv.setImageBitmap(bitmap);
            LUtils.toGrayscale(selectedCategoryIv);
            selectedCategoryIv.getDrawable().setColorFilter(ContextCompat.getColor(RewardsListActivity.this, R.color.green_dark), PorterDuff.Mode.MULTIPLY);
        }

        @Override
        public void onBitmapFailed(Drawable errorDrawable) {
            selectedCategoryIv.setImageResource(0);
        }

        @Override
        public void onPrepareLoad(Drawable placeHolderDrawable) {
            selectedCategoryIv.setImageResource(0);
        }
    });
}
项目:onyxbeacon-android-sdk    文件:RewardsListActivity.java   
private void loadProjectData() {
    selectCategoryTv.setText(R.string.select_pledge);
    selectCategoryTv.setBackgroundColor(Color.TRANSPARENT);
    categoryCircleIv.setVisibility(View.GONE);
    Picasso.with(getApplicationContext()).load(project.getPhotoUrl()).into(new Target() {
        @Override
        public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
            selectedCategoryIv.setImageBitmap(bitmap);
            LUtils.toGrayscale(selectedCategoryIv);
            selectedCategoryIv.getDrawable().setColorFilter(ContextCompat.getColor(RewardsListActivity.this, R.color.green_dark), PorterDuff.Mode.MULTIPLY);
        }

        @Override
        public void onBitmapFailed(Drawable errorDrawable) {
            selectedCategoryIv.setImageResource(0);
        }

        @Override
        public void onPrepareLoad(Drawable placeHolderDrawable) {
            selectedCategoryIv.setImageResource(0);
        }
    });
}
项目:android-sdk-examples    文件:MultiLocationMapView.java   
private void loadBitmap(String url) {

        // hold strong reference into target so that it does not get GC'd
        mTarget = new Target() {
            @Override
            public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
                setImage(ImageSource.bitmap(bitmap.copy(bitmap.getConfig(), true)));
            }

            @Override
            public void onBitmapFailed(Drawable errorDrawable) {
            }

            @Override
            public void onPrepareLoad(Drawable placeHolderDrawable) {
            }
        };

        Picasso.with(getContext())
                .load(url)
                .into(mTarget);

    }
项目:appcutt    文件:PhotoDetailActivity.java   
private void initPallete(Photo photo) {
        Picasso.with(this)
                .load(photo.getImageUrl())
                .placeholder(R.color.theme50)
                .into(new Target() {
                    @Override
                    public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
                        imgPreview.setImageBitmap(bitmap);
//                        colorPalleteView.initColors(bitmap);
                    }

                    @Override
                    public void onBitmapFailed(Drawable errorDrawable) {
                        //
                    }

                    @Override
                    public void onPrepareLoad(Drawable placeHolderDrawable) {
                        //
                    }
                });
    }
项目:DaVinci    文件:DaVinciDaemon.java   
private void sendImage(final String url, final String path) {
    Picasso.with(mContext)
            .load(url)
            .transform(new ResizeTransformation(300))
            .into(new Target() {
                @Override
                public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
                    Log.d(TAG, "Picasso " + url + " loaded");
                    sentBitmap(bitmap, url, path);
                }

                @Override
                public void onBitmapFailed(Drawable errorDrawable) {
                    Log.d(TAG, "Picasso " + url + " failed");
                }

                @Override
                public void onPrepareLoad(Drawable placeHolderDrawable) {

                }
            });
}
项目:Beautiful-Photos    文件:BeautifulPhotosPresenterImpl.java   
/**
 * Launch intent to share current photo
 */
@Override
public void share(final Context ctx) {
    final PhotoModel photo = photos.get(itemIndex);

    // Picasso already has cached this image, so extract cached bitmap from its cache
    Picasso.with(ctx).load(photo.getLargeUrl()).into(new Target() {
        @Override
        public void onBitmapFailed(Drawable errorDrawable) {
        }

        @Override
        public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
            // Get bitmap uri from filesystem and create intent with it.
            shareBitmap(ctx, bitmap, photo.getTitle());
        }

        @Override
        public void onPrepareLoad(Drawable placeHolderDrawable) {
             /* nothing to do */
        }
    });

}
项目:Pugnotification    文件:SamplePugNotification.java   
private static Target getViewTarget(final OnImageLoadingCompleted onCompleted) {
    return new Target() {
        @Override
        public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
            onCompleted.imageLoadingCompleted(bitmap);
        }

        @Override
        public void onBitmapFailed(Drawable errorDrawable) {

        }

        @Override
        public void onPrepareLoad(Drawable placeHolderDrawable) {

        }
    };
}
项目:NerdNite    文件:MainEventActivity.java   
@AfterViews
public void setSpeakerPics(){
    ArrayList<Presenter> presenters = nextEvent.getPresenters();
    Presenter p;
    int px = DisplayUtils.dpToPixels(50);
    int mg = DisplayUtils.dpToPixels(10);
    for (int i = 0; i < presenters.size(); i++){
        p = presenters.get(i);
        UserPic v = new UserPic(this);
        v.getPicView().setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT);
        params.setMargins(mg, 0, mg, 0);
        params.weight = 1;
        v.setLayoutParams(params);
        v.getPicView().setDimens(px, px);
        v.getNameView().setVisibility(View.GONE);
        Picasso.with(this).load(p.getPic()).into((Target)v.getPicView());
        speakerPics.addView(v);
    }
}
项目:NerdNite    文件:MainEventActivity.java   
@AfterViews
public void setBossPics(){
    ArrayList<Boss> bosses = city.getBosses();
    bossPics.setWeightSum(bosses.size());
    int px = DisplayUtils.dpToPixels(75);
    for (Boss boss : bosses){
        UserPic v = new UserPic(this);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT);
        params.weight = 1;
        v.setLayoutParams(params);
        v.getPicView().setDimens(px, px);
        v.getPicView().setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        Picasso.with(this).load(boss.getPic()).into((Target) v.getPicView());
        v.setName(boss.getName());
        fm.setFont(v.getNameView(), FontManager.NerdNiteFont.FONT_PROXIMA_NOVA_BOLD);
        bossPics.addView(v);
    }
}
项目:TFG-SmartU-La-red-social    文件:Imagen360Activity.java   
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
            mVRLibrary.onTextureResize(bitmap.getWidth(), bitmap.getHeight());
            // texture
            callback.texture(bitmap);
            imagenCargada();
        }
        @Override
        public void onBitmapFailed(Drawable errorDrawable) {}

        @Override
        public void onPrepareLoad(Drawable placeHolderDrawable) {}
    };
    //Cargo la imagen con Picasso, me aseguro de que no la guarde en cache
    //que la reescale para ser más pequeña, que la centre y que la ponga
    //en el target
    Picasso.with(getApplicationContext())
            .load(uri)
            .resize(callback.getMaxTextureSize(),callback.getMaxTextureSize())
            .onlyScaleDown()
            .centerInside()
            .memoryPolicy(NO_CACHE, NO_STORE)
            .into(mTarget);
}
项目:MyCalendar    文件:DetailTeacherActivity.java   
private void setBackground() {
    String s = mTeacher.getTeacher_background();
    if (FunctionHelper.isEmpty(s)) {
        img_background.setImageResource(R.drawable.background);
    } else {
        Picasso.with(mContext)
                .load("file://" + s)
                .error(R.drawable.background)
                .into(new Target() {
                    @Override
                    public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
                        img_background.setImageBitmap(bitmap);
                    }

                    @Override
                    public void onBitmapFailed(Drawable errorDrawable) {
                        img_background.setImageDrawable(errorDrawable);
                        FunctionHelper.makeLToast(mContext, mResources.getString(R.string.error_load_image));
                    }

                    @Override
                    public void onPrepareLoad(Drawable placeHolderDrawable) {
                    }
                });
    }

}
项目:DeepImagePreview-Project    文件:ImageLoaderHelper.java   
public static void loadImagePreviewFromCache(Context context, SearchResultContainer container, int imageSize, Target target){
    Picasso.with(context)
            .load(container.getFirstThumbnailLink())
            .resize(imageSize, imageSize)
            .transform(new CircleTransform())
            .networkPolicy(NetworkPolicy.OFFLINE)
            .into(target);
}
项目:DeepImagePreview-Project    文件:DetectionViewHolder.java   
public void bind(final Detection detection, final DetectionViewAdapter.Listener listener) {
    mTextView.setText(detection.getQuery());


    GradientDrawable drawable = (GradientDrawable) itemView.getBackground();
    if (detection.getContainer() != null) {
        drawable.setColor(Color.parseColor(detection.getContainer().getColor()));

        ImageLoaderHelper.loadImagePreviewFromCache(itemView.getContext(), detection.getContainer(), 80,
                new Target() {
                    @Override
                    public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
                        mImageView.setImageBitmap(bitmap);
                    }

                    @Override
                    public void onBitmapFailed(Drawable errorDrawable) {

                    }

                    @Override
                    public void onPrepareLoad(Drawable placeHolderDrawable) {

                    }
                });
    } else {
        drawable.setColor(ContextCompat.getColor(itemView.getContext(), android.R.color.darker_gray));
        mImageView.setImageBitmap(null);
    }

    itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            listener.onItemClicked(detection.getQuery());
        }
    });
}
项目:SugarPhotoPicker    文件:ImageLoader.java   
public static void display(Context context, String url, Target target){
        if(context == null){
            return;
        }
        if (TextUtils.isEmpty(url)) {
            url = "http://";
        }
        Picasso.with(context)
                .load(url)
//                .placeholder(R.drawable.icon_image_holder)
//                .error(R.drawable.icon_image_holder)
                .into(target);
    }
项目:ImageLoaderProcessor    文件:PicassoLoaderProcessor.java   
@Override
public ILoaderProxy saveImage(String url, final File destFile, final ICallback callback) {
    getPicasso().load(url).into(new Target() {
        @Override
        public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
            FileUtil.saveBitmap(bitmap, destFile.getAbsolutePath());
            AppLike.gInstance.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(destFile)));
            ToastUtils.showWarnMsg("图片保存成功!");
            if (callback != null) {
                callback.onSuccess("图片保存成功");
            }
            if (bitmap != null) {
                bitmap.recycle();
            }
        }

        @Override
        public void onBitmapFailed(Drawable errorDrawable) {
            ToastUtils.showWarnMsg("图片保存失败!");
            if (callback != null) {
                callback.onFailed("图片加载失败");
            }
        }


        @Override
        public void onPrepareLoad(Drawable placeHolderDrawable) {

        }
    });
    return obtain();
}
项目:Pocket-Plays-for-Twitch    文件:ChannelActivity.java   
private void initStreamerImageAndColors() {
    Target mTarget = getNightThemeTarget();
    String theme = new Settings(this).getTheme();
    if (!theme.equals(getString(R.string.night_theme_name)) && !theme.equals(getString(R.string.true_night_theme_name))) {
        mTarget = getLightThemeTarget();
    }

    mLoadingTarget = mTarget;
    Picasso.with(getBaseContext())
            .load(info.getMediumPreview())
            .into(mTarget);
}
项目:react-native-dominant-color    文件:RNDominantColorModule.java   
private void loadImageFromUrl(final String url, final Callback callback) {
    final Activity activity = getCurrentActivity();
    Handler uiHandler = new Handler(Looper.getMainLooper());

    final Target target = new Target() {
        @Override
        public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
            WritableMap colorMap = mapColors(bitmap);

            callback.invoke(false, colorMap);
        }

        @Override
        public void onBitmapFailed(Drawable errorDrawable) {
            callback.invoke(true, null);
        }

        @Override
        public void onPrepareLoad(Drawable placeHolderDrawable) {
        }
    };

    uiHandler.post(new Runnable() {
        @Override
        public void run() {
            Picasso
                    .with(activity.getApplicationContext())
                    .load(url)
                    .resize(200, 200)
                    .into(target);
        }
    });
}
项目:atlant-android    文件:PicassoTargetUtils.java   
private void createTarget() {
  target = new Target() {
    @Override
    public void onBitmapLoaded(Bitmap bitmap, LoadedFrom from) {
      materialProgressBar.setVisibility(View.INVISIBLE);
      imageView.setScaleType(ScaleType.CENTER_CROP);
      imageView.setColor(Color.TRANSPARENT);
      imageView.setImageBitmap(bitmap);
      imageView.invalidate();
      if (callBack != null) {
        callBack.onBitmapLoaded();
      }
    }

    @Override
    public void onBitmapFailed(Drawable errorDrawable) {
      materialProgressBar.setVisibility(View.INVISIBLE);
      imageView.setScaleType(ScaleType.CENTER_INSIDE);
      imageView.setImageDrawable(errorDrawable);
      if (callBack != null) {
        callBack.onBitmapFailed();
      }
    }

    @Override
    public void onPrepareLoad(Drawable placeHolderDrawable) {
      if (callBack != null) {
        callBack.onPrepareLoad();
      }
    }
  };
}
项目:belvedere    文件:FixedWidthImageView.java   
private void startImageLoading(Picasso picasso, Uri uri, int viewWidth, int rawImageWidth, int rawImageHeight) {
    L.d(LOG_TAG, "Start loading image: " + viewWidth + " " + rawImageWidth + " " + rawImageHeight);
    if(rawImageWidth > 0 && rawImageHeight > 0) {
        final Pair<Integer, Integer> scaledDimensions =
                scale(viewWidth, rawImageWidth, rawImageHeight);
        loadImage(picasso, scaledDimensions.first, scaledDimensions.second, uri);
    } else {
        picasso.load(uri).into((Target) this);
    }
}
项目:react-native-maps    文件:PPTGoogleMapManager.java   
/**
 * Loads a marker icon via URL and places it on the map at the required position.
 *
 * @param googleMap
 * @param latLng
 * @param uri
 */
private void markerWithCustomIcon(final GoogleMap googleMap, final LatLng latLng, Uri uri, final String publicId) {
    try {
        Target target = new Target() {
            @Override
            public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
                MarkerOptions options = new MarkerOptions();

                options.position(latLng)
                        .icon(BitmapDescriptorFactory.fromBitmap(bitmap));

                Marker marker = googleMap.addMarker(options);

                publicMarkerIds.put(marker.getId(), publicId);

                protectedFromGarbageCollectorTargets.remove(this);
            }

            @Override
            public void onBitmapFailed(Drawable errorDrawable) {
                System.out.println("Failed to load bitmap");
                protectedFromGarbageCollectorTargets.remove(this);
            }

            @Override
            public void onPrepareLoad(Drawable placeHolderDrawable) {
                System.out.println("Preparing to load bitmap");
            }
        };

        protectedFromGarbageCollectorTargets.add(target);

        Picasso.with(reactContext)
                .load(uri)
                .into(target);
    } catch (Exception ex) {
        System.out.println(ex.getMessage());
        markerWithDefaultIcon(googleMap,latLng, publicId);
    }
}