Skip to content

Commit

Permalink
bug fix, suppressed warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nuclearfog committed May 24, 2022
1 parent 688aaf0 commit ab9d2b7
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions app/src/main/java/org/nuclearfog/twidda/backend/api/Twitter.java
Original file line number Diff line number Diff line change
Expand Up @@ -1160,25 +1160,29 @@ public Directmessages getDirectmessages(String cursor) throws TwitterException {
Directmessages result = new Directmessages(cursor, nextCursor);
for (int pos = 0; pos < array.length(); pos++) {
JSONObject item = array.getJSONObject(pos);
DirectmessageV1 message = new DirectmessageV1(item);
long senderId = message.getSenderId();
long receiverId = message.getReceiverId();
// cache user instances to reduce API calls
if (userCache.containsKey(senderId)) {
message.addSender(userCache.get(senderId));
} else {
User user = showUser(senderId);
userCache.put(senderId, user);
message.addSender(user);
}
if (userCache.containsKey(receiverId)) {
message.addReceiver(userCache.get(receiverId));
} else {
User user = showUser(receiverId);
userCache.put(receiverId, user);
message.addReceiver(user);
try {
DirectmessageV1 message = new DirectmessageV1(item);
long senderId = message.getSenderId();
long receiverId = message.getReceiverId();
// cache user instances to reduce API calls
if (userCache.containsKey(senderId)) {
message.addSender(userCache.get(senderId));
} else {
User user = showUser(senderId);
userCache.put(senderId, user);
message.addSender(user);
}
if (userCache.containsKey(receiverId)) {
message.addReceiver(userCache.get(receiverId));
} else {
User user = showUser(receiverId);
userCache.put(receiverId, user);
message.addReceiver(user);
}
result.add(message);
} catch (JSONException e) {
Log.w("directmessage", e);
}
result.add(message);
}
return result;
}
Expand Down Expand Up @@ -1687,6 +1691,7 @@ private Response post(String endpoint, List<String> params) throws IOException {
* @param params additional http parameters
* @return http resonse
*/
@SuppressWarnings("SameParameterValue")
private Response post(String endpoint, List<String> params, JSONObject json) throws IOException {
RequestBody body = RequestBody.create(TYPE_JSON, json.toString());
return post(endpoint, params, body);
Expand Down Expand Up @@ -1767,6 +1772,7 @@ private Response put(String endpoint, List<String> params, RequestBody body) thr
* @param endpoint endpoint url
* @return http response
*/
@SuppressWarnings("SameParameterValue")
private Response delete(String endpoint, List<String> params) throws IOException {
String authHeader = buildHeader("DELETE", endpoint, params);
String url = appendParams(endpoint, params);
Expand Down

0 comments on commit ab9d2b7

Please sign in to comment.