mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-12-05 05:37:53 +08:00
modify some abslistview's animations
This commit is contained in:
parent
5b95cbba9b
commit
283936d0f9
@ -50,7 +50,7 @@ int main(int argc,const char*argv[]){
|
|||||||
lv->setVerticalScrollBarEnabled(true);
|
lv->setVerticalScrollBarEnabled(true);
|
||||||
lv->setOverScrollMode(View::OVER_SCROLL_ALWAYS);
|
lv->setOverScrollMode(View::OVER_SCROLL_ALWAYS);
|
||||||
lv->setDividerHeight(1);
|
lv->setDividerHeight(1);
|
||||||
for(int i=0;i<32;i++){
|
for(int i=0;i<64;i++){
|
||||||
adapter->add("");
|
adapter->add("");
|
||||||
}
|
}
|
||||||
lv->addHeaderView(createHeader(),nullptr,false);
|
lv->addHeaderView(createHeader(),nullptr,false);
|
||||||
@ -59,8 +59,10 @@ int main(int argc,const char*argv[]){
|
|||||||
adapter->notifyDataSetChanged();
|
adapter->notifyDataSetChanged();
|
||||||
lv->setSelector(new ColorDrawable(0x8800FF00));
|
lv->setSelector(new ColorDrawable(0x8800FF00));
|
||||||
lv->setSelection(2);
|
lv->setSelection(2);
|
||||||
lv->setOnItemClickListener([](AdapterView&lv,View&v,int pos,long id){
|
lv->setOnItemClickListener([adapter](AdapterView&lv,View&v,int pos,long id){
|
||||||
LOGD("clicked %d",pos);
|
LOGD("clicked %d",pos);
|
||||||
|
if(pos==60)
|
||||||
|
((AbsListView&)lv).smoothScrollToPosition(0);
|
||||||
});
|
});
|
||||||
lv->requestLayout();
|
lv->requestLayout();
|
||||||
app.exec();
|
app.exec();
|
||||||
|
@ -33,11 +33,19 @@
|
|||||||
<id name="closekeyboard">0x00000406</id>
|
<id name="closekeyboard">0x00000406</id>
|
||||||
<id name="predict1">0x00000407</id>
|
<id name="predict1">0x00000407</id>
|
||||||
<id name="keyboardview">0x00000408</id>
|
<id name="keyboardview">0x00000408</id>
|
||||||
<id name="increment">0x00000409</id>
|
<id name="prev">0x00000409</id>
|
||||||
<id name="numberpicker_input">0x0000040a</id>
|
<id name="rew">0x0000040a</id>
|
||||||
<id name="decrement">0x0000040b</id>
|
<id name="pause">0x0000040b</id>
|
||||||
<id name="body">0x0000040c</id>
|
<id name="ffwd">0x0000040c</id>
|
||||||
<id name="select_dialog_listview">0x0000040d</id>
|
<id name="next">0x0000040d</id>
|
||||||
<id name="text1">0x0000040e</id>
|
<id name="time_current">0x0000040e</id>
|
||||||
|
<id name="mediacontroller_progress">0x0000040f</id>
|
||||||
|
<id name="time">0x00000410</id>
|
||||||
|
<id name="increment">0x00000411</id>
|
||||||
|
<id name="numberpicker_input">0x00000412</id>
|
||||||
|
<id name="decrement">0x00000413</id>
|
||||||
|
<id name="body">0x00000414</id>
|
||||||
|
<id name="select_dialog_listview">0x00000415</id>
|
||||||
|
<id name="text1">0x00000416</id>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
@ -2463,7 +2463,6 @@ void View::onDrawScrollBars(Canvas& canvas){
|
|||||||
getVerticalScrollBarBounds(&bounds, nullptr);
|
getVerticalScrollBarBounds(&bounds, nullptr);
|
||||||
onDrawVerticalScrollBar(canvas, scrollBar, bounds);
|
onDrawVerticalScrollBar(canvas, scrollBar, bounds);
|
||||||
if (bInvalidate) invalidate(bounds);
|
if (bInvalidate) invalidate(bounds);
|
||||||
//LOGD("%p:%d state=%d invalidate=%d rect=(%d,%d,%d,%d)",this,mID,cache->state,bInvalidate,bounds.left,bounds.top,bounds.width,bounds.height);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,21 +39,23 @@ namespace R{
|
|||||||
static constexpr int closekeyboard = 0x00000406 ;/*1030*/
|
static constexpr int closekeyboard = 0x00000406 ;/*1030*/
|
||||||
static constexpr int predict1 = 0x00000407 ;/*1031*/
|
static constexpr int predict1 = 0x00000407 ;/*1031*/
|
||||||
static constexpr int keyboardview = 0x00000408 ;/*1032*/
|
static constexpr int keyboardview = 0x00000408 ;/*1032*/
|
||||||
static constexpr int increment = 0x00000409 ;/*1033*/
|
static constexpr int prev = 0x00000409 ;/*1033*/
|
||||||
static constexpr int numberpicker_input = 0x0000040A ;/*1034*/
|
static constexpr int rew = 0x0000040A ;/*1034*/
|
||||||
static constexpr int decrement = 0x0000040B ;/*1035*/
|
static constexpr int pause = 0x0000040B ;/*1035*/
|
||||||
static constexpr int body = 0x0000040C ;/*1036*/
|
static constexpr int ffwd = 0x0000040C ;/*1036*/
|
||||||
static constexpr int select_dialog_listview = 0x0000040D ;/*1037*/
|
static constexpr int next = 0x0000040D ;/*1037*/
|
||||||
static constexpr int text1 = 0x0000040E ;/*1038*/
|
static constexpr int time_current = 0x0000040E ;/*1038*/
|
||||||
|
static constexpr int mediacontroller_progress= 0x0000040F ;/*1039*/
|
||||||
|
static constexpr int time = 0x00000410 ;/*1040*/
|
||||||
|
static constexpr int increment = 0x00000411 ;/*1041*/
|
||||||
|
static constexpr int numberpicker_input = 0x00000412 ;/*1042*/
|
||||||
|
static constexpr int decrement = 0x00000413 ;/*1043*/
|
||||||
|
static constexpr int body = 0x00000414 ;/*1044*/
|
||||||
|
static constexpr int select_dialog_listview = 0x00000415 ;/*1045*/
|
||||||
|
static constexpr int text1 = 0x00000416 ;/*1046*/
|
||||||
};/*namespace id*/
|
};/*namespace id*/
|
||||||
|
|
||||||
namespace strings{
|
namespace strings{
|
||||||
static constexpr int number_picker_increment_button= 0x000003E8 ;/*1000*/
|
|
||||||
static constexpr int number_picker_decrement_button= 0x000003E9 ;/*1001*/
|
|
||||||
static constexpr int row1 = 0x000003EA ;/*1002*/
|
|
||||||
static constexpr int row2 = 0x000003EB ;/*1003*/
|
|
||||||
static constexpr int row3 = 0x000003EC ;/*1004*/
|
|
||||||
static constexpr int row4 = 0x000003ED ;/*1005*/
|
|
||||||
};/*namespace strings*/
|
};/*namespace strings*/
|
||||||
|
|
||||||
};//endof namespace R
|
};//endof namespace R
|
||||||
|
@ -3530,7 +3530,7 @@ void AbsListView::PositionScroller::doScroll() {
|
|||||||
|
|
||||||
if (lastPos == mLastSeenPos) {
|
if (lastPos == mLastSeenPos) {
|
||||||
// No new views, let things keep going.
|
// No new views, let things keep going.
|
||||||
mLV->postOnAnimation(*this);
|
mLV->postOnAnimation(mLV->mPostScrollRunner);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3563,7 +3563,7 @@ void AbsListView::PositionScroller::doScroll() {
|
|||||||
|
|
||||||
if (nextPos == mLastSeenPos) {
|
if (nextPos == mLastSeenPos) {
|
||||||
// No new views, let things keep going.
|
// No new views, let things keep going.
|
||||||
mLV->postOnAnimation(*this);
|
mLV->postOnAnimation(mLV->mPostScrollRunner);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3577,7 +3577,7 @@ void AbsListView::PositionScroller::doScroll() {
|
|||||||
|
|
||||||
mLastSeenPos = nextPos;
|
mLastSeenPos = nextPos;
|
||||||
|
|
||||||
mLV->postOnAnimation(*this);
|
mLV->postOnAnimation(mLV->mPostScrollRunner);
|
||||||
} else {
|
} else {
|
||||||
if (nextViewTop > extraScroll) {
|
if (nextViewTop > extraScroll) {
|
||||||
mLV->smoothScrollBy(nextViewTop - extraScroll, mScrollDuration, true, false);
|
mLV->smoothScrollBy(nextViewTop - extraScroll, mScrollDuration, true, false);
|
||||||
@ -3697,8 +3697,7 @@ void AbsListView::PositionScroller::doScroll() {
|
|||||||
// On-screen, just scroll.
|
// On-screen, just scroll.
|
||||||
const int targetTop = mLV->getChildAt(position - firstPos)->getTop();
|
const int targetTop = mLV->getChildAt(position - firstPos)->getTop();
|
||||||
const int distance = targetTop - mOffsetFromTop;
|
const int distance = targetTop - mOffsetFromTop;
|
||||||
const int duration = (int) (mScrollDuration *
|
const int duration = (int) (mScrollDuration * ((float) std::abs(distance) / mLV->getHeight()));
|
||||||
((float) std::abs(distance) / mLV->getHeight()));
|
|
||||||
mLV->smoothScrollBy(distance, duration, true, false);
|
mLV->smoothScrollBy(distance, duration, true, false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -3896,7 +3895,7 @@ void AbsListView::FlingRunnable::start(int initialVelocity) {
|
|||||||
|
|
||||||
mLV->mTouchMode = TOUCH_MODE_FLING;
|
mLV->mTouchMode = TOUCH_MODE_FLING;
|
||||||
mSuppressIdleStateChangeCall = false;
|
mSuppressIdleStateChangeCall = false;
|
||||||
mLV->postOnAnimation(*this);
|
mLV->postOnAnimation(mLV->mFlingRunnable);
|
||||||
if (PROFILE_FLINGING) {
|
if (PROFILE_FLINGING) {
|
||||||
if (!mLV->mFlingProfilingStarted) {
|
if (!mLV->mFlingProfilingStarted) {
|
||||||
mLV->mFlingProfilingStarted = true;
|
mLV->mFlingProfilingStarted = true;
|
||||||
@ -3912,7 +3911,7 @@ void AbsListView::FlingRunnable::startSpringback() {
|
|||||||
if (mScroller->springBack(0, mLV->mScrollY, 0, 0, 0, 0)) {
|
if (mScroller->springBack(0, mLV->mScrollY, 0, 0, 0, 0)) {
|
||||||
mLV->mTouchMode = TOUCH_MODE_OVERFLING;
|
mLV->mTouchMode = TOUCH_MODE_OVERFLING;
|
||||||
mLV->invalidate();
|
mLV->invalidate();
|
||||||
mLV->postOnAnimation(*this);
|
mLV->postOnAnimation(mLV->mFlingRunnable);
|
||||||
} else {
|
} else {
|
||||||
mLV->mTouchMode = TOUCH_MODE_REST;
|
mLV->mTouchMode = TOUCH_MODE_REST;
|
||||||
mLV->reportScrollStateChange(OnScrollListener::SCROLL_STATE_IDLE);
|
mLV->reportScrollStateChange(OnScrollListener::SCROLL_STATE_IDLE);
|
||||||
@ -3925,7 +3924,7 @@ void AbsListView::FlingRunnable::startOverfling(int initialVelocity) {
|
|||||||
mLV->mTouchMode = TOUCH_MODE_OVERFLING;
|
mLV->mTouchMode = TOUCH_MODE_OVERFLING;
|
||||||
mSuppressIdleStateChangeCall = false;
|
mSuppressIdleStateChangeCall = false;
|
||||||
mLV->invalidate();
|
mLV->invalidate();
|
||||||
mLV->postOnAnimation(*this);
|
mLV->postOnAnimation(mLV->mFlingRunnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbsListView::FlingRunnable::edgeReached(int delta) {
|
void AbsListView::FlingRunnable::edgeReached(int delta) {
|
||||||
@ -3942,7 +3941,7 @@ void AbsListView::FlingRunnable::edgeReached(int delta) {
|
|||||||
mLV->mPositionScroller->stop();
|
mLV->mPositionScroller->stop();
|
||||||
}
|
}
|
||||||
mLV->invalidate();
|
mLV->invalidate();
|
||||||
mLV->postOnAnimation(*this);
|
mLV->postOnAnimation(mLV->mFlingRunnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbsListView::FlingRunnable::startScroll(int distance, int duration, bool linear, bool suppressEndFlingStateChangeCall) {
|
void AbsListView::FlingRunnable::startScroll(int distance, int duration, bool linear, bool suppressEndFlingStateChangeCall) {
|
||||||
@ -3952,13 +3951,13 @@ void AbsListView::FlingRunnable::startScroll(int distance, int duration, bool li
|
|||||||
mScroller->startScroll(0, initialY, 0, distance, duration);
|
mScroller->startScroll(0, initialY, 0, distance, duration);
|
||||||
mLV->mTouchMode = TOUCH_MODE_FLING;
|
mLV->mTouchMode = TOUCH_MODE_FLING;
|
||||||
mSuppressIdleStateChangeCall = suppressEndFlingStateChangeCall;
|
mSuppressIdleStateChangeCall = suppressEndFlingStateChangeCall;
|
||||||
mLV->postOnAnimation(*this);
|
mLV->postOnAnimation(mLV->mFlingRunnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbsListView::FlingRunnable::endFling() {
|
void AbsListView::FlingRunnable::endFling() {
|
||||||
mLV->mTouchMode = TOUCH_MODE_REST;
|
mLV->mTouchMode = TOUCH_MODE_REST;
|
||||||
|
|
||||||
mLV->removeCallbacks(*this);
|
mLV->removeCallbacks(mLV->mFlingRunnable);
|
||||||
mLV->removeCallbacks(mCheckFlywheel);
|
mLV->removeCallbacks(mCheckFlywheel);
|
||||||
|
|
||||||
if (!mSuppressIdleStateChangeCall)
|
if (!mSuppressIdleStateChangeCall)
|
||||||
@ -4038,7 +4037,7 @@ void AbsListView::FlingRunnable::run() {
|
|||||||
if (more && !atEnd) {
|
if (more && !atEnd) {
|
||||||
if (atEdge) mLV->invalidate();
|
if (atEdge) mLV->invalidate();
|
||||||
mLastFlingY = y;
|
mLastFlingY = y;
|
||||||
mLV->postOnAnimation(*this);
|
mLV->postOnAnimation(mLV->mFlingRunnable);
|
||||||
} else {
|
} else {
|
||||||
endFling();
|
endFling();
|
||||||
if (PROFILE_FLINGING) {
|
if (PROFILE_FLINGING) {
|
||||||
@ -4072,7 +4071,7 @@ void AbsListView::FlingRunnable::run() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mLV->invalidate();
|
mLV->invalidate();
|
||||||
mLV->postOnAnimation(*this);
|
mLV->postOnAnimation(mLV->mFlingRunnable);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
endFling();
|
endFling();
|
||||||
|
Loading…
Reference in New Issue
Block a user