|
|
@ -26,12 +26,12 @@ import com.todoroo.astrid.data.Task;
|
|
|
|
import com.todoroo.astrid.data.TaskAttachment;
|
|
|
|
import com.todoroo.astrid.data.TaskAttachment;
|
|
|
|
import com.todoroo.astrid.data.TaskListMetadata;
|
|
|
|
import com.todoroo.astrid.data.TaskListMetadata;
|
|
|
|
import com.todoroo.astrid.data.UserActivity;
|
|
|
|
import com.todoroo.astrid.data.UserActivity;
|
|
|
|
|
|
|
|
import com.todoroo.astrid.provider.Astrid2TaskProvider;
|
|
|
|
|
|
|
|
import com.todoroo.astrid.provider.Astrid3ContentProvider;
|
|
|
|
|
|
|
|
|
|
|
|
import org.tasks.analytics.Tracker;
|
|
|
|
import org.tasks.analytics.Tracker;
|
|
|
|
import org.tasks.injection.ForApplication;
|
|
|
|
import org.tasks.injection.ForApplication;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.inject.Inject;
|
|
|
|
import javax.inject.Inject;
|
|
|
|
import javax.inject.Singleton;
|
|
|
|
import javax.inject.Singleton;
|
|
|
|
|
|
|
|
|
|
|
@ -58,8 +58,8 @@ public class Database {
|
|
|
|
TaskListMetadata.TABLE,
|
|
|
|
TaskListMetadata.TABLE,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
private final ArrayList<DatabaseUpdateListener> listeners = new ArrayList<>();
|
|
|
|
|
|
|
|
private final SQLiteOpenHelper helper;
|
|
|
|
private final SQLiteOpenHelper helper;
|
|
|
|
|
|
|
|
private final Context context;
|
|
|
|
private final Tracker tracker;
|
|
|
|
private final Tracker tracker;
|
|
|
|
private SQLiteDatabase database;
|
|
|
|
private SQLiteDatabase database;
|
|
|
|
|
|
|
|
|
|
|
@ -67,6 +67,7 @@ public class Database {
|
|
|
|
|
|
|
|
|
|
|
|
@Inject
|
|
|
|
@Inject
|
|
|
|
public Database(@ForApplication Context context, Tracker tracker) {
|
|
|
|
public Database(@ForApplication Context context, Tracker tracker) {
|
|
|
|
|
|
|
|
this.context = context;
|
|
|
|
this.tracker = tracker;
|
|
|
|
this.tracker = tracker;
|
|
|
|
helper = new DatabaseHelper(context, getName(), VERSION);
|
|
|
|
helper = new DatabaseHelper(context, getName(), VERSION);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -179,14 +180,9 @@ public class Database {
|
|
|
|
return sql.toString();
|
|
|
|
return sql.toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void addListener(DatabaseUpdateListener listener) {
|
|
|
|
|
|
|
|
listeners.add(listener);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void onDatabaseUpdated() {
|
|
|
|
private void onDatabaseUpdated() {
|
|
|
|
for(DatabaseUpdateListener listener : listeners) {
|
|
|
|
Astrid2TaskProvider.notifyDatabaseModification(context);
|
|
|
|
listener.onDatabaseUpdated();
|
|
|
|
Astrid3ContentProvider.notifyDatabaseModification(context);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|