Refactored checking of empty task ids array into helper method

pull/14/head
Sam Bosley 12 years ago
parent 3f84d69e7a
commit 565e4adf54

@ -8,6 +8,7 @@ package com.todoroo.astrid.data;
import android.content.ContentValues; import android.content.ContentValues;
import android.net.Uri; import android.net.Uri;
import android.text.TextUtils;
import com.todoroo.andlib.data.AbstractModel; import com.todoroo.andlib.data.AbstractModel;
import com.todoroo.andlib.data.Property; import com.todoroo.andlib.data.Property;
@ -146,6 +147,10 @@ public final class TaskListMetadata extends RemoteModel {
return getUuidHelper(UUID); return getUuidHelper(UUID);
} }
public static boolean taskIdsIsEmpty(String taskIds) {
return TextUtils.isEmpty(taskIds) || "[]".equals(taskIds) || "[\"-1\"]".equals(taskIds) || "[-1]".equals(taskIds);
}
// --- parcelable helpers // --- parcelable helpers
public static final Creator<TaskListMetadata> CREATOR = new ModelCreator<TaskListMetadata>(TaskListMetadata.class); public static final Creator<TaskListMetadata> CREATOR = new ModelCreator<TaskListMetadata>(TaskListMetadata.class);

@ -5,8 +5,6 @@
*/ */
package com.todoroo.astrid.dao; package com.todoroo.astrid.dao;
import android.text.TextUtils;
import com.todoroo.andlib.data.Property; import com.todoroo.andlib.data.Property;
import com.todoroo.andlib.data.TodorooCursor; import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.service.Autowired; import com.todoroo.andlib.service.Autowired;
@ -40,10 +38,8 @@ public class TaskListMetadataDao extends RemoteModelDao<TaskListMetadata> {
if (TaskListMetadata.FILTER.name.equals(columnName) || TaskListMetadata.TAG_UUID.name.equals(columnName)) if (TaskListMetadata.FILTER.name.equals(columnName) || TaskListMetadata.TAG_UUID.name.equals(columnName))
return !RemoteModel.isUuidEmpty(value.toString()); return !RemoteModel.isUuidEmpty(value.toString());
if (TaskListMetadata.TASK_IDS.name.equals(columnName)) { if (TaskListMetadata.TASK_IDS.name.equals(columnName))
String valueString = value.toString(); return !TaskListMetadata.taskIdsIsEmpty(value.toString());
return !(TextUtils.isEmpty(valueString) || "[]".equals(valueString) || "[\"-1\"]".equals(valueString)); //$NON-NLS-1$//$NON-NLS-2$
}
return NameMaps.shouldRecordOutstandingColumnForTable(NameMaps.TABLE_ID_TASK_LIST_METADATA, columnName); return NameMaps.shouldRecordOutstandingColumnForTable(NameMaps.TABLE_ID_TASK_LIST_METADATA, columnName);
} }

Loading…
Cancel
Save