From c277c50c7e62244025ddac516cda62c9e31405aa Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Fri, 17 Feb 2012 14:02:29 -0800 Subject: [PATCH] Fixed issues with comment count consistency: --- .../com/todoroo/astrid/actfm/TagUpdatesFragment.java | 11 ++++++++++- .../com/todoroo/astrid/actfm/TagViewFragment.java | 5 +++++ .../com/todoroo/astrid/activity/TaskListActivity.java | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/TagUpdatesFragment.java b/astrid/plugin-src/com/todoroo/astrid/actfm/TagUpdatesFragment.java index adf0d05cb..90f50073d 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/TagUpdatesFragment.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/TagUpdatesFragment.java @@ -1,5 +1,6 @@ package com.todoroo.astrid.actfm; +import android.app.Activity; import android.content.Intent; import android.database.Cursor; import android.graphics.Bitmap; @@ -36,6 +37,7 @@ import com.todoroo.astrid.actfm.ActFmCameraModule.ClearImageCallback; import com.todoroo.astrid.actfm.sync.ActFmPreferenceService; import com.todoroo.astrid.actfm.sync.ActFmSyncService; import com.todoroo.astrid.activity.AstridActivity; +import com.todoroo.astrid.activity.TaskListActivity; import com.todoroo.astrid.adapter.UpdateAdapter; import com.todoroo.astrid.dao.UpdateDao; import com.todoroo.astrid.data.TagData; @@ -198,9 +200,16 @@ public class TagUpdatesFragment extends ListFragment { cursor.requery(); getActivity().startManagingCursor(cursor); } + if (getActivity() instanceof TagUpdatesActivity) + setLastViewed(); + } - if(tagData != null && tagData.getValue(Task.REMOTE_ID) <= 0) { + public void setLastViewed() { + if(tagData != null && tagData.getValue(Task.REMOTE_ID) > 0) { Preferences.setLong(UPDATES_LAST_VIEWED + tagData.getValue(TagData.REMOTE_ID), DateUtilities.now()); + Activity activity = getActivity(); + if (activity instanceof TaskListActivity) + ((TaskListActivity) activity).setCommentsCount(0); } } diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewFragment.java b/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewFragment.java index 845715fc5..cbffc6d49 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewFragment.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewFragment.java @@ -230,6 +230,10 @@ public class TagViewFragment extends TaskListFragment { tagDataService.save(tagData); } + updateCommentCount(); + } + + private void updateCommentCount() { if (tagData != null) { long lastViewedComments = Preferences.getLong(TagUpdatesFragment.UPDATES_LAST_VIEWED + tagData.getValue(TagData.REMOTE_ID), 0); int unreadCount = 0; @@ -441,6 +445,7 @@ public class TagViewFragment extends TaskListFragment { getActivity().registerReceiver(notifyReceiver, intentFilter); showListSettingsPopover(); + updateCommentCount(); } @Override diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java index a6ee7d16e..413040b19 100644 --- a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java @@ -84,6 +84,7 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener if (frag != null) { setupPopoverWithFragment(commentsPopover, frag, null); commentsPopover.show(listsNav); + frag.setLastViewed(); } } else { // In this case we should be in LAYOUT_SINGLE--delegate to the task list fragment