mirror of
https://github.com/moparisthebest/Yaaic
synced 2024-11-22 17:02:21 -05:00
Reduce sensitivity of the channel gallery view.
Higher scroll speeds are reduced stronger.
This commit is contained in:
parent
7120bb48ea
commit
db91a85676
@ -48,7 +48,7 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1">
|
android:layout_weight="1">
|
||||||
<Gallery
|
<org.yaaic.model.ChannelList
|
||||||
android:id="@+id/deck"
|
android:id="@+id/deck"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
|
25
application/src/org/yaaic/model/ChannelList.java
Normal file
25
application/src/org/yaaic/model/ChannelList.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package org.yaaic.model;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
import android.widget.Gallery;
|
||||||
|
|
||||||
|
public class ChannelList extends Gallery
|
||||||
|
{
|
||||||
|
public ChannelList(Context context, AttributeSet attrs)
|
||||||
|
{
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onFling (MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
|
||||||
|
{
|
||||||
|
/* Reduce sensitivity based on f(x) = x * 0.925^y with y = (|x/500| - 1)
|
||||||
|
* The goal is to reduce higher velocities stronger than low ones
|
||||||
|
* 500 is the base, i.e. it will not reduced. */
|
||||||
|
final float fexp = Math.abs(velocityX / 500.0f) - 1;
|
||||||
|
velocityX *= Math.pow(0.925, fexp);
|
||||||
|
return super.onFling(e1, e2, velocityX, velocityY);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user