attempt at better reverse navigation

This commit is contained in:
Andrew Dolgov 2013-05-28 19:59:33 +04:00
parent ee687410d8
commit 8c923e309f
2 changed files with 23 additions and 12 deletions

View File

@ -73,10 +73,11 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
public void onOpened() { public void onOpened() {
if (m_actionbarRevertDepth == 0) { if (m_actionbarRevertDepth == 0) {
m_actionbarUpEnabled = false; m_actionbarUpEnabled = false;
m_feedIsSelected = false;
getSupportActionBar().setDisplayHomeAsUpEnabled(false); getSupportActionBar().setDisplayHomeAsUpEnabled(false);
initMenu();
} }
m_feedIsSelected = false;
initMenu();
} }
}); });
} }
@ -256,11 +257,15 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
public void onBackPressed() { public void onBackPressed() {
if (m_actionbarRevertDepth > 0) { if (m_actionbarRevertDepth > 0) {
if (m_feedIsSelected && m_slidingMenu != null && !m_slidingMenu.isMenuShowing()) {
m_slidingMenu.showMenu();
} else {
m_actionbarRevertDepth = m_actionbarRevertDepth - 1; m_actionbarRevertDepth = m_actionbarRevertDepth - 1;
m_actionbarUpEnabled = m_actionbarRevertDepth > 0; m_actionbarUpEnabled = m_actionbarRevertDepth > 0;
getSupportActionBar().setDisplayHomeAsUpEnabled(m_actionbarUpEnabled); getSupportActionBar().setDisplayHomeAsUpEnabled(m_actionbarUpEnabled);
onBackPressed(); onBackPressed();
}
} else if (m_slidingMenu != null && !m_slidingMenu.isMenuShowing()) { } else if (m_slidingMenu != null && !m_slidingMenu.isMenuShowing()) {
m_slidingMenu.showMenu(); m_slidingMenu.showMenu();
} else { } else {
@ -272,6 +277,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
case android.R.id.home: case android.R.id.home:
if (m_actionbarUpEnabled)
onBackPressed(); onBackPressed();
return true; return true;
case R.id.show_feeds: case R.id.show_feeds:

View File

@ -129,11 +129,15 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
public void onBackPressed() { public void onBackPressed() {
if (m_actionbarRevertDepth > 0) { if (m_actionbarRevertDepth > 0) {
if (m_feedIsSelected && m_slidingMenu != null && !m_slidingMenu.isMenuShowing()) {
m_slidingMenu.showMenu();
} else {
m_actionbarRevertDepth = m_actionbarRevertDepth - 1; m_actionbarRevertDepth = m_actionbarRevertDepth - 1;
m_actionbarUpEnabled = m_actionbarRevertDepth > 0; m_actionbarUpEnabled = m_actionbarRevertDepth > 0;
getSupportActionBar().setDisplayHomeAsUpEnabled(m_actionbarUpEnabled); getSupportActionBar().setDisplayHomeAsUpEnabled(m_actionbarUpEnabled);
onBackPressed(); onBackPressed();
}
} else if (m_slidingMenu != null && !m_slidingMenu.isMenuShowing()) { } else if (m_slidingMenu != null && !m_slidingMenu.isMenuShowing()) {
m_slidingMenu.showMenu(); m_slidingMenu.showMenu();
} else { } else {
@ -145,6 +149,7 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
case android.R.id.home: case android.R.id.home:
if (m_actionbarUpEnabled)
onBackPressed(); onBackPressed();
return true; return true;
case R.id.show_feeds: case R.id.show_feeds: