Search in sources :

Example 1 with OnLayoutChangeListener

use of android.view.View.OnLayoutChangeListener in project android_frameworks_base by DirtyUnicorns.

the class TileAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final Holder holder, int position) {
    if (holder.getItemViewType() == TYPE_DIVIDER) {
        holder.itemView.setVisibility(mTileDividerIndex < mTiles.size() - 1 ? View.VISIBLE : View.INVISIBLE);
        return;
    }
    if (holder.getItemViewType() == TYPE_EDIT) {
        ((TextView) holder.itemView.findViewById(android.R.id.title)).setText(mCurrentDrag != null ? R.string.drag_to_remove_tiles : R.string.drag_to_add_tiles);
        return;
    }
    if (holder.getItemViewType() == TYPE_ACCESSIBLE_DROP) {
        holder.mTileView.setClickable(true);
        holder.mTileView.setFocusable(true);
        holder.mTileView.setFocusableInTouchMode(true);
        holder.mTileView.setVisibility(View.VISIBLE);
        holder.mTileView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
        holder.mTileView.setContentDescription(mContext.getString(R.string.accessibility_qs_edit_position_label, position + 1));
        holder.mTileView.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                selectPosition(holder.getAdapterPosition(), v);
            }
        });
        if (mNeedsFocus) {
            // Wait for this to get laid out then set its focus.
            // Ensure that tile gets laid out so we get the callback.
            holder.mTileView.requestLayout();
            holder.mTileView.addOnLayoutChangeListener(new OnLayoutChangeListener() {

                @Override
                public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
                    holder.mTileView.removeOnLayoutChangeListener(this);
                    holder.mTileView.requestFocus();
                }
            });
            mNeedsFocus = false;
        }
        return;
    }
    TileInfo info = mTiles.get(position);
    if (position > mEditIndex) {
        info.state.contentDescription = mContext.getString(R.string.accessibility_qs_edit_add_tile_label, info.state.label);
    } else if (mAccessibilityMoving) {
        info.state.contentDescription = mContext.getString(R.string.accessibility_qs_edit_position_label, position + 1);
    } else {
        info.state.contentDescription = mContext.getString(R.string.accessibility_qs_edit_tile_label, position + 1, info.state.label);
    }
    holder.mTileView.onStateChanged(info.state);
    holder.mTileView.setAppLabel(info.appLabel);
    holder.mTileView.setShowAppLabel(position > mEditIndex && !info.isSystem);
    if (mAccessibilityManager.isTouchExplorationEnabled()) {
        final boolean selectable = !mAccessibilityMoving || position < mEditIndex;
        holder.mTileView.setClickable(selectable);
        holder.mTileView.setFocusable(selectable);
        holder.mTileView.setImportantForAccessibility(selectable ? View.IMPORTANT_FOR_ACCESSIBILITY_YES : View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
        if (selectable) {
            holder.mTileView.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    int position = holder.getAdapterPosition();
                    if (mAccessibilityMoving) {
                        selectPosition(position, v);
                    } else {
                        if (position < mEditIndex) {
                            showAccessibilityDialog(position, v);
                        } else {
                            startAccessibleDrag(position);
                        }
                    }
                }
            });
        }
    }
}
Also used : TileInfo(com.android.systemui.qs.customize.TileQueryHelper.TileInfo) OnLayoutChangeListener(android.view.View.OnLayoutChangeListener) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) QSIconView(com.android.systemui.qs.QSIconView)

Example 2 with OnLayoutChangeListener

use of android.view.View.OnLayoutChangeListener in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ConditionAdapterUtils method animateChange.

private static void animateChange(final View view, final View content, final View detailGroup, final boolean visible, final boolean hasButtons) {
    setViewVisibility(detailGroup, R.id.divider, hasButtons);
    setViewVisibility(detailGroup, R.id.buttonBar, hasButtons);
    final int beforeBottom = content.getBottom();
    setHeight(detailGroup, visible ? LayoutParams.WRAP_CONTENT : 0);
    detailGroup.setVisibility(View.VISIBLE);
    view.addOnLayoutChangeListener(new OnLayoutChangeListener() {

        public static final long DURATION = 250;

        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
            final int afterBottom = content.getBottom();
            v.removeOnLayoutChangeListener(this);
            final ObjectAnimator animator = ObjectAnimator.ofInt(content, "bottom", beforeBottom, afterBottom);
            animator.setDuration(DURATION);
            animator.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    if (!visible) {
                        detailGroup.setVisibility(View.GONE);
                    }
                }
            });
            animator.start();
        }
    });
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) OnLayoutChangeListener(android.view.View.OnLayoutChangeListener) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 3 with OnLayoutChangeListener

use of android.view.View.OnLayoutChangeListener in project AndroidChromium by JackyAndroid.

