Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nuclearfog committed Dec 21, 2023
1 parent 44ddfbf commit 957df8b
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 13 deletions.
3 changes: 2 additions & 1 deletion app/src/main/assets/licenses.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<!DOCTYPE html>
<html>
<html lang="en">

<head>
<title>Licenses</title>
<style>
body { font-size: x-small; font-family: sans-serif; } pre { background-color: #eeeeee; padding: 1em; white-space: normal; }
</style>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,10 @@ public Statuses getPublicTimeline(long minId, long maxId) throws MastodonExcepti
params.add("local=true");
else if (settings.getPublicTimeline().equals(GlobalSettings.TIMELINE_REMOTE))
params.add("remote=true");
return getStatuses(ENDPOINT_PUBLIC_TIMELINE, minId, maxId, params);
Statuses result = getStatuses(ENDPOINT_PUBLIC_TIMELINE, minId, maxId, params);
// some posts seems to be unsorted
Collections.sort(result);
return result;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ public class MastodonException extends ConnectionException {
errorCode = SERVICE_UNAVAILABLE;
break;
}
timeToWait = (int) ((StringUtils.getIsoTime(response.header("X-RateLimit-Reset")) - System.currentTimeMillis()) / 1000L);

String ratelimitReset = response.header("X-RateLimit-Reset");
if (ratelimitReset != null && !ratelimitReset.trim().isEmpty()) {
timeToWait = (int) ((StringUtils.getIsoTime(ratelimitReset) - System.currentTimeMillis()) / 1000L);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@

import java.io.Serializable;

import okhttp3.Call;


/**
* video player activity to show local and online videos/animations
*
Expand Down Expand Up @@ -126,7 +123,7 @@ protected void onCreate(@Nullable Bundle savedInstance) {
if (serializedData instanceof Media) {
this.media = (Media) serializedData;
MediaItem mediaItem = MediaItem.fromUri(media.getUrl());
DataSource.Factory dataSourceFactory = new OkHttpDataSource.Factory((Call.Factory) ConnectionBuilder.create(this, CACHE_SIZE));
DataSource.Factory dataSourceFactory = new OkHttpDataSource.Factory(ConnectionBuilder.create(this, CACHE_SIZE));
if (media.getMediaType() != Media.VIDEO) {
playerView.setUseController(false);
player.setRepeatMode(Player.REPEAT_MODE_ONE);
Expand All @@ -144,7 +141,7 @@ else if (serializedData instanceof MediaStatus) {
DataSource.Factory dataSourceFactory;
MediaItem mediaItem = MediaItem.fromUri(mediaStatus.getPath());
if (mediaStatus.getPath().startsWith("http")) {
dataSourceFactory = new OkHttpDataSource.Factory((Call.Factory) ConnectionBuilder.create(this, CACHE_SIZE));
dataSourceFactory = new OkHttpDataSource.Factory(ConnectionBuilder.create(this, CACHE_SIZE));
} else {
dataSourceFactory = new DataSource.Factory() {
@NonNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public void addItems(Notifications newItems, int index) {
if (!newItems.isEmpty()) {
if (index + 1 == items.size()) {
items.addAll(newItems);
notifyItemRangeInserted(items.size(), newItems.size());
notifyItemRangeInserted(index + 1, newItems.size());
} else {
items.addAll(index, newItems);
notifyItemRangeInserted(index, newItems.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public void addItems(@NonNull Statuses newItems, int index) {
if (!newItems.isEmpty()) {
if (index + 1 == items.size()) {
items.addAll(newItems);
notifyItemRangeInserted(items.size(), newItems.size());
notifyItemRangeInserted(index + 1, newItems.size());
} else {
items.addAll(index, newItems);
notifyItemRangeInserted(index, newItems.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@

import java.io.Closeable;

import okhttp3.Call;

/**
* Dialog with audio player and controls
*
Expand Down Expand Up @@ -85,7 +83,7 @@ protected void onStart() {
// initialize online source
if (data.getScheme().startsWith("http")) {
// configure with okhttp connection of the app
dataSourceFactory = new OkHttpDataSource.Factory((Call.Factory) ConnectionBuilder.create(getContext()));
dataSourceFactory = new OkHttpDataSource.Factory(ConnectionBuilder.create(getContext()));
mediaLink.setVisibility(View.VISIBLE);
}
// initialize local source
Expand Down

0 comments on commit 957df8b

Please sign in to comment.