From af7508869de08a442fbce27d34c14e5e8a455b52 Mon Sep 17 00:00:00 2001 From: drizea Date: Sat, 7 Jul 2012 13:23:40 +0300 Subject: [PATCH] basic fines info finished --- Open-ILS/src/Android/res/layout/fines.xml | 8 ++ .../src/Android/res/layout/fines_list_item.xml | 55 ++++++++++++ Open-ILS/src/Android/res/values/colors.xml | 1 + Open-ILS/src/Android/res/values/strings.xml | 1 + .../android/accountAccess/AccountAccess.java | 24 ++++- .../android/accountAccess/fines/FinesActivity.java | 100 ++++++++++++++++++++- .../android/accountAccess/fines/FinesRecord.java | 49 ++++++++++ 7 files changed, 233 insertions(+), 5 deletions(-) create mode 100644 Open-ILS/src/Android/res/layout/fines_list_item.xml create mode 100644 Open-ILS/src/Android/src/org/evergreen/android/accountAccess/fines/FinesRecord.java diff --git a/Open-ILS/src/Android/res/layout/fines.xml b/Open-ILS/src/Android/res/layout/fines.xml index 6be2116cfa..feb41cf41a 100644 --- a/Open-ILS/src/Android/res/layout/fines.xml +++ b/Open-ILS/src/Android/res/layout/fines.xml @@ -61,6 +61,14 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Open-ILS/src/Android/res/values/colors.xml b/Open-ILS/src/Android/res/values/colors.xml index 9f562e4452..b406692076 100644 --- a/Open-ILS/src/Android/res/values/colors.xml +++ b/Open-ILS/src/Android/res/values/colors.xml @@ -34,4 +34,5 @@ #ffffff #1e90ff + #ff0000 diff --git a/Open-ILS/src/Android/res/values/strings.xml b/Open-ILS/src/Android/res/values/strings.xml index 47f36d9c86..4c4d80422a 100644 --- a/Open-ILS/src/Android/res/values/strings.xml +++ b/Open-ILS/src/Android/res/values/strings.xml @@ -40,5 +40,6 @@ Total Owned Total Paid Balance Owed + Overdue Materials \ No newline at end of file diff --git a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/AccountAccess.java b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/AccountAccess.java index 5c4f05268c..fd89ddcbcc 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/AccountAccess.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/AccountAccess.java @@ -9,6 +9,7 @@ import java.util.List; import java.util.Map; import org.evergreen.android.accountAccess.checkout.CircRecord; +import org.evergreen.android.accountAccess.fines.FinesRecord; import org.evergreen.android.accountAccess.holds.HoldRecord; import org.evergreen.android.globals.Utils; import org.evergreen.android.searchCatalog.RecordInfo; @@ -183,8 +184,8 @@ public class AccountAccess { * containing : transaction, circ, record * @param : authToken, userID * @returns : array of objects, must investigate - */ - public static String METHOD_FETCH_TRANSACTIONS = "open-ils.actor.user.transactions.have_charged.fleshed"; + */ + public static String METHOD_FETCH_TRANSACTIONS = "open-ils.actor.user.transactions.have_charge.fleshed"; /** The METHOD_FETCH_MONEY_BILLING * description : @@ -936,11 +937,26 @@ public class AccountAccess { return fines; } - private Object getTransactions(){ + public ArrayList getTransactions(){ + + ArrayList finesRecords = new ArrayList(); Object transactions = Utils.doRequest(conn,SERVICE_ACTOR, METHOD_FETCH_TRANSACTIONS, new Object[]{authToken,userID}); - return transactions; + + //get Array + + List> list = (List>)transactions; + + for(int i=0;i item = list.get(i); + + FinesRecord record = new FinesRecord(item.get("circ"),item.get("record"),item.get("transaction")); + finesRecords.add(record); + } + + return finesRecords; } //---------------------------------------Book bags-----------------------------------// diff --git a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/fines/FinesActivity.java b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/fines/FinesActivity.java index 94148b621e..94ad2c2e22 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/fines/FinesActivity.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/fines/FinesActivity.java @@ -1,12 +1,21 @@ package org.evergreen.android.accountAccess.fines; +import java.util.ArrayList; +import java.util.List; + import org.evergreen.android.R; import org.evergreen.android.accountAccess.AccountAccess; import android.app.Activity; import android.app.ProgressDialog; import android.content.Context; +import android.graphics.Color; import android.os.Bundle; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; @@ -19,7 +28,7 @@ public class FinesActivity extends Activity{ private TextView balance_owed; - private ListView overdue_materials; + private ListView lv; private Runnable getFinesInfo; @@ -27,12 +36,16 @@ public class FinesActivity extends Activity{ private ProgressDialog progressDialog; + private OverdueMaterialsArrayAdapter listAdapter; + + private Context context; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fines); + lv = (ListView) findViewById(R.id.fines_overdue_materials_list); total_owned = (TextView) findViewById(R.id.fines_total_owned); total_paid = (TextView) findViewById(R.id.fines_total_paid); @@ -42,6 +55,12 @@ public class FinesActivity extends Activity{ ac = AccountAccess.getAccountAccess(); + + ArrayList finesRecords = new ArrayList(); + listAdapter = new OverdueMaterialsArrayAdapter(context, R.layout.fines_list_item,finesRecords); + lv.setAdapter(listAdapter); + + progressDialog = ProgressDialog.show(this, null, "Retrieving fines"); getFinesInfo = new Runnable() { @@ -50,10 +69,19 @@ public class FinesActivity extends Activity{ final float[] fines = ac.getFinesSummary(); + final ArrayList finesRecords = ac.getTransactions(); + runOnUiThread(new Runnable() { @Override public void run() { + listAdapter.clear(); + + for(int i=0;i { + private static final String tag = "CheckoutArrayAdapter"; + + private TextView fineTitle; + private TextView fineAuthor; + private TextView fineBalanceOwed; + private TextView fineStatus; + + private List records = new ArrayList(); + + public OverdueMaterialsArrayAdapter(Context context, int textViewResourceId, + List objects) { + super(context, textViewResourceId, objects); + this.records = objects; + } + + public int getCount() { + return this.records.size(); + } + + public FinesRecord getItem(int index) { + return this.records.get(index); + } + + public View getView(int position, View convertView, ViewGroup parent) { + View row = convertView; + + // Get item + final FinesRecord record = getItem(position); + + if(row == null){ + + Log.d(tag, "Starting XML view more infaltion ... "); + LayoutInflater inflater = (LayoutInflater) this.getContext() + .getSystemService(Context.LAYOUT_INFLATER_SERVICE); + row = inflater.inflate(R.layout.fines_list_item, parent, false); + Log.d(tag, "Successfully completed XML view more Inflation!"); + + + } + // Get reference to TextView - title + fineTitle = (TextView) row.findViewById(R.id.fines_title); + + // Get reference to TextView author + fineAuthor = (TextView) row.findViewById(R.id.fines_author); + + //Get hold status + fineBalanceOwed = (TextView) row.findViewById(R.id.fines_balance_owed); + + fineStatus = (TextView) row.findViewById(R.id.fines_status); + //set text + + + //set raw information + fineTitle.setText(record.title); + fineAuthor.setText(record.author); + fineBalanceOwed.setText(record.balance_owed); + //status.setText(record.getHoldStatus()); + fineStatus.setText(record.getStatus()); + + if(record.getStatus().equals("returned")){ + fineStatus.setTextColor(Color.argb(255, 0, 255, 0)); + } + else + fineStatus.setTextColor(Color.argb(255, 255, 0, 0)); + + return row; + } + } } diff --git a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/fines/FinesRecord.java b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/fines/FinesRecord.java new file mode 100644 index 0000000000..d27be890b6 --- /dev/null +++ b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/fines/FinesRecord.java @@ -0,0 +1,49 @@ +package org.evergreen.android.accountAccess.fines; + +import java.util.Date; + +import org.evergreen.android.globals.GlobalConfigs; +import org.opensrf.util.OSRFObject; + +public class FinesRecord { + + public String title; + + public String author; + + public Date checkoutDate; + + public Date dueDate; + + public Date dateReturned; + + public String balance_owed; + + private Date checkin_time; + + public FinesRecord(OSRFObject circ, OSRFObject mvr_record, OSRFObject mbts_transaction){ + + + title = mvr_record.getString("title"); + author = mvr_record.getString("author"); + + balance_owed = mbts_transaction.getString("total_owed"); + + if(circ.get("checkin_time") != null){ + checkin_time = GlobalConfigs.parseDate(circ.getString("checkin_time")); + } + else + checkin_time = null; + + } + + //if returned or fines still acumulating + public String getStatus(){ + + if(checkin_time != null) + return "returned"; + + return "fines accruing"; + + } +} -- 2.11.0