]> git.ktnx.net Git - mobile-ledger.git/blob - app/src/main/java/net/ktnx/mobileledger/LatestTransactions.java
fdbbfaefa22f0bb2d61f922766a58b3d74dacdbe
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / LatestTransactions.java
1 package net.ktnx.mobileledger;
2
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;
15
16 public class LatestTransactions extends AppCompatActivity
17         implements NavigationView.OnNavigationItemSelectedListener {
18
19     @Override
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);
25
26         FloatingActionButton fab = findViewById(R.id.btn_add_transaction);
27         fab.setOnClickListener(new View.OnClickListener() {
28             @Override
29             public void onClick(View view) {
30                 Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
31                         .setAction("Action", null).show();
32             }
33         });
34
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);
39         toggle.syncState();
40
41         NavigationView navigationView = findViewById(R.id.nav_view);
42         navigationView.setNavigationItemSelectedListener(this);
43     }
44
45     @Override
46     public void onBackPressed() {
47         DrawerLayout drawer = findViewById(R.id.drawer_layout);
48         if (drawer.isDrawerOpen(GravityCompat.START)) {
49             drawer.closeDrawer(GravityCompat.START);
50         } else {
51             super.onBackPressed();
52         }
53     }
54
55     @Override
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);
59         return true;
60     }
61
62     @Override
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();
68
69         //noinspection SimplifiableIfStatement
70         if (id == R.id.action_settings) {
71             return true;
72         }
73
74         return super.onOptionsItemSelected(item);
75     }
76
77     @SuppressWarnings("StatementWithEmptyBody")
78     @Override
79     public boolean onNavigationItemSelected(MenuItem item) {
80         // Handle navigation view item clicks here.
81         int id = item.getItemId();
82
83         if (id == R.id.nav_latest_transactions) {
84             // Handle the camera action
85         } else if (id == R.id.nav_reports) {
86
87         } else if (id == R.id.nav_settings) {
88
89         } else if (id == R.id.nav_exit) {
90
91         }
92
93         DrawerLayout drawer = findViewById(R.id.drawer_layout);
94         drawer.closeDrawer(GravityCompat.START);
95         return true;
96     }
97 }