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