use of android.view.View.OnLayoutChangeListener in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class CaptionPropertiesFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
final boolean enabled = mCaptioningManager.isEnabled();
mPreviewText = (SubtitleView) view.findViewById(R.id.preview_text);
mPreviewText.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE);
mPreviewWindow = view.findViewById(R.id.preview_window);
mPreviewViewport = view.findViewById(R.id.preview_viewport);
mPreviewViewport.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) {
refreshPreviewText();
}
});
}
use of android.view.View.OnLayoutChangeListener in project android_frameworks_base by crdroidandroid.
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);
}
}
}
});
}
}
}
Aggregations