зеркало из https://github.com/mozilla/gecko-dev.git
Bug 817586 - Destory awesomebar views when switching panes. r=lucasr
This commit is contained in:
Родитель
87c6119c08
Коммит
f5c9e21b7f
|
@ -56,6 +56,7 @@ public class AwesomeBarTabs extends TabHost
|
|||
@Override
|
||||
public Object instantiateItem(ViewGroup group, int index) {
|
||||
AwesomeBarTab tab = mTabs[index];
|
||||
tab.setListTouchListener(mListTouchListener);
|
||||
group.addView(tab.getView());
|
||||
return tab;
|
||||
}
|
||||
|
@ -64,6 +65,7 @@ public class AwesomeBarTabs extends TabHost
|
|||
public void destroyItem(ViewGroup group, int index, Object obj) {
|
||||
AwesomeBarTab tab = (AwesomeBarTab)obj;
|
||||
group.removeView(tab.getView());
|
||||
tab.onDestroyView();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -170,7 +172,6 @@ public class AwesomeBarTabs extends TabHost
|
|||
});
|
||||
|
||||
for (int i = 0; i < mTabs.length; i++) {
|
||||
mTabs[i].setListTouchListener(mListTouchListener);
|
||||
addAwesomeTab(mTabs[i].getTag(),
|
||||
mTabs[i].getTitleStringId(),
|
||||
i);
|
||||
|
@ -296,6 +297,7 @@ public class AwesomeBarTabs extends TabHost
|
|||
|
||||
public void destroy() {
|
||||
for (AwesomeBarTab tab : mTabs) {
|
||||
tab.onDestroyView();
|
||||
tab.destroy();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -140,6 +140,9 @@ public class AllPagesTab extends AwesomeBarTab implements GeckoEventListener {
|
|||
AwesomeBarCursorAdapter adapter = getCursorAdapter();
|
||||
list.setAdapter(adapter);
|
||||
list.setOnTouchListener(mListListener);
|
||||
|
||||
// Call filter to kick off a db query and create a cursor
|
||||
adapter.filter("");
|
||||
}
|
||||
|
||||
return mView;
|
||||
|
@ -147,19 +150,27 @@ public class AllPagesTab extends AwesomeBarTab implements GeckoEventListener {
|
|||
|
||||
@Override
|
||||
public void destroy() {
|
||||
AwesomeBarCursorAdapter adapter = getCursorAdapter();
|
||||
unregisterEventListener("SearchEngines:Data");
|
||||
if (adapter == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Cursor cursor = adapter.getCursor();
|
||||
if (cursor != null)
|
||||
cursor.close();
|
||||
|
||||
mHandler.removeMessages(MESSAGE_UPDATE_FAVICONS);
|
||||
mHandler.removeMessages(MESSAGE_LOAD_FAVICONS);
|
||||
mHandler = null;
|
||||
|
||||
unregisterEventListener("SearchEngines:Data");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
|
||||
mListView = null;
|
||||
if (mCursorAdapter == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Cursor cursor = mCursorAdapter.getCursor();
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
mCursorAdapter = null;
|
||||
}
|
||||
|
||||
public void filter(String searchTerm) {
|
||||
|
|
|
@ -26,7 +26,6 @@ import android.widget.TextView;
|
|||
abstract public class AwesomeBarTab {
|
||||
abstract public String getTag();
|
||||
abstract public int getTitleStringId();
|
||||
abstract public void destroy();
|
||||
abstract public boolean onBackPressed();
|
||||
abstract public ContextMenuSubject getSubject(ContextMenu menu, View view, ContextMenuInfo menuInfo);
|
||||
abstract public View getView();
|
||||
|
@ -139,4 +138,10 @@ abstract public class AwesomeBarTab {
|
|||
|
||||
return imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||
}
|
||||
|
||||
public void onDestroyView() {
|
||||
mView = null;
|
||||
}
|
||||
|
||||
public void destroy() { }
|
||||
}
|
||||
|
|
|
@ -92,7 +92,8 @@ public class BookmarksTab extends AwesomeBarTab {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
BookmarksListAdapter adapter = getCursorAdapter();
|
||||
if (adapter == null) {
|
||||
return;
|
||||
|
|
Загрузка…
Ссылка в новой задаче