Example usage for android.view Gravity RIGHT

List of usage examples for android.view Gravity RIGHT

Introduction

In this page you can find the example usage for android.view Gravity RIGHT.

Prototype

int RIGHT

To view the source code for android.view Gravity RIGHT.

Click Source Link

Document

Push object to the right of its container, not changing its size.

Usage

From source file:com.zyk.drawerlayout.widget.DrawerLayout.java

/**
 * Enable or disable interaction with all drawers.
 *
 * <p>This allows the application to restrict the user's ability to open or close
 * any drawer within this layout. DrawerLayout will still respond to calls to
 * {@link #openDrawer(int)}, {@link #closeDrawer(int)} and friends if a drawer is locked.</p>
 *
 * <p>Locking drawers open or closed will implicitly open or close
 * any drawers as appropriate.</p>
 *
 * @param lockMode The new lock mode for the given drawer. One of {@link #LOCK_MODE_UNLOCKED},
 *                 {@link #LOCK_MODE_LOCKED_CLOSED} or {@link #LOCK_MODE_LOCKED_OPEN}.
 *///  w  w w  .  j ava  2s  . co  m
public void setDrawerLockMode(@LockMode int lockMode) {
    setDrawerLockMode(lockMode, Gravity.LEFT);
    setDrawerLockMode(lockMode, Gravity.RIGHT);
    setDrawerLockMode(lockMode, Gravity.TOP);
    setDrawerLockMode(lockMode, Gravity.BOTTOM);
}

From source file:com.actionbarsherlock.custom.widget.VerticalDrawerLayout.java

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    mInLayout = true;//from   w w  w  .  j  a  v a  2s .co  m
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);

        if (child.getVisibility() == GONE) {
            continue;
        }

        final LayoutParams lp = (LayoutParams) child.getLayoutParams();

        if (isContentView(child)) {
            child.layout(lp.leftMargin, lp.topMargin, lp.leftMargin + child.getMeasuredWidth(),
                    lp.topMargin + child.getMeasuredHeight());
        } else { // Drawer, if it wasn't onMeasure would have thrown an exception.
            final int childWidth = child.getMeasuredWidth();
            final int childHeight = child.getMeasuredHeight();
            int childTop;

            if (checkDrawerViewGravity(child, Gravity.TOP)) {
                childTop = -childHeight + (int) (childHeight * lp.onScreen);
            } else { // Bottom; onMeasure checked for us.
                childTop = b - t - (int) (childHeight * lp.onScreen);
            }

            final int vgrav = lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK;

            switch (vgrav) {
            default:
            case Gravity.LEFT: {
                child.layout(lp.leftMargin, childTop, childWidth, childTop + childHeight);
                break;
            }

            case Gravity.RIGHT: {
                final int width = r - l;
                child.layout(width - lp.rightMargin - child.getMeasuredWidth(), childTop,
                        width - lp.rightMargin, childTop + childHeight);
                break;
            }

            case Gravity.CENTER_HORIZONTAL: {
                final int width = r - l;
                int childLeft = (width - childWidth) / 2;

                // Offset for margins. If things don't fit right because of
                // bad measurement before, oh well.
                if (childLeft < lp.leftMargin) {
                    childLeft = lp.leftMargin;
                } else if (childLeft + childWidth > width - lp.rightMargin) {
                    childLeft = width - lp.rightMargin - childWidth;
                }
                child.layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight);
                break;
            }
            }

            if (lp.onScreen == 0) {
                child.setVisibility(INVISIBLE);
            }
        }
    }
    mInLayout = false;
    mFirstLayout = false;
}

From source file:com.goftagram.telegram.ui.Components.PasscodeView.java

