mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-22 14:47:29 +00:00
patrol certain error strings
This commit is contained in:
parent
74d3e1ad7d
commit
fbb5c244ae
@ -131,7 +131,10 @@ public class GifPickerBottomDialogFragment extends BottomSheetDialogFragment {
|
|||||||
case ERROR:
|
case ERROR:
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
if (context != null && imagesResource.message != null) {
|
if (context != null && imagesResource.message != null) {
|
||||||
Snackbar.make(context, binding.getRoot(), imagesResource.message, Snackbar.LENGTH_LONG);
|
Snackbar.make(context, binding.getRoot(), imagesResource.message, Snackbar.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
if (context != null && imagesResource.resId != 0) {
|
||||||
|
Snackbar.make(context, binding.getRoot(), getString(imagesResource.resId), Snackbar.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LOADING:
|
case LOADING:
|
||||||
|
@ -204,6 +204,9 @@ public class UserSearchFragment extends Fragment {
|
|||||||
if (results.message != null) {
|
if (results.message != null) {
|
||||||
Snackbar.make(binding.getRoot(), results.message, Snackbar.LENGTH_LONG).show();
|
Snackbar.make(binding.getRoot(), results.message, Snackbar.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
if (results.resId != 0) {
|
||||||
|
Snackbar.make(binding.getRoot(), results.resId, Snackbar.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
if (results.data != null) {
|
if (results.data != null) {
|
||||||
resultsAdapter.submitList(results.data);
|
resultsAdapter.submitList(results.data);
|
||||||
}
|
}
|
||||||
|
@ -193,6 +193,9 @@ public class DirectMessageInboxFragment extends Fragment implements SwipeRefresh
|
|||||||
if (inboxResource.message != null) {
|
if (inboxResource.message != null) {
|
||||||
Snackbar.make(binding.getRoot(), inboxResource.message, Snackbar.LENGTH_LONG).show();
|
Snackbar.make(binding.getRoot(), inboxResource.message, Snackbar.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
if (inboxResource.resId != 0) {
|
||||||
|
Snackbar.make(binding.getRoot(), inboxResource.resId, Snackbar.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
binding.swipeRefreshLayout.setRefreshing(false);
|
binding.swipeRefreshLayout.setRefreshing(false);
|
||||||
break;
|
break;
|
||||||
case LOADING:
|
case LOADING:
|
||||||
|
@ -329,6 +329,9 @@ public class DirectMessageSettingsFragment extends Fragment implements ConfirmDi
|
|||||||
if (resource.message != null) {
|
if (resource.message != null) {
|
||||||
Snackbar.make(binding.getRoot(), resource.message, Snackbar.LENGTH_LONG).show();
|
Snackbar.make(binding.getRoot(), resource.message, Snackbar.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
if (resource.resId != 0) {
|
||||||
|
Snackbar.make(binding.getRoot(), resource.resId, Snackbar.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case LOADING:
|
case LOADING:
|
||||||
buttonView.setEnabled(false);
|
buttonView.setEnabled(false);
|
||||||
@ -427,6 +430,9 @@ public class DirectMessageSettingsFragment extends Fragment implements ConfirmDi
|
|||||||
if (resource.message != null) {
|
if (resource.message != null) {
|
||||||
Snackbar.make(binding.getRoot(), resource.message, Snackbar.LENGTH_LONG).show();
|
Snackbar.make(binding.getRoot(), resource.message, Snackbar.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
if (resource.resId != 0) {
|
||||||
|
Snackbar.make(binding.getRoot(), resource.resId, Snackbar.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -450,6 +456,9 @@ public class DirectMessageSettingsFragment extends Fragment implements ConfirmDi
|
|||||||
if (resource.message != null) {
|
if (resource.message != null) {
|
||||||
Snackbar.make(binding.getRoot(), resource.message, Snackbar.LENGTH_LONG).show();
|
Snackbar.make(binding.getRoot(), resource.message, Snackbar.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
if (resource.resId != 0) {
|
||||||
|
Snackbar.make(binding.getRoot(), resource.resId, Snackbar.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pendingUsersAdapter.notifyItemChanged(position);
|
pendingUsersAdapter.notifyItemChanged(position);
|
||||||
@ -477,6 +486,9 @@ public class DirectMessageSettingsFragment extends Fragment implements ConfirmDi
|
|||||||
if (resource.message != null) {
|
if (resource.message != null) {
|
||||||
Snackbar.make(binding.getRoot(), resource.message, Snackbar.LENGTH_LONG).show();
|
Snackbar.make(binding.getRoot(), resource.message, Snackbar.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
if (resource.resId != 0) {
|
||||||
|
Snackbar.make(binding.getRoot(), resource.resId, Snackbar.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case LOADING:
|
case LOADING:
|
||||||
binding.leave.setEnabled(false);
|
binding.leave.setEnabled(false);
|
||||||
@ -497,6 +509,9 @@ public class DirectMessageSettingsFragment extends Fragment implements ConfirmDi
|
|||||||
if (resource.message != null) {
|
if (resource.message != null) {
|
||||||
Snackbar.make(binding.getRoot(), resource.message, Snackbar.LENGTH_LONG).show();
|
Snackbar.make(binding.getRoot(), resource.message, Snackbar.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
if (resource.resId != 0) {
|
||||||
|
Snackbar.make(binding.getRoot(), resource.resId, Snackbar.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case LOADING:
|
case LOADING:
|
||||||
binding.end.setEnabled(false);
|
binding.end.setEnabled(false);
|
||||||
|
@ -612,6 +612,9 @@ public class DirectMessageThreadFragment extends Fragment implements DirectReact
|
|||||||
if (fetchingResource.message != null) {
|
if (fetchingResource.message != null) {
|
||||||
Snackbar.make(binding.getRoot(), fetchingResource.message, Snackbar.LENGTH_LONG).show();
|
Snackbar.make(binding.getRoot(), fetchingResource.message, Snackbar.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
if (fetchingResource.resId != 0) {
|
||||||
|
Snackbar.make(binding.getRoot(), fetchingResource.resId, Snackbar.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case LOADING:
|
case LOADING:
|
||||||
setTitle(getString(R.string.dms_thread_updating));
|
setTitle(getString(R.string.dms_thread_updating));
|
||||||
@ -750,6 +753,9 @@ public class DirectMessageThreadFragment extends Fragment implements DirectReact
|
|||||||
if (resource.message != null) {
|
if (resource.message != null) {
|
||||||
Snackbar.make(binding.getRoot(), resource.message, Snackbar.LENGTH_LONG).show();
|
Snackbar.make(binding.getRoot(), resource.message, Snackbar.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
if (resource.resId != 0) {
|
||||||
|
Snackbar.make(binding.getRoot(), resource.resId, Snackbar.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
resourceLiveData.removeObservers(getViewLifecycleOwner());
|
resourceLiveData.removeObservers(getViewLifecycleOwner());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1141,6 +1147,9 @@ public class DirectMessageThreadFragment extends Fragment implements DirectReact
|
|||||||
if (resource.message != null) {
|
if (resource.message != null) {
|
||||||
Snackbar.make(binding.getRoot(), resource.message, Snackbar.LENGTH_LONG).show();
|
Snackbar.make(binding.getRoot(), resource.message, Snackbar.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
if (resource.resId != 0) {
|
||||||
|
Snackbar.make(binding.getRoot(), resource.resId, Snackbar.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
resourceLiveData.removeObservers(getViewLifecycleOwner());
|
resourceLiveData.removeObservers(getViewLifecycleOwner());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import java.util.List;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import awais.instagrabber.R;
|
||||||
import awais.instagrabber.models.Resource;
|
import awais.instagrabber.models.Resource;
|
||||||
import awais.instagrabber.repositories.responses.User;
|
import awais.instagrabber.repositories.responses.User;
|
||||||
import awais.instagrabber.repositories.responses.directmessages.DirectBadgeCount;
|
import awais.instagrabber.repositories.responses.directmessages.DirectBadgeCount;
|
||||||
@ -156,7 +157,7 @@ public final class InboxManager {
|
|||||||
final DirectBadgeCount directBadgeCount = response.body();
|
final DirectBadgeCount directBadgeCount = response.body();
|
||||||
if (directBadgeCount == null) {
|
if (directBadgeCount == null) {
|
||||||
Log.e(TAG, "onResponse: directBadgeCount Response is null");
|
Log.e(TAG, "onResponse: directBadgeCount Response is null");
|
||||||
unseenCount.postValue(Resource.error("Unseen count response is null", getCurrentUnseenCount()));
|
unseenCount.postValue(Resource.error(R.string.dms_inbox_error_null_count, getCurrentUnseenCount()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
unseenCount.postValue(Resource.success(directBadgeCount.getBadgeCount()));
|
unseenCount.postValue(Resource.success(directBadgeCount.getBadgeCount()));
|
||||||
@ -188,14 +189,13 @@ public final class InboxManager {
|
|||||||
private void parseInboxResponse(final DirectInboxResponse response) {
|
private void parseInboxResponse(final DirectInboxResponse response) {
|
||||||
if (response == null) {
|
if (response == null) {
|
||||||
Log.e(TAG, "parseInboxResponse: Response is null");
|
Log.e(TAG, "parseInboxResponse: Response is null");
|
||||||
inbox.postValue(Resource.error("Response is null", getCurrentDirectInbox()));
|
inbox.postValue(Resource.error(R.string.generic_null_response, getCurrentDirectInbox()));
|
||||||
hasOlder = false;
|
hasOlder = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!response.getStatus().equals("ok")) {
|
if (!response.getStatus().equals("ok")) {
|
||||||
final String msg = "DM inbox fetch response: status not ok";
|
Log.e(TAG, "DM inbox fetch response: status not ok");
|
||||||
Log.e(TAG, msg);
|
inbox.postValue(Resource.error(R.string.generic_not_ok_response, getCurrentDirectInbox()));
|
||||||
inbox.postValue(Resource.error(msg, getCurrentDirectInbox()));
|
|
||||||
hasOlder = false;
|
hasOlder = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ import java.util.UUID;
|
|||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import awais.instagrabber.R;
|
||||||
import awais.instagrabber.customviews.emoji.Emoji;
|
import awais.instagrabber.customviews.emoji.Emoji;
|
||||||
import awais.instagrabber.models.Resource;
|
import awais.instagrabber.models.Resource;
|
||||||
import awais.instagrabber.models.Resource.Status;
|
import awais.instagrabber.models.Resource.Status;
|
||||||
@ -83,10 +84,6 @@ import static awais.instagrabber.utils.Utils.settingsHelper;
|
|||||||
public final class ThreadManager {
|
public final class ThreadManager {
|
||||||
private static final String TAG = ThreadManager.class.getSimpleName();
|
private static final String TAG = ThreadManager.class.getSimpleName();
|
||||||
private static final Object LOCK = new Object();
|
private static final Object LOCK = new Object();
|
||||||
private static final String ERROR_INVALID_USER = "Invalid user";
|
|
||||||
private static final String ERROR_RESPONSE_NOT_OK = "Response status from server was not ok";
|
|
||||||
private static final String ERROR_VIDEO_TOO_LONG = "Instagram does not allow uploading videos longer than 60 secs for Direct messages";
|
|
||||||
private static final String ERROR_AUDIO_TOO_LONG = "Instagram does not allow uploading audio longer than 60 secs";
|
|
||||||
private static final Map<String, ThreadManager> INSTANCE_MAP = new ConcurrentHashMap<>();
|
private static final Map<String, ThreadManager> INSTANCE_MAP = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private final MutableLiveData<Resource<Object>> fetching = new MutableLiveData<>();
|
private final MutableLiveData<Resource<Object>> fetching = new MutableLiveData<>();
|
||||||
@ -363,12 +360,12 @@ public final class ThreadManager {
|
|||||||
public void onResponse(@NonNull final Call<DirectThreadFeedResponse> call, @NonNull final Response<DirectThreadFeedResponse> response) {
|
public void onResponse(@NonNull final Call<DirectThreadFeedResponse> call, @NonNull final Response<DirectThreadFeedResponse> response) {
|
||||||
final DirectThreadFeedResponse feedResponse = response.body();
|
final DirectThreadFeedResponse feedResponse = response.body();
|
||||||
if (feedResponse == null) {
|
if (feedResponse == null) {
|
||||||
fetching.postValue(Resource.error("response was null!", null));
|
fetching.postValue(Resource.error(R.string.generic_null_response, null));
|
||||||
Log.e(TAG, "onResponse: response was null!");
|
Log.e(TAG, "onResponse: response was null!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!feedResponse.getStatus().equals("ok")) {
|
if (!feedResponse.getStatus().equals("ok")) {
|
||||||
fetching.postValue(Resource.error("response was not ok", null));
|
fetching.postValue(Resource.error(R.string.generic_not_ok_response, null));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final DirectThread thread = feedResponse.getThread();
|
final DirectThread thread = feedResponse.getThread();
|
||||||
@ -674,7 +671,7 @@ public final class ThreadManager {
|
|||||||
final long byteLength) {
|
final long byteLength) {
|
||||||
if (duration > 60000) {
|
if (duration > 60000) {
|
||||||
// instagram does not allow uploading audio longer than 60 secs for Direct messages
|
// instagram does not allow uploading audio longer than 60 secs for Direct messages
|
||||||
data.postValue(Resource.error(ERROR_AUDIO_TOO_LONG, null));
|
data.postValue(Resource.error(R.string.dms_ERROR_AUDIO_TOO_LONG, null));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Long userId = getCurrentUserId(data);
|
final Long userId = getCurrentUserId(data);
|
||||||
@ -794,7 +791,7 @@ public final class ThreadManager {
|
|||||||
handleErrorBody(call, response, data);
|
handleErrorBody(call, response, data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
data.postValue(Resource.error("request was not successful and response error body was null", item));
|
data.postValue(Resource.error(R.string.generic_failed_request, item));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1056,7 +1053,7 @@ public final class ThreadManager {
|
|||||||
final int height) {
|
final int height) {
|
||||||
if (duration > 60000) {
|
if (duration > 60000) {
|
||||||
// instagram does not allow uploading videos longer than 60 secs for Direct messages
|
// instagram does not allow uploading videos longer than 60 secs for Direct messages
|
||||||
data.postValue(Resource.error(ERROR_VIDEO_TOO_LONG, null));
|
data.postValue(Resource.error(R.string.dms_ERROR_VIDEO_TOO_LONG, null));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Long userId = getCurrentUserId(data);
|
final Long userId = getCurrentUserId(data);
|
||||||
@ -1125,7 +1122,7 @@ public final class ThreadManager {
|
|||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
final DirectThreadBroadcastResponse broadcastResponse = response.body();
|
final DirectThreadBroadcastResponse broadcastResponse = response.body();
|
||||||
if (broadcastResponse == null) {
|
if (broadcastResponse == null) {
|
||||||
data.postValue(Resource.error("Response was null from server", directItem));
|
data.postValue(Resource.error(R.string.generic_null_response, directItem));
|
||||||
Log.e(TAG, "enqueueRequest: onResponse: response body is null");
|
Log.e(TAG, "enqueueRequest: onResponse: response body is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1155,7 +1152,7 @@ public final class ThreadManager {
|
|||||||
if (response.errorBody() != null) {
|
if (response.errorBody() != null) {
|
||||||
handleErrorBody(call, response, data);
|
handleErrorBody(call, response, data);
|
||||||
}
|
}
|
||||||
data.postValue(Resource.error("request was not successful and response error body was null", directItem));
|
data.postValue(Resource.error(R.string.generic_failed_request, directItem));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1215,12 +1212,12 @@ public final class ThreadManager {
|
|||||||
@NonNull final MediaUploader.MediaUploadResponse response) {
|
@NonNull final MediaUploader.MediaUploadResponse response) {
|
||||||
final JSONObject responseJson = response.getResponse();
|
final JSONObject responseJson = response.getResponse();
|
||||||
if (responseJson == null || response.getResponseCode() != HttpURLConnection.HTTP_OK) {
|
if (responseJson == null || response.getResponseCode() != HttpURLConnection.HTTP_OK) {
|
||||||
data.postValue(Resource.error(ERROR_RESPONSE_NOT_OK, null));
|
data.postValue(Resource.error(R.string.generic_not_ok_response, null));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
final String status = responseJson.optString("status");
|
final String status = responseJson.optString("status");
|
||||||
if (TextUtils.isEmpty(status) || !status.equals("ok")) {
|
if (TextUtils.isEmpty(status) || !status.equals("ok")) {
|
||||||
data.postValue(Resource.error(ERROR_RESPONSE_NOT_OK, null));
|
data.postValue(Resource.error(R.string.generic_not_ok_response, null));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -1253,12 +1250,12 @@ public final class ThreadManager {
|
|||||||
handleErrorBody(call, response, data);
|
handleErrorBody(call, response, data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
data.postValue(Resource.error("request was not successful and response error body was null", item));
|
data.postValue(Resource.error(R.string.generic_failed_request, item));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final DirectThreadBroadcastResponse body = response.body();
|
final DirectThreadBroadcastResponse body = response.body();
|
||||||
if (body == null) {
|
if (body == null) {
|
||||||
data.postValue(Resource.error("Response is null!", item));
|
data.postValue(Resource.error(R.string.generic_null_response, item));
|
||||||
}
|
}
|
||||||
// otherwise nothing to do? maybe update the timestamp in the emoji?
|
// otherwise nothing to do? maybe update the timestamp in the emoji?
|
||||||
}
|
}
|
||||||
@ -1282,7 +1279,7 @@ public final class ThreadManager {
|
|||||||
@Nullable
|
@Nullable
|
||||||
private Long getCurrentUserId(final MutableLiveData<Resource<Object>> data) {
|
private Long getCurrentUserId(final MutableLiveData<Resource<Object>> data) {
|
||||||
if (currentUser == null || currentUser.getPk() <= 0) {
|
if (currentUser == null || currentUser.getPk() <= 0) {
|
||||||
data.postValue(Resource.error(ERROR_INVALID_USER, null));
|
data.postValue(Resource.error(R.string.dms_ERROR_INVALID_USER, null));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return currentUser.getPk();
|
return currentUser.getPk();
|
||||||
@ -1777,7 +1774,7 @@ public final class ThreadManager {
|
|||||||
}
|
}
|
||||||
final DirectThreadDetailsChangeResponse changeResponse = response.body();
|
final DirectThreadDetailsChangeResponse changeResponse = response.body();
|
||||||
if (changeResponse == null) {
|
if (changeResponse == null) {
|
||||||
data.postValue(Resource.error("Response is null", null));
|
data.postValue(Resource.error(R.string.generic_null_response, null));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
data.postValue(Resource.success(new Object()));
|
data.postValue(Resource.success(new Object()));
|
||||||
|
@ -9,28 +9,36 @@ public class Resource<T> {
|
|||||||
public final Status status;
|
public final Status status;
|
||||||
public final T data;
|
public final T data;
|
||||||
public final String message;
|
public final String message;
|
||||||
|
public final int resId;
|
||||||
|
|
||||||
private Resource(@NonNull Status status,
|
private Resource(@NonNull Status status,
|
||||||
@Nullable T data,
|
@Nullable T data,
|
||||||
@Nullable String message) {
|
@Nullable String message,
|
||||||
|
int resId) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
|
this.resId = resId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public static <T> Resource<T> success(@NonNull T data) {
|
public static <T> Resource<T> success(@NonNull T data) {
|
||||||
return new Resource<>(Status.SUCCESS, data, null);
|
return new Resource<>(Status.SUCCESS, data, null, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public static <T> Resource<T> error(String msg, @Nullable T data) {
|
public static <T> Resource<T> error(String msg, @Nullable T data) {
|
||||||
return new Resource<>(Status.ERROR, data, msg);
|
return new Resource<>(Status.ERROR, data, msg, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public static <T> Resource<T> error(int resId, @Nullable T data) {
|
||||||
|
return new Resource<>(Status.ERROR, data, null, resId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public static <T> Resource<T> loading(@Nullable T data) {
|
public static <T> Resource<T> loading(@Nullable T data) {
|
||||||
return new Resource<>(Status.LOADING, data, null);
|
return new Resource<>(Status.LOADING, data, null, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -14,6 +14,7 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import awais.instagrabber.R;
|
||||||
import awais.instagrabber.models.Resource;
|
import awais.instagrabber.models.Resource;
|
||||||
import awais.instagrabber.repositories.responses.giphy.GiphyGif;
|
import awais.instagrabber.repositories.responses.giphy.GiphyGif;
|
||||||
import awais.instagrabber.repositories.responses.giphy.GiphyGifResponse;
|
import awais.instagrabber.repositories.responses.giphy.GiphyGifResponse;
|
||||||
@ -70,7 +71,7 @@ public class GifPickerViewModel extends ViewModel {
|
|||||||
Log.e(TAG, "onResponse: ", e);
|
Log.e(TAG, "onResponse: ", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
images.postValue(Resource.error("request was not successful and response error body was null", getCurrentImages()));
|
images.postValue(Resource.error(R.string.generic_failed_request, getCurrentImages()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -85,7 +86,7 @@ public class GifPickerViewModel extends ViewModel {
|
|||||||
private void parseResponse(final Response<GiphyGifResponse> response) {
|
private void parseResponse(final Response<GiphyGifResponse> response) {
|
||||||
final GiphyGifResponse giphyGifResponse = response.body();
|
final GiphyGifResponse giphyGifResponse = response.body();
|
||||||
if (giphyGifResponse == null) {
|
if (giphyGifResponse == null) {
|
||||||
images.postValue(Resource.error("Response body was null", getCurrentImages()));
|
images.postValue(Resource.error(R.string.generic_null_response, getCurrentImages()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final GiphyGifResults results = giphyGifResponse.getResults();
|
final GiphyGifResults results = giphyGifResponse.getResults();
|
||||||
|
@ -20,6 +20,7 @@ import java.util.Objects;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import awais.instagrabber.R;
|
||||||
import awais.instagrabber.fragments.UserSearchFragment;
|
import awais.instagrabber.fragments.UserSearchFragment;
|
||||||
import awais.instagrabber.models.Resource;
|
import awais.instagrabber.models.Resource;
|
||||||
import awais.instagrabber.repositories.responses.User;
|
import awais.instagrabber.repositories.responses.User;
|
||||||
@ -205,7 +206,7 @@ public class UserSearchViewModel extends ViewModel {
|
|||||||
}
|
}
|
||||||
final RankedRecipientsResponse rankedRecipientsResponse = response.body();
|
final RankedRecipientsResponse rankedRecipientsResponse = response.body();
|
||||||
if (rankedRecipientsResponse == null) {
|
if (rankedRecipientsResponse == null) {
|
||||||
recipients.postValue(Resource.error("Response is null!", getCachedRecipients()));
|
recipients.postValue(Resource.error(R.string.generic_null_response, getCachedRecipients()));
|
||||||
searchRequest = null;
|
searchRequest = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -234,7 +235,7 @@ public class UserSearchViewModel extends ViewModel {
|
|||||||
}
|
}
|
||||||
final UserSearchResponse userSearchResponse = response.body();
|
final UserSearchResponse userSearchResponse = response.body();
|
||||||
if (userSearchResponse == null) {
|
if (userSearchResponse == null) {
|
||||||
recipients.postValue(Resource.error("Response is null!", getCachedRecipients()));
|
recipients.postValue(Resource.error(R.string.generic_null_response, getCachedRecipients()));
|
||||||
searchRequest = null;
|
searchRequest = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -286,7 +287,7 @@ public class UserSearchViewModel extends ViewModel {
|
|||||||
final ResponseBody errorBody = response.errorBody();
|
final ResponseBody errorBody = response.errorBody();
|
||||||
if (errorBody == null) {
|
if (errorBody == null) {
|
||||||
if (updateResource) {
|
if (updateResource) {
|
||||||
recipients.postValue(Resource.error("Request failed!", getCachedRecipients()));
|
recipients.postValue(Resource.error(R.string.generic_failed_request, getCachedRecipients()));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -211,6 +211,7 @@
|
|||||||
<string name="dms_inbox_raven_media_suggested">Suggested</string>
|
<string name="dms_inbox_raven_media_suggested">Suggested</string>
|
||||||
<string name="dms_inbox_raven_media_screenshot">Screenshotted</string>
|
<string name="dms_inbox_raven_media_screenshot">Screenshotted</string>
|
||||||
<string name="dms_inbox_raven_media_cant_deliver">Cannot deliver</string>
|
<string name="dms_inbox_raven_media_cant_deliver">Cannot deliver</string>
|
||||||
|
<string name="dms_inbox_error_null_count">Unseen count response is null!</string>
|
||||||
<string name="dms_thread_message_hint">Message...</string>
|
<string name="dms_thread_message_hint">Message...</string>
|
||||||
<string name="dms_thread_audio_hint">Press and hold to record audio</string>
|
<string name="dms_thread_audio_hint">Press and hold to record audio</string>
|
||||||
<string name="dms_thread_updating">Updating...</string>
|
<string name="dms_thread_updating">Updating...</string>
|
||||||
@ -219,6 +220,9 @@
|
|||||||
<string name="dms_action_leave_question">Leave this chat?</string>
|
<string name="dms_action_leave_question">Leave this chat?</string>
|
||||||
<string name="dms_action_kick">Kick</string>
|
<string name="dms_action_kick">Kick</string>
|
||||||
<string name="dms_left_users">Left users</string>
|
<string name="dms_left_users">Left users</string>
|
||||||
|
<string name="dms_ERROR_INVALID_USER">Invalid user</string>
|
||||||
|
<string name="dms_ERROR_VIDEO_TOO_LONG">Instagram does not allow uploading videos longer than 60 secs for DM.</string>
|
||||||
|
<string name="dms_ERROR_AUDIO_TOO_LONG">Instagram does not allow uploading audio longer than 60 secs.</string>
|
||||||
<string name="direct_download">Download directly</string>
|
<string name="direct_download">Download directly</string>
|
||||||
<string name="direct_download_desc">Downloads posts directly to the phone!</string>
|
<string name="direct_download_desc">Downloads posts directly to the phone!</string>
|
||||||
<string name="direct_download_loading">Fetching post(s)</string>
|
<string name="direct_download_loading">Fetching post(s)</string>
|
||||||
@ -494,4 +498,7 @@
|
|||||||
<string name="secs">secs</string>
|
<string name="secs">secs</string>
|
||||||
<string name="mins">mins</string>
|
<string name="mins">mins</string>
|
||||||
<string name="search_giphy">Search GIPHY</string>
|
<string name="search_giphy">Search GIPHY</string>
|
||||||
|
<string name="generic_null_response">Response is null!</string>
|
||||||
|
<string name="generic_not_ok_response">Response status is not ok!</string>
|
||||||
|
<string name="generic_failed_request">Request failed!</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user