Save latest time user notification activity viewed

This commit is contained in:
neslihanturan 2018-09-09 21:36:43 +03:00
parent 714b22b733
commit a2be516bc5
3 changed files with 7 additions and 4 deletions

View file

@ -16,6 +16,7 @@ import android.widget.RelativeLayout;
import com.pedrogomez.renderers.RVRendererAdapter;
import java.util.Calendar;
import java.util.Collections;
import java.util.List;
@ -87,6 +88,11 @@ public class NotificationActivity extends NavigationBaseActivity {
private void addNotifications() {
Timber.d("Add notifications");
// Store when add notification is called last
long currentDate = Calendar.getInstance().getTime().getTime();
getSharedPreferences("prefs", MODE_PRIVATE).edit().putLong("last_read_notification_date", currentDate).apply();
Timber.d("Set last notification read date to current date:"+ currentDate);
if(mNotificationWorkerFragment == null){
Observable.fromCallable(() -> {
progressBar.setVisibility(View.VISIBLE);

View file

@ -2,7 +2,6 @@ package fr.free.nrw.commons.notification;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.inject.Inject;

View file

@ -59,7 +59,6 @@ public class UnreadNotificationsCheckAsync extends AsyncTask<Void, Void, List<No
} else {
// This case is not possible ever?
Log.d("deneme","You read all notifications");
Timber.d("You read all notifications of your at"+lastReadNotificationDateStored +"++curr date is:"+currentDate);
}
return unreadNotifications;
@ -73,8 +72,7 @@ public class UnreadNotificationsCheckAsync extends AsyncTask<Void, Void, List<No
if (context.get().getWindow().getDecorView().isShown() && !context.get().isFinishing()) {
// Check if fragment is not null and visible
if (context.get().isContributionsFragmentVisible && context.get().contributionsActivityPagerAdapter.contributionsFragment != null) {
//Log.d("deneme3","context.get().contributionsFragment"+((NewContributionsFragment)context.get().contributionsFragment).toString());
((ContributionsFragment)context.get().contributionsActivityPagerAdapter.contributionsFragment).updateNotificationsNotification(unreadNotification);
(context.get().contributionsActivityPagerAdapter.contributionsFragment).updateNotificationsNotification(unreadNotification);
}
}
}