Search in sources :

Example 81 with ViewParent

use of android.view.ViewParent in project android_frameworks_base by ParanoidAndroid.

the class Bridge method getViewIndex.

@Override
public Result getViewIndex(Object viewObject) {
    if (viewObject instanceof View) {
        View view = (View) viewObject;
        ViewParent parentView = view.getParent();
        if (parentView instanceof ViewGroup) {
            Status.SUCCESS.createResult(((ViewGroup) parentView).indexOfChild(view));
        }
        return Status.SUCCESS.createResult();
    }
    throw new IllegalArgumentException("viewObject is not a View");
}
Also used : ViewParent(android.view.ViewParent) ViewGroup(android.view.ViewGroup) View(android.view.View)

Example 82 with ViewParent

use of android.view.ViewParent in project HoloEverywhere by Prototik.

the class ListPopupWindow method removePromptView.

private void removePromptView() {
    if (mPromptView != null) {
        final ViewParent parent = mPromptView.getParent();
        if (parent instanceof ViewGroup) {
            final ViewGroup group = (ViewGroup) parent;
            group.removeView(mPromptView);
        }
    }
}
Also used : ViewParent(android.view.ViewParent) ViewGroup(android.view.ViewGroup)

Example 83 with ViewParent

use of android.view.ViewParent in project meatspace-android by RomainPiel.

the class PreferenceDialogFragment method onDestroyView.

@Override
public void onDestroyView() {
    super.onDestroyView();
    ViewParent p = lv.getParent();
    if (p != null)
        ((ViewGroup) p).removeView(lv);
}
Also used : ViewParent(android.view.ViewParent)

Example 84 with ViewParent

use of android.view.ViewParent in project android_frameworks_base by ParanoidAndroid.

the class LayoutTransition method runChangeTransition.

/**
     * This function sets up animations on all of the views that change during layout.
     * For every child in the parent, we create a change animation of the appropriate
     * type (appearing, disappearing, or changing) and ask it to populate its start values from its
     * target view. We add layout listeners to all child views and listen for changes. For
     * those views that change, we populate the end values for those animations and start them.
     * Animations are not run on unchanging views.
     *
     * @param parent The container which is undergoing a change.
     * @param newView The view being added to or removed from the parent. May be null if the
     * changeReason is CHANGING.
     * @param changeReason A value of APPEARING, DISAPPEARING, or CHANGING, indicating whether the
     * transition is occurring because an item is being added to or removed from the parent, or
     * if it is running in response to a layout operation (that is, if the value is CHANGING).
     */
private void runChangeTransition(final ViewGroup parent, View newView, final int changeReason) {
    Animator baseAnimator = null;
    Animator parentAnimator = null;
    final long duration;
    switch(changeReason) {
        case APPEARING:
            baseAnimator = mChangingAppearingAnim;
            duration = mChangingAppearingDuration;
            parentAnimator = defaultChangeIn;
            break;
        case DISAPPEARING:
            baseAnimator = mChangingDisappearingAnim;
            duration = mChangingDisappearingDuration;
            parentAnimator = defaultChangeOut;
            break;
        case CHANGING:
            baseAnimator = mChangingAnim;
            duration = mChangingDuration;
            parentAnimator = defaultChange;
            break;
        default:
            // Shouldn't reach here
            duration = 0;
            break;
    }
    // If the animation is null, there's nothing to do
    if (baseAnimator == null) {
        return;
    }
    // reset the inter-animation delay, in case we use it later
    staggerDelay = 0;
    // used for later cleanup
    final ViewTreeObserver observer = parent.getViewTreeObserver();
    if (!observer.isAlive()) {
        // If the observer's not in a good state, skip the transition
        return;
    }
    int numChildren = parent.getChildCount();
    for (int i = 0; i < numChildren; ++i) {
        final View child = parent.getChildAt(i);
        // only animate the views not being added or removed
        if (child != newView) {
            setupChangeAnimation(parent, changeReason, baseAnimator, duration, child);
        }
    }
    if (mAnimateParentHierarchy) {
        ViewGroup tempParent = parent;
        while (tempParent != null) {
            ViewParent parentParent = tempParent.getParent();
            if (parentParent instanceof ViewGroup) {
                setupChangeAnimation((ViewGroup) parentParent, changeReason, parentAnimator, duration, tempParent);
                tempParent = (ViewGroup) parentParent;
            } else {
                tempParent = null;
            }
        }
    }
    // This is the cleanup step. When we get this rendering event, we know that all of
    // the appropriate animations have been set up and run. Now we can clear out the
    // layout listeners.
    observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {

        public boolean onPreDraw() {
            parent.getViewTreeObserver().removeOnPreDrawListener(this);
            int count = layoutChangeListenerMap.size();
            if (count > 0) {
                Collection<View> views = layoutChangeListenerMap.keySet();
                for (View view : views) {
                    View.OnLayoutChangeListener listener = layoutChangeListenerMap.get(view);
                    view.removeOnLayoutChangeListener(listener);
                }
            }
            layoutChangeListenerMap.clear();
            return true;
        }
    });
}
Also used : ViewGroup(android.view.ViewGroup) ViewParent(android.view.ViewParent) Collection(java.util.Collection) ViewTreeObserver(android.view.ViewTreeObserver) View(android.view.View)

Example 85 with ViewParent

use of android.view.ViewParent in project android_frameworks_base by ParanoidAndroid.

the class EditTextPreference method onBindDialogView.

@Override
protected void onBindDialogView(View view) {
    super.onBindDialogView(view);
    EditText editText = mEditText;
    editText.setText(getText());
    ViewParent oldParent = editText.getParent();
    if (oldParent != view) {
        if (oldParent != null) {
            ((ViewGroup) oldParent).removeView(editText);
        }
        onAddEditTextToDialogView(view, editText);
    }
}
Also used : EditText(android.widget.EditText) ViewParent(android.view.ViewParent) ViewGroup(android.view.ViewGroup)

Aggregations

ViewParent (android.view.ViewParent)409 ViewGroup (android.view.ViewGroup)185 View (android.view.View)156 ImageView (android.widget.ImageView)36 Rect (android.graphics.Rect)32 VelocityTracker (android.view.VelocityTracker)32 TextView (android.widget.TextView)24 FrameLayout (android.widget.FrameLayout)17 SuppressLint (android.annotation.SuppressLint)16 Paint (android.graphics.Paint)15 AdapterView (android.widget.AdapterView)14 AccessibilityEvent (android.view.accessibility.AccessibilityEvent)13 ViewTreeObserver (android.view.ViewTreeObserver)12 LayoutParams (android.view.WindowManager.LayoutParams)11 Description (org.hamcrest.Description)11 ExpandableNotificationRow (com.android.systemui.statusbar.ExpandableNotificationRow)10 SignalClusterView (com.android.systemui.statusbar.SignalClusterView)10 TypeSafeMatcher (org.hamcrest.TypeSafeMatcher)10 MotionEvent (android.view.MotionEvent)9 EditText (android.widget.EditText)9