public class DropdownChipLayouter extends Object
Modifier and Type | Class and Description |
---|---|
static class |
DropdownChipLayouter.AdapterType
The type of adapter that is requesting a chip layout.
|
static interface |
DropdownChipLayouter.ChipDeleteListener |
static interface |
DropdownChipLayouter.PermissionRequestDismissedListener
Listener that handles the dismisses of the entries of the
RecipientEntry.ENTRY_TYPE_PERMISSION_REQUEST type. |
protected class |
DropdownChipLayouter.ViewHolder
A holder class the view.
|
Constructor and Description |
---|
DropdownChipLayouter(LayoutInflater inflater,
Context context) |
Modifier and Type | Method and Description |
---|---|
protected void |
bindDrawableToDeleteView(StateListDrawable drawable,
String recipient,
ImageView view) |
protected void |
bindIconToView(boolean showImage,
RecipientEntry entry,
ImageView view,
DropdownChipLayouter.AdapterType type)
Binds the avatar icon to the image view.
|
protected void |
bindIndicatorToView(int indicatorIconId,
String indicatorText,
TextView view) |
protected void |
bindPermissionRequestDismissView(ImageView view) |
protected void |
bindTextToView(CharSequence text,
TextView view)
Binds the text to the given text view.
|
View |
bindView(View convertView,
ViewGroup parent,
RecipientEntry entry,
int position,
DropdownChipLayouter.AdapterType type,
String constraint)
Layouts and binds recipient information to the view.
|
View |
bindView(View convertView,
ViewGroup parent,
RecipientEntry entry,
int position,
DropdownChipLayouter.AdapterType type,
String constraint,
StateListDrawable deleteDrawable)
|
protected int |
getAlternateItemLayoutResId(DropdownChipLayouter.AdapterType type)
Returns a layout id for each item inside alternate auto-complete list.
|
protected int |
getDefaultPhotoResId()
Returns a resource ID representing an image which should be shown when ther's no relevant
photo is available.
|
protected int |
getDeleteResId()
Returns an id for ImageView in an item View for showing the delete button.
|
protected int |
getDestinationResId()
Returns an id for TextView in an item View for showing a destination
(an email address or a phone number).
|
protected CharSequence |
getDestinationType(RecipientEntry entry) |
protected int |
getDestinationTypeResId()
Returns an id for TextView in an item View for showing the type of the destination.
|
protected int |
getDisplayNameResId()
Returns an id for TextView in an item View for showing a display name.
|
protected int |
getItemLayoutResId(DropdownChipLayouter.AdapterType type)
Returns a layout id for each item inside auto-complete list.
|
protected int |
getPermissionGroupResId()
Returns an id for the ViewGroup in an item View that contains the request permission ui
elements.
|
protected int |
getPermissionRequestDismissResId()
Returns an id for ImageView in an item View for dismissing the permission request.
|
protected int |
getPersonGroupResId()
Returns an id for the ViewGroup in an item View that contains the person ui elements.
|
protected int |
getPhotoResId()
Returns an id for ImageView in an item View for showing photo image for a person.
|
protected CharSequence[] |
getStyledResults(String constraint,
RecipientEntry entry)
Given a constraint and a recipient entry, tries to find the constraint in the name and
destination in the recipient entry.
|
protected CharSequence[] |
getStyledResults(String constraint,
String... results)
Given a constraint and results, tries to find the constraint in those results, one at a time.
|
View |
newView(DropdownChipLayouter.AdapterType type)
Returns a new view with
getItemLayoutResId(AdapterType) . |
protected View |
reuseOrInflateView(View convertView,
ViewGroup parent,
DropdownChipLayouter.AdapterType type)
Returns the same view, or inflates a new one if the given view was null.
|
void |
setAutocompleteDividerMarginStart(int autocompleteDividerMarginStart) |
void |
setDeleteListener(DropdownChipLayouter.ChipDeleteListener listener) |
void |
setPermissionRequestDismissedListener(DropdownChipLayouter.PermissionRequestDismissedListener listener) |
void |
setQuery(com.android.ex.chips.Queries.Query query) |
protected void |
setViewVisibility(View view,
int visibility) |
public DropdownChipLayouter(LayoutInflater inflater, Context context)
public void setQuery(com.android.ex.chips.Queries.Query query)
public void setDeleteListener(DropdownChipLayouter.ChipDeleteListener listener)
public void setPermissionRequestDismissedListener(DropdownChipLayouter.PermissionRequestDismissedListener listener)
public void setAutocompleteDividerMarginStart(int autocompleteDividerMarginStart)
public View bindView(View convertView, ViewGroup parent, RecipientEntry entry, int position, DropdownChipLayouter.AdapterType type, String constraint)
convertView
- The view to bind information to.parent
- The parent to bind the view to if we inflate a new view.entry
- The recipient entry to get information from.position
- The position in the list.type
- The adapter type that is requesting the bind.constraint
- The constraint typed in the auto complete view.public View bindView(View convertView, ViewGroup parent, RecipientEntry entry, int position, DropdownChipLayouter.AdapterType type, String constraint, StateListDrawable deleteDrawable)
deleteDrawable
- a StateListDrawable
representing
the delete icon. android.R.attr.state_activated should map to the delete icon, and the
default state can map to a drawable of your choice (or null for no drawable).public View newView(DropdownChipLayouter.AdapterType type)
getItemLayoutResId(AdapterType)
.protected View reuseOrInflateView(View convertView, ViewGroup parent, DropdownChipLayouter.AdapterType type)
protected void bindTextToView(CharSequence text, TextView view)
protected void bindIconToView(boolean showImage, RecipientEntry entry, ImageView view, DropdownChipLayouter.AdapterType type)
protected void bindDrawableToDeleteView(StateListDrawable drawable, String recipient, ImageView view)
protected void bindIndicatorToView(@DrawableRes int indicatorIconId, String indicatorText, TextView view)
protected void bindPermissionRequestDismissView(ImageView view)
protected void setViewVisibility(View view, int visibility)
protected CharSequence getDestinationType(RecipientEntry entry)
@LayoutRes protected int getItemLayoutResId(DropdownChipLayouter.AdapterType type)
getDisplayNameResId()
,
getDestinationResId()
, and getPhotoResId()
.@LayoutRes protected int getAlternateItemLayoutResId(DropdownChipLayouter.AdapterType type)
getDisplayNameResId()
,
getDestinationResId()
, and getPhotoResId()
.@DrawableRes protected int getDefaultPhotoResId()
@IdRes protected int getPersonGroupResId()
@IdRes protected int getDisplayNameResId()
android.R.id#title
is returned.@IdRes protected int getDestinationResId()
android.R.id#text1
is returned.@IdRes protected int getDestinationTypeResId()
android.R.id#text2
is returned.@IdRes protected int getPhotoResId()
android.R.id#icon
is returned.@IdRes protected int getDeleteResId()
android.R.id#icon1
is returned.@IdRes protected int getPermissionGroupResId()
@IdRes protected int getPermissionRequestDismissResId()
android.R.id#icon2
is returned.protected CharSequence[] getStyledResults(@Nullable String constraint, RecipientEntry entry)
constraint
- A string that we will attempt to find within the results.entry
- The recipient entry to style results for.protected CharSequence[] getStyledResults(@Nullable String constraint, String... results)
constraint
- A string that we will attempt to find within the results.results
- Strings that may contain the constraint. The order given is the order used to
search for the constraint.