Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

library change for center lock #98

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,13 @@ horizontallistview/bin
horizontallistview/gen
sample/bin
sample/gen
library/pom.xml
library/pom.xml

# Files to be ignored
*~
android-support-v4.jar
R.java
project.properties
lint.xml
.DS_STORE
.factorypath
9 changes: 9 additions & 0 deletions library/src/main/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="java"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
33 changes: 33 additions & 0 deletions library/src/main/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>main</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
4 changes: 4 additions & 0 deletions library/src/main/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.source=1.6
11 changes: 8 additions & 3 deletions library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<manifest package="it.sephiroth.android.library">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="it.sephiroth.android.library" >

<application />
<uses-sdk
android:minSdkVersion="3"
android:targetSdkVersion="19" />

</manifest>
<application />

</manifest>
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package it.sephiroth.android.library.widget;

import it.sephiroth.android.library.R;
import it.sephiroth.android.library.util.ViewHelperFactory;
import it.sephiroth.android.library.util.ViewHelperFactory.ViewHelper;
import it.sephiroth.android.library.util.v11.MultiChoiceModeListener;
import it.sephiroth.android.library.util.v11.MultiChoiceModeWrapper;

import java.util.ArrayList;
import java.util.List;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
Expand Down Expand Up @@ -46,20 +55,12 @@
import android.widget.ListAdapter;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

