зеркало из https://github.com/mozilla/pjs.git
Bug 722020 (Part 2) - Fix bookmarks context menu. r=wesj
This commit is contained in:
Родитель
d0bc6b91d7
Коммит
e586a75214
|
@ -409,23 +409,7 @@ public class AwesomeBar extends Activity implements GeckoEventListener {
|
||||||
Object selectedItem = null;
|
Object selectedItem = null;
|
||||||
String title = "";
|
String title = "";
|
||||||
|
|
||||||
if (list == findViewById(R.id.all_pages_list)) {
|
if (list == findViewById(R.id.history_list)) {
|
||||||
if (!(menuInfo instanceof AdapterView.AdapterContextMenuInfo)) {
|
|
||||||
Log.e(LOGTAG, "menuInfo is not AdapterContextMenuInfo");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
|
|
||||||
selectedItem = list.getItemAtPosition(info.position);
|
|
||||||
|
|
||||||
if (!(selectedItem instanceof Cursor)) {
|
|
||||||
Log.e(LOGTAG, "item at " + info.position + " is not a Cursor");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Cursor cursor = (Cursor) selectedItem;
|
|
||||||
title = cursor.getString(cursor.getColumnIndexOrThrow(URLColumns.TITLE));
|
|
||||||
} else {
|
|
||||||
if (!(menuInfo instanceof ExpandableListView.ExpandableListContextMenuInfo)) {
|
if (!(menuInfo instanceof ExpandableListView.ExpandableListContextMenuInfo)) {
|
||||||
Log.e(LOGTAG, "menuInfo is not ExpandableListContextMenuInfo");
|
Log.e(LOGTAG, "menuInfo is not ExpandableListContextMenuInfo");
|
||||||
return;
|
return;
|
||||||
|
@ -442,15 +426,31 @@ public class AwesomeBar extends Activity implements GeckoEventListener {
|
||||||
ExpandableListView exList = (ExpandableListView) list;
|
ExpandableListView exList = (ExpandableListView) list;
|
||||||
selectedItem = exList.getExpandableListAdapter().getChild(groupPosition, childPosition);
|
selectedItem = exList.getExpandableListAdapter().getChild(groupPosition, childPosition);
|
||||||
|
|
||||||
if (exList == findViewById(R.id.bookmarks_list)) {
|
// The history list is backed by a SimpleExpandableListAdapter
|
||||||
// The bookmarks list is backed by a SimpleCursorTreeAdapter
|
@SuppressWarnings("rawtypes")
|
||||||
Cursor cursor = (Cursor) selectedItem;
|
Map map = (Map) selectedItem;
|
||||||
title = cursor.getString(cursor.getColumnIndexOrThrow(URLColumns.TITLE));
|
title = (String) map.get(URLColumns.TITLE);
|
||||||
} else {
|
} else {
|
||||||
// The history list is backed by a SimpleExpandableListAdapter
|
if (!(menuInfo instanceof AdapterView.AdapterContextMenuInfo)) {
|
||||||
@SuppressWarnings("rawtypes")
|
Log.e(LOGTAG, "menuInfo is not AdapterContextMenuInfo");
|
||||||
Map map = (Map) selectedItem;
|
return;
|
||||||
title = (String) map.get(URLColumns.TITLE);
|
}
|
||||||
|
|
||||||
|
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
|
||||||
|
selectedItem = list.getItemAtPosition(info.position);
|
||||||
|
|
||||||
|
if (!(selectedItem instanceof Cursor)) {
|
||||||
|
Log.e(LOGTAG, "item at " + info.position + " is not a Cursor");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Cursor cursor = (Cursor) selectedItem;
|
||||||
|
title = cursor.getString(cursor.getColumnIndexOrThrow(URLColumns.TITLE));
|
||||||
|
|
||||||
|
// Don't show the context menu for folders
|
||||||
|
if (list == findViewById(R.id.bookmarks_list) &&
|
||||||
|
cursor.getInt(cursor.getColumnIndexOrThrow(Bookmarks.IS_FOLDER)) == 1) {
|
||||||
|
selectedItem = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче