Example usage for android.view Gravity END

List of usage examples for android.view Gravity END

Introduction

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

Prototype

int END

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

Click Source Link

Document

Push object to x-axis position at the end of its container, not changing its size.

Usage

From source file:com.maskyn.fileeditorpro.activity.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int i = item.getItemId();
    if (mDrawerToggle.onOptionsItemSelected(item)) {
        Toast.makeText(getBaseContext(), "drawer click", Toast.LENGTH_SHORT).show();
        mDrawerLayout.closeDrawer(Gravity.END);
        return true;
    } else if (i == R.id.im_save_normaly) {
        saveTheFile(false);//from  www.  j a v  a2 s.  com

    } else if (i == R.id.im_save_as) {
        saveTheFile(true);

    } else if (i == R.id.im_rename) {
        EditTextDialog.newInstance(EditTextDialog.Actions.Rename, greatUri.getFileName())
                .show(getFragmentManager().beginTransaction(), "dialog");
    } else if (i == R.id.im_undo) {
        mEditor.onTextContextMenuItem(ID_UNDO);

    } else if (i == R.id.im_redo) {
        mEditor.onTextContextMenuItem(ID_REDO);

    } else if (i == R.id.im_search) {
        FindTextDialog.newInstance(mEditor.getText().toString()).show(getFragmentManager().beginTransaction(),
                "dialog");
    } else if (i == R.id.im_cancel) {
        searchResult = null;
        invalidateOptionsMenu();

    } else if (i == R.id.im_replace) {
        replaceText(false);

    } else if (i == R.id.im_replace_all) {
        replaceText(true);

    } else if (i == R.id.im_next_item) {
        nextResult();

    } else if (i == R.id.im_previous_item) {
        previousResult();

    } else if (i == R.id.im_goto_line) {
        int min = mEditor.getLineUtils().firstReadLine();
        int max = mEditor.getLineUtils().lastReadLine();
        NumberPickerDialog.newInstance(NumberPickerDialog.Actions.GoToLine, min, min, max)
                .show(getFragmentManager().beginTransaction(), "dialog");
    } else if (i == R.id.im_view_it_on_browser) {
        Intent browserIntent;
        try {
            browserIntent = new Intent(Intent.ACTION_VIEW);
            browserIntent.setDataAndType(greatUri.getUri(), "*/*");
            startActivity(browserIntent);
        } catch (ActivityNotFoundException ex2) {
            //
        }

    } else if (i == R.id.im_view_markdown) {
        Intent browserIntent = new Intent(MainActivity.this, MarkdownActivity.class);
        browserIntent.putExtra("text", pageSystem.getAllText(mEditor.getText().toString()));
        startActivity(browserIntent);
    } else if (i == R.id.im_info) {
        FileInfoDialog.newInstance(greatUri.getUri()).show(getFragmentManager().beginTransaction(), "dialog");
    } else if (i == R.id.im_donate) {
        final String appPackageName = "com.maskyn.fileeditorpro";
        try {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
        } catch (android.content.ActivityNotFoundException anfe) {
            startActivity(new Intent(Intent.ACTION_VIEW,
                    Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
        }
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.htc.dotdesign.ToolBoxService.java

private void initDragButton() {
    //Initialize drag button
    if (mDragButton != null) {
        mCurrFuncIcon = (ImageView) mDragButton.findViewById(R.id.curr_func_icon);

        if (mDragBtnColorIcon != null) {
            mDragBtnColorIcon.setColor(mCurrBrushColor);
            mCurrFuncIcon.setBackground(mDragBtnColorIcon);
        }/*from   ww  w. j  ava 2 s .  c  o  m*/

        mDragButton.setOnTouchListener(new OnTouchListener() {
            //private int initialX;
            private int initialY;
            private float initialTouchX;
            private float initialTouchY;
            private boolean mIsMoving = false;
            private boolean mIsTryMoving = false;

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                Log.d(DotDesignConstants.LOG_TAG, LOG_PREFIX + "onTouch");
                switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    Log.d(DotDesignConstants.LOG_TAG, LOG_PREFIX + "onTouch, ACTION_DOWN");
                    //initialX = mDragButtonParams.x;
                    initialY = mDragButtonParams.y;
                    initialTouchX = event.getRawX();
                    initialTouchY = event.getRawY();
                    break;
                case MotionEvent.ACTION_UP:
                    Log.d(DotDesignConstants.LOG_TAG, LOG_PREFIX + "onTouch, ACTION_UP");
                    if (!mIsMoving && !mIsTryMoving) {
                        if (!mbIsAnimationPlaying) {
                            if (mIsToolBarOpen) {
                                if (mIsToolBarExtend) {
                                    setToolPanelVisibility(false);
                                } else {
                                    mToolBar.clearAnimation();
                                    if (mCurrLayoutMode == LayoutMode.LEFT_SIDE) {
                                        playAnimation(mToolBar, mLeftOut);
                                    } else if (mCurrLayoutMode == LayoutMode.RIGHT_SIDE) {
                                        playAnimation(mToolBar, mRightOut);
                                    }
                                }
                            } else {
                                if (mCurrLayoutMode == LayoutMode.LEFT_SIDE) {
                                    mToolBarParams.gravity = Gravity.START;
                                } else if (mCurrLayoutMode == LayoutMode.RIGHT_SIDE) {
                                    mToolBarParams.gravity = Gravity.END;
                                }
                                mToolBarParams.gravity = Gravity.TOP | mToolBarParams.gravity;
                                mToolBarParams.x = 0;
                                mToolBarParams.y = mDragButtonParams.y;
                                mWindowManager.updateViewLayout(mToolBarParent, mToolBarParams);
                                mToolBarParent.setVisibility(View.VISIBLE);

                                mToolBar.clearAnimation();
                                mToolBar.setVisibility(View.VISIBLE);
                                if (mCurrLayoutMode == LayoutMode.LEFT_SIDE) {
                                    playAnimation(mToolBar, mLeftIn);
                                } else if (mCurrLayoutMode == LayoutMode.RIGHT_SIDE) {
                                    playAnimation(mToolBar, mRightIn);
                                }
                            }
                        }
                    } else {
                        mIsTryMoving = false;
                        mIsMoving = false;

                        /*if (mDragButtonParams.x <= mScreenWidth / 2) {
                            mDragButtonParams.x = 0;
                            mWindowManager.updateViewLayout(mDragButton, mDragButtonParams);
                            mCurrLayoutMode = LayoutMode.LEFT_SIDE;
                        } else {
                            mDragButtonParams.x = mScreenWidth - mDragButtonWidth;
                            mWindowManager.updateViewLayout(mDragButton, mDragButtonParams);
                            mCurrLayoutMode = LayoutMode.RIGHT_SIDE;
                        }*/
                    }
                    // mDragButton.setBackgroundResource(R.drawable.floating2);
                    break;
                case MotionEvent.ACTION_MOVE:
                    Log.d(DotDesignConstants.LOG_TAG,
                            LOG_PREFIX + "onTouch, ACTION_MOVE, mToolBox.getHeight()" + mToolBar.getHeight());
                    if (Math.abs(event.getRawX() - initialTouchX) > 10
                            || Math.abs(event.getRawY() - initialTouchY) > 10) {
                        mIsTryMoving = true;
                    }
                    if (/*!mIsToolBarExtend && */mIsTryMoving) {
                        mIsMoving = true;
                        // paramsF.x = initialX + (int) (event.getRawX() - initialTouchX);
                        mDragButtonParams.y = initialY + (int) (event.getRawY() - initialTouchY);
                        if (mDragButtonParams.y < 0) {
                            mDragButtonParams.y = 0;
                        } else if (mDragButtonParams.y > mScreenHeight - mDragButtonHeight) {
                            mDragButtonParams.y = mScreenHeight - mDragButtonHeight;
                        }

                        mWindowManager.updateViewLayout(mDragButton, mDragButtonParams);
                        // mDragButton.setBackgroundResource(R.drawable.ic_launcher);

                        if (mIsToolBarOpen) {
                            mToolBarParams.y = mDragButtonParams.y;
                            mWindowManager.updateViewLayout(mToolBarParent, mToolBarParams);
                        }

                        if (mIsToolBarExtend) {
                            setToolPanelVisibility(false);
                        }
                    }
                    break;
                }
                return true;
            }
        });
    }
}

From source file:com.facebook.litho.widget.TextSpec.java

private static Alignment getAlignment(int gravity) {
    final Alignment alignment;
    switch (gravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) {
    case Gravity.START:
        alignment = ALIGN_NORMAL;//from  w ww.ja v a 2s.c  om
        break;
    case Gravity.END:
        alignment = ALIGN_OPPOSITE;
        break;
    case Gravity.LEFT: // unsupported, default to normal
        alignment = ALIGN_NORMAL;
        break;
    case Gravity.RIGHT: // unsupported, default to opposite
        alignment = ALIGN_OPPOSITE;
        break;
    case Gravity.CENTER_HORIZONTAL:
        alignment = ALIGN_CENTER;
        break;
    default:
        alignment = textAlignment;
        break;
    }
    return alignment;
}

From source file:com.github.shareme.gwsmaterialuikit.library.material.widget.EditText.java

@Override
protected void applyStyle(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super.applyStyle(context, attrs, defStyleAttr, defStyleRes);

    CharSequence text = mInputView == null ? null : mInputView.getText();
    removeAllViews();//from   w  ww .j  a va  2 s . c om

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.EditText, defStyleAttr, defStyleRes);

    int labelPadding = -1;
    int labelTextSize = -1;
    ColorStateList labelTextColor = null;
    int supportPadding = -1;
    int supportTextSize = -1;
    ColorStateList supportColors = null;
    ColorStateList supportErrorColors = null;
    String supportHelper = null;
    String supportError = null;
    ColorStateList dividerColors = null;
    ColorStateList dividerErrorColors = null;
    int dividerHeight = -1;
    int dividerPadding = -1;
    int dividerAnimDuration = -1;

    mAutoCompleteMode = a.getInteger(R.styleable.EditText_et_autoCompleteMode, mAutoCompleteMode);
    if (needCreateInputView(mAutoCompleteMode)) {
        switch (mAutoCompleteMode) {
        case AUTOCOMPLETE_MODE_SINGLE:
            mInputView = new InternalAutoCompleteTextView(context, attrs, defStyleAttr);
            break;
        case AUTOCOMPLETE_MODE_MULTI:
            mInputView = new InternalMultiAutoCompleteTextView(context, attrs, defStyleAttr);
            break;
        default:
            mInputView = new InternalEditText(context, attrs, defStyleAttr);
            break;
        }
        ViewUtil.applyFont(mInputView, attrs, defStyleAttr, defStyleRes);
        if (text != null)
            mInputView.setText(text);

        mInputView.addTextChangedListener(new InputTextWatcher());

        if (mDivider != null) {
            mDivider.setAnimEnable(false);
            ViewUtil.setBackground(mInputView, mDivider);
            mDivider.setAnimEnable(true);
        }
    } else
        ViewUtil.applyStyle(mInputView, attrs, defStyleAttr, defStyleRes);
    mInputView.setVisibility(View.VISIBLE);
    mInputView.setFocusableInTouchMode(true);

    for (int i = 0, count = a.getIndexCount(); i < count; i++) {
        int attr = a.getIndex(i);

        if (attr == R.styleable.EditText_et_labelEnable)
            mLabelEnable = a.getBoolean(attr, false);
        else if (attr == R.styleable.EditText_et_labelPadding)
            labelPadding = a.getDimensionPixelSize(attr, 0);
        else if (attr == R.styleable.EditText_et_labelTextSize)
            labelTextSize = a.getDimensionPixelSize(attr, 0);
        else if (attr == R.styleable.EditText_et_labelTextColor)
            labelTextColor = a.getColorStateList(attr);
        else if (attr == R.styleable.EditText_et_labelTextAppearance)
            getLabelView().setTextAppearance(context, a.getResourceId(attr, 0));
        else if (attr == R.styleable.EditText_et_labelEllipsize) {
            int labelEllipsize = a.getInteger(attr, 0);
            switch (labelEllipsize) {
            case 1:
                getLabelView().setEllipsize(TruncateAt.START);
                break;
            case 2:
                getLabelView().setEllipsize(TruncateAt.MIDDLE);
                break;
            case 3:
                getLabelView().setEllipsize(TruncateAt.END);
                break;
            case 4:
                getLabelView().setEllipsize(TruncateAt.MARQUEE);
                break;
            default:
                getLabelView().setEllipsize(TruncateAt.END);
                break;
            }
        } else if (attr == R.styleable.EditText_et_labelInAnim)
            mLabelInAnimId = a.getResourceId(attr, 0);
        else if (attr == R.styleable.EditText_et_labelOutAnim)
            mLabelOutAnimId = a.getResourceId(attr, 0);
        else if (attr == R.styleable.EditText_et_supportMode)
            mSupportMode = a.getInteger(attr, 0);
        else if (attr == R.styleable.EditText_et_supportPadding)
            supportPadding = a.getDimensionPixelSize(attr, 0);
        else if (attr == R.styleable.EditText_et_supportTextSize)
            supportTextSize = a.getDimensionPixelSize(attr, 0);
        else if (attr == R.styleable.EditText_et_supportTextColor)
            supportColors = a.getColorStateList(attr);
        else if (attr == R.styleable.EditText_et_supportTextErrorColor)
            supportErrorColors = a.getColorStateList(attr);
        else if (attr == R.styleable.EditText_et_supportTextAppearance)
            getSupportView().setTextAppearance(context, a.getResourceId(attr, 0));
        else if (attr == R.styleable.EditText_et_supportEllipsize) {
            int supportEllipsize = a.getInteger(attr, 0);
            switch (supportEllipsize) {
            case 1:
                getSupportView().setEllipsize(TruncateAt.START);
                break;
            case 2:
                getSupportView().setEllipsize(TruncateAt.MIDDLE);
                break;
            case 3:
                getSupportView().setEllipsize(TruncateAt.END);
                break;
            case 4:
                getSupportView().setEllipsize(TruncateAt.MARQUEE);
                break;
            default:
                getSupportView().setEllipsize(TruncateAt.END);
                break;
            }
        } else if (attr == R.styleable.EditText_et_supportMaxLines)
            getSupportView().setMaxLines(a.getInteger(attr, 0));
        else if (attr == R.styleable.EditText_et_supportLines)
            getSupportView().setLines(a.getInteger(attr, 0));
        else if (attr == R.styleable.EditText_et_supportSingleLine)
            getSupportView().setSingleLine(a.getBoolean(attr, false));
        else if (attr == R.styleable.EditText_et_supportMaxChars)
            mSupportMaxChars = a.getInteger(attr, 0);
        else if (attr == R.styleable.EditText_et_helper)
            supportHelper = a.getString(attr);
        else if (attr == R.styleable.EditText_et_error)
            supportError = a.getString(attr);
        else if (attr == R.styleable.EditText_et_inputId)
            mInputView.setId(a.getResourceId(attr, 0));
        else if (attr == R.styleable.EditText_et_dividerColor)
            dividerColors = a.getColorStateList(attr);
        else if (attr == R.styleable.EditText_et_dividerErrorColor)
            dividerErrorColors = a.getColorStateList(attr);
        else if (attr == R.styleable.EditText_et_dividerHeight)
            dividerHeight = a.getDimensionPixelSize(attr, 0);
        else if (attr == R.styleable.EditText_et_dividerPadding)
            dividerPadding = a.getDimensionPixelSize(attr, 0);
        else if (attr == R.styleable.EditText_et_dividerAnimDuration)
            dividerAnimDuration = a.getInteger(attr, 0);
        else if (attr == R.styleable.EditText_et_dividerCompoundPadding)
            mDividerCompoundPadding = a.getBoolean(attr, true);
    }

    a.recycle();

    if (mInputView.getId() == 0)
        mInputView.setId(ViewUtil.generateViewId());

    if (mDivider == null) {
        mDividerColors = dividerColors;
        mDividerErrorColors = dividerErrorColors;

        if (mDividerColors == null) {
            int[][] states = new int[][] { new int[] { -android.R.attr.state_focused },
                    new int[] { android.R.attr.state_focused, android.R.attr.state_enabled }, };
            int[] colors = new int[] { ThemeUtil.colorControlNormal(context, 0xFF000000),
                    ThemeUtil.colorControlActivated(context, 0xFF000000), };

            mDividerColors = new ColorStateList(states, colors);
        }

        if (mDividerErrorColors == null)
            mDividerErrorColors = ColorStateList.valueOf(ThemeUtil.colorAccent(context, 0xFFFF0000));

        if (dividerHeight < 0)
            dividerHeight = 0;

        if (dividerPadding < 0)
            dividerPadding = 0;

        if (dividerAnimDuration < 0)
            dividerAnimDuration = context.getResources().getInteger(android.R.integer.config_shortAnimTime);

        mDividerPadding = dividerPadding;
        mInputView.setPadding(0, 0, 0, mDividerPadding + dividerHeight);

        mDivider = new DividerDrawable(dividerHeight,
                mDividerCompoundPadding ? mInputView.getTotalPaddingLeft() : 0,
                mDividerCompoundPadding ? mInputView.getTotalPaddingRight() : 0, mDividerColors,
                dividerAnimDuration);
        mDivider.setInEditMode(isInEditMode());
        mDivider.setAnimEnable(false);
        ViewUtil.setBackground(mInputView, mDivider);
        mDivider.setAnimEnable(true);
    } else {
        if (dividerHeight >= 0 || dividerPadding >= 0) {
            if (dividerHeight < 0)
                dividerHeight = mDivider.getDividerHeight();

            if (dividerPadding >= 0)
                mDividerPadding = dividerPadding;

            mInputView.setPadding(0, 0, 0, mDividerPadding + dividerHeight);
            mDivider.setDividerHeight(dividerHeight);
            mDivider.setPadding(mDividerCompoundPadding ? mInputView.getTotalPaddingLeft() : 0,
                    mDividerCompoundPadding ? mInputView.getTotalPaddingRight() : 0);
        }

        if (dividerColors != null)
            mDividerColors = dividerColors;

        if (dividerErrorColors != null)
            mDividerErrorColors = dividerErrorColors;

        mDivider.setColor(getError() == null ? mDividerColors : mDividerErrorColors);

        if (dividerAnimDuration >= 0)
            mDivider.setAnimationDuration(dividerAnimDuration);
    }

    if (labelPadding >= 0)
        getLabelView().setPadding(mDivider.getPaddingLeft(), 0, mDivider.getPaddingRight(), labelPadding);

    if (labelTextSize >= 0)
        getLabelView().setTextSize(TypedValue.COMPLEX_UNIT_PX, labelTextSize);

    if (labelTextColor != null)
        getLabelView().setTextColor(labelTextColor);

    if (mLabelEnable) {
        mLabelVisible = true;
        getLabelView().setText(mInputView.getHint());
        addView(getLabelView(), 0, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        setLabelVisible(!TextUtils.isEmpty(mInputView.getText().toString()), false);
    }

    if (supportTextSize >= 0)
        getSupportView().setTextSize(TypedValue.COMPLEX_UNIT_PX, supportTextSize);

    if (supportColors != null)
        mSupportColors = supportColors;
    else if (mSupportColors == null)
        mSupportColors = context.getResources().getColorStateList(R.color.abc_secondary_text_material_light);

    if (supportErrorColors != null)
        mSupportErrorColors = supportErrorColors;
    else if (mSupportErrorColors == null)
        mSupportErrorColors = ColorStateList.valueOf(ThemeUtil.colorAccent(context, 0xFFFF0000));

    if (supportPadding >= 0)
        getSupportView().setPadding(mDivider.getPaddingLeft(), supportPadding, mDivider.getPaddingRight(), 0);

    if (supportHelper == null && supportError == null)
        getSupportView().setTextColor(getError() == null ? mSupportColors : mSupportErrorColors);
    else if (supportHelper != null)
        setHelper(supportHelper);
    else
        setError(supportError);

    if (mSupportMode != SUPPORT_MODE_NONE) {
        switch (mSupportMode) {
        case SUPPORT_MODE_CHAR_COUNTER:
            getSupportView().setGravity(Gravity.END);
            updateCharCounter(mInputView.getText().length());
            break;
        case SUPPORT_MODE_HELPER:
        case SUPPORT_MODE_HELPER_WITH_ERROR:
            getSupportView().setGravity(GravityCompat.START);
            break;
        }
        addView(getSupportView(), new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
    }

    addView(mInputView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    requestLayout();
}

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

/**
 * Called when the page changes.//from  w  w w  .  ja v a2s  .c o m
 */
private void onPageChangedInternal(int previousPage) {
    if (mAnimator != null) {
        mAnimator.end();
    }
    mPageIndicator.onPageSelected(mCurrentPageIndex, true);

    List<Animator> animators = new ArrayList<>();
    // Header animation
    Animator fadeAnimator = null;
    if (previousPage < getCurrentPageIndex()) {
        // sliding to left
        animators.add(createAnimator(mTitleView, false, Gravity.START, 0));
        animators.add(fadeAnimator = createAnimator(mDescriptionView, false, Gravity.START,
                DESCRIPTION_START_DELAY_MS));
        animators.add(createAnimator(mTitleView, true, Gravity.END, HEADER_APPEAR_DELAY_MS));
        animators.add(createAnimator(mDescriptionView, true, Gravity.END,
                HEADER_APPEAR_DELAY_MS + DESCRIPTION_START_DELAY_MS));
    } else {
        // sliding to right
        animators.add(createAnimator(mTitleView, false, Gravity.END, 0));
        animators.add(fadeAnimator = createAnimator(mDescriptionView, false, Gravity.END,
                DESCRIPTION_START_DELAY_MS));
        animators.add(createAnimator(mTitleView, true, Gravity.START, HEADER_APPEAR_DELAY_MS));
        animators.add(createAnimator(mDescriptionView, true, Gravity.START,
                HEADER_APPEAR_DELAY_MS + DESCRIPTION_START_DELAY_MS));
    }
    final int currentPageIndex = getCurrentPageIndex();
    fadeAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mTitleView.setText(getPageTitle(currentPageIndex));
            mDescriptionView.setText(getPageDescription(currentPageIndex));
        }
    });

    // Animator for switching between page indicator and button.
    if (getCurrentPageIndex() == getPageCount() - 1) {
        mStartButton.setVisibility(View.VISIBLE);
        Animator navigatorFadeOutAnimator = AnimatorInflater.loadAnimator(getActivity(),
                R.animator.lb_onboarding_page_indicator_fade_out);
        navigatorFadeOutAnimator.setTarget(mPageIndicator);
        navigatorFadeOutAnimator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                mPageIndicator.setVisibility(View.GONE);
            }
        });
        animators.add(navigatorFadeOutAnimator);
        Animator buttonFadeInAnimator = AnimatorInflater.loadAnimator(getActivity(),
                R.animator.lb_onboarding_start_button_fade_in);
        buttonFadeInAnimator.setTarget(mStartButton);
        animators.add(buttonFadeInAnimator);
    } else if (previousPage == getPageCount() - 1) {
        mPageIndicator.setVisibility(View.VISIBLE);
        Animator navigatorFadeInAnimator = AnimatorInflater.loadAnimator(getActivity(),
                R.animator.lb_onboarding_page_indicator_fade_in);
        navigatorFadeInAnimator.setTarget(mPageIndicator);
        animators.add(navigatorFadeInAnimator);
        Animator buttonFadeOutAnimator = AnimatorInflater.loadAnimator(getActivity(),
                R.animator.lb_onboarding_start_button_fade_out);
        buttonFadeOutAnimator.setTarget(mStartButton);
        buttonFadeOutAnimator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                mStartButton.setVisibility(View.GONE);
            }
        });
        animators.add(buttonFadeOutAnimator);
    }
    mAnimator = new AnimatorSet();
    mAnimator.playTogether(animators);
    mAnimator.start();
    onPageChanged(mCurrentPageIndex, previousPage);
}

