use of com.uwetrottmann.seriesguide.backend.lists.Lists in project SeriesGuide by UweTrottmann.
the class RemoveListItemTask method doBackgroundAction.
@Override
protected Integer doBackgroundAction(Void... params) {
if (isSendingToHexagon()) {
Lists listsService = getContext().getHexagonTools().getListsService();
if (listsService == null) {
// no longer signed in
return ERROR_HEXAGON_API;
}
// extract the list id of this list item
String[] splitListItemId = SeriesGuideContract.ListItems.splitListItemId(listItemId);
if (splitListItemId == null) {
return ERROR_DATABASE;
}
String removeFromListId = splitListItemId[2];
// send the item to be removed from hexagon
SgListList wrapper = new SgListList();
List<SgList> lists = buildListItemLists(removeFromListId, listItemId);
wrapper.setLists(lists);
try {
listsService.removeItems(wrapper).execute();
} catch (IOException e) {
HexagonTools.trackFailedRequest(getContext(), "remove list item", e);
return ERROR_HEXAGON_API;
}
}
// update local state
if (!doDatabaseUpdate()) {
return ERROR_DATABASE;
}
return SUCCESS;
}
use of com.uwetrottmann.seriesguide.backend.lists.Lists in project SeriesGuide by UweTrottmann.
the class ChangeListItemListsTask method doBackgroundAction.
@Override
protected Integer doBackgroundAction(Void... params) {
if (isSendingToHexagon()) {
Lists listsService = getContext().getHexagonTools().getListsService();
if (listsService == null) {
return ERROR_HEXAGON_API;
}
SgListList wrapper = new SgListList();
if (addToTheseLists.size() > 0) {
List<SgList> lists = buildListItemLists(addToTheseLists);
wrapper.setLists(lists);
try {
listsService.save(wrapper).execute();
} catch (IOException e) {
HexagonTools.trackFailedRequest(getContext(), "add list items", e);
return ERROR_HEXAGON_API;
}
}
if (removeFromTheseLists.size() > 0) {
List<SgList> lists = buildListItemLists(removeFromTheseLists);
wrapper.setLists(lists);
try {
listsService.removeItems(wrapper).execute();
} catch (IOException e) {
HexagonTools.trackFailedRequest(getContext(), "remove list items", e);
return ERROR_HEXAGON_API;
}
}
}
// update local state
if (!doDatabaseUpdate()) {
return ERROR_DATABASE;
}
return SUCCESS;
}
Aggregations