the class CustomTabBottomBarDelegate method hideBottomBar.

private void hideBottomBar() {
    if (mBottomBarView == null)
        return;
    ((ViewGroup) mBottomBarView.getParent()).removeView(mBottomBarView);
    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lp.gravity = Gravity.BOTTOM;
    final ViewGroup compositorView = mActivity.getCompositorViewHolder();
    compositorView.addView(mBottomBarView, lp);
    compositorView.addOnLayoutChangeListener(new OnLayoutChangeListener() {

        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
            compositorView.removeOnLayoutChangeListener(this);
            mBottomBarView.animate().alpha(0f).translationY(mBottomBarView.getHeight()).setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE).setDuration(SLIDE_ANIMATION_DURATION_MS).withEndAction(new Runnable() {

                @Override
                public void run() {
                    ((ViewGroup) mBottomBarView.getParent()).removeView(mBottomBarView);
                    mBottomBarView = null;
                }
            }).start();
        }
    });
}
Also used : LayoutParams(android.widget.FrameLayout.LayoutParams) LayoutParams(android.widget.FrameLayout.LayoutParams) OnLayoutChangeListener(android.view.View.OnLayoutChangeListener) ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) View(android.view.View)

Example 4 with OnLayoutChangeListener

use of android.view.View.OnLayoutChangeListener in project AndroidChromium by JackyAndroid.

the class SnackbarView method show.

void show() {
    addToParent();
    mView.addOnLayoutChangeListener(new OnLayoutChangeListener() {

        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
            mView.removeOnLayoutChangeListener(this);
            mView.setTranslationY(mView.getHeight() + getLayoutParams().bottomMargin);
            Animator animator = ObjectAnimator.ofFloat(mView, View.TRANSLATION_Y, 0);
            animator.setInterpolator(new DecelerateInterpolator());
            animator.setDuration(mAnimationDuration);
            startAnimatorOnSurfaceView(animator);
        }
    });
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) OnLayoutChangeListener(android.view.View.OnLayoutChangeListener) SurfaceView(android.view.SurfaceView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 5 with OnLayoutChangeListener

use of android.view.View.OnLayoutChangeListener in project k-9 by k9mail.

the class CryptoInfoDialog method prepareIconAnimation.

private void prepareIconAnimation() {
    topText.setAlpha(0.0f);
    bottomText.setAlpha(0.0f);
    dialogView.addOnLayoutChangeListener(new OnLayoutChangeListener() {

        @Override
        public void onLayoutChange(View view, int i, int i1, int i2, int i3, int i4, int i5, int i6, int i7) {
            float halfVerticalPixelDifference = (bottomIconFrame.getY() - topIconFrame.getY()) / 2.0f;
            topIconFrame.setTranslationY(halfVerticalPixelDifference);
            bottomIconFrame.setTranslationY(-halfVerticalPixelDifference);
            topIconFrame.animate().translationY(0).setStartDelay(ICON_ANIM_DELAY).setDuration(ICON_ANIM_DURATION).setInterpolator(new AccelerateDecelerateInterpolator()).start();
            bottomIconFrame.animate().translationY(0).setStartDelay(ICON_ANIM_DELAY).setDuration(ICON_ANIM_DURATION).setInterpolator(new AccelerateDecelerateInterpolator()).start();
            topText.animate().alpha(1.0f).setStartDelay(ICON_ANIM_DELAY + ICON_ANIM_DURATION).start();
            bottomText.animate().alpha(1.0f).setStartDelay(ICON_ANIM_DELAY + ICON_ANIM_DURATION).start();
            view.removeOnLayoutChangeListener(this);
        }
    });
}
Also used : OnLayoutChangeListener(android.view.View.OnLayoutChangeListener) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) SuppressLint(android.annotation.SuppressLint)

Aggregations

View (android.view.View)12 OnLayoutChangeListener (android.view.View.OnLayoutChangeListener)12 TextView (android.widget.TextView)7 RecyclerView (android.support.v7.widget.RecyclerView)6 OnClickListener (android.view.View.OnClickListener)5 QSIconView (com.android.systemui.qs.QSIconView)5 TileInfo (com.android.systemui.qs.customize.TileQueryHelper.TileInfo)5 ImageView (android.widget.ImageView)3 Animator (android.animation.Animator)2 ObjectAnimator (android.animation.ObjectAnimator)2 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 SuppressLint (android.annotation.SuppressLint)1 SurfaceView (android.view.SurfaceView)1 ViewGroup (android.view.ViewGroup)1 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)1 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)1 FrameLayout (android.widget.FrameLayout)1 LayoutParams (android.widget.FrameLayout.LayoutParams)1 SubtitleView (com.android.internal.widget.SubtitleView)1 ContentViewCore (org.chromium.content.browser.ContentViewCore)1