本文整理汇总了Java中android.widget.Gallery.getFirstVisiblePosition方法的典型用法代码示例。如果您正苦于以下问题:Java Gallery.getFirstVisiblePosition方法的具体用法?Java Gallery.getFirstVisiblePosition怎么用?Java Gallery.getFirstVisiblePosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.Gallery
的用法示例。
在下文中一共展示了Gallery.getFirstVisiblePosition方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldDelayGallery
import android.widget.Gallery; //导入方法依赖的package包/类
private static boolean shouldDelayGallery(int position, View convertView, ViewGroup parent, String url)
{
if (url == null || BitmapAjaxCallback.isMemoryCached(url))
{
return false;
}
Gallery gallery = (Gallery) parent;
Integer selected = (Integer) gallery.getTag(AQuery.TAG_NUM);
if (selected == null)
{
selected = 0;
gallery.setTag(AQuery.TAG_NUM, 0);
gallery.setCallbackDuringFling(false);
Common common = new Common();
common.listen(gallery);
}
int first = gallery.getFirstVisiblePosition();
int last = gallery.getLastVisiblePosition();
int diff = last - first;
int delta = (diff / 2) + 1;
int from = selected - delta;
int to = selected + delta;
if (from < 0)
{
//shift window back to positive region
to = to - from;
from = 0;
}
if ((position >= from && position <= to))
{
//AQUtility.debug("yes", position + ":" + from + "." + to);
convertView.setTag(AQuery.TAG_NUM, position);
return false;
}
//AQUtility.debug("no", position + ":" + from + "." + to);
convertView.setTag(AQuery.TAG_NUM, null);
return true;
}
示例2: shouldDelayGallery
import android.widget.Gallery; //导入方法依赖的package包/类
private static boolean shouldDelayGallery(int position, View convertView, ViewGroup parent, String url){
if(url == null || BitmapAjaxCallback.isMemoryCached(url)){
return false;
}
Gallery gallery = (Gallery) parent;
Integer selected = (Integer) gallery.getTag(AQuery.TAG_NUM);
if(selected == null){
selected = 0;
gallery.setTag(AQuery.TAG_NUM, 0);
gallery.setCallbackDuringFling(false);
Common common = new Common();
common.listen(gallery);
}
int first = gallery.getFirstVisiblePosition();
int last = gallery.getLastVisiblePosition();
int diff = last - first;
int delta = (diff / 2) + 1;
int from = selected - delta;
int to = selected + delta;
if(from < 0){
//shift window back to positive region
to = to - from;
from = 0;
}
if((position >= from && position <= to)){
//AQUtility.debug("yes", position + ":" + from + "." + to);
convertView.setTag(AQuery.TAG_NUM, position);
return false;
}
//AQUtility.debug("no", position + ":" + from + "." + to);
convertView.setTag(AQuery.TAG_NUM, null);
return true;
}
示例3: shouldDelayGallery
import android.widget.Gallery; //导入方法依赖的package包/类
private static boolean shouldDelayGallery(int position, View convertView,
ViewGroup parent, String url) {
if (url == null || BitmapAjaxCallback.isMemoryCached(url)) {
return false;
}
Gallery gallery = (Gallery) parent;
Integer selected = (Integer) gallery.getTag(Constants.TAG_NUM);
if (selected == null) {
selected = 0;
gallery.setTag(Constants.TAG_NUM, 0);
gallery.setCallbackDuringFling(false);
Common common = new Common();
common.listen(gallery);
}
int first = gallery.getFirstVisiblePosition();
int last = gallery.getLastVisiblePosition();
int diff = last - first;
int delta = (diff / 2) + 1;
int from = selected - delta;
int to = selected + delta;
if (from < 0) {
// shift window back to positive region
to = to - from;
from = 0;
}
if ((position >= from && position <= to)) {
// AQUtility.debug("yes", position + ":" + from + "." + to);
convertView.setTag(Constants.TAG_NUM, position);
return false;
}
// AQUtility.debug("no", position + ":" + from + "." + to);
convertView.setTag(Constants.TAG_NUM, null);
return true;
}