Example usage for android.view View setActivated

List of usage examples for android.view View setActivated

Introduction

In this page you can find the example usage for android.view View setActivated.

Prototype

public void setActivated(boolean activated) 

Source Link

Document

Changes the activated state of this view.

Usage

From source file:org.lucasr.twowayview.TwoWayView.java

@TargetApi(11)
private void updateOnScreenCheckedViews() {
    final int firstPos = mFirstPosition;
    final int count = getChildCount();

    final boolean useActivated = Build.VERSION.SDK_INT >= HONEYCOMB;

    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);
        final int position = firstPos + i;

        if (child instanceof Checkable) {
            ((Checkable) child).setChecked(mCheckStates.get(position));
        } else if (useActivated) {
            child.setActivated(mCheckStates.get(position));
        }//from   w  w  w. j  av  a2  s. com
    }
}

From source file:com.aliasapps.seq.scroller.TwoWayView.java

@TargetApi(11)
private void updateOnScreenCheckedViews() {
    final int firstPos = mFirstPosition;
    final int count = getChildCount();

    final boolean useActivated = getContext()
            .getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.HONEYCOMB;

    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);
        final int position = firstPos + i;

        if (child instanceof Checkable) {
            ((Checkable) child).setChecked(mCheckStates.get(position));
        } else if (useActivated) {
            child.setActivated(mCheckStates.get(position));
        }//w  ww .j  a va 2s.  c  o m
    }
}

From source file:com.artifex.mupdflib.TwoWayView.java

@TargetApi(11)
private void updateOnScreenCheckedViews() {
    final int firstPos = mFirstPosition;
    final int count = getChildCount();

    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);
        final int position = firstPos + i;

        if (child instanceof Checkable) {
            ((Checkable) child).setChecked(mCheckStates.get(position));
        } else if (Build.VERSION.SDK_INT >= HONEYCOMB) {
            child.setActivated(mCheckStates.get(position));
        }//w w  w. j  a v  a2s.  c om
    }
}

From source file:org.lucasr.twowayview.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. j a  v a 2  s . c om*/

    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 (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());
    }
}

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 www.  j ava 2  s. c  om

    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  ww .  j  a  v  a2s .  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  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 != 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());
    }
}