Commit 2e90cead authored by Sajal Narang's avatar Sajal Narang

Fetch fresh notifications before showing

parent 987407ef
...@@ -52,6 +52,7 @@ public class MainActivity extends AppCompatActivity ...@@ -52,6 +52,7 @@ public class MainActivity extends AppCompatActivity
private static final String TAG = "MainActivity"; private static final String TAG = "MainActivity";
SessionManager session; SessionManager session;
NotificationsResponse notificationsResponse; NotificationsResponse notificationsResponse;
private boolean showNotifications = false;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -83,6 +84,10 @@ public class MainActivity extends AppCompatActivity ...@@ -83,6 +84,10 @@ public class MainActivity extends AppCompatActivity
public void onResponse(Call<NotificationsResponse> call, Response<NotificationsResponse> response) { public void onResponse(Call<NotificationsResponse> call, Response<NotificationsResponse> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
notificationsResponse = response.body(); notificationsResponse = response.body();
if (showNotifications) {
showNotifications();
showNotifications = false;
}
} }
//Server Error //Server Error
} }
...@@ -130,11 +135,10 @@ public class MainActivity extends AppCompatActivity ...@@ -130,11 +135,10 @@ public class MainActivity extends AppCompatActivity
//noinspection SimplifiableIfStatement //noinspection SimplifiableIfStatement
if (id == R.id.action_notifications) { if (id == R.id.action_notifications) {
showNotifications = true;
fetchNotifications(); fetchNotifications();
showNotifications();
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
......
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