From source file:im.neon.adapters.VectorMessagesAdapter.java

/**
 * The user taps on the action icon.// w ww  .j av  a 2  s.co  m
 * @param event the selected event.
 * @param textMsg the event text
 * @param anchorView the popup anchor.
 */
@SuppressLint("NewApi")
private void onMessageClick(final Event event, final String textMsg, final View anchorView) {
    final PopupMenu popup = (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
            ? new PopupMenu(mContext, anchorView, Gravity.END)
            : new PopupMenu(mContext, anchorView);

    popup.getMenuInflater().inflate(R.menu.vector_room_message_settings, popup.getMenu());

    // force to display the icons
    try {
        Field[] fields = popup.getClass().getDeclaredFields();
        for (Field field : fields) {
            if ("mPopup".equals(field.getName())) {
                field.setAccessible(true);
                Object menuPopupHelper = field.get(popup);
                Class<?> classPopupHelper = Class.forName(menuPopupHelper.getClass().getName());
                Method setForceIcons = classPopupHelper.getMethod("setForceShowIcon", boolean.class);
                setForceIcons.invoke(menuPopupHelper, true);
                break;
            }
        }
    } catch (Exception e) {
        Log.e(LOG_TAG, "onMessageClick : force to display the icons failed " + e.getLocalizedMessage());
    }

    Menu menu = popup.getMenu();

    // hide entries
    for (int i = 0; i < menu.size(); i++) {
        menu.getItem(i).setVisible(false);
    }

    menu.findItem(R.id.ic_action_view_source).setVisible(true);
    menu.findItem(R.id.ic_action_vector_permalink).setVisible(true);

    if (!TextUtils.isEmpty(textMsg)) {
        menu.findItem(R.id.ic_action_vector_copy).setVisible(true);
        menu.findItem(R.id.ic_action_vector_quote).setVisible(true);
    }

    if (event.isUploadingMedias(mMediasCache)) {
        menu.findItem(R.id.ic_action_vector_cancel_upload).setVisible(true);
    }

    if (event.isDownloadingMedias(mMediasCache)) {
        menu.findItem(R.id.ic_action_vector_cancel_download).setVisible(true);
    }

    if (event.canBeResent()) {
        menu.findItem(R.id.ic_action_vector_resend_message).setVisible(true);

        if (event.isUndeliverable() || event.isUnkownDevice()) {
            menu.findItem(R.id.ic_action_vector_redact_message).setVisible(true);
        }
    } else if (event.mSentState == Event.SentState.SENT) {

        // test if the event can be redacted
        boolean canBeRedacted = !mIsPreviewMode
                && !TextUtils.equals(event.getType(), Event.EVENT_TYPE_MESSAGE_ENCRYPTION);

        if (canBeRedacted) {
            // oneself message -> can redact it
            if (TextUtils.equals(event.sender, mSession.getMyUserId())) {
                canBeRedacted = true;
            } else {
                // need the mininum power level to redact an event
                Room room = mSession.getDataHandler().getRoom(event.roomId);

                if ((null != room) && (null != room.getLiveState().getPowerLevels())) {
                    PowerLevels powerLevels = room.getLiveState().getPowerLevels();
                    canBeRedacted = powerLevels.getUserPowerLevel(mSession.getMyUserId()) >= powerLevels.redact;
                }
            }
        }

        menu.findItem(R.id.ic_action_vector_redact_message).setVisible(canBeRedacted);

        if (Event.EVENT_TYPE_MESSAGE.equals(event.getType())) {
            Message message = JsonUtils.toMessage(event.getContentAsJsonObject());

            // share / forward the message
            menu.findItem(R.id.ic_action_vector_share).setVisible(true);
            menu.findItem(R.id.ic_action_vector_forward).setVisible(true);

            // save the media in the downloads directory
            if (Message.MSGTYPE_IMAGE.equals(message.msgtype) || Message.MSGTYPE_VIDEO.equals(message.msgtype)
                    || Message.MSGTYPE_FILE.equals(message.msgtype)) {
                menu.findItem(R.id.ic_action_vector_save).setVisible(true);
            }

            // offer to report a message content
            menu.findItem(R.id.ic_action_vector_report)
                    .setVisible(!mIsPreviewMode && !TextUtils.equals(event.sender, mSession.getMyUserId()));
        }

    }

    // e2e
    menu.findItem(R.id.ic_action_device_verification).setVisible(mE2eIconByEventId.containsKey(event.eventId));

    // display the menu
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(final MenuItem item) {
            // warn the listener
            if (null != mVectorMessagesAdapterEventsListener) {
                mVectorMessagesAdapterEventsListener.onEventAction(event, textMsg, item.getItemId());
            }

            // disable the selection
            mHighlightedEventId = null;
            notifyDataSetChanged();

            return true;
        }
    });

    // fix an issue reported by GA
    try {
        popup.show();
    } catch (Exception e) {
        Log.e(LOG_TAG, " popup.show failed " + e.getMessage());
    }
}

