aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseLayoutRule.java
diff options
context:
space:
mode:
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseLayoutRule.java')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseLayoutRule.java58
1 files changed, 35 insertions, 23 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseLayoutRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseLayoutRule.java
index 581788b..6f76b51 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseLayoutRule.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseLayoutRule.java
@@ -16,7 +16,6 @@
package com.android.ide.common.layout;
-import static com.android.util.XmlUtils.ANDROID_URI;
import static com.android.ide.common.layout.LayoutConstants.ATTR_ID;
import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_ABOVE;
import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_ALIGN_BASELINE;
@@ -52,7 +51,10 @@ import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_Y;
import static com.android.ide.common.layout.LayoutConstants.VALUE_FILL_PARENT;
import static com.android.ide.common.layout.LayoutConstants.VALUE_MATCH_PARENT;
import static com.android.ide.common.layout.LayoutConstants.VALUE_WRAP_CONTENT;
+import static com.android.util.XmlUtils.ANDROID_URI;
+import com.android.annotations.NonNull;
+import com.android.annotations.Nullable;
import com.android.ide.common.api.DrawingStyle;
import com.android.ide.common.api.DropFeedback;
import com.android.ide.common.api.IAttributeInfo;
@@ -114,11 +116,13 @@ public class BaseLayoutRule extends BaseViewRule {
IMenuCallback actionCallback = new IMenuCallback() {
@Override
- public void action(RuleAction action, List<? extends INode> selectedNodes,
- final String valueId, final Boolean newValue) {
+ public void action(@NonNull RuleAction action,
+ @NonNull List<? extends INode> selectedNodes,
+ final @Nullable String valueId,
+ final @Nullable Boolean newValue) {
parentNode.editXml("Change Margins", new INodeHandler() {
@Override
- public void handle(INode n) {
+ public void handle(@NonNull INode n) {
String uri = ANDROID_URI;
String all = first.getStringAttr(uri, ATTR_LAYOUT_MARGIN);
String left = first.getStringAttr(uri, ATTR_LAYOUT_MARGIN_LEFT);
@@ -154,8 +158,8 @@ public class BaseLayoutRule extends BaseViewRule {
final INode first = targets.get(0);
ChoiceProvider provider = new ChoiceProvider() {
@Override
- public void addChoices(List<String> titles, List<URL> iconUrls,
- List<String> ids) {
+ public void addChoices(@NonNull List<String> titles, @NonNull List<URL> iconUrls,
+ @NonNull List<String> ids) {
IAttributeInfo info = first.getAttributeInfo(ANDROID_URI, attributeName);
if (info != null) {
// Generate list of possible gravity value constants
@@ -180,8 +184,10 @@ public class BaseLayoutRule extends BaseViewRule {
}
@Override
- public void addLayoutActions(List<RuleAction> actions, final INode parentNode,
- final List<? extends INode> children) {
+ public void addLayoutActions(
+ @NonNull List<RuleAction> actions,
+ final @NonNull INode parentNode,
+ final @NonNull List<? extends INode> children) {
super.addLayoutActions(actions, parentNode, children);
final List<? extends INode> targets = children == null || children.size() == 0 ?
@@ -192,8 +198,11 @@ public class BaseLayoutRule extends BaseViewRule {
// Shared action callback
IMenuCallback actionCallback = new IMenuCallback() {
@Override
- public void action(RuleAction action, List<? extends INode> selectedNodes,
- final String valueId, final Boolean newValue) {
+ public void action(
+ @NonNull RuleAction action,
+ @NonNull List<? extends INode> selectedNodes,
+ final @Nullable String valueId,
+ final @Nullable Boolean newValue) {
final String actionId = action.getId();
final String undoLabel;
if (actionId.equals(ACTION_FILL_WIDTH)) {
@@ -205,7 +214,7 @@ public class BaseLayoutRule extends BaseViewRule {
}
parentNode.editXml(undoLabel, new INodeHandler() {
@Override
- public void handle(INode n) {
+ public void handle(@NonNull INode n) {
String attribute = actionId.equals(ACTION_FILL_WIDTH)
? ATTR_LAYOUT_WIDTH : ATTR_LAYOUT_HEIGHT;
String value;
@@ -244,7 +253,8 @@ public class BaseLayoutRule extends BaseViewRule {
* Derived layouts should override this behavior if not appropriate.
*/
@Override
- public void onPaste(INode targetNode, Object targetView, IDragElement[] elements) {
+ public void onPaste(@NonNull INode targetNode, @Nullable Object targetView,
+ @NonNull IDragElement[] elements) {
DropFeedback feedback = onDropEnter(targetNode, targetView, elements);
if (feedback != null) {
Point p = targetNode.getBounds().getTopLeft();
@@ -576,7 +586,7 @@ public class BaseLayoutRule extends BaseViewRule {
targetNode.editXml("Insert Elements", new INodeHandler() {
@Override
- public void handle(INode node) {
+ public void handle(@NonNull INode node) {
// Now write the new elements.
int insertPos = initialInsertPos;
for (IDragElement element : elements) {
@@ -606,9 +616,9 @@ public class BaseLayoutRule extends BaseViewRule {
}
@Override
- public DropFeedback onResizeBegin(INode child, INode parent,
- SegmentType horizontalEdge, SegmentType verticalEdge,
- Object childView, Object parentView) {
+ public DropFeedback onResizeBegin(@NonNull INode child, @NonNull INode parent,
+ @Nullable SegmentType horizontalEdge, @Nullable SegmentType verticalEdge,
+ @Nullable Object childView, @Nullable Object parentView) {
ResizeState state = createResizeState(parent, parentView, child);
state.horizontalEdgeType = horizontalEdge;
state.verticalEdgeType = verticalEdge;
@@ -618,7 +628,8 @@ public class BaseLayoutRule extends BaseViewRule {
Map<INode, Rect> sizes = mRulesEngine.measureChildren(parent,
new IClientRulesEngine.AttributeFilter() {
@Override
- public String getAttribute(INode node, String namespace, String localName) {
+ public String getAttribute(@NonNull INode node, @Nullable String namespace,
+ @NonNull String localName) {
// Change attributes to wrap_content
if (ATTR_LAYOUT_WIDTH.equals(localName)
&& SdkConstants.NS_RESOURCES.equals(namespace)) {
@@ -638,7 +649,8 @@ public class BaseLayoutRule extends BaseViewRule {
return new DropFeedback(state, new IFeedbackPainter() {
@Override
- public void paint(IGraphics gc, INode node, DropFeedback feedback) {
+ public void paint(@NonNull IGraphics gc, @NonNull INode node,
+ @NonNull DropFeedback feedback) {
ResizeState resizeState = (ResizeState) feedback.userData;
if (resizeState != null && resizeState.bounds != null) {
paintResizeFeedback(gc, node, resizeState);
@@ -737,8 +749,8 @@ public class BaseLayoutRule extends BaseViewRule {
}
@Override
- public void onResizeUpdate(DropFeedback feedback, INode child, INode parent,
- Rect newBounds, int modifierMask) {
+ public void onResizeUpdate(@Nullable DropFeedback feedback, @NonNull INode child,
+ @NonNull INode parent, @NonNull Rect newBounds, int modifierMask) {
ResizeState state = (ResizeState) feedback.userData;
state.bounds = newBounds;
state.modifierMask = modifierMask;
@@ -799,14 +811,14 @@ public class BaseLayoutRule extends BaseViewRule {
}
@Override
- public void onResizeEnd(DropFeedback feedback, INode child, final INode parent,
- final Rect newBounds) {
+ public void onResizeEnd(@Nullable DropFeedback feedback, @NonNull INode child,
+ final @NonNull INode parent, final @NonNull Rect newBounds) {
final Rect oldBounds = child.getBounds();
if (oldBounds.w != newBounds.w || oldBounds.h != newBounds.h) {
final ResizeState state = (ResizeState) feedback.userData;
child.editXml("Resize", new INodeHandler() {
@Override
- public void handle(INode n) {
+ public void handle(@NonNull INode n) {
setNewSizeBounds(state, n, parent, oldBounds, newBounds,
state.horizontalEdgeType, state.verticalEdgeType);
}