当前位置: 首页>>代码示例>>Java>>正文


Java SectionIndexer.getSectionForPosition方法代码示例

本文整理汇总了Java中android.widget.SectionIndexer.getSectionForPosition方法的典型用法代码示例。如果您正苦于以下问题:Java SectionIndexer.getSectionForPosition方法的具体用法?Java SectionIndexer.getSectionForPosition怎么用?Java SectionIndexer.getSectionForPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.SectionIndexer的用法示例。


在下文中一共展示了SectionIndexer.getSectionForPosition方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findCurrentSectionPosition

import android.widget.SectionIndexer; //导入方法依赖的package包/类
int findCurrentSectionPosition(int fromPosition) {
	ListAdapter adapter = getAdapter();

	if (fromPosition >= adapter.getCount()) return -1; // dataset has changed, no candidate

	if (adapter instanceof SectionIndexer) {
		// try fast way by asking section indexer
		SectionIndexer indexer = (SectionIndexer) adapter;
		int sectionPosition = indexer.getSectionForPosition(fromPosition);
		int itemPosition = indexer.getPositionForSection(sectionPosition);
		int typeView = adapter.getItemViewType(itemPosition);
		if (isItemViewTypePinned(adapter, typeView)) {
			return itemPosition;
		} // else, no luck
	}

	// try slow way by looking through to the next section item above
	for (int position=fromPosition; position>=0; position--) {
		int viewType = adapter.getItemViewType(position);
		if (isItemViewTypePinned(adapter, viewType)) return position;
	}
	return -1; // no candidate found
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:PinnedSectionListView.java

示例2: findCurrentSectionPosition

import android.widget.SectionIndexer; //导入方法依赖的package包/类
int findCurrentSectionPosition(int fromPosition) {
	ListAdapter adapter = getAdapter();

	if (fromPosition >= adapter.getCount()) return -1; // dataset has changed, no candidate
	
	if (adapter instanceof SectionIndexer) {
		// try fast way by asking section indexer
		SectionIndexer indexer = (SectionIndexer) adapter;
		int sectionPosition = indexer.getSectionForPosition(fromPosition);
		int itemPosition = indexer.getPositionForSection(sectionPosition);
		int typeView = adapter.getItemViewType(itemPosition);
		if (isItemViewTypePinned(adapter, typeView)) {
			return itemPosition;
		} // else, no luck
	}

	// try slow way by looking through to the next section item above
	for (int position=fromPosition; position>=0; position--) {
		int viewType = adapter.getItemViewType(position);
		if (isItemViewTypePinned(adapter, viewType)) return position;
	}
	return -1; // no candidate found
}
 
开发者ID:lanyan520,项目名称:Idea-ChainSelector,代码行数:24,代码来源:PinnedSectionListView.java

示例3: findCurrentSectionPosition

import android.widget.SectionIndexer; //导入方法依赖的package包/类
int findCurrentSectionPosition(int fromPosition) {
  ListAdapter adapter = getAdapter();

  if (adapter instanceof SectionIndexer) {
    // try fast way by asking section indexer
    SectionIndexer indexer = (SectionIndexer) adapter;
    int sectionPosition = indexer.getSectionForPosition(fromPosition);
    int itemPosition = indexer.getPositionForSection(sectionPosition);
    int typeView = adapter.getItemViewType(itemPosition);
    if (isItemViewTypePinned(adapter, typeView)) {
      return itemPosition;
    } // else, no luck
  }

  // try slow way by looking through to the next section item above
  for (int position = fromPosition; position >= 0; position--) {
    int viewType = adapter.getItemViewType(position);
    if (isItemViewTypePinned(adapter, viewType)) return position;
  }
  return -1; // no candidate found
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:22,代码来源:PinnedSectionListView.java

示例4: findCurrentSectionPosition

import android.widget.SectionIndexer; //导入方法依赖的package包/类
int findCurrentSectionPosition(int fromPosition) {
	ListAdapter adapter = getAdapter();

	if (adapter instanceof SectionIndexer) {
		// try fast way by asking section indexer
		SectionIndexer indexer = (SectionIndexer) adapter;
		int sectionPosition = indexer.getSectionForPosition(fromPosition);
		int itemPosition = indexer.getPositionForSection(sectionPosition);
		int typeView = adapter.getItemViewType(itemPosition);
		if (isItemViewTypePinned(adapter, typeView)) {
			return itemPosition;
		} // else, no luck
	}

	// try slow way by looking through to the next section item above
	for (int position=Math.min(fromPosition,adapter.getCount()-1); position>=0; position--) {
		int viewType = adapter.getItemViewType(position);
		if (isItemViewTypePinned(adapter, viewType)) return position;
	}
	return -1; // no candidate found
}
 
开发者ID:mrprona92,项目名称:SecretBrand,代码行数:22,代码来源:PinnedSectionListView.java

示例5: findCurrentSectionPosition

import android.widget.SectionIndexer; //导入方法依赖的package包/类
int findCurrentSectionPosition(int fromPosition) {
    ListAdapter adapter = getAdapter();

    if (fromPosition >= adapter.getCount()) return -1; // dataset has changed, no candidate

    if (adapter instanceof SectionIndexer) {
        // try fast way by asking section indexer
        SectionIndexer indexer = (SectionIndexer) adapter;
        int sectionPosition = indexer.getSectionForPosition(fromPosition);
        int itemPosition = indexer.getPositionForSection(sectionPosition);
        int typeView = adapter.getItemViewType(itemPosition);
        if (isItemViewTypePinned(adapter, typeView)) {
            return itemPosition;
        } // else, no luck
    }

    // try slow way by looking through to the next section item above
    for (int position = fromPosition; position >= 0; position--) {
        int viewType = adapter.getItemViewType(position);
        if (isItemViewTypePinned(adapter, viewType)) return position;
    }
    return -1; // no candidate found
}
 
开发者ID:mzule,项目名称:AndroidWeekly,代码行数:24,代码来源:PinnedSectionListView.java

示例6: findCurrentSectionPosition

import android.widget.SectionIndexer; //导入方法依赖的package包/类
int findCurrentSectionPosition(int fromPosition) {
    ListAdapter adapter = getAdapter();

    if (adapter instanceof SectionIndexer) {
        // try fast way by asking section indexer
        SectionIndexer indexer = (SectionIndexer) adapter;
        int sectionPosition = indexer.getSectionForPosition(fromPosition);
        int itemPosition = indexer.getPositionForSection(sectionPosition);
        int typeView = adapter.getItemViewType(itemPosition);
        if (isItemViewTypePinned(adapter, typeView)) {
            return itemPosition;
        } // else, no luck
    }

    // try slow way by looking through to the next section item above
    for (int position = fromPosition; position >= 0; position--) {
        int viewType = adapter.getItemViewType(position);
        if (isItemViewTypePinned(adapter, viewType)) return position;
    }
    return -1; // no candidate found
}
 
开发者ID:BigAppOS,项目名称:BigApp_Discuz_Android,代码行数:22,代码来源:PinnedSectionListView.java

示例7: findCurrentSectionPosition

import android.widget.SectionIndexer; //导入方法依赖的package包/类
int findCurrentSectionPosition(int fromPosition) {
	ListAdapter adapter = getAdapter();

	if (adapter instanceof SectionIndexer) {
		// try fast way by asking section indexer
		SectionIndexer indexer = (SectionIndexer) adapter;
		int sectionPosition = indexer.getSectionForPosition(fromPosition);
		int itemPosition = indexer.getPositionForSection(sectionPosition);
		int typeView = adapter.getItemViewType(itemPosition);
		if (isItemViewTypePinned(adapter, typeView)) {
			return itemPosition;
		} // else, no luck
	}

	// try slow way by looking through to the next section item above
	for (int position=fromPosition; position>=0; position--) {
		int viewType = adapter.getItemViewType(position);
		if (isItemViewTypePinned(adapter, viewType)) return position;
	}
	return -1; // no candidate found
}
 
开发者ID:xulailing,项目名称:android-open-project-demo-master,代码行数:22,代码来源:PinnedSectionListView.java

示例8: findCurrentSectionPosition

import android.widget.SectionIndexer; //导入方法依赖的package包/类
int findCurrentSectionPosition(int fromPosition) {
	PinnedSectionGridAdapter adapter = getPinnedAdapter();

	if (adapter instanceof SectionIndexer) {
		// try fast way by asking section indexer
		SectionIndexer indexer = (SectionIndexer) adapter;
		int sectionPosition = indexer.getSectionForPosition(fromPosition);
		int itemPosition = indexer.getPositionForSection(sectionPosition);
		//int typeView = adapter.getItemViewType(itemPosition);
		if (isItemViewTypePinned(adapter, itemPosition)) {
			return itemPosition;
		} // else, no luck
	}

	// try slow way by looking through to the next section item above
	for (int position = fromPosition; position >= 0; position--) {
		//int viewType = adapter.getItemViewType(position);
		if (isItemViewTypePinned(adapter, position))
			return position;
	}
	return -1; // no candidate found
}
 
开发者ID:LeshiyGS,项目名称:shikimori,代码行数:23,代码来源:PinnedSectionGridView.java

示例9: findCurrentSectionPosition

import android.widget.SectionIndexer; //导入方法依赖的package包/类
int findCurrentSectionPosition(int fromPosition) {
	PinnedSectionListAdapter adapter = getPinnedAdapter();

	if (adapter instanceof SectionIndexer) {
		// try fast way by asking section indexer
		SectionIndexer indexer = (SectionIndexer) adapter;
		int sectionPosition = indexer.getSectionForPosition(fromPosition);
		int itemPosition = indexer.getPositionForSection(sectionPosition);
		//int typeView = adapter.getItemViewType(itemPosition);
		if (isItemViewTypePinned(adapter, itemPosition)) {
			return itemPosition;
		} // else, no luck
	}

	// try slow way by looking through to the next section item above
	for (int position = fromPosition; position >= 0; position--) {
		//int viewType = adapter.getItemViewType(position);
		if (isItemViewTypePinned(adapter, position))
			return position;
	}
	return -1; // no candidate found
}
 
开发者ID:LeshiyGS,项目名称:shikimori,代码行数:23,代码来源:PinnedSectionListView.java

示例10: findCurrentSectionPosition

import android.widget.SectionIndexer; //导入方法依赖的package包/类
int findCurrentSectionPosition(int fromPosition) {
	ListAdapter adapter = getAdapter();

	if (adapter instanceof SectionIndexer) {
		// try fast way by asking section indexer
		SectionIndexer indexer = (SectionIndexer) adapter;
		int sectionPosition = indexer.getSectionForPosition(fromPosition);
		int itemPosition = indexer.getPositionForSection(sectionPosition);
		int typeView = adapter.getItemViewType(itemPosition);
		if (isItemViewTypePinned(adapter, typeView)) {
			return itemPosition;
		} // else, no luck
	}

	// try slow way by looking through to the next section item above
	for (int position=fromPosition; position>=0; position--) {
		if(position >= adapter.getCount())break;//fix by bitjjj
		int viewType = adapter.getItemViewType(position);
		if (isItemViewTypePinned(adapter, viewType)) return position;
	}
	return -1; // no candidate found
}
 
开发者ID:bitjjj,项目名称:GameRecorder,代码行数:23,代码来源:PinnedSectionListView.java

示例11: findCurrentSectionPosition

import android.widget.SectionIndexer; //导入方法依赖的package包/类
private int findCurrentSectionPosition(int fromPosition) {
	PinnedSectionListAdapter adapter = (PinnedSectionListAdapter) getAdapter();

	if (adapter instanceof SectionIndexer) {
		// try fast way by asking section indexer
		SectionIndexer indexer = (SectionIndexer) adapter;
		int sectionPosition = indexer.getSectionForPosition(fromPosition);
		int itemPosition = indexer.getPositionForSection(sectionPosition);
		int typeView = adapter.getItemViewType(itemPosition);
		if (adapter.isItemViewTypePinned(typeView)) {
			return itemPosition;
		} // else, no luck
	}

	// try slow way by looking through to the next section item above
	for (int position=fromPosition; position>=0; position--) {
		int viewType = adapter.getItemViewType(position);
		if (adapter.isItemViewTypePinned(viewType)) return position;
	}
	return -1; // no candidate found
}
 
开发者ID:wefika,项目名称:pinned-section-listview,代码行数:22,代码来源:PinnedSectionListView.java

示例12: findCurrentSectionPosition

import android.widget.SectionIndexer; //导入方法依赖的package包/类
int findCurrentSectionPosition(int fromPosition) {
	ListAdapter adapter = getAdapter();

	// dataset has changed, no candidate
	if (fromPosition >= adapter.getCount()) {
		return -1;
	}

	if (adapter instanceof SectionIndexer) {
		// try fast way by asking section indexer
		SectionIndexer indexer = (SectionIndexer) adapter;
		int sectionPosition = indexer.getSectionForPosition(fromPosition);
		int itemPosition = indexer.getPositionForSection(sectionPosition);
		int typeView = adapter.getItemViewType(itemPosition);
		if (isItemViewTypePinned(adapter, typeView)) {
			return itemPosition;
		} // else, no luck
	}

	// try slow way by looking through to the next section item above
	for (int position = fromPosition; position >= 0; position--) {
		int viewType = adapter.getItemViewType(position);
		if (isItemViewTypePinned(adapter, viewType)) {
			return position;
		}
	}
	// no candidate found
	return -1;
}
 
开发者ID:kuastw,项目名称:KUAS-AP-Material,代码行数:30,代码来源:PinnedSectionListView.java


注:本文中的android.widget.SectionIndexer.getSectionForPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。