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

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

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

origin: mikepenz/FastAdapter

  @Override
  public void onSelectionChanged(SimpleItem item, boolean selected) {
    Log.i("FastAdapter", "SelectedCount: " + mFastAdapter.getSelections().size() + " ItemsCount: " + mFastAdapter.getSelectedItems().size());
  }
});
origin: mikepenz/FastAdapter

  @Override
  public boolean onClick(View v, IAdapter<SimpleItem> adapter, @NonNull SimpleItem item, int position) {
    Toast.makeText(v.getContext(), "SelectedCount: " + mFastAdapter.getSelections().size() + " ItemsCount: " + mFastAdapter.getSelectedItems().size(), Toast.LENGTH_SHORT).show();
    return false;
  }
});
origin: mikepenz/FastAdapter

@Override
public void saveInstanceState(@Nullable Bundle savedInstanceState, String prefix) {
  if (savedInstanceState == null) {
    return;
  }
  Set<Item> selections = mFastAdapter.getSelectedItems();
  long[] selectionsArray = new long[selections.size()];
  int i = 0;
  for (Item item : selections) {
    selectionsArray[i] = item.getIdentifier();
    i++;
  }
  //remember the selections
  savedInstanceState.putLongArray(BUNDLE_SELECTIONS + prefix, selectionsArray);
}
origin: mikepenz/FastAdapter

/**
 * helper method to get all selections from the ItemAdapter's original item list
 *
 * @return a Set with the selected items out of all items in this itemAdapter (not the listed ones)
 */
public Set<Item> getSelectedItems() {
  if (mOriginalItems != null) {
    Set<Item> selections = new HashSet<>();
    for (int i = 0, size = mOriginalItems.size(); i < size; i++) {
      Item item = mOriginalItems.get(i);
      if (item.isSelected()) {
        selections.add(item);
      }
    }
    return selections;
  } else {
    return mItemAdapter.getFastAdapter().getSelectedItems();
  }
}
origin: mikepenz/FastAdapter

@Test
public void select() throws Exception {
  adapter.withSelectable(true);
  itemAdapter.set(TestDataGenerator.genTestItemList(100));
  assertThat(adapter.getSelectedItems().size()).isEqualTo(0);
  assertThat(adapter.getSelections().size()).isEqualTo(0);
  adapter.select(10);
  assertThat(adapter.getSelectedItems().size()).isEqualTo(1);
  assertThat(adapter.getSelectedItems().iterator().next().getIdentifier()).isEqualTo(10);
  assertThat(adapter.getSelections().size()).isEqualTo(1);
  assertThat(adapter.getSelections().iterator().next()).isEqualTo(10);
}
com.mikepenz.fastadapterFastAdaptergetSelectedItems

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
  • 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
  • getRelativeInfo,
  • notifyItemChanged,
  • saveInstanceState,
  • select,
  • withSavedInstanceState,
  • addAdapter,
  • getItemId,
  • getItemViewType,
  • getPreItemCount

Popular in Java

  • Creating JSON documents from java classes using gson
  • runOnUiThread (Activity)
  • setScale (BigDecimal)
  • requestLocationUpdates (LocationManager)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • Top PhpStorm plugins
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