Set a 'record outstanding entry' flag based on user logged in state so we don't have to record outstanding entries when a user isn't logged in

pull/14/head
Sam Bosley 12 years ago
parent 6dded6fb06
commit f770046989

@ -13,6 +13,7 @@ import android.text.TextUtils;
import com.timsu.astrid.R;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.billing.BillingConstants;
import com.todoroo.astrid.dao.RemoteModelDao;
import com.todoroo.astrid.service.StatisticsConstants;
import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.sync.SyncProviderUtilities;
@ -54,6 +55,15 @@ public class ActFmPreferenceService extends SyncProviderUtilities {
// --- user management
@Override
public void setToken(String setting) {
super.setToken(setting);
if (TextUtils.isEmpty(setting))
RemoteModelDao.outstandingEntryFlag = -1;
else
RemoteModelDao.outstandingEntryFlag = 1;
}
/**
* @return get user id
*/

@ -10,6 +10,7 @@ import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.ExceptionService;
import com.todoroo.andlib.sql.Query;
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
import com.todoroo.astrid.dao.Database;
import com.todoroo.astrid.dao.HistoryDao;
import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
@ -101,6 +102,9 @@ public final class PluginServices {
@Autowired
TaskListMetadataOutstandingDao taskListMetadataOutstandingDao;
@Autowired
ActFmPreferenceService actFmPreferenceService;
private static volatile PluginServices instance;
static {
@ -204,6 +208,10 @@ public final class PluginServices {
return getInstance().taskListMetadataOutstandingDao;
}
public static ActFmPreferenceService getActFmPreferenceService() {
return getInstance().actFmPreferenceService;
}
// -- helpers
/**

@ -83,7 +83,8 @@ public class MetadataDao extends DatabaseDao<Metadata> {
((cv.containsKey(Metadata.KEY.name) &&
TaskToTagMetadata.KEY.equals(item.getValue(Metadata.KEY))) ||
(cv.containsKey(Metadata.DELETION_DATE.name) &&
item.getValue(Metadata.DELETION_DATE) > 0));
item.getValue(Metadata.DELETION_DATE) > 0)) &&
RemoteModelDao.getOutstandingEntryFlag();
}
@Override

@ -5,6 +5,7 @@ import com.todoroo.andlib.data.DatabaseDao;
import com.todoroo.andlib.data.Property;
import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.sql.Query;
import com.todoroo.astrid.core.PluginServices;
import com.todoroo.astrid.data.RemoteModel;
import com.todoroo.astrid.helper.UUIDHelper;
@ -29,7 +30,26 @@ public class RemoteModelDao<RTYPE extends RemoteModel> extends DatabaseDao<RTYPE
item.setValue(RemoteModel.UUID_PROPERTY, UUIDHelper.newUUID());
}
return super.createNew(item);
};
}
public static int outstandingEntryFlag = -1;
public static boolean getOutstandingEntryFlag() {
if (outstandingEntryFlag == -1) {
synchronized (RemoteModelDao.class) {
if (PluginServices.getActFmPreferenceService().isLoggedIn())
outstandingEntryFlag = 1;
else
outstandingEntryFlag = 0;
}
}
return outstandingEntryFlag > 0;
}
@Override
protected boolean shouldRecordOutstanding(RTYPE item) {
return super.shouldRecordOutstanding(item) && getOutstandingEntryFlag();
}
/**
* Fetch a model object by UUID

@ -77,7 +77,8 @@ public class TagMetadataDao extends DatabaseDao<TagMetadata> {
((cv.containsKey(TagMetadata.KEY.name) &&
TagMemberMetadata.KEY.equals(item.getValue(TagMetadata.KEY))) ||
(cv.containsKey(TagMetadata.DELETION_DATE.name) &&
item.getValue(TagMetadata.DELETION_DATE) > 0));
item.getValue(TagMetadata.DELETION_DATE) > 0)) &&
RemoteModelDao.getOutstandingEntryFlag();
}
@Override

Loading…
Cancel
Save