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


Java SectionIndexer类代码示例

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


SectionIndexer类属于android.widget包,在下文中一共展示了SectionIndexer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getPositionForSection

import android.widget.SectionIndexer; //导入依赖的package包/类
@Override
public int getPositionForSection(int section) {
    int position = 0;

    for (ListAdapter piece : getPieces()) {
        if (piece instanceof SectionIndexer) {
            Object[] sections = ((SectionIndexer) piece).getSections();
            int numSections = 0;

            if (sections != null) {
                numSections = sections.length;
            }

            if (section < numSections) {
                return (position + ((SectionIndexer) piece).getPositionForSection(section));
            } else if (sections != null) {
                section -= numSections;
            }
        }

        position += piece.getCount();
    }

    return (0);
}
 
开发者ID:Twelvelines,项目名称:AndroidMuseumBleManager,代码行数:26,代码来源:MergeAdapter.java

示例3: getSections

import android.widget.SectionIndexer; //导入依赖的package包/类
@Override
public Object[] getSections() {
    ArrayList<Object> sections = new ArrayList<Object>();

    for (ListAdapter piece : getPieces()) {
        if (piece instanceof SectionIndexer) {
            Object[] curSections = ((SectionIndexer) piece).getSections();

            if (curSections != null) {
                Collections.addAll(sections, curSections);
            }
        }
    }

    if (sections.size() == 0) {
        return (new String[0]);
    }

    return (sections.toArray(new Object[0]));
}
 
开发者ID:Twelvelines,项目名称:AndroidMuseumBleManager,代码行数:21,代码来源:MergeAdapter.java

示例4: findCurrentSectionPosition

import android.widget.SectionIndexer; //导入依赖的package包/类
private int findCurrentSectionPosition(int fromPosition) {
    PinnedSectionListAdapter adapter = (PinnedSectionListAdapter) getAdapter();
    if (adapter instanceof SectionIndexer) {
        SectionIndexer indexer = (SectionIndexer) adapter;
        int itemPosition = indexer.getPositionForSection(indexer.getSectionForPosition
                (fromPosition));
        if (adapter.isItemViewTypePinned(adapter.getItemViewType(itemPosition))) {
            return itemPosition;
        }
    }
    for (int position = fromPosition; position >= 0; position--) {
        if (adapter.isItemViewTypePinned(adapter.getItemViewType(position))) {
            return position;
        }
    }
    return -1;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:18,代码来源: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:lanyan520,项目名称:Idea-ChainSelector,代码行数: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:nordfalk,项目名称:EsperantoRadio,代码行数:22,代码来源:PinnedSectionListView.java

示例7: getPositionForSection

import android.widget.SectionIndexer; //导入依赖的package包/类
public int getPositionForSection(int section) {
    int position = 0;

    for (ListAdapter piece : pieces) {
        if (piece instanceof SectionIndexer) {
            Object[] sections = ((SectionIndexer) piece).getSections();
            int numSections = 0;

            if (sections != null) {
                numSections = sections.length;
            }

            if (section < numSections) {
                return (position + ((SectionIndexer) piece)
                        .getPositionForSection(section));
            } else if (sections != null) {
                section -= numSections;
            }
        }

        position += piece.getCount();
    }

    return (0);
}
 
开发者ID:wade-fs,项目名称:MediaManager,代码行数:26,代码来源:MergeAdapter.java

示例8: getSections

import android.widget.SectionIndexer; //导入依赖的package包/类
public Object[] getSections() {
    ArrayList<Object> sections = new ArrayList<>();

    for (ListAdapter piece : pieces) {
        if (piece instanceof SectionIndexer) {
            Object[] curSections = ((SectionIndexer) piece).getSections();

            if (curSections != null) {
                Collections.addAll(sections, curSections);
            }
        }
    }

    if (sections.size() == 0) {
        return (null);
    }

    return (sections.toArray(new Object[sections.size()]));
}
 
开发者ID:wade-fs,项目名称:MediaManager,代码行数:20,代码来源:MergeAdapter.java

示例9: getPositionForSection

import android.widget.SectionIndexer; //导入依赖的package包/类
public int getPositionForSection(int section) {
    int position = 0;

    ListAdapter piece;
    for (Iterator i$ = this.getPieces().iterator(); i$.hasNext(); position += piece.getCount()) {
        piece = (ListAdapter) i$.next();
        if (piece instanceof SectionIndexer) {
            Object[] sections = ((SectionIndexer) piece).getSections();
            int numSections = 0;
            if (sections != null) {
                numSections = sections.length;
            }

            if (section < numSections) {
                return position + ((SectionIndexer) piece).getPositionForSection(section);
            }

            if (sections != null) {
                section -= numSections;
            }
        }
    }

    return 0;
}
 
开发者ID:xiaoyaoyou1212,项目名称:BLE,代码行数:26,代码来源:MergeAdapter.java

示例10: getSectionForPosition

import android.widget.SectionIndexer; //导入依赖的package包/类
public int getSectionForPosition(int position) {
    int section = 0;

    int size;
    for (Iterator i$ = this.getPieces().iterator(); i$.hasNext(); position -= size) {
        ListAdapter piece = (ListAdapter) i$.next();
        size = piece.getCount();
        if (position < size) {
            if (piece instanceof SectionIndexer) {
                return section + ((SectionIndexer) piece).getSectionForPosition(position);
            }

            return 0;
        }

        if (piece instanceof SectionIndexer) {
            Object[] sections = ((SectionIndexer) piece).getSections();
            if (sections != null) {
                section += sections.length;
            }
        }
    }

    return 0;
}
 
开发者ID:xiaoyaoyou1212,项目名称:BLE,代码行数:26,代码来源:MergeAdapter.java

示例11: getSections

import android.widget.SectionIndexer; //导入依赖的package包/类
public Object[] getSections() {
    ArrayList sections = new ArrayList();
    Iterator i$ = this.getPieces().iterator();

    while (i$.hasNext()) {
        ListAdapter piece = (ListAdapter) i$.next();
        if (piece instanceof SectionIndexer) {
            Object[] curSections = ((SectionIndexer) piece).getSections();
            if (curSections != null) {
                Collections.addAll(sections, curSections);
            }
        }
    }

    if (sections.size() == 0) {
        return new String[0];
    } else {
        return sections.toArray(new Object[sections.size()]);
    }
}
 
开发者ID:xiaoyaoyou1212,项目名称:BLE,代码行数:21,代码来源:MergeAdapter.java

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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