From 7251b6dc84fc4eabaef6f5605d80c0d8b8422332 Mon Sep 17 00:00:00 2001 From: kenstir Date: Mon, 12 Oct 2015 16:50:41 -0400 Subject: [PATCH] * avoid displaying the string 'null' for records missing fields like publisher --- .../evergreen_ils/searchCatalog/RecordInfo.java | 44 ++++++++++++---------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/Open-ILS/src/Android/core/src/org/evergreen_ils/searchCatalog/RecordInfo.java b/Open-ILS/src/Android/core/src/org/evergreen_ils/searchCatalog/RecordInfo.java index 402a20337c..f69fa94118 100644 --- a/Open-ILS/src/Android/core/src/org/evergreen_ils/searchCatalog/RecordInfo.java +++ b/Open-ILS/src/Android/core/src/org/evergreen_ils/searchCatalog/RecordInfo.java @@ -25,6 +25,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import android.text.TextUtils; import android.util.Log; import org.opensrf.util.OSRFObject; @@ -79,17 +80,29 @@ public class RecordInfo implements Serializable { this.dummy = true; } + private String safeGetString(OSRFObject info, String field) { + String s = info.getString(field); + if (s == null) + return ""; + return s; + } + + private String safeString(String s) { + if (s == null) + return ""; + return s; + } + public RecordInfo(OSRFObject info) { copyInformationList = new ArrayList(); try { - - this.title = info.getString("title"); - this.author = info.getString("author"); - this.pubdate = info.getString("pubdate"); - this.publisher = info.getString("publisher"); + this.title = safeString(info.getString("title")); + this.author = safeString(info.getString("author")); + this.pubdate = safeString(info.getString("pubdate")); + this.publisher = safeString(info.getString("publisher")); this.doc_id = info.getInt("doc_id"); - this.image = info.getString("tcn"); - this.doc_type = info.getString("doc_type"); + this.image = safeString(info.getString("tcn")); + this.doc_type = safeString(info.getString("doc_type")); } catch (Exception e) { Log.d(TAG, "Exception basic info " + e.getMessage()); } @@ -103,7 +116,6 @@ public class RecordInfo implements Serializable { ; try { - Map subjectMap = (Map) info.get("subject"); this.subject = ""; @@ -123,29 +135,21 @@ public class RecordInfo implements Serializable { } ; try { - this.online_loc = ((List) info.get("online_loc")).get(0).toString(); - } catch (Exception e) { - Log.d(TAG, "Exception online_loc " + e.getMessage()); + //Log.d(TAG, "Exception online_loc " + e.getMessage()); } ; try { - this.physical_description = (String) info - .get("physical_description"); + this.physical_description = (String) info.get("physical_description"); } catch (Exception e) { - Log.d(TAG, "Exception physical_description " - + e.getMessage()); + Log.d(TAG, "Exception physical_description " + e.getMessage()); } ; try { this.series = ""; List seriesList = (List) info.get("series"); - for (int i = 0; i < seriesList.size(); i++) - if (i < seriesList.size() - 1) - this.series += seriesList.get(i) + ", "; - else - this.series += seriesList.get(i); + this.series = TextUtils.join(", ", seriesList); } catch (Exception e) { Log.d(TAG, "Exception series " + e.getMessage()); } -- 2.11.0