use of de.geeksfactory.opacclient.objects.Starred in project opacclient by opacapp.
the class StarredFragment method getEncodedStarredObjects.
private JSONObject getEncodedStarredObjects() {
JSONObject starred = new JSONObject();
try {
starred.put(JSON_LIBRARY_NAME, app.getLibrary().getIdent());
JSONArray items = new JSONArray();
StarDataSource data = new StarDataSource(getActivity());
List<Starred> libItems = data.getAllItems(app.getLibrary().getIdent());
for (Starred libItem : libItems) {
JSONObject item = new JSONObject();
item.put(JSON_ITEM_MNR, libItem.getMNr());
item.put(JSON_ITEM_TITLE, libItem.getTitle());
item.put(JSON_ITEM_MEDIATYPE, libItem.getMediaType());
items.put(item);
}
starred.put(JSON_STARRED_LIST, items);
} catch (JSONException e) {
showExportError();
}
return starred;
}
use of de.geeksfactory.opacclient.objects.Starred in project opacclient by opacapp.
the class StarDataSource method getItem.
public Starred getItem(long id) {
String[] selA = { String.valueOf(id) };
Cursor cursor = context.getContentResolver().query(((OpacClient) context.getApplication()).getStarProviderStarUri(), StarDatabase.COLUMNS, StarDatabase.STAR_WHERE_ID, selA, null);
Starred item = null;
cursor.moveToFirst();
if (!cursor.isAfterLast()) {
item = cursorToItem(cursor);
cursor.moveToNext();
}
// Make sure to close the cursor
cursor.close();
return item;
}
use of de.geeksfactory.opacclient.objects.Starred in project opacclient by opacapp.
the class StarDataSource method getAllItems.
public List<Starred> getAllItems(String bib) {
List<Starred> items = new ArrayList<>();
String[] selA = { bib };
Cursor cursor = context.getContentResolver().query(((OpacClient) context.getApplication()).getStarProviderStarUri(), StarDatabase.COLUMNS, StarDatabase.STAR_WHERE_LIB, selA, null);
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
Starred item = cursorToItem(cursor);
items.add(item);
cursor.moveToNext();
}
// Make sure to close the cursor
cursor.close();
return items;
}
Aggregations