mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-11-30 11:18:02 +08:00
fix viewpager's drag and scrolling
This commit is contained in:
parent
119a76cf49
commit
4502b1b1b6
3
README.md
Normal file → Executable file
3
README.md
Normal file → Executable file
@ -3,12 +3,13 @@
|
|||||||
|
|
||||||
# **Features:**
|
# **Features:**
|
||||||
* Multi Layer/Multi Window
|
* Multi Layer/Multi Window
|
||||||
* Intigated with 30+ UI Components and 15+ Drawables(compatibal with android)
|
* Integrated with 30+ UI Components and 15+ Drawables(compatibal with android)
|
||||||
* Full compatible with Android
|
* Full compatible with Android
|
||||||
* Smooth Scrolling
|
* Smooth Scrolling
|
||||||
* Scrolling with SpringBack Support
|
* Scrolling with SpringBack Support
|
||||||
# **Screen Shots**
|
# **Screen Shots**
|
||||||
![TextView](docs/images/screenshots/textviews.png)
|
![TextView](docs/images/screenshots/textviews.png)
|
||||||
|
![ViewPager](docs/videos/viewpager.gif)
|
||||||
# **UI Components:**
|
# **UI Components:**
|
||||||
* View
|
* View
|
||||||
* TextView
|
* TextView
|
||||||
|
2
src/gui/widget/view.cc
Normal file → Executable file
2
src/gui/widget/view.cc
Normal file → Executable file
@ -2238,7 +2238,7 @@ void View::unscheduleDrawable(Drawable& who,Runnable what){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void View::unscheduleDrawable(Drawable& who){
|
void View::unscheduleDrawable(Drawable& who){
|
||||||
LOGD(" %p ",&who);
|
LOGV(" %p ",&who);
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewGroup*View::getParent()const{
|
ViewGroup*View::getParent()const{
|
||||||
|
8
src/gui/widget/viewpager.cc
Normal file → Executable file
8
src/gui/widget/viewpager.cc
Normal file → Executable file
@ -31,6 +31,7 @@ void ViewPager::initViewPager(){
|
|||||||
mScroller = new Scroller(context, mInterpolator);
|
mScroller = new Scroller(context, mInterpolator);
|
||||||
mAdapter = nullptr;
|
mAdapter = nullptr;
|
||||||
mObserver = nullptr;
|
mObserver = nullptr;
|
||||||
|
mFakeDragging =false;
|
||||||
ViewConfiguration configuration = ViewConfiguration::get(context);
|
ViewConfiguration configuration = ViewConfiguration::get(context);
|
||||||
float density = 2.65f;//context.getResources().getDisplayMetrics().density;
|
float density = 2.65f;//context.getResources().getDisplayMetrics().density;
|
||||||
|
|
||||||
@ -1482,7 +1483,7 @@ bool ViewPager::onInterceptTouchEvent(MotionEvent& ev){
|
|||||||
float xDiff = std::abs(dx);
|
float xDiff = std::abs(dx);
|
||||||
float y = ev.getY(pointerIndex);
|
float y = ev.getY(pointerIndex);
|
||||||
float yDiff = std::abs(y - mInitialMotionY);
|
float yDiff = std::abs(y - mInitialMotionY);
|
||||||
|
|
||||||
if (dx != 0 && !isGutterDrag(mLastMotionX, dx)
|
if (dx != 0 && !isGutterDrag(mLastMotionX, dx)
|
||||||
&& canScroll(this, false, (int) dx, (int) x, (int) y)) {
|
&& canScroll(this, false, (int) dx, (int) x, (int) y)) {
|
||||||
// Nested view has scrollable area under this point. Let it be handled there.
|
// Nested view has scrollable area under this point. Let it be handled there.
|
||||||
@ -1595,8 +1596,7 @@ bool ViewPager::onTouchEvent(MotionEvent& ev){
|
|||||||
if (!mIsBeingDragged) {
|
if (!mIsBeingDragged) {
|
||||||
int pointerIndex = ev.findPointerIndex(mActivePointerId);
|
int pointerIndex = ev.findPointerIndex(mActivePointerId);
|
||||||
if (pointerIndex == -1) {
|
if (pointerIndex == -1) {
|
||||||
// A child has consumed some touch events and put us into an inconsistent
|
// A child has consumed some touch events and put us into an inconsistent state.
|
||||||
// state.
|
|
||||||
needsInvalidate = resetTouch();
|
needsInvalidate = resetTouch();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1605,8 +1605,6 @@ bool ViewPager::onTouchEvent(MotionEvent& ev){
|
|||||||
float y = ev.getY(pointerIndex);
|
float y = ev.getY(pointerIndex);
|
||||||
float yDiff = std::abs(y - mLastMotionY);
|
float yDiff = std::abs(y - mLastMotionY);
|
||||||
|
|
||||||
LOGV("Moved xy to %f,%f xydiff=%f,%f",x,y,xDiff, yDiff);
|
|
||||||
|
|
||||||
if (xDiff > mTouchSlop && xDiff > yDiff) {
|
if (xDiff > mTouchSlop && xDiff > yDiff) {
|
||||||
LOGV("Starting drag!");
|
LOGV("Starting drag!");
|
||||||
mIsBeingDragged = true;
|
mIsBeingDragged = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user