<!-- Bookbags -->
<activity android:name=".accountAccess.bookbags.BookbagsListView"></activity>
+ <activity android:name=".accountAccess.bookbags.BookBagDetails"></activity>
</application>
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
+
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/create_bookbag"
+ />
+ <EditText
+ android:id="@+id/bookbag_create_name"
+ android:layout_width="200dip"
+ android:layout_height="wrap_content"
+ android:hint="@string/bookbag_name"
+ />
+ <Button
+ android:id="@+id/bookbag_create_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/create"
+ />
+
+ </LinearLayout>
-
- <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>
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:gravity="center_vertical"
+ android:paddingLeft="5dip"
+ android:paddingTop="10dip"
+ >
+
+ <TextView
+ style="@style/TitleSearchStyleList"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/bags_name"
+ />
+
+ <TextView
+ style="@style/TitleSearchStyleList"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:gravity="center"
+ android:text="@string/bags_items"
+ />
+
+
+ <TextView
+ style="@style/TitleSearchStyleList"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:gravity="center"
+ android:text="@string/bags_shared"
+ />
+
+ <TextView
+ style="@style/TitleSearchStyleList"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/bags_action"
+ android:layout_gravity="right"
+ android:gravity="center"
+ />
+
+ </LinearLayout>
<ListView
- android:id="@+id/checkout_items_list"
+ android:id="@+id/bookbag_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
+ android:paddingTop="10dip"
></ListView>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="wrap_content"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
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"/>
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ />
<TextView
android:id="@+id/bookbag_items"
style="@style/AuthorSearchStyleList"
android:layout_width="fill_parent"
- android:layout_height="wrap_content"/>
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:gravity="center"
+ />
- <TextView
+ <CheckBox
android:id="@+id/bookbag_shared"
- style="@style/PubSearchStyleList"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:gravity="center"
+ android:focusable="false"
/>
- </LinearLayout>
<Button
- android:id="@+id/renew_button"
+ android:id="@+id/details_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="@string/delete_button"
- android:layout_gravity="right"
- android:layout_alignParentRight="true"
+ android:text="@string/details"
+ android:layout_gravity="right"
/>
-
-</RelativeLayout>
\ No newline at end of file
+
+</LinearLayout>
\ No newline at end of file
--- /dev/null
+<?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" >
+ <Spinner
+ android:id="@+id/bookbag_spinner"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <Button
+ android:id="@+id/add_to_bookbag_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/add_button"
+
+ />
+</LinearLayout>
--- /dev/null
+<?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"
+ android:orientation="horizontal"
+ >
+
+ <TextView
+ android:text="@string/bookbag_name"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ />
+
+ <TextView
+ android:id="@+id/bookbag_name"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ />
+
+ <Button
+ android:id="@+id/remove_bookbag"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/delete_button"
+ />
+
+ </LinearLayout>
+
+
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:gravity="center_vertical"
+ android:paddingLeft="5dip"
+ >
+
+ <TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/title"
+ android:gravity="center"
+ />
+
+ <TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:gravity="center"
+ android:text="@string/author"
+ />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/bags_action"
+ android:layout_gravity="right"
+ android:gravity="center"
+ />
+
+ </LinearLayout>
+
+ <ListView
+ android:id="@+id/bookbagitem_list"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:paddingTop="10dip"
+ ></ListView>
+
+</LinearLayout>
\ No newline at end of file
--- /dev/null
+<?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="wrap_content"
+ android:gravity="left|center"
+ android:paddingBottom="3dip"
+ android:paddingTop="3dip"
+ android:paddingLeft="3dip"
+ android:orientation="horizontal" >
+
+ <TextView
+ android:id="@+id/bookbagitem_title"
+ style="@style/TitleSearchStyleList"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:paddingLeft="3dip"
+ />
+
+ <TextView
+ android:id="@+id/bookbagitem_author"
+ style="@style/AuthorSearchStyleList"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:gravity="center"
+ android:paddingLeft="3dip"
+ />
+
+ <Button
+ android:id="@+id/bookbagitem_remove_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/bookbagitem_remove"
+ android:layout_gravity="right"
+ android:layout_weight="0"
+ />
+
+</LinearLayout>
\ No newline at end of file
</LinearLayout>
<ListView
- android:id="@+id/bookbag_list"
+ android:id="@+id/checkout_items_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<!-- Bookbag Activities -->
<string name="delete_button">delete</string>
-
+ <string name="bags_name">name</string>
+ <string name="bags_items">no items</string>
+ <string name="bags_shared">shared</string>
+ <string name="bags_action">action</string>
+ <string name="details">details</string>
+ <string name="bookbagitem_remove">remove</string>
+ <string name="create_bookbag">New : </string>
+ <string name="create">create</string>
+ <string name="bookbag_name">bookbag name</string>
+ <string name="add_button">add</string>
</resources>
\ No newline at end of file
public static String METHOD_FLESH_PUBLIC_CONTAINER = "open-ils.actor.container.flesh";
+ public static String METHOD_CONTAINER_DELETE = "open-ils.actor.container.item.delete";
+
+ public static String METHOD_CONTAINER_CREATE = "open-ils.actor.container.create";
+
+ public static String METHOD_CONTAINER_ITEM_CREATE = "open-ils.actor.container.item.create";
+
+ public static String METHOD_CONTAINER_FULL_DELETE = "open-ils.actor.container.full_delete";
/** The conn. */
public HttpConnection conn;
return items;
}
+ public void removeBookbagItem(Integer id) throws SessionNotFoundException, NoNetworkAccessException, NoAccessToServer {
+
+ removeContainer("biblio", id);
+
+ }
+
+ public void createBookbag(String name) throws SessionNotFoundException, NoNetworkAccessException, NoAccessToServer{
+
+ OSRFObject cbreb = new OSRFObject("cbreb");
+ cbreb.put("btype", "bookbag");
+ cbreb.put("name", name);
+ cbreb.put("pub", false);
+ cbreb.put("owner",userID);
+
+ createContainer("biblio",cbreb);
+ }
+
+ public void deleteBookBag(Integer id) throws SessionNotFoundException, NoNetworkAccessException, NoAccessToServer {
+
+ Object response = Utils.doRequest(conn, SERVICE_ACTOR, METHOD_CONTAINER_FULL_DELETE, authToken, cm, new Object[]{authToken,"biblio",id});
+ }
+
+ public void addRecordToBookBag(Integer record_id, Integer bookbag_id) throws SessionNotFoundException, NoAccessToServer, NoNetworkAccessException{
+
+ OSRFObject cbrebi = new OSRFObject("cbrebi");
+ cbrebi.put("bucket", bookbag_id);
+ cbrebi.put("target_biblio_record_entry", record_id);
+ cbrebi.put("id", null);
+
+ Object response = Utils.doRequest(conn, SERVICE_ACTOR, METHOD_CONTAINER_ITEM_CREATE, authToken, cm, new Object[]{authToken,"biblio",cbrebi});
+ }
+
+ private void removeContainer(String container, Integer id) throws SessionNotFoundException, NoNetworkAccessException, NoAccessToServer {
+
+ Object response = Utils.doRequest(conn, SERVICE_ACTOR, METHOD_CONTAINER_DELETE, authToken, cm, new Object[]{authToken,container,id});
+ }
+
+
+ private void createContainer(String container, Object parameter) throws SessionNotFoundException, NoNetworkAccessException, NoAccessToServer{
+
+ Object response = Utils.doRequest(conn, SERVICE_ACTOR, METHOD_CONTAINER_CREATE, authToken, cm, new Object[]{authToken,container,parameter});
+ }
+
}
package org.evergreen.android.accountAccess.bookbags;
+import java.io.Serializable;
import java.util.ArrayList;
import org.opensrf.util.OSRFObject;
-public class BookBag {
+public class BookBag implements Serializable{
public int id;
public String description = null;
- public String shared = null;
+ public Boolean shared = null;
public ArrayList<BookBagItem> items = null;
String pub_visible = object.getString("pub");
if(pub_visible.equals("f"))
- this.shared = "false";
+ this.shared = false;
else
- this.shared = "true";
+ this.shared = true;
}
}
--- /dev/null
+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.SessionNotFoundException;
+import org.evergreen.android.globals.NoAccessToServer;
+import org.evergreen.android.globals.NoNetworkAccessException;
+import org.evergreen.android.globals.Utils;
+import org.evergreen.android.searchCatalog.RecordInfo;
+import org.evergreen.android.searchCatalog.SearchCatalog;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.ProgressDialog;
+import android.app.Service;
+import android.app.AlertDialog.Builder;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.net.ConnectivityManager;
+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.AdapterView;
+import android.widget.AdapterView.OnItemSelectedListener;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.ListView;
+import android.widget.TextView;
+import android.widget.Toast;
+
+public class BookBagDetails extends Activity{
+
+private String TAG = "BookBags";
+
+ public static final int RESULT_CODE_UPDATE = 1;
+
+ private SearchCatalog search;
+
+ private AccountAccess accountAccess;
+
+ private ListView lv;
+
+ private BookBagItemsArrayAdapter listAdapter = null;
+
+ private ArrayList<BookBagItem> bookBagItems = null;
+
+ private Context context;
+
+ private ProgressDialog progressDialog;
+
+ private BookBag bookBag;
+
+ private TextView bookbag_name;
+
+ private Button delete_bookbag_button;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ // TODO Auto-generated method stub
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.bookbagitem_list);
+ accountAccess = AccountAccess.getAccountAccess();
+ bookBag = (BookBag) getIntent().getSerializableExtra("bookBag");
+
+ context = this;
+ search = SearchCatalog.getInstance((ConnectivityManager)getSystemService(Service.CONNECTIVITY_SERVICE));
+ bookbag_name = (TextView) findViewById(R.id.bookbag_name);
+ delete_bookbag_button = (Button) findViewById(R.id.remove_bookbag);
+ bookbag_name.setText(bookBag.name);
+ delete_bookbag_button.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+
+ final Thread deleteBookbag = new Thread(new Runnable() {
+
+ @Override
+ public void run() {
+
+ try {
+ accountAccess.deleteBookBag(bookBag.id);
+ } catch (SessionNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NoNetworkAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NoAccessToServer e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ progressDialog.dismiss();
+ setResult(RESULT_CODE_UPDATE);
+ finish();
+ }
+ });
+ }
+ });
+
+ Builder confirmationDialogBuilder = new AlertDialog.Builder(
+ context);
+ confirmationDialogBuilder
+ .setMessage("Delete bookbag?");
+
+ confirmationDialogBuilder.setNegativeButton(
+ android.R.string.no, null);
+ confirmationDialogBuilder.setPositiveButton(
+ android.R.string.yes,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog,
+ int which) {
+
+
+ progressDialog = ProgressDialog.show(context, "Please wait", "Deleting Bookbag");
+ deleteBookbag.start();
+
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ progressDialog.dismiss();
+ setResult(RESULT_CODE_UPDATE);
+ finish();
+ }
+ });
+ }
+ });
+
+ confirmationDialogBuilder.create().show();
+
+ }
+ });
+
+ lv = (ListView) findViewById(R.id.bookbagitem_list);
+ bookBagItems = new ArrayList<BookBagItem>();
+ listAdapter = new BookBagItemsArrayAdapter(context, R.layout.bookbagitem_list_item, bookBagItems);
+ lv.setAdapter(listAdapter);
+
+ lv.setOnItemSelectedListener(new OnItemSelectedListener() {
+
+ @Override
+ public void onItemSelected(AdapterView<?> arg0, View arg1,
+ int arg2, long arg3) {
+
+
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView<?> arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ });
+
+ Thread getBookBags = new Thread(new Runnable() {
+
+ @Override
+ public void run() {
+
+ ArrayList<RecordInfo> records = new ArrayList<RecordInfo>();
+ ArrayList<Integer> ids = new ArrayList<Integer>();
+
+ for(int i=0;i<bookBag.items.size();i++){
+ ids.add(bookBag.items.get(i).target_copy);
+ }
+ records = search.getRecordsInfo(ids);
+
+ for(int i=0;i<bookBag.items.size();i++){
+ bookBag.items.get(i).recordInfo = records.get(i);
+ }
+
+ runOnUiThread(new Runnable() {
+
+ @Override
+ public void run() {
+ for(int i=0;i<bookBag.items.size();i++)
+ listAdapter.add(bookBag.items.get(i));
+
+
+ progressDialog.dismiss();
+
+ if(bookBagItems.size() == 0)
+ Toast.makeText(context, "No circ records", Toast.LENGTH_LONG);
+
+ listAdapter.notifyDataSetChanged();
+ }
+ });
+
+
+ }
+ });
+
+ progressDialog = new ProgressDialog(context);
+ progressDialog.setMessage("Please wait while retrieving Book Bag data");
+ progressDialog.show();
+ getBookBags.start();
+
+
+
+
+ }
+
+ class BookBagItemsArrayAdapter extends ArrayAdapter<BookBagItem> {
+ private static final String tag = "BookbagArrayAdapter";
+
+ private TextView title;
+ private TextView author;
+ private Button remove;
+
+
+ private List<BookBagItem> records = new ArrayList<BookBagItem>();
+
+ public BookBagItemsArrayAdapter(Context context, int textViewResourceId,
+ List<BookBagItem> objects) {
+ super(context, textViewResourceId, objects);
+ this.records = objects;
+ }
+
+ public int getCount() {
+ return this.records.size();
+ }
+
+ public BookBagItem getItem(int index) {
+ return this.records.get(index);
+ }
+
+ public View getView(int position, View convertView, ViewGroup parent) {
+ View row = convertView;
+
+ // Get item
+ final BookBagItem 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.bookbagitem_list_item, parent, false);
+ Log.d(tag, "Successfully completed XML Row Inflation!");
+
+ }
+
+ title = (TextView) row.findViewById(R.id.bookbagitem_title);
+
+ author = (TextView) row.findViewById(R.id.bookbagitem_author);
+
+ remove = (Button) row.findViewById(R.id.bookbagitem_remove_button);
+
+ title.setText(record.recordInfo.title);
+
+ author.setText(record.recordInfo.author);
+
+ remove.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+
+
+ Thread removeItem = new Thread(new Runnable() {
+
+ @Override
+ public void run() {
+
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ progressDialog = ProgressDialog.show(context, "Please wait", "Removing item");
+ }
+ });
+
+ try {
+ accountAccess.removeBookbagItem(record.id);
+ } catch (SessionNotFoundException e) {
+
+ try{
+ if(accountAccess.authenticate())
+ accountAccess.removeBookbagItem(record.id);
+ }catch(Exception e1){};
+
+ e.printStackTrace();
+ } catch (NoNetworkAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NoAccessToServer e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ progressDialog.dismiss();
+ }
+ });
+ }
+ });
+
+ removeItem.start();
+ }
+ });
+
+ return row;
+ }
+ }
+}
package org.evergreen.android.accountAccess.bookbags;
+import java.io.Serializable;
+
+import org.evergreen.android.searchCatalog.RecordInfo;
import org.opensrf.util.OSRFObject;
-public class BookBagItem {
+public class BookBagItem implements Serializable{
public int target_copy;
+ public int id;
+
+ public RecordInfo recordInfo;
+
public BookBagItem(OSRFObject cbrebi){
this.target_copy = cbrebi.getInt("target_biblio_record_entry");
+ this.id = cbrebi.getInt("id");
+
}
}
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.content.Intent;
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.AdapterView;
+import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.CheckBox;
+import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
private Context context;
private ProgressDialog progressDialog;
+
+ private EditText bookbag_name;
+
+ private Button create_bookbag;
+
+ private Runnable getBookbagsRunnable;
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
- setContentView(R.layout.checkout_list);
+ setContentView(R.layout.bookbag_list);
context = this;
accountAccess = AccountAccess.getAccountAccess();
+
+ bookbag_name = (EditText) findViewById(R.id.bookbag_create_name);
+ create_bookbag = (Button) findViewById(R.id.bookbag_create_button);
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() {
+ lv.setOnItemSelectedListener(new OnItemSelectedListener() {
+
+ @Override
+ public void onItemSelected(AdapterView<?> arg0, View arg1,
+ int position, long arg3) {
+
+
+ Toast.makeText(getApplicationContext(), "Text", Toast.LENGTH_LONG).show();
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView<?> arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ });
+ create_bookbag.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+
+ final String name = bookbag_name.getText().toString();
+
+ Thread createBookbag = new Thread(new Runnable() {
+ @Override
+ public void run() {
+
+ if(name.length()>1){
+ try {
+ accountAccess.createBookbag(name);
+ } catch (SessionNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NoNetworkAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NoAccessToServer e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ progressDialog.dismiss();
+ }
+ });
+
+ Thread getBookBags = new Thread(getBookbagsRunnable);
+ getBookBags.start();
+ }
+
+ }
+ });
+
+ if(name.length()>1){
+ progressDialog = ProgressDialog.show(context, "Please wait", "Creating Bookbag");
+ createBookbag.start();
+ }
+ else
+ Toast.makeText(context, "Bookbag name must be at least 2 characters long", Toast.LENGTH_SHORT).show();
+ }
+ });
+
+ getBookbagsRunnable = new Runnable() {
@Override
public void run() {
-
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ progressDialog = ProgressDialog.show(context, "Plese wait", "retrieving Bookbag data");
+ }
+ });
try {
bookBags = accountAccess.getBookbags();
@Override
public void run() {
+ listAdapter.clear();
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);
+ Toast.makeText(context, "No data", Toast.LENGTH_LONG);
listAdapter.notifyDataSetChanged();
}
}
- });
+ };
+
+ Thread getBookBags = new Thread(getBookbagsRunnable);
if(accountAccess.isAuthenticated()){
- progressDialog = new ProgressDialog(context);
- progressDialog.setMessage("Please wait while retrieving Book Bag data");
- progressDialog.show();
getBookBags.start();
}
}
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ // TODO Auto-generated method stub
+ super.onActivityResult(requestCode, resultCode, data);
+
+ switch(resultCode){
+
+ case BookBagDetails.RESULT_CODE_UPDATE : {
+ Thread getBookBags = new Thread(getBookbagsRunnable);
+ getBookBags.start();
+ } break;
+
+ }
+ }
class BookBagsArrayAdapter extends ArrayAdapter<BookBag> {
private static final String tag = "BookbagArrayAdapter";
private TextView name;
private TextView items;
- private TextView shared;
-
+ private CheckBox shared;
+ private Button detailsButton;
private List<BookBag> records = new ArrayList<BookBag>();
items = (TextView) row.findViewById(R.id.bookbag_items);
- shared = (TextView) row.findViewById(R.id.bookbag_shared);
+ shared = (CheckBox) row.findViewById(R.id.bookbag_shared);
+
+ detailsButton = (Button) row.findViewById(R.id.details_button);
name.setText(record.name+"");
- items.setText("items :" + record.items.size());
+ items.setText(record.items.size() + "");
- shared.setText(record.shared);
+ shared.setChecked(record.shared);
+
+ detailsButton.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ Intent intent = new Intent(context,BookBagDetails.class);
+ intent.putExtra("bookBag", record);
+ startActivityForResult(intent, 0);
+
+ }
+ });
return row;
}
System.out.println("Exception in reAuth");
}
}
-
-
-
-
+
runOnUiThread(new Runnable() {
@Override
public void run() {
for(int i=0;i<ids.size();i++){
- RecordInfo record = new RecordInfo(getItemShortInfo(ids.get(i)));
+ RecordInfo record = new RecordInfo(getItemShortInfo(Integer.parseInt(ids.get(i))));
//get copy information
resultsRecordInfo.add(record);
* @param id the id
* @return the item short info
*/
- private OSRFObject getItemShortInfo(String id){
+ private OSRFObject getItemShortInfo(Integer id){
Method method = new Method(METHOD_SLIM_RETRIVE);
}
+
+ public ArrayList<RecordInfo> getRecordsInfo(ArrayList<Integer> ids){
+
+ ArrayList<RecordInfo> recordInfoArray = new ArrayList<RecordInfo>();
+
+ for(int i=0;i<ids.size();i++){
+ RecordInfo recordInfo = new RecordInfo(getItemShortInfo(ids.get(i)));
+ recordInfoArray.add(recordInfo);
+ }
+
+ return recordInfoArray;
+ }
+
/**
* Select organisation.
*
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.accountAccess.bookbags.BookBag;
import org.evergreen.android.accountAccess.holds.PlaceHold;
import org.evergreen.android.globals.GlobalConfigs;
import org.evergreen.android.globals.NoAccessToServer;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.TextView;
+import android.widget.Toast;
public class SearchCatalogListView extends Activity{
private static final int PLACE_HOLD = 0;
private static final int DETAILS = 1;
+
+ private static final int BOOK_BAG = 2;
private TextView searchResultsNumber;
+ private ArrayList<BookBag> bookBags;
+
+ private Integer bookbag_selected = -1;
+
private final ImageDownloader imageDownloader = new ImageDownloader();
@Override
});
+ //get bookbags
+ Runnable getBookbagsRunnable = new Runnable() {
+
+ @Override
+ public void run() {
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ progressDialog = ProgressDialog.show(context, "Plese wait", "retrieving Bookbag data");
+ }
+ });
+ AccountAccess accountAccess = AccountAccess.getAccountAccess();
+ 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() {
+ progressDialog.dismiss();
+
+
+
+ }
+ });
+
+
+ }
+ };
+
+ Thread getBookBags = new Thread(getBookbagsRunnable);
+ getBookBags.start();
+
+
}
@Override
menu.add(Menu.NONE, DETAILS,0,"Details");
menu.add(Menu.NONE,PLACE_HOLD,1,"Place Hold");
+ menu.add(Menu.NONE,BOOK_BAG,2,"Add to bookbag");
}
}
AdapterView.AdapterContextMenuInfo menuArrayItem = (AdapterView.AdapterContextMenuInfo)item.getMenuInfo();
int menuItemIndex = item.getItemId();
- RecordInfo info = (RecordInfo)lv.getItemAtPosition(menuArrayItem.position);
+ final RecordInfo info = (RecordInfo)lv.getItemAtPosition(menuArrayItem.position);
//start activity with book details
startActivity(intent);
}
+
+ case BOOK_BAG : {
+
+
+ if(bookBags.size() > 0){
+ String array_spinner[] = new String[bookBags.size()];
+
+ for(int i=0;i<array_spinner.length;i++)
+ array_spinner[i] = bookBags.get(i).name;
+
+
+ AlertDialog.Builder builder;
+ AlertDialog alertDialog;
+
+ LayoutInflater inflater = (LayoutInflater) context.getSystemService(LAYOUT_INFLATER_SERVICE);
+ View layout = inflater.inflate(R.layout.bookbag_spinner,null);
+
+ Spinner s = (Spinner) layout.findViewById(R.id.bookbag_spinner);
+
+ Button add = (Button) layout.findViewById(R.id.add_to_bookbag_button);
+ ArrayAdapter adapter = new ArrayAdapter(context,android.R.layout.simple_spinner_item, array_spinner);
+
+ s.setAdapter(adapter);
+
+
+ add.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ // TODO Auto-generated method stub
+ Thread addtoBookbag = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ AccountAccess ac = AccountAccess.getAccountAccess();
+ try {
+ ac.addRecordToBookBag(info.doc_id, bookBags.get(bookbag_selected).id);
+ } catch (SessionNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NoAccessToServer e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NoNetworkAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ progressDialog.dismiss();
+ }
+ });
+
+ }
+ });
+ progressDialog.show(context, "Please wait", "Add to bookbag");
+ addtoBookbag.start();
+ }});
+
+ builder = new AlertDialog.Builder(context);
+ builder.setView(layout);
+ alertDialog = builder.create();
+ alertDialog.show();
+
+
+
+ s.setOnItemSelectedListener(new OnItemSelectedListener() {
+
+ @Override
+ public void onItemSelected(AdapterView<?> arg0, View arg1,
+ int position, long arg3) {
+
+ bookbag_selected = position;
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView<?> arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ });
+
+
+ }
+ else
+ Toast.makeText(context, "No bookbags", Toast.LENGTH_SHORT).show();
+
+ }
break;
}