本文整理汇总了Java中com.mikepenz.fastadapter.IItem类的典型用法代码示例。如果您正苦于以下问题:Java IItem类的具体用法?Java IItem怎么用?Java IItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IItem类属于com.mikepenz.fastadapter包,在下文中一共展示了IItem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: handleStates
import com.mikepenz.fastadapter.IItem; //导入依赖的package包/类
/**
* internal method which correctly set the selected state and expandable state on the newly added items
*
* @param fastAdapter the fastAdapter which manages everything
* @param startPosition the position of the first item to handle
* @param endPosition the position of the last item to handle
*/
public static <Item extends IItem> void handleStates(FastAdapter<Item> fastAdapter, int startPosition, int endPosition) {
for (int i = endPosition; i >= startPosition; i--) {
Item updateItem = fastAdapter.getItem(i);
if (updateItem != null) {
if (updateItem.isSelected()) {
fastAdapter.getSelections().add(i);
} else if (fastAdapter.getSelections().contains(i)) {
fastAdapter.getSelections().remove(i);
}
if (updateItem instanceof IExpandable) {
if (((IExpandable) updateItem).isExpanded() && fastAdapter.getExpanded().indexOfKey(i) < 0) {
fastAdapter.expand(i);
}
}
}
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:AdapterUtil.java
示例2: restoreSubItemSelectionStatesForAlternativeStateManagement
import com.mikepenz.fastadapter.IItem; //导入依赖的package包/类
/**
* internal method to restore the selection state of subItems
*
* @param item the parent item
* @param selectedItems the list of selectedItems from the savedInstanceState
*/
public static <Item extends IItem> void restoreSubItemSelectionStatesForAlternativeStateManagement(Item item, List<String> selectedItems) {
if (item instanceof IExpandable && !((IExpandable) item).isExpanded() && ((IExpandable) item).getSubItems() != null) {
List<Item> subItems = (List<Item>) ((IExpandable<Item, ?>) item).getSubItems();
Item subItem;
String id;
for (int i = 0, size = subItems.size(); i < size; i++) {
subItem = subItems.get(i);
id = String.valueOf(subItem.getIdentifier());
if (selectedItems != null && selectedItems.contains(id)) {
subItem.withSetSelected(true);
}
restoreSubItemSelectionStatesForAlternativeStateManagement(subItem, selectedItems);
}
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:AdapterUtil.java
示例3: findSubItemSelections
import com.mikepenz.fastadapter.IItem; //导入依赖的package包/类
/**
* internal method to find all selections from subItems and sub sub items so we can save those inside our savedInstanceState
*
* @param item the parent item
* @param selections the ArrayList which will be stored in the savedInstanceState
*/
public static <Item extends IItem> void findSubItemSelections(Item item, List<String> selections) {
if (item instanceof IExpandable && !((IExpandable) item).isExpanded() && ((IExpandable) item).getSubItems() != null) {
List<Item> subItems = (List<Item>) ((IExpandable<Item, ?>) item).getSubItems();
Item subItem;
String id;
for (int i = 0, size = subItems.size(); i < size; i++) {
subItem = subItems.get(i);
id = String.valueOf(subItem.getIdentifier());
if (subItem.isSelected()) {
selections.add(id);
}
findSubItemSelections(subItem, selections);
}
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:AdapterUtil.java
示例4: onBindHeaderViewHolder
import com.mikepenz.fastadapter.IItem; //导入依赖的package包/类
@Override
public void onBindHeaderViewHolder(RecyclerView.ViewHolder holder, int position) {
TextView textView = (TextView) holder.itemView;
IItem item = getItem(position);
if (item instanceof SimpleItem && ((SimpleItem) item).header != null) {
//based on the position we set the headers text
textView.setText(String.valueOf(((SimpleItem) item).header.charAt(0)));
} else if (item instanceof SimpleSubItem && ((SimpleSubItem) item).header != null) {
//based on the position we set the headers text
textView.setText(String.valueOf(((SimpleSubItem) item).header.charAt(0)));
} else if (item instanceof SimpleSubExpandableItem && ((SimpleSubExpandableItem) item).header != null) {
//based on the position we set the headers text
textView.setText(String.valueOf(((SimpleSubExpandableItem) item).header.charAt(0)));
}
holder.itemView.setBackgroundColor(getRandomColor());
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:StickyHeaderAdapter.java
示例5: onClick
import com.mikepenz.fastadapter.IItem; //导入依赖的package包/类
/**
* implements the basic behavior of a CAB and multi select behavior,
* including logics if the clicked item is collapsible
*
* @param act the current Activity
* @param item the current item
* @return null if nothing was done, or a boolean to inform if the event was consumed
*/
public Boolean onClick(AppCompatActivity act, IItem item) {
//if we are current in CAB mode, and we remove the last selection, we want to finish the actionMode
if (mActionMode != null && (mSupportSubItems ? SubItemUtil.getSelectedItems(mFastAdapter).size() == 1 : mFastAdapter.getSelections().size() == 1) && item.isSelected()) {
mActionMode.finish();
mFastAdapter.deselect();
return true;
}
if (mActionMode != null) {
// calculate the selection count for the action mode
// because current selection is not reflecting the future state yet!
int selected = mSupportSubItems ? SubItemUtil.getSelectedItems(mFastAdapter).size() : mFastAdapter.getSelections().size();
if (item.isSelected())
selected--;
else if (item.isSelectable())
selected++;
checkActionMode(act, selected);
}
return null;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:ActionModeHelper.java
示例6: updateViews
import com.mikepenz.fastadapter.IItem; //导入依赖的package包/类
public boolean updateViews(final Integer id) {
if (id != null) {
if (mFastItemAdapter != null) {
List<IItem> items = mFastItemAdapter.getAdapterItems();
int index = Util.indexOf(items, item -> item instanceof ISettingsItem && ((ISettingsItem) item).getSettings().checkId(id));
if (index != -1) {
mFastItemAdapter.notifyAdapterItemChanged(index);
return true;
}
}
} else {
// for (ISetting setting : mSettings)
// setting.init(mViews.get(setting.getParentId()), settData, global, this, this, this);
}
return false;
}
开发者ID:MFlisar,项目名称:RecyclerViewPreferences,代码行数:17,代码来源:SettingsFragment.java
示例7: getSettingItems
import com.mikepenz.fastadapter.IItem; //导入依赖的package包/类
private static List<IItem> getSettingItems(boolean global, Object customSettingsObject, ISetup setup, ISettCallback settingsCallback, List<SettingsGroup> groups, Set<Integer> collapsedIds,
boolean forceNoHeaders, Integer... settingGroupIds) {
// Setup
boolean addIfAnyParentIsInGroup = true;//setup.getSettingsStyle() != Setup.SettingsStyle.MultiLevelList;//global ? useViewPager : true;
boolean addTopHeaders = settingGroupIds.length > 1;
boolean showHeadersAsButtons = setup.getSettingsStyle() == Setup.SettingsStyle.MultiLevelList;
AtomicInteger headerId = new AtomicInteger(-2);
// Function
List<IItem> items = new ArrayList<>();
for (Integer settingGroupId : settingGroupIds) {
items.addAll(getSettingItems(global, customSettingsObject, setup, settingsCallback, null, groups, settingGroupId, addIfAnyParentIsInGroup, addTopHeaders, showHeadersAsButtons, headerId,
forceNoHeaders, collapsedIds));
}
return items;
}
开发者ID:MFlisar,项目名称:RecyclerViewPreferences,代码行数:17,代码来源:SettingsUtil.java
示例8: saveAllergies
import com.mikepenz.fastadapter.IItem; //导入依赖的package包/类
@OnClick(R.id.accept_selection_button)
void saveAllergies() {
acceptFab.setEnabled(false);
Intent returnIntent = new Intent();
final List<AbstractItem> selected = getSelected();
ArrayList<AllergenGroupWrapper> vos = new ArrayList<>();
for (IItem i : selected) {
switch (i.getType()) {
case R.id.fastadapter_allergen_group_sub_item:
final AllergenGroupSubItem item = (AllergenGroupSubItem) i;
vos.add(new AllergenGroupWrapper(item.getVo(), item.getParent().getTitle()));
break;
case R.id.fastadapter_allergen_item:
final AllergenItem item1 = (AllergenItem) i;
vos.add(new AllergenGroupWrapper(item1.getVo()));
break;
default:
LogUtil.wtf(TAG, "Invalid item type in adapter: " + i);
break;
}
}
returnIntent.putParcelableArrayListExtra("result", vos);
setResult(Activity.RESULT_OK, returnIntent);
finish();
}
开发者ID:citiususc,项目名称:calendula,代码行数:27,代码来源:AllergiesSearchActivity.java
示例9: getAllItems
import com.mikepenz.fastadapter.IItem; //导入依赖的package包/类
/**
* Gets all items (including sub items) from the FastAdapter
*
* @param fastAdapter the FastAdapter
* @return a list of all items including the whole subItem hirachy
*/
public static <Item extends IItem> List<Item> getAllItems(FastAdapter<Item> fastAdapter) {
int size = fastAdapter.getItemCount();
List<Item> items = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
Item item = fastAdapter.getItem(i);
items.add(item);
addAllSubItems(item, items);
}
return items;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:AdapterUtil.java
示例10: addAllSubItems
import com.mikepenz.fastadapter.IItem; //导入依赖的package包/类
/**
* Gets all subItems from a given parent item
*
* @param item the parent from which we add all items
* @param items the list in which we add the subItems
*/
public static <Item extends IItem> void addAllSubItems(Item item, List<Item> items) {
if (item instanceof IExpandable && !((IExpandable) item).isExpanded() && ((IExpandable) item).getSubItems() != null) {
List<Item> subItems = (List<Item>) ((IExpandable<Item, ?>) item).getSubItems();
Item subItem;
for (int i = 0, size = subItems.size(); i < size; i++) {
subItem = subItems.get(i);
items.add(subItem);
addAllSubItems(subItem, items);
}
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:AdapterUtil.java
示例11: onActionItemClicked
import com.mikepenz.fastadapter.IItem; //导入依赖的package包/类
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
// delete the selected items with the SubItemUtil to correctly handle sub items
// this will even delete empty headers if you want to
List<IItem> deleted = SubItemUtil.deleteSelected(fastItemAdapter, true, true);
//as we no longer have a selection so the actionMode can be finished
mode.finish();
//we consume the event
return true;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:ExpandableMultiselectDeleteSampleActivity.java
示例12: getCharacterForElement
import com.mikepenz.fastadapter.IItem; //导入依赖的package包/类
@Override
public Character getCharacterForElement(int position) {
IItem item = getItem(position);
if (item instanceof SimpleSubItem && ((SimpleSubItem) item).name != null) {
//based on the position we set the headers text
return ((SimpleSubItem) item).name.getText().charAt(0);
}
return ' ';
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:FastScrollIndicatorAdapter.java
示例13: getCustomStringForElement
import com.mikepenz.fastadapter.IItem; //导入依赖的package包/类
@Override
public String getCustomStringForElement(int position) {
IItem item = getItem(position);
if (item instanceof GenericIconItem && ((GenericIconItem) item).getModel().icon.getName() != null) {
//based on the position we set the headers text
return ((GenericIconItem) item).getModel().icon.getName();
}
return "";
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:FastScrollIndicatorAdapter.java
示例14: getHeaderId
import com.mikepenz.fastadapter.IItem; //导入依赖的package包/类
@Override
public long getHeaderId(int position) {
IItem item = getItem(position);
//in our sample we want a separate header per first letter of our items
//this if is not necessary for your code, we only use it as this sticky header is reused for different item implementations
if (item instanceof SimpleItem && ((SimpleItem) item).header != null) {
return ((SimpleItem) item).header.charAt(0);
} else if (item instanceof SimpleSubItem && ((SimpleSubItem) item).header != null) {
return ((SimpleSubItem) item).header.charAt(0);
} else if (item instanceof SimpleSubExpandableItem && ((SimpleSubExpandableItem) item).header != null) {
return ((SimpleSubExpandableItem) item).header.charAt(0);
}
return -1;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:StickyHeaderAdapter.java
示例15: selectRange
import com.mikepenz.fastadapter.IItem; //导入依赖的package包/类
/**
* selects all items in a range, from and to indizes are inclusive
*
* @param from the from index
* @param to the to index
* @param select true, if the provided range should be selected, false otherwise
* @param skipHeaders true, if you do not want to process headers, false otherwise
*/
public <T extends IItem & IExpandable> void selectRange(int from, int to, boolean select, boolean skipHeaders) {
if (from > to) {
int temp = from;
from = to;
to = temp;
}
IItem item;
for (int i = from; i <= to; i++) {
item = mFastAdapter.getAdapterItem(i);
if (item.isSelectable()) {
if (select) {
mFastAdapter.select(i);
} else {
mFastAdapter.deselect(i);
}
}
if (mSupportSubItems && !skipHeaders) {
// if a group is collapsed, select all sub items
if (item instanceof IExpandable && !((IExpandable)item).isExpanded()) {
SubItemUtil.selectAllSubItems(mFastAdapter, (T) mFastAdapter.getAdapterItem(i), select, true, mPayload);
}
}
}
if (mActionModeHelper != null) {
mActionModeHelper.checkActionMode(null); // works with null as well, as the ActionMode is active for sure!
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:38,代码来源:RangeSelectorHelper.java
示例16: getSelectedItems
import com.mikepenz.fastadapter.IItem; //导入依赖的package包/类
/**
* returns a set of selected items, regardless of their visibility
*
* @param adapter the adapter instance
* @return a set of all selected items and subitems
*/
public static Set<IItem> getSelectedItems(FastAdapter adapter) {
Set<IItem> selections = new HashSet<>();
int length = adapter.getItemCount();
List<IItem> items = new ArrayList<>();
for (int i = 0; i < length; i++) {
items.add(adapter.getItem(i));
}
updateSelectedItemsWithCollapsed(selections, items);
return selections;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:SubItemUtil.java
示例17: updateSelectedItemsWithCollapsed
import com.mikepenz.fastadapter.IItem; //导入依赖的package包/类
private static void updateSelectedItemsWithCollapsed(Set<IItem> selected, List<IItem> items) {
int length = items.size();
for (int i = 0; i < length; i++) {
if (items.get(i).isSelected()) {
selected.add(items.get(i));
}
if (items.get(i) instanceof IExpandable && ((IExpandable) items.get(i)).getSubItems() != null) {
updateSelectedItemsWithCollapsed(selected, ((IExpandable) items.get(i)).getSubItems());
}
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:SubItemUtil.java
示例18: countSelectedSubItems
import com.mikepenz.fastadapter.IItem; //导入依赖的package包/类
public static <T extends IItem & IExpandable> int countSelectedSubItems(Set<IItem> selections, T header) {
int count = 0;
List<IItem> subItems = header.getSubItems();
int items = header.getSubItems() != null ? header.getSubItems().size() : 0;
for (int i = 0; i < items; i++) {
if (selections.contains(subItems.get(i))) {
count++;
}
if (subItems.get(i) instanceof IExpandable && ((IExpandable) subItems.get(i)).getSubItems() != null) {
count += countSelectedSubItems(selections, (T) subItems.get(i));
}
}
return count;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:SubItemUtil.java
示例19: selectAllSubItems
import com.mikepenz.fastadapter.IItem; //导入依赖的package包/类
/**
* select or unselect all sub itmes underneath an expandable item
*
* @param adapter the adapter instance
* @param header the header who's children should be selected or deselected
* @param select the new selected state of the sub items
* @param notifyParent true, if the parent should be notified about the changes of its children selection state
* @param payload payload for the notifying function
*/
public static <T extends IItem & IExpandable> void selectAllSubItems(final FastAdapter adapter, T header, boolean select, boolean notifyParent, Object payload) {
int subItems = header.getSubItems().size();
int position = adapter.getPosition(header);
if (header.isExpanded()) {
for (int i = 0; i < subItems; i++) {
if (((IItem)header.getSubItems().get(i)).isSelectable()) {
if (select) {
adapter.select(position + i + 1);
} else {
adapter.deselect(position + i + 1);
}
}
if (header.getSubItems().get(i) instanceof IExpandable)
selectAllSubItems(adapter, header, select, notifyParent, payload);
}
} else {
for (int i = 0; i < subItems; i++) {
if (((IItem)header.getSubItems().get(i)).isSelectable()) {
((IItem) header.getSubItems().get(i)).withSetSelected(select);
}
if (header.getSubItems().get(i) instanceof IExpandable)
selectAllSubItems(adapter, header, select, notifyParent, payload);
}
}
// we must notify the view only!
if (notifyParent && position >= 0) {
adapter.notifyItemChanged(position, payload);
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:41,代码来源:SubItemUtil.java
示例20: getParent
import com.mikepenz.fastadapter.IItem; //导入依赖的package包/类
private static <T extends IExpandable & IItem> T getParent(IItem item) {
if (item instanceof ISubItem) {
return (T) ((ISubItem) item).getParent();
}
return null;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:SubItemUtil.java
注:本文中的com.mikepenz.fastadapter.IItem类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论