Fix notifications list (#1067)
There was a missing notifyDataSetChanged() call. Fixes #1054 Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@swatian.com> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1067 Reviewed-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
This commit is contained in:
parent
db8e47168d
commit
ff41e82baf
|
@ -10,13 +10,11 @@ import androidx.annotation.NonNull;
|
|||
import androidx.annotation.Nullable;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
import org.gitnex.tea4j.models.NotificationThread;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.BottomSheetNotificationsBinding;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.SimpleCallback;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
|
||||
/**
|
||||
* Author opyale
|
||||
|
@ -61,11 +59,13 @@ public class BottomSheetNotificationsFragment extends BottomSheetDialogFragment
|
|||
.markNotificationThreadAsRead(Authorization.get(context), notificationThread.getId(), "pinned")
|
||||
.enqueue((SimpleCallback<Void>) (call, voidResponse) -> {
|
||||
|
||||
if(voidResponse.isPresent() && voidResponse.get().isSuccessful()) {
|
||||
onOptionSelectedListener.run();
|
||||
} else {
|
||||
// reload without any checks, because Gitea returns a 205 and Java expects this to be empty
|
||||
// but Gitea send a response -> results in a call of onFailure and no response is present
|
||||
//if(voidResponse.isPresent() && voidResponse.get().isSuccessful()) {
|
||||
onOptionSelectedListener.run();
|
||||
/*} else {
|
||||
Toasty.error(context, getString(R.string.genericError));
|
||||
}
|
||||
}*/
|
||||
|
||||
dismiss();
|
||||
}));
|
||||
|
@ -75,11 +75,15 @@ public class BottomSheetNotificationsFragment extends BottomSheetDialogFragment
|
|||
.markNotificationThreadAsRead(Authorization.get(context), notificationThread.getId(), "read")
|
||||
.enqueue((SimpleCallback<Void>) (call, voidResponse) -> {
|
||||
|
||||
if(voidResponse.isPresent() && voidResponse.get().isSuccessful()) {
|
||||
onOptionSelectedListener.run();
|
||||
} else {
|
||||
// reload without any checks, because Gitea returns a 205 and Java expects this to be empty
|
||||
// but Gitea send a response -> results in a call of onFailure and no response is present
|
||||
// reload without any checks, because Gitea returns a 205 and Java expects this to be empty
|
||||
// but Gitea send a response -> results in a call of onFailure and no response is present
|
||||
//if(voidResponse.isPresent() && voidResponse.get().isSuccessful()) {
|
||||
onOptionSelectedListener.run();
|
||||
/*} else {
|
||||
Toasty.error(context, getString(R.string.genericError));
|
||||
}
|
||||
}*/
|
||||
|
||||
dismiss();
|
||||
}));
|
||||
|
@ -89,11 +93,15 @@ public class BottomSheetNotificationsFragment extends BottomSheetDialogFragment
|
|||
.markNotificationThreadAsRead(Authorization.get(context), notificationThread.getId(), "unread")
|
||||
.enqueue((SimpleCallback<Void>) (call, voidResponse) -> {
|
||||
|
||||
if(voidResponse.isPresent() && voidResponse.get().isSuccessful()) {
|
||||
onOptionSelectedListener.run();
|
||||
} else {
|
||||
// reload without any checks, because Gitea returns a 205 and Java expects this to be empty
|
||||
// but Gitea send a response -> results in a call of onFailure and no response is present
|
||||
// reload without any checks, because Gitea returns a 205 and Java expects this to be empty
|
||||
// but Gitea send a response -> results in a call of onFailure and no response is present
|
||||
//if(voidResponse.isPresent() && voidResponse.get().isSuccessful()) {
|
||||
onOptionSelectedListener.run();
|
||||
/*} else {
|
||||
Toasty.error(context, getString(R.string.genericError));
|
||||
}
|
||||
}*/
|
||||
|
||||
dismiss();
|
||||
}));
|
||||
|
|
|
@ -4,8 +4,6 @@ import android.app.Activity;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
@ -155,19 +153,20 @@ public class NotificationsFragment extends Fragment implements NotificationsAdap
|
|||
.enqueue((SimpleCallback<List<NotificationThread>>) (call1, listResponse) -> {
|
||||
|
||||
if(listResponse.isPresent() && listResponse.get().isSuccessful() && listResponse.get().body() != null) {
|
||||
System.out.println(listResponse.get().body());
|
||||
if(!append) {
|
||||
notificationThreads.clear();
|
||||
}
|
||||
|
||||
if(listResponse.get().body().size() > 0) {
|
||||
notificationThreads.addAll(listResponse.get().body());
|
||||
notificationsAdapter.notifyDataSetChanged();
|
||||
}
|
||||
else {
|
||||
notificationsAdapter.setMoreDataAvailable(false);
|
||||
}
|
||||
|
||||
if(!append || listResponse.get().body().size() > 0) {
|
||||
notificationsAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
AppUtil.setMultiVisibility(View.GONE, viewBinding.progressBar);
|
||||
|
@ -240,10 +239,12 @@ public class NotificationsFragment extends Fragment implements NotificationsAdap
|
|||
|
||||
if(notificationThread.isUnread() && !notificationThread.isPinned()) {
|
||||
RetrofitClient.getApiInterface(context).markNotificationThreadAsRead(Authorization.get(context), notificationThread.getId(), "read").enqueue((SimpleCallback<Void>) (call, voidResponse) -> {
|
||||
if(voidResponse.isPresent() && voidResponse.get().isSuccessful()) {
|
||||
pageCurrentIndex = 1;
|
||||
loadNotifications(false);
|
||||
}
|
||||
// reload without any checks, because Gitea returns a 205 and Java expects this to be empty
|
||||
// but Gitea send a response -> results in a call of onFailure and no response is present
|
||||
//if(voidResponse.isPresent() && voidResponse.get().isSuccessful()) {
|
||||
pageCurrentIndex = 1;
|
||||
loadNotifications(false);
|
||||
//}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue