From 3d3b22511096e5991b601d486b0dc62fcf24297d Mon Sep 17 00:00:00 2001 From: kenstir Date: Mon, 16 Dec 2013 20:43:59 -0500 Subject: [PATCH] * Fixed a NPE seen once when coercing results of getItemsCheckedOut(). * Make getItemsCheckedOut() sort by due date. * Fixed a situation where session was non-null but was not valid; force reload of session in LoadingTask --- .../Android/core/res/layout/search_result_list.xml | 2 +- Open-ILS/src/Android/core/res/values/strings.xml | 4 +- .../android/accountAccess/AccountAccess.java | 86 ++++++++-------------- .../searchCatalog/AdvancedSearchActivity.java | 1 - .../searchCatalog/SearchCatalogListView.java | 2 - .../android/views/splashscreen/LoadingTask.java | 4 +- 6 files changed, 34 insertions(+), 65 deletions(-) diff --git a/Open-ILS/src/Android/core/res/layout/search_result_list.xml b/Open-ILS/src/Android/core/res/layout/search_result_list.xml index f4be2ebfb5..bc82ae2a84 100644 --- a/Open-ILS/src/Android/core/res/layout/search_result_list.xml +++ b/Open-ILS/src/Android/core/res/layout/search_result_list.xml @@ -56,7 +56,7 @@ android:layout_width="fill_parent" android:layout_height="wrap_content" android:hint="@string/search_hint" - android:singleLine="true" /> + android:singleLine="true"/> - Browse catalog + Library catalog Search keywords Advanced Search @@ -102,7 +102,7 @@ delete name - no items + items shared action details diff --git a/Open-ILS/src/Android/core/src/org/evergreen/android/accountAccess/AccountAccess.java b/Open-ILS/src/Android/core/src/org/evergreen/android/accountAccess/AccountAccess.java index 7d48cb5fa7..b6e62983f2 100644 --- a/Open-ILS/src/Android/core/src/org/evergreen/android/accountAccess/AccountAccess.java +++ b/Open-ILS/src/Android/core/src/org/evergreen/android/accountAccess/AccountAccess.java @@ -22,10 +22,7 @@ package org.evergreen.android.accountAccess; import java.io.IOException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import android.accounts.*; import android.app.Activity; @@ -323,9 +320,9 @@ public class AccountAccess { * Retrieve session. * @throws SessionNotFoundException */ - public boolean retrieveSession(String auth_token) throws SessionNotFoundException { + public boolean retrieveSession(String auth_token, boolean force) throws SessionNotFoundException { - if (this.haveSession && this.authToken.equals(auth_token)) + if (!force && this.haveSession && this.authToken.equals(auth_token)) return true; this.haveSession = false; this.authToken = auth_token; @@ -365,7 +362,7 @@ public class AccountAccess { final String new_authToken = b.getString(AccountManager.KEY_AUTHTOKEN); if (TextUtils.isEmpty(new_authToken)) return false; - return retrieveSession(new_authToken); + return retrieveSession(new_authToken, true); } // ------------------------Checked Out Items Section @@ -376,79 +373,54 @@ public class AccountAccess { * * @return the items checked out * @throws SessionNotFoundException the session not found exception - * @throws NoNetworkAccessException the no network access exception - * @throws NoAccessToServer the no access to server */ public ArrayList getItemsCheckedOut() throws SessionNotFoundException { ArrayList circRecords = new ArrayList(); - /* - * ArrayList long_overdue = new ArrayList(); - * ArrayList claims_returned = new ArrayList(); - * ArrayList lost = new ArrayList(); - * ArrayList out = new ArrayList(); - * ArrayList overdue = new ArrayList(); - */ - - // fetch ids - List long_overdue_id; - List overdue_id; - List claims_returned_id; - List lost_id; - List out_id; Object resp = Utils.doRequest(conn, SERVICE_ACTOR, METHOD_FETCH_CHECKED_OUT_SUM, authToken, new Object[] { authToken, userID }); + if (resp == null) + return circRecords; + Map resp_map = ((Map) resp); - long_overdue_id = (List) ((Map) resp) - .get("long_overdue"); - claims_returned_id = (List) ((Map) resp) - .get("claims_returned"); - lost_id = (List) ((Map) resp).get("lost"); - out_id = (List) ((Map) resp).get("out"); - overdue_id = (List) ((Map) resp).get("overdue"); - - // get all the record circ info - if (out_id != null) + if (resp_map.get("out") != null) { + List out_id = (List) resp_map.get("out"); for (int i = 0; i < out_id.size(); i++) { - // get circ OSRFObject circ = retrieveCircRecord(out_id.get(i)); CircRecord circRecord = new CircRecord(circ, CircRecord.OUT, Integer.parseInt(out_id.get(i))); - // get info - fetchInfoForCheckedOutItem(circ.getInt("target_copy"), - circRecord); + fetchInfoForCheckedOutItem(circ.getInt("target_copy"), circRecord); circRecords.add(circRecord); - - // Log.d(TAG, out.get(i).get("target_copy")); - // fetchInfoForCheckedOutItem(out.get(i).get("target_copy")+""); } + } - if (overdue_id != null) + if (resp_map.get("overdue") != null) { + List overdue_id = (List) resp_map.get("overdue"); for (int i = 0; i < overdue_id.size(); i++) { - // get circ OSRFObject circ = retrieveCircRecord(overdue_id.get(i)); - CircRecord circRecord = new CircRecord(circ, - CircRecord.OVERDUE, Integer.parseInt(overdue_id.get(i))); - // fetch info - fetchInfoForCheckedOutItem(circ.getInt("target_copy"), - circRecord); + CircRecord circRecord = new CircRecord(circ, CircRecord.OVERDUE, + Integer.parseInt(overdue_id.get(i))); + fetchInfoForCheckedOutItem(circ.getInt("target_copy"), circRecord); circRecords.add(circRecord); - } + } + // TODO are we using this too? In the opac they are not used /* - * for(int i=0;i() { + @Override + public int compare(CircRecord lhs, CircRecord rhs) { + return lhs.getDueDate().compareTo(rhs.getDueDate()); + } + }); return circRecords; } diff --git a/Open-ILS/src/Android/core/src/org/evergreen/android/searchCatalog/AdvancedSearchActivity.java b/Open-ILS/src/Android/core/src/org/evergreen/android/searchCatalog/AdvancedSearchActivity.java index 61d251d5b1..d0f8236e16 100644 --- a/Open-ILS/src/Android/core/src/org/evergreen/android/searchCatalog/AdvancedSearchActivity.java +++ b/Open-ILS/src/Android/core/src/org/evergreen/android/searchCatalog/AdvancedSearchActivity.java @@ -71,7 +71,6 @@ public class AdvancedSearchActivity extends Activity { // header portion actions myAccountButton = (Button) findViewById(R.id.my_account_button); - myAccountButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { diff --git a/Open-ILS/src/Android/core/src/org/evergreen/android/searchCatalog/SearchCatalogListView.java b/Open-ILS/src/Android/core/src/org/evergreen/android/searchCatalog/SearchCatalogListView.java index 00a16424da..cafda04efa 100644 --- a/Open-ILS/src/Android/core/src/org/evergreen/android/searchCatalog/SearchCatalogListView.java +++ b/Open-ILS/src/Android/core/src/org/evergreen/android/searchCatalog/SearchCatalogListView.java @@ -163,7 +163,6 @@ public class SearchCatalogListView extends Activity { // end header portion actions advancedSearchButton = (Button) findViewById(R.id.menu_advanced_search_button); - advancedSearchButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { @@ -239,7 +238,6 @@ public class SearchCatalogListView extends Activity { public void run() { final String text = searchText.getText().toString(); - if (text.length() < 1) return; diff --git a/Open-ILS/src/Android/core/src/org/evergreen/android/views/splashscreen/LoadingTask.java b/Open-ILS/src/Android/core/src/org/evergreen/android/views/splashscreen/LoadingTask.java index f27c4d324c..96a6cd4bb6 100644 --- a/Open-ILS/src/Android/core/src/org/evergreen/android/views/splashscreen/LoadingTask.java +++ b/Open-ILS/src/Android/core/src/org/evergreen/android/views/splashscreen/LoadingTask.java @@ -118,7 +118,7 @@ public class LoadingTask { boolean haveSession = false; boolean retry = false; try { - haveSession = ac.retrieveSession(auth_token); + haveSession = ac.retrieveSession(auth_token, true); } catch (SessionNotFoundException e) { mAccountManager.invalidateAuthToken(accountType, auth_token); retry = true; @@ -133,7 +133,7 @@ public class LoadingTask { Log.d(TAG, tag+"account_name="+account_name+" token="+auth_token); if (account_name == null) return "no account"; - haveSession = ac.retrieveSession(auth_token); + haveSession = ac.retrieveSession(auth_token, true); } if (!haveSession) return "no session"; -- 2.11.0