view list book bags functionality added
authordrizea <danielrizea27@gmail.com>
Wed, 18 Jul 2012 11:27:33 +0000 (14:27 +0300)
committerdrizea <danielrizea27@gmail.com>
Wed, 18 Jul 2012 11:27:33 +0000 (14:27 +0300)
need work on UI and add another bookbag details view + menu

Open-ILS/src/Android/AndroidManifest.xml
Open-ILS/src/Android/res/layout/bookbag_list.xml [new file with mode: 0644]
Open-ILS/src/Android/res/layout/bookbag_list_item.xml [new file with mode: 0644]
Open-ILS/src/Android/res/layout/checkout_list.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/bookbags/BookBag.java [new file with mode: 0644]
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/bookbags/BookBagItem.java [new file with mode: 0644]
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/bookbags/BookbagsListView.java [new file with mode: 0644]
Open-ILS/src/Android/src/org/evergreen/android/views/AccountScreenDashboard.java

index e337a0d..3151964 100644 (file)
@@ -71,6 +71,8 @@
         <activity android:name=".searchCatalog.RecordDetails"></activity>
         <activity android:name=".searchCatalog.RecordDetails_Simple"></activity>
         
+        <!-- Bookbags -->
+        <activity android:name=".accountAccess.bookbags.BookbagsListView"></activity>
         
     </application>
     
diff --git a/Open-ILS/src/Android/res/layout/bookbag_list.xml b/Open-ILS/src/Android/res/layout/bookbag_list.xml
new file mode 100644 (file)
index 0000000..392ff2a
--- /dev/null
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:orientation="vertical" >
+    
+    
+     <LinearLayout android:layout_width="fill_parent"
+         android:layout_height="wrap_content">
+         <TextView 
+             android:layout_width="wrap_content"
+             android:layout_height="wrap_content"
+             android:text="@string/search_result_text"
+             />
+         
+         <TextView 
+             android:id="@+id/search_result_number"
+             android:layout_width="wrap_content"
+             android:layout_height="wrap_content"
+             android:textStyle="bold"
+             />
+         
+     </LinearLayout>
+     
+       <ListView 
+         android:id="@+id/checkout_items_list"
+         android:layout_width="fill_parent"
+         android:layout_height="wrap_content"  
+         ></ListView>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/Open-ILS/src/Android/res/layout/bookbag_list_item.xml b/Open-ILS/src/Android/res/layout/bookbag_list_item.xml
new file mode 100644 (file)
index 0000000..a8a0efa
--- /dev/null
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:gravity="left|center"
+       android:paddingBottom="3dip"
+       android:paddingTop="3dip" 
+       android:paddingLeft="3dip" 
+    android:orientation="horizontal" >
+
+       <LinearLayout 
+       android:layout_width="fill_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical"
+    android:gravity="center_vertical" 
+       android:paddingLeft="5dip"
+       android:layout_alignParentLeft="true"
+       >
+       
+       
+           
+               <TextView
+               android:id="@+id/bookbag_name"
+               style="@style/TitleSearchStyleList"
+               android:layout_width="fill_parent"
+               android:layout_height="wrap_content"/>   
+           
+               <TextView
+               android:id="@+id/bookbag_items"
+               style="@style/AuthorSearchStyleList"
+               android:layout_width="fill_parent"
+               android:layout_height="wrap_content"/>
+               
+               
+               <TextView
+               android:id="@+id/bookbag_shared"
+               style="@style/PubSearchStyleList"
+               android:layout_width="fill_parent"
+               android:layout_height="wrap_content"
+               />
+               
+       </LinearLayout>
+               <Button
+                android:id="@+id/renew_button"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/delete_button" 
+                android:layout_gravity="right"  
+                android:layout_alignParentRight="true"
+                   />
+
+</RelativeLayout>
\ No newline at end of file
index 392ff2a..6fceb02 100644 (file)
@@ -4,8 +4,7 @@
     android:layout_height="fill_parent"
     android:orientation="vertical" >
     
-    
-     <LinearLayout android:layout_width="fill_parent"
+    <LinearLayout android:layout_width="fill_parent"
          android:layout_height="wrap_content">
          <TextView 
              android:layout_width="wrap_content"
              android:textStyle="bold"
              />
          
-     </LinearLayout>
+    </LinearLayout>
      
        <ListView 
-         android:id="@+id/checkout_items_list"
+         android:id="@+id/bookbag_list"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"  
-         ></ListView>
+         >
+           
+       </ListView>
 
 </LinearLayout>
\ No newline at end of file
index b405472..243959b 100644 (file)
@@ -43,4 +43,7 @@
     <string name="balance_owed">Balance Owed</string>
     <string name="overdue_materials">Overdue Materials</string>
     
+    <!-- Bookbag Activities -->
+    <string name="delete_button">delete</string>
+    
 </resources>
\ No newline at end of file
index 822c67d..0c79032 100644 (file)
@@ -8,6 +8,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.evergreen.android.accountAccess.bookbags.BookBag;
+import org.evergreen.android.accountAccess.bookbags.BookBagItem;
 import org.evergreen.android.accountAccess.checkout.CircRecord;
 import org.evergreen.android.accountAccess.fines.FinesRecord;
 import org.evergreen.android.accountAccess.holds.HoldRecord;
