SHOW:
|
|
- or go back to the newest paste.
1 | - | public void checkItem(ToDoItem item) { |
1 | + | private void refreshItemsFromTable() { |
2 | - | if (mClient == null) { |
2 | + | |
3 | - | return; |
3 | + | // Pobranie wszystkich zadań nie oznaczonych flagą 'completed' |
4 | - | } |
4 | + | // i dodanie ich do adaptera listy. |
5 | mToDoTable.where().field("complete").eq(val(false)).execute(new TableQueryCallback<ToDoItem>() { | |
6 | - | // Ustawienie flagi 'completed' i aktualizacja tabeli |
6 | + | |
7 | - | item.setComplete(true); |
7 | + | public void onCompleted(List<ToDoItem> result, int count, Exception exception, ServiceFilterResponse response) { |
8 | - | |
8 | + | |
9 | - | mToDoTable.update(item, new TableOperationCallback<ToDoItem>() { |
9 | + | mAdapter.clear(); |
10 | ||
11 | - | public void onCompleted(ToDoItem entity, Exception exception, ServiceFilterResponse response) { |
11 | + | for (ToDoItem item : result) { |
12 | mAdapter.add(item); | |
13 | - | if (entity.isComplete()) { |
13 | + | |
14 | - | mAdapter.remove(entity); |
14 | + | |
15 | } else { | |
16 | createAndShowDialog(exception, "Error"); | |
17 | } | |
18 | } | |
19 | }); | |
20 | } |