當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。