@@ -983,26 +985,40 @@ public class AccountAccess {
        
        //---------------------------------------Book bags-----------------------------------//
        
-       public Object getBookbags()
+       public ArrayList<BookBag> getBookbags()
                        throws SessionNotFoundException, NoNetworkAccessException, NoAccessToServer{
                
                Object response = Utils.doRequest(conn,SERVICE_ACTOR, METHOD_FLESH_CONTAINERS, authToken, cm, new Object[]{authToken,userID,"biblio","bookbag"});
        
                List<OSRFObject> bookbags = (List<OSRFObject>)response;
                
+               ArrayList<BookBag> bookBagObj = new ArrayList<BookBag>();
+               
                for(int i=0;i<bookbags.size();i++){
                        
-                       getBookbagContent(bookbags.get(i).getInt("id"));
-               }
-               
+                       BookBag bag = new BookBag(bookbags.get(i));     
+                       getBookbagContent(bag,bookbags.get(i).getInt("id"));
                
-               return bookbags;
+                       bookBagObj.add(bag);
+               }
+               return bookBagObj;
        }
        
-       private Object getBookbagContent(Integer bookbagID)
+       private Object getBookbagContent(BookBag bag, Integer bookbagID)
                        throws SessionNotFoundException, NoNetworkAccessException, NoAccessToServer{
                
-               return Utils.doRequest(conn,SERVICE_ACTOR, METHOD_FLESH_PUBLIC_CONTAINER, authToken, cm, new Object[]{authToken,"biblio",bookbagID});
+               Map<String,?> map =(Map<String,?>) Utils.doRequest(conn,SERVICE_ACTOR, METHOD_FLESH_PUBLIC_CONTAINER, authToken, cm, new Object[]{authToken,"biblio",bookbagID});
+       
+               List<OSRFObject> items =(List<OSRFObject>) map.get("items"); 
+               
+               for(int i=0;i<items.size();i++){
+                       
+                       BookBagItem bookBagItem = new BookBagItem(items.get(i));
+                       
+                       bag.items.add(bookBagItem);
+               }
+               
+               return items;
        }
        
 }
