1 package net.ktnx.mobileledger;
3 import android.os.Bundle;
4 import android.support.design.widget.FloatingActionButton;
5 import android.support.design.widget.NavigationView;
6 import android.support.design.widget.Snackbar;
7 import android.support.v4.view.GravityCompat;
8 import android.support.v4.widget.DrawerLayout;
9 import android.support.v7.app.ActionBarDrawerToggle;
10 import android.support.v7.app.AppCompatActivity;
11 import android.support.v7.widget.Toolbar;
12 import android.view.Menu;
13 import android.view.MenuItem;
14 import android.view.View;
16 public class LatestTransactions extends AppCompatActivity
17 implements NavigationView.OnNavigationItemSelectedListener {
20 protected void onCreate(Bundle savedInstanceState) {
21 super.onCreate(savedInstanceState);
22 setContentView(R.layout.activity_latest_transactions);
23 Toolbar toolbar = findViewById(R.id.toolbar);
24 setSupportActionBar(toolbar);
26 FloatingActionButton fab = findViewById(R.id.btn_add_transaction);
27 fab.setOnClickListener(new View.OnClickListener() {
29 public void onClick(View view) {
30 Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
31 .setAction("Action", null).show();
35 DrawerLayout drawer = findViewById(R.id.drawer_layout);
36 ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
37 this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
38 drawer.addDrawerListener(toggle);
41 NavigationView navigationView = findViewById(R.id.nav_view);
42 navigationView.setNavigationItemSelectedListener(this);
46 public void onBackPressed() {
47 DrawerLayout drawer = findViewById(R.id.drawer_layout);
48 if (drawer.isDrawerOpen(GravityCompat.START)) {
49 drawer.closeDrawer(GravityCompat.START);
51 super.onBackPressed();
56 public boolean onCreateOptionsMenu(Menu menu) {
57 // Inflate the menu; this adds items to the action bar if it is present.
58 getMenuInflater().inflate(R.menu.latest_transactions, menu);
63 public boolean onOptionsItemSelected(MenuItem item) {
64 // Handle action bar item clicks here. The action bar will
65 // automatically handle clicks on the Home/Up button, so long
66 // as you specify a parent activity in AndroidManifest.xml.
67 int id = item.getItemId();
69 //noinspection SimplifiableIfStatement
70 if (id == R.id.action_settings) {
74 return super.onOptionsItemSelected(item);
77 @SuppressWarnings("StatementWithEmptyBody")
79 public boolean onNavigationItemSelected(MenuItem item) {
80 // Handle navigation view item clicks here.
81 int id = item.getItemId();
83 if (id == R.id.nav_latest_transactions) {
84 // Handle the camera action
85 } else if (id == R.id.nav_reports) {
87 } else if (id == R.id.nav_settings) {
89 } else if (id == R.id.nav_exit) {
93 DrawerLayout drawer = findViewById(R.id.drawer_layout);
94 drawer.closeDrawer(GravityCompat.START);