Commit 3861a7b6 authored by Thomas's avatar Thomas
Browse files

Crash due to delayed service call (Peertube)

parent 443ff2d2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -917,7 +917,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
            timelinesVM.getTimeline(timelineStatuses, timelineParams)
                    .observe(getViewLifecycleOwner(), 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;
                            timelineParams.maxId = null;
                            max_id = null;
+11 −8
Original line number Diff line number Diff line
@@ -24,7 +24,9 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;

import androidx.annotation.Nullable;
import androidx.core.app.NotificationCompat;
@@ -50,12 +52,6 @@ public class RetrieveInfoService extends Service implements NetworkStateReceiver
        networkStateReceiver = new NetworkStateReceiver();
        networkStateReceiver.addListener(this);
        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) {
            NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID,
                    getString(R.string.notification_channel_name),
@@ -83,8 +79,13 @@ public class RetrieveInfoService extends Service implements NetworkStateReceiver

            startForeground(1, notification);
        }
        Thread thread = new Thread() {

    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {

        Thread thread = new Thread() {
            @Override
            public void run() {
                EmojiHelper.fillMapEmoji(getApplicationContext());
@@ -96,7 +97,9 @@ public class RetrieveInfoService extends Service implements NetworkStateReceiver
                peertubeInformation.setPlaylistPrivacies(new LinkedHashMap<>());
                peertubeInformation.setTranslations(new LinkedHashMap<>());
                peertubeInformation = new RetrofitPeertubeAPI(RetrieveInfoService.this).getPeertubeInformation();
                stopForeground(true);
                Handler mainHandler = new Handler(Looper.getMainLooper());
                Runnable myRunnable = () -> stopForeground(true);
                mainHandler.post(myRunnable);
            }
        };
        thread.start();