diff --git a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/bookbags/BookBag.java b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/bookbags/BookBag.java
new file mode 100644 (file)
index 0000000..449a98e
--- /dev/null
@@ -0,0 +1,35 @@
+package org.evergreen.android.accountAccess.bookbags;
+
+import java.util.ArrayList;
+
+import org.opensrf.util.OSRFObject;
+
+public class BookBag {
+       
+       public int id;
+       
+       public String name = null;
+
+       public String description = null;
+       
+       public String shared = null;
+       
+       public ArrayList<BookBagItem> items = null;
+       
+       public BookBag(OSRFObject object){
+       
+               this.id = object.getInt("id");
+               this.name = object.getString("name");
+               this.description = object.getString("description");
+               this.items = new ArrayList<BookBagItem>();
+               
+               
+               String pub_visible  = object.getString("pub");
+               
+               if(pub_visible.equals("f"))
+                       this.shared = "false";
+               else
+                       this.shared = "true";
+       }
+       
+}
diff --git a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/bookbags/BookBagItem.java b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/bookbags/BookBagItem.java
new file mode 100644 (file)
index 0000000..7cc5e12
--- /dev/null
@@ -0,0 +1,14 @@
+package org.evergreen.android.accountAccess.bookbags;
+
+import org.opensrf.util.OSRFObject;
+
+public class BookBagItem {
+
+       public int target_copy;
+
+       public BookBagItem(OSRFObject cbrebi){
+               
+               
+               this.target_copy = cbrebi.getInt("target_biblio_record_entry");
+       }
+}
diff --git a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/bookbags/BookbagsListView.java b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/bookbags/BookbagsListView.java
new file mode 100644 (file)
index 0000000..dac5210
--- /dev/null
@@ -0,0 +1,177 @@
+package org.evergreen.android.accountAccess.bookbags;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.evergreen.android.R;
+import org.evergreen.android.accountAccess.AccountAccess;
+import org.evergreen.android.accountAccess.MaxRenewalsException;
+import org.evergreen.android.accountAccess.SessionNotFoundException;
+import org.evergreen.android.accountAccess.checkout.CircRecord;
+import org.evergreen.android.globals.NoAccessToServer;
+import org.evergreen.android.globals.NoNetworkAccessException;
+import org.evergreen.android.globals.Utils;
+
+import android.app.Activity;
+import android.app.ProgressDialog;
+import android.content.Context;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+import android.widget.TextView;
+import android.widget.Toast;
+
+public class BookbagsListView extends Activity{
+
+       private String TAG = "BookBags";
+       
+       private AccountAccess accountAccess = null;
+       
+       private ListView lv;
+       
+       private BookBagsArrayAdapter listAdapter = null;
+
+       private ArrayList<BookBag> bookBags = null;
+
+       private Context context;
+       
+       private ProgressDialog progressDialog;
+       
+       @Override
+       public void onCreate(Bundle savedInstanceState) {
+               // TODO Auto-generated method stub
+               super.onCreate(savedInstanceState);
+               
+               setContentView(R.layout.checkout_list);
+               
+               context = this;
+               accountAccess = AccountAccess.getAccountAccess();
+               lv = (ListView) findViewById(R.id.bookbag_list);
+               bookBags = new ArrayList<BookBag>();
+               listAdapter = new BookBagsArrayAdapter(context, R.layout.bookbag_list_item, bookBags);
+               lv.setAdapter(listAdapter);
+               
+               Thread getBookBags = new Thread(new Runnable() {
+                       
+                       @Override
+                       public void run() {
+                               
+                               
+                               try {
+                                       bookBags = accountAccess.getBookbags();
+                                       
+                               }  catch (NoNetworkAccessException e) {
+                                       Utils.showNetworkNotAvailableDialog(context);
+                               } catch (NoAccessToServer e) {
+                                       Utils.showServerNotAvailableDialog(context);
+                                       
+                               }catch (SessionNotFoundException e) {
+                                       //TODO other way?
+                                       try{
+                                               if(accountAccess.authenticate())
+                                                       accountAccess.getBookbags();
+                                       }catch(Exception eauth){
+                                               System.out.println("Exception in reAuth");
+                                       }
+                               }                       
+       
+                               runOnUiThread(new Runnable() {
+                                       
+                                       @Override
+                                       public void run() {
+                                               for(int i=0;i<bookBags.size();i++)
+                                                       listAdapter.add(bookBags.get(i));
+                                               
+                                               
+                                               progressDialog.dismiss();       
+                                               
+                                               if(bookBags.size() == 0)
+                                                       Toast.makeText(context, "No circ records", Toast.LENGTH_LONG);
+                                               
+                                               listAdapter.notifyDataSetChanged();
+                                       }
+                               });
+                               
+                               
+                       }
+               });
+               
+               
+               if(accountAccess.isAuthenticated()){
+                       progressDialog = new ProgressDialog(context);
+                       progressDialog.setMessage("Please wait while retrieving Book Bag data");
+                       progressDialog.show();
+                       getBookBags.start();
+                       
+               }
+               else
+                       Toast.makeText(context, "You must be authenticated to retrieve circ records", Toast.LENGTH_LONG);
+
+       
+                               
+
+       }
+       
+         class BookBagsArrayAdapter extends ArrayAdapter<BookBag> {
+               private static final String tag = "BookbagArrayAdapter";
+               
+               private TextView name;
+               private TextView items;
+               private TextView shared;
+               
+               
+               private List<BookBag> records = new ArrayList<BookBag>();
+
+               public BookBagsArrayAdapter(Context context, int textViewResourceId,
+                               List<BookBag> objects) {
+                       super(context, textViewResourceId, objects);
+                       this.records = objects;
+               }
+
+               public int getCount() {
+                       return this.records.size();
+               }
+
+               public BookBag getItem(int index) {
+                       return this.records.get(index);
+               }
+
+               public View getView(int position, View convertView, ViewGroup parent) {
+                       View row = convertView;
+                       
+                       // Get item
+                       final BookBag record = getItem(position);
+
+                       
+                               //if it is the right type of view
+                                       if (row == null ) {
+               
+                                                       Log.d(tag, "Starting XML Row Inflation ... ");
+                                                       LayoutInflater inflater = (LayoutInflater) this.getContext()
+                                                                       .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+                                                       row = inflater.inflate(R.layout.bookbag_list_item, parent, false);
+                                                       Log.d(tag, "Successfully completed XML Row Inflation!");
+               
+                                       }
+
+                               name = (TextView) row.findViewById(R.id.bookbag_name);
+                               
+                               items = (TextView) row.findViewById(R.id.bookbag_items);
+                               
+                               shared = (TextView) row.findViewById(R.id.bookbag_shared);
+                               
+                               name.setText(record.name+"");
+                               
+                               items.setText("items :" + record.items.size());
+                               
+                               shared.setText(record.shared);
+                               
+                       return row;
+               }
+           }
+}
index fae20d0..e878420 100644 (file)
@@ -2,6 +2,7 @@
 package org.evergreen.android.views;
 
 import org.evergreen.android.R;
+import org.evergreen.android.accountAccess.bookbags.BookbagsListView;
 import org.evergreen.android.accountAccess.checkout.ItemsCheckOutListView;
 import org.evergreen.android.accountAccess.fines.FinesActivity;
 import org.evergreen.android.accountAccess.holds.HoldsListView;
@@ -122,7 +123,7 @@ public class AccountScreenDashboard extends Activity {
                   startActivity (new Intent(getApplicationContext(), FinesActivity.class));
                   break;
              case R.id.account_btn_book_bags :
-                  //startActivity (new Intent(getApplicationContext(), F6Activity.class));
+                  startActivity (new Intent(getApplicationContext(), BookbagsListView.class));
                   break;
              default: 
                   break;