-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomepage.java
More file actions
185 lines (150 loc) · 6.28 KB
/
Copy pathHomepage.java
File metadata and controls
185 lines (150 loc) · 6.28 KB
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
package com.example.loginpage;
import android.app.NotificationManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.Uri;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.RequiresApi;
import android.support.design.widget.BottomNavigationView;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
import com.example.loginpage.Home.Homefragment;
import com.example.loginpage.ChatFiles.Chatfragment;
import com.example.loginpage.loginactivity.Login2;
import com.google.firebase.auth.FirebaseAuth;
public class Homepage extends AppCompatActivity {
private static final int nid = 16;
private static int otp = 0;
NotificationManager notify;
FirebaseAuth auth;
BottomNavigationView bottomNavigationView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_homepage);
bottomNavigationView = findViewById(R.id.bottomnvtbar);
bottomNavigationView.setOnNavigationItemSelectedListener(listener);
auth = FirebaseAuth.getInstance();
Mynavigation mynavigation = new Mynavigation(getSupportFragmentManager());
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new Homefragment()).commit();
notify = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
isOnline();
}
BottomNavigationView.OnNavigationItemSelectedListener listener = new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
Fragment selectedFragment = null;
switch (menuItem.getItemId()) {
case R.id.nav_chat:
selectedFragment = new Chatfragment();
break;
case R.id.nav_home:
selectedFragment = new Homefragment();
break;
}
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, selectedFragment).commit();
return true;
}
};
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menuitems, menu);
return true;
}
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.aboutus:
Intent intent = new Intent(this, AboutUs.class);
startActivity(intent);
break;
case R.id.share:
Toast.makeText(this, "Share Clicked", Toast.LENGTH_SHORT).show();
Uri uri = Uri.parse("https://drive.google.com/open?id=1-okrysggXpna1iItNxpJtHIYYO0BrfNv");
Intent i2 = new Intent(Intent.ACTION_VIEW, uri);
if (i2.resolveActivity(getPackageManager()) != null) {
startActivity(i2);
} else {
Toast.makeText(this, "Sorry can'handle intent", Toast.LENGTH_SHORT).show();
}
break;
case R.id.logout:
alertDialogue();
break;
case R.id.mfeedback:
Intent i1 = new Intent(Homepage.this, Feedback.class);
startActivity(i1);
break;
case R.id.profile:
Intent intent7 = new Intent(this, Profilepage.class);
startActivity(intent7);
break;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onBackPressed() {
super.onBackPressed();
moveTaskToBack(true);
}
public void isOnline() {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
android.net.NetworkInfo wifi = cm
.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
android.net.NetworkInfo datac = cm
.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
if ((wifi != null & datac != null)
&& (wifi.isConnected() | datac.isConnected())) {
Toast.makeText(this, "Internet Connected", Toast.LENGTH_SHORT).show();
} else {
//no connection
Toast.makeText(Homepage.this, "No Internet Connection", Toast.LENGTH_LONG).show();
}
}
public void alertDialogue() {
final AlertDialog.Builder builder = new AlertDialog.Builder(Homepage.this);
builder.setTitle("Logout");
builder.setMessage("Do you want to Logout?");
builder.setIcon(R.drawable.ic_exit_to_app_black_24dp);
builder.setPositiveButton("confirm", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
auth.signOut();
Intent intent = new Intent(Homepage.this, Login2.class);
startActivity(intent);
Toast.makeText(Homepage.this, "Logged Out Successfully!!!", Toast.LENGTH_SHORT).show();
}
});
builder.setNegativeButton("deneid", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
builder.show();
}
public class Mynavigation extends FragmentPagerAdapter {
public Mynavigation(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int i) {
return null;
}
@Override
public int getCount() {
return 0;
}
}
}