From source file:com.example.leebeomwoo.viewbody_final.MainActivity.java

public void popupDisplay() {
    View popupView = getLayoutInflater().inflate(R.layout.menu, null);
    /**/*from   ww  w . j a va2s  . c o m*/
     * LayoutParams WRAP_CONTENT  inflate? View? ? ??
     * PopupWinidow ?.
     *
     mPopupWindow = new PopupWindow(popupView,
     RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
     */
    mPopupWindow = new PopupWindow(popupView, 1000, RelativeLayout.LayoutParams.MATCH_PARENT);
    cancel_menuBtn = popupView.findViewById(R.id.cancel_menuBtn);
    account_menuBtn = popupView.findViewById(R.id.account_menuBtn);
    body_menuBtn = popupView.findViewById(R.id.body_menuBtn);
    follow_menuBtn = popupView.findViewById(R.id.follow_menuBtn);
    food_menuBtn = popupView.findViewById(R.id.food_menuBtn);
    qna_menuBtn = popupView.findViewById(R.id.qna_Btn);
    writer_menuBtn = popupView.findViewById(R.id.writer_menuBtn);
    menu_list = popupView.findViewById(R.id.menu_list);
    menu_Scroll = popupView.findViewById(R.id.menu_Scroll);
    btn_View = popupView.findViewById(R.id.btn_View);
    main = popupView.findViewById(R.id.menu_main);
    top = popupView.findViewById(R.id.menu_top);
    menuHomeBtn = popupView.findViewById(R.id.menuBtn_home);
    //licenseBtn = popupView.findViewById(R.id.license_Btn);
    license_source = popupView.findViewById(R.id.sourceTxt);
    license_Title = popupView.findViewById(R.id.titleTxt);
    checkedTextView = popupView.findViewById(R.id.menuchecked);

    cancel_menuBtn.setOnClickListener(this);
    account_menuBtn.setOnClickListener(this);
    body_menuBtn.setOnClickListener(this);
    follow_menuBtn.setOnClickListener(this);
    food_menuBtn.setOnClickListener(this);
    qna_menuBtn.setOnClickListener(this);
    writer_menuBtn.setOnClickListener(this);
    // licenseBtn.setOnClickListener(this);
    checkedTextView.setOnClickListener(this);
    SharedPreferences preferencesCompat = getSharedPreferences("a", MODE_PRIVATE);
    int tutorial = preferencesCompat.getInt("First", 0);
    if (tutorial == 0) {
        checkedTextView.setChecked(true);
    } else {
        checkedTextView.setChecked(false);
    }
    menu_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {
            final String item = (String) parent.getItemAtPosition(position);
            switch (item) {
            case "? ?":
                bodyTab_sub = new BodyTab_Sub();
                bodyTab_sub.setTabitemSelected(0);
                mPopupWindow.dismiss();
                break;
            case "? ":
                bodyTab_sub = new BodyTab_Sub();
                bodyTab_sub.setTabitemSelected(1);
                mPopupWindow.dismiss();
                break;
            case " ?":
                bodyTab_sub = new BodyTab_Sub();
                bodyTab_sub.setTabitemSelected(2);
                mPopupWindow.dismiss();
                break;
            case " ":
                bodyTab_sub = new BodyTab_Sub();
                bodyTab_sub.setTabitemSelected(3);
                mPopupWindow.dismiss();
                break;
            case "":
                bodyTab_sub = new BodyTab_Sub();
                bodyTab_sub.setTabitemSelected(4);
                mPopupWindow.dismiss();
                break;
            case " ?":
                followTab_sub = new FollowTab_Sub();
                followTab_sub.setTabitemSelected(0);
                mPopupWindow.dismiss();
                break;
            case "?":
                followTab_sub = new FollowTab_Sub();
                followTab_sub.setTabitemSelected(1);
                mPopupWindow.dismiss();
                break;
            case "?":
                followTab_sub = new FollowTab_Sub();
                followTab_sub.setTabitemSelected(2);
                mPopupWindow.dismiss();
                break;
            case " ?":
                followTab_sub = new FollowTab_Sub();
                followTab_sub.setTabitemSelected(3);
                mPopupWindow.dismiss();
                break;
            case "?":
                foodTab_sub = new FoodTab_Sub();
                foodTab_sub.setTabitemSelected(0);
                mPopupWindow.dismiss();
                break;
            case "":
                foodTab_sub = new FoodTab_Sub();
                foodTab_sub.setTabitemSelected(1);
                mPopupWindow.dismiss();
                break;
            case "?":
                foodTab_sub = new FoodTab_Sub();
                foodTab_sub.setTabitemSelected(2);
                mPopupWindow.dismiss();
                break;
            case "":
                foodTab_sub = new FoodTab_Sub();
                foodTab_sub.setTabitemSelected(3);
                mPopupWindow.dismiss();
                break;
            case "?":
                foodTab_sub = new FoodTab_Sub();
                foodTab_sub.setTabitemSelected(4);
                mPopupWindow.dismiss();
                break;
            case "?":
                writerTab_sub = new WriterTab_Sub();
                writerTab_sub.setTabitemSelected(0);
                mPopupWindow.dismiss();
                break;
            case "?":
                writerTab_sub = new WriterTab_Sub();
                writerTab_sub.setTabitemSelected(1);
                mPopupWindow.dismiss();
                break;

            }
        }

    });
    /**
     * @View anchor : anchor View    ? .
     * @ :  anchor View ?   View? ?
     * ??  ? .
     * xoff, yoff : anchor View  PopupWindow xoff x,
     * yoff y ? ??? ? ? .
     * @int xoff : -?(  ??), +?(  ??)
     * @int yoff : -?(  ??), +?(  ??)
     * achor View  ? ? .
     *  ,  ?? . ( ? ?)
     * mPopupWindow.showAsDropDown(btn_Popup, 50, 50);
     */
    mPopupWindow.setAnimationStyle(-1); // ? (-1:, 0:)

    /**
     * showAtLocation(parent, gravity, x, y)
     * @praent : PopupWindow ?? parent View 
     * View v = (View) findViewById(R.id.btn_click)?  parent ?
     * @gravity : parent View? Gravity ?  Popupwindow ? ?? .
     * @x : PopupWindow (-x, +x) ? , ??? ? ?
     * @y : PopupWindow (-y, +y) ? ?, ??? ? ?
     * mPopupWindow.showAtLocation(popupView, Gravity.NO_GRAVITY, 0, 0);
     * */
    //mPopupWindow.showAtLocation(popupView, Gravity.CENTER, 0, 0);
    /**
     * update()   PopupWindow?  ?, x, y
     * anchor View   .
     * mPopupWindow.update(anchor, xoff, yoff, width, height)(width, height);
     */
    mPopupWindow.setFocusable(true);
    mPopupWindow.setOutsideTouchable(true);
    Log.d("popup", "display");
    mPopupWindow.showAsDropDown(popupView, Gravity.END, 0, 0);
}

