Search in sources :

Example 16 with Component

use of carbon.recycler.Component in project Carbon by ZieIony.

the class RelativeLayout method findComponentsOfType.

public List<Component> findComponentsOfType(Class type) {
    List<Component> result = new ArrayList<>();
    List<ViewGroup> groups = new ArrayList<>();
    groups.add(this);
    while (!groups.isEmpty()) {
        ViewGroup group = groups.remove(0);
        for (int i = 0; i < group.getChildCount(); i++) {
            View child = group.getChildAt(i);
            if (child instanceof ComponentView && ((ComponentView) child).getComponent().getClass().equals(type))
                result.add(((ComponentView) child).getComponent());
            if (child instanceof ViewGroup)
                groups.add((ViewGroup) child);
        }
    }
    return result;
}
Also used : ComponentView(carbon.component.ComponentView) ViewGroup(android.view.ViewGroup) ArrayList(java.util.ArrayList) Component(carbon.recycler.Component) ComponentView(carbon.component.ComponentView) View(android.view.View) RippleView(carbon.drawable.ripple.RippleView) ShadowView(carbon.shadow.ShadowView) AnimatedView(carbon.animation.AnimatedView) Paint(android.graphics.Paint)

Example 17 with Component

use of carbon.recycler.Component in project Carbon by ZieIony.

the class FrameLayout method findComponentsOfType.

public List<Component> findComponentsOfType(Class type) {
    List<Component> result = new ArrayList<>();
    List<ViewGroup> groups = new ArrayList<>();
    groups.add(this);
    while (!groups.isEmpty()) {
        ViewGroup group = groups.remove(0);
        for (int i = 0; i < group.getChildCount(); i++) {
            View child = group.getChildAt(i);
            if (child instanceof ComponentView && ((ComponentView) child).getComponent().getClass().equals(type))
                result.add(((ComponentView) child).getComponent());
            if (child instanceof ViewGroup)
                groups.add((ViewGroup) child);
        }
    }
    return result;
}
Also used : ComponentView(carbon.component.ComponentView) ViewGroup(android.view.ViewGroup) ArrayList(java.util.ArrayList) Component(carbon.recycler.Component) ComponentView(carbon.component.ComponentView) View(android.view.View) RippleView(carbon.drawable.ripple.RippleView) ShadowView(carbon.shadow.ShadowView) AnimatedView(carbon.animation.AnimatedView) Paint(android.graphics.Paint)

Example 18 with Component

use of carbon.recycler.Component in project Carbon by ZieIony.

the class CollapsingToolbarLayout method findComponentsById.

public List<Component> findComponentsById(int id) {
    List<Component> result = new ArrayList<>();
    List<ViewGroup> groups = new ArrayList<>();
    groups.add(this);
    while (!groups.isEmpty()) {
        ViewGroup group = groups.remove(0);
        for (int i = 0; i < group.getChildCount(); i++) {
            View child = group.getChildAt(i);
            if (child instanceof ComponentView && ((ComponentView) child).getComponent().getView().getId() == id)
                result.add(((ComponentView) child).getComponent());
            if (child instanceof ViewGroup)
                groups.add((ViewGroup) child);
        }
    }
    return result;
}
Also used : ComponentView(carbon.component.ComponentView) ViewGroup(android.view.ViewGroup) ArrayList(java.util.ArrayList) Component(carbon.recycler.Component) StateAnimatorView(carbon.widget.StateAnimatorView) ComponentView(carbon.component.ComponentView) View(android.view.View) CornerView(carbon.widget.CornerView) RippleView(carbon.drawable.ripple.RippleView) TouchMarginView(carbon.widget.TouchMarginView) MaxSizeView(carbon.widget.MaxSizeView) ShadowView(carbon.shadow.ShadowView) RevealView(carbon.widget.RevealView) AnimatedView(carbon.animation.AnimatedView) InsetView(carbon.widget.InsetView) Paint(android.graphics.Paint)

Example 19 with Component

use of carbon.recycler.Component in project Carbon by ZieIony.

the class ComponentView method init.

private void init(AttributeSet attrs) {
    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ComponentView, 0, 0);
    if (a != null) {
        int id = a.getResourceId(R.styleable.ComponentView_carbon_id, 0);
        int layout = a.getResourceId(R.styleable.ComponentView_carbon_layout, 0);
        String type = a.getString(R.styleable.ComponentView_carbon_type);
        try {
            Component component;
            if (layout != 0 && type == null) {
                component = new DataBindingComponent(this, layout);
            } else {
                Constructor<?> constructor = Class.forName(type).getConstructor(ViewGroup.class);
                component = (Component) constructor.newInstance(this);
            }
            View view = component.getView();
            view.setTag(component);
            view.setId(id);
            addView(view);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
        a.recycle();
    }
}
Also used : TypedArray(android.content.res.TypedArray) Component(carbon.recycler.Component) View(android.view.View) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 20 with Component

use of carbon.recycler.Component in project Carbon by ZieIony.

the class DrawerLayout method findComponentsById.

public List<Component> findComponentsById(int id) {
    List<Component> result = new ArrayList<>();
    List<ViewGroup> groups = new ArrayList<>();
    groups.add(this);
    while (!groups.isEmpty()) {
        ViewGroup group = groups.remove(0);
        for (int i = 0; i < group.getChildCount(); i++) {
            View child = group.getChildAt(i);
            if (child instanceof ComponentView && ((ComponentView) child).getComponent().getView().getId() == id)
                result.add(((ComponentView) child).getComponent());
            if (child instanceof ViewGroup)
                groups.add((ViewGroup) child);
        }
    }
    return result;
}
Also used : ComponentView(carbon.component.ComponentView) ViewGroup(android.view.ViewGroup) ArrayList(java.util.ArrayList) Component(carbon.recycler.Component) ComponentView(carbon.component.ComponentView) View(android.view.View) RippleView(carbon.drawable.ripple.RippleView) ShadowView(carbon.shadow.ShadowView) AnimatedView(carbon.animation.AnimatedView) Paint(android.graphics.Paint)

Aggregations

View (android.view.View)23 Component (carbon.recycler.Component)23 Paint (android.graphics.Paint)22 ViewGroup (android.view.ViewGroup)22 AnimatedView (carbon.animation.AnimatedView)22 ComponentView (carbon.component.ComponentView)22 RippleView (carbon.drawable.ripple.RippleView)22 ShadowView (carbon.shadow.ShadowView)22 ArrayList (java.util.ArrayList)22 CornerView (carbon.widget.CornerView)6 InsetView (carbon.widget.InsetView)6 MaxSizeView (carbon.widget.MaxSizeView)6 RevealView (carbon.widget.RevealView)6 StateAnimatorView (carbon.widget.StateAnimatorView)6 TouchMarginView (carbon.widget.TouchMarginView)6 TypedArray (android.content.res.TypedArray)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1