public PasscodeView(final Context context) {
    super(context);

    setWillNotDraw(false);// ww w.j  a v a 2s .  c  o  m
    setVisibility(GONE);

    backgroundFrameLayout = new FrameLayout(context);
    addView(backgroundFrameLayout);
    LayoutParams layoutParams = (LayoutParams) backgroundFrameLayout.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    backgroundFrameLayout.setLayoutParams(layoutParams);

    passwordFrameLayout = new FrameLayout(context);
    addView(passwordFrameLayout);
    layoutParams = (LayoutParams) passwordFrameLayout.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    passwordFrameLayout.setLayoutParams(layoutParams);

    ImageView imageView = new ImageView(context);
    imageView.setScaleType(ImageView.ScaleType.FIT_XY);
    imageView.setImageResource(R.drawable.passcode_logo);
    passwordFrameLayout.addView(imageView);
    layoutParams = (LayoutParams) imageView.getLayoutParams();
    if (AndroidUtilities.density < 1) {
        layoutParams.width = AndroidUtilities.dp(30);
        layoutParams.height = AndroidUtilities.dp(30);
    } else {
        layoutParams.width = AndroidUtilities.dp(40);
        layoutParams.height = AndroidUtilities.dp(40);
    }
    layoutParams.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
    layoutParams.bottomMargin = AndroidUtilities.dp(100);
    imageView.setLayoutParams(layoutParams);

    passcodeTextView = new TextView(context);
    passcodeTextView.setTextColor(0xffffffff);
    passcodeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    passcodeTextView.setGravity(Gravity.CENTER_HORIZONTAL);
    passwordFrameLayout.addView(passcodeTextView);
    layoutParams = (LayoutParams) passcodeTextView.getLayoutParams();
    layoutParams.width = LayoutHelper.WRAP_CONTENT;
    layoutParams.height = LayoutHelper.WRAP_CONTENT;
    layoutParams.bottomMargin = AndroidUtilities.dp(62);
    layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
    passcodeTextView.setLayoutParams(layoutParams);

    passwordEditText2 = new AnimatingTextView(context);
    passwordFrameLayout.addView(passwordEditText2);
    layoutParams = (FrameLayout.LayoutParams) passwordEditText2.getLayoutParams();
    layoutParams.height = LayoutHelper.WRAP_CONTENT;
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.leftMargin = AndroidUtilities.dp(70);
    layoutParams.rightMargin = AndroidUtilities.dp(70);
    layoutParams.bottomMargin = AndroidUtilities.dp(6);
    layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
    passwordEditText2.setLayoutParams(layoutParams);

    passwordEditText = new EditText(context);
    passwordEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36);
    passwordEditText.setTextColor(0xffffffff);
    passwordEditText.setMaxLines(1);
    passwordEditText.setLines(1);
    passwordEditText.setGravity(Gravity.CENTER_HORIZONTAL);
    passwordEditText.setSingleLine(true);
    passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
    passwordEditText.setTypeface(Typeface.DEFAULT);
    passwordEditText.setBackgroundDrawable(null);
    AndroidUtilities.clearCursorDrawable(passwordEditText);
    passwordFrameLayout.addView(passwordEditText);
    layoutParams = (FrameLayout.LayoutParams) passwordEditText.getLayoutParams();
    layoutParams.height = LayoutHelper.WRAP_CONTENT;
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.leftMargin = AndroidUtilities.dp(70);
    layoutParams.rightMargin = AndroidUtilities.dp(70);
    layoutParams.bottomMargin = AndroidUtilities.dp(6);
    layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
    passwordEditText.setLayoutParams(layoutParams);
    passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_DONE) {
                processDone(false);
                return true;
            }
            return false;
        }
    });
    passwordEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

        }

        @Override
        public void afterTextChanged(Editable s) {
            if (passwordEditText.length() == 4 && UserConfig.passcodeType == 0) {
                processDone(false);
            }
        }
    });
    if (android.os.Build.VERSION.SDK_INT < 11) {
        passwordEditText.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
            public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
                menu.clear();
            }
        });
    } else {
        passwordEditText.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
            public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
                return false;
            }

            public void onDestroyActionMode(ActionMode mode) {
            }

            public boolean onCreateActionMode(ActionMode mode, Menu menu) {
                return false;
            }

            public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
                return false;
            }
        });
    }

    checkImage = new ImageView(context);
    checkImage.setImageResource(R.drawable.passcode_check);
    checkImage.setScaleType(ImageView.ScaleType.CENTER);
    checkImage.setBackgroundResource(R.drawable.bar_selector_lock);
    passwordFrameLayout.addView(checkImage);
    layoutParams = (LayoutParams) checkImage.getLayoutParams();
    layoutParams.width = AndroidUtilities.dp(60);
    layoutParams.height = AndroidUtilities.dp(60);
    layoutParams.bottomMargin = AndroidUtilities.dp(4);
    layoutParams.rightMargin = AndroidUtilities.dp(10);
    layoutParams.gravity = Gravity.BOTTOM | Gravity.RIGHT;
    checkImage.setLayoutParams(layoutParams);
    checkImage.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            processDone(false);
        }
    });

    FrameLayout lineFrameLayout = new FrameLayout(context);
    lineFrameLayout.setBackgroundColor(0x26ffffff);
    passwordFrameLayout.addView(lineFrameLayout);
    layoutParams = (LayoutParams) lineFrameLayout.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = AndroidUtilities.dp(1);
    layoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT;
    layoutParams.leftMargin = AndroidUtilities.dp(20);
    layoutParams.rightMargin = AndroidUtilities.dp(20);
    lineFrameLayout.setLayoutParams(layoutParams);

    numbersFrameLayout = new FrameLayout(context);
    addView(numbersFrameLayout);
    layoutParams = (LayoutParams) numbersFrameLayout.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    numbersFrameLayout.setLayoutParams(layoutParams);

    lettersTextViews = new ArrayList<>(10);
    numberTextViews = new ArrayList<>(10);
    numberFrameLayouts = new ArrayList<>(10);
    for (int a = 0; a < 10; a++) {
        TextView textView = new TextView(context);
        textView.setTextColor(0xffffffff);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36);
        textView.setGravity(Gravity.CENTER);
        textView.setText(String.format(Locale.US, "%d", a));
        numbersFrameLayout.addView(textView);
        layoutParams = (LayoutParams) textView.getLayoutParams();
        layoutParams.width = AndroidUtilities.dp(50);
        layoutParams.height = AndroidUtilities.dp(50);
        layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
        textView.setLayoutParams(layoutParams);
        numberTextViews.add(textView);

        textView = new TextView(context);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
        textView.setTextColor(0x7fffffff);
        textView.setGravity(Gravity.CENTER);
        numbersFrameLayout.addView(textView);
        layoutParams = (LayoutParams) textView.getLayoutParams();
        layoutParams.width = AndroidUtilities.dp(50);
        layoutParams.height = AndroidUtilities.dp(20);
        layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
        textView.setLayoutParams(layoutParams);
        switch (a) {
        case 0:
            textView.setText("+");
            break;
        case 2:
            textView.setText("ABC");
            break;
        case 3:
            textView.setText("DEF");
            break;
        case 4:
            textView.setText("GHI");
            break;
        case 5:
            textView.setText("JKL");
            break;
        case 6:
            textView.setText("MNO");
            break;
        case 7:
            textView.setText("PQRS");
            break;
        case 8:
            textView.setText("TUV");
            break;
        case 9:
            textView.setText("WXYZ");
            break;
        default:
            break;
        }
        lettersTextViews.add(textView);
    }
    eraseView = new ImageView(context);
    eraseView.setScaleType(ImageView.ScaleType.CENTER);
    eraseView.setImageResource(R.drawable.passcode_delete);
    numbersFrameLayout.addView(eraseView);
    layoutParams = (LayoutParams) eraseView.getLayoutParams();
    layoutParams.width = AndroidUtilities.dp(50);
    layoutParams.height = AndroidUtilities.dp(50);
    layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    eraseView.setLayoutParams(layoutParams);
    for (int a = 0; a < 11; a++) {
        FrameLayout frameLayout = new FrameLayout(context);
        frameLayout.setBackgroundResource(R.drawable.bar_selector_lock);
        frameLayout.setTag(a);
        if (a == 10) {
            frameLayout.setOnLongClickListener(new OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    passwordEditText.setText("");
                    passwordEditText2.eraseAllCharacters(true);
                    return true;
                }
            });
        }
        frameLayout.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                int tag = (Integer) v.getTag();
                switch (tag) {
                case 0:
                    passwordEditText2.appendCharacter("0");
                    break;
                case 1:
                    passwordEditText2.appendCharacter("1");
                    break;
                case 2:
                    passwordEditText2.appendCharacter("2");
                    break;
                case 3:
                    passwordEditText2.appendCharacter("3");
                    break;
                case 4:
                    passwordEditText2.appendCharacter("4");
                    break;
                case 5:
                    passwordEditText2.appendCharacter("5");
                    break;
                case 6:
                    passwordEditText2.appendCharacter("6");
                    break;
                case 7:
                    passwordEditText2.appendCharacter("7");
                    break;
                case 8:
                    passwordEditText2.appendCharacter("8");
                    break;
                case 9:
                    passwordEditText2.appendCharacter("9");
                    break;
                case 10:
                    passwordEditText2.eraseLastCharacter();
                    break;
                }
                if (passwordEditText2.lenght() == 4) {
                    processDone(false);
                }
            }
        });
        numberFrameLayouts.add(frameLayout);
    }
    for (int a = 10; a >= 0; a--) {
        FrameLayout frameLayout = numberFrameLayouts.get(a);
        numbersFrameLayout.addView(frameLayout);
        layoutParams = (LayoutParams) frameLayout.getLayoutParams();
        layoutParams.width = AndroidUtilities.dp(100);
        layoutParams.height = AndroidUtilities.dp(100);
        layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
        frameLayout.setLayoutParams(layoutParams);
    }
}

