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);
}
}
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);
}
});
}
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;
}
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;
}
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;
}
Aggregations