bug fix, cleanup

This commit is contained in:
nuclearfog 2023-06-12 21:26:56 +02:00
parent 819f414ed9
commit c38ccc9e8d
No known key found for this signature in database
GPG Key ID: 03488A185C476379
10 changed files with 55 additions and 32 deletions

View File

@ -38,8 +38,6 @@ android {
excludes += ['/META-INF/CHANGES', '/META-INF/DEPENDENCIES', '/META-INF/README.md', '/META-INF/androidx.*', '/META-INF/kotlin*', '/META-INF/com.*', '/META-INF/services/**', '/META-INF/com/**', '/kotlin/**', '/Debug*']
}
}
}
dependencies {

View File

@ -551,7 +551,7 @@ public class Mastodon implements Connection {
Statuses result = new Statuses();
for (Status status : statusThreads) {
// Mastodon doesn't support min/max ID.
if (status.getRepliedStatusId() == id && (minId == 0 || status.getId() > minId) && (maxId == 0 || status.getId() < maxId)) {
if (status.getRepliedStatusId() == id && (minId == 0L || status.getId() > minId) && (maxId == 0L || status.getId() < maxId)) {
result.add(status);
}
}

View File

@ -3,6 +3,7 @@ package org.nuclearfog.twidda.backend.api.mastodon.impl;
import android.util.Patterns;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.json.JSONException;
import org.json.JSONObject;
@ -62,6 +63,15 @@ public class MastodonCard implements Card {
}
@Override
public boolean equals(@Nullable Object obj) {
if (!(obj instanceof Card))
return false;
Card card = (Card) obj;
return card.getTitle().equals(getTitle()) && card.getUrl().equals(getUrl()) && card.getImageUrl().equals(getImageUrl());
}
@NonNull
@Override
public String toString() {

View File

@ -920,7 +920,7 @@ public class TwitterV1 implements Connection {
root.put("event", event);
if (!message.isEmpty())
data.put("text", message);
if (mediaId != 0) {
if (mediaId != 0L) {
JSONObject attachment = new JSONObject();
JSONObject media = new JSONObject();
attachment.put("type", "media");

View File

@ -3,6 +3,7 @@ package org.nuclearfog.twidda.backend.api.twitter.v2.impl;
import android.util.Patterns;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.json.JSONArray;
import org.json.JSONObject;
@ -67,6 +68,15 @@ public class TwitterCard implements Card {
}
@Override
public boolean equals(@Nullable Object obj) {
if (!(obj instanceof Card))
return false;
Card card = (Card) obj;
return card.getTitle().equals(getTitle()) && card.getUrl().equals(getUrl()) && card.getImageUrl().equals(getImageUrl());
}
@NonNull
@Override
public String toString() {

View File

@ -410,7 +410,7 @@ public class StatusUpdate implements Serializable, Closeable {
@NonNull
@Override
public String toString() {
if (replyId != 0)
if (replyId != 0L)
return "to=" + replyId + " status=\"" + text + "\"";
return "status=\"" + text + "\"";
}

View File

@ -1078,7 +1078,7 @@ public class GlobalSettings {
String bearerToken = settings.getString(BEARER_TOKEN, "");
String hostname = settings.getString(HOSTNAME, TWITTER_HOST);
int apiId = settings.getInt(CURRENT_API, 0);
long userId = settings.getLong(CURRENT_ID, 0);
long userId = settings.getLong(CURRENT_ID, 0L);
if ((apiId == Account.API_TWITTER_1 || apiId == Account.API_TWITTER_2) && twitterAlt)
hostname = TWITTER_ALT_HOST;
login = new ConfigAccount(userId, oauthToken, oauthSecret, consumerToken, consumerSecret, bearerToken, hostname, apiId);

View File

@ -54,6 +54,8 @@ public class CardHolder extends ViewHolder implements OnClickListener {
private GlobalSettings settings;
private OnHolderClickListener listener;
private Card card;
/**
*
*/
@ -93,6 +95,7 @@ public class CardHolder extends ViewHolder implements OnClickListener {
* @param card card content
*/
public void setContent(Card card) {
if (!card.equals(this.card)) {
SpannableStringBuilder urlDescription = new SpannableStringBuilder();
Drawable placeholder = new ColorDrawable(EMPTY_COLOR);
// set url preview image
@ -120,5 +123,7 @@ public class CardHolder extends ViewHolder implements OnClickListener {
}
// apply description
linkText.setText(urlDescription);
this.card = card;
}
}
}

View File

@ -133,7 +133,7 @@ public class StatusFragment extends ListFragment implements StatusSelectListener
Bundle param = getArguments();
if (param != null) {
mode = param.getInt(KEY_MODE, 0);
id = param.getLong(KEY_ID, 0);
id = param.getLong(KEY_ID, 0L);
search = param.getString(KEY_SEARCH, "");
}
if (savedInstanceState != null) {

View File

@ -175,7 +175,7 @@ public class UserFragment extends ListFragment implements UserClickListener, OnC
Bundle param = getArguments();
if (param != null) {
mode = param.getInt(KEY_MODE, 0);
id = param.getLong(KEY_ID, 0);
id = param.getLong(KEY_ID, 0L);
search = param.getString(KEY_SEARCH, "");
boolean delUser = param.getBoolean(KEY_DELETE, false);
adapter.enableDeleteButton(delUser);