List of usage examples for android.view View setPressed
public void setPressed(boolean pressed)
From source file:com.aliasapps.seq.scroller.TwoWayView.java
@TargetApi(11) private void setupChild(View child, int position, int top, int left, boolean flow, boolean selected, boolean recycled) { final boolean isSelected = selected && shouldShowSelector(); final boolean updateChildSelected = isSelected != child.isSelected(); final int touchMode = mTouchMode; final boolean isPressed = touchMode > TOUCH_MODE_DOWN && touchMode < TOUCH_MODE_DRAGGING && mMotionPosition == position; final boolean updateChildPressed = isPressed != child.isPressed(); final boolean needToMeasure = !recycled || updateChildSelected || child.isLayoutRequested(); // Respect layout params that are already in the view. Otherwise make some up... LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (lp == null) { lp = generateDefaultLayoutParams(); }//from w w w .jav a 2 s . c o m lp.viewType = mAdapter.getItemViewType(position); if (recycled && !lp.forceAdd) { attachViewToParent(child, (flow ? -1 : 0), lp); } else { lp.forceAdd = false; addViewInLayout(child, (flow ? -1 : 0), lp, true); } if (updateChildSelected) { child.setSelected(isSelected); } if (updateChildPressed) { child.setPressed(isPressed); } if (mChoiceMode.compareTo(ChoiceMode.NONE) != 0 && mCheckStates != null) { if (child instanceof Checkable) { ((Checkable) child).setChecked(mCheckStates.get(position)); } else if (getContext().getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.HONEYCOMB) { child.setActivated(mCheckStates.get(position)); } } if (needToMeasure) { measureChild(child, lp); } else { cleanupLayoutState(child); } final int w = child.getMeasuredWidth(); final int h = child.getMeasuredHeight(); final int childTop = (mIsVertical && !flow ? top - h : top); final int childLeft = (!mIsVertical && !flow ? left - w : left); if (needToMeasure) { final int childRight = childLeft + w; final int childBottom = childTop + h; child.layout(childLeft, childTop, childRight, childBottom); } else { child.offsetLeftAndRight(childLeft - child.getLeft()); child.offsetTopAndBottom(childTop - child.getTop()); } }
From source file:com.artifex.mupdf.view.ThumbnailViews.java
@TargetApi(11) private void setupChild(View child, int position, int top, int left, boolean flow, boolean selected, boolean recycled) { final boolean isSelected = selected && shouldShowSelector(); final boolean updateChildSelected = isSelected != child.isSelected(); final int touchMode = mTouchMode; final boolean isPressed = touchMode > TOUCH_MODE_DOWN && touchMode < TOUCH_MODE_DRAGGING && mMotionPosition == position; final boolean updateChildPressed = isPressed != child.isPressed(); final boolean needToMeasure = !recycled || updateChildSelected || child.isLayoutRequested(); // Respect layout params that are already in the view. Otherwise make // some up... LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (lp == null) { lp = generateDefaultLayoutParams(); }/*from w w w . j a v a 2 s.c o m*/ lp.viewType = mAdapter.getItemViewType(position); if (recycled && !lp.forceAdd) { attachViewToParent(child, (flow ? -1 : 0), lp); } else { lp.forceAdd = false; addViewInLayout(child, (flow ? -1 : 0), lp, true); } if (updateChildSelected) { child.setSelected(isSelected); } if (updateChildPressed) { child.setPressed(isPressed); } if (mChoiceMode.compareTo(ChoiceMode.NONE) != 0 && mCheckStates != null) { if (child instanceof Checkable) { ((Checkable) child).setChecked(mCheckStates.get(position)); } else if (getContext().getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.HONEYCOMB) { child.setActivated(mCheckStates.get(position)); } } if (needToMeasure) { measureChild(child, lp); } else { cleanupLayoutState(child); } final int w = child.getMeasuredWidth(); final int h = child.getMeasuredHeight(); final int childTop = (mIsVertical && !flow ? top - h : top); final int childLeft = (!mIsVertical && !flow ? left - w : left); if (needToMeasure) { final int childRight = childLeft + w; final int childBottom = childTop + h; child.layout(childLeft, childTop, childRight, childBottom); } else { child.offsetLeftAndRight(childLeft - child.getLeft()); child.offsetTopAndBottom(childTop - child.getTop()); } }
From source file:com.artifex.mupdflib.TwoWayView.java
@TargetApi(11) private void setupChild(View child, int position, int top, int left, boolean flow, boolean selected, boolean recycled) { final boolean isSelected = selected && shouldShowSelector(); final boolean updateChildSelected = isSelected != child.isSelected(); final int touchMode = mTouchMode; final boolean isPressed = touchMode > TOUCH_MODE_DOWN && touchMode < TOUCH_MODE_DRAGGING && mMotionPosition == position; final boolean updateChildPressed = isPressed != child.isPressed(); final boolean needToMeasure = !recycled || updateChildSelected || child.isLayoutRequested(); // Respect layout params that are already in the view. Otherwise make some up... LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (lp == null) { lp = generateDefaultLayoutParams(); }/*from w w w .jav a 2s . com*/ lp.viewType = mAdapter.getItemViewType(position); if (recycled && !lp.forceAdd) { attachViewToParent(child, (flow ? -1 : 0), lp); } else { lp.forceAdd = false; addViewInLayout(child, (flow ? -1 : 0), lp, true); } if (updateChildSelected) { child.setSelected(isSelected); } if (updateChildPressed) { child.setPressed(isPressed); } if (mChoiceMode != ChoiceMode.NONE && mCheckStates != null) { if (child instanceof Checkable) { ((Checkable) child).setChecked(mCheckStates.get(position)); } else if (Build.VERSION.SDK_INT >= HONEYCOMB) { child.setActivated(mCheckStates.get(position)); } } if (needToMeasure) { measureChild(child, lp); } else { cleanupLayoutState(child); } final int w = child.getMeasuredWidth(); final int h = child.getMeasuredHeight(); final int childTop = (mIsVertical && !flow ? top - h : top); final int childLeft = (!mIsVertical && !flow ? left - w : left); if (needToMeasure) { final int childRight = childLeft + w; final int childBottom = childTop + h; child.layout(childLeft, childTop, childRight, childBottom); } else { child.offsetLeftAndRight(childLeft - child.getLeft()); child.offsetTopAndBottom(childTop - child.getTop()); } }