BlocksActivity.java 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* Copyright 2017 Andrew Dawson
  2. *
  3. * This file is a part of Tusky.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it under the terms of the
  6. * GNU General Public License as published by the Free Software Foundation; either version 3 of the
  7. * License, or (at your option) any later version.
  8. *
  9. * Tusky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
  10. * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  11. * Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along with Tusky; if not,
  14. * see <http://www.gnu.org/licenses>. */
  15. package com.keylesspalace.tusky;
  16. import android.os.Bundle;
  17. import android.support.annotation.Nullable;
  18. import android.support.v4.app.Fragment;
  19. import android.support.v4.app.FragmentTransaction;
  20. import android.support.v7.app.ActionBar;
  21. import android.support.v7.widget.Toolbar;
  22. import android.view.MenuItem;
  23. public class BlocksActivity extends BaseActivity {
  24. @Override
  25. protected void onCreate(@Nullable Bundle savedInstanceState) {
  26. super.onCreate(savedInstanceState);
  27. setContentView(R.layout.activity_blocks);
  28. Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  29. setSupportActionBar(toolbar);
  30. ActionBar bar = getSupportActionBar();
  31. if (bar != null) {
  32. bar.setTitle(getString(R.string.title_blocks));
  33. bar.setDisplayHomeAsUpEnabled(true);
  34. bar.setDisplayShowHomeEnabled(true);
  35. }
  36. FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
  37. Fragment fragment = AccountFragment.newInstance(AccountFragment.Type.BLOCKS);
  38. fragmentTransaction.add(R.id.fragment_container, fragment);
  39. fragmentTransaction.commit();
  40. }
  41. @Override
  42. public boolean onOptionsItemSelected(MenuItem item) {
  43. switch (item.getItemId()) {
  44. case android.R.id.home: {
  45. onBackPressed();
  46. return true;
  47. }
  48. }
  49. return super.onOptionsItemSelected(item);
  50. }
  51. }