Search in sources :

Example 6 with BaseBitmapDataSubscriber

use of com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber in project gl-react-native by ProjectSeptemberInc.

the class GLImage method reloadImage.

private void reloadImage() {
    if (pending != null && !pending.isFinished())
        pending.close();
    final Uri uri = src;
    ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(uri).setAutoRotateEnabled(// I don't really understand why need to disable this. but it actually fixes the image is properly rotated according to EXIF data
    false).build();
    pending = Fresco.getImagePipeline().fetchDecodedImage(imageRequest, null);
    pending.subscribe(new BaseBitmapDataSubscriber() {

        @Override
        protected void onNewResultImpl(@Nullable Bitmap bitmap) {
            onLoad(bitmap);
        }

        @Override
        protected void onFailureImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
            Log.e("GLImage", "Failed to load '" + uri.getPath() + "'", dataSource.getFailureCause());
        }
    }, decodeExecutor);
}
Also used : Bitmap(android.graphics.Bitmap) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) CloseableReference(com.facebook.common.references.CloseableReference) Uri(android.net.Uri) BaseBitmapDataSubscriber(com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber)

Example 7 with BaseBitmapDataSubscriber

use of com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber in project remusic by aa112901.

the class RadioDetailActivity method setAlbumart.

private void setAlbumart() {
    albumTitle.setText(albumName);
    albumArtSmall.setImageURI(Uri.parse(albumPath));
    try {
        ImageRequest imageRequest = ImageRequest.fromUri(albumPath);
        CacheKey cacheKey = DefaultCacheKeyFactory.getInstance().getEncodedCacheKey(imageRequest);
        BinaryResource resource = ImagePipelineFactory.getInstance().getMainDiskStorageCache().getResource(cacheKey);
        File file = ((FileBinaryResource) resource).getFile();
        if (file != null) {
            new setBlurredAlbumArt().execute(ImageUtils.getArtworkQuick(file, 300, 300));
            return;
        }
        imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(albumPath)).setProgressiveRenderingEnabled(true).build();
        ImagePipeline imagePipeline = Fresco.getImagePipeline();
        DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, RadioDetailActivity.this);
        dataSource.subscribe(new BaseBitmapDataSubscriber() {

            @Override
            public void onNewResultImpl(@Nullable Bitmap bitmap) {
                // No need to do any cleanup.
                if (bitmap != null) {
                    new setBlurredAlbumArt().execute(bitmap);
                }
                ;
            }

            @Override
            public void onFailureImpl(DataSource dataSource) {
            // No cleanup required here.
            }
        }, CallerThreadExecutor.getInstance());
    //drawable = Drawable.createFromStream( new URL(albumPath).openStream(),"src");
    } catch (Exception e) {
    }
}
Also used : CloseableReference(com.facebook.common.references.CloseableReference) FileBinaryResource(com.facebook.binaryresource.FileBinaryResource) BaseBitmapDataSubscriber(com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber) DataSource(com.facebook.datasource.DataSource) Bitmap(android.graphics.Bitmap) BinaryResource(com.facebook.binaryresource.BinaryResource) FileBinaryResource(com.facebook.binaryresource.FileBinaryResource) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) ImagePipeline(com.facebook.imagepipeline.core.ImagePipeline) File(java.io.File) CacheKey(com.facebook.cache.common.CacheKey)

Example 8 with BaseBitmapDataSubscriber

use of com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber in project ride-read-android by Ride-Read.

the class MapFragment method addMoment2Map.

private void addMoment2Map(final MapMoment moment) {
    final LatLng latLng = new LatLng(moment.getLatitude(), moment.getLongitude());
    ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(moment.getPictures().get(0) + QiNiuUtils.CROP_SMALL_100)).setProgressiveRenderingEnabled(true).build();
    ImagePipeline imagePipeline = Fresco.getImagePipeline();
    DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, Utils.getAppContext());
    dataSource.subscribe(new BaseBitmapDataSubscriber() {

        @Override
        public void onNewResultImpl(@Nullable Bitmap bitmap) {
            addMomentMarker(latLng, bitmap, moment);
        }

        @Override
        public void onFailureImpl(DataSource dataSource) {
        }
    }, CallerThreadExecutor.getInstance());
}
Also used : Bitmap(android.graphics.Bitmap) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) CloseableReference(com.facebook.common.references.CloseableReference) LatLng(com.amap.api.maps.model.LatLng) ImagePipeline(com.facebook.imagepipeline.core.ImagePipeline) BaseBitmapDataSubscriber(com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber) DataSource(com.facebook.datasource.DataSource)

Aggregations

Bitmap (android.graphics.Bitmap)8 BaseBitmapDataSubscriber (com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber)8 ImageRequest (com.facebook.imagepipeline.request.ImageRequest)8 CloseableReference (com.facebook.common.references.CloseableReference)7 ImagePipeline (com.facebook.imagepipeline.core.ImagePipeline)7 DataSource (com.facebook.datasource.DataSource)6 Uri (android.net.Uri)3 ComponentName (android.content.ComponentName)2 RemoteViews (android.widget.RemoteViews)2 LatLng (com.amap.api.maps.model.LatLng)2 SuppressLint (android.annotation.SuppressLint)1 PendingIntent (android.app.PendingIntent)1 Intent (android.content.Intent)1 RemoteException (android.os.RemoteException)1 Nullable (android.support.annotation.Nullable)1 NotificationCompat (android.support.v4.app.NotificationCompat)1 BinaryResource (com.facebook.binaryresource.BinaryResource)1 FileBinaryResource (com.facebook.binaryresource.FileBinaryResource)1 CacheKey (com.facebook.cache.common.CacheKey)1 CloseableImage (com.facebook.imagepipeline.image.CloseableImage)1