Rearrange member vars and method params in Zoom.java

This commit is contained in:
misaochan 2018-05-29 18:36:37 +10:00
parent 0d282af0e6
commit 7dcf2376a6
2 changed files with 9 additions and 16 deletions

View file

@ -497,9 +497,8 @@ public class ShareActivity
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
//TODO: Move this to a new class. Save references to the findViewByIds and pass them to the new method /**
/* * Allows zooming in to the uploaded image. Called when zoom FAB is tapped
* function to provide pinch zoom
*/ */
private void zoomImageFromThumb(final View thumbView, Uri imageuri) { private void zoomImageFromThumb(final View thumbView, Uri imageuri) {
// If there's an animation in progress, cancel it immediately and proceed with this one. // If there's an animation in progress, cancel it immediately and proceed with this one.
@ -511,15 +510,14 @@ public class ShareActivity
mainFab.setVisibility(View.GONE); mainFab.setVisibility(View.GONE);
InputStream input = null; InputStream input = null;
try { try {
input = this.getContentResolver().openInputStream(imageuri); input = this.getContentResolver().openInputStream(imageuri);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} }
Zoom zoomObj = new Zoom(thumbView, flContainer, input, imageuri, this.getContentResolver()); Zoom zoomObj = new Zoom(thumbView, flContainer, this.getContentResolver());
Bitmap scaledImage = zoomObj.createScaledImage(); Bitmap scaledImage = zoomObj.createScaledImage(input, imageuri);
// Load the high-resolution "zoomed-in" image. // Load the high-resolution "zoomed-in" image.
expandedImageView.setImageBitmap(scaledImage); expandedImageView.setImageBitmap(scaledImage);
@ -569,8 +567,8 @@ public class ShareActivity
startScaleFinal = startScale; startScaleFinal = startScale;
} }
/* /**
* called when upper arrow floating button * Called when user taps the ^ FAB button, expands to show Zoom and Map
*/ */
@OnClick(R.id.main_fab) @OnClick(R.id.main_fab)
public void onMainFabClicked() { public void onMainFabClicked() {
@ -583,11 +581,10 @@ public class ShareActivity
@OnClick(R.id.media_upload_zoom_in) @OnClick(R.id.media_upload_zoom_in)
public void onZoomInFabClicked() { public void onZoomInFabClicked() {
//This try catch block was originally holding the entire click listener on the fab button, I did not wanted to risk exceptions
try { try {
zoomImageFromThumb(backgroundImageView, mediaUri); zoomImageFromThumb(backgroundImageView, mediaUri);
} catch (Exception e) { } catch (Exception e) {
Log.i("exception", e.toString()); Timber.e(e);
} }
} }

View file

@ -20,20 +20,16 @@ import timber.log.Timber;
public class Zoom { public class Zoom {
private View thumbView; private View thumbView;
private InputStream input;
private Uri imageUri;
private ContentResolver contentResolver; private ContentResolver contentResolver;
private FrameLayout flContainer; private FrameLayout flContainer;
Zoom(View thumbView, FrameLayout flContainer, InputStream input, Uri imageUri, ContentResolver contentResolver) { Zoom(View thumbView, FrameLayout flContainer, ContentResolver contentResolver) {
this.thumbView = thumbView; this.thumbView = thumbView;
this.input = input;
this.imageUri = imageUri;
this.contentResolver = contentResolver; this.contentResolver = contentResolver;
this.flContainer = flContainer; this.flContainer = flContainer;
} }
Bitmap createScaledImage() { Bitmap createScaledImage(InputStream input, Uri imageUri) {
Bitmap scaled = null; Bitmap scaled = null;
BitmapRegionDecoder decoder = null; BitmapRegionDecoder decoder = null;