Now updating the task notes appearance setting clears the cache

pull/14/head
Tim Su 14 years ago
parent 13e69cc004
commit 211819b21a

@ -84,7 +84,8 @@ public final class ProducteevDataService {
metadataService.deleteWhere(Metadata.KEY.eq(ProducteevTask.METADATA_KEY)); metadataService.deleteWhere(Metadata.KEY.eq(ProducteevTask.METADATA_KEY));
metadataService.deleteWhere(Metadata.KEY.eq(ProducteevNote.METADATA_KEY)); metadataService.deleteWhere(Metadata.KEY.eq(ProducteevNote.METADATA_KEY));
storeObjectDao.deleteWhere(StoreObject.TYPE.eq(ProducteevDashboard.TYPE)); storeObjectDao.deleteWhere(StoreObject.TYPE.eq(ProducteevDashboard.TYPE));
PluginServices.getTaskService().clearDetails(); PluginServices.getTaskService().clearDetails(Task.ID.in(Query.select(Metadata.TASK).from(Metadata.TABLE).
where(MetadataCriteria.withKey(ProducteevTask.METADATA_KEY))));
} }
/** /**

@ -14,9 +14,9 @@ import android.content.pm.ResolveInfo;
import android.content.res.Resources; import android.content.res.Resources;
import android.os.Bundle; import android.os.Bundle;
import android.preference.Preference; import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceCategory; import android.preference.PreferenceCategory;
import android.preference.PreferenceScreen; import android.preference.PreferenceScreen;
import android.preference.Preference.OnPreferenceClickListener;
import android.widget.Toast; import android.widget.Toast;
import com.timsu.astrid.R; import com.timsu.astrid.R;
@ -140,7 +140,7 @@ public class EditPreferences extends TodorooPreferences {
preference.setOnPreferenceClickListener(new OnPreferenceClickListener() { preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference p) { public boolean onPreferenceClick(Preference p) {
database.openForWriting(); database.openForWriting();
Toast.makeText(EditPreferences.this, "" + taskService.clearDetails(), Toast.makeText(EditPreferences.this, "" + taskService.clearDetails(Criterion.all),
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG).show();
return false; return false;
} }
@ -186,10 +186,12 @@ public class EditPreferences extends TodorooPreferences {
preference.setSummary(R.string.EPr_showNotes_desc_disabled); preference.setSummary(R.string.EPr_showNotes_desc_disabled);
else else
preference.setSummary(R.string.EPr_showNotes_desc_enabled); preference.setSummary(R.string.EPr_showNotes_desc_enabled);
if((Boolean)value != Preferences.getBoolean(preference.getKey(), false)) if((Boolean)value != Preferences.getBoolean(preference.getKey(), false)) {
taskService.clearDetails(Task.NOTES.neq(""));
Flags.set(Flags.REFRESH); Flags.set(Flags.REFRESH);
} }
} }
}
} }

@ -6,6 +6,7 @@ import android.content.Intent;
import com.todoroo.andlib.service.Autowired; import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService; import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.utility.Flags; import com.todoroo.astrid.utility.Flags;
@ -33,7 +34,7 @@ public final class GlobalEventReceiver extends BroadcastReceiver {
DependencyInjectionService.getInstance().inject(this); DependencyInjectionService.getInstance().inject(this);
if(AstridApiConstants.BROADCAST_EVENT_FLUSH_DETAILS.equals(intent.getAction())) { if(AstridApiConstants.BROADCAST_EVENT_FLUSH_DETAILS.equals(intent.getAction())) {
taskService.clearDetails(); taskService.clearDetails(Criterion.all);
Flags.set(Flags.REFRESH); Flags.set(Flags.REFRESH);
} }
} }

@ -14,8 +14,8 @@ import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.PermaSql; import com.todoroo.astrid.api.PermaSql;
import com.todoroo.astrid.dao.MetadataDao; import com.todoroo.astrid.dao.MetadataDao;
import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
import com.todoroo.astrid.dao.TaskDao; import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
import com.todoroo.astrid.dao.TaskDao.TaskCriteria; import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
@ -226,13 +226,14 @@ public class TaskService {
/** /**
* Clear details cache. Useful if user performs some operation that * Clear details cache. Useful if user performs some operation that
* affects details * affects details
* @param criterion
* *
* @return # of affected rows * @return # of affected rows
*/ */
public int clearDetails() { public int clearDetails(Criterion criterion) {
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
values.put(Task.DETAILS.name, (String) null); values.put(Task.DETAILS.name, (String) null);
return taskDao.updateMultiple(values, Criterion.all); return taskDao.updateMultiple(values, criterion);
} }
/** /**

Loading…
Cancel
Save