Removed TODO, reimplemented delete repo.

This commit is contained in:
Peter Serwylo 2013-12-06 15:29:22 +11:00
parent 4fdc23569b
commit 41e0919c6f
2 changed files with 29 additions and 10 deletions

View File

@ -1,9 +0,0 @@
Highlight repo list items on check
Implement add/delete actions
Only allow delete when multiple items are selected (disable edit action)
Change text view to Delete repositories if multiple selected?
Create view to show repository details? Maybe this is for a subsequent patch...

View File

@ -186,13 +186,41 @@ public class ManageRepo extends ListActivity {
boolean wasChanged = data.getBooleanExtra(RepoDetailsActivity.ACTION_IS_CHANGED, false);
if (wasDeleted) {
refreshList();
int repoId = data.getIntExtra(RepoDetailsActivity.DATA_REPO_ID, 0);
remove(repoId);
} else if (wasEnabled || wasDisabled || wasChanged) {
changed = true;
}
}
}
private DB.Repo getRepoById(int repoId) {
for (int i = 0; i < getListAdapter().getCount(); i ++) {
DB.Repo repo = (DB.Repo)getListAdapter().getItem(i);
if (repo.id == repoId) {
return repo;
}
}
return null;
}
private void remove(int repoId) {
DB.Repo repo = getRepoById(repoId);
if (repo == null) {
return;
}
List<DB.Repo> reposToRemove = new ArrayList<DB.Repo>(1);
reposToRemove.add(repo);
try {
DB db = DB.getDB();
db.doDisableRepos(reposToRemove, true);
} finally {
DB.releaseDB();
}
refreshList();
}
protected List<Repo> getRepos() {
List<Repo> repos = null;
try {