mirror of
https://github.com/moparisthebest/Yaaic
synced 2024-08-13 16:53:50 -04:00
Refactor ChannelList to ConversationGallery - Moved to view package, added javadoc and licence header
This commit is contained in:
parent
f4637ac582
commit
7845ad73f0
@ -1,25 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
60
application/src/org/yaaic/view/ConversationGallery.java
Normal file
60
application/src/org/yaaic/view/ConversationGallery.java
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
Yaaic - Yet Another Android IRC Client
|
||||||
|
|
||||||
|
Copyright 2009-2011 Sebastian Kaspari
|
||||||
|
|
||||||
|
This file is part of Yaaic.
|
||||||
|
|
||||||
|
Yaaic is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Yaaic is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.yaaic.view;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
import android.widget.Gallery;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Conversation gallery for horizontal scrolling
|
||||||
|
*
|
||||||
|
* @author Thomas Martitz
|
||||||
|
*/
|
||||||
|
public class ConversationGallery extends Gallery
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new conversation gallery
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* @param attrs
|
||||||
|
*/
|
||||||
|
public ConversationGallery(Context context, AttributeSet attrs)
|
||||||
|
{
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On Fling: Reduce sensitivity of the channel gallery view
|
||||||
|
*/
|
||||||
|
@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