use of android.view.ViewTreeObserver.OnPreDrawListener in project SeaStar by 13120241790.
the class DragPointView method initbg.
private void initbg() {
setGravity(Gravity.CENTER);
getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
@SuppressWarnings("deprecation")
@Override
public boolean onPreDraw() {
if (!initBgFlag) {
DragPointView.this.setBackgroundDrawable(createStateListDrawable((getHeight() > getWidth() ? getHeight() : getWidth()) / 2, backgroundColor));
initBgFlag = true;
return false;
}
return true;
}
});
}
use of android.view.ViewTreeObserver.OnPreDrawListener in project GestureViews by alexvasilkov.
the class FullImageActivity method runAfterImageDraw.
/**
* Runs provided action after image is drawn for the first time.
*/
private void runAfterImageDraw(final Runnable action) {
image.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
@Override
public boolean onPreDraw() {
image.getViewTreeObserver().removeOnPreDrawListener(this);
runOnNextFrame(action);
return true;
}
});
image.invalidate();
}
use of android.view.ViewTreeObserver.OnPreDrawListener in project libgdx by libgdx.
the class AndroidOnscreenKeyboard method setVisible.
public void setVisible(boolean visible) {
if (visible && dialog != null) {
dialog.dismiss();
dialog = null;
}
if (visible && dialog == null && !input.isPeripheralAvailable(Peripheral.HardwareKeyboard)) {
handler.post(new Runnable() {
@Override
public void run() {
dialog = createDialog();
dialog.show();
handler.post(new Runnable() {
@Override
public void run() {
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
InputMethodManager input = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
if (input != null)
input.showSoftInput(textView, InputMethodManager.SHOW_FORCED);
}
});
final View content = dialog.getWindow().findViewById(Window.ID_ANDROID_CONTENT);
content.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
int[] screenloc = new int[2];
private int keyboardHeight;
private boolean keyboardShowing;
@Override
public boolean onPreDraw() {
content.getLocationOnScreen(screenloc);
keyboardHeight = Math.abs(screenloc[1]);
if (keyboardHeight > 0)
keyboardShowing = true;
if (keyboardHeight == 0 && keyboardShowing) {
dialog.dismiss();
dialog = null;
}
return true;
}
});
}
});
} else {
if (!visible && dialog != null) {
dialog.dismiss();
}
}
}
use of android.view.ViewTreeObserver.OnPreDrawListener in project AisenWeiBo by wangdan.
the class WallpaperViewer method init.
public void init() {
setBackgroundResource(R.drawable.wallpaper_viewer_bg);
getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
@Override
public boolean onPreDraw() {
getViewTreeObserver().removeOnPreDrawListener(this);
// 初始化 innerView
mInnerView = new View(getContext());
mInnerView.setLayoutParams(new LayoutParams((int) (getWidth() * INN_WIDTH_PERCENTS), LayoutParams.MATCH_PARENT));
mInnerView.setBackgroundResource(R.drawable.wallpaper_viewer_inn_bg);
mInnCenterPositionX = (int) (getWidth() * (1 - INN_WIDTH_PERCENTS) / 2);
setInnViewPositionX(mInnCenterPositionX);
addView(mInnerView);
return true;
}
});
}
use of android.view.ViewTreeObserver.OnPreDrawListener in project UltimateAndroid by cymcsg.
the class RotaryView method init.
public void init() {
paint = new Paint();
paint.setAntiAlias(true);
paint.setStyle(Paint.Style.FILL_AND_STROKE);
paintWhite = new Paint();
paintWhite.setAntiAlias(true);
paintWhite.setColor(0xffffffff);
paintWhite.setStyle(Paint.Style.FILL_AND_STROKE);
bitmapRefreshPaint = new Paint();
bitmapRefreshPaint.setAntiAlias(true);
setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
// 绘制完毕
this.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
public boolean onPreDraw() {
Init();
getViewTreeObserver().removeOnPreDrawListener(this);
return false;
}
});
}
Aggregations