use of com.android.ide.common.rendering.api.DataBindingItem in project android_frameworks_base by crdroidandroid.
the class AdapterHelper method getView.
@SuppressWarnings("deprecation")
static Pair<View, Boolean> getView(AdapterItem item, AdapterItem parentItem, ViewGroup parent, LayoutlibCallback callback, ResourceReference adapterRef, boolean skipCallbackParser) {
// we don't care about recycling here because we never scroll.
DataBindingItem dataBindingItem = item.getDataBindingItem();
BridgeContext context = RenderAction.getCurrentContext();
Pair<View, Boolean> pair = context.inflateView(dataBindingItem.getViewReference(), parent, false, /*attachToRoot*/
skipCallbackParser);
View view = pair.getFirst();
skipCallbackParser |= pair.getSecond();
if (view != null) {
fillView(context, view, item, parentItem, callback, adapterRef);
} else {
// create a text view to display an error.
TextView tv = new TextView(context);
tv.setText("Unable to find layout: " + dataBindingItem.getViewReference().getName());
view = tv;
}
return Pair.of(view, skipCallbackParser);
}
use of com.android.ide.common.rendering.api.DataBindingItem in project android_frameworks_base by crdroidandroid.
the class FakeExpandableAdapter method createItems.
private void createItems(Iterable<DataBindingItem> iterable, final int itemCount, final int repeatCount, List<ResourceReference> types, int depth) {
// Need an array to count for each type.
// This is likely too big, but is the max it can be.
int[] typeCount = new int[itemCount];
// we put several repeating sets.
for (int r = 0; r < repeatCount; r++) {
// loop on the type of list items, and add however many for each type.
for (DataBindingItem dataBindingItem : iterable) {
ResourceReference viewRef = dataBindingItem.getViewReference();
int typeIndex = types.indexOf(viewRef);
if (typeIndex == -1) {
typeIndex = types.size();
types.add(viewRef);
}
List<DataBindingItem> children = dataBindingItem.getChildren();
int count = dataBindingItem.getCount();
// if there are children, we use the count as a repeat count for the children.
if (children.size() > 0) {
count = 1;
}
int index = typeCount[typeIndex];
typeCount[typeIndex] += count;
for (int k = 0; k < count; k++) {
AdapterItem item = new AdapterItem(dataBindingItem, typeIndex, mItems.size(), index++);
mItems.add(item);
if (children.size() > 0) {
createItems(dataBindingItem, depth + 1);
}
}
}
}
}
use of com.android.ide.common.rendering.api.DataBindingItem in project platform_frameworks_base by android.
the class FakeExpandableAdapter method createItems.
private void createItems(Iterable<DataBindingItem> iterable, final int itemCount, final int repeatCount, List<ResourceReference> types, int depth) {
// Need an array to count for each type.
// This is likely too big, but is the max it can be.
int[] typeCount = new int[itemCount];
// we put several repeating sets.
for (int r = 0; r < repeatCount; r++) {
// loop on the type of list items, and add however many for each type.
for (DataBindingItem dataBindingItem : iterable) {
ResourceReference viewRef = dataBindingItem.getViewReference();
int typeIndex = types.indexOf(viewRef);
if (typeIndex == -1) {
typeIndex = types.size();
types.add(viewRef);
}
List<DataBindingItem> children = dataBindingItem.getChildren();
int count = dataBindingItem.getCount();
// if there are children, we use the count as a repeat count for the children.
if (children.size() > 0) {
count = 1;
}
int index = typeCount[typeIndex];
typeCount[typeIndex] += count;
for (int k = 0; k < count; k++) {
AdapterItem item = new AdapterItem(dataBindingItem, typeIndex, mItems.size(), index++);
mItems.add(item);
if (children.size() > 0) {
createItems(dataBindingItem, depth + 1);
}
}
}
}
}
use of com.android.ide.common.rendering.api.DataBindingItem in project android_frameworks_base by ParanoidAndroid.
the class FakeExpandableAdapter method createItems.
private void createItems(Iterable<DataBindingItem> iterable, final int itemCount, final int repeatCount, List<ResourceReference> types, int depth) {
// Need an array to count for each type.
// This is likely too big, but is the max it can be.
int[] typeCount = new int[itemCount];
// we put several repeating sets.
for (int r = 0; r < repeatCount; r++) {
// loop on the type of list items, and add however many for each type.
for (DataBindingItem dataBindingItem : iterable) {
ResourceReference viewRef = dataBindingItem.getViewReference();
int typeIndex = types.indexOf(viewRef);
if (typeIndex == -1) {
typeIndex = types.size();
types.add(viewRef);
}
List<DataBindingItem> children = dataBindingItem.getChildren();
int count = dataBindingItem.getCount();
// if there are children, we use the count as a repeat count for the children.
if (children.size() > 0) {
count = 1;
}
int index = typeCount[typeIndex];
typeCount[typeIndex] += count;
for (int k = 0; k < count; k++) {
AdapterItem item = new AdapterItem(dataBindingItem, typeIndex, mItems.size(), index++);
mItems.add(item);
if (children.size() > 0) {
createItems(dataBindingItem, depth + 1);
}
}
}
}
}
use of com.android.ide.common.rendering.api.DataBindingItem in project android_frameworks_base by AOSPA.
the class FakeExpandableAdapter method createItems.
private void createItems(Iterable<DataBindingItem> iterable, final int itemCount, final int repeatCount, List<ResourceReference> types, int depth) {
// Need an array to count for each type.
// This is likely too big, but is the max it can be.
int[] typeCount = new int[itemCount];
// we put several repeating sets.
for (int r = 0; r < repeatCount; r++) {
// loop on the type of list items, and add however many for each type.
for (DataBindingItem dataBindingItem : iterable) {
ResourceReference viewRef = dataBindingItem.getViewReference();
int typeIndex = types.indexOf(viewRef);
if (typeIndex == -1) {
typeIndex = types.size();
types.add(viewRef);
}
List<DataBindingItem> children = dataBindingItem.getChildren();
int count = dataBindingItem.getCount();
// if there are children, we use the count as a repeat count for the children.
if (children.size() > 0) {
count = 1;
}
int index = typeCount[typeIndex];
typeCount[typeIndex] += count;
for (int k = 0; k < count; k++) {
AdapterItem item = new AdapterItem(dataBindingItem, typeIndex, mItems.size(), index++);
mItems.add(item);
if (children.size() > 0) {
createItems(dataBindingItem, depth + 1);
}
}
}
}
}
Aggregations