Bug 1312033 - Activity Stream Top Sites: Never add more sites than returned by the cursor. r=ahunt
authorSebastian Kaspari <s.kaspari@gmail.com>
Tue, 25 Oct 2016 15:16:40 +0200
changeset 319548 7d5fa98f80d19195a459620fc2c9440433cf2d8e
parent 319547 09efa4960b229036ad249e1fdcf47b468a7a416a
child 319549 77d16c6dc1f8013b9fc5a97312eaef0d14cf62d7
push id30872
push userphilringnalda@gmail.com
push dateThu, 27 Oct 2016 01:30:58 +0000
treeherdermozilla-central@54f7bdea8976 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahunt
bugs1312033
milestone52.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 1312033 - Activity Stream Top Sites: Never add more sites than returned by the cursor. r=ahunt MozReview-Commit-ID: JONNSrRPNyW
mobile/android/base/java/org/mozilla/gecko/home/activitystream/topsites/TopSitesPageAdapter.java
--- a/mobile/android/base/java/org/mozilla/gecko/home/activitystream/topsites/TopSitesPageAdapter.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/activitystream/topsites/TopSitesPageAdapter.java
@@ -1,22 +1,18 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 package org.mozilla.gecko.home.activitystream.topsites;
 
 import android.content.Context;
 import android.database.Cursor;
-import android.database.CursorWrapper;
 import android.support.annotation.UiThread;
-import android.support.v7.widget.CardView;
 import android.support.v7.widget.RecyclerView;
-import android.util.Log;
-import android.util.TypedValue;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.FrameLayout;
 
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.db.BrowserContract;
 
@@ -58,17 +54,17 @@ public class TopSitesPageAdapter extends
      */
     public void swapCursor(Cursor cursor, int startIndex) {
         topSites.clear();
 
         if (cursor == null) {
             return;
         }
 
-        for (int i = 0; i < tiles; i++) {
+        for (int i = 0; i < tiles && startIndex + i < cursor.getCount(); i++) {
             cursor.moveToPosition(startIndex + i);
 
             // The Combined View only contains pages that have been visited at least once, i.e. any
             // page in the TopSites query will contain a HISTORY_ID. _ID however will be 0 for all rows.
             final long id = cursor.getLong(cursor.getColumnIndexOrThrow(BrowserContract.Combined.HISTORY_ID));
             final String url = cursor.getString(cursor.getColumnIndexOrThrow(BrowserContract.Combined.URL));
 
             topSites.add(new TopSite(id, url));