20131204

1枚举类



public static enum Mode {



DISABLED(0x0),



PULL_FROM_START(0x1),



PULL_FROM_END(0x2),



BOTH(0x3),



MANUAL_REFRESH_ONLY(0x4);



public static Mode PULL_DOWN_TO_REFRESH = Mode.PULL_FROM_START;



public static Mode PULL_UP_TO_REFRESH = Mode.PULL_FROM_END;



static Mode mapIntToValue(final int modeInt) {
for (Mode value : Mode.values()) {
if (modeInt == value.getIntValue()) {
return value;
}
}


// If not, return default
return getDefault();
}


static Mode getDefault() {
return PULL_FROM_START;
}


private int mIntValue;


// The modeInt values need to match those from attrs.xml
Mode(int modeInt) {
mIntValue = modeInt;
}


/**
* @return true if the mode permits Pull-to-Refresh
*/
boolean permitsPullToRefresh() {
return !(this == DISABLED || this == MANUAL_REFRESH_ONLY);
}


/**
* @return true if this mode wants the Loading Layout Header to be shown
*/
public boolean showHeaderLoadingLayout() {
return this == PULL_FROM_START || this == BOTH;
}


/**
* @return true if this mode wants the Loading Layout Footer to be shown
*/
public boolean showFooterLoadingLayout() {
return this == PULL_FROM_END || this == BOTH || this == MANUAL_REFRESH_ONLY;
}


int getIntValue() {
return mIntValue;
}


}


// ===========================================================
// Inner, Anonymous Classes, and Enumerations
// ===========================================================



public static interface OnLastItemVisibleListener {


/**
* Called when the user has scrolled to the end of the list
*/
public void onLastItemVisible();


}

枚举类实在是一个数据结构和类的结合体,可以通过构造方法传值,里面可以定义方法,可以遍历里面的值;


2 ViewCompat.postOnAnimal(View v,Runalbe);方法,这个开启的线程是在主进程里面的,可以更新界面;

3 动画的数度控制可以通过setInterpolator()来控制;

4 动画完成的递归算法

if (mStartTime == -1) {
mStartTime = System.currentTimeMillis();
} else {


/**
* We do do all calculations in long to reduce software float
* calculations. We use 1000 as it gives us good accuracy and
* small rounding errors
*/
long normalizedTime = (1000 * (System.currentTimeMillis() - mStartTime)) / mDuration;
normalizedTime = Math.max(Math.min(normalizedTime, 1000), 0);


final int deltaY = Math.round((mScrollFromY - mScrollToY)
* mInterpolator.getInterpolation(normalizedTime / 1000f));
mCurrentY = mScrollFromY - deltaY;
setHeaderScroll(mCurrentY);
}


// If we're not at the target Y, keep going...
if (mContinueRunning && mScrollToY != mCurrentY) {
ViewCompat.postOnAnimation(PullToRefreshBase.this, this);
} else {
if (null != mListener) {
mListener.onSmoothScrollFinished();
}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值