From source file:net.opacapp.multilinecollapsingtoolbar.CollapsingTextHelper.java

private void calculateUsingTextSize(final float textSize) {
    if (mText == null)
        return;/*w w  w .  j a v a2  s .  c  o  m*/
    final float availableWidth;
    final float newTextSize;
    boolean updateDrawText = false;
    // BEGIN MODIFICATION: Add maxLines variable
    int maxLines;
    // END MODIFICATION
    if (isClose(textSize, mCollapsedTextSize)) {
        availableWidth = mCollapsedBounds.width();
        newTextSize = mCollapsedTextSize;
        mScale = 1f;
        if (mCurrentTypeface != mCollapsedTypeface) {
            mCurrentTypeface = mCollapsedTypeface;
            updateDrawText = true;
        }
        // BEGIN MODIFICATION: Set maxLines variable
        maxLines = 1;
        // END MODIFICATION
    } else {
        availableWidth = mExpandedBounds.width();
        newTextSize = mExpandedTextSize;
        if (mCurrentTypeface != mExpandedTypeface) {
            mCurrentTypeface = mExpandedTypeface;
            updateDrawText = true;
        }
        if (isClose(textSize, mExpandedTextSize)) {
            // If we're close to the expanded text size, snap to it and use a scale of 1
            mScale = 1f;
        } else {
            // Else, we'll scale down from the expanded text size
            mScale = textSize / mExpandedTextSize;
        }
        // BEGIN MODIFICATION: Set maxLines variable
        maxLines = this.maxLines;
        // END MODIFICATION
    }
    if (availableWidth > 0) {
        updateDrawText = (mCurrentTextSize != newTextSize) || mBoundsChanged || updateDrawText;
        mCurrentTextSize = newTextSize;
        mBoundsChanged = false;
    }
    if (mTextToDraw == null || updateDrawText) {
        mTextPaint.setTextSize(mCurrentTextSize);
        mTextPaint.setTypeface(mCurrentTypeface);

        // BEGIN MODIFICATION: Text layout creation and text truncation
        StaticLayout layout = new StaticLayout(mText, mTextPaint, (int) availableWidth,
                Layout.Alignment.ALIGN_NORMAL, 1, 0, false);
        CharSequence truncatedText;
        if (layout.getLineCount() > maxLines) {
            int lastLine = maxLines - 1;
            CharSequence textBefore = lastLine > 0 ? mText.subSequence(0, layout.getLineEnd(lastLine - 1)) : "";
            CharSequence lineText = mText.subSequence(layout.getLineStart(lastLine),
                    layout.getLineEnd(lastLine));
            // if last char in line is space, move it behind the ellipsis
            CharSequence lineEnd = "";
            if (lineText.charAt(lineText.length() - 1) == ' ') {
                lineEnd = lineText.subSequence(lineText.length() - 1, lineText.length());
                lineText = lineText.subSequence(0, lineText.length() - 1);
            }
            // insert ellipsis character
            lineText = TextUtils.concat(lineText, "\u2026", lineEnd);
            // if the text is too long, truncate it
            CharSequence truncatedLineText = TextUtils.ellipsize(lineText, mTextPaint, availableWidth,
                    TextUtils.TruncateAt.END);
            truncatedText = TextUtils.concat(textBefore, truncatedLineText);

        } else {
            truncatedText = mText;
        }
        if (!TextUtils.equals(truncatedText, mTextToDraw)) {
            mTextToDraw = truncatedText;
            mIsRtl = calculateIsRtl(mTextToDraw);
        }

        final Layout.Alignment alignment;

        // Don't rectify gravity for RTL languages, Layout.Alignment does it already.
        switch (mExpandedTextGravity & GravityCompat.RELATIVE_HORIZONTAL_GRAVITY_MASK) {
        case Gravity.CENTER_HORIZONTAL:
            alignment = Layout.Alignment.ALIGN_CENTER;
            break;
        case Gravity.RIGHT:
        case Gravity.END:
            alignment = Layout.Alignment.ALIGN_OPPOSITE;
            break;
        case Gravity.LEFT:
        case Gravity.START:
        default:
            alignment = Layout.Alignment.ALIGN_NORMAL;
            break;
        }

        mTextLayout = new StaticLayout(mTextToDraw, mTextPaint, (int) availableWidth, alignment, 1, 0, false);
        // END MODIFICATION
    }
}

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;//from  w  w  w  . j  a va2s  .c o m
    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.adityarathi.muo.ui.activities.NowPlayingActivity.java

/**
 * Toggles the open/closed state of the current queue drawer.
 *///from www .  jav a2  s .c  om
public void toggleCurrentQueueDrawer() {
    if (mDrawerLayout == null)
        return;

    if (mDrawerLayout.isDrawerOpen(Gravity.END))
        mDrawerLayout.closeDrawer(Gravity.END);
    else
        mDrawerLayout.openDrawer(Gravity.END);

}