| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.widget; |
| 18 |
|
| 19 |
import android.annotation.Nullable; |
| 20 |
import android.compat.annotation.UnsupportedAppUsage; |
| 21 |
import android.database.DataSetObservable; |
| 22 |
import android.database.DataSetObserver; |
| 23 |
import android.view.View; |
| 24 |
import android.view.ViewGroup; |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
public abstract class BaseAdapter implements ListAdapter, SpinnerAdapter { |
| 33 |
@UnsupportedAppUsage |
| 34 |
private final DataSetObservable mDataSetObservable = new DataSetObservable(); |
| 35 |
private CharSequence[] mAutofillOptions; |
| 36 |
|
| 37 |
public boolean hasStableIds() { |
| 38 |
return false; |
| 39 |
} |
| 40 |
|
| 41 |
public void registerDataSetObserver(DataSetObserver observer) { |
| 42 |
mDataSetObservable.registerObserver(observer); |
| 43 |
} |
| 44 |
|
| 45 |
public void unregisterDataSetObserver(DataSetObserver observer) { |
| 46 |
mDataSetObservable.unregisterObserver(observer); |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
public void notifyDataSetChanged() { |
| 54 |
mDataSetObservable.notifyChanged(); |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
public void notifyDataSetInvalidated() { |
| 63 |
mDataSetObservable.notifyInvalidated(); |
| 64 |
} |
| 65 |
|
| 66 |
public boolean areAllItemsEnabled() { |
| 67 |
return true; |
| 68 |
} |
| 69 |
|
| 70 |
public boolean isEnabled(int position) { |
| 71 |
return true; |
| 72 |
} |
| 73 |
|
| 74 |
public View getDropDownView(int position, View convertView, ViewGroup parent) { |
| 75 |
return getView(position, convertView, parent); |
| 76 |
} |
| 77 |
|
| 78 |
public int getItemViewType(int position) { |
| 79 |
return 0; |
| 80 |
} |
| 81 |
|
| 82 |
public int getViewTypeCount() { |
| 83 |
return 1; |
| 84 |
} |
| 85 |
|
| 86 |
public boolean isEmpty() { |
| 87 |
return getCount() == 0; |
| 88 |
} |
| 89 |
|
| 90 |
@Override |
| 91 |
public CharSequence[] getAutofillOptions() { |
| 92 |
return mAutofillOptions; |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
public void setAutofillOptions(@Nullable CharSequence... options) { |
| 99 |
mAutofillOptions = options; |
| 100 |
} |
| 101 |
} |