Also update the IProjectCallback to handle expandableListView.
Change-Id: I36ca8733182bbd9d169fee3e709ebc532fef7b1e
}
public Object getAdapterItemValue(ResourceReference adapterView, Object adapterCookie,
- ResourceReference itemRef, int fullPosition, int typePosition,
+ ResourceReference itemRef,
+ int fullPosition, int typePosition, int fullChildPosition, int typeChildPosition,
ResourceReference viewRef, ViewAttribute viewAttribute, Object defaultValue) {
if (viewAttribute == ViewAttribute.TEXT && ((String) defaultValue).length() == 0) {
return viewRef.getName() + " " + typePosition;
return null;
}
- public AdapterBinding getAdapterBinding(ResourceReference adapterView, Object adapterCookie) {
+ public AdapterBinding getAdapterBinding(ResourceReference adapterView, Object adapterCookie,
+ Object viewObject) {
return null;
}
}
public Object getAdapterItemValue(ResourceReference adapterView, Object adapterCookie,
ResourceReference itemRef, int fullPosition, int typePosition,
+ int fullChildPosition, int typeChildPosition,
ResourceReference viewRef, ViewAttribute viewAttribute, Object defaultValue) {
return null;
}
public AdapterBinding getAdapterBinding(ResourceReference adapterView,
- Object adapterCookie) {
+ Object adapterCookie, Object viewObject) {
return null;
}
}
package com.android.ide.eclipse.adt.internal.editors.layout.gle2;
import com.android.ide.common.rendering.api.Capability;
+import com.android.ide.common.rendering.api.DataBindingItem;
import com.android.ide.common.rendering.api.MergeCookie;
import com.android.ide.common.rendering.api.ViewInfo;
-import com.android.ide.common.rendering.api.AdapterBinding.AdapterItemReference;
import com.android.ide.eclipse.adt.internal.editors.descriptors.AttributeDescriptor;
import com.android.ide.eclipse.adt.internal.editors.descriptors.ElementDescriptor;
import com.android.ide.eclipse.adt.internal.editors.layout.descriptors.ViewElementDescriptor;
UiViewElementNode childNode = createNode(rootNode, "ListView", false);
/*UiViewElementNode grandChildNode =*/ createNode(childNode, "LinearLayout", false);
/*UiViewElementNode greatGrandChildNode =*/ createNode(childNode, "TextView", false);
- AdapterItemReference adapterItem = new AdapterItemReference("foo");
+ DataBindingItem dataBindingItem = new DataBindingItem("foo");
ViewInfo root = new ViewInfo("FrameLayout", rootNode, 0, 50, 320, 480);
ViewInfo child = new ViewInfo("ListView", childNode, 0, 0, 320, 430);
root.setChildren(Collections.singletonList(child));
- ViewInfo grandChild = new ViewInfo("LinearLayout", adapterItem, 0, 0, 320, 17);
+ ViewInfo grandChild = new ViewInfo("LinearLayout", dataBindingItem, 0, 0, 320, 17);
child.setChildren(Collections.singletonList(grandChild));
ViewInfo greatGrandChild = new ViewInfo("Button", null, 0, 0, 73, 17);
grandChild.setChildren(Collections.singletonList(greatGrandChild));
package com.android.ide.common.rendering;
+import static com.android.ide.common.rendering.api.Result.Status.NOT_IMPLEMENTED;
+
import com.android.ide.common.log.ILogger;
import com.android.ide.common.rendering.api.Bridge;
import com.android.ide.common.rendering.api.Capability;
}
}
+ /**
+ * Utility method returning the parent of a given view object.
+ *
+ * @param viewObject the object for which to return the parent.
+ *
+ * @return a {@link Result} indicating the status of the action, and if success, the parent
+ * object in {@link Result#getData()}
+ */
+ public Result getViewParent(Object viewObject) {
+ if (mBridge != null) {
+ return mBridge.getViewParent(viewObject);
+ }
+
+ return NOT_IMPLEMENTED.createResult();
+ }
+
+ /**
+ * Utility method returning the index of a given view in its parent.
+ * @param viewObject the object for which to return the index.
+ *
+ * @return a {@link Result} indicating the status of the action, and if success, the index in
+ * the parent in {@link Result#getData()}
+ */
+ public Result getViewIndex(Object viewObject) {
+ if (mBridge != null) {
+ return mBridge.getViewIndex(viewObject);
+ }
+
+ return NOT_IMPLEMENTED.createResult();
+ }
+
+
// ------ Implementation
private LayoutLibrary(Bridge bridge, ILayoutBridge legacyBridge, ClassLoader classLoader,
for (Entry<ResourceType, Map<String, ResourceValue>> entry : map.entrySet()) {
// ugly case but works.
result.put(entry.getKey().getName(),
- (Map<String, IResourceValue>)(Map) entry.getValue());
+ (Map) entry.getValue());
}
return result;
package com.android.ide.common.rendering.api;
+import static com.android.ide.common.rendering.api.Result.Status.NOT_IMPLEMENTED;
+
import com.android.ide.common.rendering.api.Result.Status;
import java.awt.image.BufferedImage;
public void clearCaches(Object projectKey) {
}
+
+ /**
+ * Utility method returning the parent of a given view object.
+ *
+ * @param viewObject the object for which to return the parent.
+ *
+ * @return a {@link Result} indicating the status of the action, and if success, the parent
+ * object in {@link Result#getData()}
+ */
+ public Result getViewParent(Object viewObject) {
+ return NOT_IMPLEMENTED.createResult();
+ }
+
+ /**
+ * Utility method returning the index of a given view in its parent.
+ * @param viewObject the object for which to return the index.
+ *
+ * @return a {@link Result} indicating the status of the action, and if success, the index in
+ * the parent in {@link Result#getData()}
+ */
+ public Result getViewIndex(Object viewObject) {
+ return NOT_IMPLEMENTED.createResult();
+ }
}
* @param itemRef the {@link ResourceReference} for the layout used by the adapter item.
* @param fullPosition the position of the item in the full list.
* @param typePosition the position of the item if only items of the same type are considered.
- * If there is only one type of items, this is the same as <var>position</var>.
+ * If there is only one type of items, this is the same as <var>fullPosition</var>.
+ * @param fullChildPosition the position of the item in the full children list. This is only
+ * valid if the adapter view is an ExpandableListView.
+ * @param typeChildPosition the position of the child item if only items of the same type are
+ * considered. This is only valid if the adapter view is an ExpandableListView.
+ * If there is only one type of items, this is the same as <var>fullChildPosition</var>.
* @param viewRef The {@link ResourceReference} for the view we're trying to fill.
* @param ViewAttribute the attribute being queried.
* @param defaultValue the default value for this attribute. The object class matches the
* @see ViewAttribute#getAttributeClass()
*/
Object getAdapterItemValue(ResourceReference adapterView, Object adapterCookie,
- ResourceReference itemRef, int fullPosition, int typePosition,
+ ResourceReference itemRef,
+ int fullPosition, int typePosition,
+ int fullChildPosition, int typeChildPosition,
ResourceReference viewRef, ViewAttribute viewAttribute, Object defaultValue);
/**
* This is only called if {@link SessionParams} does not have an {@link AdapterBinding} for
* the given {@link ResourceReference} already.
*
- * @param adapterView the adapter view to return the adapter binding for.
+ * @param adapterViewRef the reference of adapter view to return the adapter binding for.
* @param adapterCookie the view cookie for this particular view.
+ * @param viewObject the view object for the adapter.
* @return an adapter binding for the given view or null if there's no data.
*/
- AdapterBinding getAdapterBinding(ResourceReference adapterView, Object adapterCookie);
+ AdapterBinding getAdapterBinding(ResourceReference adapterViewRef, Object adapterCookie,
+ Object viewObject);
}
}
/**
- * Returns the View parent.
- *
- * @param viewObject the object for which to return the parent.
- *
- * @return a {@link Result} indicating the status of the action, and if success, the parent
- * object in {@link Result#getData()}
- */
- public Result getViewParent(Object viewObject) {
- return NOT_IMPLEMENTED.createResult();
- }
-
- /**
- * Returns the index of a given view it its parent.
- * @param viewObject the object for which to return the index.
- *
- * @return a {@link Result} indicating the status of the action, and if success, the index in
- * the parent in {@link Result#getData()}
- */
- public Result getViewIndex(Object viewObject) {
- return NOT_IMPLEMENTED.createResult();
- }
-
- /**
* Inserts a new child in a ViewGroup object, and renders the result.
* <p/>
* The child is first inflated and then added to its new parent, at the given <var>index<var>