hold list view with image resource + bug fixes
authordrizea <danielrizea27@gmail.com>
Mon, 13 Aug 2012 15:43:34 +0000 (18:43 +0300)
committerdrizea <danielrizea27@gmail.com>
Mon, 13 Aug 2012 15:43:34 +0000 (18:43 +0300)
12 files changed:
Open-ILS/src/Android/res/layout/hold_details.xml
Open-ILS/src/Android/res/layout/holds_list.xml
Open-ILS/src/Android/res/layout/holds_list_item.xml
Open-ILS/src/Android/res/layout/place_hold.xml
Open-ILS/src/Android/res/values/strings.xml
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/AccountAccess.java
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/holds/HoldDetails.java
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/holds/HoldRecord.java
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/holds/HoldsListView.java
Open-ILS/src/Android/src/org/evergreen/android/globals/GlobalConfigs.java
Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/ImageDownloader.java
Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SearchCatalogListView.java

index 4608f04..1de0426 100644 (file)
@@ -42,6 +42,7 @@
         android:fillViewport="true"
         android:layout_above="@id/action_bar"
         android:layout_below="@id/header_actionbar"
+        android:padding="5dp"
         >
        <LinearLayout 
            android:layout_width="fill_parent"
index b7bb837..5ad2c18 100644 (file)
@@ -7,11 +7,14 @@
     <include android:id="@+id/header_actionbar" layout="@layout/simple_actionbar"/>
     
      <LinearLayout android:layout_width="fill_parent"
-         android:layout_height="wrap_content">
+         android:layout_height="wrap_content"
+         android:orientation="horizontal"
+         android:padding="5dp"
+         >
          <TextView 
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
-             android:text="@string/search_result_text"
+             android:text="@string/hold_items"
              />
          
          <TextView 
@@ -19,6 +22,7 @@
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:textStyle="bold"
+             android:textSize="14sp"
              />
          
      </LinearLayout>
@@ -26,7 +30,7 @@
        <ListView 
          android:id="@+id/holds_item_list"
          android:layout_width="fill_parent"
-         android:layout_height="wrap_content"  
+         android:layout_height="fill_parent"  
        ></ListView>
 
 </LinearLayout>
\ No newline at end of file
index 70af455..04ef517 100644 (file)
@@ -1,9 +1,29 @@
 <?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
-    android:layout_height="match_parent" > 
+    android:layout_height="match_parent" 
+    android:orientation="horizontal"
+    android:paddingLeft="5dp"
+    > 
 
-    <TextView 
+    
+    <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"
+        >
+        
+         <TextView 
      android:layout_width="wrap_content"   
      android:layout_height="wrap_content"
      android:id="@+id/hold_title"   
@@ -13,8 +33,7 @@
      <TextView 
      android:layout_width="wrap_content"   
      android:layout_height="wrap_content"
-     android:id="@+id/hold_author"
-     android:layout_below="@+id/hold_title"   
+     android:id="@+id/hold_author" 
      style="@style/AuthorSearchStyleList"
         />
         
      android:layout_width="wrap_content"   
      android:layout_height="wrap_content"
      android:id="@+id/hold_status"
-     android:layout_below="@+id/hold_author"   
      android:textColor="@color/blue"
         />   
+        
+    </LinearLayout>
+   
     
-</RelativeLayout>
\ No newline at end of file
+</LinearLayout>
\ No newline at end of file
index fd99ac8..8190be6 100644 (file)
@@ -37,6 +37,7 @@
         android:fillViewport="true"
         android:layout_above="@id/action_bar"
         android:layout_below="@id/header_actionbar"
+        android:padding="5dip"
         >
        <LinearLayout 
            android:layout_width="fill_parent"
index 3894643..046ad82 100644 (file)
@@ -97,6 +97,8 @@
     <string name="hold_expire_time_hint">Hold expire time</string>
     <string name="hold_thaw_date_hint">Date when the hold is frozen</string>
     
+    <string name="hold_items">Hold items: </string>
+    
     <!-- Checkout items -->
     <string name="checkout_item_txt">Total items out: </string>
     <string name="checkout_overdue_items">/ Overdue items: </string>
