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

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

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

origin: mikepenz/FastAdapter

  @Override
  public boolean onTouch(View v, MotionEvent event, int position, FastAdapter<Item> fastAdapter, Item item) {
    boolean consumed = false;
    // handle our extensions
    for (IAdapterExtension<Item> ext : fastAdapter.mExtensions.values()) {
      if (!consumed) {
        consumed = ext.onTouch(v, event, position, fastAdapter, item);
      } else {
        break;
      }
    }
    if (fastAdapter.mOnTouchListener != null) {
      IAdapter<Item> adapter = fastAdapter.getAdapter(position);
      if (adapter != null) {
        return fastAdapter.mOnTouchListener.onTouch(v, event, adapter, item, position);
      }
    }
    return consumed;
  }
};
origin: mikepenz/FastAdapter

  @Override
  public boolean onLongClick(View v, int pos, FastAdapter<Item> fastAdapter, Item item) {
    boolean consumed = false;
    IAdapter<Item> adapter = fastAdapter.getAdapter(pos);
    if (adapter != null && item != null && item.isEnabled()) {
      //first call the OnPreLongClickListener which would allow to prevent executing of any following code, including selection
      if (fastAdapter.mOnPreLongClickListener != null) {
        consumed = fastAdapter.mOnPreLongClickListener.onLongClick(v, adapter, item, pos);
      }
      // handle our extensions
      for (IAdapterExtension<Item> ext : fastAdapter.mExtensions.values()) {
        if (!consumed) {
          consumed = ext.onLongClick(v, pos, fastAdapter, item);
        } else {
          break;
        }
      }
      //call the normal long click listener after selection was handled
      if (!consumed && fastAdapter.mOnLongClickListener != null) {
        consumed = fastAdapter.mOnLongClickListener.onLongClick(v, adapter, item, pos);
      }
    }
    return consumed;
  }
};
origin: mikepenz/FastAdapter

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

/**
 * notifies the fastAdapter about new / removed items within a sub hierarchy
 * NOTE this currently only works for sub items with only 1 level
 *
 * @param position      the global position of the parent item
 * @param previousCount the previous count of sub items
 * @return the new count of subItems
 */
public int notifyAdapterSubItemsChanged(int position, int previousCount) {
  Item item = mFastAdapter.getItem(position);
  if (item != null && item instanceof IExpandable) {
    IExpandable expandable = (IExpandable) item;
    IAdapter adapter = mFastAdapter.getAdapter(position);
    if (adapter != null && adapter instanceof IItemAdapter) {
      ((IItemAdapter) adapter).removeRange(position + 1, previousCount);
      ((IItemAdapter) adapter).add(position + 1, expandable.getSubItems());
    }
    return expandable.getSubItems().size();
  }
  return 0;
}
origin: mikepenz/FastAdapter

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

IAdapter adapter = fastAdapter.getAdapter(pos);
boolean success = false;
if (adapter instanceof IItemAdapter) {
origin: mikepenz/FastAdapter

IAdapter adapter = fastAdapter.getAdapter(pos);
boolean success = false;
if (adapter instanceof IItemAdapter) {
origin: mikepenz/FastAdapter

/**
 * opens the expandable item at the given position
 *
 * @param position          the global position
 * @param notifyItemChanged true if we need to call notifyItemChanged. DEFAULT: false
 */
public void expand(int position, boolean notifyItemChanged) {
  Item item = mFastAdapter.getItem(position);
  if (item != null && item instanceof IExpandable) {
    IExpandable expandable = (IExpandable) item;
    //if this item is not already expanded and has sub items we go on
    if (!expandable.isExpanded() && expandable.getSubItems() != null && expandable.getSubItems().size() > 0) {
      IAdapter<Item> adapter = mFastAdapter.getAdapter(position);
      if (adapter != null && adapter instanceof IItemAdapter) {
        ((IItemAdapter<?, Item>) adapter).addInternal(position + 1, expandable.getSubItems());
      }
      //remember that this item is now opened (not collapsed)
      expandable.withIsExpanded(true);
      //we need to notify to get the correct drawable if there is one showing the current state
      if (notifyItemChanged) {
        mFastAdapter.notifyItemChanged(position);
      }
    }
  }
}
origin: mikepenz/FastAdapter

IAdapter adapter = mFastAdapter.getAdapter(position);
if (adapter != null && adapter instanceof IItemAdapter) {
  ((IItemAdapter) adapter).removeRange(position + 1, expandedItemsCount[0]);
origin: mikepenz/FastAdapter

@Override
public void onClick(View v, int pos, FastAdapter<Item> fastAdapter, Item item) {
  IAdapter<Item> adapter = fastAdapter.getAdapter(pos);
  if (adapter != null && item != null && item.isEnabled()) {
    boolean consumed = false;
com.mikepenz.fastadapterFastAdaptergetAdapter

Javadoc

Gets the adapter for the given position

Popular methods of FastAdapter

  • with
    creates a new FastAdapter with the provided adapters if adapters is null, a default ItemAdapter is d
  • getItem
    gets the IItem by a position, from all registered adapters
  • getItemCount
    calculates the total ItemCount over all registered adapters
  • getExtension
  • 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)
  • CodeWhisperer alternatives
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