From 417a9e257f65373b379d16a729921dd3f820e025 Mon Sep 17 00:00:00 2001 From: Margaret Leibovic Date: Wed, 21 Mar 2012 14:08:00 -0700 Subject: [PATCH] Bug 731654 - (2/3) Get rid of mLayout/mHeight/mWidth. r=sriram --- mobile/android/base/FormAssistPopup.java | 27 +++++++----------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/mobile/android/base/FormAssistPopup.java b/mobile/android/base/FormAssistPopup.java index 196c54e2aa6..48f8d3ba1e0 100644 --- a/mobile/android/base/FormAssistPopup.java +++ b/mobile/android/base/FormAssistPopup.java @@ -63,11 +63,6 @@ import org.json.JSONObject; public class FormAssistPopup extends ListView implements GeckoEventListener { private Context mContext; - private RelativeLayout.LayoutParams mLayout; - - private int mWidth; - private int mHeight; - private Animation mAnimation; private static final String LOGTAG = "FormAssistPopup"; @@ -185,12 +180,6 @@ public class FormAssistPopup extends ListView implements GeckoEventListener { startAnimation(mAnimation); } - if (mLayout == null) { - mLayout = (RelativeLayout.LayoutParams) getLayoutParams(); - mWidth = mLayout.width; - mHeight = mLayout.height; - } - int left = 0; int top = 0; int width = 0; @@ -203,14 +192,12 @@ public class FormAssistPopup extends ListView implements GeckoEventListener { height = (int) (rect.getDouble(3) * zoom); } catch (JSONException e) { } - int popupWidth = mWidth; - int popupHeight = mHeight; + int popupWidth = RelativeLayout.LayoutParams.FILL_PARENT; int popupLeft = left < 0 ? 0 : left; - int popupTop = top + height; FloatSize viewport = GeckoApp.mAppContext.getLayerController().getViewportSize(); - // Late initializing variable to allow DisplayMetrics not to be null and avoid NPE + // Late initializing static variables to allow DisplayMetrics not to be null and avoid NPE if (sMinWidth == 0) { DisplayMetrics metrics = new DisplayMetrics(); GeckoApp.mAppContext.getWindowManager().getDefaultDisplay().getMetrics(metrics); @@ -231,7 +218,8 @@ public class FormAssistPopup extends ListView implements GeckoEventListener { popupLeft = (int) (viewport.width - popupWidth); } - popupHeight = sRowHeight * getAdapter().getCount(); + int popupHeight = sRowHeight * getAdapter().getCount(); + int popupTop = top + height; // The text box doesnt fit below if ((popupTop + popupHeight) > viewport.height) { @@ -251,9 +239,10 @@ public class FormAssistPopup extends ListView implements GeckoEventListener { } } - mLayout = new RelativeLayout.LayoutParams(popupWidth, popupHeight); - mLayout.setMargins(popupLeft, popupTop, 0, 0); - setLayoutParams(mLayout); + RelativeLayout.LayoutParams layoutParams = + new RelativeLayout.LayoutParams(popupWidth, popupHeight); + layoutParams.setMargins(popupLeft, popupTop, 0, 0); + setLayoutParams(layoutParams); requestLayout(); return true;