mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2025-03-12 01:39:53 +02:00
Crash due to delayed service call (Peertube)
This commit is contained in:
parent
443ff2d299
commit
3861a7b6e4
2 changed files with 12 additions and 9 deletions
|
@ -917,7 +917,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
timelinesVM.getTimeline(timelineStatuses, timelineParams)
|
timelinesVM.getTimeline(timelineStatuses, timelineParams)
|
||||||
.observe(getViewLifecycleOwner(), statuses -> {
|
.observe(getViewLifecycleOwner(), statuses -> {
|
||||||
initialStatuses = statuses;
|
initialStatuses = statuses;
|
||||||
if (!retry_for_home_done && timelineType == Timeline.TimeLineEnum.HOME && (statuses == null || statuses.statuses.size() == 0) && timelineParams.maxId != null) {
|
if (!retry_for_home_done && timelineType == Timeline.TimeLineEnum.HOME && (statuses == null || statuses.statuses == null || statuses.statuses.size() == 0) && timelineParams.maxId != null) {
|
||||||
retry_for_home_done = true;
|
retry_for_home_done = true;
|
||||||
timelineParams.maxId = null;
|
timelineParams.maxId = null;
|
||||||
max_id = null;
|
max_id = null;
|
||||||
|
|
|
@ -24,7 +24,9 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
import android.os.Looper;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.core.app.NotificationCompat;
|
import androidx.core.app.NotificationCompat;
|
||||||
|
@ -50,12 +52,6 @@ public class RetrieveInfoService extends Service implements NetworkStateReceiver
|
||||||
networkStateReceiver = new NetworkStateReceiver();
|
networkStateReceiver = new NetworkStateReceiver();
|
||||||
networkStateReceiver.addListener(this);
|
networkStateReceiver.addListener(this);
|
||||||
registerReceiver(networkStateReceiver, new IntentFilter(android.net.ConnectivityManager.CONNECTIVITY_ACTION));
|
registerReceiver(networkStateReceiver, new IntentFilter(android.net.ConnectivityManager.CONNECTIVITY_ACTION));
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID,
|
NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID,
|
||||||
getString(R.string.notification_channel_name),
|
getString(R.string.notification_channel_name),
|
||||||
|
@ -83,8 +79,13 @@ public class RetrieveInfoService extends Service implements NetworkStateReceiver
|
||||||
|
|
||||||
startForeground(1, notification);
|
startForeground(1, notification);
|
||||||
}
|
}
|
||||||
Thread thread = new Thread() {
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
|
|
||||||
|
Thread thread = new Thread() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
EmojiHelper.fillMapEmoji(getApplicationContext());
|
EmojiHelper.fillMapEmoji(getApplicationContext());
|
||||||
|
@ -96,7 +97,9 @@ public class RetrieveInfoService extends Service implements NetworkStateReceiver
|
||||||
peertubeInformation.setPlaylistPrivacies(new LinkedHashMap<>());
|
peertubeInformation.setPlaylistPrivacies(new LinkedHashMap<>());
|
||||||
peertubeInformation.setTranslations(new LinkedHashMap<>());
|
peertubeInformation.setTranslations(new LinkedHashMap<>());
|
||||||
peertubeInformation = new RetrofitPeertubeAPI(RetrieveInfoService.this).getPeertubeInformation();
|
peertubeInformation = new RetrofitPeertubeAPI(RetrieveInfoService.this).getPeertubeInformation();
|
||||||
stopForeground(true);
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
|
Runnable myRunnable = () -> stopForeground(true);
|
||||||
|
mainHandler.post(myRunnable);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
thread.start();
|
thread.start();
|
||||||
|
|
Loading…
Reference in a new issue