Getting closer but it's still not really working

pull/14/head
Sam Bosley 11 years ago
parent 1c686eb533
commit 9d76225086

@ -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() {

@ -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

@ -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>(Task.class, null, tagData.getValue(TagData.TASKS_PUSHED_AT), BriefMe.TAG_ID_KEY, tagData.getUuid()), callback);
ActFmSyncThread.getInstance().enqueueMessage(new BriefMe<TagData>(TagData.class, tagData.getUuid(), tagData.getValue(TagData.PUSHED_AT)), callback);
ActFmSyncThread.getInstance().enqueueMessage(new BriefMe<UserActivity>(UserActivity.class, null, tagData.getValue(TagData.USER_ACTIVITIES_PUSHED_AT), BriefMe.TAG_ID_KEY, tagData.getUuid()), callback);
// ActFmSyncThread.getInstance().enqueueMessage(new BriefMe<UserActivity>(UserActivity.class, null, tagData.getValue(TagData.USER_ACTIVITIES_PUSHED_AT), BriefMe.TAG_ID_KEY, tagData.getUuid()), callback);
ActFmSyncThread.getInstance().enqueueMessage(new BriefMe<TaskListMetadata>(TaskListMetadata.class, null, tagData.getValue(TagData.METADATA_PUSHED_AT), BriefMe.TAG_ID_KEY, tagData.getUuid()), callback);
new FetchHistory<TagData>(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<TagData>(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();
}
}

@ -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);
}

Loading…
Cancel
Save