Search in sources :

Example 21 with SubsamplingScaleImageView

use of com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView in project subsampling-scale-image-view by davemorrissey.

the class ViewPagerFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(layout.view_pager_page, container, false);
    if (savedInstanceState != null) {
        if (asset == null && savedInstanceState.containsKey(BUNDLE_ASSET)) {
            asset = savedInstanceState.getString(BUNDLE_ASSET);
        }
    }
    if (asset != null) {
        SubsamplingScaleImageView imageView = (SubsamplingScaleImageView) rootView.findViewById(id.imageView);
        imageView.setImage(ImageSource.asset(asset));
    }
    return rootView;
}
Also used : SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) View(android.view.View)

Example 22 with SubsamplingScaleImageView

use of com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView in project subsampling-scale-image-view by davemorrissey.

the class AdvancedEventHandlingActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final SubsamplingScaleImageView imageView = findViewById(id.imageView);
    final GestureDetector gestureDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() {

        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            if (imageView.isReady()) {
                PointF sCoord = imageView.viewToSourceCoord(e.getX(), e.getY());
                Toast.makeText(getApplicationContext(), "Single tap: " + ((int) sCoord.x) + ", " + ((int) sCoord.y), Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(getApplicationContext(), "Single tap: Image not ready", Toast.LENGTH_SHORT).show();
            }
            return true;
        }

        @Override
        public void onLongPress(MotionEvent e) {
            if (imageView.isReady()) {
                PointF sCoord = imageView.viewToSourceCoord(e.getX(), e.getY());
                Toast.makeText(getApplicationContext(), "Long press: " + ((int) sCoord.x) + ", " + ((int) sCoord.y), Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(getApplicationContext(), "Long press: Image not ready", Toast.LENGTH_SHORT).show();
            }
        }

        @Override
        public boolean onDoubleTap(MotionEvent e) {
            if (imageView.isReady()) {
                PointF sCoord = imageView.viewToSourceCoord(e.getX(), e.getY());
                Toast.makeText(getApplicationContext(), "Double tap: " + ((int) sCoord.x) + ", " + ((int) sCoord.y), Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(getApplicationContext(), "Double tap: Image not ready", Toast.LENGTH_SHORT).show();
            }
            return true;
        }
    });
    imageView.setImage(ImageSource.asset("sanmartino.jpg"));
    imageView.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            return gestureDetector.onTouchEvent(motionEvent);
        }
    });
}
Also used : PointF(android.graphics.PointF) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) GestureDetector(android.view.GestureDetector) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) View(android.view.View) MotionEvent(android.view.MotionEvent)

Example 23 with SubsamplingScaleImageView

use of com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView in project subsampling-scale-image-view by davemorrissey.

the class EventHandlingActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SubsamplingScaleImageView imageView = findViewById(id.imageView);
    imageView.setImage(ImageSource.asset("sanmartino.jpg"));
    imageView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(v.getContext(), "Clicked", Toast.LENGTH_SHORT).show();
        }
    });
    imageView.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            Toast.makeText(v.getContext(), "Long clicked", Toast.LENGTH_SHORT).show();
            return true;
        }
    });
}
Also used : SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) View(android.view.View)

Example 24 with SubsamplingScaleImageView

use of com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView in project subsampling-scale-image-view by davemorrissey.

the class ImageDisplayRegionFragment method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(layout.imagedisplay_region_fragment, container, false);
    final SubsamplingScaleImageView imageView = rootView.findViewById(id.imageView);
    imageView.setBitmapDecoderFactory(new CompatDecoderFactory<ImageDecoder>(SkiaImageDecoder.class, Bitmap.Config.ARGB_8888));
    imageView.setRegionDecoderFactory(new CompatDecoderFactory<ImageRegionDecoder>(SkiaImageRegionDecoder.class, Bitmap.Config.ARGB_8888));
    imageView.setOrientation(SubsamplingScaleImageView.ORIENTATION_90);
    imageView.setImage(ImageSource.asset("card.png").region(new Rect(5200, 651, 8200, 3250)));
    final ImageDisplayActivity activity = (ImageDisplayActivity) getActivity();
    if (activity != null) {
        rootView.findViewById(id.previous).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                activity.previous();
            }
        });
    }
    rootView.findViewById(id.rotate).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            imageView.setOrientation((imageView.getOrientation() + 90) % 360);
        }
    });
    return rootView;
}
Also used : Rect(android.graphics.Rect) ImageRegionDecoder(com.davemorrissey.labs.subscaleview.decoder.ImageRegionDecoder) SkiaImageRegionDecoder(com.davemorrissey.labs.subscaleview.decoder.SkiaImageRegionDecoder) SkiaImageDecoder(com.davemorrissey.labs.subscaleview.decoder.SkiaImageDecoder) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) ImageDecoder(com.davemorrissey.labs.subscaleview.decoder.ImageDecoder) SkiaImageDecoder(com.davemorrissey.labs.subscaleview.decoder.SkiaImageDecoder) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) View(android.view.View) SkiaImageRegionDecoder(com.davemorrissey.labs.subscaleview.decoder.SkiaImageRegionDecoder)

Example 25 with SubsamplingScaleImageView

use of com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView in project subsampling-scale-image-view by davemorrissey.

the class ImageDisplayLargeFragment method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(layout.imagedisplay_large_fragment, container, false);
    final ImageDisplayActivity activity = (ImageDisplayActivity) getActivity();
    if (activity != null) {
        rootView.findViewById(id.next).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                activity.next();
            }
        });
    }
    SubsamplingScaleImageView imageView = rootView.findViewById(id.imageView);
    imageView.setImage(ImageSource.asset("card.png"));
    return rootView;
}
Also used : SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) View(android.view.View)

Aggregations

SubsamplingScaleImageView (com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView)30 View (android.view.View)18 PointF (android.graphics.PointF)5 Rect (android.graphics.Rect)4 OnClickListener (android.view.View.OnClickListener)4 TextView (android.widget.TextView)4 GestureDetector (android.view.GestureDetector)3 MotionEvent (android.view.MotionEvent)3 ImageView (android.widget.ImageView)2 ImageViewState (com.davemorrissey.labs.subscaleview.ImageViewState)2 SuppressLint (android.annotation.SuppressLint)1 WallpaperManager (android.app.WallpaperManager)1 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 RequiresApi (android.support.annotation.RequiresApi)1 ActionBar (android.support.v7.app.ActionBar)1 RecyclerView (android.support.v7.widget.RecyclerView)1 Toolbar (android.support.v7.widget.Toolbar)1 OnTouchListener (android.view.View.OnTouchListener)1 ViewGroup (android.view.ViewGroup)1