Search in sources :

Example 1 with SubsamplingScaleImageView

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

the class ConfigurationActivity method updateNotes.

private void updateNotes() {
    if (position > notes.size() - 1) {
        return;
    }
    getActionBar().setSubtitle(notes.get(position).subtitle);
    ((TextView) findViewById(id.note)).setText(notes.get(position).text);
    findViewById(id.next).setVisibility(position >= notes.size() - 1 ? View.INVISIBLE : View.VISIBLE);
    findViewById(id.previous).setVisibility(position <= 0 ? View.INVISIBLE : View.VISIBLE);
    SubsamplingScaleImageView imageView = (SubsamplingScaleImageView) findViewById(id.imageView);
    if (position == 0) {
        imageView.setMinimumDpi(50);
    } else {
        imageView.setMaxScale(2F);
    }
    if (position == 1) {
        imageView.setMinimumTileDpi(50);
    } else {
        imageView.setMinimumTileDpi(500);
    }
    if (position == 4) {
        imageView.setDoubleTapZoomStyle(SubsamplingScaleImageView.ZOOM_FOCUS_CENTER);
    } else if (position == 5) {
        imageView.setDoubleTapZoomStyle(SubsamplingScaleImageView.ZOOM_FOCUS_CENTER_IMMEDIATE);
    } else {
        imageView.setDoubleTapZoomStyle(SubsamplingScaleImageView.ZOOM_FOCUS_FIXED);
    }
    if (position == 6) {
        imageView.setDoubleTapZoomDpi(240);
    } else {
        imageView.setDoubleTapZoomScale(1F);
    }
    if (position == 7) {
        imageView.setPanLimit(SubsamplingScaleImageView.PAN_LIMIT_CENTER);
    } else if (position == 8) {
        imageView.setPanLimit(SubsamplingScaleImageView.PAN_LIMIT_OUTSIDE);
    } else {
        imageView.setPanLimit(SubsamplingScaleImageView.PAN_LIMIT_INSIDE);
    }
    if (position == 9) {
        imageView.setDebug(true);
    } else {
        imageView.setDebug(false);
    }
    if (position == 2) {
        imageView.setScaleAndCenter(0f, new PointF(1228, 816));
        imageView.setPanEnabled(false);
    } else {
        imageView.setPanEnabled(true);
    }
    if (position == 3) {
        imageView.setScaleAndCenter(1f, new PointF(1228, 816));
        imageView.setZoomEnabled(false);
    } else {
        imageView.setZoomEnabled(true);
    }
}
Also used : PointF(android.graphics.PointF) TextView(android.widget.TextView) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView)

Example 2 with SubsamplingScaleImageView

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

the class AdvancedEventHandlingActivity method initialiseImage.

private void initialiseImage() {
    final SubsamplingScaleImageView imageView = (SubsamplingScaleImageView) 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("squirrel.jpg"));
    imageView.setOnTouchListener(new OnTouchListener() {

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

Example 3 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(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(layout.imagedisplay_large_fragment, container, false);
    rootView.findViewById(id.next).setOnClickListener(new OnClickListener() {

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

Example 4 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(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(layout.imagedisplay_region_fragment, container, false);
    final SubsamplingScaleImageView imageView = (SubsamplingScaleImageView) rootView.findViewById(id.imageView);
    imageView.setOrientation(SubsamplingScaleImageView.ORIENTATION_90);
    imageView.setImage(ImageSource.asset("card.png").region(new Rect(0, 0, 3778, 2834)));
    rootView.findViewById(id.previous).setOnClickListener(new OnClickListener() {

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

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

Example 5 with SubsamplingScaleImageView

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

the class ImageDisplayRotateFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(layout.imagedisplay_rotate_fragment, container, false);
    final SubsamplingScaleImageView imageView = (SubsamplingScaleImageView) rootView.findViewById(id.imageView);
    imageView.setImage(ImageSource.asset("squirrel.jpg"));
    imageView.setOrientation(90);
    rootView.findViewById(id.previous).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View view) {
            ((ImageDisplayActivity) getActivity()).previous();
        }
    });
    rootView.findViewById(id.next).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View view) {
            ((ImageDisplayActivity) getActivity()).next();
        }
    });
    rootView.findViewById(id.rotate).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View view) {
            imageView.setOrientation((imageView.getOrientation() + 90) % 360);
        }
    });
    return rootView;
}
Also used : OnClickListener(android.view.View.OnClickListener) 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