Search in sources :

Example 6 with Starred

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;
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) Starred(de.geeksfactory.opacclient.objects.Starred) StarDataSource(de.geeksfactory.opacclient.storage.StarDataSource)

Example 7 with 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;
}
Also used : Cursor(android.database.Cursor) Starred(de.geeksfactory.opacclient.objects.Starred)

Example 8 with Starred

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;
}
Also used : ArrayList(java.util.ArrayList) Starred(de.geeksfactory.opacclient.objects.Starred) Cursor(android.database.Cursor)

Aggregations

Starred (de.geeksfactory.opacclient.objects.Starred)8 Cursor (android.database.Cursor)4 StarDataSource (de.geeksfactory.opacclient.storage.StarDataSource)2 ArrayList (java.util.ArrayList)2 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 View (android.view.View)1 AbsListView (android.widget.AbsListView)1 AdapterView (android.widget.AdapterView)1 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 OpacClient (de.geeksfactory.opacclient.OpacClient)1 SearchField (de.geeksfactory.opacclient.searchfields.SearchField)1 SearchQuery (de.geeksfactory.opacclient.searchfields.SearchQuery)1 JsonSearchFieldDataSource (de.geeksfactory.opacclient.storage.JsonSearchFieldDataSource)1 List (java.util.List)1 JSONArray (org.json.JSONArray)1 JSONException (org.json.JSONException)1