ViewTagActivity.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. import butterknife.BindView;
  24. import butterknife.ButterKnife;
  25. public class ViewTagActivity extends BaseActivity {
  26. @BindView(R.id.toolbar) Toolbar toolbar;
  27. @Override
  28. protected void onCreate(@Nullable Bundle savedInstanceState) {
  29. super.onCreate(savedInstanceState);
  30. setContentView(R.layout.activity_view_tag);
  31. ButterKnife.bind(this);
  32. String hashtag = getIntent().getStringExtra("hashtag");
  33. setSupportActionBar(toolbar);
  34. ActionBar bar = getSupportActionBar();
  35. if (bar != null) {
  36. bar.setTitle(String.format(getString(R.string.title_tag), hashtag));
  37. bar.setDisplayHomeAsUpEnabled(true);
  38. bar.setDisplayShowHomeEnabled(true);
  39. }
  40. FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
  41. Fragment fragment = TimelineFragment.newInstance(TimelineFragment.Kind.TAG, hashtag);
  42. fragmentTransaction.add(R.id.fragment_container, fragment);
  43. fragmentTransaction.commit();
  44. }
  45. @Override
  46. public boolean onOptionsItemSelected(MenuItem item) {
  47. switch (item.getItemId()) {
  48. case android.R.id.home: {
  49. onBackPressed();
  50. return true;
  51. }
  52. }
  53. return super.onOptionsItemSelected(item);
  54. }
  55. }