congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
FastAdapter.getExtension
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: mikepenz/FastAdapter

public ActionModeHelper(FastAdapter<Item> fastAdapter, int cabMenu, ActionMode.Callback callback) {
  this.mFastAdapter = fastAdapter;
  this.mCabMenu = cabMenu;
  this.mCallback = callback;
  this.mInternalCallback = new ActionBarCallBack();
  this.mSelectExtension = fastAdapter.getExtension(SelectExtension.class);
  if (mSelectExtension == null) {
    throw new IllegalStateException("The provided FastAdapter requires the `SelectExtension` or `withSelectable(true)`");
  }
}
origin: mikepenz/FastAdapter

public ActionModeHelper(FastAdapter<Item> fastAdapter, int cabMenu, ActionItemClickedListener actionItemClickedListener) {
  this.mFastAdapter = fastAdapter;
  this.mCabMenu = cabMenu;
  this.mInternalCallback = new ActionBarCallBack();
  this.actionItemClickedListener = actionItemClickedListener;
  this.mSelectExtension = fastAdapter.getExtension(SelectExtension.class);
  if (mSelectExtension == null) {
    throw new IllegalStateException("The provided FastAdapter requires the `SelectExtension` or `withSelectable(true)`");
  }
}
origin: mikepenz/FastAdapter

/**
 * Uses Reflection to collapse all items if this adapter uses expandable items
 *
 * @param fastAdapter
 */
private static void collapseIfPossible(FastAdapter fastAdapter) {
  try {
    Class c = Class.forName("com.mikepenz.fastadapter.expandable.ExpandableExtension");
    if (c != null) {
      IAdapterExtension extension = fastAdapter.getExtension(c);
      if (extension != null) {
        Method method = extension.getClass().getMethod("collapse");
        method.invoke(extension);
      }
    }
  } catch (Exception ignored) {
    //
  }
}
origin: mikepenz/FastAdapter

  @Override
  public boolean apply(@NonNull IAdapter lastParentAdapter, int lastParentPosition, @NonNull IItem item, int position) {
    if (position != -1) {
      SelectExtension extension = (SelectExtension) adapter.getExtension(SelectExtension.class);
      if (extension != null) {
        extension.deselect(position);
      }
    } else {
      item.withSetSelected(false);
    }
    return true;
  }
}, false);
origin: mikepenz/FastAdapter

/**
 * counts the selected items in the adapter underneath an expandable item, recursively
 *
 * @param adapter the adapter instance
 * @param header  the header who's selected children should be counted
 * @return number of selected items underneath the header
 */
public static <T extends IItem & IExpandable> int countSelectedSubItems(final FastAdapter adapter, T header) {
  SelectExtension extension = (SelectExtension) adapter.getExtension(SelectExtension.class);
  if (extension != null) {
    Set<IItem> selections = extension.getSelectedItems();
    return countSelectedSubItems(selections, header);
  }
  return 0;
}
origin: mikepenz/MaterialDrawer

public boolean setSelectionAtPosition(int position, boolean fireOnClick) {
  if (mDrawerBuilder.mRecyclerView != null) {
    SelectExtension<IDrawerItem> select = getAdapter().getExtension(SelectExtension.class);
    if (select != null) {
      select.deselect();
      select.select(position, false);
      notifySelect(position, fireOnClick);
    }
  }
  return false;
}
origin: mikepenz/FastAdapter

/**
 * deselects all selections
 */
public void deselect() {
  SelectExtension<Item> selectExtension = mFastAdapter.getExtension(SelectExtension.class);
  if (selectExtension == null) {
    return;
  }
  for (Item item : AdapterUtil.getAllItems(mFastAdapter)) {
    selectExtension.deselect(item);
  }
  mFastAdapter.notifyDataSetChanged();
}
origin: mikepenz/FastAdapter

/**
 * select all items
 *
 * @param considerSelectableFlag true if the select method should not select an item if its not selectable
 */
public void select(boolean considerSelectableFlag) {
  SelectExtension<Item> selectExtension = mFastAdapter.getExtension(SelectExtension.class);
  if (selectExtension == null) {
    return;
  }
  for (Item item : AdapterUtil.getAllItems(mFastAdapter)) {
    selectExtension.select(item, considerSelectableFlag);
  }
  mFastAdapter.notifyDataSetChanged();
}
origin: mikepenz/FastAdapter

  @Override
  public boolean apply(@NonNull IAdapter lastParentAdapter, int lastParentPosition, @NonNull IItem item, int position) {
    if (item.getIdentifier() == identifier) {
      if (position != -1) {
        SelectExtension extension = (SelectExtension) adapter.getExtension(SelectExtension.class);
        if (extension != null) {
          if (select) {
            extension.select(position);
          } else {
            extension.deselect(position);
          }
        }
      } else {
        item.withSetSelected(select);
      }
      return true;
    }
    return false;
  }
}, true);
origin: mikepenz/FastAdapter

@Test
public void select() throws Exception {
  itemAdapter.set(TestDataGenerator.genTestItemList(100));
  SelectExtension<TestItem> selectExtension = adapter.getExtension(SelectExtension.class);
  assertThat(selectExtension).isEqualTo(this.selectExtension);
  assertThat(selectExtension.getSelectedItems().size()).isEqualTo(0);
  assertThat(selectExtension.getSelections().size()).isEqualTo(0);
  selectExtension.select(10);
  assertThat(selectExtension.getSelectedItems().size()).isEqualTo(1);
  assertThat(selectExtension.getSelectedItems().iterator().next().getIdentifier()).isEqualTo(10);
  assertThat(selectExtension.getSelections().size()).isEqualTo(1);
  assertThat(selectExtension.getSelections().iterator().next()).isEqualTo(10);
}
origin: mikepenz/MaterialDrawer

/**
 * set the current selection in the drawer
 * NOTE: This will trigger onDrawerItemSelected without a view if you pass fireOnClick = true;
 *
 * @param identifier  the identifier to search for
 * @param fireOnClick true if the click listener should be called
 */
public void setSelection(long identifier, boolean fireOnClick) {
  SelectExtension<IDrawerItem> select = getAdapter().getExtension(SelectExtension.class);
  if (select != null) {
    select.deselect();
    select.selectByIdentifier(identifier, false, true);
    //we also have to call the general notify
    Pair<IDrawerItem, Integer> res = getAdapter().getItemById(identifier);
    if (res != null) {
      Integer position = res.second;
      notifySelect(position != null ? position : -1, fireOnClick);
    }
  }
}
origin: mikepenz/FastAdapter

for (int i = 0; i < subItems; i++) {
  if (((IItem) header.getSubItems().get(i)).isSelectable()) {
    SelectExtension extension = (SelectExtension) adapter.getExtension(SelectExtension.class);
    if (extension != null) {
      if (select) {
origin: mikepenz/FastAdapter

mFastAdapter.withMultiSelect(true);
mFastAdapter.withSelectOnLongClick(false);
selectExtension = mFastAdapter.getExtension(SelectExtension.class);
com.mikepenz.fastadapterFastAdaptergetExtension

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
  • 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

  • Creating JSON documents from java classes using gson
  • notifyDataSetChanged (ArrayAdapter)
  • getSystemService (Context)
  • scheduleAtFixedRate (Timer)
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • LinkedHashMap (java.util)
    LinkedHashMap is an implementation of Map that guarantees iteration order. All optional operations a
  • Join (org.hibernate.mapping)
  • Top 17 Free Sublime Text Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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