Tabnine Logo
FastAdapter.getItem
Code IndexAdd Tabnine to your IDE (free)

How to use
getItem
method
in
com.mikepenz.fastadapter.FastAdapter

Best Java code snippets using com.mikepenz.fastadapter.FastAdapter.getItem (Showing top 20 results out of 315)

origin: mikepenz/FastAdapter

/**
 * make sure we return the Item from the FastAdapter so we retrieve the item from all adapters
 *
 * @param position
 * @return
 */
public Item getItem(int position) {
  return mFastAdapter.getItem(position);
}
origin: mikepenz/FastAdapter

/**
 * @return a set with the global positions of all selected items (which are currently in the list (includes expanded expandable items))
 */
public Set<Integer> getSelections() {
  Set<Integer> selections = new ArraySet<>();
  for (int i = 0, size = mFastAdapter.getItemCount(); i < size; i++) {
    if (mFastAdapter.getItem(i).isSelected()) {
      selections.add(i);
    }
  }
  return selections;
}
origin: mikepenz/FastAdapter

/**
 * 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;
}
origin: mikepenz/FastAdapter

/**
 * make sure we return the Item from the FastAdapter so we retrieve the item from all adapters
 *
 * @param position
 * @return
 */
public Item getItem(int position) {
  return mFastAdapter.getItem(position);
}
origin: mikepenz/FastAdapter

@Override
public void withSavedInstanceState(@Nullable Bundle savedInstanceState, String prefix) {
  if (savedInstanceState == null) {
    return;
  }
  ArrayList<String> expandedItems = savedInstanceState.getStringArrayList(BUNDLE_EXPANDED + prefix);
  String id;
  for (int i = 0, size = mFastAdapter.getItemCount(); i < size; i++) {
    Item item = mFastAdapter.getItem(i);
    id = String.valueOf(item.getIdentifier());
    if (expandedItems != null && expandedItems.contains(id)) {
      expand(i);
      size = mFastAdapter.getItemCount();
    }
  }
}
origin: mikepenz/MaterialDrawer

/**
 * check if the item is within the bounds of the list
 *
 * @param position
 * @param includeOffset
 * @return
 */
protected boolean checkDrawerItem(int position, boolean includeOffset) {
  return getAdapter().getItem(position) != null;
}
origin: mikepenz/MaterialDrawer

/**
 * calculates the position of an drawerItem. searching by it's identifier
 *
 * @param identifier
 * @return
 */
public static int getPositionByIdentifier(DrawerBuilder drawer, long identifier) {
  if (identifier != -1) {
    for (int i = 0; i < drawer.getAdapter().getItemCount(); i++) {
      if (drawer.getAdapter().getItem(i).getIdentifier() == identifier) {
        return i;
      }
    }
  }
  return -1;
}
origin: mikepenz/MaterialDrawer

/**
 * get the drawerItem at a specific position
 *
 * @param position
 * @return
 */
protected IDrawerItem getDrawerItem(int position) {
  return (IDrawerItem) getAdapter().getItem(position);
}
origin: mikepenz/FastAdapter

@Override
public void saveInstanceState(Bundle savedInstanceState, String prefix) {
  if (savedInstanceState == null) {
    return;
  }
  ArrayList<String> expandedItems = new ArrayList<>();
  Item item;
  for (int i = 0, size = mFastAdapter.getItemCount(); i < size; i++) {
    item = mFastAdapter.getItem(i);
    if (item instanceof IExpandable && ((IExpandable) item).isExpanded()) {
      expandedItems.add(String.valueOf(item.getIdentifier()));
    }
  }
  //remember the collapsed states
  savedInstanceState.putStringArrayList(BUNDLE_EXPANDED + prefix, expandedItems);
}
origin: mikepenz/FastAdapter

/**
 * finds the int ItemId from the IItem which exists at the given position
 *
 * @param position the global position
 * @return the itemId for this position
 */
@Override
public long getItemId(int position) {
  return getItem(position).getIdentifier();
}
origin: mikepenz/FastAdapter

/**
 * returns the expanded items this contains position and the count of items
 * which are expanded by this position
 *
 * @return the expanded items
 */
public SparseIntArray getExpanded() {
  SparseIntArray expandedItems = new SparseIntArray();
  Item item;
  for (int i = 0, size = mFastAdapter.getItemCount(); i < size; i++) {
    item = mFastAdapter.getItem(i);
    if (item instanceof IExpandable && ((IExpandable) item).isExpanded()) {
      expandedItems.put(i, ((IExpandable) item).getSubItems().size());
    }
  }
  return expandedItems;
}
origin: mikepenz/FastAdapter

/**
 * finds the int ItemViewType from the IItem which exists at the given position
 *
 * @param position the global position
 * @return the viewType for this position
 */
