1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-08 07:57:28 +00:00

Uncomment code, which was commented for testing

This commit is contained in:
Ammar Githam 2021-03-15 22:53:28 +09:00
parent faee351a11
commit 4bb77abb33

View File

@ -883,74 +883,71 @@ public final class ThreadManager {
public LiveData<Resource<Object>> acceptRequest() {
final MutableLiveData<Resource<Object>> data = new MutableLiveData<>();
data.postValue(Resource.success(new Object()));
// final Call<String> request = service.approveRequest(threadId);
// request.enqueue(new Callback<String>() {
// @Override
// public void onResponse(@NonNull final Call<String> call,
// @NonNull final Response<String> response) {
// if (!response.isSuccessful()) {
// try {
// final String string = response.errorBody() != null ? response.errorBody().string() : "";
// final String msg = String.format(Locale.US,
// "onResponse: url: %s, responseCode: %d, errorBody: %s",
// call.request().url().toString(),
// response.code(),
// string);
// Log.e(TAG, msg);
// data.postValue(Resource.error(msg, null));
// return;
// } catch (IOException e) {
// Log.e(TAG, "onResponse: ", e);
// }
// return;
// }
// data.postValue(Resource.success(new Object()));
// // refreshChats();
// }
//
// @Override
// public void onFailure(@NonNull final Call<String> call, @NonNull final Throwable t) {
// Log.e(TAG, "onFailure: ", t);
// data.postValue(Resource.error(t.getMessage(), null));
// }
// });
final Call<String> request = service.approveRequest(threadId);
request.enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull final Call<String> call,
@NonNull final Response<String> response) {
if (!response.isSuccessful()) {
try {
final String string = response.errorBody() != null ? response.errorBody().string() : "";
final String msg = String.format(Locale.US,
"onResponse: url: %s, responseCode: %d, errorBody: %s",
call.request().url().toString(),
response.code(),
string);
Log.e(TAG, msg);
data.postValue(Resource.error(msg, null));
return;
} catch (IOException e) {
Log.e(TAG, "onResponse: ", e);
}
return;
}
data.postValue(Resource.success(new Object()));
}
@Override
public void onFailure(@NonNull final Call<String> call, @NonNull final Throwable t) {
Log.e(TAG, "onFailure: ", t);
data.postValue(Resource.error(t.getMessage(), null));
}
});
return data;
}
public LiveData<Resource<Object>> declineRequest() {
final MutableLiveData<Resource<Object>> data = new MutableLiveData<>();
data.postValue(Resource.success(new Object()));
// final Call<String> request = service.declineRequest(threadId);
// request.enqueue(new Callback<String>() {
// @Override
// public void onResponse(@NonNull final Call<String> call,
// @NonNull final Response<String> response) {
// if (!response.isSuccessful()) {
// try {
// final String string = response.errorBody() != null ? response.errorBody().string() : "";
// final String msg = String.format(Locale.US,
// "onResponse: url: %s, responseCode: %d, errorBody: %s",
// call.request().url().toString(),
// response.code(),
// string);
// Log.e(TAG, msg);
// data.postValue(Resource.error(msg, null));
// return;
// } catch (IOException e) {
// Log.e(TAG, "onResponse: ", e);
// }
// return;
// }
// data.postValue(Resource.success(new Object()));
// }
//
// @Override
// public void onFailure(@NonNull final Call<String> call, @NonNull final Throwable t) {
// Log.e(TAG, "onFailure: ", t);
// data.postValue(Resource.error(t.getMessage(), null));
// }
// });
final Call<String> request = service.declineRequest(threadId);
request.enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull final Call<String> call,
@NonNull final Response<String> response) {
if (!response.isSuccessful()) {
try {
final String string = response.errorBody() != null ? response.errorBody().string() : "";
final String msg = String.format(Locale.US,
"onResponse: url: %s, responseCode: %d, errorBody: %s",
call.request().url().toString(),
response.code(),
string);
Log.e(TAG, msg);
data.postValue(Resource.error(msg, null));
return;
} catch (IOException e) {
Log.e(TAG, "onResponse: ", e);
}
return;
}
data.postValue(Resource.success(new Object()));
}
@Override
public void onFailure(@NonNull final Call<String> call, @NonNull final Throwable t) {
Log.e(TAG, "onFailure: ", t);
data.postValue(Resource.error(t.getMessage(), null));
}
});
return data;
}