@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 } }); } }
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) { } }); } }
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) { } }); }
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) { } }; }
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); }
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) { } }); }
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); }
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); }
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); } }
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); } }); }
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()); }
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; }
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) { } }; }
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); }
@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) { } }); }
@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); }
/** * 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) { } }; }
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); }
@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) { } }); } }
/** * 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); }
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); } }); }
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); }
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) { // } }); }
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) { } }); }
/** * 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 */ } }); }
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) { } }; }
@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); } }
@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); } }
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); }
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) { } }); } }
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); }
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()); } }); }
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); }
@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(); }
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); }
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); } }); }
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(); } } }; }
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); } }
/** * 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); } }