Java Code Examples for com.squareup.picasso.Picasso#LoadedFrom

The following examples show how to use com.squareup.picasso.Picasso#LoadedFrom . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TmpTarget.java    From ello-android with MIT License 6 votes vote down vote up
@Override
public void onBitmapLoaded (Bitmap bitmap, Picasso.LoadedFrom loadedFrom) {
    FileOutputStream outputStream;

    try {
        outputStream = context.openFileOutput(fileName, Context.MODE_PRIVATE);
        bitmap.compress(Bitmap.CompressFormat.JPEG, 90, outputStream);
        outputStream.flush();
        outputStream.close();
        File savedFile = context.getFileStreamPath(fileName);
        if(savedFile != null) {
            Uri webURI = Uri.fromFile(savedFile);
            Intent imageResized = new Intent(ElloPreferences.IMAGE_RESIZED);
            if(webURI != null) {
                imageResized.putExtra("RESIZED_IMAGE_PATH", webURI.getPath());
                context.sendBroadcast(imageResized);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 2
Source File: MD360PlayerActivity.java    From MD360Player4Android with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 3
Source File: ChannelActivity.java    From Pocket-Plays-for-Twitch with GNU General Public License v3.0 6 votes vote down vote up
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) {

		}
	};
}
 
Example 4
Source File: BitmapPlayerActivity.java    From MD360Player4Android with Apache License 2.0 5 votes vote down vote up
private void loadImage(Uri uri, final MD360BitmapTexture.Callback callback){
    mTarget = new Target() {
        @Override
        public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
            Log.d(TAG, "loaded image, size:" + bitmap.getWidth() + "," + bitmap.getHeight());

            // 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) {

        }
    };
    Log.d(TAG, "load image with max texture size:" + callback.getMaxTextureSize());
    Picasso.with(getApplicationContext())
            .load(uri)
            .resize(callback.getMaxTextureSize(),callback.getMaxTextureSize())
            .onlyScaleDown()
            .centerInside()
            .memoryPolicy(NO_CACHE, NO_STORE)
            .into(mTarget);
}
 
Example 5
Source File: DetailActivity.java    From RxAndroidBootstrap with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_detail);

    mActionBarSize = getActionBarSize();


    mFlexibleSpaceImageHeight = getResources().getDimensionPixelSize(R.dimen.flexible_space_image_height);

    image = (ImageView) findViewById(R.id.image);
    ViewCompat.setTransitionName(image, EXTRA_IMAGE);
    collapsingToolbar.setTitle(getIntent().getStringExtra(EXTRA_TITLE));
    bitmapImageViewTarget = new Target() {
        @Override
        public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
            Palette.generateAsync(bitmap, DetailActivity.this);
            image.setImageBitmap(bitmap);
        }

        @Override
        public void onBitmapFailed(Drawable errorDrawable) {
            //place your code here
        }

        @Override
        public void onPrepareLoad(Drawable placeHolderDrawable) {
            //place your code here
        }
    };
    Picasso.with(this).load(getIntent().getStringExtra(EXTRA_IMAGE)).into(bitmapImageViewTarget);


}
 
Example 6
Source File: PPTGoogleMapManager.java    From react-native-maps with MIT License 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 7
Source File: PicassoImageCardViewTarget.java    From TuentiTV with Apache License 2.0 4 votes vote down vote up
@Override public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom loadedFrom) {
  Drawable bitmapDrawable = new BitmapDrawable(imageCardView.getContext().getResources(), bitmap);
  imageCardView.setMainImage(bitmapDrawable);
}
 
Example 8
Source File: BaseSliderView.java    From LoyalNativeSlider with MIT License 4 votes vote down vote up
protected void workAroundGetImagePicasso() {

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

            }

            @Override
            public void onBitmapFailed(Drawable errorDrawable) {

            }

            @Override
            public void onPrepareLoad(Drawable placeHolderDrawable) {

            }
        };
    }
 
Example 9
Source File: CardPresenter.java    From BuildingForAndroidTV with MIT License 4 votes vote down vote up
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom loadedFrom) {
    Drawable bitmapDrawable = new BitmapDrawable(mContext.getResources(), bitmap);
    mImageCardView.setMainImage(bitmapDrawable);
}
 
Example 10
Source File: PicassoBackgroundManagerTarget.java    From AndroidDemoProjects with Apache License 2.0 4 votes vote down vote up
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom loadedFrom) {
    this.mBackgroundManager.setBitmap(bitmap);
}
 
Example 11
Source File: SimpleTarget.java    From android with Apache License 2.0 4 votes vote down vote up
@Override public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
}
 
Example 12
Source File: BackgroundHelper.java    From android-tv-leanback with Apache License 2.0 4 votes vote down vote up
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom loadedFrom) {
    this.mBackgroundManager.setBitmap(bitmap);
}
 
Example 13
Source File: PlayerFragment.java    From Sky31Radio with Apache License 2.0 4 votes vote down vote up
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
    Timber.d("onBitmapLoaded: %s (%s)", from.name(), bitmap.toString());
    playerRootView.setBackgroundDrawable(new BitmapDrawable(getResources(), bitmap));
    centerThumbnailIV.setImageBitmap(bitmap);
}
 
Example 14
Source File: PlaybackOverlayFragment.java    From android-tv-leanback with Apache License 2.0 4 votes vote down vote up
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom loadedFrom) {
    Drawable bitmapDrawable = new BitmapDrawable(sActivity.getResources(), bitmap);
    mPlaybackControlsRow.setImageDrawable(bitmapDrawable);
}
 
Example 15
Source File: InstructionTarget.java    From graphhopper-navigation-android with MIT License 4 votes vote down vote up
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
  Drawable drawable = createDrawable(bitmap);
  createAndSetImageSpan(drawable);
  sendInstructionLoadedCallback();
}
 
Example 16
Source File: GenericPicassoBitmapAdapter.java    From android-slideshow-widget with Apache License 2.0 4 votes vote down vote up
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom loadedFrom) {
    GenericPicassoBitmapAdapter.this.onBitmapLoaded(position, bitmap);
}
 
Example 17
Source File: PicassoBackgroundManagerTarget.java    From BuildingForAndroidTV with MIT License 4 votes vote down vote up
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom loadedFrom) {
    this.mBackgroundManager.setBitmap(bitmap);
}
 
Example 18
Source File: ContactView.java    From material with Apache License 2.0 4 votes vote down vote up
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
    setAvatarBitmap(bitmap);
}
 
Example 19
Source File: ListenerTarget.java    From Nox with Apache License 2.0 4 votes vote down vote up
@Override public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
  listener.onImageLoaded(bitmap);
}
 
Example 20
Source File: PaletteTransformation.java    From udacity-p1-p2-popular-movies with MIT License 2 votes vote down vote up
/**
 * Callback when an image has been successfully loaded.
 * Note: You must not recycle the bitmap.
 * @param palette The extracted {@linkplain Palette}
 */
protected abstract void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from, Palette palette);