use of android.view.View.OnAttachStateChangeListener in project platform_frameworks_base by android.
the class SpTexts method add.
public int add(final TextView text) {
if (text == null)
return 0;
final Resources res = mContext.getResources();
final float fontScale = res.getConfiguration().fontScale;
final float density = res.getDisplayMetrics().density;
final float px = text.getTextSize();
final int sp = (int) (px / fontScale / density);
mTexts.put(text, sp);
text.addOnAttachStateChangeListener(new OnAttachStateChangeListener() {
@Override
public void onViewDetachedFromWindow(View v) {
}
@Override
public void onViewAttachedToWindow(View v) {
setTextSizeH(text, sp);
}
});
return sp;
}
use of android.view.View.OnAttachStateChangeListener in project Conductor by bluelinelabs.
the class ViewAttachHandler method listenForDeepestChildAttach.
void listenForDeepestChildAttach(final View view, final ChildAttachListener attachListener) {
if (!(view instanceof ViewGroup)) {
attachListener.onAttached();
return;
}
ViewGroup viewGroup = (ViewGroup) view;
if (viewGroup.getChildCount() == 0) {
attachListener.onAttached();
return;
}
childOnAttachStateChangeListener = new OnAttachStateChangeListener() {
boolean attached = false;
@Override
public void onViewAttachedToWindow(View v) {
if (!attached) {
attached = true;
attachListener.onAttached();
v.removeOnAttachStateChangeListener(this);
childOnAttachStateChangeListener = null;
}
}
@Override
public void onViewDetachedFromWindow(View v) {
}
};
findDeepestChild(viewGroup).addOnAttachStateChangeListener(childOnAttachStateChangeListener);
}
use of android.view.View.OnAttachStateChangeListener in project Conductor by bluelinelabs.
the class ViewUtils method reportAttached.
public static void reportAttached(View view, boolean attached, boolean propogateToChildren) {
if (view instanceof AttachFakingFrameLayout) {
((AttachFakingFrameLayout) view).setAttached(attached, false);
}
List<OnAttachStateChangeListener> listeners = getAttachStateListeners(view);
// Add, then remove an OnAttachStateChangeListener to initialize the attachStateListeners variable inside a view
if (listeners == null) {
OnAttachStateChangeListener tmpListener = new OnAttachStateChangeListener() {
@Override
public void onViewAttachedToWindow(View v) {
}
@Override
public void onViewDetachedFromWindow(View v) {
}
};
view.addOnAttachStateChangeListener(tmpListener);
view.removeOnAttachStateChangeListener(tmpListener);
listeners = getAttachStateListeners(view);
}
for (OnAttachStateChangeListener listener : listeners) {
if (attached) {
listener.onViewAttachedToWindow(view);
} else {
listener.onViewDetachedFromWindow(view);
}
}
if (propogateToChildren && view instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) view;
int childCount = viewGroup.getChildCount();
for (int i = 0; i < childCount; i++) {
reportAttached(viewGroup.getChildAt(i), attached, true);
}
}
}
use of android.view.View.OnAttachStateChangeListener in project android_frameworks_base by DirtyUnicorns.
the class TileService method showDialog.
/**
* Used to show a dialog.
*
* This will collapse the Quick Settings panel and show the dialog.
*
* @param dialog Dialog to show.
*
* @see #isLocked()
*/
public final void showDialog(Dialog dialog) {
dialog.getWindow().getAttributes().token = mToken;
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_QS_DIALOG);
dialog.getWindow().getDecorView().addOnAttachStateChangeListener(new OnAttachStateChangeListener() {
@Override
public void onViewAttachedToWindow(View v) {
}
@Override
public void onViewDetachedFromWindow(View v) {
try {
mService.onDialogHidden(mTileToken);
} catch (RemoteException e) {
}
}
});
dialog.show();
try {
mService.onShowDialog(mTileToken);
} catch (RemoteException e) {
}
}
use of android.view.View.OnAttachStateChangeListener in project android_frameworks_base by ResurrectionRemix.
the class SpTexts method add.
public int add(final TextView text) {
if (text == null)
return 0;
final Resources res = mContext.getResources();
final float fontScale = res.getConfiguration().fontScale;
final float density = res.getDisplayMetrics().density;
final float px = text.getTextSize();
final int sp = (int) (px / fontScale / density);
mTexts.put(text, sp);
text.addOnAttachStateChangeListener(new OnAttachStateChangeListener() {
@Override
public void onViewDetachedFromWindow(View v) {
}
@Override
public void onViewAttachedToWindow(View v) {
setTextSizeH(text, sp);
}
});
return sp;
}
Aggregations