Skip to content

Commit 1835999

Browse files
committed
Reformat some code
1 parent 868cea2 commit 1835999

File tree

3 files changed

+24
-18
lines changed

3 files changed

+24
-18
lines changed

gallery-viewer/src/main/java/com/liuzhenlin/galleryviewer/GalleryViewPager.java

+13-12
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,18 @@ void startImageOverScrollAndSpringBack(
8888
if (isLayoutValid(image)) {
8989
image.startImageOverScrollAndSpringBack(dx, dy, duration);
9090
} else {
91-
image.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
92-
@Override
93-
public void onGlobalLayout() {
94-
if (isLayoutValid(image)) {
95-
if (mImageOverScrollEnabled) {
96-
image.startImageOverScrollAndSpringBack(dx, dy, duration);
91+
image.getViewTreeObserver().addOnGlobalLayoutListener(
92+
new ViewTreeObserver.OnGlobalLayoutListener() {
93+
@Override
94+
public void onGlobalLayout() {
95+
if (isLayoutValid(image)) {
96+
if (mImageOverScrollEnabled) {
97+
image.startImageOverScrollAndSpringBack(dx, dy, duration);
98+
}
99+
image.getViewTreeObserver().removeGlobalOnLayoutListener(this);
100+
}
97101
}
98-
image.getViewTreeObserver().removeGlobalOnLayoutListener(this);
99-
}
100-
}
101-
});
102+
});
102103
}
103104
}
104105

@@ -122,8 +123,8 @@ public GalleryViewPager(@NonNull Context context) {
122123
public GalleryViewPager(@NonNull Context context, @Nullable AttributeSet attrs) {
123124
super(context, attrs);
124125
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.GalleryViewPager, 0, 0);
125-
setImageOverScrollEnabled(ta.getBoolean(R.styleable.
126-
GalleryViewPager_imageOverScrollEnabled, true));
126+
setImageOverScrollEnabled(
127+
ta.getBoolean(R.styleable.GalleryViewPager_imageOverScrollEnabled, true));
127128
ta.recycle();
128129

129130
final float dp = getResources().getDisplayMetrics().density;

gallery-viewer/src/main/java/com/liuzhenlin/galleryviewer/GestureImageView.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ public GestureImageView(Context context, @Nullable AttributeSet attrs) {
161161

162162
public GestureImageView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
163163
super(context, attrs, defStyleAttr);
164-
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.GestureImageView, defStyleAttr, 0);
164+
TypedArray ta = context.obtainStyledAttributes(
165+
attrs, R.styleable.GestureImageView, defStyleAttr, 0);
165166
setImageGesturesEnabled(ta.getBoolean(R.styleable
166167
.GestureImageView_imageGesturesEnabled, true));
167168
setMoveUnmagnifiedImageViaSingleFingerAllowed(ta.getBoolean(R.styleable
@@ -298,8 +299,9 @@ private void initializeImage() {
298299
final boolean piiic = mFitWidthImageScale >= mFitCenterImageScale * PIIIC_THRESHOLD;
299300
if (piiic) {
300301
mDoubleTapMagnifiedImageScale = mFitWidthImageScale;
301-
// Make sure the mImageMaxScale is not less than 3 times that of mDoubleTapMagnifiedImageScale,
302-
// preferring to have the maximum scale for the image 5 times larger than mFitCenterImageScale.
302+
// Make sure the mImageMaxScale is not less than 3 times that of
303+
// mDoubleTapMagnifiedImageScale, preferring to have the maximum scale for the image
304+
// 5 times larger than mFitCenterImageScale.
303305
if (mImageMaxScale < mDoubleTapMagnifiedImageScale * 3f) {
304306
mImageMaxScale = mDoubleTapMagnifiedImageScale * 3f;
305307
}
@@ -311,7 +313,8 @@ private void initializeImage() {
311313
// so just reset the current matrix to its initial state.
312314
mImageMatrix.reset();
313315
if (piiic) {
314-
// Scales the image to fit exactly the width of the view with the top edge showed to the user
316+
// Scales the image to fit exactly the width of the view with the top edge showed
317+
// to the user
315318
mImageMatrix.postScale(mFitWidthImageScale, mFitWidthImageScale, 0, 0);
316319
} else {
317320
// Translates the image to the center of the current view

gallery-viewer/src/main/java/com/liuzhenlin/galleryviewer/OverScroller.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,8 @@ public void startScroll(float startX, float startY, float dx, float dy, int dura
391391
* @return true if a springback was initiated, false if startX and startY were
392392
* already within the valid range.
393393
*/
394-
public boolean springBack(float startX, float startY, float minX, float maxX, float minY, float maxY) {
394+
public boolean springBack(
395+
float startX, float startY, float minX, float maxX, float minY, float maxY) {
395396
mMode = FLING_MODE;
396397

397398
// Make sure both methods are called.
@@ -731,7 +732,8 @@ boolean springback(float start, float min, float max) {
731732
return !mFinished;
732733
}
733734

734-
private void startSpringback(float start, float end, @SuppressWarnings("unused") float velocity) {
735+
private void startSpringback(
736+
float start, float end, @SuppressWarnings("unused") float velocity) {
735737
// mStartTime has been set
736738
mFinished = false;
737739
mState = CUBIC;

0 commit comments

Comments
 (0)