Holds: Use format text "DVD" instead of vertically stretched
authorkenstir <kenstir@gmail.com>
Tue, 20 Oct 2015 03:30:20 +0000 (23:30 -0400)
committerkenstir <kenstir@gmail.com>
Tue, 20 Oct 2015 03:30:20 +0000 (23:30 -0400)
types_of_resource icon.

Open-ILS/src/Android/core/res/layout/holds_list_item.xml
Open-ILS/src/Android/core/src/org/evergreen_ils/accountAccess/AccountAccess.java
Open-ILS/src/Android/core/src/org/evergreen_ils/accountAccess/holds/HoldRecord.java
Open-ILS/src/Android/core/src/org/evergreen_ils/accountAccess/holds/HoldsListView.java

index 3533b08..d877d51 100644 (file)
@@ -1,51 +1,38 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent" 
-    android:orientation="horizontal"
-    android:paddingLeft="5dp"
-    android:background="@color/background"
-    > 
-
-    
-    <ImageView 
-        android:id="@+id/hold_resource_icon"
-        android:layout_width="wrap_content"
-        android:layout_height="fill_parent"
-       android:layout_gravity="center"
-       android:background="@color/white"
-        />
-    
-    <LinearLayout 
-        android:layout_width="fill_parent"
-        android:layout_height="fill_parent"
-        android:orientation="vertical"
-        android:padding="5dp"
-        android:layout_weight="1"
+              android:layout_width="fill_parent"
+              android:layout_height="fill_parent"
+              android:orientation="vertical"
+              android:padding="5dp"
+              android:layout_weight="1"
         >
