Search in sources :

Example 21 with Account

use of de.geeksfactory.opacclient.objects.Account in project opacclient by opacapp.

the class DrawerAccountsAdapter method setCurrentAccount.

public void setCurrentAccount(Account currentAccount) {
    if (this.currentAccount == null || currentAccount == this.currentAccount)
        return;
    this.currentAccount = currentAccount;
    accountsWithoutCurrent.clear();
    for (Account account : accounts) {
        if (account.getId() != this.currentAccount.getId()) {
            accountsWithoutCurrent.add(account);
        }
    }
    notifyDataSetChanged();
}
Also used : Account(de.geeksfactory.opacclient.objects.Account)

Example 22 with Account

use of de.geeksfactory.opacclient.objects.Account in project opacclient by opacapp.

the class BiBer1992AccountTest method testParseResList.

@Test
public void testParseResList() throws OpacApi.OpacErrorException, JSONException {
    String html = readResource("/biber1992/reslist/" + file);
    // we may not have all files for all libraries
    if (html == null)
        return;
    List<ReservedItem> media = BiBer1992.parseResList(new Account(), Jsoup.parse(html), new JSONObject(), reportHandler, new JSONObject(readResource("/biber1992/headers_reservations.json")));
    assertTrue(media.size() > 0);
}
Also used : Account(de.geeksfactory.opacclient.objects.Account) JSONObject(org.json.JSONObject) ReservedItem(de.geeksfactory.opacclient.objects.ReservedItem) Test(org.junit.Test)

Example 23 with Account

use of de.geeksfactory.opacclient.objects.Account in project opacclient by opacapp.

the class BiBer1992AccountTest method testParseMediaList.

@Test
public void testParseMediaList() throws OpacApi.OpacErrorException, JSONException {
    String html = readResource("/biber1992/medialist/" + file);
    // we may not have all files for all libraries
    if (html == null)
        return;
    List<LentItem> media = BiBer1992.parseMediaList(new AccountData(0), new Account(), Jsoup.parse(html), new JSONObject(), reportHandler, new JSONObject(readResource("/biber1992/headers_lent.json")));
    assertTrue(media.size() > 0);
    for (LentItem item : media) {
        assertNotNull(item.getDeadline());
        // sensible dates
        assertTrue(item.getDeadline().isAfter(new LocalDate(2010, 1, 1)));
        assertNotNull(item.getId());
    }
}
Also used : Account(de.geeksfactory.opacclient.objects.Account) JSONObject(org.json.JSONObject) AccountData(de.geeksfactory.opacclient.objects.AccountData) LentItem(de.geeksfactory.opacclient.objects.LentItem) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Example 24 with Account

use of de.geeksfactory.opacclient.objects.Account in project opacclient by opacapp.

the class BibliothecaAccountTest method testParseReservationList.

@Test
public void testParseReservationList() throws OpacApi.OpacErrorException, JSONException, NotReachableException {
    String html = readResource("/bibliotheca/account/" + file);
    // we may not have all files for all libraries
    if (html == null)
        return;
    if (file.equals("gladbeck.html") || file.equals("halle.html") || file.equals("albstadt.html") || file.equals("bernau.html"))
        return;
    AccountData data = Bibliotheca.parse_account(new Account(), Jsoup.parse(html), new JSONObject(), reportHandler, new JSONObject(readResource("/bibliotheca/headers_lent.json")), new JSONObject(readResource("/bibliotheca/headers_reservations.json")));
    assertTrue(data.getReservations().size() > 0);
    for (ReservedItem item : data.getReservations()) {
        assertContainsData(item.getTitle());
        assertNullOrNotEmpty(item.getAuthor());
    }
}
Also used : Account(de.geeksfactory.opacclient.objects.Account) JSONObject(org.json.JSONObject) AccountData(de.geeksfactory.opacclient.objects.AccountData) ReservedItem(de.geeksfactory.opacclient.objects.ReservedItem) Test(org.junit.Test)

Example 25 with Account

use of de.geeksfactory.opacclient.objects.Account in project opacclient by opacapp.

the class BibliothecaAccountTest method testParseMediaList.

@Test
public void testParseMediaList() throws OpacApi.OpacErrorException, JSONException, NotReachableException {
    String html = readResource("/bibliotheca/account/" + file);
    // we may not have all files for all libraries
    if (html == null)
        return;
    AccountData data = Bibliotheca.parse_account(new Account(), Jsoup.parse(html), new JSONObject(), reportHandler, new JSONObject(readResource("/bibliotheca/headers_lent.json")), new JSONObject(readResource("/bibliotheca/headers_reservations.json")));
    assertTrue(data.getLent().size() > 0);
    for (LentItem item : data.getLent()) {
        assertContainsData(item.getTitle());
        assertNullOrNotEmpty(item.getAuthor());
        assertNotNull(item.getProlongData());
        assertNotNull(item.getDeadline());
    }
}
Also used : Account(de.geeksfactory.opacclient.objects.Account) JSONObject(org.json.JSONObject) AccountData(de.geeksfactory.opacclient.objects.AccountData) LentItem(de.geeksfactory.opacclient.objects.LentItem) Test(org.junit.Test)

Aggregations

Account (de.geeksfactory.opacclient.objects.Account)25 AccountDataSource (de.geeksfactory.opacclient.storage.AccountDataSource)8 View (android.view.View)6 TextView (android.widget.TextView)6 Cursor (android.database.Cursor)5 ImageView (android.widget.ImageView)5 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)5 DialogInterface (android.content.DialogInterface)4 Intent (android.content.Intent)4 AlertDialog (android.support.v7.app.AlertDialog)4 LayoutInflater (android.view.LayoutInflater)4 AdapterView (android.widget.AdapterView)4 ListView (android.widget.ListView)4 OpacClient (de.geeksfactory.opacclient.OpacClient)4 AccountData (de.geeksfactory.opacclient.objects.AccountData)4 JSONObject (org.json.JSONObject)4 SuppressLint (android.annotation.SuppressLint)3 SharedPreferences (android.content.SharedPreferences)3 RecyclerView (android.support.v7.widget.RecyclerView)3