Search in sources :

Example 31 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 32 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 33 with Callback

use of com.squareup.picasso.Callback in project UltimateAndroid by cymcsg.

the class BaseSliderView method bindEventAndShow.

/**
     * When you want to implement your own slider view, please call this method in the end in `getView()` method
     * @param v the whole view
     * @param targetImageView where to place image
     */
protected void bindEventAndShow(final View v, ImageView targetImageView) {
    final BaseSliderView me = this;
    v.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mOnSliderClickListener != null) {
                mOnSliderClickListener.onSliderClick(me);
            }
        }
    });
    if (targetImageView == null)
        return;
    mLoadListener.onStart(me);
    Picasso p = Picasso.with(mContext);
    RequestCreator rq = null;
    if (mUrl != null) {
        rq = p.load(mUrl);
    } else if (mFile != null) {
        rq = p.load(mFile);
    } else if (mRes != 0) {
        rq = p.load(mRes);
    } else {
        return;
    }
    if (rq == null) {
        return;
    }
    if (getEmpty() != 0) {
        rq.placeholder(getEmpty());
    }
    if (getError() != 0) {
        rq.error(getError());
    }
    switch(mScaleType) {
        case Fit:
            rq.fit();
            break;
        case CenterCrop:
            rq.fit().centerCrop();
            break;
        case CenterInside:
            rq.fit().centerInside();
            break;
    }
    rq.into(targetImageView, new Callback() {

        @Override
        public void onSuccess() {
            if (v.findViewById(R.id.loading_bar) != null) {
                v.findViewById(R.id.loading_bar).setVisibility(View.INVISIBLE);
            }
        }

        @Override
        public void onError() {
            if (mLoadListener != null) {
                mLoadListener.onEnd(false, me);
            }
        }
    });
}
Also used : Callback(com.squareup.picasso.Callback) Picasso(com.squareup.picasso.Picasso) ImageView(android.widget.ImageView) View(android.view.View) RequestCreator(com.squareup.picasso.RequestCreator)

Example 34 with Callback

use of com.squareup.picasso.Callback in project boxing by Bilibili.

the class BoxingPicassoLoader method displayRaw.

@Override
public void displayRaw(@NonNull ImageView img, @NonNull String absPath, final IBoxingCallback callback) {
    String path = "file://" + absPath;
    Picasso.with(img.getContext()).load(path).transform(new BitmapTransform(1080, 720)).into(img, new Callback() {

        @Override
        public void onSuccess() {
            if (callback != null) {
                callback.onSuccess();
            }
        }

        @Override
        public void onError() {
            if (callback != null) {
                callback.onFail(null);
            }
        }
    });
}
Also used : Callback(com.squareup.picasso.Callback) IBoxingCallback(com.bilibili.boxing.loader.IBoxingCallback)

Example 35 with Callback

use of com.squareup.picasso.Callback in project Tusky by Vavassor.

the class ViewMediaFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.fragment_view_media, container, false);
    ButterKnife.bind(this, rootView);
    Bundle arguments = getArguments();
    String url = arguments.getString("url");
    attacher = new PhotoViewAttacher(photoView);
    // Clicking outside the photo closes the viewer.
    attacher.setOnOutsidePhotoTapListener(new OnOutsidePhotoTapListener() {

        @Override
        public void onOutsidePhotoTap(ImageView imageView) {
            dismiss();
        }
    });
    /* A vertical swipe motion also closes the viewer. This is especially useful when the photo
         * mostly fills the screen so clicking outside is difficult. */
    attacher.setOnSingleFlingListener(new OnSingleFlingListener() {

        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            if (Math.abs(velocityY) > Math.abs(velocityX)) {
                dismiss();
                return true;
            }
            return false;
        }
    });
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dismiss();
        }
    });
    Picasso.with(getContext()).load(url).into(photoView, new Callback() {

        @Override
        public void onSuccess() {
            rootView.findViewById(R.id.view_media_progress).setVisibility(View.GONE);
            toolbar.setOnMenuItemClickListener(ViewMediaFragment.this);
            toolbar.inflateMenu(R.menu.view_media_tooblar);
            attacher.update();
        }

        @Override
        public void onError() {
        }
    });
    return rootView;
}
Also used : Callback(com.squareup.picasso.Callback) Bundle(android.os.Bundle) OnSingleFlingListener(com.github.chrisbanes.photoview.OnSingleFlingListener) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) PhotoView(com.github.chrisbanes.photoview.PhotoView) PhotoViewAttacher(com.github.chrisbanes.photoview.PhotoViewAttacher) OnOutsidePhotoTapListener(com.github.chrisbanes.photoview.OnOutsidePhotoTapListener) MotionEvent(android.view.MotionEvent)

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