summaryrefslogtreecommitdiff
path: root/core/java/android/widget/PopupWindow.java
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-18 17:39:46 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-18 17:39:46 -0700
commit105925376f8d0f6b318c9938c7b83ef7fef094da (patch)
tree3b19ee2bd8704cb9c6a0da7e42dec6759183de6d /core/java/android/widget/PopupWindow.java
parentba87e3e6c985e7175152993b5efcc7dd2f0e1c93 (diff)
auto import from //branches/cupcake_rel/...@140373
Diffstat (limited to 'core/java/android/widget/PopupWindow.java')
-rw-r--r--core/java/android/widget/PopupWindow.java42
1 files changed, 27 insertions, 15 deletions
diff --git a/core/java/android/widget/PopupWindow.java b/core/java/android/widget/PopupWindow.java
index a4f729f6f6eb..f864690b60f8 100644
--- a/core/java/android/widget/PopupWindow.java
+++ b/core/java/android/widget/PopupWindow.java
@@ -1125,17 +1125,16 @@ public class PopupWindow {
}
/**
- * <p>Updates the position and the dimension of the popup window. Width and
- * height can be set to -1 to update location only. Calling this function
- * also updates the window with the current popup state as
- * described for {@link #update()}.</p>
+ * <p>Updates the position and the dimension of the popup window. Calling this
+ * function also updates the window with the current popup state as described
+ * for {@link #update()}.</p>
*
* @param anchor the popup's anchor view
* @param width the new width, can be -1 to ignore
* @param height the new height, can be -1 to ignore
*/
public void update(View anchor, int width, int height) {
- update(anchor, 0, 0, width, height);
+ update(anchor, false, 0, 0, true, width, height);
}
/**
@@ -1153,31 +1152,44 @@ public class PopupWindow {
* @param height the new height, can be -1 to ignore
*/
public void update(View anchor, int xoff, int yoff, int width, int height) {
+ update(anchor, true, xoff, yoff, true, width, height);
+ }
+
+ private void update(View anchor, boolean updateLocation, int xoff, int yoff,
+ boolean updateDimension, int width, int height) {
+
if (!isShowing() || mContentView == null) {
return;
}
WeakReference<View> oldAnchor = mAnchor;
if (oldAnchor == null || oldAnchor.get() != anchor ||
- mAnchorXoff != xoff || mAnchorYoff != yoff) {
+ (updateLocation && (mAnchorXoff != xoff || mAnchorYoff != yoff))) {
registerForScrollChanged(anchor, xoff, yoff);
}
WindowManager.LayoutParams p = (WindowManager.LayoutParams)
mPopupView.getLayoutParams();
- if (width == -1) {
- width = mPopupWidth;
- } else {
- mPopupWidth = width;
+ if (updateDimension) {
+ if (width == -1) {
+ width = mPopupWidth;
+ } else {
+ mPopupWidth = width;
+ }
+ if (height == -1) {
+ height = mPopupHeight;
+ } else {
+ mPopupHeight = height;
+ }
}
- if (height == -1) {
- height = mPopupHeight;
+
+ if (updateLocation) {
+ mAboveAnchor = findDropDownPosition(anchor, p, xoff, yoff);
} else {
- mPopupHeight = height;
+ mAboveAnchor = findDropDownPosition(anchor, p, mAnchorXoff, mAnchorYoff);
}
-
- mAboveAnchor = findDropDownPosition(anchor, p, xoff, yoff);
+
update(p.x, p.y, width, height);
}