-        
-         <TextView 
-     android:layout_width="wrap_content"   
-     android:layout_height="wrap_content"
-     android:id="@+id/hold_title"   
-     style="@style/TitleSearchStyleList"
-        />
-    
-     <TextView 
-     android:layout_width="wrap_content"   
-     android:layout_height="wrap_content"
-     android:id="@+id/hold_author" 
-     style="@style/AuthorSearchStyleList"
-        />
-        
-     <TextView 
-     android:layout_width="wrap_content"   
-     android:layout_height="wrap_content"
-     android:id="@+id/hold_status"
-     android:textColor="@color/blue"
-        />   
-        
-    </LinearLayout>
-   
-    
-</LinearLayout>
\ No newline at end of file
+
+    <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:id="@+id/hold_title"
+            style="@style/TitleSearchStyleList"
+            android:text="La Dolce Vita"/>
+
+    <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:id="@+id/hold_author"
+            style="@style/AuthorSearchStyleList"
+            android:text="Fellini, Federico"/>
+
+    <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:id="@+id/hold_format"
+            style="@style/AuthorSearchStyleList"
+            android:text="DVD"/>
+
+    <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:id="@+id/hold_status"
+            android:textColor="@color/blue"
+            android:text="Waiting on copy"/>
+
+</LinearLayout>
index e77e1ef..2893e7d 100644 (file)
@@ -605,14 +605,10 @@ public class AccountAccess {
         listHoldsAhr = (List<OSRFObject>) resp;
 
         for (int i = 0; i < listHoldsAhr.size(); i++) {
-            // create hold item
             HoldRecord hold = new HoldRecord(listHoldsAhr.get(i));
-            // get title
             fetchHoldTitleInfo(listHoldsAhr.get(i), hold);
-
-            // get status
             fetchHoldStatus(listHoldsAhr.get(i), hold);
-
+            hold.format = fetchFormat(hold.target);
             holds.add(hold);
         }
         return holds;
@@ -633,36 +629,27 @@ public class AccountAccess {
     private Object fetchHoldTitleInfo(OSRFObject holdArhObject, HoldRecord hold) {
 
         String holdType = (String) holdArhObject.get("hold_type");
-
+        Integer target = holdArhObject.getInt("target");
         String method = null;
 
         Object response;
         OSRFObject holdInfo = null;
         if (holdType.equals("T") || holdType.equals("M")) {
-
             if (holdType.equals("M"))
                 method = METHOD_FETCH_MRMODS;
-            if (holdType.equals("T"))
+            else //(holdType.equals("T"))
                 method = METHOD_FETCH_RMODS;
             holdInfo = (OSRFObject) Utils.doRequest(conn, SERVICE_SEARCH,
-                    method, new Object[] { holdArhObject.get("target") });
+                    method, new Object[] {
+                            target });
 
             // Log.d(TAG, "Hold here " + holdInfo);
             hold.title = ((OSRFObject) holdInfo).getString("title");
             hold.author = ((OSRFObject) holdInfo).getString("author");
             hold.recordInfo = new RecordInfo((OSRFObject) holdInfo);
-            try {
-                hold.types_of_resource = ((List<Object>) holdInfo
-                        .get("types_of_resource")).get(0).toString();
-            } catch (Exception e) {
-                System.err.println("Can't get types of resurce type"
-                        + e.getMessage());
-            }
-            ;
         } else {
             // multiple objects per hold ????
             holdInfo = holdFetchObjects(holdArhObject, hold);
-
         }
         return holdInfo;
     }
@@ -693,9 +680,9 @@ public class AccountAccess {
 
             if (call_number != null) {
 
-                OSRFObject volume = (OSRFObject) Utils.doRequest(conn,
-                        SERVICE_SEARCH, METHOD_FETCH_VOLUME,
-                        new Object[] { copyObject.getInt("call_number") });
+                OSRFObject volume = (OSRFObject) Utils.doRequest(conn, SERVICE_SEARCH,
+                        METHOD_FETCH_VOLUME, new Object[] {
+                                copyObject.getInt("call_number") });
                 // in volume object : record
                 Integer record = volume.getInt("record");
 
@@ -710,13 +697,6 @@ public class AccountAccess {
                 holdObj.title = holdInfo.getString("title");
                 holdObj.author = holdInfo.getString("author");
                 holdObj.recordInfo = new RecordInfo((OSRFObject) holdInfo);
-                try {
-                    holdObj.types_of_resource = ((List<Object>) holdInfo
-                            .get("types_of_resource")).get(0).toString();
-                } catch (Exception e) {
-                    System.err.println("Can't get types of resurce type"
-                            + e.getMessage());
-                }
             }
 
             return copyObject;
@@ -743,13 +723,6 @@ public class AccountAccess {
             holdObj.title = holdInfo.getString("title");
             holdObj.author = holdInfo.getString("author");
             holdObj.recordInfo = new RecordInfo((OSRFObject) holdInfo);
-            try {
-                holdObj.types_of_resource = ((List<Object>) holdInfo
-                        .get("types_of_resource")).get(0).toString();
-            } catch (Exception e) {
-                System.err.println("Can't get types of resurce type"
-                        + e.getMessage());
-            }
         } else if (type.equals("I")) {
             OSRFObject issuance = (OSRFObject) Utils.doRequest(conn,
                     SERVICE_SERIAL, METHOD_FETCH_ISSUANCE,
@@ -790,13 +763,6 @@ public class AccountAccess {
             holdObj.title = holdInfo.getString("title");
             holdObj.author = holdInfo.getString("author");
             holdObj.recordInfo = new RecordInfo((OSRFObject) holdInfo);
-            try {
-                holdObj.types_of_resource = ((List<Object>) holdInfo
-                        .get("types_of_resource")).get(0).toString();
-            } catch (Exception e) {
-                System.err.println("Can't get types of resurce type"
-                        + e.getMessage());
-            }
         }
 
         return null;
index 6faf310..cf3fa4a 100644 (file)
@@ -43,7 +43,7 @@ public class HoldRecord implements Serializable {
 
     public String author = null;
 
-    public String types_of_resource;
+    public String format = "";
 
     // only for P types
     public String part_label = null;
index 5352c55..81c7ccf 100644 (file)
  */
 package org.evergreen_ils.accountAccess.holds;
 
-import java.util.ArrayList;
-import java.util.List;
-
-import android.support.v7.app.ActionBar;
-import android.support.v7.app.ActionBarActivity;
-import org.evergreen_ils.R;
-import org.evergreen_ils.accountAccess.AccountAccess;
-import org.evergreen_ils.accountAccess.SessionNotFoundException;
-import org.evergreen_ils.globals.GlobalConfigs;
-import org.evergreen_ils.searchCatalog.ImageDownloader;
-import org.evergreen_ils.views.splashscreen.SplashActivity;
-
-import android.app.Activity;
 import android.app.ProgressDialog;
 import android.content.Context;
 import android.content.Intent;
 import android.os.Bundle;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.ActionBarActivity;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
-import android.view.View.OnClickListener;
 import android.view.ViewGroup;
-import android.widget.AdapterView;
+import android.widget.*;
 import android.widget.AdapterView.OnItemClickListener;
-import android.widget.ArrayAdapter;
-import android.widget.Button;
-import android.widget.ImageView;
-import android.widget.ListView;
-import android.widget.TextView;
-import org.evergreen_ils.accountAccess.holds.HoldRecord;
+import org.evergreen_ils.R;
+import org.evergreen_ils.accountAccess.AccountAccess;
+import org.evergreen_ils.accountAccess.SessionNotFoundException;
+import org.evergreen_ils.searchCatalog.ImageDownloader;
+import org.evergreen_ils.searchCatalog.SearchFormat;
+import org.evergreen_ils.views.splashscreen.SplashActivity;
+
+import java.util.ArrayList;
+import java.util.List;
 
 public class HoldsListView extends ActionBarActivity {
 
-    private final String TAG = HoldsListView.class.getName();
+    private final String TAG = HoldsListView.class.getSimpleName();
 
     private AccountAccess accountAccess = null;
 
@@ -85,6 +76,7 @@ public class HoldsListView extends ActionBarActivity {
             SplashActivity.restartApp(this);
             return;
         }
+        SearchFormat.init(this);
 
         setContentView(R.layout.holds_list);
 
@@ -165,13 +157,11 @@ public class HoldsListView extends ActionBarActivity {
 
     @Override
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
-        // TODO Auto-generated method stub
         super.onActivityResult(requestCode, resultCode, data);
 
         switch (resultCode) {
 
         case HoldDetails.RESULT_CODE_CANCEL:
-            // nothing
             Log.d(TAG, "Do nothing");
             break;
 
@@ -194,8 +184,8 @@ public class HoldsListView extends ActionBarActivity {
 
         private TextView holdTitle;
         private TextView holdAuthor;
+        private TextView holdFormat;
         private TextView status;
-        private ImageView hold_icon;
 
         private List<HoldRecord> records = new ArrayList<HoldRecord>();
 
@@ -216,7 +206,6 @@ public class HoldsListView extends ActionBarActivity {
         public View getView(int position, View convertView, ViewGroup parent) {
             View row = convertView;
 
-            // Get item
             final HoldRecord record = getItem(position);
 
             if (row == null) {
@@ -225,31 +214,14 @@ public class HoldsListView extends ActionBarActivity {
                 row = inflater.inflate(R.layout.holds_list_item, parent, false);
             }
 
-            hold_icon = (ImageView) row.findViewById(R.id.hold_resource_icon);
-
-            // Get reference to TextView - title
             holdTitle = (TextView) row.findViewById(R.id.hold_title);
-
-            // Get reference to TextView author
             holdAuthor = (TextView) row.findViewById(R.id.hold_author);
-
-            // Get hold status
+            holdFormat = (TextView) row.findViewById(R.id.hold_format);
             status = (TextView) row.findViewById(R.id.hold_status);
 
-            // set text
-            String imageResourceHref = GlobalConfigs.httpAddress
-                    + GlobalConfigs.hold_icon_address
-                    + record.types_of_resource + ".jpg";
-
-            if (imageResourceHref.contains(" ")) {
-                imageResourceHref = imageResourceHref.replace(" ", "%20");
-            }
-
-            imageDownloader.download(imageResourceHref, hold_icon);
-
-            // set raw information
             holdTitle.setText(record.title);
             holdAuthor.setText(record.author);
+            holdFormat.setText(SearchFormat.getLabelFromSearchFormat(record.format));
             status.setText(record.getHoldStatus(getResources()));
 
             return row;