index d24e465..439df8b 100644 (file)
@@ -685,7 +685,7 @@ public class AccountAccess {
                
                
                Object response;
-               Object holdInfo = null;
+               OSRFObject holdInfo = null;
                if(holdType.equals("T") || holdType.equals("M")){
                        
                        if(holdType.equals("M")) 
@@ -693,13 +693,15 @@ public class AccountAccess {
                        if(holdType.equals("T"))
                                method = METHOD_FETCH_RMODS;
                        System.out.println();
-                       holdInfo = Utils.doRequest(conn,SERVICE_SEARCH, method, cm, new Object[]{holdArhObject.get("target")});
+                       holdInfo =  (OSRFObject)Utils.doRequest(conn,SERVICE_SEARCH, method, cm, new Object[]{holdArhObject.get("target")});
 
                        //System.out.println("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 ????
@@ -709,7 +711,7 @@ public class AccountAccess {
                return holdInfo;
        }
        
-       private Object holdFetchObjects(OSRFObject hold, HoldRecord holdObj) throws  NoNetworkAccessException, NoAccessToServer{
+       private OSRFObject holdFetchObjects(OSRFObject hold, HoldRecord holdObj) throws  NoNetworkAccessException, NoAccessToServer{
                
                String type = (String)hold.get("hold_type");
                
@@ -741,6 +743,9 @@ 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());};
                        }
                        
                        
@@ -767,6 +772,9 @@ 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")){   
@@ -805,6 +813,9 @@ 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 f043482..766de1d 100644 (file)
@@ -43,11 +43,11 @@ import android.widget.Toast;
 
 public class HoldDetails extends Activity {
 
-       public static final int RESULT_CODE_DELETE_HOLD = 0;
+       public static final int RESULT_CODE_DELETE_HOLD = 5;
 
-       public static final int RESULT_CODE_UPDATE_HOLD = 1;
-
-       public static final int RESULT_CODE_CANCEL = 2;
+       public static final int RESULT_CODE_UPDATE_HOLD = 6;
+       
+       public static final int RESULT_CODE_CANCEL = 7;
 
        private TextView recipient;
 
@@ -241,11 +241,7 @@ public class HoldDetails extends Activity {
                                                                                                System.out.println("Exception in reAuth");
                                                                                        }
                                                                                }               
-                                                                               
-                                                                               
-                                                                               
-                                                                               
-                                                                               
+               
                                                                                runOnUiThread(new Runnable() {
                                                                                        @Override
                                                                                        public void run() {
@@ -277,8 +273,6 @@ public class HoldDetails extends Activity {
                                if (thaw_date != null)
                                        thaw_date_s = GlobalConfigs.getStringDate(thaw_date);
 
-
-                               
                                try {
                                        accountAccess.updateHold(record.ahr, selectedOrgPos,
                                                        email_notification.isChecked(), phone_notification
index ebd4350..c6ac35f 100644 (file)
@@ -2,6 +2,7 @@ package org.evergreen.android.accountAccess.holds;
 
 import java.io.Serializable;
 import java.util.Date;
+import java.util.List;
 
 import org.evergreen.android.globals.GlobalConfigs;
 import org.evergreen.android.searchCatalog.RecordInfo;
@@ -35,6 +36,7 @@ public class HoldRecord implements Serializable{
        
        public String author = null;
        
+       public String types_of_resource;
        
        /* Hold status 
        *  holdStatus == 4 => AVAILABLE
@@ -106,7 +108,6 @@ public class HoldRecord implements Serializable{
                        this.suspended = true;
                pickup_lib = ahr.getInt("pickup_lib");
                
-               
        }
        //based on status integer field retreive hold status in text
        public String getHoldStatus(){
index 999c652..47f13d9 100644 (file)
@@ -1,14 +1,17 @@
 package org.evergreen.android.accountAccess.holds;
 
+import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.List;
 
 import org.evergreen.android.R;
 import org.evergreen.android.accountAccess.AccountAccess;
 import org.evergreen.android.accountAccess.SessionNotFoundException;
+import org.evergreen.android.globals.GlobalConfigs;
 import org.evergreen.android.globals.NoAccessToServer;
 import org.evergreen.android.globals.NoNetworkAccessException;
 import org.evergreen.android.globals.Utils;
+import org.evergreen.android.searchCatalog.ImageDownloader;
 import org.evergreen.android.searchCatalog.SearchCatalogListView;
 import org.evergreen.android.views.AccountScreenDashboard;
 
@@ -27,6 +30,7 @@ import android.widget.AdapterView.OnItemClickListener;
 import android.widget.ArrayAdapter;
 import android.widget.Button;
 import android.widget.ImageButton;
+import android.widget.ImageView;
 import android.widget.ListView;
 import android.widget.TextView;
 import android.widget.Toast;
@@ -52,8 +56,12 @@ public class HoldsListView extends Activity{
        private Button myAccountButton;
        
        private TextView headerTitle;
+       
+       private TextView holdsNoText;
 
        private ProgressDialog progressDialog;
+       
+       private ImageDownloader imageDownloader;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
@@ -83,6 +91,10 @@ public class HoldsListView extends Activity{
                });
         //end header portion actions
                
+        holdsNoText = (TextView)findViewById(R.id.holds_number);
+        
+        imageDownloader = new ImageDownloader(40, 40, false);
+        
                lv = (ListView)findViewById(R.id.holds_item_list);
                context = this;
                accountAccess = AccountAccess.getAccountAccess();
@@ -119,6 +131,7 @@ public class HoldsListView extends Activity{
                                                for(int i=0;i<holdRecords.size();i++)
                                                        listAdapter.add(holdRecords.get(i));
                                                
+                                               holdsNoText.setText(" "+listAdapter.getCount());
                                                progressDialog.dismiss();
                                                listAdapter.notifyDataSetChanged();
                                                
@@ -127,6 +140,8 @@ public class HoldsListView extends Activity{
                        }
                };
                
+               
+               
                if(accountAccess.isAuthenticated()){
                        progressDialog = new ProgressDialog(context);
                        progressDialog.setMessage("Loading holds");
@@ -166,6 +181,7 @@ public class HoldsListView extends Activity{
                
                case HoldDetails.RESULT_CODE_CANCEL : { 
                        //nothing
+                       Log.d(TAG, "Do nothing");
                        }break;
                        
                case HoldDetails.RESULT_CODE_DELETE_HOLD : {
@@ -176,6 +192,7 @@ public class HoldsListView extends Activity{
                        //thread to retrieve holds
                        Thread getHoldsThread = new Thread(getHoldsRunnable);
                        getHoldsThread.start();
+                       Log.d(TAG, "Update on delete hold");
                }break;
                
                case HoldDetails.RESULT_CODE_UPDATE_HOLD : {
@@ -186,6 +203,7 @@ public class HoldsListView extends Activity{
                        //thread to retrieve holds
                        Thread getHoldsThread = new Thread(getHoldsRunnable);
                        getHoldsThread.start();
+                       Log.d(TAG, "Update on update hold");
                }break;
                
                }
@@ -197,6 +215,7 @@ public class HoldsListView extends Activity{
        private TextView holdTitle;
        private TextView holdAuthor;
        private TextView status;
+       private ImageView hold_icon;
        
        private List<HoldRecord> records = new ArrayList<HoldRecord>();
 
@@ -230,6 +249,9 @@ public class HoldsListView extends Activity{
 
 
                }
+               
+               hold_icon = (ImageView) row.findViewById(R.id.hold_resource_icon);
+               
                // Get reference to TextView - title
                holdTitle = (TextView) row.findViewById(R.id.hold_title);
                
@@ -240,8 +262,15 @@ public class HoldsListView extends Activity{
                status = (TextView) row.findViewById(R.id.hold_status);
                
                        //set text
-                       
-               System.out.println("Row" + record.title + " " + record.author + " " + record.getHoldStatus());
+               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);
+               
+               System.out.println("Image " + imageResourceHref + " Row " + record.title + " " + record.author + " " + record.getHoldStatus() );
                //set raw information
                holdTitle.setText(record.title);
                holdAuthor.setText(record.author);
index a90064e..d48e84a 100644 (file)
@@ -35,6 +35,8 @@ public class GlobalConfigs {
        
        public static boolean loadedOrgTree = false;
        
+       public static String hold_icon_address = "/opac/images/tor/"; 
+       
        //two days notification before checkout expires, this can be modified from preferences
        public static int NOTIFICATION_BEFORE_CHECKOUT_EXPIRATION = 2; 
        
index b8711ca..f5e90ea 100644 (file)
@@ -44,6 +44,8 @@ public class ImageDownloader {
    
     private int MIN_IMG_HEIGHT = 75;
     
+    private int MIN_IMG_WIDTH = 30;
+    
     private int bitmap_width;
     private int bitmap_height;
     private boolean scale;
@@ -61,6 +63,7 @@ public class ImageDownloader {
        this.bitmap_height = h;
        this.bitmap_width = w;
        this.scale = scale;
+       MIN_IMG_HEIGHT = h;
     }
     /**
      * Download the specified image from the Internet and binds it to the provided ImageView. The
@@ -120,6 +123,7 @@ public class ImageDownloader {
                     DownloadedDrawable downloadedDrawable = new DownloadedDrawable(task);
                     imageView.setImageDrawable(downloadedDrawable);
                     imageView.setMinimumHeight(MIN_IMG_HEIGHT);
+                    imageView.setMinimumWidth(MIN_IMG_WIDTH);
                     task.execute(url);
                     break;
             }
index 2af7e4d..7f98883 100644 (file)
@@ -37,6 +37,7 @@ import android.view.View.OnClickListener;
 import android.view.View.OnKeyListener;
 import android.view.ViewGroup;
 import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.InputMethodManager;
 import android.widget.AbsListView;
 import android.widget.AbsListView.OnScrollListener;
 import android.widget.AdapterView;
@@ -227,6 +228,9 @@ public class SearchCatalogListView extends Activity {
                                        @Override
                                        public void run() {
 
+                                               InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
+                               imm.hideSoftInputFromWindow(searchText.getWindowToken(), 0);
+
                                                searchOptionsMenu.setVisibility(View.GONE);
                                                searchResultsNumber.setVisibility(View.VISIBLE);