20131204

原创 2013年12月04日 18:22:41

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();
}
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

JAVA笔记【20131204】

一、对象 Java中对象变量都是对对象的引用。 可以显式的将对象变量设置为空(null),表明这个对象变量未引用任何对象。 例: Date deadLine ;          deadLine =...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)