1
1
package io .neurolab ;
2
2
3
3
import android .os .Bundle ;
4
+ import android .support .annotation .NonNull ;
4
5
import android .support .design .widget .FloatingActionButton ;
5
6
import android .support .design .widget .Snackbar ;
6
7
import android .view .View ;
@@ -20,10 +21,10 @@ public class MainActivity extends AppCompatActivity
20
21
protected void onCreate (Bundle savedInstanceState ) {
21
22
super .onCreate (savedInstanceState );
22
23
setContentView (R .layout .activity_main );
23
- Toolbar toolbar = ( Toolbar ) findViewById (R .id .toolbar );
24
+ Toolbar toolbar = findViewById (R .id .toolbar );
24
25
setSupportActionBar (toolbar );
25
26
26
- FloatingActionButton fab = ( FloatingActionButton ) findViewById (R .id .fab );
27
+ FloatingActionButton fab = findViewById (R .id .fab );
27
28
fab .setOnClickListener (new View .OnClickListener () {
28
29
@ Override
29
30
public void onClick (View view ) {
@@ -32,19 +33,19 @@ public void onClick(View view) {
32
33
}
33
34
});
34
35
35
- DrawerLayout drawer = ( DrawerLayout ) findViewById (R .id .drawer_layout );
36
+ DrawerLayout drawer = findViewById (R .id .drawer_layout );
36
37
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle (
37
38
this , drawer , toolbar , R .string .navigation_drawer_open , R .string .navigation_drawer_close );
38
39
drawer .addDrawerListener (toggle );
39
40
toggle .syncState ();
40
41
41
- NavigationView navigationView = ( NavigationView ) findViewById (R .id .nav_view );
42
+ NavigationView navigationView = findViewById (R .id .nav_view );
42
43
navigationView .setNavigationItemSelectedListener (this );
43
44
}
44
45
45
46
@ Override
46
47
public void onBackPressed () {
47
- DrawerLayout drawer = ( DrawerLayout ) findViewById (R .id .drawer_layout );
48
+ DrawerLayout drawer = findViewById (R .id .drawer_layout );
48
49
if (drawer .isDrawerOpen (GravityCompat .START )) {
49
50
drawer .closeDrawer (GravityCompat .START );
50
51
} else {
@@ -76,7 +77,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
76
77
77
78
@ SuppressWarnings ("StatementWithEmptyBody" )
78
79
@ Override
79
- public boolean onNavigationItemSelected (MenuItem item ) {
80
+ public boolean onNavigationItemSelected (@ NonNull MenuItem item ) {
80
81
// Handle navigation view item clicks here.
81
82
int id = item .getItemId ();
82
83
@@ -94,7 +95,7 @@ public boolean onNavigationItemSelected(MenuItem item) {
94
95
95
96
}
96
97
97
- DrawerLayout drawer = ( DrawerLayout ) findViewById (R .id .drawer_layout );
98
+ DrawerLayout drawer = findViewById (R .id .drawer_layout );
98
99
drawer .closeDrawer (GravityCompat .START );
99
100
return true ;
100
101
}
0 commit comments