Bug 787877 - History list doesn't update after you remove the last history item using context menu (r=wesj)

This commit is contained in:
Lucas Rocha 2012-09-12 12:31:44 +01:00
parent ffc89c8d34
commit 9b186f36d8

View File

@ -205,7 +205,6 @@ public class HistoryTab extends AwesomeBarTab {
private static final long MS_PER_WEEK = MS_PER_DAY * 7; private static final long MS_PER_WEEK = MS_PER_DAY * 7;
protected Pair<GroupList,List<ChildrenList>> doInBackground(Void... arg0) { protected Pair<GroupList,List<ChildrenList>> doInBackground(Void... arg0) {
Pair<GroupList, List<ChildrenList>> result = null;
Cursor cursor = BrowserDB.getRecentHistory(getContentResolver(), MAX_RESULTS); Cursor cursor = BrowserDB.getRecentHistory(getContentResolver(), MAX_RESULTS);
Date now = new Date(); Date now = new Date();
@ -217,9 +216,9 @@ public class HistoryTab extends AwesomeBarTab {
// Split the list of urls into separate date range groups // Split the list of urls into separate date range groups
// and show it in an expandable list view. // and show it in an expandable list view.
List<ChildrenList> childrenLists = null; List<ChildrenList> childrenLists = new LinkedList<ChildrenList>();
ChildrenList children = null; ChildrenList children = null;
GroupList groups = null; GroupList groups = new GroupList();
HistorySection section = null; HistorySection section = null;
// Move cursor before the first row in preparation // Move cursor before the first row in preparation
@ -234,12 +233,6 @@ public class HistoryTab extends AwesomeBarTab {
long time = cursor.getLong(cursor.getColumnIndexOrThrow(URLColumns.DATE_LAST_VISITED)); long time = cursor.getLong(cursor.getColumnIndexOrThrow(URLColumns.DATE_LAST_VISITED));
HistorySection itemSection = getSectionForTime(time, today); HistorySection itemSection = getSectionForTime(time, today);
if (groups == null)
groups = new GroupList();
if (childrenLists == null)
childrenLists = new LinkedList<ChildrenList>();
if (section != itemSection) { if (section != itemSection) {
if (section != null) { if (section != null) {
groups.add(createGroupItem(section)); groups.add(createGroupItem(section));
@ -263,11 +256,8 @@ public class HistoryTab extends AwesomeBarTab {
// Close the query cursor as we won't use it anymore // Close the query cursor as we won't use it anymore
cursor.close(); cursor.close();
if (groups != null && childrenLists != null) { // groups and childrenLists will be empty lists if there's no history
result = Pair.<GroupList,List<ChildrenList>>create(groups, childrenLists); return Pair.<GroupList,List<ChildrenList>>create(groups, childrenLists);
}
return result;
} }
public Map<String,Object> createHistoryItem(Cursor cursor) { public Map<String,Object> createHistoryItem(Cursor cursor) {
@ -350,10 +340,6 @@ public class HistoryTab extends AwesomeBarTab {
} }
protected void onPostExecute(Pair<GroupList,List<ChildrenList>> result) { protected void onPostExecute(Pair<GroupList,List<ChildrenList>> result) {
// FIXME: display some sort of message when there's no history
if (result == null)
return;
mCursorAdapter = new HistoryListAdapter( mCursorAdapter = new HistoryListAdapter(
mContext, mContext,
result.first, result.first,