diff --git a/app/src/main/java/org/mian/gitnex/fragments/BottomSheetNotificationsFragment.java b/app/src/main/java/org/mian/gitnex/fragments/BottomSheetNotificationsFragment.java index a5c8ddde..ef8b2d51 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/BottomSheetNotificationsFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/BottomSheetNotificationsFragment.java @@ -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,9 @@ public class BottomSheetNotificationsFragment extends BottomSheetDialogFragment .markNotificationThreadAsRead(Authorization.get(context), notificationThread.getId(), "pinned") .enqueue((SimpleCallback) (call, voidResponse) -> { - if(voidResponse.isPresent() && voidResponse.get().isSuccessful()) { - onOptionSelectedListener.run(); - } else { - Toasty.error(context, getString(R.string.genericError)); - } + // 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 + onOptionSelectedListener.run(); dismiss(); })); @@ -75,11 +71,9 @@ public class BottomSheetNotificationsFragment extends BottomSheetDialogFragment .markNotificationThreadAsRead(Authorization.get(context), notificationThread.getId(), "read") .enqueue((SimpleCallback) (call, voidResponse) -> { - if(voidResponse.isPresent() && voidResponse.get().isSuccessful()) { - onOptionSelectedListener.run(); - } else { - Toasty.error(context, getString(R.string.genericError)); - } + // 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 + onOptionSelectedListener.run(); dismiss(); })); @@ -89,11 +83,9 @@ public class BottomSheetNotificationsFragment extends BottomSheetDialogFragment .markNotificationThreadAsRead(Authorization.get(context), notificationThread.getId(), "unread") .enqueue((SimpleCallback) (call, voidResponse) -> { - if(voidResponse.isPresent() && voidResponse.get().isSuccessful()) { - onOptionSelectedListener.run(); - } else { - Toasty.error(context, getString(R.string.genericError)); - } + // 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 + onOptionSelectedListener.run(); dismiss(); })); diff --git a/app/src/main/java/org/mian/gitnex/fragments/NotificationsFragment.java b/app/src/main/java/org/mian/gitnex/fragments/NotificationsFragment.java index e749f95f..4dc7a0ff 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/NotificationsFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/NotificationsFragment.java @@ -155,19 +155,20 @@ public class NotificationsFragment extends Fragment implements NotificationsAdap .enqueue((SimpleCallback>) (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 +241,10 @@ public class NotificationsFragment extends Fragment implements NotificationsAdap if(notificationThread.isUnread() && !notificationThread.isPinned()) { RetrofitClient.getApiInterface(context).markNotificationThreadAsRead(Authorization.get(context), notificationThread.getId(), "read").enqueue((SimpleCallback) (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 + pageCurrentIndex = 1; + loadNotifications(false); }); }