Bug 1357780 - ActionProvider be able to use new context draft
authorJulian_Chu <walkingice0204@gmail.com>
Wed, 17 May 2017 18:19:31 +0800
changeset 580070 0250f2e464bd48a75b17d8087a04e59c47ca7a7c
parent 579118 41958333867b0f537271dbd4cb4ba9e8a67a85a8
child 580071 1bec34ccb27e939481e705d98322482e7fb323a2
push id59440
push userbmo:walkingice0204@gmail.com
push dateThu, 18 May 2017 05:35:23 +0000
bugs1357780
milestone55.0a1
Bug 1357780 - ActionProvider be able to use new context The Context menu will use ActionProvider to create ActionView to use. GeckoActionProvider cache a Context inside. In CustomTabs, we might change Theme at runtime, therefore cached context might be outdated. Now we check wheter the context is the same one. MozReview-Commit-ID: I8S3dEjdyZI
mobile/android/base/java/org/mozilla/gecko/widget/GeckoActionProvider.java
--- a/mobile/android/base/java/org/mozilla/gecko/widget/GeckoActionProvider.java
+++ b/mobile/android/base/java/org/mozilla/gecko/widget/GeckoActionProvider.java
@@ -79,16 +79,23 @@ public class GeckoActionProvider {
             return DEFAULT_HISTORY_FILE_NAME;
         }
 
         return "history-" + mime[0] + ".xml";
     }
 
     // Gets the action provider for a particular mimetype
     public static GeckoActionProvider getForType(String mimeType, Context context) {
+        if (mProviders.keySet().contains(mimeType)) {
+            GeckoActionProvider provider = mProviders.get(mimeType);
+            if (provider.mContext != context) {
+                mProviders.remove(mimeType);
+            }
+        }
+
         if (!mProviders.keySet().contains(mimeType)) {
             GeckoActionProvider provider = new GeckoActionProvider(context);
 
             // For empty types, we just return a default provider
             if (TextUtils.isEmpty(mimeType)) {
                 return provider;
             }