Skip to content

Commit

Permalink
prevent crashes on tablets (how did I not notice this help)
Browse files Browse the repository at this point in the history
  • Loading branch information
fennifith committed Jun 28, 2016
1 parent 90c7819 commit d0af39e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions app/src/main/java/pasta/streamer/activities/HomeActivity.java
Expand Up @@ -141,8 +141,10 @@ public void onCreate(Bundle savedInstanceState) {
}

setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.drawer_toggle);
if (drawer_layout != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.drawer_toggle);
}

if (content != null) {
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
Expand Down Expand Up @@ -330,6 +332,8 @@ public void onAnimationUpdate(ValueAnimator animation) {
} else if (getIntent().getStringExtra("query") != null) {
f = new SearchFragment();
getSupportFragmentManager().beginTransaction().add(R.id.fragment, f).commit();

getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setDrawerEnabled(false);

search(getIntent().getStringExtra("query"), true);
Expand Down Expand Up @@ -360,7 +364,8 @@ public void setDrawerEnabled(boolean enabled) {
if (drawer_layout != null)
drawer_layout.setDrawerLockMode(enabled ? DrawerLayout.LOCK_MODE_UNLOCKED : DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
drawer_container.setVisibility(enabled ? View.VISIBLE : View.GONE);
getSupportActionBar().setHomeAsUpIndicator(enabled ? R.drawable.drawer_toggle : R.drawable.drawer_back);
if (drawer_layout != null || !enabled)
getSupportActionBar().setHomeAsUpIndicator(enabled ? R.drawable.drawer_toggle : R.drawable.drawer_back);
}

public void setListeners(Fragment f) {
Expand Down Expand Up @@ -670,8 +675,6 @@ protected void done(@Nullable AlbumListData result) {
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_home, menu);

if (drawer_layout == null) menu.findItem(android.R.id.home).setVisible(false);

SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.action_search));

searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
Expand Down

0 comments on commit d0af39e

Please sign in to comment.