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