Close right drawer when home is pressed

possible use cases:
- open left drawer
- close left drawer
- navigate up (show map)
In each case, the right drawer should be closed.
If the left drawer is to be opened, this fixes a bug where both drawers would overlap for a second. (Because the right drawer would not be closed until onDrawerOpened has fired)
This commit is contained in:
fkloft 2013-09-25 15:38:33 +02:00
parent 5f0ec3b581
commit 533057be56

View File

@ -12,6 +12,7 @@ import android.preference.PreferenceManager;
import android.support.v4.app.ActionBarDrawerToggle; import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.widget.DrawerLayout; import android.support.v4.widget.DrawerLayout;
import android.text.Html; import android.text.Html;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView; import android.widget.AdapterView;
@ -296,6 +297,14 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt
mDrawerLayout.closeDrawer(mDrawerLeft); mDrawerLayout.closeDrawer(mDrawerLeft);
} }
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home)
mDrawerLayout.closeDrawer(mDrawerRight);
return super.onOptionsItemSelected(item);
}
public void onPostCreate(Bundle savedInstanceState) { public void onPostCreate(Bundle savedInstanceState) {
// Sync the toggle state after onRestoreInstanceState has occurred. // Sync the toggle state after onRestoreInstanceState has occurred.
syncState(); syncState();