diff options
author | Steve Slaven <bpk@hoopajoo.net> | 2011-01-03 16:44:09 (GMT) |
---|---|---|
committer | Steve Slaven <bpk@hoopajoo.net> | 2011-01-03 16:44:09 (GMT) |
commit | 33e47109a5ddb9f3011d5c66eed92e6a07722c2b (patch) | |
tree | 37b9a1a9aaf6e20464489b5df48bdf1c26d7304c /src/net/hoopajoo/android/SoftKeys/InputSmoother.java | |
parent | 92bea9162959c4b5af21bcd8299233bfe9078508 (diff) | |
download | SoftKeys-33e47109a5ddb9f3011d5c66eed92e6a07722c2b.zip SoftKeys-33e47109a5ddb9f3011d5c66eed92e6a07722c2b.tar.gz SoftKeys-33e47109a5ddb9f3011d5c66eed92e6a07722c2b.tar.bz2 |
Make only the stop button rotate the service view, added a basic input
smoother though the display is still jittery, maybe it's a window
management problem
Diffstat (limited to 'src/net/hoopajoo/android/SoftKeys/InputSmoother.java')
-rw-r--r-- | src/net/hoopajoo/android/SoftKeys/InputSmoother.java | 50 |
1 files changed, 21 insertions, 29 deletions
diff --git a/src/net/hoopajoo/android/SoftKeys/InputSmoother.java b/src/net/hoopajoo/android/SoftKeys/InputSmoother.java index 812c3b4..12283be 100644 --- a/src/net/hoopajoo/android/SoftKeys/InputSmoother.java +++ b/src/net/hoopajoo/android/SoftKeys/InputSmoother.java @@ -50,10 +50,29 @@ public class InputSmoother { for( PointCheck p : mPoints ) { p.outlier = false; } - + + // currently this just checks to see if we delta'd farther than 10 pixels, + // it would be nice to add something smarter like curve fitting someday + // but it probably doesn't matter + int lastx = mPoints.get( 0 ).x; + int lasty = mPoints.get( 0 ).y; + + for( PointCheck p : mPoints ) { + if( Math.abs( lastx - p.x ) > 10 ) { + p.outlier = true; + } + if( Math.abs( lasty - p.y ) > 10 ) { + p.outlier = true; + } + lastx = p.x; + lasty = p.y; + } + // set current as the last non-outlier mCurrent = null; - for( PointCheck p : new ListReverser<PointCheck>( mPoints ) ) { + for( int i = mPoints.size() - 1; i >= 0; i-- ) { + PointCheck p = mPoints.get( i ); + if( mCurrent != null ) { if( p.outlier == false ) { mCurrent = p; @@ -79,31 +98,4 @@ public class InputSmoother { public int y; public boolean outlier; } - - class ListReverser<T> implements Iterable<T> { - private ListIterator<T> listIterator; - - public ListReverser(List<T> wrappedList) { - this.listIterator = wrappedList.listIterator(wrappedList.size()); - } - - public Iterator<T> iterator() { - return new Iterator<T>() { - - public boolean hasNext() { - return listIterator.hasPrevious(); - } - - public T next() { - return listIterator.previous(); - } - - public void remove() { - listIterator.remove(); - } - - }; - } - - } } |