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;
}
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;
}
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;
}
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();
}
}
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;
}
Aggregations