From 84b54939282e48bd7f2b87b4c2732583b554bacc Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 18 May 2016 17:22:07 +0200 Subject: [PATCH 1/3] handle some code --- build.gradle | 2 +- library/src/main/AndroidManifest.xml | 2 +- .../sothree/slidinguppanel/SlidingUpPanelLayout.java | 11 ++++++----- .../com/sothree/slidinguppanel/ViewDragHelper.java | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index 9d66dfce..85b0dd79 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:1.5.0' + classpath 'com.android.tools.build:gradle:2.1.0' } } diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml index 2d9f13bc..7a0fbbe3 100644 --- a/library/src/main/AndroidManifest.xml +++ b/library/src/main/AndroidManifest.xml @@ -5,7 +5,7 @@ android:versionName="3.3.0"> + android:minSdkVersion="11" /> diff --git a/library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java b/library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java index fa306f6d..7659ad9b 100644 --- a/library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java +++ b/library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java @@ -511,6 +511,7 @@ public void removePanelSlideListener(PanelSlideListener listener) { * Provides an on click for the portion of the main view that is dimmed. The listener is not * triggered if the panel is in a collapsed or a hidden position. If the on click listener is * not provided, the clicks on the dimmed area are passed through to the main layout. + * * @param listener */ public void setFadeOnClickListener(View.OnClickListener listener) { @@ -572,6 +573,7 @@ public void setScrollableView(View scrollableView) { /** * Sets the current scrollable view helper. See ScrollableViewHelper description for details. + * * @param helper */ public void setScrollableViewHelper(ScrollableViewHelper helper) { @@ -1329,7 +1331,7 @@ public boolean tryCaptureView(View child, int pointerId) { @Override public void onViewDragStateChanged(int state) { - if (mDragHelper.getViewDragState() == ViewDragHelper.STATE_IDLE) { + if (mDragHelper != null && mDragHelper.getViewDragState() == ViewDragHelper.STATE_IDLE) { mSlideOffset = computeSlideOffset(mSlideableView.getTop()); applyParallaxForCurrentSlideOffset(); @@ -1388,8 +1390,8 @@ public void onViewReleased(View releasedChild, float xvel, float yvel) { // settle at the bottom target = computePanelTopPosition(0.0f); } - - mDragHelper.settleCapturedViewAt(releasedChild.getLeft(), target); + if (mDragHelper != null) + mDragHelper.settleCapturedViewAt(releasedChild.getLeft(), target); invalidate(); } @@ -1448,9 +1450,8 @@ public LayoutParams(Context c, AttributeSet attrs) { final TypedArray ta = c.obtainStyledAttributes(attrs, ATTRS); if (ta != null) { this.weight = ta.getFloat(0, 0); + ta.recycle(); } - - ta.recycle(); } } diff --git a/library/src/main/java/com/sothree/slidinguppanel/ViewDragHelper.java b/library/src/main/java/com/sothree/slidinguppanel/ViewDragHelper.java index 58a4e82a..17edb16c 100644 --- a/library/src/main/java/com/sothree/slidinguppanel/ViewDragHelper.java +++ b/library/src/main/java/com/sothree/slidinguppanel/ViewDragHelper.java @@ -64,7 +64,7 @@ public class ViewDragHelper { /** * Edge flag indicating that the left edge should be affected. */ - public static final int EDGE_LEFT = 1 << 0; + public static final int EDGE_LEFT = 1; /** * Edge flag indicating that the right edge should be affected. @@ -89,7 +89,7 @@ public class ViewDragHelper { /** * Indicates that a check should occur along the horizontal axis */ - public static final int DIRECTION_HORIZONTAL = 1 << 0; + public static final int DIRECTION_HORIZONTAL = 1; /** * Indicates that a check should occur along the vertical axis From 47590b225a9abc51bb570a072a5a77c42cded433 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 18 May 2016 18:59:02 +0200 Subject: [PATCH 2/3] handle some code --- .../com/sothree/slidinguppanel/SlidingUpPanelLayout.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java b/library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java index 7659ad9b..3ebd870d 100644 --- a/library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java +++ b/library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java @@ -283,9 +283,10 @@ public SlidingUpPanelLayout(Context context, AttributeSet attrs, int defStyle) { if (defAttrs != null) { int gravity = defAttrs.getInt(0, Gravity.NO_GRAVITY); setGravity(gravity); + defAttrs.recycle(); } - defAttrs.recycle(); + TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingUpPanelLayout); @@ -311,9 +312,10 @@ public SlidingUpPanelLayout(Context context, AttributeSet attrs, int defStyle) { if (interpolatorResId != -1) { scrollerInterpolator = AnimationUtils.loadInterpolator(context, interpolatorResId); } + ta.recycle(); } - ta.recycle(); + } final float density = context.getResources().getDisplayMetrics().density; @@ -418,7 +420,6 @@ public void setPanelHeight(int val) { if (getPanelState() == PanelState.COLLAPSED) { smoothToBottom(); invalidate(); - return; } } From 2940d4bf6cbc811124cf72521a6af0e868c56d29 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 18 May 2016 19:25:08 +0200 Subject: [PATCH 3/3] public is redundant --- .../com/sothree/slidinguppanel/SlidingUpPanelLayout.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java b/library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java index 3ebd870d..3d674b4a 100644 --- a/library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java +++ b/library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java @@ -11,7 +11,6 @@ import android.os.Build; import android.os.Parcel; import android.os.Parcelable; -import android.support.annotation.NonNull; import android.support.v4.view.MotionEventCompat; import android.support.v4.view.ViewCompat; import android.util.AttributeSet; @@ -235,14 +234,14 @@ public interface PanelSlideListener { * @param panel The child view that was moved * @param slideOffset The new offset of this sliding pane within its range, from 0-1 */ - public void onPanelSlide(View panel, float slideOffset); + void onPanelSlide(View panel, float slideOffset); /** * Called when a sliding panel state changes * * @param panel The child view that was slid to an collapsed position */ - public void onPanelStateChanged(View panel, PanelState previousState, PanelState newState); + void onPanelStateChanged(View panel, PanelState previousState, PanelState newState); } /**