From source file:com.hippo.nimingban.ui.ListActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Intent intent;/*from   w ww .  j  a  va 2 s . c o  m*/
    switch (item.getItemId()) {
    case android.R.id.home:
        if (mSlidingDrawerLayout.isDrawerOpen(Gravity.LEFT)) {
            mSlidingDrawerLayout.closeDrawer(Gravity.LEFT);
        } else {
            mSlidingDrawerLayout.openDrawer(Gravity.LEFT);
        }
        mSlidingDrawerLayout.closeDrawer(Gravity.RIGHT);
        return true;
    case R.id.action_rule:
        if (mCurrentForum != null && mCurrentForum.getNMBMsg() != null) {
            View view = getLayoutInflater().inflate(R.layout.dialog_rule, null);
            TextView tv = (TextView) view.findViewById(R.id.text);
            tv.setText(fixURLSpan(Html.fromHtml(mCurrentForum.getNMBMsg(),
                    new URLImageGetter(tv, NMBApplication.getConaco(this)), null)));
            tv.setMovementMethod(new LinkMovementMethod2(ListActivity.this));
            new AlertDialog.Builder(this).setTitle(R.string.rule).setView(view).show();
        }
        return true;
    case R.id.action_create_post:
        if (mCurrentForum != null) {
            intent = new Intent(this, TypeSendActivity.class);
            intent.setAction(TypeSendActivity.ACTION_CREATE_POST);
            intent.putExtra(TypeSendActivity.KEY_SITE, mCurrentForum.getNMBSite().getId());
            intent.putExtra(TypeSendActivity.KEY_ID, mCurrentForum.getNMBId());
            startActivity(intent);
        }
        return true;
    case R.id.action_refresh:
        mPostHelper.refresh();
        return true;
    case R.id.action_sort_forums:
        intent = new Intent(this, SortForumsActivity.class);
        intent.putExtra(SortForumsActivity.KEY_SITE, ACSite.getInstance().getId()); // TODO support other site
        startActivityForResult(intent, REQUEST_CODE_SORT_FORUMS);
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.cssweb.android.base.QuoteGridActivity.java

private void AddViewItem(String paramString, int paramInt1, LinearLayout paramLinearLayout, int paramInt2,
        int paramInt3, int paramInt4, boolean paramBoolean) {
    TextView localTextView = new TextView(this);
    float f = this.mFontSize;

    localTextView.setTextSize(f);/*from w w  w.  ja v a 2s.com*/
    //??4?
    if (paramInt2 == paramInt4 && paramInt3 == 0 && nameOrcode) {

        if (this.mPaint.measureText(paramString) > textWeight)
            localTextView.setTextSize(13);
    }

    if (n2 == paramInt2) {
        String str = (n1 == 0) ? paramString + low : (n1 == 1) ? paramString + top : paramString;
        localTextView.setText(str);
    } else {
        localTextView.setText(paramString);
    }
    localTextView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
    localTextView.setFocusable(paramBoolean);
    localTextView.setOnClickListener(mClickListener);
    localTextView.setOnLongClickListener(mLongClickListener);
    localTextView.setOnTouchListener(this); //touch
    localTextView.setTag(paramInt2);
    localTextView.setEnabled(paramBoolean);
    localTextView.setSingleLine(false);
    if (paramInt4 == 0 && paramInt3 >= 0) {//
        localTextView.setGravity(Gravity.CENTER);
        int i1 = this.residTitleCol;
        int i8 = 0;
        localTextView.setTextColor(paramInt1);
        if (paramInt3 == 0) {
            localDrawable = getResources().getDrawable(i1);
            i8 = localDrawable.getIntrinsicWidth();
        } else if (paramInt3 == 100) {
            localDrawable = getResources().getDrawable(this.residTitleScrollCol[2]);
            i8 = localDrawable.getIntrinsicWidth();
        } else if (paramInt3 == 13) {
            localDrawable = getResources().getDrawable(this.residTitleScrollCol[0]);
            i8 = localDrawable.getIntrinsicWidth();
            i8 += 20;
        } else if (paramInt3 == 8) {
            localDrawable = getResources().getDrawable(this.residTitleScrollCol[0]);
            i8 = localDrawable.getIntrinsicWidth();
            i8 += 10;
        } else if (paramInt3 % 2 == 0) {
            localDrawable = getResources().getDrawable(this.residTitleScrollCol[1]);
            i8 = localDrawable.getIntrinsicWidth();
        } else {
            localDrawable = getResources().getDrawable(this.residTitleScrollCol[0]);
            i8 = localDrawable.getIntrinsicWidth();
        }
        localTextView.setBackgroundDrawable(localDrawable);
        int i6 = localDrawable.getIntrinsicHeight();
        localTextView.setHeight(i6 + CssSystem.getTableTitleHeight(this));
        //int i9 = (int) Math.max(i8, mPaint.measureText(paramString));
        localTextView.setWidth(i8);
        paramLinearLayout.addView(localTextView);
        return;
    }
    if (paramInt4 != 0 && paramInt3 >= 0) {
        int i8 = 0;
        localTextView.setTextColor(paramInt1);
        if (paramInt3 == 0) {
            localDrawable = getResources().getDrawable(this.residCol);
            i8 = localDrawable.getIntrinsicWidth();
        } else if (paramInt3 == 100) {
            localDrawable = getResources().getDrawable(this.residScrollCol[2]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();
        } else if (paramInt3 == 13) {
            localDrawable = getResources().getDrawable(this.residScrollCol[0]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();
            i8 += 20;
            //localTextView.setWidth(i8+20);
        } else if (paramInt3 == 8) {
            localDrawable = getResources().getDrawable(this.residScrollCol[0]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();
            i8 += 10;
            //localTextView.setWidth(i8+20);
        } else if (paramInt3 % 2 == 0) {
            localDrawable = getResources().getDrawable(this.residScrollCol[1]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();
        } else {
            localDrawable = getResources().getDrawable(this.residScrollCol[0]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();
        }
        localTextView.setBackgroundDrawable(localDrawable);
        int i6 = localDrawable.getIntrinsicHeight();
        localTextView.setHeight(i6 + rowHeight);
        //int i9 = (int) Math.max(i8, mPaint.measureText(paramString));
        localTextView.setWidth(i8);
        paramLinearLayout.addView(localTextView);
        return;
    }
    //      if ((paramInt3 == j) && (paramInt4 == l)) {
    //         int i13 = this.residTitleScrollCol[l];
    //         localDrawable = localResources.getDrawable(i13);
    //         localTextView.setTextColor(paramInt1);
    //         localTextView.setBackgroundDrawable(localDrawable);
    //         paramLinearLayout.addView(localTextView);
    //         return;
    //      }
}

From source file:com.zyk.drawerlayout.widget.DrawerLayout.java

/**
 * Enable or disable interaction with the given drawer.
 *
 * <p>This allows the application to restrict the user's ability to open or close
 * the given drawer. DrawerLayout will still respond to calls to {@link #openDrawer(int)},
 * {@link #closeDrawer(int)} and friends if a drawer is locked.</p>
 *
 * <p>Locking a drawer open or closed will implicitly open or close
 * that drawer as appropriate.</p>
 *
 * @param lockMode The new lock mode for the given drawer. One of {@link #LOCK_MODE_UNLOCKED},
 *                 {@link #LOCK_MODE_LOCKED_CLOSED} or {@link #LOCK_MODE_LOCKED_OPEN}.
 * @param edgeGravity Gravity.LEFT, RIGHT, START or END.
 *                    Expresses which drawer to change the mode for.
 *
 * @see #LOCK_MODE_UNLOCKED// w  w  w .  j av a2 s  . c o  m
 * @see #LOCK_MODE_LOCKED_CLOSED
 * @see #LOCK_MODE_LOCKED_OPEN
 */
public void setDrawerLockMode(@LockMode int lockMode, @EdgeGravity int edgeGravity) {
    final int absGravity = GravityCompat.getAbsoluteGravity(edgeGravity, ViewCompat.getLayoutDirection(this));

    switch (edgeGravity) {
    case Gravity.LEFT:
        mLockModeLeft = lockMode;
        break;
    case Gravity.TOP:
        mLockModeTop = lockMode;
        break;
    case Gravity.RIGHT:
        mLockModeRight = lockMode;
        break;
    case Gravity.BOTTOM:
        mLockModeBottom = lockMode;
        break;
    case GravityCompat.START:
        mLockModeStart = lockMode;
        break;
    case GravityCompat.END:
        mLockModeEnd = lockMode;
        break;
    }

    if (lockMode != LOCK_MODE_UNLOCKED) {
        // Cancel interaction in progress
        final ViewDragHelper helper;
        if (absGravity == Gravity.LEFT) {
            helper = mLeftDragger;
        } else if (absGravity == Gravity.TOP) {
            helper = mTopDragger;
        } else if (absGravity == Gravity.RIGHT) {
            helper = mRightDragger;
        } else {
            helper = mBottomDragger;
        }
        helper.cancel();
    }
    switch (lockMode) {
    case LOCK_MODE_LOCKED_OPEN:
        final View toOpen = findDrawerWithGravity(absGravity);
        if (toOpen != null) {
            openDrawer(toOpen);
        }
        break;
    case LOCK_MODE_LOCKED_CLOSED:
        final View toClose = findDrawerWithGravity(absGravity);
        if (toClose != null) {
            closeDrawer(toClose);
        }
        break;
    // default: do nothing
    }
}

From source file:ca.co.rufus.androidboilerplate.ui.DebugDrawerLayout.java

/**
 * Simple gravity to string - only supports LEFT and RIGHT for debugging output.
 *
 * @param gravity Absolute gravity value
 * @return LEFT or RIGHT as appropriate, or a hex string
 *///w  w w .j a va2  s  . co  m
static String gravityToString(@EdgeGravity int gravity) {
    if ((gravity & Gravity.LEFT) == Gravity.LEFT) {
        return "LEFT";
    }
    if ((gravity & Gravity.RIGHT) == Gravity.RIGHT) {
        return "RIGHT";
    }
    return Integer.toHexString(gravity);
}

From source file:android.support.v17.leanback.app.OnboardingSupportFragment.java

private Animator createAnimator(View view, boolean fadeIn, int slideDirection, long startDelay) {
    boolean isLtr = getView().getLayoutDirection() == View.LAYOUT_DIRECTION_LTR;
    boolean slideRight = (isLtr && slideDirection == Gravity.END) || (!isLtr && slideDirection == Gravity.START)
            || slideDirection == Gravity.RIGHT;
    Animator fadeAnimator;/*  w w  w.  j  av  a  2  s.  com*/
    Animator slideAnimator;
    if (fadeIn) {
        fadeAnimator = ObjectAnimator.ofFloat(view, View.ALPHA, 0.0f, 1.0f);
        slideAnimator = ObjectAnimator.ofFloat(view, View.TRANSLATION_X,
                slideRight ? sSlideDistance : -sSlideDistance, 0);
        fadeAnimator.setInterpolator(HEADER_APPEAR_INTERPOLATOR);
        slideAnimator.setInterpolator(HEADER_APPEAR_INTERPOLATOR);
    } else {
        fadeAnimator = ObjectAnimator.ofFloat(view, View.ALPHA, 1.0f, 0.0f);
        slideAnimator = ObjectAnimator.ofFloat(view, View.TRANSLATION_X, 0,
                slideRight ? sSlideDistance : -sSlideDistance);
        fadeAnimator.setInterpolator(HEADER_DISAPPEAR_INTERPOLATOR);
        slideAnimator.setInterpolator(HEADER_DISAPPEAR_INTERPOLATOR);
    }
    fadeAnimator.setDuration(HEADER_ANIMATION_DURATION_MS);
    fadeAnimator.setTarget(view);
    slideAnimator.setDuration(HEADER_ANIMATION_DURATION_MS);
    slideAnimator.setTarget(view);
    AnimatorSet animator = new AnimatorSet();
    animator.playTogether(fadeAnimator, slideAnimator);
    if (startDelay > 0) {
        animator.setStartDelay(startDelay);
    }
    return animator;
}

From source file:com.hippo.ehviewer.ui.scene.FavoritesScene.java

@Override
@Implemented(EasyRecyclerView.CustomChoiceListener.class)
public void onIntoCustomChoice(EasyRecyclerView view) {
    if (mFabLayout != null) {
        mFabLayout.setExpanded(true);/*www. ja  va 2  s.c  o m*/
    }
    if (mHelper != null) {
        mHelper.setRefreshLayoutEnable(false);
    }
    // Lock drawer
    setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.LEFT);
    setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.RIGHT);
}

From source file:com.nickandjerry.dynamiclayoutinflator.DynamicLayoutInflator.java

private static int parseGravity(String value) {
    int gravity = Gravity.NO_GRAVITY;
    String[] parts = value.toLowerCase().split("[|]");
    for (String part : parts) {
        switch (part) {
        case "center":
            gravity = gravity | Gravity.CENTER;
            break;
        case "left":
        case "textStart":
            gravity = gravity | Gravity.LEFT;
            break;
        case "right":
        case "textEnd":
            gravity = gravity | Gravity.RIGHT;
            break;
        case "top":
            gravity = gravity | Gravity.TOP;
            break;
        case "bottom":
            gravity = gravity | Gravity.BOTTOM;
            break;
        case "center_horizontal":
            gravity = gravity | Gravity.CENTER_HORIZONTAL;
            break;
        case "center_vertical":
            gravity = gravity | Gravity.CENTER_VERTICAL;
            break;
        }/*  w ww.  j av a 2s.  co m*/
    }
    return gravity;
}