Merge "Revert "Synchronize selected item data on-demand after data set invalidation"" into mnc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
2e4e5d745f
@@ -5308,13 +5308,6 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
void syncSelectedItem() {
|
|
||||||
if (mDataChanged) {
|
|
||||||
layoutChildren();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleDataChanged() {
|
protected void handleDataChanged() {
|
||||||
int count = mItemCount;
|
int count = mItemCount;
|
||||||
|
|||||||
@@ -551,67 +551,37 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the position of the currently selected item within the adapter's
|
* Return the position of the currently selected item within the adapter's data set
|
||||||
* data set, or {@link #INVALID_POSITION} if there is nothing selected.
|
|
||||||
* <p>
|
|
||||||
* <strong>Note:</strong> Prior to {@link android.os.Build.VERSION_CODES#MNC},
|
|
||||||
* calling this method between an adapter data set change and a subsequent
|
|
||||||
* layout pass could return invalid data.
|
|
||||||
*
|
*
|
||||||
* @return the selected item's position (starting at 0), or
|
* @return int Position (starting at 0), or {@link #INVALID_POSITION} if there is nothing selected.
|
||||||
* {@link #INVALID_POSITION} if there is nothing selected
|
|
||||||
*/
|
*/
|
||||||
@ViewDebug.CapturedViewProperty
|
@ViewDebug.CapturedViewProperty
|
||||||
public int getSelectedItemPosition() {
|
public int getSelectedItemPosition() {
|
||||||
syncSelectedItem();
|
|
||||||
return mNextSelectedPosition;
|
return mNextSelectedPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the row ID corresponding to the currently selected item, or
|
* @return The id corresponding to the currently selected item, or {@link #INVALID_ROW_ID}
|
||||||
* {@link #INVALID_ROW_ID} if nothing is selected.
|
* if nothing is selected.
|
||||||
* <p>
|
|
||||||
* <strong>Note:</strong> Prior to {@link android.os.Build.VERSION_CODES#MNC},
|
|
||||||
* calling this method between an adapter data set change and a subsequent
|
|
||||||
* layout pass could return invalid data.
|
|
||||||
*
|
|
||||||
* @return the selected item's row ID, or {@link #INVALID_ROW_ID} if
|
|
||||||
* nothing is selected
|
|
||||||
*/
|
*/
|
||||||
@ViewDebug.CapturedViewProperty
|
@ViewDebug.CapturedViewProperty
|
||||||
public long getSelectedItemId() {
|
public long getSelectedItemId() {
|
||||||
syncSelectedItem();
|
|
||||||
return mNextSelectedRowId;
|
return mNextSelectedRowId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the view corresponding to the currently selected item, or
|
* @return The view corresponding to the currently selected item, or null
|
||||||
* {@code null} if nothing is selected.
|
* if nothing is selected
|
||||||
* <p>
|
|
||||||
* <strong>Note:</strong> Prior to {@link android.os.Build.VERSION_CODES#MNC},
|
|
||||||
* calling this method between an adapter data set change and a subsequent
|
|
||||||
* layout pass could return inconsistent data.
|
|
||||||
*
|
|
||||||
* @return the selected item's view, or {@code null} if nothing is selected
|
|
||||||
*/
|
*/
|
||||||
@Nullable
|
|
||||||
public abstract View getSelectedView();
|
public abstract View getSelectedView();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the data corresponding to the currently selected item, or
|
* @return The data corresponding to the currently selected item, or
|
||||||
* {@code null} if nothing is selected.
|
* null if there is nothing selected.
|
||||||
* <p>
|
|
||||||
* <strong>Note:</strong> Prior to {@link android.os.Build.VERSION_CODES#MNC},
|
|
||||||
* calling this method between an adapter data set change and a subsequent
|
|
||||||
* layout pass could return inconsistent data.
|
|
||||||
*
|
|
||||||
* @return the data corresponding to the currently selected item, or
|
|
||||||
* {@code null} if there is nothing selected.
|
|
||||||
*/
|
*/
|
||||||
@Nullable
|
|
||||||
public Object getSelectedItem() {
|
public Object getSelectedItem() {
|
||||||
final T adapter = getAdapter();
|
T adapter = getAdapter();
|
||||||
final int selection = getSelectedItemPosition();
|
int selection = getSelectedItemPosition();
|
||||||
if (adapter != null && adapter.getCount() > 0 && selection >= 0) {
|
if (adapter != null && adapter.getCount() > 0 && selection >= 0) {
|
||||||
return adapter.getItem(selection);
|
return adapter.getItem(selection);
|
||||||
} else {
|
} else {
|
||||||
@@ -619,15 +589,6 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Synchronizes the selected item's position and ID, if necessary.
|
|
||||||
*/
|
|
||||||
void syncSelectedItem() {
|
|
||||||
if (mDataChanged) {
|
|
||||||
onLayout(false, mLeft, mTop, mRight, mBottom);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The number of items owned by the Adapter associated with this
|
* @return The number of items owned by the Adapter associated with this
|
||||||
* AdapterView. (This is the number of data items, which may be
|
* AdapterView. (This is the number of data items, which may be
|
||||||
|
|||||||
Reference in New Issue
Block a user