ListView: copy from AOSP

copied from tag android-6.0.1_r81
This commit is contained in:
Julian Winkler
2024-11-30 08:02:13 +01:00
committed by Mis012
parent d5bc4ea9a6
commit 60095ea795
13 changed files with 9814 additions and 604 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,5 @@
package android.widget;
public interface Filterable {}
public interface Filterable {
public Filter getFilter();
}

View File

@@ -228,4 +228,40 @@ public class HeaderViewListAdapter implements ListAdapter, Filterable {
public ListAdapter getWrappedAdapter() {
return mAdapter;
}
public Filter getFilter() {
if (mAdapter instanceof Filterable) {
return ((Filterable) mAdapter).getFilter();
}
return null;
}
public boolean isEnabled(int position) {
// Header (negative positions will throw an IndexOutOfBoundsException)
int numHeaders = getHeadersCount();
if (position < numHeaders) {
return mHeaderViewInfos.get(position).isSelectable;
}
// Adapter
final int adjPosition = position - numHeaders;
int adapterCount = 0;
if (mAdapter != null) {
adapterCount = mAdapter.getCount();
if (adjPosition < adapterCount) {
return mAdapter.isEnabled(adjPosition);
}
}
// Footer (off-limits positions will throw an IndexOutOfBoundsException)
return mFooterViewInfos.get(adjPosition - adapterCount).isSelectable;
}
public boolean areAllItemsEnabled() {
if (mAdapter != null) {
return mAreAllFixedViewsSelectable && mAdapter.areAllItemsEnabled();
} else {
return true;
}
}
}

View File

@@ -1,4 +1,8 @@
package android.widget;
public interface ListAdapter extends Adapter {
public boolean isEnabled(int position);
public boolean areAllItemsEnabled();
}

File diff suppressed because it is too large Load Diff

View File

@@ -58,6 +58,7 @@ public class PopupWindow {
public void setContentView(View view) {
contentView = view;
contentView.attachToWindowInternal();
native_setContentView(popover, view.widget);
}