Loading src/com/cyanogenmod/filemanager/ui/widgets/FlingerListView.java +60 −37 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.view.HapticFeedbackConstants; import android.view.MotionEvent; import android.view.View; import android.view.ViewConfiguration; import android.widget.AbsListView; import android.widget.AdapterView; import android.widget.ListView; Loading Loading @@ -143,9 +144,9 @@ public class FlingerListView extends ListView { private int mFlingingViewPos; private View mFlingingView; private boolean mFlingingViewPressed; private int mFlingingViewHeight; private int mFlingingViewWidth; private boolean mScrolling; private boolean mScrollInAnimation; private boolean mFlinging; private boolean mFlingingStarted; private boolean mMoveStarted; Loading Loading @@ -199,6 +200,18 @@ public class FlingerListView extends ListView { //Initialize variables this.mFlingRemovePercentaje = DEFAULT_FLING_REMOVE_PERCENTAJE; this.mFlingThreshold = AndroidHelper.convertDpToPixel(getContext(), MIN_FLINGER_THRESHOLD); setOnScrollListener(new OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { mScrollInAnimation = (scrollState == SCROLL_STATE_FLING); } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { } }); mScrollInAnimation = false; } /** Loading Loading @@ -309,7 +322,6 @@ public class FlingerListView extends ListView { Rect r = new Rect(); this.mFlingingView.getDrawingRect(r); this.mFlingingViewWidth = r.width(); this.mFlingingViewHeight = r.height(); // Set the pressed state this.mFlingingView.postDelayed(new Runnable() { Loading @@ -324,15 +336,14 @@ public class FlingerListView extends ListView { } }, PRESSED_DELAY_TIME); // Enable this, cause some strange effects. By the other side, the scrolling // is not as much smooth as it should be //super.onTouchEvent(ev); // If not the view is not scrolling the capture event if (!mScrollInAnimation) { return true; } } break; case MotionEvent.ACTION_MOVE: this.mMoveStarted = true; if (this.mFlingingView != null) { this.mFlingingView.removeCallbacks(this.mLongPressDetection); this.mFlingingViewPressed = false; Loading @@ -342,7 +353,7 @@ public class FlingerListView extends ListView { // Detect scrolling this.mCurrentY = (int)ev.getY(); this.mScrolling = Math.abs(this.mCurrentY - this.mStartY) > this.mFlingingViewHeight; Math.abs(this.mCurrentY - this.mStartY) > (this.mFlingThreshold / 3); if (this.mFlingingStarted) { // Don't allow scrolling this.mScrolling = false; Loading @@ -359,17 +370,26 @@ public class FlingerListView extends ListView { this.mFlingingView.setPressed(false); // Started if (!this.mFlingingStarted && this.mTranslationX > this.mFlingThreshold) { if (!this.mFlingingStarted) { // Flinging starting if (!mMoveStarted) { if (!this.mOnItemFlingerListener.onItemFlingerStart( this, this.mFlingingView, this.mFlingingViewPos, this.mFlingingView.getId())) { this.mCurrentX = 0; this.mTranslationX = 0; this.mFlingingView.setTranslationX(this.mTranslationX); this.mFlingingView.setPressed(false); break; } } mMoveStarted = true; if (this.mTranslationX > this.mFlingThreshold) { this.mFlingingStarted = true; } } // Detect if flinging occurs float flingLimit = Loading Loading @@ -398,6 +418,11 @@ public class FlingerListView extends ListView { }); } } } else { this.mCurrentX = 0; this.mTranslationX = 0; this.mFlingingView.setTranslationX(this.mTranslationX); this.mFlingingView.setPressed(false); } } if (this.mFlingingStarted) { Loading Loading @@ -427,8 +452,7 @@ public class FlingerListView extends ListView { // What is the motion if (!this.mScrolling && this.mFlingingView != null) { if (!this.mMoveStarted) { if (!this.mLongPress) { if(!this.mMoveStarted && !this.mLongPress) { this.mFlingingViewPressed = false; this.mFlingingView.removeCallbacks(this.mLongPressDetection); this.mFlingingView.setPressed(true); Loading @@ -444,11 +468,10 @@ public class FlingerListView extends ListView { this.mFlingingView, this.mFlingingViewPos, this.mFlingingView.getId()); } } // Handled this.mFlingingView.setPressed(false); } return true; } Loading Loading
src/com/cyanogenmod/filemanager/ui/widgets/FlingerListView.java +60 −37 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.view.HapticFeedbackConstants; import android.view.MotionEvent; import android.view.View; import android.view.ViewConfiguration; import android.widget.AbsListView; import android.widget.AdapterView; import android.widget.ListView; Loading Loading @@ -143,9 +144,9 @@ public class FlingerListView extends ListView { private int mFlingingViewPos; private View mFlingingView; private boolean mFlingingViewPressed; private int mFlingingViewHeight; private int mFlingingViewWidth; private boolean mScrolling; private boolean mScrollInAnimation; private boolean mFlinging; private boolean mFlingingStarted; private boolean mMoveStarted; Loading Loading @@ -199,6 +200,18 @@ public class FlingerListView extends ListView { //Initialize variables this.mFlingRemovePercentaje = DEFAULT_FLING_REMOVE_PERCENTAJE; this.mFlingThreshold = AndroidHelper.convertDpToPixel(getContext(), MIN_FLINGER_THRESHOLD); setOnScrollListener(new OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { mScrollInAnimation = (scrollState == SCROLL_STATE_FLING); } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { } }); mScrollInAnimation = false; } /** Loading Loading @@ -309,7 +322,6 @@ public class FlingerListView extends ListView { Rect r = new Rect(); this.mFlingingView.getDrawingRect(r); this.mFlingingViewWidth = r.width(); this.mFlingingViewHeight = r.height(); // Set the pressed state this.mFlingingView.postDelayed(new Runnable() { Loading @@ -324,15 +336,14 @@ public class FlingerListView extends ListView { } }, PRESSED_DELAY_TIME); // Enable this, cause some strange effects. By the other side, the scrolling // is not as much smooth as it should be //super.onTouchEvent(ev); // If not the view is not scrolling the capture event if (!mScrollInAnimation) { return true; } } break; case MotionEvent.ACTION_MOVE: this.mMoveStarted = true; if (this.mFlingingView != null) { this.mFlingingView.removeCallbacks(this.mLongPressDetection); this.mFlingingViewPressed = false; Loading @@ -342,7 +353,7 @@ public class FlingerListView extends ListView { // Detect scrolling this.mCurrentY = (int)ev.getY(); this.mScrolling = Math.abs(this.mCurrentY - this.mStartY) > this.mFlingingViewHeight; Math.abs(this.mCurrentY - this.mStartY) > (this.mFlingThreshold / 3); if (this.mFlingingStarted) { // Don't allow scrolling this.mScrolling = false; Loading @@ -359,17 +370,26 @@ public class FlingerListView extends ListView { this.mFlingingView.setPressed(false); // Started if (!this.mFlingingStarted && this.mTranslationX > this.mFlingThreshold) { if (!this.mFlingingStarted) { // Flinging starting if (!mMoveStarted) { if (!this.mOnItemFlingerListener.onItemFlingerStart( this, this.mFlingingView, this.mFlingingViewPos, this.mFlingingView.getId())) { this.mCurrentX = 0; this.mTranslationX = 0; this.mFlingingView.setTranslationX(this.mTranslationX); this.mFlingingView.setPressed(false); break; } } mMoveStarted = true; if (this.mTranslationX > this.mFlingThreshold) { this.mFlingingStarted = true; } } // Detect if flinging occurs float flingLimit = Loading Loading @@ -398,6 +418,11 @@ public class FlingerListView extends ListView { }); } } } else { this.mCurrentX = 0; this.mTranslationX = 0; this.mFlingingView.setTranslationX(this.mTranslationX); this.mFlingingView.setPressed(false); } } if (this.mFlingingStarted) { Loading Loading @@ -427,8 +452,7 @@ public class FlingerListView extends ListView { // What is the motion if (!this.mScrolling && this.mFlingingView != null) { if (!this.mMoveStarted) { if (!this.mLongPress) { if(!this.mMoveStarted && !this.mLongPress) { this.mFlingingViewPressed = false; this.mFlingingView.removeCallbacks(this.mLongPressDetection); this.mFlingingView.setPressed(true); Loading @@ -444,11 +468,10 @@ public class FlingerListView extends ListView { this.mFlingingView, this.mFlingingViewPos, this.mFlingingView.getId()); } } // Handled this.mFlingingView.setPressed(false); } return true; } Loading