Search in sources :

Example 1 with DataBindingItem

use of com.android.ide.common.rendering.api.DataBindingItem in project android_frameworks_base by ParanoidAndroid.

the class BaseAdapter method getView.

protected View getView(AdapterItem item, AdapterItem parentItem, View convertView, ViewGroup parent) {
    // 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*/
    mSkipCallbackParser);
    View view = pair.getFirst();
    mSkipCallbackParser |= pair.getSecond();
    if (view != null) {
        fillView(context, view, item, parentItem);
    } 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 view;
}
Also used : BridgeContext(com.android.layoutlib.bridge.android.BridgeContext) DataBindingItem(com.android.ide.common.rendering.api.DataBindingItem) TextView(android.widget.TextView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 2 with DataBindingItem

use of com.android.ide.common.rendering.api.DataBindingItem in project platform_frameworks_base by android.

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);
}
Also used : BridgeContext(com.android.layoutlib.bridge.android.BridgeContext) DataBindingItem(com.android.ide.common.rendering.api.DataBindingItem) TextView(android.widget.TextView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 3 with DataBindingItem

use of com.android.ide.common.rendering.api.DataBindingItem in project android_frameworks_base by AOSPA.

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);
}
Also used : BridgeContext(com.android.layoutlib.bridge.android.BridgeContext) DataBindingItem(com.android.ide.common.rendering.api.DataBindingItem) TextView(android.widget.TextView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 4 with DataBindingItem

use of com.android.ide.common.rendering.api.DataBindingItem in project android_frameworks_base by ResurrectionRemix.

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);
}
Also used : BridgeContext(com.android.layoutlib.bridge.android.BridgeContext) DataBindingItem(com.android.ide.common.rendering.api.DataBindingItem) TextView(android.widget.TextView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 5 with DataBindingItem

use of com.android.ide.common.rendering.api.DataBindingItem in project android by JetBrains.

the class LayoutMetadata method getNodeBinding.

@Nullable
private static AdapterBinding getNodeBinding(@Nullable Object viewObject, @Nullable String header, @Nullable String footer, @Nullable String layout, int count) {
    if (layout != null || header != null || footer != null) {
        AdapterBinding binding = new AdapterBinding(count);
        if (header != null) {
            boolean isFramework = header.startsWith(ANDROID_LAYOUT_RESOURCE_PREFIX);
            binding.addHeader(new ResourceReference(stripLayoutPrefix(header), isFramework));
        }
        if (footer != null) {
            boolean isFramework = footer.startsWith(ANDROID_LAYOUT_RESOURCE_PREFIX);
            binding.addFooter(new ResourceReference(stripLayoutPrefix(footer), isFramework));
        }
        if (layout != null) {
            boolean isFramework = layout.startsWith(ANDROID_LAYOUT_RESOURCE_PREFIX);
            if (isFramework) {
                layout = layout.substring(ANDROID_LAYOUT_RESOURCE_PREFIX.length());
            } else if (layout.startsWith(LAYOUT_RESOURCE_PREFIX)) {
                layout = layout.substring(LAYOUT_RESOURCE_PREFIX.length());
            }
            binding.addItem(new DataBindingItem(layout, isFramework, 1));
        } else if (viewObject != null) {
            String listFqcn = LayoutlibCallbackImpl.getListAdapterViewFqcn(viewObject.getClass());
            if (listFqcn != null) {
                if (listFqcn.endsWith(EXPANDABLE_LIST_VIEW)) {
                    binding.addItem(new DataBindingItem(DEFAULT_EXPANDABLE_LIST_ITEM, true, /* isFramework */
                    1));
                } else {
                    binding.addItem(new DataBindingItem(DEFAULT_LIST_ITEM, true, /* isFramework */
                    1));
                }
            }
        } else {
            binding.addItem(new DataBindingItem(DEFAULT_LIST_ITEM, true, /* isFramework */
            1));
        }
        return binding;
    }
    return null;
}
Also used : AdapterBinding(com.android.ide.common.rendering.api.AdapterBinding) DataBindingItem(com.android.ide.common.rendering.api.DataBindingItem) ResourceReference(com.android.ide.common.rendering.api.ResourceReference) Nullable(com.android.annotations.Nullable)

Aggregations

DataBindingItem (com.android.ide.common.rendering.api.DataBindingItem)13 ResourceReference (com.android.ide.common.rendering.api.ResourceReference)7 View (android.view.View)6 AdapterView (android.widget.AdapterView)6 ImageView (android.widget.ImageView)6 TextView (android.widget.TextView)6 BridgeContext (com.android.layoutlib.bridge.android.BridgeContext)6 Nullable (com.android.annotations.Nullable)1 AdapterBinding (com.android.ide.common.rendering.api.AdapterBinding)1