Commit a0a4dcac authored by Varun Patil's avatar Varun Patil

Refactor MainActivity to use EmptyCallback

parent bd840c83
...@@ -171,7 +171,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -171,7 +171,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
private void fetchNotifications() { private void fetchNotifications() {
RetrofitInterface retrofitInterface = getRetrofitInterface(); RetrofitInterface retrofitInterface = getRetrofitInterface();
retrofitInterface.getNotifications(getSessionIDHeader()).enqueue(new Callback<List<Notification>>() { retrofitInterface.getNotifications(getSessionIDHeader()).enqueue(new EmptyCallback<List<Notification>>() {
@Override @Override
public void onResponse(Call<List<Notification>> call, Response<List<Notification>> response) { public void onResponse(Call<List<Notification>> call, Response<List<Notification>> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
...@@ -183,10 +183,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -183,10 +183,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
} }
} }
} }
@Override
public void onFailure(Call<List<Notification>> call, Throwable t) {
}
}); });
} }
...@@ -347,7 +343,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -347,7 +343,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
/** Open the event fragment from the provided id */ /** Open the event fragment from the provided id */
private void openEventFragment(String id) { private void openEventFragment(String id) {
RetrofitInterface retrofitInterface = getRetrofitInterface(); RetrofitInterface retrofitInterface = getRetrofitInterface();
retrofitInterface.getEvent(getSessionIDHeader(), id).enqueue(new Callback<Event>() { retrofitInterface.getEvent(getSessionIDHeader(), id).enqueue(new EmptyCallback<Event>() {
@Override @Override
public void onResponse(Call<Event> call, Response<Event> response) { public void onResponse(Call<Event> call, Response<Event> response) {
EventFragment eventFragment = new EventFragment(); EventFragment eventFragment = new EventFragment();
...@@ -356,9 +352,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -356,9 +352,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
eventFragment.setArguments(bundle); eventFragment.setArguments(bundle);
updateFragment(eventFragment); updateFragment(eventFragment);
} }
@Override
public void onFailure(Call<Event> call, Throwable t) {}
}); });
} }
...@@ -408,7 +401,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -408,7 +401,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
final String fcmId = instanceIdResult.getToken(); final String fcmId = instanceIdResult.getToken();
RetrofitInterface retrofitInterface = getRetrofitInterface(); RetrofitInterface retrofitInterface = getRetrofitInterface();
retrofitInterface.patchUserMe(getSessionIDHeader(), new UserFCMPatchRequest(fcmId, getCurrentVersion())).enqueue(new Callback<User>() { retrofitInterface.patchUserMe(getSessionIDHeader(), new UserFCMPatchRequest(fcmId, getCurrentVersion())).enqueue(new EmptyCallback<User>() {
@Override @Override
public void onResponse(Call<User> call, Response<User> response) { public void onResponse(Call<User> call, Response<User> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
...@@ -420,9 +413,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -420,9 +413,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
Toast.makeText(MainActivity.this, "Your session has expired!", Toast.LENGTH_LONG).show(); Toast.makeText(MainActivity.this, "Your session has expired!", Toast.LENGTH_LONG).show();
} }
} }
@Override
public void onFailure(Call<User> call, Throwable t) {}
}); });
} }
}); });
......
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