зеркало из 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
|
@Override
|
||||||
public Object instantiateItem(ViewGroup group, int index) {
|
public Object instantiateItem(ViewGroup group, int index) {
|
||||||
AwesomeBarTab tab = mTabs[index];
|
AwesomeBarTab tab = mTabs[index];
|
||||||
|
tab.setListTouchListener(mListTouchListener);
|
||||||
group.addView(tab.getView());
|
group.addView(tab.getView());
|
||||||
return tab;
|
return tab;
|
||||||
}
|
}
|
||||||
|
@ -64,6 +65,7 @@ public class AwesomeBarTabs extends TabHost
|
||||||
public void destroyItem(ViewGroup group, int index, Object obj) {
|
public void destroyItem(ViewGroup group, int index, Object obj) {
|
||||||
AwesomeBarTab tab = (AwesomeBarTab)obj;
|
AwesomeBarTab tab = (AwesomeBarTab)obj;
|
||||||
group.removeView(tab.getView());
|
group.removeView(tab.getView());
|
||||||
|
tab.onDestroyView();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -170,7 +172,6 @@ public class AwesomeBarTabs extends TabHost
|
||||||
});
|
});
|
||||||
|
|
||||||
for (int i = 0; i < mTabs.length; i++) {
|
for (int i = 0; i < mTabs.length; i++) {
|
||||||
mTabs[i].setListTouchListener(mListTouchListener);
|
|
||||||
addAwesomeTab(mTabs[i].getTag(),
|
addAwesomeTab(mTabs[i].getTag(),
|
||||||
mTabs[i].getTitleStringId(),
|
mTabs[i].getTitleStringId(),
|
||||||
i);
|
i);
|
||||||
|
@ -296,6 +297,7 @@ public class AwesomeBarTabs extends TabHost
|
||||||
|
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
for (AwesomeBarTab tab : mTabs) {
|
for (AwesomeBarTab tab : mTabs) {
|
||||||
|
tab.onDestroyView();
|
||||||
tab.destroy();
|
tab.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,6 +140,9 @@ public class AllPagesTab extends AwesomeBarTab implements GeckoEventListener {
|
||||||
AwesomeBarCursorAdapter adapter = getCursorAdapter();
|
AwesomeBarCursorAdapter adapter = getCursorAdapter();
|
||||||
list.setAdapter(adapter);
|
list.setAdapter(adapter);
|
||||||
list.setOnTouchListener(mListListener);
|
list.setOnTouchListener(mListListener);
|
||||||
|
|
||||||
|
// Call filter to kick off a db query and create a cursor
|
||||||
|
adapter.filter("");
|
||||||
}
|
}
|
||||||
|
|
||||||
return mView;
|
return mView;
|
||||||
|
@ -147,19 +150,27 @@ public class AllPagesTab extends AwesomeBarTab implements GeckoEventListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() {
|
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_UPDATE_FAVICONS);
|
||||||
mHandler.removeMessages(MESSAGE_LOAD_FAVICONS);
|
mHandler.removeMessages(MESSAGE_LOAD_FAVICONS);
|
||||||
mHandler = null;
|
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) {
|
public void filter(String searchTerm) {
|
||||||
|
|
|
@ -26,7 +26,6 @@ import android.widget.TextView;
|
||||||
abstract public class AwesomeBarTab {
|
abstract public class AwesomeBarTab {
|
||||||
abstract public String getTag();
|
abstract public String getTag();
|
||||||
abstract public int getTitleStringId();
|
abstract public int getTitleStringId();
|
||||||
abstract public void destroy();
|
|
||||||
abstract public boolean onBackPressed();
|
abstract public boolean onBackPressed();
|
||||||
abstract public ContextMenuSubject getSubject(ContextMenu menu, View view, ContextMenuInfo menuInfo);
|
abstract public ContextMenuSubject getSubject(ContextMenu menu, View view, ContextMenuInfo menuInfo);
|
||||||
abstract public View getView();
|
abstract public View getView();
|
||||||
|
@ -139,4 +138,10 @@ abstract public class AwesomeBarTab {
|
||||||
|
|
||||||
return imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
return imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onDestroyView() {
|
||||||
|
mView = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void destroy() { }
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,8 @@ public class BookmarksTab extends AwesomeBarTab {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() {
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
BookmarksListAdapter adapter = getCursorAdapter();
|
BookmarksListAdapter adapter = getCursorAdapter();
|
||||||
if (adapter == null) {
|
if (adapter == null) {
|
||||||
return;
|
return;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче