aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorge Ruesga <jorge@ruesga.com>2013-11-29 23:38:32 +0000
committerGerrit Code Review <gerrit@cyanogenmod.org>2013-11-29 23:38:32 +0000
commit45c2f21a66a6152000dacfd72e6cec3652194ecd (patch)
tree1e00d4fe250aeab7a4f0d53b97a98f56de612274
parent21c7a518b43592f042d1452aa600f86c34b41290 (diff)
parentb7e30877660bf8ea7950c7b8dddbbe980d3e734d (diff)
downloadandroid_packages_apps_CMFileManager-45c2f21a66a6152000dacfd72e6cec3652194ecd.tar.gz
android_packages_apps_CMFileManager-45c2f21a66a6152000dacfd72e6cec3652194ecd.tar.bz2
android_packages_apps_CMFileManager-45c2f21a66a6152000dacfd72e6cec3652194ecd.zip
Merge "CMFM: Improve flingerview handling" into cm-10.2
-rw-r--r--src/com/cyanogenmod/filemanager/ui/widgets/FlingerListView.java97
1 files changed, 60 insertions, 37 deletions
diff --git a/src/com/cyanogenmod/filemanager/ui/widgets/FlingerListView.java b/src/com/cyanogenmod/filemanager/ui/widgets/FlingerListView.java
index 8079127e..018f72ed 100644
--- a/src/com/cyanogenmod/filemanager/ui/widgets/FlingerListView.java
+++ b/src/com/cyanogenmod/filemanager/ui/widgets/FlingerListView.java
@@ -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;
@@ -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;
@@ -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;
}
/**
@@ -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() {
@@ -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);
- return true;
+ // 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;
@@ -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;
@@ -359,16 +370,25 @@ public class FlingerListView extends ListView {
this.mFlingingView.setPressed(false);
// Started
- if (!this.mFlingingStarted && this.mTranslationX > this.mFlingThreshold) {
+ if (!this.mFlingingStarted) {
// Flinging starting
- if (!this.mOnItemFlingerListener.onItemFlingerStart(
- this,
- this.mFlingingView,
- this.mFlingingViewPos,
- this.mFlingingView.getId())) {
- break;
+ 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;
}
- this.mFlingingStarted = true;
}
// Detect if flinging occurs
@@ -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) {
@@ -427,28 +452,26 @@ public class FlingerListView extends ListView {
// What is the motion
if (!this.mScrolling && this.mFlingingView != null) {
- if (!this.mMoveStarted) {
- if (!this.mLongPress) {
- this.mFlingingViewPressed = false;
- this.mFlingingView.removeCallbacks(this.mLongPressDetection);
- this.mFlingingView.setPressed(true);
-
- this.mFlingingView.postDelayed(new Runnable() {
- @Override
- @SuppressWarnings("synthetic-access")
- public void run() {
- FlingerListView.this.mFlingingView.setPressed(false);
- }
- }, PRESSED_DELAY_TIME);
- performItemClick(
- this.mFlingingView,
- this.mFlingingViewPos,
- this.mFlingingView.getId());
- }
- }
+ if(!this.mMoveStarted && !this.mLongPress) {
+ this.mFlingingViewPressed = false;
+ this.mFlingingView.removeCallbacks(this.mLongPressDetection);
+ this.mFlingingView.setPressed(true);
- // Handled
- this.mFlingingView.setPressed(false);
+ this.mFlingingView.postDelayed(new Runnable() {
+ @Override
+ @SuppressWarnings("synthetic-access")
+ public void run() {
+ FlingerListView.this.mFlingingView.setPressed(false);
+ }
+ }, PRESSED_DELAY_TIME);
+ performItemClick(
+ this.mFlingingView,
+ this.mFlingingViewPos,
+ this.mFlingingView.getId());
+
+ // Handled
+ this.mFlingingView.setPressed(false);
+ }
return true;
}