diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/CommentsFragment.java b/astrid/plugin-src/com/todoroo/astrid/actfm/CommentsFragment.java index 978204729..347c18425 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/CommentsFragment.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/CommentsFragment.java @@ -47,6 +47,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.actfm.sync.ActFmSyncThread.SyncMessageCallback; +import com.todoroo.astrid.actfm.sync.messages.NameMaps; import com.todoroo.astrid.activity.AstridActivity; import com.todoroo.astrid.activity.TaskListActivity; import com.todoroo.astrid.adapter.UpdateAdapter; @@ -240,11 +241,19 @@ public abstract class CommentsFragment extends SherlockListFragment { updateAdapter = new UpdateAdapter(this, R.layout.update_adapter_row, cursor, false, source); addHeaderToListView(listView); + addFooterToListView(listView); listView.setAdapter(updateAdapter); } else { cursor = updateAdapter.getCursor(); cursor.requery(); activity.startManagingCursor(cursor); + if (footerView != null && !canLoadMoreHistory()) { + listView.removeFooterView(footerView); + footerView = null; + } else if (footerView == null && canLoadMoreHistory()) { + addFooterToListView(listView); + listView.setAdapter(updateAdapter); + } populateListHeader(listHeader); } @@ -276,19 +285,32 @@ public abstract class CommentsFragment extends SherlockListFragment { if (activity instanceof CommentsActivity) setLastViewed(); + } + + private void addFooterToListView(ListView listView) { if (footerView != null) { listView.removeFooterView(footerView); - if (canLoadMoreHistory()) { - footerView = new Button(getActivity()); - footerView.setText(R.string.TEA_load_more); - footerView.setBackgroundColor(Color.alpha(0)); - footerView.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - loadMoreHistory(0, doneRunnable); + } + if (canLoadMoreHistory()) { + footerView = new Button(getActivity()); + footerView.setText(R.string.TEA_load_more); + footerView.setBackgroundColor(Color.alpha(0)); + footerView.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + int historyCount = 0; + Cursor c = updateAdapter.getCursor(); + for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) { + if (NameMaps.TABLE_ID_HISTORY.equals(c.getString(UpdateAdapter.TYPE_PROPERTY_INDEX))) + historyCount++; } - }); - } + loadMoreHistory(historyCount, doneRunnable); + } + }); + listView.addFooterView(footerView); + } else { + footerView = null; } + } protected void setLastViewed() { diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/TagCommentsFragment.java b/astrid/plugin-src/com/todoroo/astrid/actfm/TagCommentsFragment.java index 7de1e3c6b..1769d7f1b 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/TagCommentsFragment.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/TagCommentsFragment.java @@ -64,8 +64,11 @@ public class TagCommentsFragment extends CommentsFragment { @Override protected void loadModelFromIntent(Intent intent) { - if (tagData == null) - tagData = intent.getParcelableExtra(TagViewFragment.EXTRA_TAG_DATA); + if (tagData == null) { + long id = intent.getLongExtra(TagViewFragment.EXTRA_TAG_DATA, 0); + if (id > 0) + tagData = tagDataService.fetchById(id, TagData.PROPERTIES); + } } @Override diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewFragment.java b/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewFragment.java index 1628abd16..727d7212a 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewFragment.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewFragment.java @@ -51,8 +51,6 @@ import com.todoroo.astrid.actfm.sync.ActFmSyncService; import com.todoroo.astrid.actfm.sync.ActFmSyncThread; import com.todoroo.astrid.actfm.sync.ActFmSyncThread.SyncMessageCallback; import com.todoroo.astrid.actfm.sync.messages.BriefMe; -import com.todoroo.astrid.actfm.sync.messages.FetchHistory; -import com.todoroo.astrid.actfm.sync.messages.NameMaps; import com.todoroo.astrid.activity.AstridActivity; import com.todoroo.astrid.activity.FilterListFragment; import com.todoroo.astrid.activity.TaskListActivity; @@ -454,10 +452,10 @@ public class TagViewFragment extends TaskListFragment { ActFmSyncThread.getInstance().repopulateQueueFromOutstandingTables(); ActFmSyncThread.getInstance().enqueueMessage(new BriefMe(Task.class, null, tagData.getValue(TagData.TASKS_PUSHED_AT), BriefMe.TAG_ID_KEY, tagData.getUuid()), callback); ActFmSyncThread.getInstance().enqueueMessage(new BriefMe(TagData.class, tagData.getUuid(), tagData.getValue(TagData.PUSHED_AT)), callback); - ActFmSyncThread.getInstance().enqueueMessage(new BriefMe(UserActivity.class, null, tagData.getValue(TagData.USER_ACTIVITIES_PUSHED_AT), BriefMe.TAG_ID_KEY, tagData.getUuid()), callback); +// ActFmSyncThread.getInstance().enqueueMessage(new BriefMe(UserActivity.class, null, tagData.getValue(TagData.USER_ACTIVITIES_PUSHED_AT), BriefMe.TAG_ID_KEY, tagData.getUuid()), callback); ActFmSyncThread.getInstance().enqueueMessage(new BriefMe(TaskListMetadata.class, null, tagData.getValue(TagData.METADATA_PUSHED_AT), BriefMe.TAG_ID_KEY, tagData.getUuid()), callback); - new FetchHistory(tagDataDao, TagData.HISTORY_FETCH_DATE, TagData.HISTORY_HAS_MORE, NameMaps.TABLE_ID_TAGS, - tagData.getUuid(), null, tagData.getValue(TagData.HISTORY_FETCH_DATE), 0, true, null).execute(); +// new FetchHistory(tagDataDao, TagData.HISTORY_FETCH_DATE, TagData.HISTORY_HAS_MORE, NameMaps.TABLE_ID_TAGS, +// tagData.getUuid(), null, tagData.getValue(TagData.HISTORY_FETCH_DATE), 0, true, null).execute(); } } diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java b/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java index bc92e689f..9b8aa4d6b 100644 --- a/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java @@ -1165,7 +1165,11 @@ public class TaskListFragment extends SherlockListFragment implements OnScrollLi Activity activity = getActivity(); if (activity != null) { Intent intent = new Intent(activity, CommentsActivity.class); - intent.putExtra(TagViewFragment.EXTRA_TAG_DATA, getActiveTagData()); + long id = 0; + TagData td = getActiveTagData(); + if (td != null) + id = td.getId(); + intent.putExtra(TagViewFragment.EXTRA_TAG_DATA, id); startActivity(intent); AndroidUtilities.callOverridePendingTransition(activity, R.anim.slide_left_in, R.anim.slide_left_out); }