From 59280307b381a247a2f6a5299a5893f5f5337306 Mon Sep 17 00:00:00 2001 From: John Reck Date: Mon, 6 Dec 2010 10:27:39 -0800 Subject: Fixes race condition in HistoryAdapter Bug: 3245076 There was a race condition between the two loaders. If most visited finished loading first, history would crash. Change-Id: I561edffe0cadef452b5fa2d621466bf23a9c57cf --- src/com/android/browser/BrowserHistoryPage.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/com/android/browser/BrowserHistoryPage.java') diff --git a/src/com/android/browser/BrowserHistoryPage.java b/src/com/android/browser/BrowserHistoryPage.java index e9db66790..f99e7b54f 100644 --- a/src/com/android/browser/BrowserHistoryPage.java +++ b/src/com/android/browser/BrowserHistoryPage.java @@ -376,7 +376,6 @@ public class BrowserHistoryPage extends Fragment @Override public long getChildId(int groupPosition, int childPosition) { - if (!mDataValid) return 0; if (moveCursorToChildPosition(groupPosition, childPosition)) { Cursor cursor = getCursor(groupPosition); return cursor.getLong(HistoryQuery.INDEX_ID); @@ -418,7 +417,9 @@ public class BrowserHistoryPage extends Fragment public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { if (groupPosition >= super.getGroupCount()) { - if (!mDataValid) throw new IllegalStateException("Data is not valid"); + if (mMostVisited == null || mMostVisited.isClosed()) { + throw new IllegalStateException("Data is not valid"); + } TextView item; if (null == convertView || !(convertView instanceof TextView)) { LayoutInflater factory = LayoutInflater.from(getContext()); @@ -436,7 +437,7 @@ public class BrowserHistoryPage extends Fragment boolean moveCursorToChildPosition( int groupPosition, int childPosition) { if (groupPosition >= super.getGroupCount()) { - if (mDataValid && !mMostVisited.isClosed()) { + if (mMostVisited != null && !mMostVisited.isClosed()) { mMostVisited.moveToPosition(childPosition); return true; } -- cgit v1.2.3