Klasse AdvancedAdapter<T>

java.lang.Object
android.widget.BaseAdapter
eltos.simpledialogfragment.list.AdvancedAdapter<T>
Alle implementierten Schnittstellen:
android.widget.Adapter, android.widget.Filterable, android.widget.ListAdapter, android.widget.SpinnerAdapter
Bekannte direkte Unterklassen:
AdvancedSectionAdapter, SimpleColorDialog.ColorAdapter

public abstract class AdvancedAdapter<T> extends android.widget.BaseAdapter implements android.widget.Filterable
Created by eltos on 04.12.2016.

This adapter keeps track of checked items even if they are currently not visible due to filtering.

When extending this class, note the following: - Set the underlying data set via setData(T[]) or setDataAndIds(T[], long[]) - Overwrite getView(int, android.view.View, android.view.ViewGroup). You can either return with the super-call, that will automatically care for the checked state if the View is an instance of Checkable or set checked state yourself by using isItemChecked(int) In your activity refer to the isItemChecked(int) and other functions to get checked items rather than using the functions of the ListView!

  • Felddetails

    • CHOICE_MODE_NONE

      public static final int CHOICE_MODE_NONE
      Siehe auch:
    • CHOICE_MODE_SINGLE

      public static final int CHOICE_MODE_SINGLE
      Siehe auch:
    • CHOICE_MODE_MULTIPLE

      public static final int CHOICE_MODE_MULTIPLE
      Siehe auch:
  • Konstruktordetails

    • AdvancedAdapter

      public AdvancedAdapter()
  • Methodendetails

    • setData

      public void setData(T[] list)
      Set this adapters data
      Parameter:
      list - a list of objects to be maintained by this adapter
    • setData

      public void setData(ArrayList<? extends T> list)
      Set this adapters data
      Parameter:
      list - an array-list of objects to be maintained by this adapter
    • setData

      public void setData(T[] list, AdvancedAdapter.ItemIdentifier<T> identifier)
      Set this adapters data and ids
      Parameter:
      list - a list of objects to be maintained by this adapter
      identifier - an Identifier returning a unique id for every item
    • setData

      public void setData(ArrayList<? extends T> list, AdvancedAdapter.ItemIdentifier<T> identifier)
      Set this adapters data and ids
      Parameter:
      list - an array-list of objects to be maintained by this adapter
      identifier - an Identifier returning a unique id for every item
    • setDataAndIds

      public void setDataAndIds(T[] list, long[] ids)
    • setDataAndIds

      public void setDataAndIds(ArrayList<androidx.core.util.Pair<T,Long>> list)
    • getData

      public ArrayList<T> getData()
      Get the data maintained by this adapter
      Gibt zurück:
      an array-list of the data
    • getFilter

      @Nullable public AdvancedAdapter<T>.AdvancedFilter getFilter()
      Overwrite this method to return your AdvancedFilter here
      Angegeben von:
      getFilter in Schnittstelle android.widget.Filterable
      Gibt zurück:
      an instance of AdvancedFilter for filtering data
    • setChoiceMode

      public void setChoiceMode(int choiceMode)
      Defines the choice behavior for the list. By default, lists do not have any choice behavior (CHOICE_MODE_NONE). By setting the choiceMode to CHOICE_MODE_SINGLE, the list allows up to one item to be checked Using CHOICE_MODE_MULTIPLE, any number of items may be checked.
      Parameter:
      choiceMode - One of CHOICE_MODE_NONE, CHOICE_MODE_SINGLE or CHOICE_MODE_MULTIPLE
    • getCount

      public int getCount()
      Angegeben von:
      getCount in Schnittstelle android.widget.Adapter
    • getItem

      public T getItem(int filteredPosition)
      Angegeben von:
      getItem in Schnittstelle android.widget.Adapter
    • getItemId

      public long getItemId(int filteredPosition)
      Angegeben von:
      getItemId in Schnittstelle android.widget.Adapter
    • setItemChecked

      public void setItemChecked(int filteredPosition, boolean checked)
    • toggleChecked

      public void toggleChecked(int filteredPosition)
    • setAllItemsChecked

      public void setAllItemsChecked(boolean checked)
    • setItemChecked

      public void setItemChecked(long id, boolean checked)
    • setItemsCheckedFromIds

      public void setItemsCheckedFromIds(ArrayList<Long> checkedItemIds)
    • setItemsCheckedFromIds

      public void setItemsCheckedFromIds(long[] checkedItemIds)
    • isItemChecked

      public boolean isItemChecked(int filteredPosition)
    • getCheckedItemCount

      public int getCheckedItemCount()
    • getCheckedItems

      public ArrayList<T> getCheckedItems()
    • getCheckedItemOriginalPositions

      public ArrayList<Integer> getCheckedItemOriginalPositions()
    • getCheckedItemIds

      public ArrayList<Long> getCheckedItemIds()
    • filterItems

      protected void filterItems()
    • highlight

      protected android.text.Spannable highlight(String text, android.content.Context context)
      Highlights everything that matched the current filter (if any) in text
      Parameter:
      text - the text to highlight
      context - a context to get the default highlight color from
      Gibt zurück:
      a spannable string
    • highlight

      protected android.text.Spannable highlight(String text, int color)
      Highlights everything that matched the current filter (if any) in text
      Parameter:
      text - the text to highlight
      color - the highlight color
      Gibt zurück:
      a spannable string
    • notifyDataSetChanged

      public void notifyDataSetChanged()
      Setzt außer Kraft:
      notifyDataSetChanged in Klasse android.widget.BaseAdapter
    • getView

      public android.view.View getView(int position, android.view.View convertView, android.view.ViewGroup parent)
      Angegeben von:
      getView in Schnittstelle android.widget.Adapter