import it.sephiroth.android.library.R;
import it.sephiroth.android.library.util.ViewHelperFactory;
import it.sephiroth.android.library.util.ViewHelperFactory.ViewHelper;
import it.sephiroth.android.library.util.v11.MultiChoiceModeListener;
import it.sephiroth.android.library.util.v11.MultiChoiceModeWrapper;

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public abstract class AbsHListView extends AdapterView<ListAdapter> implements ViewTreeObserver.OnGlobalLayoutListener,
ViewTreeObserver.OnTouchModeChangeListener {

private static final String TAG = "AbsListView";
public static int CHILD_WIDTH;

/**
* Disables the transcript mode.
Expand Down Expand Up @@ -3664,7 +3665,7 @@ void reportScrollStateChange( int newState ) {
}
}
}

/**
* Responsible for fling behavior. Use {@link #start(int)} to initiate a fling. Each frame of the fling is handled in
* {@link #run()}. A FlingRunnable will keep re-posting itself until the fling is done.
Expand Down Expand Up @@ -3717,12 +3718,31 @@ void start( int initialVelocity ) {
int initialX = initialVelocity < 0 ? Integer.MAX_VALUE : 0;
mLastFlingX = initialX;
mScroller.setInterpolator( null );
mScroller.fling( initialX, 0, initialVelocity, 0, 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE );

mScroller.fling( initialX, 0, initialVelocity, 0, 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE,getScrollX() );
mTouchMode = TOUCH_MODE_FLING;
mViewHelper.postOnAnimation( this );
mViewHelper.postOnAnimation(this);
}

int getScrollX() {
View firstChild = getChildAt(0);
int scrollX = 0;
if (getFirstVisiblePosition() == 0) {
scrollX = (-firstChild.getLeft());
CHILD_WIDTH = (int) (firstChild.getMeasuredWidth() - (32 * getResources()
.getDisplayMetrics().density));
} else if (getFirstVisiblePosition() > 0) {
scrollX = (int) (-firstChild.getLeft()
+ (firstChild.getMeasuredWidth() + (32 * getResources()
.getDisplayMetrics().density)) + (getFirstVisiblePosition() - 1)
* (firstChild.getMeasuredWidth()));

CHILD_WIDTH = firstChild.getMeasuredWidth();
}
return scrollX;
}

void startSpringback() {
void startSpringback() {
if ( mScroller.springBack( getScrollX(), 0, 0, 0, 0, 0 ) ) {
mTouchMode = TOUCH_MODE_OVERFLING;
invalidate();
Expand All @@ -3735,7 +3755,7 @@ void startSpringback() {

void startOverfling( int initialVelocity ) {
mScroller.setInterpolator( null );
mScroller.fling( getScrollX(), 0, initialVelocity, 0, Integer.MIN_VALUE, Integer.MAX_VALUE, 0, 0, getWidth(), 0 );
mScroller.fling( getScrollX(), 0, initialVelocity, 0, Integer.MIN_VALUE, Integer.MAX_VALUE, 0, 0, getWidth(), 0,getScrollX() );
mTouchMode = TOUCH_MODE_OVERFLING;
invalidate();
mViewHelper.postOnAnimation( this );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,8 @@ public boolean springBack(int startX, int startY, int minX, int maxX, int minY,
}

public void fling(int startX, int startY, int velocityX, int velocityY,
int minX, int maxX, int minY, int maxY) {
fling(startX, startY, velocityX, velocityY, minX, maxX, minY, maxY, 0, 0);
int minX, int maxX, int minY, int maxY,int scrollX) {
fling(startX, startY, velocityX, velocityY, minX, maxX, minY, maxY, 0, 0,scrollX);
}

/**
Expand Down Expand Up @@ -456,7 +456,7 @@ public void fling(int startX, int startY, int velocityX, int velocityY,
* direction will be possible.
*/
public void fling(int startX, int startY, int velocityX, int velocityY,
int minX, int maxX, int minY, int maxY, int overX, int overY) {
int minX, int maxX, int minY, int maxY, int overX, int overY,int scrollX) {
// Continue a scroll or fling in progress
if (mFlywheel && !isFinished()) {
float oldVelocityX = mScrollerX.mCurrVelocity;
Expand All @@ -469,8 +469,8 @@ public void fling(int startX, int startY, int velocityX, int velocityY,
}

mMode = FLING_MODE;
mScrollerX.fling(startX, velocityX, minX, maxX, overX);
mScrollerY.fling(startY, velocityY, minY, maxY, overY);
mScrollerX.fling(startX, velocityX, minX, maxX, overX,scrollX);
mScrollerY.fling(startY, velocityY, minY, maxY, overY,scrollX);
}

/**
Expand Down Expand Up @@ -768,7 +768,7 @@ private void startSpringback(int start, int end, int velocity) {
mDuration = (int) (1000.0 * Math.sqrt(-2.0 * delta / mDeceleration));
}

void fling(int start, int velocity, int min, int max, int over) {
void fling(int start, int velocity, int min, int max, int over,int scrollX) {
mOver = over;
mFinished = false;
mCurrVelocity = mVelocity = velocity;
Expand All @@ -789,9 +789,21 @@ void fling(int start, int velocity, int min, int max, int over) {
totalDistance = getSplineFlingDistance(velocity);
}

mSplineDistance = (int) (totalDistance * Math.signum(velocity));
mFinal = start + mSplineDistance;
mSplineDistance = (int) (totalDistance * 1.5 * Math
.signum(velocity));
int totalDistanceToScroll = mSplineDistance + scrollX;
int initPosition = scrollX / AbsHListView.CHILD_WIDTH;
int position = totalDistanceToScroll / AbsHListView.CHILD_WIDTH;
if (position == initPosition) {
mDuration = mSplineDuration = mSplineDuration + 100;
if (mSplineDistance > 0)
position = position + 1;

}
mSplineDistance = position * AbsHListView.CHILD_WIDTH - scrollX;

mFinal = start + mSplineDistance;

// Clamp to a valid final position
if (mFinal < min) {
adjustDuration(mStart, mFinal, min);
Expand Down Expand Up @@ -855,7 +867,7 @@ private void startAfterEdge(int start, int min, int max, int velocity) {
} else {
final double totalDistance = getSplineFlingDistance(velocity);
if (totalDistance > Math.abs(overDistance)) {
fling(start, velocity, positive ? min : start, positive ? start : max, mOver);
fling(start, velocity, positive ? min : start, positive ? start : max, mOver,0);
} else {
startSpringback(start, edge, velocity);
}
Expand Down
15 changes: 15 additions & 0 deletions library/src/main/project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-19
android.library=true