Bug 1266104 - Ensure SavedReaderViewHelper is loaded for recent tabs panel r=margaret

I wonder if there is a better solution to guarantee we have the necessary data loaded, however
this seems to be the only special case (i.e. the only place we use TwoLinePageRow without
the DB having been loaded first).

MozReview-Commit-ID: F4iAIpe87IY

--HG--
extra : amend_source : 798700a320878d440bac4a6af7a5438601f3fe36
This commit is contained in:
Andrzej Hunt 2016-04-20 22:02:49 +02:00
Родитель 4718e06787
Коммит 3d195e4e1f
1 изменённых файлов: 10 добавлений и 0 удалений

Просмотреть файл

@ -22,6 +22,7 @@ import org.mozilla.gecko.Telemetry;
import org.mozilla.gecko.TelemetryContract;
import org.mozilla.gecko.db.BrowserContract.CommonColumns;
import org.mozilla.gecko.db.BrowserContract.URLColumns;
import org.mozilla.gecko.reader.SavedReaderViewHelper;
import org.mozilla.gecko.util.EventCallback;
import org.mozilla.gecko.util.NativeEventListener;
import org.mozilla.gecko.util.NativeJSObject;
@ -286,6 +287,15 @@ public class RecentTabsPanel extends HomeFragment
@Override
public Cursor loadCursor() {
// TwoLinePageRow requires the SavedReaderViewHelper to be initialised. Usually this is
// done as part of BrowserDatabaseHelper.onOpen(), however we don't actually access
// the DB when showing the Recent Tabs panel, hence it's possible that the SavedReaderViewHelper
// isn't loaded. Therefore we need to explicitly force loading here.
// Note: loadCursor is run on a background thread, hence it's safe to do this here.
// (loading time is a few ms, and hence shouldn't impact overall loading time for this
// panel in any significant way).
SavedReaderViewHelper.getSavedReaderViewHelper(getContext()).loadItems();
final Context context = getContext();
final MatrixCursor c = new MatrixCursor(new String[] { RecentTabs._ID,