2222import android .animation .AnimatorSet ;
2323import android .animation .ObjectAnimator ;
2424import android .content .Context ;
25- import android .util .Log ;
25+ import android .util .Slog ;
2626import android .view .Gravity ;
2727import android .view .MotionEvent ;
2828import android .view .ScaleGestureDetector ;
2929import android .view .View ;
3030import android .view .ViewGroup ;
3131import android .view .View .OnClickListener ;
32- import android .widget .ScrollView ;
33- import android .widget .FrameLayout ;
3432
3533public class ExpandHelper implements Gefingerpoken , OnClickListener {
3634 public interface Callback {
@@ -41,7 +39,7 @@ public interface Callback {
4139 }
4240
4341 private static final String TAG = "ExpandHelper" ;
44- protected static final boolean DEBUG = true ;
42+ protected static final boolean DEBUG = false ;
4543 private static final long EXPAND_DURATION = 250 ;
4644 private static final long GLOW_DURATION = 150 ;
4745
@@ -95,7 +93,7 @@ public void setView(View v) {
9593 mView = v ;
9694 }
9795 public void setHeight (float h ) {
98- if (DEBUG ) Log .v (TAG , "SetHeight: setting to " + h );
96+ if (DEBUG ) Slog .v (TAG , "SetHeight: setting to " + h );
9997 ViewGroup .LayoutParams lp = mView .getLayoutParams ();
10098 lp .height = (int )h ;
10199 mView .setLayoutParams (lp );
@@ -110,7 +108,7 @@ public float getHeight() {
110108 }
111109 public int getNaturalHeight (int maximum ) {
112110 ViewGroup .LayoutParams lp = mView .getLayoutParams ();
113- if (DEBUG ) Log .v (TAG , "Inspecting a child of type: " + mView .getClass ().getName ());
111+ if (DEBUG ) Slog .v (TAG , "Inspecting a child of type: " + mView .getClass ().getName ());
114112 int oldHeight = lp .height ;
115113 lp .height = ViewGroup .LayoutParams .WRAP_CONTENT ;
116114 mView .setLayoutParams (lp );
@@ -176,7 +174,7 @@ public void onAnimationEnd(Animator animation) {
176174 new ScaleGestureDetector .SimpleOnScaleGestureListener () {
177175 @ Override
178176 public boolean onScaleBegin (ScaleGestureDetector detector ) {
179- if (DEBUG ) Log .v (TAG , "onscalebegin()" );
177+ if (DEBUG ) Slog .v (TAG , "onscalebegin()" );
180178 float x = detector .getFocusX ();
181179 float y = detector .getFocusY ();
182180
@@ -194,15 +192,15 @@ public boolean onScaleBegin(ScaleGestureDetector detector) {
194192 // your fingers have to be somewhat close to the bounds of the view in question
195193 mInitialTouchFocusY = detector .getFocusY ();
196194 mInitialTouchSpan = Math .abs (detector .getCurrentSpan ());
197- if (DEBUG ) Log .d (TAG , "got mInitialTouchSpan: (" + mInitialTouchSpan + ")" );
195+ if (DEBUG ) Slog .d (TAG , "got mInitialTouchSpan: (" + mInitialTouchSpan + ")" );
198196
199197 mStretching = initScale (v );
200198 return mStretching ;
201199 }
202200
203201 @ Override
204202 public boolean onScale (ScaleGestureDetector detector ) {
205- if (DEBUG ) Log .v (TAG , "onscale() on " + mCurrView );
203+ if (DEBUG ) Slog .v (TAG , "onscale() on " + mCurrView );
206204
207205 // are we scaling or dragging?
208206 float span = Math .abs (detector .getCurrentSpan ()) - mInitialTouchSpan ;
@@ -212,28 +210,28 @@ public boolean onScale(ScaleGestureDetector detector) {
212210 drag *= mGravity == Gravity .BOTTOM ? -1f : 1f ;
213211 float pull = Math .abs (drag ) + Math .abs (span ) + 1f ;
214212 float hand = drag * Math .abs (drag ) / pull + span * Math .abs (span ) / pull ;
215- if (DEBUG ) Log .d (TAG , "current span handle is: " + hand );
213+ if (DEBUG ) Slog .d (TAG , "current span handle is: " + hand );
216214 hand = hand + mOldHeight ;
217215 float target = hand ;
218- if (DEBUG ) Log .d (TAG , "target is: " + target );
216+ if (DEBUG ) Slog .d (TAG , "target is: " + target );
219217 hand = hand < mSmallSize ? mSmallSize : (hand > mLargeSize ? mLargeSize : hand );
220218 hand = hand > mNaturalHeight ? mNaturalHeight : hand ;
221- if (DEBUG ) Log .d (TAG , "scale continues: hand =" + hand );
219+ if (DEBUG ) Slog .d (TAG , "scale continues: hand =" + hand );
222220 mScaler .setHeight (hand );
223221
224222 // glow if overscale
225223 float stretch = (float ) Math .abs ((target - hand ) / mMaximumStretch );
226224 float strength = 1f / (1f + (float ) Math .pow (Math .E , -1 * ((8f * stretch ) - 5f )));
227- if (DEBUG ) Log .d (TAG , "stretch: " + stretch + " strength: " + strength );
225+ if (DEBUG ) Slog .d (TAG , "stretch: " + stretch + " strength: " + strength );
228226 setGlow (GLOW_BASE + strength * (1f - GLOW_BASE ));
229227 return true ;
230228 }
231229
232230 @ Override
233231 public void onScaleEnd (ScaleGestureDetector detector ) {
234- if (DEBUG ) Log .v (TAG , "onscaleend()" );
232+ if (DEBUG ) Slog .v (TAG , "onscaleend()" );
235233 // I guess we're alone now
236- if (DEBUG ) Log .d (TAG , "scale end" );
234+ if (DEBUG ) Slog .d (TAG , "scale end" );
237235 finishScale (false );
238236 }
239237 });
@@ -279,23 +277,23 @@ private void handleGlowVisibility() {
279277 }
280278
281279 public boolean onInterceptTouchEvent (MotionEvent ev ) {
282- if (DEBUG ) Log .d (TAG , "interceptTouch: act=" + (ev .getAction ()) +
280+ if (DEBUG ) Slog .d (TAG , "interceptTouch: act=" + (ev .getAction ()) +
283281 " stretching=" + mStretching );
284282 mDetector .onTouchEvent (ev );
285283 return mStretching ;
286284 }
287285
288286 public boolean onTouchEvent (MotionEvent ev ) {
289287 final int action = ev .getAction ();
290- if (DEBUG ) Log .d (TAG , "touch: act=" + (action ) + " stretching=" + mStretching );
288+ if (DEBUG ) Slog .d (TAG , "touch: act=" + (action ) + " stretching=" + mStretching );
291289 if (mStretching ) {
292- if (DEBUG ) Log .d (TAG , "detector ontouch" );
290+ if (DEBUG ) Slog .d (TAG , "detector ontouch" );
293291 mDetector .onTouchEvent (ev );
294292 }
295293 switch (action ) {
296294 case MotionEvent .ACTION_UP :
297295 case MotionEvent .ACTION_CANCEL :
298- if (DEBUG ) Log .d (TAG , "cancel" );
296+ if (DEBUG ) Slog .d (TAG , "cancel" );
299297 mStretching = false ;
300298 clearView ();
301299 break ;
@@ -304,20 +302,20 @@ public boolean onTouchEvent(MotionEvent ev) {
304302 }
305303 private boolean initScale (View v ) {
306304 if (v != null ) {
307- if (DEBUG ) Log .d (TAG , "scale begins on view: " + v );
305+ if (DEBUG ) Slog .d (TAG , "scale begins on view: " + v );
308306 mStretching = true ;
309307 setView (v );
310308 setGlow (GLOW_BASE );
311309 mScaler .setView (v );
312310 mOldHeight = mScaler .getHeight ();
313311 if (mCallback .canChildBeExpanded (v )) {
314- if (DEBUG ) Log .d (TAG , "working on an expandable child" );
312+ if (DEBUG ) Slog .d (TAG , "working on an expandable child" );
315313 mNaturalHeight = mScaler .getNaturalHeight (mLargeSize );
316314 } else {
317- if (DEBUG ) Log .d (TAG , "working on a non-expandable child" );
315+ if (DEBUG ) Slog .d (TAG , "working on a non-expandable child" );
318316 mNaturalHeight = mOldHeight ;
319317 }
320- if (DEBUG ) Log .d (TAG , "got mOldHeight: " + mOldHeight +
318+ if (DEBUG ) Slog .d (TAG , "got mOldHeight: " + mOldHeight +
321319 " mNaturalHeight: " + mNaturalHeight );
322320 v .getParent ().requestDisallowInterceptTouchEvent (true );
323321 }
@@ -342,7 +340,7 @@ private void finishScale(boolean force) {
342340 mStretching = false ;
343341 setGlow (0f );
344342 mCallback .setUserExpandedChild (mCurrView , h == mNaturalHeight );
345- if (DEBUG ) Log .d (TAG , "scale was finished on view: " + mCurrView );
343+ if (DEBUG ) Slog .d (TAG , "scale was finished on view: " + mCurrView );
346344 clearView ();
347345 }
348346
@@ -362,7 +360,7 @@ private void setView(View v) {
362360 String debugLog = "Looking for glows: " +
363361 (mCurrViewTopGlow != null ? "found top " : "didn't find top" ) +
364362 (mCurrViewBottomGlow != null ? "found bottom " : "didn't find bottom" );
365- Log .v (TAG , debugLog );
363+ Slog .v (TAG , debugLog );
366364 }
367365 }
368366 }
0 commit comments