use of android.view.ViewTreeObserver in project android_frameworks_base by DirtyUnicorns.
the class Editor method getInsertionController.
InsertionPointCursorController getInsertionController() {
if (!mInsertionControllerEnabled) {
return null;
}
if (mInsertionPointCursorController == null) {
mInsertionPointCursorController = new InsertionPointCursorController();
final ViewTreeObserver observer = mTextView.getViewTreeObserver();
observer.addOnTouchModeChangeListener(mInsertionPointCursorController);
}
return mInsertionPointCursorController;
}
use of android.view.ViewTreeObserver in project android_frameworks_base by DirtyUnicorns.
the class Editor method getSelectionController.
SelectionModifierCursorController getSelectionController() {
if (!mSelectionControllerEnabled) {
return null;
}
if (mSelectionModifierCursorController == null) {
mSelectionModifierCursorController = new SelectionModifierCursorController();
final ViewTreeObserver observer = mTextView.getViewTreeObserver();
observer.addOnTouchModeChangeListener(mSelectionModifierCursorController);
}
return mSelectionModifierCursorController;
}
use of android.view.ViewTreeObserver in project floatingsearchview by arimorty.
the class FloatingSearchView method onLayout.
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
if (mIsInitialLayout) {
// we need to add 5dp to the mSuggestionsSection because we are
// going to move it up by 5dp in order to cover the search bar's
// shadow padding and rounded corners. We also need to add an additional 10dp to
// mSuggestionsSection in order to hide mSuggestionListContainer's
// rounded corners and shadow for both, top and bottom.
int addedHeight = 3 * Util.dpToPx(CARD_VIEW_CORNERS_AND_TOP_BOTTOM_SHADOW_HEIGHT);
final int finalHeight = mSuggestionsSection.getHeight() + addedHeight;
mSuggestionsSection.getLayoutParams().height = finalHeight;
mSuggestionsSection.requestLayout();
ViewTreeObserver vto = mSuggestionListContainer.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (mSuggestionsSection.getHeight() == finalHeight) {
Util.removeGlobalLayoutObserver(mSuggestionListContainer, this);
mIsSuggestionsSectionHeightSet = true;
moveSuggestListToInitialPos();
if (mSuggestionSecHeightListener != null) {
mSuggestionSecHeightListener.onSuggestionSecHeightSet();
mSuggestionSecHeightListener = null;
}
}
}
});
mIsInitialLayout = false;
refreshDimBackground();
if (isInEditMode()) {
inflateOverflowMenu(mMenuId);
}
}
}
use of android.view.ViewTreeObserver in project MaterialLibrary by DeveloperPaul123.
the class BaseFabListActivity method toggleButton.
/**
* Toggles the material floating action button.
* @param visible
*/
public void toggleButton(final boolean visible) {
if (isShowing != visible) {
isShowing = visible;
int height = materialFloatingActionButton.getHeight();
if (height == 0) {
ViewTreeObserver vto = materialFloatingActionButton.getViewTreeObserver();
if (vto.isAlive()) {
vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
ViewTreeObserver currentVto = materialFloatingActionButton.getViewTreeObserver();
if (currentVto.isAlive()) {
currentVto.removeOnPreDrawListener(this);
}
toggleButton(visible);
return true;
}
});
return;
}
}
int translationY = visible ? 0 : height;
materialFloatingActionButton.animate().setInterpolator(interpolator).setDuration(500).translationY(translationY);
// On pre-Honeycomb a translated view is still clickable, so we need to disable clicks manually
materialFloatingActionButton.setClickable(visible);
}
}
use of android.view.ViewTreeObserver in project httpclient by pixmob.
the class ActivityChooserView method dismissPopup.
/**
* Dismisses the popup window with activities.
*
* @return True if dismissed, false if already dismissed.
*/
public boolean dismissPopup() {
if (isShowingPopup()) {
getListPopupWindow().dismiss();
ViewTreeObserver viewTreeObserver = getViewTreeObserver();
if (viewTreeObserver.isAlive()) {
viewTreeObserver.removeGlobalOnLayoutListener(mOnGlobalLayoutListener);
}
}
return true;
}
Aggregations