use of android.widget.ListAdapter in project HoloEverywhere by Prototik.
the class GridFragment method ensureGrid.
private void ensureGrid() {
if (mGrid != null) {
return;
}
View root = getView();
if (root == null) {
throw new IllegalStateException("Content view not yet created");
}
if (root instanceof GridView) {
mGrid = (GridView) root;
} else {
mStandardEmptyView = (TextView) root.findViewById(R.id.internalEmpty);
if (mStandardEmptyView == null) {
mEmptyView = root.findViewById(android.R.id.empty);
} else {
mStandardEmptyView.setVisibility(View.GONE);
}
mProgressContainer = root.findViewById(R.id.progressContainer);
mGridContainer = root.findViewById(R.id.listContainer);
View rawGridVIew = root.findViewById(android.R.id.list);
if (!(rawGridVIew instanceof GridView)) {
if (rawGridVIew == null) {
throw new RuntimeException("Your content must have a GridVIew whose id attribute is " + "'android.R.id.list'");
}
throw new RuntimeException("Content has view with id attribute 'android.R.id.list' " + "that is not a GridVIew class");
}
mGrid = (GridView) rawGridVIew;
if (mEmptyView != null) {
mGrid.setEmptyView(mEmptyView);
} else if (mEmptyText != null) {
mStandardEmptyView.setText(mEmptyText);
mGrid.setEmptyView(mStandardEmptyView);
}
}
mGridShown = true;
mGrid.setOnItemClickListener(mOnClickListener);
if (mAdapter != null) {
ListAdapter adapter = mAdapter;
mAdapter = null;
setGridAdapter(adapter);
} else {
if (mProgressContainer != null) {
setGridShown(false, false);
}
}
mHandler.post(mRequestFocus);
}
use of android.widget.ListAdapter in project HoloEverywhere by Prototik.
the class ListFragment method ensureList.
private void ensureList() {
if (mList != null) {
return;
}
View root = getView();
if (root == null) {
throw new IllegalStateException("Content view not yet created");
}
if (root instanceof ListView) {
mList = (ListView) root;
} else {
mStandardEmptyView = (TextView) root.findViewById(R.id.internalEmpty);
if (mStandardEmptyView == null) {
mEmptyView = root.findViewById(android.R.id.empty);
} else {
mStandardEmptyView.setVisibility(View.GONE);
}
mProgressContainer = root.findViewById(R.id.progressContainer);
mListContainer = root.findViewById(R.id.listContainer);
View rawListView = root.findViewById(android.R.id.list);
if (!(rawListView instanceof ListView)) {
if (rawListView == null) {
throw new RuntimeException("Your content must have a ListView whose id attribute is " + "'android.R.id.list'");
}
throw new RuntimeException("Content has view with id attribute 'android.R.id.list' " + "that is not a ListView class");
}
mList = (ListView) rawListView;
if (mEmptyView != null) {
mList.setEmptyView(mEmptyView);
} else if (mEmptyText != null) {
mStandardEmptyView.setText(mEmptyText);
mList.setEmptyView(mStandardEmptyView);
}
}
mListShown = true;
mList.setOnItemClickListener(mOnClickListener);
if (mAdapter != null) {
ListAdapter adapter = mAdapter;
mAdapter = null;
setListAdapter(adapter);
} else {
if (mProgressContainer != null) {
setListShown(false, false);
}
}
mHandler.post(mRequestFocus);
}
use of android.widget.ListAdapter in project HoloEverywhere by Prototik.
the class ListPopupWindow method performItemClick.
public boolean performItemClick(int position) {
if (isShowing()) {
if (mItemClickListener != null) {
final DropDownListView list = mDropDownList;
final View child = list.getChildAt(position - list.getFirstVisiblePosition());
final ListAdapter adapter = list.getAdapter();
mItemClickListener.onItemClick(list, child, position, adapter.getItemId(position));
}
return true;
}
return false;
}
use of android.widget.ListAdapter in project HoloEverywhere by Prototik.
the class ListPopupWindow method measureHeightOfChildren.
private int measureHeightOfChildren(int widthMeasureSpec, int startPosition, int endPosition, final int maxHeight, int disallowPartialChildPosition) {
final ListAdapter adapter = mAdapter;
if (adapter == null) {
return mDropDownList.getListPaddingTop() + mDropDownList.getListPaddingBottom();
}
int returnedHeight = mDropDownList.getListPaddingTop() + mDropDownList.getListPaddingBottom();
final int dividerHeight = mDropDownList.getDividerHeight() > 0 && mDropDownList.getDivider() != null ? mDropDownList.getDividerHeight() : 0;
int prevHeightWithoutPartialChild = 0;
int i;
View child;
endPosition = endPosition == -1 ? adapter.getCount() - 1 : endPosition;
for (i = startPosition; i <= endPosition; ++i) {
child = mAdapter.getView(i, null, mDropDownList);
if (mDropDownList.getCacheColorHint() != 0) {
child.setDrawingCacheBackgroundColor(mDropDownList.getCacheColorHint());
}
measureScrapChild(child, i, widthMeasureSpec);
if (i > 0) {
returnedHeight += dividerHeight;
}
returnedHeight += child.getMeasuredHeight();
if (returnedHeight >= maxHeight) {
return disallowPartialChildPosition >= 0 && i > disallowPartialChildPosition && prevHeightWithoutPartialChild > 0 && returnedHeight != maxHeight ? prevHeightWithoutPartialChild : maxHeight;
}
if (disallowPartialChildPosition >= 0 && i >= disallowPartialChildPosition) {
prevHeightWithoutPartialChild = returnedHeight;
}
}
return returnedHeight;
}
use of android.widget.ListAdapter in project HoloEverywhere by Prototik.
the class ListPopupWindow method onKeyDown.
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (isShowing()) {
if (keyCode != KeyEvent.KEYCODE_SPACE && (mDropDownList.getSelectedItemPosition() >= 0 || keyCode != KeyEvent.KEYCODE_ENTER && keyCode != KeyEvent.KEYCODE_DPAD_CENTER)) {
int curIndex = mDropDownList.getSelectedItemPosition();
boolean consumed;
final boolean below = !mPopup.isAboveAnchor();
final ListAdapter adapter = mAdapter;
int firstItem = Integer.MAX_VALUE;
int lastItem = Integer.MIN_VALUE;
if (adapter != null) {
adapter.areAllItemsEnabled();
firstItem = 0;
lastItem = adapter.getCount() - 1;
/*
* TODO firstItem = allEnabled ? 0 : mDropDownList
* .lookForSelectablePosition(0, true); lastItem =
* allEnabled ? adapter.getCount() - 1 :
* mDropDownList.lookForSelectablePosition(
* adapter.getCount() - 1, false);
*/
}
if (below && keyCode == KeyEvent.KEYCODE_DPAD_UP && curIndex <= firstItem || !below && keyCode == KeyEvent.KEYCODE_DPAD_DOWN && curIndex >= lastItem) {
clearListSelection();
mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
show();
return true;
} else {
mDropDownList.mListSelectionHidden = false;
}
consumed = mDropDownList.onKeyDown(keyCode, event);
if (ListPopupWindow.DEBUG) {
Log.v(ListPopupWindow.TAG, "Key down: code=" + keyCode + " list consumed=" + consumed);
}
if (consumed) {
mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
mDropDownList.requestFocusFromTouch();
show();
switch(keyCode) {
case KeyEvent.KEYCODE_ENTER:
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_DPAD_DOWN:
case KeyEvent.KEYCODE_DPAD_UP:
return true;
}
} else {
if (below && keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
if (curIndex == lastItem) {
return true;
}
} else if (!below && keyCode == KeyEvent.KEYCODE_DPAD_UP && curIndex == firstItem) {
return true;
}
}
}
}
return false;
}
Aggregations