Commit 987407ef authored by Sajal Narang's avatar Sajal Narang

Launch NotificationsFragment through main menu

parent e02df0a9
......@@ -51,6 +51,7 @@ public class MainActivity extends AppCompatActivity
private static final String TAG = "MainActivity";
SessionManager session;
NotificationsResponse notificationsResponse;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -81,14 +82,7 @@ public class MainActivity extends AppCompatActivity
@Override
public void onResponse(Call<NotificationsResponse> call, Response<NotificationsResponse> response) {
if (response.isSuccessful()) {
NotificationsResponse notificationsResponse = response.body();
String notificationsResponseJson = new Gson().toJson(notificationsResponse);
Bundle bundle = new Bundle();
bundle.putString(Constants.NOTIFICATIONS_RESPONSE_JSON, notificationsResponseJson);
NotificationsFragment notificationsFragment = new NotificationsFragment();
notificationsFragment.setArguments(bundle);
updateFragment(notificationsFragment);
notificationsResponse = response.body();
}
//Server Error
}
......@@ -100,6 +94,15 @@ public class MainActivity extends AppCompatActivity
});
}
public void showNotifications() {
String notificationsResponseJson = new Gson().toJson(notificationsResponse);
Bundle bundle = new Bundle();
bundle.putString(Constants.NOTIFICATIONS_RESPONSE_JSON, notificationsResponseJson);
NotificationsFragment notificationsFragment = new NotificationsFragment();
notificationsFragment.setArguments(bundle);
updateFragment(notificationsFragment);
}
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
......@@ -126,7 +129,9 @@ public class MainActivity extends AppCompatActivity
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
if (id == R.id.action_notifications) {
fetchNotifications();
showNotifications();
return true;
}
......@@ -176,11 +181,8 @@ public class MainActivity extends AppCompatActivity
if (ContextCompat.checkSelfPermission(MainActivity.this,
Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {
} else
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 0);
break;
case R.id.nav_contacts:
......
......@@ -7,10 +7,4 @@
android:icon="@drawable/ic_notifications_black_24dp"
android:title="Notifications"
app:showAsAction="always" />
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:title="@string/action_settings"
app:showAsAction="never" />
</menu>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment