Search in sources :

Example 26 with Callback

use of com.squareup.picasso.Callback in project wh-app-android by WhiteHouse.

the class GalleryPhotoFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mPhotoDescription.setText(Html.fromHtml(prepDescription(mFeedItem.description())));
    Picasso.with(view.getContext()).load(mFeedItem.getBestThumbnailUrl(1500)).into(mPhotoView, new Callback() {

        @Override
        public void onSuccess() {
            mPhotoViewAttacher = new PhotoViewAttacher(mPhotoView) {

                @Override
                public boolean onTouch(View v, MotionEvent ev) {
                    switch(ev.getAction()) {
                        case MotionEvent.ACTION_DOWN:
                            mTouching = true;
                            decideDescriptionVisibility(getScale());
                            break;
                        case MotionEvent.ACTION_CANCEL:
                        case MotionEvent.ACTION_UP:
                            mTouching = false;
                            decideDescriptionVisibility(getScale());
                            break;
                    }
                    return super.onTouch(v, ev);
                }
            };
            mPhotoViewAttacher.setOnMatrixChangeListener(rectF -> {
                decideDescriptionVisibility(mPhotoViewAttacher.getScale());
                if (mPhotoViewAttacher.getScale() > 1.1f) {
                    mPhotoViewAttacher.setAllowParentInterceptOnEdge(false);
                } else {
                    mPhotoViewAttacher.setAllowParentInterceptOnEdge(true);
                }
            });
        }

        @Override
        public void onError() {
        }
    });
}
Also used : Bundle(android.os.Bundle) ButterKnife(butterknife.ButterKnife) LayoutInflater(android.view.LayoutInflater) ImageView(android.widget.ImageView) PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher) InjectView(butterknife.InjectView) GsonUtils(gov.whitehouse.util.GsonUtils) ViewGroup(android.view.ViewGroup) FeedItem(gov.whitehouse.data.model.FeedItem) Picasso(com.squareup.picasso.Picasso) TextView(android.widget.TextView) MotionEvent(android.view.MotionEvent) Html(android.text.Html) Menu(android.view.Menu) View(android.view.View) Callback(com.squareup.picasso.Callback) Nullable(android.support.annotation.Nullable) BaseFragment(gov.whitehouse.app.BaseFragment) R(gov.whitehouse.R) Callback(com.squareup.picasso.Callback) PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher) ImageView(android.widget.ImageView) InjectView(butterknife.InjectView) TextView(android.widget.TextView) View(android.view.View) MotionEvent(android.view.MotionEvent)

Example 27 with Callback

use of com.squareup.picasso.Callback in project kickmaterial by byoutline.

the class ProjectDetailsActivity method loadProjectPhoto.

private void loadProjectPhoto() {
    Bitmap bitmap = picassoCache.getPlaceholder(project.getBigPhotoUrl());
    boolean bigPhotoMustBeFetched = bitmap == null;
    if (bigPhotoMustBeFetched) {
        bitmap = picassoCache.getPlaceholder(project.getPhotoUrl());
        boolean placeholderAlreadyFetched = bitmap != null;
        if (placeholderAlreadyFetched) {
            binding.projectPhotoIv.setImageBitmap(bitmap);
        }
    }
    // Make sure that transition starts soon even if image is not ready.
    binding.projectPhotoIv.postDelayed(this::supportStartPostponedEnterTransition, MAX_TRANSITION_DELAY);
    Picasso.with(this).load(project.getBigPhotoUrl()).resize(imageWidth, imageHeight).onlyScaleDown().centerCrop().transform(PaletteAndAplaTransformation.instance()).into(binding.projectPhotoIv, new Callback() {

        @Override
        public void onSuccess() {
            // Ew!
            Bitmap bitmap = ((BitmapDrawable) binding.projectPhotoIv.getDrawable()).getBitmap();
            Palette palette = PaletteAndAplaTransformation.getPalette(bitmap);
            binding.detailsContainer.setBackgroundColor(palette.getDarkVibrantColor(Color.BLACK));
            supportStartPostponedEnterTransition();
        }

        @Override
        public void onError() {
            supportStartPostponedEnterTransition();
        }
    });
}
Also used : Palette(android.support.v7.graphics.Palette) Bitmap(android.graphics.Bitmap) SharedElementCallback(android.support.v4.app.SharedElementCallback) Callback(com.squareup.picasso.Callback)

Example 28 with Callback

use of com.squareup.picasso.Callback in project cw-omnibus by commonsguy.

the class AbstractDragDropDemoActivity method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.main);
    originalColors.put(R.id.outer_container, getResources().getColor(R.color.outer_normal));
    originalColors.put(R.id.inner_container, getResources().getColor(R.color.inner_normal));
    originalColors.put(R.id.thumbnail_large, getResources().getColor(R.color.image_normal));
    dropTargetReadyColor = getResources().getColor(R.color.drop_target_ready);
    ViewGroup dropFrame = (ViewGroup) findViewById(R.id.drop_frame);
    getLayoutInflater().inflate(getDropFrameContentId(), dropFrame, true);
    iv = (ImageView) findViewById(R.id.asset);
    Picasso.with(this).load("file:///android_asset/FreedomTower-Morning.jpg").fit().centerCrop().into(iv, new Callback() {

        @Override
        public void onSuccess() {
            iv.setOnLongClickListener(AbstractDragDropDemoActivity.this);
        }

        @Override
        public void onError() {
        // TODO
        }
    });
    if (icicle != null) {
        imageUri = icicle.getParcelable(STATE_IMAGE_URI);
        if (imageUri != null) {
            showThumbnail();
        }
    }
}
Also used : Callback(com.squareup.picasso.Callback) ViewGroup(android.view.ViewGroup)

Example 29 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 30 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)

Aggregations

Callback (com.squareup.picasso.Callback)54 ImageView (android.widget.ImageView)21 View (android.view.View)18 TextView (android.widget.TextView)14 RequestCreator (com.squareup.picasso.RequestCreator)12 LayoutInflater (android.view.LayoutInflater)7 Context (android.content.Context)6 DisplayMetrics (android.util.DisplayMetrics)6 Bitmap (android.graphics.Bitmap)5 Intent (android.content.Intent)4 ViewGroup (android.view.ViewGroup)4 AppCompatImageView (androidx.appcompat.widget.AppCompatImageView)4 JSONArray (org.json.JSONArray)4 JSONException (org.json.JSONException)4 JSONObject (org.json.JSONObject)4 Resources (android.content.res.Resources)3 ColorDrawable (android.graphics.drawable.ColorDrawable)3 Bundle (android.os.Bundle)3 MotionEvent (android.view.MotionEvent)3 RecyclerView (androidx.recyclerview.widget.RecyclerView)3