2 * Copyright © 2019 Damyan Ivanov.
3 * This file is part of Mobile-Ledger.
4 * Mobile-Ledger is free software: you can distribute it and/or modify it
5 * under the term of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your opinion), any later version.
9 * Mobile-Ledger is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License terms for details.
14 * You should have received a copy of the GNU General Public License
15 * along with Mobile-Ledger. If not, see <https://www.gnu.org/licenses/>.
18 package net.ktnx.mobileledger.ui.profiles;
20 import android.content.Intent;
21 import android.os.Bundle;
22 import android.support.design.widget.FloatingActionButton;
23 import android.support.design.widget.Snackbar;
24 import android.support.v7.widget.Toolbar;
25 import android.view.View;
26 import android.support.v7.app.AppCompatActivity;
27 import android.support.v7.app.ActionBar;
28 import android.view.MenuItem;
30 import net.ktnx.mobileledger.R;
31 import net.ktnx.mobileledger.ui.activity.ProfileListActivity;
34 * An activity representing a single Profile detail screen. This
35 * activity is only used on narrow width devices. On tablet-size devices,
36 * item details are presented side-by-side with a list of items
37 * in a {@link ProfileListActivity}.
39 public class ProfileDetailActivity extends AppCompatActivity {
42 protected void onCreate(Bundle savedInstanceState) {
43 super.onCreate(savedInstanceState);
44 setContentView(R.layout.activity_profile_detail);
45 Toolbar toolbar = (Toolbar) findViewById(R.id.detail_toolbar);
46 setSupportActionBar(toolbar);
48 FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
49 fab.setOnClickListener(new View.OnClickListener() {
51 public void onClick(View view) {
52 Snackbar.make(view, "Replace with your own detail action", Snackbar.LENGTH_LONG)
53 .setAction("Action", null).show();
57 // Show the Up button in the action bar.
58 ActionBar actionBar = getSupportActionBar();
59 if (actionBar != null) {
60 actionBar.setDisplayHomeAsUpEnabled(true);
63 // savedInstanceState is non-null when there is fragment state
64 // saved from previous configurations of this activity
65 // (e.g. when rotating the screen from portrait to landscape).
66 // In this case, the fragment will automatically be re-added
67 // to its container so we don't need to manually add it.
68 // For more information, see the Fragments API guide at:
70 // http://developer.android.com/guide/components/fragments.html
72 if (savedInstanceState == null) {
73 // Create the detail fragment and add it to the activity
74 // using a fragment transaction.
75 Bundle arguments = new Bundle();
76 arguments.putString(ProfileDetailFragment.ARG_ITEM_ID,
77 getIntent().getStringExtra(ProfileDetailFragment.ARG_ITEM_ID));
78 ProfileDetailFragment fragment = new ProfileDetailFragment();
79 fragment.setArguments(arguments);
80 getSupportFragmentManager().beginTransaction()
81 .add(R.id.profile_detail_container, fragment).commit();
86 public boolean onOptionsItemSelected(MenuItem item) {
87 int id = item.getItemId();
88 if (id == android.R.id.home) {
89 // This ID represents the Home or Up button. In the case of this
90 // activity, the Up button is shown. For
91 // more details, see the Navigation pattern on Android Design:
93 // http://developer.android.com/design/patterns/navigation.html#up-vs-back
95 navigateUpTo(new Intent(this, ProfileListActivity.class));
98 return super.onOptionsItemSelected(item);