Skip to content

Commit

Permalink
Set display home as up enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
fasteque committed Feb 12, 2016
1 parent 28d6396 commit c38a3cd
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.os.Bundle;
import android.view.MenuItem;

import com.fastebro.android.rgbtool.model.events.PrintColorDetailsEvent;
import com.fastebro.androidrgbtool.R;
Expand All @@ -37,6 +38,10 @@ protected void onCreate(Bundle savedInstanceState) {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}

SectionsPagerAdapter sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
ViewPager viewPager = (ViewPager) findViewById(R.id.container);
viewPager.setAdapter(sectionsPagerAdapter);
Expand All @@ -53,6 +58,20 @@ protected void onCreate(Bundle savedInstanceState) {
}
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
finishAfterTransition();
} else {
finish();
}
return true;
} else {
return super.onOptionsItemSelected(item);
}
}

public void printColors() {
showPrintColorDialog(PrintJobDialogFragment.PRINT_COLOR_DETAILS_JOB);
}
Expand Down

0 comments on commit c38a3cd

Please sign in to comment.