From 636c2f266e4aa5a5c98404f920b268719def3eea Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 9 Mar 2017 17:03:13 +0100 Subject: [PATCH] Dismiss notifications when notifications fragment is opened --- .../com/keylesspalace/tusky/NotificationsFragment.java | 9 +++++++++ .../com/keylesspalace/tusky/PullNotificationService.java | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/NotificationsFragment.java b/app/src/main/java/com/keylesspalace/tusky/NotificationsFragment.java index e6350e4b..5e0f3f20 100644 --- a/app/src/main/java/com/keylesspalace/tusky/NotificationsFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/NotificationsFragment.java @@ -15,6 +15,7 @@ package com.keylesspalace.tusky; +import android.app.NotificationManager; import android.content.Context; import android.graphics.drawable.Drawable; import android.os.Bundle; @@ -70,6 +71,14 @@ public class NotificationsFragment extends SFragment implements super.onDestroy(); } + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + NotificationManager notificationManager = + (NotificationManager) getActivity().getSystemService(Context.NOTIFICATION_SERVICE); + notificationManager.cancel(PullNotificationService.NOTIFY_ID); + super.onCreate(savedInstanceState); + } + @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, diff --git a/app/src/main/java/com/keylesspalace/tusky/PullNotificationService.java b/app/src/main/java/com/keylesspalace/tusky/PullNotificationService.java index 292cc2cd..f3be9f6d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/PullNotificationService.java +++ b/app/src/main/java/com/keylesspalace/tusky/PullNotificationService.java @@ -57,7 +57,7 @@ import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; public class PullNotificationService extends IntentService { - private static final int NOTIFY_ID = 6; // This is an arbitrary number. + static final int NOTIFY_ID = 6; // This is an arbitrary number. private static final String TAG = "PullNotifications"; // logging tag and Volley request tag public PullNotificationService() {