From: drizea Date: Fri, 22 Jun 2012 10:43:47 +0000 (+0300) Subject: Checkout Items list done need UI dev on it X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=02b5a449760f5704ad93b83c5e96ee9eac4251e3;p=working%2FEvergreen.git Checkout Items list done need UI dev on it --- diff --git a/Open-ILS/src/Android/AndroidManifest.xml b/Open-ILS/src/Android/AndroidManifest.xml index 62dd77e620..f7e108d96b 100644 --- a/Open-ILS/src/Android/AndroidManifest.xml +++ b/Open-ILS/src/Android/AndroidManifest.xml @@ -38,6 +38,10 @@ > + + + + diff --git a/Open-ILS/src/Android/res/layout/checkout_list.xml b/Open-ILS/src/Android/res/layout/checkout_list.xml new file mode 100644 index 0000000000..392ff2a956 --- /dev/null +++ b/Open-ILS/src/Android/res/layout/checkout_list.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Open-ILS/src/Android/res/layout/checkout_list_item.xml b/Open-ILS/src/Android/res/layout/checkout_list_item.xml new file mode 100644 index 0000000000..5c2845327c --- /dev/null +++ b/Open-ILS/src/Android/res/layout/checkout_list_item.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + \ 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 02411112c4..1985ae1502 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 @@ -17,6 +17,7 @@ import org.opensrf.util.OSRFObject; /** * The Class AuthenticateUser. + * Singleton class */ public class AccountAccess { @@ -221,12 +222,13 @@ public class AccountAccess { /** The password. */ public static String password = "demo123"; + private static AccountAccess accountAccess = null; /** * Instantiates a new authenticate user. * * @param httpAddress the http address */ - public AccountAccess(String httpAddress) { + private AccountAccess(String httpAddress) { this.httpAddress = httpAddress; @@ -243,6 +245,42 @@ public class AccountAccess { } + public static AccountAccess getAccountAccess(String httpAddress){ + + if(accountAccess == null){ + accountAccess = new AccountAccess(httpAddress); + } + if(!httpAddress.equals(accountAccess.httpAddress)) + accountAccess.updateHttpAddress(httpAddress); + + return accountAccess; + } + + // the object must be initialized before + public static AccountAccess getAccountAccess(){ + + if(accountAccess != null){ + return accountAccess; + } + + return null; + } + /* + * Change the Http conn to a new library address + */ + public void updateHttpAddress(String httpAddress){ + + try { + // configure the connection + + System.out.println("Connection with " + httpAddress); + conn = new HttpConnection(httpAddress + "/osrf-gateway-v1"); + + } catch (Exception e) { + System.err.println("Exception in establishing connection " + + e.getMessage()); + } + } /** * Md5. * @@ -374,6 +412,8 @@ public class AccountAccess { System.err.println("Error in parsing authtime " + e.getMessage()); } + //get user ID + accountAccess.getAccountSummary(); return true; } @@ -384,34 +424,60 @@ public class AccountAccess { //------------------------Checked Out Items Section -------------------------// - public void getItemsCheckedOut(){ + public ArrayList getItemsCheckedOut(){ + + ArrayList circRecords = new ArrayList(); + /* ArrayList long_overdue = new ArrayList(); ArrayList claims_returned = new ArrayList(); ArrayList lost = new ArrayList(); ArrayList out = new ArrayList(); + ArrayList overdue = new ArrayList(); + */ + //fetch ids List long_overdue_id; + List overdue_id; List claims_returned_id; List lost_id; List out_id; + Object resp = Utils.doRequest(conn, SERVICE_ACTOR, METHOD_FETCH_CHECKED_OUT_SUM, new Object[]{authToken, userID}); long_overdue_id = (List)((Map)resp).get("long_overdue"); claims_returned_id = (List)((Map)resp).get("claims_returned"); lost_id = (List)((Map)resp).get("lost"); out_id = (List)((Map)resp).get("out"); + overdue_id = (List)((Map)resp).get("overdue"); //get all the record circ info - for(int i=0;i circRecords = null; + + @Override + public void onCreate(Bundle savedInstanceState) { + // TODO Auto-generated method stub + super.onCreate(savedInstanceState); + + setContentView(R.layout.checkout_list); + + accountAccess = AccountAccess.getAccountAccess(); + + lv = (ListView) findViewById(R.id.checkout_items_list); + + circRecords = accountAccess.getItemsCheckedOut(); + + listAdapter = new CheckOutArrayAdapter(this, R.layout.checkout_list_item, circRecords); + lv.setAdapter(listAdapter); + + + + listAdapter.notifyDataSetChanged(); + + } + + + class CheckOutArrayAdapter extends ArrayAdapter { + private static final String tag = "CheckoutArrayAdapter"; + + private TextView recordTitle; + private TextView recordAuthor; + private TextView recordDueDate; + private TextView recordRenewals; + + private List records = new ArrayList(); + + public CheckOutArrayAdapter(Context context, int textViewResourceId, + List objects) { + super(context, textViewResourceId, objects); + this.records = objects; + } + + public int getCount() { + return this.records.size(); + } + + public CircRecord getItem(int index) { + return this.records.get(index); + } + + public View getView(int position, View convertView, ViewGroup parent) { + View row = convertView; + + // Get item + CircRecord record = getItem(position); + + + if(record == null) + { + Log.d(tag, "Starting XML view more infaltion ... "); + LayoutInflater inflater = (LayoutInflater) this.getContext() + .getSystemService(Context.LAYOUT_INFLATER_SERVICE); + row = inflater.inflate(R.layout.search_result_footer_view, parent, false); + Log.d(tag, "Successfully completed XML view more Inflation!"); + + + } + else{ + + //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.checkout_list_item, parent, false); + Log.d(tag, "Successfully completed XML Row Inflation!"); + + } + + // Get reference to TextView - title + recordTitle = (TextView) row.findViewById(R.id.checkout_record_title); + + // Get reference to TextView - author + recordAuthor = (TextView) row.findViewById(R.id.checkout_record_author); + + //Get reference to TextView - record Publisher date+publisher + recordDueDate = (TextView) row.findViewById(R.id.checkout_due_date); + + //Get remaining renewals + recordRenewals = (TextView) row.findViewById(R.id.checkout_renewals_remaining); + //set text + System.out.println("Row" + record.getTitle() + " " + record.getAuthor() + " " + record.getDueDate() + " " + record.getRenewals()); + recordTitle.setText(record.getTitle()); + recordAuthor.setText(record.getAuthor()); + recordDueDate.setText(record.getDueDate()); + recordRenewals.setText(record.getRenewals()); + } + + return row; + } + } +} diff --git a/Open-ILS/src/Android/src/org/evergreen/android/globals/GlobalConfigs.java b/Open-ILS/src/Android/src/org/evergreen/android/globals/GlobalConfigs.java index b5533d3ad6..d6db656059 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/globals/GlobalConfigs.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/globals/GlobalConfigs.java @@ -66,7 +66,7 @@ public class GlobalConfigs { //authenticate - AccountAccess ac = new AccountAccess(GlobalConfigs.httpAddress); + AccountAccess ac = AccountAccess.getAccountAccess(GlobalConfigs.httpAddress); ac.authenticate(); return true; diff --git a/Open-ILS/src/Android/src/org/evergreen/android/globals/Utils.java b/Open-ILS/src/Android/src/org/evergreen/android/globals/Utils.java index be017b2aa1..333dc345ca 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/globals/Utils.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/globals/Utils.java @@ -9,6 +9,7 @@ import java.net.MalformedURLException; import java.net.SocketTimeoutException; import java.net.URL; import java.net.URLConnection; +import java.util.Map; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; @@ -18,7 +19,7 @@ import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.params.BasicHttpParams; import org.apache.http.params.HttpConnectionParams; import org.apache.http.params.HttpParams; -import org.evergreen.android.accountAccess.SessionNotFoundException; +import org.evergreen.android.accountAccess.AccountAccess; import org.opensrf.Method; import org.opensrf.net.http.GatewayRequest; import org.opensrf.net.http.HttpConnection; @@ -218,15 +219,17 @@ public class Utils { } - - public static Object doRequest(HttpConnection conn, String service, String methodName, Object[] params) throws SessionNotFoundException{ - + //TODO throw NO_SESSION + public static Object doRequest(HttpConnection conn, String service, String methodName, Object[] params) //throws SessionNotFoundException{ + { //TODO check params and throw errors Method method = new Method(methodName); - - for(int i=0;i)response).get("textcode"); + if(textcode != null){ + if(textcode.equals("NO_SESSION")){ + response = requireNewSession(conn, service, methodName, params); + } + + } + }catch(Exception e){ + + } + return response; } return null; } - + + public static Object requireNewSession(HttpConnection conn, String service, String methodName, Object[] params){ + + AccountAccess ac = AccountAccess.getAccountAccess(); + boolean success = ac.authenticate(); + + Object response = null; + + if(success){ + response = doRequest(conn, service, methodName, params); + } + + return response; + } } diff --git a/Open-ILS/src/Android/src/org/evergreen/android/views/AccountScreenDashboard.java b/Open-ILS/src/Android/src/org/evergreen/android/views/AccountScreenDashboard.java index c5dd27d2fb..30c20e756f 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/views/AccountScreenDashboard.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/views/AccountScreenDashboard.java @@ -2,9 +2,10 @@ package org.evergreen.android.views; import org.evergreen.android.R; -import org.evergreen.android.globals.GlobalConfigs; +import org.evergreen.android.accountAccess.ItemsCheckOutListView; import android.app.Activity; +import android.content.Intent; import android.os.Bundle; import android.view.View; @@ -110,7 +111,7 @@ public class AccountScreenDashboard extends Activity { switch (id) { case R.id.account_btn_check_out : - //startActivity (new Intent(getApplicationContext(), F3Activity.class)); + startActivity (new Intent(getApplicationContext(),ItemsCheckOutListView.class)); break; case R.id.account_btn_holds: //startActivity (new Intent(getApplicationContext(), F4Activity.class)); diff --git a/Open-ILS/src/Android/src/org/evergreen/android/views/ApplicationPreferences.java b/Open-ILS/src/Android/src/org/evergreen/android/views/ApplicationPreferences.java index e7d82e2bc2..416f00da18 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/views/ApplicationPreferences.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/views/ApplicationPreferences.java @@ -75,6 +75,8 @@ public class ApplicationPreferences extends PreferenceActivity implements OnShar public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { + + if(key.equals("username")){ AccountAccess.userName = sharedPreferences.getString("username", ""); }else @@ -95,7 +97,7 @@ public class ApplicationPreferences extends PreferenceActivity implements OnShar public void run() { boolean routeToAddress = true; - AccountAccess account = new AccountAccess(GlobalConfigs.httpAddress); + AccountAccess account = AccountAccess.getAccountAccess(GlobalConfigs.httpAddress); try{ Utils.checkNetworkStatus((ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE), context); }catch(NoNetworkAccessException e){