Search in sources :

Example 11 with Callback

use of com.squareup.picasso.Callback in project SeriesGuide by UweTrottmann.

the class EpisodeDetailsFragment method loadImage.

private void loadImage(String imagePath, boolean hideDetails) {
    // immediately hide container if there is no image
    if (TextUtils.isEmpty(imagePath)) {
        mImageContainer.setVisibility(View.GONE);
        return;
    }
    if (hideDetails) {
        // show image placeholder
        mEpisodeImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        mEpisodeImage.setImageResource(R.drawable.ic_image_missing);
    } else {
        // try loading image
        mImageContainer.setVisibility(View.VISIBLE);
        ServiceUtils.loadWithPicasso(getActivity(), TvdbImageTools.fullSizeUrl(imagePath)).error(R.drawable.ic_image_missing).into(mEpisodeImage, new Callback() {

            @Override
            public void onSuccess() {
                mEpisodeImage.setScaleType(ImageView.ScaleType.CENTER_CROP);
            }

            @Override
            public void onError() {
                mEpisodeImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
            }
        });
    }
}
Also used : Callback(com.squareup.picasso.Callback)

Example 12 with Callback

use of com.squareup.picasso.Callback in project SeriesGuide by UweTrottmann.

the class FullscreenImageActivity method loadLargeImage.

private void loadLargeImage(boolean hasPreviewImage) {
    String imagePath = getIntent().getStringExtra(EXTRA_IMAGE);
    if (TextUtils.isEmpty(imagePath)) {
        // set to null so picasso shows error drawable
        imagePath = null;
    }
    RequestCreator requestCreator = ServiceUtils.loadWithPicasso(this, imagePath);
    if (hasPreviewImage) {
        // keep showing preview image if loading full image fails
        requestCreator.noPlaceholder().into(photoView);
    } else {
        // no preview image? show error image instead if loading full image fails
        requestCreator.error(R.drawable.ic_image_missing).into(photoView, new Callback() {

            @Override
            public void onSuccess() {
                photoView.setScaleType(ImageView.ScaleType.FIT_CENTER);
            }

            @Override
            public void onError() {
                photoView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
            }
        });
    }
}
Also used : Callback(com.squareup.picasso.Callback) RequestCreator(com.squareup.picasso.RequestCreator)

Example 13 with Callback

use of com.squareup.picasso.Callback in project SeriesGuide by UweTrottmann.

the class FullscreenImageActivity method setupViews.

private void setupViews() {
    photoView = (PhotoView) findViewById(R.id.fullscreen_content);
    // try to immediately show cached preview image
    String previewImagePath = getIntent().getStringExtra(EXTRA_PREVIEW_IMAGE);
    if (!TextUtils.isEmpty(previewImagePath)) {
        ServiceUtils.loadWithPicasso(this, previewImagePath).networkPolicy(NetworkPolicy.OFFLINE).into(photoView, new Callback() {

            @Override
            public void onSuccess() {
                loadLargeImage(true);
            }

            @Override
            public void onError() {
                loadLargeImage(false);
            }
        });
    } else {
        loadLargeImage(false);
    }
    // Set up an instance of SystemUiHider to control the system UI for
    // this activity.
    systemUiHider = SystemUiHider.getInstance(this, photoView, SystemUiHider.FLAG_FULLSCREEN);
    systemUiHider.setup();
    photoView.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {

        @Override
        public void onViewTap(View view, float x, float y) {
            systemUiHider.toggle();
        }
    });
}
Also used : Callback(com.squareup.picasso.Callback) PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher) ImageView(android.widget.ImageView) PhotoView(uk.co.senab.photoview.PhotoView) View(android.view.View)

Example 14 with Callback

use of com.squareup.picasso.Callback in project SeriesGuide by UweTrottmann.

the class OverviewFragment method loadEpisodeImage.

private void loadEpisodeImage(String imagePath) {
    if (TextUtils.isEmpty(imagePath)) {
        imageEpisode.setImageDrawable(null);
        return;
    }
    if (DisplaySettings.preventSpoilers(getContext())) {
        // show image placeholder
        imageEpisode.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        imageEpisode.setImageResource(R.drawable.ic_image_missing);
    } else {
        // try loading image
        ServiceUtils.loadWithPicasso(getActivity(), TvdbImageTools.fullSizeUrl(imagePath)).error(R.drawable.ic_image_missing).into(imageEpisode, new Callback() {

            @Override
            public void onSuccess() {
                imageEpisode.setScaleType(ImageView.ScaleType.CENTER_CROP);
            }

            @Override
            public void onError() {
                imageEpisode.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
            }
        });
    }
}
Also used : Callback(com.squareup.picasso.Callback)

Example 15 with Callback

use of com.squareup.picasso.Callback in project Hummingbird-for-Android by xiprox.

the class FavoriteAnimeAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View rootView = inflater.inflate(R.layout.item_favorite_grid, null);
    FavoriteAnime fav = mItems.get(position);
    final ImageView mCover = (ImageView) rootView.findViewById(R.id.item_favorite_cover);
    final TextView mTitle = (TextView) rootView.findViewById(R.id.item_favorite_title);
    ViewFlipper mFlipper = (ViewFlipper) rootView.findViewById(R.id.item_favorite_flipper);
    Picasso.with(context).load(fav.getCoverImage()).into(mCover, new Callback() {

        @Override
        public void onSuccess() {
            int darkMutedColor;
            Bitmap bitmap = ((BitmapDrawable) mCover.getDrawable()).getBitmap();
            darkMutedColor = Palette.generate(bitmap).getDarkMutedSwatch().getRgb();
            mTitle.setBackgroundDrawable(new ColorDrawable(darkMutedColor));
        }

        @Override
        public void onError() {
        }
    });
    mTitle.setText(fav.getTitle());
    if (mFlipper.getDisplayedChild() == 0)
        mFlipper.showNext();
    return rootView;
}
Also used : ViewFlipper(android.widget.ViewFlipper) Bitmap(android.graphics.Bitmap) Callback(com.squareup.picasso.Callback) ColorDrawable(android.graphics.drawable.ColorDrawable) FavoriteAnime(tr.bcxip.hummingbird.api.objects.FavoriteAnime) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

Callback (com.squareup.picasso.Callback)19 ImageView (android.widget.ImageView)7 View (android.view.View)6 Bitmap (android.graphics.Bitmap)4 TextView (android.widget.TextView)4 ColorDrawable (android.graphics.drawable.ColorDrawable)3 LayoutInflater (android.view.LayoutInflater)3 Bundle (android.os.Bundle)2 Palette (android.support.v7.graphics.Palette)2 MotionEvent (android.view.MotionEvent)2 ViewGroup (android.view.ViewGroup)2 Picasso (com.squareup.picasso.Picasso)2 RequestCreator (com.squareup.picasso.RequestCreator)2 PhotoViewAttacher (uk.co.senab.photoview.PhotoViewAttacher)2 AccountManagerCallback (android.accounts.AccountManagerCallback)1 TargetApi (android.annotation.TargetApi)1 Intent (android.content.Intent)1 Resources (android.content.res.Resources)1 BitmapFactory (android.graphics.BitmapFactory)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1