Index: platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerActivity.java |
diff --git a/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerActivity.java b/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerActivity.java |
index 0291f5e29145bcfd76d5f7c58ce0819763c8b2ea..ea610397b99ec550ff7118eee924ee1862632df5 100644 |
--- a/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerActivity.java |
+++ b/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerActivity.java |
@@ -52,7 +52,7 @@ public class ViewerActivity |
public boolean onOptionsItemSelected(MenuItem item) { |
// Pass the event to ActionBarDrawerToggle, if it returns |
// true, then it has handled the app icon touch event |
- if (mDrawerToggle.onOptionsItemSelected(item)) { |
+ if (mDrawerToggle != null && mDrawerToggle.onOptionsItemSelected(item)) { |
return true; |
} |
@@ -78,11 +78,13 @@ public class ViewerActivity |
surfaceView.setOnTouchListener(this); |
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout); |
- mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, |
- R.string.drawer_open, R.string.drawer_close); |
- mDrawerLayout.addDrawerListener(mDrawerToggle); |
- getActionBar().setDisplayHomeAsUpEnabled(true); |
- getActionBar().setHomeButtonEnabled(true); |
+ if (mDrawerLayout != null) { // xlarge-land has no drawer layout (drawer is always open) |
+ mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, |
+ R.string.drawer_open, R.string.drawer_close); |
+ mDrawerLayout.addDrawerListener(mDrawerToggle); |
+ getActionBar().setDisplayHomeAsUpEnabled(true); |
+ getActionBar().setHomeButtonEnabled(true); |
+ } |
mDrawerList = (ListView) findViewById(R.id.leftDrawer); |
mStateAdapter = new StateAdapter(this); |
@@ -95,13 +97,17 @@ public class ViewerActivity |
@Override |
protected void onPostCreate(Bundle savedInstanceState) { |
super.onPostCreate(savedInstanceState); |
- mDrawerToggle.syncState(); |
+ if (mDrawerToggle != null) { |
+ mDrawerToggle.syncState(); |
+ } |
} |
@Override |
public void onConfigurationChanged(Configuration newConfig) { |
super.onConfigurationChanged(newConfig); |
- mDrawerToggle.onConfigurationChanged(newConfig); |
+ if (mDrawerToggle != null) { |
+ mDrawerToggle.onConfigurationChanged(newConfig); |
+ } |
} |
@Override |