@Override
public int getItemViewType(int position) {
  return getItem(position).getType();
}
origin: mikepenz/MaterialDrawer

/**
 * set the selection of the MiniDrawer
 *
 * @param identifier the identifier of the item which should be selected (-1 for none)
 */
public void setSelection(long identifier) {
  if (identifier == -1) {
    mAdapter.deselect();
  }
  int count = mAdapter.getItemCount();
  for (int i = 0; i < count; i++) {
    IDrawerItem item = mAdapter.getItem(i);
    if (item.getIdentifier() == identifier && !item.isSelected()) {
      mAdapter.deselect();
      mAdapter.select(i);
    }
  }
}
origin: mikepenz/FastAdapter

/**
 * deselects an item and removes its position in the selections list
 * also takes an iterator to remove items from the map
 *
 * @param position the global position
 * @param entries  the iterator which is used to deselect all
 */
public void deselect(int position, @Nullable Iterator<Integer> entries) {
  Item item = mFastAdapter.getItem(position);
  if (item == null) {
    return;
  }
  deselect(item, position, entries);
}
origin: mikepenz/FastAdapter

@Override
public void notifyAdapterItemRangeChanged(int position, int itemCount, Object payload) {
  for (int i = position; i < position + itemCount; i++) {
    Item item = mFastAdapter.getItem(position);
    if (item instanceof IExpandable && ((IExpandable) item).isExpanded()) {
      collapse(position);
    }
  }
}
origin: mikepenz/FastAdapter

/**
 * toggles the selection of the item at the given position
 *
 * @param position the global position
 */
public void toggleSelection(int position) {
  if (mFastAdapter.getItem(position).isSelected()) {
    deselect(position);
  } else {
    select(position);
  }
}
origin: mikepenz/FastAdapter

/**
 * toggles the expanded state of the given expandable item at the given position
 *
 * @param position the global position
 */
public void toggleExpandable(int position) {
  Item item = mFastAdapter.getItem(position);
  if (item instanceof IExpandable && ((IExpandable) item).isExpanded()) {
    collapse(position);
  } else {
    expand(position);
  }
}
origin: mikepenz/MaterialDrawer

private void notifySelect(int position, boolean fireOnClick) {
  if (fireOnClick && position >= 0) {
    IDrawerItem item = mDrawerBuilder.mAdapter.getItem(position);
    if (item instanceof AbstractDrawerItem && ((AbstractDrawerItem) item).getOnDrawerItemClickListener() != null) {
      ((AbstractDrawerItem) item).getOnDrawerItemClickListener().onItemClick(null, position, item);
    }
    if (mDrawerBuilder.mOnDrawerItemClickListener != null) {
      mDrawerBuilder.mOnDrawerItemClickListener.onItemClick(null, position, item);
    }
  }
  //we set the selection on a normal item in the drawer so we have to deselect the items in the StickyDrawer
  mDrawerBuilder.resetStickyFooterSelection();
}
origin: mikepenz/FastAdapter

@Test
public void getItem() throws Exception {
  List<TestItem> items = TestDataGenerator.genTestItemList(100);
  TestItem item = items.get(40);
  itemAdapter.set(items);
  assertThat(adapter.getItem(40)).isEqualTo(item);
}
origin: mikepenz/FastAdapter

@Test
public void getItem() throws Exception {
  List<TestItem> items = TestDataGenerator.genTestItemList(100);
  TestItem item = items.get(40);
  itemAdapter.set(items);
  assertThat(adapter.getItem(40)).isEqualTo(item);
}
com.mikepenz.fastadapterFastAdaptergetItem

Javadoc

gets the IItem by a position, from all registered adapters

Popular methods of FastAdapter

  • with
    creates a new FastAdapter with the provided adapters if adapters is null, a default ItemAdapter is d
  • getItemCount
    calculates the total ItemCount over all registered adapters
  • getExtension
  • getAdapter
    Gets the adapter for the given position
  • getPosition
    Searches for the given item and calculates its global position
  • getSelections
  • withSelectable
    Set to true if you want the items to be selectable. By default, no items are selectable
  • addExtension
  • getPreItemCountByOrder
    calculates the item count up to a given (excluding this) order number
  • getRelativeInfo
    Internal method to get the Item as ItemHolder which comes with the relative position within its adap
  • notifyItemChanged
  • saveInstanceState
    add the values to the bundle for saveInstanceState
  • notifyItemChanged,
  • saveInstanceState,
  • select,
  • withSavedInstanceState,
  • addAdapter,
  • getItemId,
  • getItemViewType,
  • getPreItemCount,
  • getSelectedItems

Popular in Java

  • Reading from database using SQL prepared statement
  • putExtra (Intent)
  • getResourceAsStream (ClassLoader)
  • runOnUiThread (Activity)
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • Path (java.nio.file)
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • JButton (javax.swing)
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now