Fix activity leak

pull/437/head
Alex Baker 8 years ago
parent 4ba4ce9ba4
commit 8c7b690059

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

@ -1,5 +0,0 @@
package com.todoroo.astrid.dao;
public interface DatabaseUpdateListener {
void onDatabaseUpdated();
}

@ -14,9 +14,6 @@ import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.astrid.activity.TaskListActivity; import com.todoroo.astrid.activity.TaskListActivity;
import com.todoroo.astrid.backup.TasksXmlImporter; import com.todoroo.astrid.backup.TasksXmlImporter;
import com.todoroo.astrid.dao.Database; import com.todoroo.astrid.dao.Database;
import com.todoroo.astrid.dao.DatabaseUpdateListener;
import com.todoroo.astrid.provider.Astrid2TaskProvider;
import com.todoroo.astrid.provider.Astrid3ContentProvider;
import org.tasks.Broadcaster; import org.tasks.Broadcaster;
import org.tasks.BuildConfig; import org.tasks.BuildConfig;
@ -71,14 +68,6 @@ public class StartupService {
return; return;
} }
database.addListener(new DatabaseUpdateListener() {
@Override
public void onDatabaseUpdated() {
Astrid2TaskProvider.notifyDatabaseModification(activity);
Astrid3ContentProvider.notifyDatabaseModification(activity);
}
});
try { try {
database.openForWriting(); database.openForWriting();
} catch (SQLiteException e) { } catch (SQLiteException e) {

Loading…
Cancel
Save