Bug 836924 - java.lang.NullPointerException: at org.mozilla.gecko.Tabs.getContentResolver r=bnicholson
authorMark Finkle <mfinkle@mozilla.com>
Mon, 18 Feb 2013 16:17:54 -0500
changeset 132132 adf96501de917cf1516beaa2ef79c19ae3a4c67a
parent 132131 fc380df34bd6a0055483a554695cf8276d803ca5
child 132133 8febb0aa205f439e0449e4e9d6b17ff2bee005e0
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbnicholson
bugs836924
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 836924 - java.lang.NullPointerException: at org.mozilla.gecko.Tabs.getContentResolver r=bnicholson
mobile/android/base/AwesomeBar.java
mobile/android/base/MemoryMonitor.java
--- a/mobile/android/base/AwesomeBar.java
+++ b/mobile/android/base/AwesomeBar.java
@@ -7,17 +7,16 @@ package org.mozilla.gecko;
 
 import org.mozilla.gecko.db.BrowserDB;
 import org.mozilla.gecko.db.BrowserContract.Combined;
 import org.mozilla.gecko.util.GeckoAsyncTask;
 import org.mozilla.gecko.util.StringUtils;
 
 import android.app.Activity;
 import android.app.AlertDialog;
-import android.content.ContentResolver;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.res.Configuration;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.net.Uri;
 import android.os.AsyncTask;
@@ -64,30 +63,27 @@ public class AwesomeBar extends GeckoAct
     static final String USER_ENTERED_KEY = "user_entered";
     static final String READING_LIST_KEY = "reading_list";
     public static enum Target { NEW_TAB, CURRENT_TAB, PICK_SITE };
 
     private String mTarget;
     private AwesomeBarTabs mAwesomeTabs;
     private CustomEditText mText;
     private ImageButton mGoButton;
-    private ContentResolver mResolver;
     private ContextMenuSubject mContextMenuSubject;
     private boolean mIsUsingSwype;
     private boolean mDelayRestartInput;
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         Log.d(LOGTAG, "creating awesomebar");
 
-        mResolver = Tabs.getInstance().getContentResolver();
         LayoutInflater.from(this).setFactory(GeckoViewsFactory.getInstance());
-
         setContentView(R.layout.awesomebar);
 
         mGoButton = (ImageButton) findViewById(R.id.awesomebar_button);
         mText = (CustomEditText) findViewById(R.id.awesomebar_text);
 
         TabWidget tabWidget = (TabWidget) findViewById(android.R.id.tabs);
         tabWidget.setDividerDrawable(null);
 
@@ -379,20 +375,20 @@ public class AwesomeBar extends GeckoAct
     }
 
     private void openUserEnteredAndFinish(String url) {
         int index = url.indexOf(' ');
         String keywordUrl = null;
         String keywordSearch = null;
 
         if (index == -1) {
-            keywordUrl = BrowserDB.getUrlForKeyword(mResolver, url);
+            keywordUrl = BrowserDB.getUrlForKeyword(getContentResolver(), url);
             keywordSearch = "";
         } else {
-            keywordUrl = BrowserDB.getUrlForKeyword(mResolver, url.substring(0, index));
+            keywordUrl = BrowserDB.getUrlForKeyword(getContentResolver(), url.substring(0, index));
             keywordSearch = url.substring(index + 1);
         }
 
         if (keywordUrl != null) {
             String search = URLEncoder.encode(keywordSearch);
             url = keywordUrl.replace("%s", search);
         }
 
@@ -570,17 +566,17 @@ public class AwesomeBar extends GeckoAct
                 keywordText.setText(keyword);
 
                 editPrompt.setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {
                     public void onClick(DialogInterface dialog, int whichButton) {
                         (new GeckoAsyncTask<Void, Void, Void>(GeckoApp.mAppContext, GeckoAppShell.getHandler()) {
                             @Override
                             public Void doInBackground(Void... params) {
                                 String newUrl = locationText.getText().toString().trim();
-                                BrowserDB.updateBookmark(mResolver, id, newUrl, nameText.getText().toString(),
+                                BrowserDB.updateBookmark(getContentResolver(), id, newUrl, nameText.getText().toString(),
                                                          keywordText.getText().toString());
                                 return null;
                             }
 
                             @Override
                             public void onPostExecute(Void result) {
                                 Toast.makeText(AwesomeBar.this, R.string.bookmark_updated, Toast.LENGTH_SHORT).show();
                             }
@@ -622,17 +618,17 @@ public class AwesomeBar extends GeckoAct
 
                     @Override
                     public void onPreExecute() {
                         mInReadingList = mAwesomeTabs.isInReadingList();
                     }
 
                     @Override
                     public Void doInBackground(Void... params) {
-                        BrowserDB.removeBookmark(mResolver, id);
+                        BrowserDB.removeBookmark(getContentResolver(), id);
                         return null;
                     }
 
                     @Override
                     public void onPostExecute(Void result) {
                         int messageId = R.string.bookmark_removed;
                         if (mInReadingList) {
                             messageId = R.string.reading_list_removed;
@@ -645,17 +641,17 @@ public class AwesomeBar extends GeckoAct
                     }
                 }).execute();
                 break;
             }
             case R.id.remove_history: {
                 (new GeckoAsyncTask<Void, Void, Void>(GeckoApp.mAppContext, GeckoAppShell.getHandler()) {
                     @Override
                     public Void doInBackground(Void... params) {
-                        BrowserDB.removeHistoryEntry(mResolver, id);
+                        BrowserDB.removeHistoryEntry(getContentResolver(), id);
                         return null;
                     }
 
                     @Override
                     public void onPostExecute(Void result) {
                         Toast.makeText(AwesomeBar.this, R.string.history_removed, Toast.LENGTH_SHORT).show();
                     }
                 }).execute();
--- a/mobile/android/base/MemoryMonitor.java
+++ b/mobile/android/base/MemoryMonitor.java
@@ -213,13 +213,13 @@ class MemoryMonitor extends BroadcastRec
 
             if (!mStoragePressure) {
                 // pressure is off, so we can abort
                 return;
             }
 
             BrowserDB.expireHistory(mContext.getContentResolver(),
                                     BrowserContract.ExpirePriority.AGGRESSIVE);
-            BrowserDB.removeThumbnails(Tabs.getInstance().getContentResolver());
+            BrowserDB.removeThumbnails(mContext.getContentResolver());
             // TODO: drop or shrink disk caches
         }
     }
 }