use of android.view.ViewGroup in project cw-omnibus by commonsguy.
the class BaseMenuPresenter method updateMenuView.
/**
* Reuses item views when it can
*/
public void updateMenuView(boolean cleared) {
final ViewGroup parent = (ViewGroup) mMenuView;
if (parent == null)
return;
int childIndex = 0;
if (mMenu != null) {
mMenu.flagActionItems();
ArrayList<MenuItemImpl> visibleItems = mMenu.getVisibleItems();
final int itemCount = visibleItems.size();
for (int i = 0; i < itemCount; i++) {
MenuItemImpl item = visibleItems.get(i);
if (shouldIncludeItem(childIndex, item)) {
final View convertView = parent.getChildAt(childIndex);
final MenuItemImpl oldItem = convertView instanceof MenuView.ItemView ? ((MenuView.ItemView) convertView).getItemData() : null;
final View itemView = getItemView(item, convertView, parent);
if (item != oldItem) {
// Don't let old states linger with new data.
itemView.setPressed(false);
if (IS_HONEYCOMB)
itemView.jumpDrawablesToCurrentState();
}
if (itemView != convertView) {
addItemView(itemView, childIndex);
}
childIndex++;
}
}
}
// Remove leftover views.
while (childIndex < parent.getChildCount()) {
if (!filterLeftoverView(parent, childIndex)) {
childIndex++;
}
}
}
use of android.view.ViewGroup in project SimplifyReader by chentao0707.
the class SwipeBackLayout method attachToActivity.
public void attachToActivity(Activity activity) {
mActivity = activity;
TypedArray a = activity.getTheme().obtainStyledAttributes(new int[] { android.R.attr.windowBackground });
int background = a.getResourceId(0, 0);
a.recycle();
ViewGroup decor = (ViewGroup) activity.getWindow().getDecorView().findViewById(Window.ID_ANDROID_CONTENT);
ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
decorChild.setBackgroundResource(background);
decor.removeView(decorChild);
addView(decorChild);
setContentView(decorChild);
decor.addView(this);
}
use of android.view.ViewGroup in project SimplifyReader by chentao0707.
the class ViewDragHelper method canScroll.
/**
* Tests scrollability within child views of v given a delta of dx.
*
* @param v View to test for horizontal scrollability
* @param checkV Whether the view v passed should itself be checked for
* scrollability (true), or just its children (false).
* @param dx Delta scrolled in pixels along the X axis
* @param dy Delta scrolled in pixels along the Y axis
* @param x X coordinate of the active touch point
* @param y Y coordinate of the active touch point
* @return true if child views of v can be scrolled by delta of dx.
*/
protected boolean canScroll(View v, boolean checkV, int dx, int dy, int x, int y) {
if (v instanceof ViewGroup) {
final ViewGroup group = (ViewGroup) v;
final int scrollX = v.getScrollX();
final int scrollY = v.getScrollY();
final int count = group.getChildCount();
// first.
for (int i = count - 1; i >= 0; i--) {
// TODO: Add versioned support here for transformed views.
// This will not work for transformed views in Honeycomb+
final View child = group.getChildAt(i);
if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child, true, dx, dy, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) {
return true;
}
}
}
return checkV && (ViewCompat.canScrollHorizontally(v, -dx) || ViewCompat.canScrollVertically(v, -dy));
}
use of android.view.ViewGroup in project Launcher3 by chislon.
the class AppsCustomizeTabHost method setVisibilityOfSiblingsWithLowerZOrder.
private void setVisibilityOfSiblingsWithLowerZOrder(int visibility) {
ViewGroup parent = (ViewGroup) getParent();
if (parent == null)
return;
View overviewPanel = ((Launcher) getContext()).getOverviewPanel();
final int count = parent.getChildCount();
if (!isChildrenDrawingOrderEnabled()) {
for (int i = 0; i < count; i++) {
final View child = parent.getChildAt(i);
if (child == this) {
break;
} else {
if (child.getVisibility() == GONE || child == overviewPanel) {
continue;
}
child.setVisibility(visibility);
}
}
} else {
throw new RuntimeException("Failed; can't get z-order of views");
}
}
use of android.view.ViewGroup in project Launcher3 by chislon.
the class FocusHelper method handleTabKeyEvent.
/**
* Handles key events in the tab widget.
*/
static boolean handleTabKeyEvent(AccessibleTabView v, int keyCode, KeyEvent e) {
if (!LauncherAppState.getInstance().isScreenLarge())
return false;
final FocusOnlyTabWidget parent = (FocusOnlyTabWidget) v.getParent();
final TabHost tabHost = findTabHostParent(parent);
final ViewGroup contents = tabHost.getTabContentView();
final int tabCount = parent.getTabCount();
final int tabIndex = parent.getChildTabIndex(v);
final int action = e.getAction();
final boolean handleKeyEvent = (action != KeyEvent.ACTION_UP);
boolean wasHandled = false;
switch(keyCode) {
case KeyEvent.KEYCODE_DPAD_LEFT:
if (handleKeyEvent) {
// Select the previous tab
if (tabIndex > 0) {
parent.getChildTabViewAt(tabIndex - 1).requestFocus();
}
}
wasHandled = true;
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
if (handleKeyEvent) {
// Select the next tab, or if the last tab has a focus right id, select that
if (tabIndex < (tabCount - 1)) {
parent.getChildTabViewAt(tabIndex + 1).requestFocus();
} else {
if (v.getNextFocusRightId() != View.NO_ID) {
tabHost.findViewById(v.getNextFocusRightId()).requestFocus();
}
}
}
wasHandled = true;
break;
case KeyEvent.KEYCODE_DPAD_UP:
// Do nothing
wasHandled = true;
break;
case KeyEvent.KEYCODE_DPAD_DOWN:
if (handleKeyEvent) {
// Select the content view
contents.requestFocus();
}
wasHandled = true;
break;
default:
break;
}
return wasHandled;
}
Aggregations