types_of_resource icon.
<?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>
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;
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;
}
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");
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;
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,
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;
public String author = null;
- public String types_of_resource;
+ public String format = "";
// only for P types
public String part_label = null;
*/
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;
SplashActivity.restartApp(this);
return;
}
+ SearchFormat.init(this);
setContentView(R.layout.holds_list);
@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;
private TextView holdTitle;
private TextView holdAuthor;
+ private TextView holdFormat;
private TextView status;
- private ImageView hold_icon;
private List<HoldRecord> records = new ArrayList<HoldRecord>();
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
- // Get item
final HoldRecord record = getItem(position);
if (row == null) {
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;