Bug 725930: DoorHangerPopup should be initialized late to avoid problems in startup. [r=mfinkle]
authorSriram Ramasubramanian <sriram@mozilla.com>
Mon, 13 Feb 2012 10:29:29 -0800
changeset 86732 8b995dfd66e1241ac83a027e05aa32f0a003849b
parent 86731 25d02871313b7bbcdae317850e2c42b08b20e189
child 86733 ffcf24db0f74b196dea03005e96a41591e578253
push idunknown
push userunknown
push dateunknown
reviewersmfinkle
bugs725930
milestone13.0a1
Bug 725930: DoorHangerPopup should be initialized late to avoid problems in startup. [r=mfinkle]
mobile/android/base/DoorHangerPopup.java
--- a/mobile/android/base/DoorHangerPopup.java
+++ b/mobile/android/base/DoorHangerPopup.java
@@ -54,35 +54,44 @@ import org.json.JSONObject;
 import org.json.JSONException;
 
 public class DoorHangerPopup extends PopupWindow {
     private static final String LOGTAG = "GeckoDoorHangerPopup";
 
     private Context mContext;
     private LinearLayout mContent;
 
+    private boolean mInflated; 
+
     public DoorHangerPopup(Context aContext) {
         super(aContext);
         mContext = aContext;
+        mInflated = false;
+   }
 
+    private void init() {
         setBackgroundDrawable(new BitmapDrawable());
         setOutsideTouchable(true);
         setWindowLayoutMode(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
 
         LayoutInflater inflater = LayoutInflater.from(mContext);
         RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.doorhangerpopup, null);
         mContent = (LinearLayout) layout.findViewById(R.id.doorhanger_container);
         
         setContentView(layout);
+        mInflated = true;
     }
 
     public void addDoorHanger(String message, String value, JSONArray buttons,
                               Tab tab, JSONObject options) {
         Log.i(LOGTAG, "Adding a DoorHanger to Tab: " + tab.getId());
 
+        if (!mInflated)
+            init();
+
         // Replace the doorhanger if it already exists
         DoorHanger dh = tab.getDoorHanger(value);
         if (dh != null) {
             tab.removeDoorHanger(value);
         }
         dh = new DoorHanger(mContent.getContext(), value);
  
         // Set the doorhanger text and buttons