-
Notifications
You must be signed in to change notification settings - Fork 21
/
BaseActivity.java
102 lines (92 loc) · 4.05 KB
/
BaseActivity.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package com.bdp.onroad;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.inputmethod.EditorInfo;
import android.widget.AutoCompleteTextView;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.bdp.onroad.LoginActivity;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
public class BaseActivity extends AppCompatActivity {
protected DrawerLayout dl;
private ActionBarDrawerToggle t;
private NavigationView nv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
// setContentView(R.layout.base_layout);
setContentView(R.layout.activity_base);
dl = (DrawerLayout) findViewById(R.id.activity_base);
t = new ActionBarDrawerToggle(this, dl, R.string.app_name, R.string.about_us);
dl.addDrawerListener(t);
t.syncState();
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
nv = (NavigationView) findViewById(R.id.nv);
nv.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
int id = item.getItemId();
switch (id) {
case R.id.nav_home:
Intent I = new Intent(BaseActivity.this, UserTypeActivity.class);
startActivity(I);
finish();
break;
case R.id.nav_aboutUs:
Toast.makeText(BaseActivity.this, "About Us", Toast.LENGTH_SHORT).show();
break;
case R.id.nav_profile:
Toast.makeText(BaseActivity.this, "Profile", Toast.LENGTH_SHORT).show();
break;
case R.id.nav_rides:
startActivity(new Intent(BaseActivity.this, activity_HikeSearch.class));
finish();
break;
case R.id.nav_ridereqs:
startActivity(new Intent(BaseActivity.this, UserDriverActivity.class));
finish();
break;
case R.id.nav_logout:
FirebaseAuth.getInstance().signOut();
startActivity(new Intent(BaseActivity.this, LoginActivity.class));
finish();
Toast.makeText(BaseActivity.this, "Logged You Out", Toast.LENGTH_SHORT).show();
break;
case R.id.nav_cancelRides:
Toast.makeText(BaseActivity.this, "Cancelling Rides", Toast.LENGTH_SHORT).show();
startActivity(new Intent(BaseActivity.this, cancelRides.class));
finish();
break;
default:
return true;
}
return true;
}
});
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (t.onOptionsItemSelected(item))
return true;
return super.onOptionsItemSelected(item);
}
}