Class CustomListDialog<This extends CustomListDialog<This>>

java.lang.Object
androidx.fragment.app.Fragment
androidx.fragment.app.DialogFragment
eltos.simpledialogfragment.SimpleDialog<This>
eltos.simpledialogfragment.CustomViewDialog<This>
eltos.simpledialogfragment.list.CustomListDialog<This>
All Implemented Interfaces:
android.content.ComponentCallbacks, android.content.DialogInterface.OnCancelListener, android.content.DialogInterface.OnDismissListener, android.view.View.OnCreateContextMenuListener, android.widget.AdapterView.OnItemClickListener, android.widget.AdapterView.OnItemLongClickListener, androidx.activity.result.ActivityResultCaller, androidx.lifecycle.HasDefaultViewModelProviderFactory, androidx.lifecycle.LifecycleOwner, androidx.lifecycle.ViewModelStoreOwner, androidx.savedstate.SavedStateRegistryOwner
Direct Known Subclasses:
SimpleColorDialog, SimpleListDialog

public abstract class CustomListDialog<This extends CustomListDialog<This>> extends CustomViewDialog<This> implements android.widget.AdapterView.OnItemClickListener, android.widget.AdapterView.OnItemLongClickListener
A dialog that displays a list of items. MULTI_CHOICE and SINGLE_CHOICE modes are supported. Specify your custom adapter Result: SELECTED_POSITIONS Integer ArrayList selected item positions SELECTED_IDS Long[] selected item ids In SINGLE_CHOICE and SINGLE_CHOICE_DIRECT mode also: SELECTED_SINGLE_POSITION int selected item position SELECTED_SINGLE_ID long selected item id Created by eltos on 02.01.2017.
  • Field Details

  • Constructor Details

    • CustomListDialog

      public CustomListDialog()
  • Method Details

    • onCreateAdapter

      protected abstract AdvancedAdapter onCreateAdapter()
      Overwrite this method to provide a custom adapter
      Returns:
      the ListAdapter to use
    • choiceMode

      public This choiceMode(int mode)
      Sets the list choice mode
      Parameters:
      mode - one of NO_CHOICE, SINGLE_CHOICE, SINGLE_CHOICE_DIRECT or MULTI_CHOICE
      Returns:
      this instance
    • choiceMin

      public This choiceMin(int count)
      Sets the minimum required choices for the positive button to become enabled
      Parameters:
      count - the minimum required choices
      Returns:
      this instance
    • choiceMax

      public This choiceMax(int count)
      Sets the maximum allowed choices for the positive button to become enabled
      Parameters:
      count - the maximum allowed choices
      Returns:
      this instance
    • choicePreset

      public This choicePreset(List<Integer> positions)
      Sets the initially checked item positions
      Parameters:
      positions - the initially checked positions
      Returns:
      this instance
    • choicePreset

      public This choicePreset(int[] positions)
      Sets the initially checked item positions
      Parameters:
      positions - the initially checked positions
      Returns:
      this instance
    • choicePreset

      public This choicePreset(int position)
      Sets the initially checked item position
      Parameters:
      position - the initially checked position
      Returns:
      this instance
    • choiceIdPreset

      public This choiceIdPreset(List<Long> ids)
      Sets the initially checked items by their ids
      Parameters:
      ids - the initially checked item ids
      Returns:
      this instance
    • choiceIdPreset

      public This choiceIdPreset(long[] ids)
      Sets the initially checked items by their ids
      Parameters:
      ids - the initially checked item ids
      Returns:
      this instance
    • choiceIdPreset

      public This choiceIdPreset(long id)
      Sets the initially checked item by its id
      Parameters:
      id - the initially checked item id
      Returns:
      this instance
    • grid

      public This grid()
      Change the list into a grid list view (grid mode)
      Returns:
      this instance
    • gridNumColumn

      public This gridNumColumn(int numColumns)
      Specifies the number of columns of this grid view (only if in grid mode)
      Parameters:
      numColumns - the number of columns
      Returns:
      this instance
    • gridColumnWidth

      public This gridColumnWidth(@DimenRes int columnWidthDimenResId)
      Specifies the column with of this grid view (only if in grid mode)
      Parameters:
      columnWidthDimenResId - the with as an android dimension resource identifier
      Returns:
      this instance
    • divider

      public This divider(boolean show)
      Sets the visibility of the divider
      Parameters:
      show - whether to display a divider or not
      Returns:
      this instance
    • filterable

      public This filterable(boolean enabled)
      If set to true, show an input field at the to of the list and allow the user to filter the list
      Parameters:
      enabled - whether to allow filtering or not
      Returns:
      this instance
    • emptyText

      public This emptyText(CharSequence title)
      Sets a string to be displayed if no items are currently visible
      Parameters:
      title - the string to be displayed
      Returns:
      this instance
    • emptyText

      public This emptyText(@StringRes int titleResourceId)
      Sets a string to be displayed if no items are currently visible
      Parameters:
      titleResourceId - the android string resource to be displayed
      Returns:
      this instance
    • pos

      public This pos(CharSequence positiveButton)
      Description copied from class: SimpleDialog
      Sets this dialogs positive button text
      Overrides:
      pos in class SimpleDialog<This extends CustomListDialog<This>>
      Parameters:
      positiveButton - the text as string
      Returns:
      this instance
    • pos

      public This pos(int positiveButtonResourceId)
      Description copied from class: SimpleDialog
      Sets this dialogs positive button text
      Overrides:
      pos in class SimpleDialog<This extends CustomListDialog<This>>
      Parameters:
      positiveButtonResourceId - the text as android string resource
      Returns:
      this instance
    • onItemClick

      public void onItemClick(android.widget.AdapterView<?> parent, android.view.View view, int position, long id)
      Callback method to be invoked when an item in this AdapterView has been clicked. Implementers can call Adapter#getItem(position) if they need to access the data associated with the selected item.
      Specified by:
      onItemClick in interface android.widget.AdapterView.OnItemClickListener
      Parameters:
      parent - The AdapterView where the click happened.
      view - The view within the AdapterView that was clicked (this will be a view provided by the adapter)
      position - The position of the view in the adapter.
      id - The row id of the item that was clicked.
    • onItemLongClick

      public boolean onItemLongClick(android.widget.AdapterView<?> parent, android.view.View view, int position, long id)
      Callback method to be invoked when an item in this view has been clicked and held. Implementers can call Adapter#getItem(position) if they need to access the data associated with the selected item.
      Specified by:
      onItemLongClick in interface android.widget.AdapterView.OnItemLongClickListener
      Parameters:
      parent - The AbsListView where the click happened
      view - The view within the AbsListView that was clicked
      position - The position of the view in the list
      id - The row id of the item that was clicked
      Returns:
      true if the callback consumed the long click, false otherwise
    • onCreateContentView

      protected android.view.View onCreateContentView(android.os.Bundle savedInstanceState)
      Description copied from class: CustomViewDialog
      Inflate your custom view here.
      Specified by:
      onCreateContentView in class CustomViewDialog<This extends CustomListDialog<This>>
      Parameters:
      savedInstanceState - The last saved instance state of the Fragment, or null if this fragment is created for the first time.
      Returns:
      Return a new View to be displayed by the Fragment.
    • getListView

      protected android.widget.AbsListView getListView()
    • notifyDataSetChanged

      protected void notifyDataSetChanged()
    • onDialogShown

      protected void onDialogShown()
      Description copied from class: CustomViewDialog
      Overwrite this method to take action once the dialog is shown such as settings an input focus, showing the keyboard or setting the initial positiveButtonState
      Overrides:
      onDialogShown in class CustomViewDialog<This extends CustomListDialog<This>>
    • updatePosButton

      protected void updatePosButton()
    • onResult

      protected android.os.Bundle onResult(int which)
      Description copied from class: CustomViewDialog
      Overwrite this method to provide additional results from your custom view to be passed to the SimpleDialog.OnDialogResultListener.onResult(java.lang.String, int, android.os.Bundle)
      Overrides:
      onResult in class CustomViewDialog<This extends CustomListDialog<This>>
      Parameters:
      which - see SimpleDialog.OnDialogResultListener
      Returns:
      the bundle to merge with the results or null
    • onSaveInstanceState

      public void onSaveInstanceState(android.os.Bundle outState)
      Overrides:
      onSaveInstanceState in class androidx.fragment.app.DialogFragment