@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_sale_skidkaonline, container, false); setHasOptionsMenu(true); setRetainInstance(true); sale = getArguments().getParcelable(CURRENT_SALE_TAG); progressBar = (CircularProgressView) rootView.findViewById(R.id.fragment_sale_progressbar); imageView = (SubsamplingScaleImageView) rootView.findViewById(R.id.fragment_sale_imageview); imageView.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CUSTOM); imageView.setMaxScale(getResources().getDimension(R.dimen.image_maximum_scale)); File smallFile = ImageLoader.getInstance().getDiskCache().get(sale.getSmallImageUrl()); if (smallFile != null) { imageView.setImage(ImageSource.uri(smallFile.getAbsolutePath())); loadBigImage(); } else { ImageLoader.getInstance() .loadImage( sale.getSmallImageUrl(), null, UIL.getScaleImageOptions(), new ImageLoadingListener() { @Override public void onLoadingStarted(String s, View view) { progressBar.setVisibility(View.VISIBLE); } @Override public void onLoadingFailed(String s, View view, FailReason failReason) { progressBar.setVisibility(View.GONE); } @Override public void onLoadingComplete(String s, View view, Bitmap bitmap) { File smallFile = ImageLoader.getInstance().getDiskCache().get(sale.getSmallImageUrl()); if (smallFile != null) { imageView.setImage(ImageSource.uri(smallFile.getAbsolutePath())); } bitmap.recycle(); loadBigImage(); } @Override public void onLoadingCancelled(String s, View view) {} }, new ImageLoadingProgressListener() { @Override public void onProgressUpdate(String s, View view, int progress, int size) { progressBar.setProgress(progress * 500 / size); } }); } return rootView; }
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); } }); }
private void initialiseImage() { SubsamplingScaleImageView imageView = (SubsamplingScaleImageView) findViewById(id.imageView); imageView.setImage(ImageSource.asset("squirrel.jpg")); }