Search in sources :

Example 56 with ViewParent

use of android.view.ViewParent in project StickyListHeaders by emilsjolander.

the class WrapperView method update.

void update(View item, View header, Drawable divider, int dividerHeight) {
    //every wrapperview must have a list item
    if (item == null) {
        throw new NullPointerException("List view item must not be null.");
    }
    //only remove the current item if it is not the same as the new item. this can happen if wrapping a recycled view
    if (this.mItem != item) {
        removeView(this.mItem);
        this.mItem = item;
        final ViewParent parent = item.getParent();
        if (parent != null && parent != this) {
            if (parent instanceof ViewGroup) {
                ((ViewGroup) parent).removeView(item);
            }
        }
        addView(item);
    }
    //same logik as above but for the header
    if (this.mHeader != header) {
        if (this.mHeader != null) {
            removeView(this.mHeader);
        }
        this.mHeader = header;
        if (header != null) {
            addView(header);
        }
    }
    if (this.mDivider != divider) {
        this.mDivider = divider;
        this.mDividerHeight = dividerHeight;
        invalidate();
    }
}
Also used : ViewParent(android.view.ViewParent) ViewGroup(android.view.ViewGroup)

Example 57 with ViewParent

use of android.view.ViewParent in project AndroidTraining by mixi-inc.

the class ActionBarView method onFinishInflate.

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    addView(mHomeLayout);
    if (mCustomNavView != null && (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) {
        final ViewParent parent = mCustomNavView.getParent();
        if (parent != this) {
            if (parent instanceof ViewGroup) {
                ((ViewGroup) parent).removeView(mCustomNavView);
            }
            addView(mCustomNavView);
        }
    }
}
Also used : ViewParent(android.view.ViewParent) ViewGroup(android.view.ViewGroup)

Example 58 with ViewParent

use of android.view.ViewParent in project SmartAndroidSource by jaychou2012.

the class SmartImageViewAttacher method onTouch.

@Override
public boolean onTouch(View v, MotionEvent ev) {
    boolean handled = false;
    if (mZoomEnabled && hasDrawable((ImageView) v)) {
        ViewParent parent = v.getParent();
        switch(ev.getAction()) {
            case ACTION_DOWN:
                // event
                if (null != parent)
                    parent.requestDisallowInterceptTouchEvent(true);
                else
                    Log.i(LOG_TAG, "onTouch getParent() returned null");
                // If we're flinging, and the user presses down, cancel
                // fling
                cancelFling();
                break;
            case ACTION_CANCEL:
            case ACTION_UP:
                // to min scale
                if (getScale() < mMinScale) {
                    RectF rect = getDisplayRect();
                    if (null != rect) {
                        v.post(new AnimatedZoomRunnable(getScale(), mMinScale, rect.centerX(), rect.centerY()));
                        handled = true;
                    }
                }
                break;
        }
        // Try the Scale/Drag detector
        if (null != mScaleDragDetector && mScaleDragDetector.onTouchEvent(ev)) {
            handled = true;
        }
        // Check to see if the user double tapped
        if (null != mGestureDetector && mGestureDetector.onTouchEvent(ev)) {
            handled = true;
        }
    }
    return handled;
}
Also used : RectF(android.graphics.RectF) ViewParent(android.view.ViewParent) ImageView(android.widget.ImageView)

Example 59 with ViewParent

use of android.view.ViewParent in project SmartAndroidSource by jaychou2012.

the class ActionBarView method onFinishInflate.

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    addView(mHomeLayout);
    if (mCustomNavView != null && (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) {
        final ViewParent parent = mCustomNavView.getParent();
        if (parent != this) {
            if (parent instanceof ViewGroup) {
                ((ViewGroup) parent).removeView(mCustomNavView);
            }
            addView(mCustomNavView);
        }
    }
}
Also used : ViewParent(android.view.ViewParent) ViewGroup(android.view.ViewGroup)

Example 60 with ViewParent

use of android.view.ViewParent in project android-viewbadger by jgilfelt.

the class BadgeView method applyTo.

private void applyTo(View target) {
    LayoutParams lp = target.getLayoutParams();
    ViewParent parent = target.getParent();
    FrameLayout container = new FrameLayout(context);
    if (target instanceof TabWidget) {
        // set target to the relevant tab child container
        target = ((TabWidget) target).getChildTabViewAt(targetTabIndex);
        this.target = target;
        ((ViewGroup) target).addView(container, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
        this.setVisibility(View.GONE);
        container.addView(this);
    } else {
        // TODO verify that parent is indeed a ViewGroup
        ViewGroup group = (ViewGroup) parent;
        int index = group.indexOfChild(target);
        group.removeView(target);
        group.addView(container, index, lp);
        container.addView(target);
        this.setVisibility(View.GONE);
        container.addView(this);
        group.invalidate();
    }
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) ViewParent(android.view.ViewParent) ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) TabWidget(android.widget.TabWidget)

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