Fix Edge Navigation discovery panel

Previously the view was not getting cleaned
up, this could break some browser functionality

Change-Id: Ic29e11316a54a3876feb7752652742c104f277cf
CR-Fixed: 900986
diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java
index 374bc15..4f7ad3f 100644
--- a/src/com/android/browser/BaseUi.java
+++ b/src/com/android/browser/BaseUi.java
@@ -448,10 +448,13 @@
             mEdgeSwipeController.cleanup();
         }
 
-        mEdgeSwipeSettings = null;
-
         String action = BrowserSettings.getInstance().getEdgeSwipeAction();
 
+        if (mEdgeSwipeSettings != null)  {
+            mEdgeSwipeSettings.cleanup();
+        }
+        mEdgeSwipeSettings = null;
+
         if (action.equalsIgnoreCase(
                 mActivity.getResources().getString(R.string.value_temporal_edge_swipe))) {
             mEdgeSwipeController = new EdgeSwipeController(
diff --git a/src/com/android/browser/EdgeSwipeSettings.java b/src/com/android/browser/EdgeSwipeSettings.java
index 71c8a56..dd6da87 100644
--- a/src/com/android/browser/EdgeSwipeSettings.java
+++ b/src/com/android/browser/EdgeSwipeSettings.java
@@ -182,6 +182,14 @@
         goLive();
     }
 
+    public void cleanup() {
+        synchronized (this) {
+            goLive();
+            mModel.cleanup();
+        }
+    }
+
+
     private void showCurrBitmap() {
         if (mStationaryView.getVisibility() == View.VISIBLE) {
             return;
@@ -309,4 +317,3 @@
         return left;
     }
 }
-