added splash screen + make each method throw conenction exceptions user/drizea/android
authordrizea <danielrizea27@gmail.com>
Thu, 12 Jul 2012 12:39:45 +0000 (15:39 +0300)
committerdrizea <danielrizea27@gmail.com>
Thu, 12 Jul 2012 12:39:45 +0000 (15:39 +0300)
The splash screen is not finished, it must be included in the application logic
Each method that conencts to EG server now throws NoNetworkAvailableException, NoServerAvailalbeException and if necessary, SessionNotFoundException

24 files changed:
Open-ILS/src/Android/AndroidManifest.xml
Open-ILS/src/Android/res/drawable/background_splash.xml [new file with mode: 0644]
Open-ILS/src/Android/res/drawable/evergreen_logo.png [new file with mode: 0644]
Open-ILS/src/Android/res/drawable/main_logo.png [new file with mode: 0644]
Open-ILS/src/Android/res/layout/activity_splash.xml [new file with mode: 0644]
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/AccountAccess.java
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/SessionNotFoundException.java
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/checkout/ItemsCheckOutListView.java
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/fines/FinesActivity.java
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/holds/HoldDetails.java
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/holds/HoldsListView.java
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/holds/PlaceHold.java
Open-ILS/src/Android/src/org/evergreen/android/globals/GlobalConfigs.java
Open-ILS/src/Android/src/org/evergreen/android/globals/NoAccessToHttpAddress.java [deleted file]
Open-ILS/src/Android/src/org/evergreen/android/globals/NoAccessToServer.java [new file with mode: 0644]
Open-ILS/src/Android/src/org/evergreen/android/globals/ShowNetworkNotAvailableRunnable.java [new file with mode: 0644]
Open-ILS/src/Android/src/org/evergreen/android/globals/ShowServerNotAvailableRunnable.java [new file with mode: 0644]
Open-ILS/src/Android/src/org/evergreen/android/globals/Utils.java
Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SearchCatalog.java
Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SearchCatalogListView.java
Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/TabsView.java
Open-ILS/src/Android/src/org/evergreen/android/views/ApplicationPreferences.java
Open-ILS/src/Android/src/org/evergreen/android/views/splashscreen/LoadingTask.java [new file with mode: 0644]
Open-ILS/src/Android/src/org/evergreen/android/views/splashscreen/SplashActivity.java [new file with mode: 0644]

index a22d270..357b319 100644 (file)
         >
 
         <activity
-            android:name=".views.MainScreenDashboard"
+            android:name=".views.splashscreen.SplashActivity"
             android:label="@string/app_name"
             android:theme="@android:style/Theme.Light.NoTitleBar"
-             >
-            <intent-filter>
+            >
+               <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
-            </intent-filter>
+            </intent-filter>          
+        </activity>
+        
+        <activity
+            android:name=".views.MainScreenDashboard"
+            android:label="@string/app_name"
+            android:theme="@android:style/Theme.Light.NoTitleBar"
+             >
         </activity>
         
         <activity android:name=".views.AccountScreenDashboard"
diff --git a/Open-ILS/src/Android/res/drawable/background_splash.xml b/Open-ILS/src/Android/res/drawable/background_splash.xml
new file mode 100644 (file)
index 0000000..bd15294
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <gradient
+        android:angle="45"
+        android:endColor="#E5E5E5"
+        android:startColor="#FFFFFF" />
+
+</shape>
\ No newline at end of file
diff --git a/Open-ILS/src/Android/res/drawable/evergreen_logo.png b/Open-ILS/src/Android/res/drawable/evergreen_logo.png
new file mode 100644 (file)
index 0000000..3448dba
Binary files /dev/null and b/Open-ILS/src/Android/res/drawable/evergreen_logo.png differ
diff --git a/Open-ILS/src/Android/res/drawable/main_logo.png b/Open-ILS/src/Android/res/drawable/main_logo.png
new file mode 100644 (file)
index 0000000..a01d157
Binary files /dev/null and b/Open-ILS/src/Android/res/drawable/main_logo.png differ
diff --git a/Open-ILS/src/Android/res/layout/activity_splash.xml b/Open-ILS/src/Android/res/layout/activity_splash.xml
new file mode 100644 (file)
index 0000000..376e010
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:background="@drawable/background_splash"
+    android:gravity="center_horizontal"
+    android:orientation="vertical" >
+
+
+    <ImageView 
+        android:id="@+id/logo"
+        android:layout_width="280dip"
+        android:layout_height="wrap_content"
+        android:src="@drawable/evergreen_logo"
+        android:layout_centerInParent="true"
+        
+        />
+    
+
+    
+    <ProgressBar
+        android:id="@+id/activity_splash_progress_bar"
+        style="@android:style/Widget.ProgressBar.Horizontal"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:layout_below="@id/logo"
+        android:paddingTop="40dip"
+         />
+
+        <TextView 
+        android:id="@+id/action_in_progress"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:layout_below="@id/logo"
+        android:layout_above="@id/activity_splash_progress_bar"
+        android:paddingTop="20dip"
+        />
+</RelativeLayout>
\ No newline at end of file
index bfcf2ce..1608ae1 100644 (file)
@@ -11,6 +11,8 @@ 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.NoAccessToServer;
+import org.evergreen.android.globals.NoNetworkAccessException;
 import org.evergreen.android.globals.Utils;
 import org.evergreen.android.searchCatalog.RecordInfo;
 import org.opensrf.Method;
@@ -19,6 +21,8 @@ import org.opensrf.net.http.HttpConnection;
 import org.opensrf.net.http.HttpRequest;
 import org.opensrf.util.OSRFObject;
 
+import android.net.ConnectivityManager;
+
 /**
  * The Class AuthenticateUser.
  * Singleton class
@@ -226,6 +230,8 @@ public class AccountAccess {
         * */
        public String authToken = null;
        
+       private ConnectivityManager cm;
+       
        /** The auth time. */
        private Integer authTime = null;
        
@@ -243,10 +249,11 @@ public class AccountAccess {
         *
         * @param httpAddress the http address
         */
-       private AccountAccess(String httpAddress) {
+       private AccountAccess(String httpAddress, ConnectivityManager cm) {
 
                this.httpAddress = httpAddress;
-
+               this.cm = cm;
+               
                try {
                        // configure the connection
                        
@@ -268,10 +275,10 @@ public class AccountAccess {
                return false;
        }
        
-       public static AccountAccess getAccountAccess(String httpAddress){
+       public static AccountAccess getAccountAccess(String httpAddress, ConnectivityManager cm){
                
                if(accountAccess == null){
-                       accountAccess = new AccountAccess(httpAddress);
+                       accountAccess = new AccountAccess(httpAddress,cm);
                }
                System.out.println(" Addresses " + httpAddress + " " + accountAccess.httpAddress);
                if(!httpAddress.equals(accountAccess.httpAddress))
@@ -347,7 +354,7 @@ public class AccountAccess {
        /**
         * Authenticate.
         */
-       public boolean authenticate(){
+       public boolean authenticate() throws NoNetworkAccessException, NoAccessToServer{
                
                String seed = authenticateInit();
                
@@ -383,12 +390,12 @@ public class AccountAccess {
         * Authenticate init.
         * @return seed for phase 2 of login
         */
-       private String authenticateInit() {
+       private String authenticateInit() throws NoAccessToServer,NoNetworkAccessException{
 
                String seed = null;
 
                System.out.println("Send request to " + httpAddress);
-               Object resp  = (Object) Utils.doRequest(conn, SERVICE_AUTH, METHOD_AUTH_INIT, new Object[]{userName});
+               Object resp  = (Object) Utils.doRequest(conn, SERVICE_AUTH, METHOD_AUTH_INIT, cm,new Object[]{userName});
                if(resp != null)
                        seed = resp.toString();
                
@@ -405,7 +412,7 @@ public class AccountAccess {
         * @param seed the seed
         * @returns bollean if auth was ok
         */
-       private boolean authenticateComplete(String seed) {
+       private boolean authenticateComplete(String seed) throws NoAccessToServer, NoNetworkAccessException {
 
                //calculate hash to pass to server for authentication process phase 2
                //seed = "b18a9063e0c6f49dfe7a854cc6ab5775";
@@ -422,7 +429,7 @@ public class AccountAccess {
                System.out.println("Password " + password);
                System.out.println("Compelx param " + complexParam);
                
-               Object resp  =  Utils.doRequest(conn, SERVICE_AUTH, METHOD_AUTH_COMPLETE, new Object[]{complexParam});
+               Object resp  =  Utils.doRequest(conn, SERVICE_AUTH, METHOD_AUTH_COMPLETE, cm, new Object[]{complexParam});
                if(resp == null)
                        return false;
                
@@ -453,7 +460,7 @@ public class AccountAccess {
        
        //------------------------Checked Out Items Section -------------------------//
        
-       public ArrayList<CircRecord> getItemsCheckedOut(){
+       public ArrayList<CircRecord> getItemsCheckedOut() throws SessionNotFoundException, NoNetworkAccessException, NoAccessToServer{
 
                
                ArrayList<CircRecord> circRecords = new ArrayList<CircRecord>();
@@ -473,7 +480,7 @@ public class AccountAccess {
                List<String> out_id;
                
                
-               Object resp  =  Utils.doRequest(conn, SERVICE_ACTOR, METHOD_FETCH_CHECKED_OUT_SUM, new Object[]{authToken, userID});
+               Object resp  =  Utils.doRequest(conn, SERVICE_ACTOR, METHOD_FETCH_CHECKED_OUT_SUM, authToken, cm, new Object[]{authToken, userID});
 
                        long_overdue_id = (List<String>)((Map<String,?>)resp).get("long_overdue");
                        claims_returned_id = (List<String>)((Map<String,?>)resp).get("claims_returned");
@@ -527,9 +534,9 @@ public class AccountAccess {
         * @param : target_copy from circ
         * @returns : "circ" OSRFObject 
         */
-       private OSRFObject retrieveCircRecord(String id){
+       private OSRFObject retrieveCircRecord(String id) throws SessionNotFoundException, NoNetworkAccessException, NoAccessToServer{
 
-               OSRFObject circ  = (OSRFObject) Utils.doRequest(conn, SERVICE_CIRC, METHOD_FETCH_CIRC_BY_ID, new Object[]{authToken,id});
+               OSRFObject circ  = (OSRFObject) Utils.doRequest(conn, SERVICE_CIRC, METHOD_FETCH_CIRC_BY_ID, authToken, cm, new Object[]{authToken,id});
                return circ;
        }
        
@@ -539,7 +546,7 @@ public class AccountAccess {
         * Usefull info : title and author 
         *  (for acp : dummy_title, dummy_author)
         */
-       private OSRFObject fetchInfoForCheckedOutItem(Integer target_copy, CircRecord circRecord){
+       private OSRFObject fetchInfoForCheckedOutItem(Integer target_copy, CircRecord circRecord) throws NoNetworkAccessException, NoAccessToServer{
                
                if(target_copy == null)
                        return null;
@@ -566,17 +573,17 @@ public class AccountAccess {
                return result;
        }
        
-       private OSRFObject fetchModsFromCopy(Integer target_copy){
+       private OSRFObject fetchModsFromCopy(Integer target_copy) throws NoNetworkAccessException, NoAccessToServer{
 
                //sync request          
-               OSRFObject mvr  = (OSRFObject) Utils.doRequest(conn, SERVICE_SEARCH, METHOD_FETCH_MODS_FROM_COPY, new Object[]{target_copy});
+               OSRFObject mvr  = (OSRFObject) Utils.doRequest(conn, SERVICE_SEARCH, METHOD_FETCH_MODS_FROM_COPY, cm, new Object[]{target_copy});
        
                return mvr;
        }
        
-       private OSRFObject fetchAssetCopy(Integer target_copy){
+       private OSRFObject fetchAssetCopy(Integer target_copy) throws NoNetworkAccessException, NoAccessToServer{
                
-               OSRFObject acp  = (OSRFObject) Utils.doRequest(conn, SERVICE_SEARCH, METHOD_FETCH_COPY, new Object[]{target_copy});
+               OSRFObject acp  = (OSRFObject) Utils.doRequest(conn, SERVICE_SEARCH, METHOD_FETCH_COPY, cm, new Object[]{target_copy});
                
                return acp;
        }
@@ -586,14 +593,14 @@ public class AccountAccess {
        /* Method used to renew a circulation record based on target_copy_id
         * Returns many objects, don't think they are needed
         */
-       public void renewCirc(Integer target_copy) throws MaxRenewalsException{
+       public void renewCirc(Integer target_copy) throws MaxRenewalsException, SessionNotFoundException, NoNetworkAccessException, NoAccessToServer{ 
                
                HashMap<String,Integer> complexParam = new HashMap<String, Integer>();
                complexParam.put("patron", this.userID);                
                complexParam.put("copyid", target_copy);
                complexParam.put("opac_renewal", 1);
                
-               Object a_lot = (Object) Utils.doRequest(conn, SERVICE_CIRC, METHOD_RENEW_CIRC, new Object[]{authToken,complexParam});
+               Object a_lot = (Object) Utils.doRequest(conn, SERVICE_CIRC, METHOD_RENEW_CIRC, authToken, cm, new Object[]{authToken,complexParam});
                
                Map<String,String> resp = (Map<String,String>)a_lot;
                
@@ -607,16 +614,16 @@ public class AccountAccess {
 
        //------------------------Holds Section --------------------------------------//
        
-       public Object fetchOrgSettings(Integer org_id, String setting){
+       public Object fetchOrgSettings(Integer org_id, String setting)throws SessionNotFoundException, NoNetworkAccessException, NoAccessToServer{
                
-               OSRFObject response  = (OSRFObject) Utils.doRequest(conn, SERVICE_ACTOR, METHOD_FETCH_ORG_SETTINGS, new Object[]{org_id,setting});
+               OSRFObject response  = (OSRFObject) Utils.doRequest(conn, SERVICE_ACTOR, METHOD_FETCH_ORG_SETTINGS, cm, new Object[]{org_id,setting});
                return response;
                
        }
        
        
        
-       public List<HoldRecord> getHolds(){
+       public List<HoldRecord> getHolds() throws SessionNotFoundException, NoNetworkAccessException, NoAccessToServer{
 
                
                ArrayList<HoldRecord> holds = new ArrayList<HoldRecord>();
@@ -624,7 +631,7 @@ public class AccountAccess {
                //fields of interest : expire_time
                List<OSRFObject> listHoldsAhr = null;
 
-               listHoldsAhr = (List<OSRFObject>) Utils.doRequest(conn, SERVICE_CIRC, METHOD_FETCH_HOLDS, new Object[]{authToken,userID});
+               listHoldsAhr = (List<OSRFObject>) Utils.doRequest(conn, SERVICE_CIRC, METHOD_FETCH_HOLDS, authToken, cm, new Object[]{authToken,userID});
                
                for(int i=0;i<listHoldsAhr.size();i++){
                        //create hold item
@@ -649,7 +656,7 @@ public class AccountAccess {
         *  P - pat
         */
        
-       private Object fetchHoldTitleInfo(OSRFObject holdArhObject, HoldRecord hold){
+       private Object fetchHoldTitleInfo(OSRFObject holdArhObject, HoldRecord hold) throws NoNetworkAccessException, NoAccessToServer{
                
                
                String holdType = (String)holdArhObject.get("hold_type");
@@ -667,7 +674,7 @@ public class AccountAccess {
                        if(holdType.equals("T"))
                                method = METHOD_FETCH_RMODS;
                        System.out.println();
-                       holdInfo = Utils.doRequest(conn,SERVICE_SEARCH, method, new Object[]{holdArhObject.get("target")});
+                       holdInfo = Utils.doRequest(conn,SERVICE_SEARCH, method, cm, new Object[]{holdArhObject.get("target")});
 
                        //System.out.println("Hold here " + holdInfo);
                        hold.title = ((OSRFObject)holdInfo).getString("title");
@@ -683,7 +690,7 @@ public class AccountAccess {
                return holdInfo;
        }
        
-       private Object holdFetchObjects(OSRFObject hold, HoldRecord holdObj){
+       private Object holdFetchObjects(OSRFObject hold, HoldRecord holdObj) throws  NoNetworkAccessException, NoAccessToServer{
                
                String type = (String)hold.get("hold_type");
                
@@ -702,7 +709,7 @@ public class AccountAccess {
                        
                        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, cm, new Object[]{copyObject.getInt("call_number")}); 
                        //in volume object : record
                                Integer record = volume.getInt("record");
                                
@@ -710,7 +717,7 @@ public class AccountAccess {
                                holdObj.part_label = volume.getString("label");
                                                
                                System.out.println("Record " + record);
-                               OSRFObject holdInfo = (OSRFObject)Utils.doRequest(conn,SERVICE_SEARCH,  METHOD_FETCH_RMODS, new Object[]{record});
+                               OSRFObject holdInfo = (OSRFObject)Utils.doRequest(conn,SERVICE_SEARCH,  METHOD_FETCH_RMODS, cm, new Object[]{record});
 
                                holdObj.title = holdInfo.getString("title");
                                holdObj.author = holdInfo.getString("author");
@@ -726,7 +733,7 @@ public class AccountAccess {
                                //must test
                                
                                //fetch_volume
-                               OSRFObject volume = (OSRFObject) Utils.doRequest(conn,SERVICE_SEARCH, METHOD_FETCH_VOLUME, new Object[]{hold.getInt("target")});
+                               OSRFObject volume = (OSRFObject) Utils.doRequest(conn,SERVICE_SEARCH, METHOD_FETCH_VOLUME, cm, new Object[]{hold.getInt("target")});
                                //in volume object : record 
                                
                                //in volume object : record
@@ -736,7 +743,7 @@ public class AccountAccess {
                                holdObj.part_label = volume.getString("label");
                                                
                                System.out.println("Record " + record);
-                               OSRFObject holdInfo = (OSRFObject)Utils.doRequest(conn,SERVICE_SEARCH,  METHOD_FETCH_RMODS, new Object[]{record});
+                               OSRFObject holdInfo = (OSRFObject)Utils.doRequest(conn,SERVICE_SEARCH,  METHOD_FETCH_RMODS, cm, new Object[]{record});
 
                                holdObj.title = holdInfo.getString("title");
                                holdObj.author = holdInfo.getString("author");
@@ -744,7 +751,7 @@ public class AccountAccess {
                        }
                        else
                                if(type.equals("I")){   
-                                       OSRFObject issuance = (OSRFObject) Utils.doRequest(conn,SERVICE_SERIAL, METHOD_FETCH_ISSUANCE, new Object[]{hold.getInt("target")});
+                                       OSRFObject issuance = (OSRFObject) Utils.doRequest(conn,SERVICE_SERIAL, METHOD_FETCH_ISSUANCE, cm, new Object[]{hold.getInt("target")});
                                //TODO
                                        
                                }
@@ -766,14 +773,14 @@ public class AccountAccess {
                                                
                                                //returns [{record:id, label=part label}]
                                                
-                                               List<Object> part = (List<Object>)Utils.doRequest(conn,SERVICE_FIELDER,"open-ils.fielder.bmp.atomic",new Object[]{param});
+                                               List<Object> part = (List<Object>)Utils.doRequest(conn,SERVICE_FIELDER,"open-ils.fielder.bmp.atomic", cm, new Object[]{param});
                                                
                                                Map<String,?> partObj =(Map<String,?>)part.get(0);
                                                
                                                Integer recordID = (Integer)partObj.get("record"); 
                                                String part_label = (String)partObj.get("label");
                                                
-                                               OSRFObject holdInfo = (OSRFObject)Utils.doRequest(conn,SERVICE_SEARCH,  METHOD_FETCH_RMODS, new Object[]{recordID});
+                                               OSRFObject holdInfo = (OSRFObject)Utils.doRequest(conn,SERVICE_SEARCH,  METHOD_FETCH_RMODS, cm, new Object[]{recordID});
 
                                                holdObj.part_label = part_label;
                                                holdObj.title = holdInfo.getString("title");
@@ -785,11 +792,11 @@ public class AccountAccess {
        }
        
        
-       public Object fetchHoldStatus(OSRFObject hold, HoldRecord holdObj){
+       public Object fetchHoldStatus(OSRFObject hold, HoldRecord holdObj) throws SessionNotFoundException, NoNetworkAccessException, NoAccessToServer{
                
                Integer hold_id = hold.getInt("id");
                // MAP : potential_copies, status, total_holds, queue_position, estimated_wait
-               Object hold_status = Utils.doRequest(conn,SERVICE_CIRC, METHOD_FETCH_HOLD_STATUS, new Object[]{authToken,hold_id});
+               Object hold_status = Utils.doRequest(conn,SERVICE_CIRC, METHOD_FETCH_HOLD_STATUS, authToken, cm, new Object[]{authToken,hold_id});
        
                //get status
                holdObj.status = ((Map<String,Integer>)hold_status).get("status");
@@ -798,11 +805,11 @@ public class AccountAccess {
        }
        
        
-       public boolean cancelHold(OSRFObject hold){
+       public boolean cancelHold(OSRFObject hold) throws SessionNotFoundException, NoNetworkAccessException, NoAccessToServer{
                
                Integer hold_id = hold.getInt("id");
                
-               Object response = Utils.doRequest(conn,SERVICE_CIRC, METHOD_CANCEL_HOLD, new Object[]{authToken,hold_id});
+               Object response = Utils.doRequest(conn,SERVICE_CIRC, METHOD_CANCEL_HOLD, authToken, cm, new Object[]{authToken,hold_id});
                
                //delete successful 
                if(response.toString().equals("1"))
@@ -812,7 +819,8 @@ public class AccountAccess {
                
        }
        
-       public Object updateHold(OSRFObject ahr,Integer pickup_lib, boolean email_notify, boolean phone_notify, String phone, boolean suspendHold, String expire_time,String thaw_date){
+       public Object updateHold(OSRFObject ahr,Integer pickup_lib, boolean email_notify, boolean phone_notify, String phone, boolean suspendHold, String expire_time,String thaw_date)
+                       throws SessionNotFoundException, NoNetworkAccessException, NoAccessToServer{
                //TODO verify that object is correct passed to the server
 
                ahr.put("pickup_lib", pickup_lib); //pick-up lib
@@ -824,12 +832,13 @@ public class AccountAccess {
                //only if it is frozen
            ahr.put("thaw_date",thaw_date);
                
-               Object response = Utils.doRequest(conn,SERVICE_CIRC, METHOD_UPDATE_HOLD, new Object[]{authToken,ahr});
+               Object response = Utils.doRequest(conn,SERVICE_CIRC, METHOD_UPDATE_HOLD, authToken, cm, new Object[]{authToken,ahr});
                
                return response;
        }
        
-       public String[] createHold(Integer recordID, Integer pickup_lib, boolean email_notify, boolean phone_notify, String phone, boolean suspendHold, String expire_time,String thaw_date){
+       public String[] createHold(Integer recordID, Integer pickup_lib, boolean email_notify, boolean phone_notify, String phone, boolean suspendHold, String expire_time,String thaw_date)
+                       throws SessionNotFoundException, NoNetworkAccessException, NoAccessToServer{
                
        OSRFObject ahr = new OSRFObject("ahr");
        ahr.put("target", recordID);
@@ -851,7 +860,7 @@ public class AccountAccess {
        //extra parameters (not mandatory for hold creation)
 
        
-       Object response = Utils.doRequest(conn,SERVICE_CIRC, METHOD_CREATE_HOLD, new Object[]{authToken,ahr});
+       Object response = Utils.doRequest(conn,SERVICE_CIRC, METHOD_CREATE_HOLD, authToken, cm, new Object[]{authToken,ahr});
                
        String[] resp = new String[3];
        //if we can get hold ID then we return true
@@ -879,7 +888,8 @@ public class AccountAccess {
                return resp;
        }
        // ?? return boolean 
-       public Object isHoldPossible(Integer pickup_lib,Integer recordID){
+       public Object isHoldPossible(Integer pickup_lib,Integer recordID)
+                       throws SessionNotFoundException, NoNetworkAccessException, NoAccessToServer{
                
                
                HashMap<String,Integer> mapAsk = getHoldPreCreateInfo(recordID, pickup_lib);
@@ -896,12 +906,13 @@ public class AccountAccess {
                //"patronid":2,"depth":0,"pickup_lib":"8","partid":null}
                
                
-               Object response = Utils.doRequest(conn,SERVICE_CIRC, METHOD_VERIFY_HOLD_POSSIBLE, new Object[]{authToken,mapAsk});
+               Object response = Utils.doRequest(conn,SERVICE_CIRC, METHOD_VERIFY_HOLD_POSSIBLE, authToken, cm, new Object[]{authToken,mapAsk});
                
                return response;
        }
        //return 
-       public HashMap<String,Integer> getHoldPreCreateInfo(Integer recordID, Integer pickup_lib){
+       public HashMap<String,Integer> getHoldPreCreateInfo(Integer recordID, Integer pickup_lib)
+       throws NoNetworkAccessException, NoAccessToServer{
        
                
                HashMap<String, Integer> param = new HashMap<String, Integer>();
@@ -909,7 +920,7 @@ public class AccountAccess {
                param.put("pickup_lib",pickup_lib);
                param.put("record", recordID);
                
-               Map<String,?> response = (Map<String,?>)Utils.doRequest(conn, SERVICE_SEARCH, "open-ils.search.metabib.record_to_descriptors", new Object[]{param});
+               Map<String,?> response = (Map<String,?>)Utils.doRequest(conn, SERVICE_SEARCH, "open-ils.search.metabib.record_to_descriptors", cm, new Object[]{param});
                
                Object obj = response.get("metarecord");
                System.out.println(obj);
@@ -930,10 +941,11 @@ public class AccountAccess {
        
        //----------------------------Fines Summary------------------------------------//
        
-       public float[] getFinesSummary(){
+       public float[] getFinesSummary()
+                       throws SessionNotFoundException, NoNetworkAccessException, NoAccessToServer{
                
                //mous object
-               OSRFObject finesSummary = (OSRFObject) Utils.doRequest(conn,SERVICE_ACTOR, METHOD_FETCH_FINES_SUMMARY, new Object[]{authToken,userID});
+               OSRFObject finesSummary = (OSRFObject) Utils.doRequest(conn,SERVICE_ACTOR, METHOD_FETCH_FINES_SUMMARY, authToken, cm, new Object[]{authToken,userID});
                
                float fines[] = new float[3];
                try{
@@ -947,11 +959,12 @@ public class AccountAccess {
                return fines;
        }
        
-       public ArrayList<FinesRecord> getTransactions(){
+       public ArrayList<FinesRecord> getTransactions()
+       throws SessionNotFoundException, NoNetworkAccessException, NoAccessToServer{
                
                ArrayList<FinesRecord> finesRecords = new ArrayList<FinesRecord>();
                
-               Object transactions = Utils.doRequest(conn,SERVICE_ACTOR, METHOD_FETCH_TRANSACTIONS, new Object[]{authToken,userID});
+               Object transactions = Utils.doRequest(conn,SERVICE_ACTOR, METHOD_FETCH_TRANSACTIONS, authToken, cm, new Object[]{authToken,userID});
                
                
                //get Array
@@ -971,9 +984,10 @@ public class AccountAccess {
        
        //---------------------------------------Book bags-----------------------------------//
        
-       public Object getBookbags(){
+       public Object getBookbags()
+                       throws SessionNotFoundException, NoNetworkAccessException, NoAccessToServer{
                
-               Object response = Utils.doRequest(conn,SERVICE_ACTOR, METHOD_FLESH_CONTAINERS, new Object[]{authToken,userID,"biblio","bookbag"});
+               Object response = Utils.doRequest(conn,SERVICE_ACTOR, METHOD_FLESH_CONTAINERS, authToken, cm, new Object[]{authToken,userID,"biblio","bookbag"});
        
                List<OSRFObject> bookbags = (List<OSRFObject>)response;
                
@@ -986,9 +1000,10 @@ public class AccountAccess {
                return bookbags;
        }
        
-       private Object getBookbagContent(Integer bookbagID){
+       private Object getBookbagContent(Integer bookbagID)
+                       throws SessionNotFoundException, NoNetworkAccessException, NoAccessToServer{
                
-               return Utils.doRequest(conn,SERVICE_ACTOR, METHOD_FLESH_PUBLIC_CONTAINER, new Object[]{authToken,"biblio",bookbagID});
+               return Utils.doRequest(conn,SERVICE_ACTOR, METHOD_FLESH_PUBLIC_CONTAINER, authToken, cm, new Object[]{authToken,"biblio",bookbagID});
        }
        
 }
index 9329373..ee4afa9 100644 (file)
@@ -5,6 +5,6 @@ public class SessionNotFoundException extends Exception{
        /**
         * 
         */
-       private static final long serialVersionUID = 1L;
+       private static final long serialVersionUID = 123232L;
 
 }
index 390fdb2..0e740c1 100644 (file)
@@ -6,6 +6,10 @@ 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.globals.NoAccessToServer;
+import org.evergreen.android.globals.NoNetworkAccessException;
+import org.evergreen.android.globals.Utils;
 
 import android.app.Activity;
 import android.app.ProgressDialog;
@@ -56,7 +60,23 @@ public class ItemsCheckOutListView extends Activity{
                        @Override
                        public void run() {
                                
-                               circRecords = accountAccess.getItemsCheckedOut();                       
+                               
+                               try {
+                                       circRecords = accountAccess.getItemsCheckedOut();
+                               }  catch (NoNetworkAccessException e) {
+                                       Utils.showNetworkNotAvailableDialog(context);
+                               } catch (NoAccessToServer e) {
+                                       Utils.showServerNotAvailableDialog(context);
+                                       
+                               }catch (SessionNotFoundException e) {
+                                       //TODO other way?
+                                       try{
+                                               if(accountAccess.authenticate())
+                                                       circRecords = accountAccess.getItemsCheckedOut();
+                                       }catch(Exception eauth){
+                                               System.out.println("Exception in reAuth");
+                                       }
+                               }                       
        
                                runOnUiThread(new Runnable() {
                                        
@@ -183,22 +203,52 @@ public class ItemsCheckOutListView extends Activity{
                                                                                        }
                                                                                });
                                                                                
-                                                                               try{
-                                                                                       ac.renewCirc(record.getTargetCopy());
-                                                                               }catch(MaxRenewalsException e){
-                                                                                       runOnUiThread(new Runnable() {
+                                                                               
+                                                                                       try {
+                                                                                               ac.renewCirc(record.getTargetCopy());
+                                                                                       } catch (MaxRenewalsException e1) {
+                                                                                               runOnUiThread(new Runnable() {
+                                                                                                       
+                                                                                                       @Override
+                                                                                                       public void run() {
+                                                                                                               progressDialog.dismiss();
+                                                                                                               Toast.makeText(context, "Max renewals reached", Toast.LENGTH_SHORT).show();
+                                                                                                       }
+                                                                                               });
                                                                                                
-                                                                                               @Override
-                                                                                               public void run() {
-                                                                                                       progressDialog.dismiss();
-                                                                                                       Toast.makeText(context, "Max renewals reached", Toast.LENGTH_SHORT).show();
+                                                                                               refresh = false;
+                                                                                       } catch (SessionNotFoundException e1) {
+                                                                                               try{
+                                                                                                       if(accountAccess.authenticate())
+                                                                                                               ac.renewCirc(record.getTargetCopy());
+                                                                                               }catch(Exception eauth){
+                                                                                                       System.out.println("Exception in reAuth");
                                                                                                }
-                                                                                       });
-                                                                                       
-                                                                                       refresh = false;
-                                                                               }
+                                                                                       } catch (NoNetworkAccessException e1) {
+                                                                                               Utils.showNetworkNotAvailableDialog(context);
+                                                                                       } catch (NoAccessToServer e1) {
+                                                                                               Utils.showServerNotAvailableDialog(context);
+                                                                                       }
+                                                       
                                                                                if(refresh){
-                                                                                       circRecords = accountAccess.getItemsCheckedOut();
+                                                                                       
+                                                                                       try {
+                                                                                               circRecords = accountAccess.getItemsCheckedOut();
+                                                                                       }  catch (NoNetworkAccessException e) {
+                                                                                               Utils.showNetworkNotAvailableDialog(context);
+                                                                                       } catch (NoAccessToServer e) {
+                                                                                               Utils.showServerNotAvailableDialog(context);
+                                                                                               
+                                                                                       }catch (SessionNotFoundException e) {
+                                                                                               //TODO other way?
+                                                                                               try{
+                                                                                                       if(accountAccess.authenticate())
+                                                                                                               circRecords = accountAccess.getItemsCheckedOut();
+                                                                                               }catch(Exception eauth){
+                                                                                                       System.out.println("Exception in reAuth");
+                                                                                               }
+                                                                                       }               
+                                                                                       
                                                                                        listAdapter.clear();
                                                                                        for(int i=0;i<circRecords.size();i++){
                                                                                                listAdapter.add(circRecords.get(i));
index 94ad2c2..1add524 100644 (file)
@@ -5,6 +5,10 @@ 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 android.app.Activity;
 import android.app.ProgressDialog;
@@ -67,10 +71,38 @@ public class FinesActivity extends Activity{
                        @Override
                        public void run() {
                                
-                               final float[] fines = ac.getFinesSummary();
+                               float[] finesR = null;
+                               try {
+                                       finesR = ac.getFinesSummary();
+                               } catch (SessionNotFoundException e) {
+                                       try{
+                                               if(ac.authenticate())
+                                                       finesR = ac.getFinesSummary();
+                                       }catch(Exception e1){}
+                               } catch (NoNetworkAccessException e) {
+                                       Utils.showNetworkNotAvailableDialog(context);
+                               } catch (NoAccessToServer e) {
+                                       Utils.showServerNotAvailableDialog(context);
+                               }
                                
-                               final ArrayList<FinesRecord> finesRecords = ac.getTransactions();
+                               ArrayList<FinesRecord> frecords = null;
+                               try {
+                                       frecords = ac.getTransactions();
+                               } catch (SessionNotFoundException e) {
+                                       
+                                       try{
+                                               if(ac.authenticate())
+                                                       frecords = ac.getTransactions();
+                                       }catch(Exception e1){}
+                                       
+                               } catch (NoNetworkAccessException e) {
+                                       Utils.showNetworkNotAvailableDialog(context);
+                               } catch (NoAccessToServer e) {
+                                       Utils.showServerNotAvailableDialog(context);
+                               }
                                
+                               final ArrayList<FinesRecord> finesRecords = frecords;
+                               final float[] fines = finesR;
                                runOnUiThread(new Runnable() {          
                                        @Override
                                        public void run() {     
index 56c932c..d9422aa 100644 (file)
@@ -6,7 +6,11 @@ import java.util.Date;
 
 import org.evergreen.android.R;
 import org.evergreen.android.accountAccess.AccountAccess;
+import org.evergreen.android.accountAccess.SessionNotFoundException;
 import org.evergreen.android.globals.GlobalConfigs;
+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.AlertDialog;
@@ -195,8 +199,28 @@ public class HoldDetails extends Activity {
                                                                        
                                                                        @Override
                                                                        public void run() {
-                                                                               accountAccess.cancelHold(record.ahr);
-                                                                       
+                                                                               
+                                                                               try {
+                                                                                       accountAccess.cancelHold(record.ahr);
+                                                                               }  catch (NoNetworkAccessException e) {
+                                                                                       Utils.showNetworkNotAvailableDialog(context);
+                                                                               } catch (NoAccessToServer e) {
+                                                                                       Utils.showServerNotAvailableDialog(context);
+                                                                                       
+                                                                               }catch (SessionNotFoundException e) {
+                                                                                       //TODO other way?
+                                                                                       try{
+                                                                                               if(accountAccess.authenticate())
+                                                                                                       accountAccess.cancelHold(record.ahr);
+                                                                                       }catch(Exception eauth){
+                                                                                               System.out.println("Exception in reAuth");
+                                                                                       }
+                                                                               }               
+                                                                               
+                                                                               
+                                                                               
+                                                                               
+                                                                               
                                                                                runOnUiThread(new Runnable() {
                                                                                        @Override
                                                                                        public void run() {
@@ -228,11 +252,35 @@ public class HoldDetails extends Activity {
                                if (thaw_date != null)
                                        thaw_date_s = GlobalConfigs.getStringDate(thaw_date);
 
-                               accountAccess.updateHold(record.ahr, selectedOrgPos,
-                                               email_notification.isChecked(), phone_notification
-                                                               .isChecked(),
-                                               phone_number.getText().toString(), suspendHold
-                                                               .isChecked(), expire_date_s, thaw_date_s);
+
+                               
+                               try {
+                                       accountAccess.updateHold(record.ahr, selectedOrgPos,
+                                                       email_notification.isChecked(), phone_notification
+                                                                       .isChecked(),
+                                                       phone_number.getText().toString(), suspendHold
+                                                                       .isChecked(), expire_date_s, thaw_date_s);
+                               }  catch (NoNetworkAccessException e) {
+                                       Utils.showNetworkNotAvailableDialog(context);
+                               } catch (NoAccessToServer e) {
+                                       Utils.showServerNotAvailableDialog(context);
+                                       
+                               }catch (SessionNotFoundException e) {
+                                       //TODO other way?
+                                       try{
+                                               if(accountAccess.authenticate())
+                                                       accountAccess.updateHold(record.ahr, selectedOrgPos,
+                                                                       email_notification.isChecked(), phone_notification
+                                                                                       .isChecked(),
+                                                                       phone_number.getText().toString(), suspendHold
+                                                                                       .isChecked(), expire_date_s, thaw_date_s);
+                                       }catch(Exception eauth){
+                                               System.out.println("Exception in reAuth");
+                                       }
+                               }
+                               
+                               
+                               
                                
                                runOnUiThread(new Runnable() {
                                        @Override
index eb55fba..bc64a57 100644 (file)
@@ -5,6 +5,10 @@ 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 android.app.Activity;
 import android.app.ProgressDialog;
@@ -58,7 +62,21 @@ public class HoldsListView extends Activity{
                        @Override
                        public void run() {
                                
-                               holdRecords = accountAccess.getHolds();
+                               try {
+                                       holdRecords = accountAccess.getHolds();
+                               } catch (SessionNotFoundException e) {
+                                       //TODO other way?
+                                       try{
+                                               if(accountAccess.authenticate())
+                                                       holdRecords = accountAccess.getHolds();
+                                       }catch(Exception eauth){
+                                               System.out.println("Exception in reAuth");
+                                       }
+                               } catch (NoNetworkAccessException e) {
+                                       Utils.showNetworkNotAvailableDialog(context);
+                               } catch (NoAccessToServer e) {
+                                       Utils.showServerNotAvailableDialog(context);
+                               }
                        
                                runOnUiThread(new Runnable() {
                                        @Override
index ecd366e..d5c762b 100644 (file)
@@ -6,7 +6,11 @@ import java.util.Date;
 
 import org.evergreen.android.R;
 import org.evergreen.android.accountAccess.AccountAccess;
+import org.evergreen.android.accountAccess.SessionNotFoundException;
 import org.evergreen.android.globals.GlobalConfigs;
+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 android.app.Activity;
@@ -138,9 +142,10 @@ public class PlaceHold extends Activity{
                                                progressDialog = ProgressDialog.show(context, "Please wait", "Placing hold");
                                        }
                                });
+                               //TODO verify hold possible 
                                
-                               accountAccess.getHoldPreCreateInfo(record_id, 4);
-                               accountAccess.isHoldPossible(4, record_id);
+                               //accountAccess.getHoldPreCreateInfo(record_id, 4);
+                               //accountAccess.isHoldPossible(4, record_id);
                                
                                
                                String expire_date_s = null;
@@ -155,8 +160,26 @@ public class PlaceHold extends Activity{
                                if(globalConfigs.organisations.size() > selectedOrgPos)
                                        selectedOrgID = globalConfigs.organisations.get(selectedOrgPos).id;
                                
-                               final String[] holdPlaced = accountAccess.createHold(record_id,selectedOrgID,email_notification.isChecked(),phone_notification.isChecked(),phone_number.getText().toString(),suspendHold.isChecked(),expire_date_s,thaw_date_s);
+                               
+                               
+                               String[] stringResponse = new String[]{"false"};
+                               try {
+                                       stringResponse = accountAccess.createHold(record_id,selectedOrgID,email_notification.isChecked(),phone_notification.isChecked(),phone_number.getText().toString(),suspendHold.isChecked(),expire_date_s,thaw_date_s);
+                               } catch (SessionNotFoundException e) {
+                                       
+                                       try{
+                                               if(accountAccess.authenticate())
+                                                       stringResponse = accountAccess.createHold(record_id,selectedOrgID,email_notification.isChecked(),phone_notification.isChecked(),phone_number.getText().toString(),suspendHold.isChecked(),expire_date_s,thaw_date_s);
+                                       }catch(Exception e1){}
+                                       
+                               } catch (NoNetworkAccessException e) {
+                                       Utils.showNetworkNotAvailableDialog(context);
+                               } catch (NoAccessToServer e) {
+                                       Utils.showServerNotAvailableDialog(context);
+                               }
                        
+                               final String[] holdPlaced = stringResponse;
+                               
                                runOnUiThread(new Runnable() {
                                        @Override
                                        public void run() {
index a681d89..33a2808 100644 (file)
@@ -8,6 +8,7 @@ import java.util.Date;
 import java.util.StringTokenizer;
 
 import org.evergreen.android.accountAccess.AccountAccess;
+import org.evergreen.android.accountAccess.SessionNotFoundException;
 import org.evergreen.android.searchCatalog.Organisation;
 import org.evergreen.android.views.ApplicationPreferences;
 import org.open_ils.idl.IDLParser;
@@ -73,11 +74,11 @@ public class GlobalConfigs {
                        boolean noNetworkAccess = false;
                        System.out.println("Check for network conenctivity");
                        try{
-                               Utils.checkNetworkStatus((ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE), context);
+                               Utils.checkNetworkStatus((ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE));
                                
                        }catch(NoNetworkAccessException e){
                                noNetworkAccess = true;
-                       }catch(NoAccessToHttpAddress e){
+                       }catch(NoAccessToServer e){
 
                                System.out.println("No access to network");
                                Intent preferencesAnctivity = new Intent(context, ApplicationPreferences.class);
@@ -94,8 +95,10 @@ public class GlobalConfigs {
                                
                                
                                //authenticate
-                               AccountAccess ac = AccountAccess.getAccountAccess(GlobalConfigs.httpAddress);
-                               ac.authenticate();
+                               AccountAccess ac = AccountAccess.getAccountAccess(GlobalConfigs.httpAddress,(ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE));
+                               try{
+                                       ac.authenticate();
+                               }catch(Exception e){}
                                
                                //TODO getorg hidding levels
                                //getOrgHiddentDepth();
@@ -130,14 +133,16 @@ public class GlobalConfigs {
        public void getOrganisations(){
                
                String orgFile = null;
+               
+               
+               organisations = new ArrayList<Organisation>();
+               
                try{
                        //using https: address
                        orgFile = Utils.getNetPageContent(httpAddress+collectionsRequest);
                        System.out.println("Request org " + httpAddress + collectionsRequest );
                }catch(Exception e){};
-               
-               organisations = new ArrayList<Organisation>();
-               
+       
                if(orgFile != null){
                        organisations = new ArrayList<Organisation>();
                        
@@ -274,12 +279,16 @@ public class GlobalConfigs {
                for(int i=0; i<organisations.size();i++){
                        
                        AccountAccess ac = AccountAccess.getAccountAccess();
-                       
-                       Object obj = ac.fetchOrgSettings(organisations.get(i).id, "opac.org_unit_hiding.depth");
-                       
-                       
-               }
                
+                       try{
+                               Object obj = ac.fetchOrgSettings(organisations.get(i).id, "opac.org_unit_hiding.depth");
+                       }catch(NoNetworkAccessException e){}
+                       catch(NoAccessToServer e){}
+                       catch(SessionNotFoundException e) {// not used here
+                               }
+                       
+                       }
+
        }
        
        
diff --git a/Open-ILS/src/Android/src/org/evergreen/android/globals/NoAccessToHttpAddress.java b/Open-ILS/src/Android/src/org/evergreen/android/globals/NoAccessToHttpAddress.java
deleted file mode 100644 (file)
index 89a9433..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.evergreen.android.globals;
-
-public class NoAccessToHttpAddress extends Exception{
-
-       /**
-        * 
-        */
-       private static final long serialVersionUID = 1L;
-
-}
diff --git a/Open-ILS/src/Android/src/org/evergreen/android/globals/NoAccessToServer.java b/Open-ILS/src/Android/src/org/evergreen/android/globals/NoAccessToServer.java
new file mode 100644 (file)
index 0000000..bfa7337
--- /dev/null
@@ -0,0 +1,10 @@
+package org.evergreen.android.globals;
+
+public class NoAccessToServer extends Exception{
+
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
+
+}
diff --git a/Open-ILS/src/Android/src/org/evergreen/android/globals/ShowNetworkNotAvailableRunnable.java b/Open-ILS/src/Android/src/org/evergreen/android/globals/ShowNetworkNotAvailableRunnable.java
new file mode 100644 (file)
index 0000000..b547afb
--- /dev/null
@@ -0,0 +1,33 @@
+package org.evergreen.android.globals;
+
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+
+class ShowNetworkNotAvailableRunnable implements Runnable{
+
+               public Context context;
+               
+               public ShowNetworkNotAvailableRunnable(Context context) {
+                       this.context = context;
+               }
+               
+               @Override
+               public void run() {
+                       // TODO Auto-generated method stub
+                       AlertDialog alertDialog = new AlertDialog.Builder(context).create();
+                   alertDialog.setTitle("Error");
+                   alertDialog.setMessage("You need to have an internet connection");
+                   alertDialog.setButton("OK",
+                   new DialogInterface.OnClickListener() {
+                
+                     @Override
+                     public void onClick(DialogInterface dialog, int id) {
+                       dialog.dismiss();
+                     }
+                   });
+                   
+                   alertDialog.show();
+               }
+               
+       }
\ No newline at end of file
diff --git a/Open-ILS/src/Android/src/org/evergreen/android/globals/ShowServerNotAvailableRunnable.java b/Open-ILS/src/Android/src/org/evergreen/android/globals/ShowServerNotAvailableRunnable.java
new file mode 100644 (file)
index 0000000..0d9d261
--- /dev/null
@@ -0,0 +1,34 @@
+package org.evergreen.android.globals;
+
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+
+public class ShowServerNotAvailableRunnable implements Runnable{
+       
+       private Context context;
+       
+       public ShowServerNotAvailableRunnable(Context context) {
+               this.context = context;
+       }
+       
+       @Override
+       public void run() {
+               AlertDialog alertDialog = new AlertDialog.Builder(context).create();
+           alertDialog.setTitle("Error");
+           alertDialog.setMessage("There is no network connectivity to " + GlobalConfigs.httpAddress);
+           alertDialog.setButton("OK",
+           new DialogInterface.OnClickListener() {
+        
+             @Override
+             public void onClick(DialogInterface dialog, int id) {
+               dialog.dismiss();
+             }
+           });
+
+
+               
+               alertDialog.show();
+       }
+       
+}
\ No newline at end of file
index 96374d2..751e4c3 100644 (file)
@@ -19,13 +19,15 @@ 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.AccountAccess;
+import org.evergreen.android.accountAccess.SessionNotFoundException;
 import org.opensrf.Method;
 import org.opensrf.net.http.GatewayRequest;
 import org.opensrf.net.http.HttpConnection;
 import org.opensrf.net.http.HttpRequest;
 
+import android.app.AlertDialog;
 import android.content.Context;
+import android.content.DialogInterface;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.net.ConnectivityManager;
@@ -110,8 +112,8 @@ public class Utils {
         *              NoAccessToHttpAddress if the library remote server can't be reached
         *   
         */
-       public static boolean checkNetworkStatus(ConnectivityManager cm, Context context )
-                       throws NoNetworkAccessException, NoAccessToHttpAddress{
+       public static boolean checkNetworkStatus(ConnectivityManager cm)
+                       throws NoNetworkAccessException, NoAccessToServer{
                
                boolean HaveConnectedWifi = false;
                boolean HaveConnectedMobile = false;
@@ -142,7 +144,7 @@ public class Utils {
                        // 2 seconds timeout
                        httpAddressAccessReachable = checkIfNetAddressIsReachable(GlobalConfigs.httpAddress);
                        if(httpAddressAccessReachable == false)
-                               throw new NoAccessToHttpAddress();
+                               throw new NoAccessToServer();
                }
 
                if(!networkAccessEnabled)
@@ -152,7 +154,8 @@ public class Utils {
                
        }
        
-       public static boolean checkIfNetAddressIsReachable(String url){
+       
+       public static boolean checkIfNetAddressIsReachable(String url) throws NoAccessToServer{
                
                boolean result = false;
                try
@@ -178,6 +181,7 @@ public class Utils {
                catch (SocketTimeoutException e)
                {
                    result = false; // this is somewhat expected
+                   throw new NoAccessToServer();
                }
                catch (Exception e) {
                        Log.d(TAG, "Exception in is reachable " + e.getMessage());
@@ -220,9 +224,18 @@ public class Utils {
         
 
        }
-       //TODO throw NO_SESSION 
-       public static Object doRequest(HttpConnection conn, String service, String methodName, Object[] params) //throws SessionNotFoundException{
-       {
+
+       public static Object doRequest(HttpConnection conn, String service, String methodName, String authToken, ConnectivityManager cm, Object[] params ) 
+                       throws SessionNotFoundException, NoNetworkAccessException, NoAccessToServer{
+               
+               
+               //check for network connectivity
+               checkNetworkStatus(cm);
+               
+               //check to see if EG http server is reachable
+               checkIfNetAddressIsReachable(GlobalConfigs.httpAddress);
+               
+               
                //TODO check params and throw errors
                Method method = new Method(methodName);
                
@@ -247,7 +260,7 @@ public class Utils {
                                        if(textcode != null){
                                                if(textcode.equals("NO_SESSION")){
                                                        System.out.println("REQUIRE NEW SESSION");
-                                                       response = requireNewSession(conn, service, methodName, params);
+                                                       throw new SessionNotFoundException();
                                                }
                                                
                                        }
@@ -261,18 +274,54 @@ public class Utils {
                
        }
        
-       public static Object requireNewSession(HttpConnection conn, String service, String methodName, Object[] params){
+       //does not require authToken 
+       public static Object doRequest(HttpConnection conn, String service, String methodName, ConnectivityManager cm, Object[] params ) 
+                       throws NoNetworkAccessException, NoAccessToServer{
+               
+               
+               //check for network connectivity
+               checkNetworkStatus(cm);
+               
+               //check to see if EG http server is reachable
+               checkIfNetAddressIsReachable(GlobalConfigs.httpAddress);
                
-               AccountAccess ac = AccountAccess.getAccountAccess();
-               boolean success = ac.authenticate();
                
-               Object response = null;
+               //TODO check params and throw errors
+               Method method = new Method(methodName);
+               
+               System.out.println("Method :" + methodName + " param:");
+               for(int i=0;i<params.length;i++){
+                       method.addParam(params[i]);
+                       System.out.print("Param "+i+":" + params[i]);
+               }
+               //need space
+               System.out.println();
                
-               if(success){
-                       response =  doRequest(conn, service, methodName, params);
+               //sync request
+               HttpRequest req = new GatewayRequest(conn, service, method).send();
+               Object resp;
+
+               while ((resp = req.recv()) != null) {
+                       System.out.println("Sync Response: " + resp);
+                       Object response = (Object) resp;
+
+                       return response;
+                       
                }
+               return null;
                
-               return response;
        }
 
+       
+       
+       public static ShowServerNotAvailableRunnable showServerNotAvailableDialog(Context context){
+               
+               return new ShowServerNotAvailableRunnable(context);
+       }
+       
+       public static ShowNetworkNotAvailableRunnable showNetworkNotAvailableDialog(Context context){
+       
+               return new ShowNetworkNotAvailableRunnable(context);
+       }
+       
 }
index a7f7f15..f4dccd0 100644 (file)
@@ -1,15 +1,17 @@
 
 package org.evergreen.android.searchCatalog;
 
+import java.io.NotSerializableException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.StringTokenizer;
 
+import org.evergreen.android.accountAccess.SessionNotFoundException;
 import org.evergreen.android.globals.GlobalConfigs;
+import org.evergreen.android.globals.NoAccessToServer;
+import org.evergreen.android.globals.NoNetworkAccessException;
 import org.evergreen.android.globals.Utils;
-import org.open_ils.idl.IDLParser;
 import org.opensrf.Method;
 import org.opensrf.net.http.GatewayRequest;
 import org.opensrf.net.http.HttpConnection;
@@ -18,6 +20,7 @@ import org.opensrf.net.http.HttpRequestHandler;
 import org.opensrf.util.OSRFObject;
 
 import android.content.Context;
+import android.net.ConnectivityManager;
 import android.util.Log;
 
 /**
@@ -68,12 +71,12 @@ public class SearchCatalog {
        
        public Integer searchLimit = 10;
        
+       private ConnectivityManager cm;
        
-       
-       public static SearchCatalog getInstance(){
+       public static SearchCatalog getInstance(ConnectivityManager cm){
                
                if(searchCatalogSingleton == null){
-                       searchCatalogSingleton = new SearchCatalog();
+                       searchCatalogSingleton = new SearchCatalog(cm);
                }
                
                return searchCatalogSingleton;
@@ -84,8 +87,11 @@ public class SearchCatalog {
         * @param httpAddress the http address
         * @param locale the locale
         */
-       private SearchCatalog() {
+       private SearchCatalog(ConnectivityManager cm) {
                super();
+               
+               this.cm = cm;
+               
                try{
                        // configure the connection
                        conn = new HttpConnection(GlobalConfigs.httpAddress+"/osrf-gateway-v1");
@@ -107,7 +113,7 @@ public class SearchCatalog {
         * @param searchWords the search words
         * @return the search results
         */
-       public ArrayList<RecordInfo> getSearchResults(String searchWords, Integer offset){
+       public ArrayList<RecordInfo> getSearchResults(String searchWords, Integer offset) throws NoNetworkAccessException, NoAccessToServer{
                
                
                ArrayList<RecordInfo> resultsRecordInfo = new ArrayList<RecordInfo>();
@@ -139,45 +145,26 @@ public class SearchCatalog {
                {
                        System.out.println("Exception in JSON " + e.getMessage());
                }
+
                
-               System.out.println("JSON argument " + complexParm);
-               method.addParam(complexParm);
-               method.addParam(searchWords);
-               method.addParam(1);
-               
-               
-               // sync test
-               HttpRequest req = new GatewayRequest(conn, SERVICE, method).send();
-               Object resp;
-               
-               //why in while ?
-               
+               Object resp = Utils.doRequest(conn, SERVICE, METHOD_MULTICASS_SEARCH, cm, new Object[]{complexParm,searchWords,1});
+
                ArrayList<String> ids = new ArrayList<String>();
-               
-               while ( (resp = req.recv()) != null){
-                   System.out.println("Sync Response: " + resp);
+
+               System.out.println("Sync Response: " + resp);
                    
-                   Map<String,?> response = (Map<String,?>) resp;
+               Map<String,?> response = (Map<String,?>) resp;
                    
-                   System.out.println(" ids : " + response.get("ids") + " " );
+               System.out.println(" ids : " + response.get("ids") + " " );
                    
-                   List<List<String>> result_ids = (List) response.get("ids");
+               List<List<String>> result_ids = (List) response.get("ids");
 
-                   visible =Integer.parseInt((String)response.get("count"));
+               visible =Integer.parseInt((String)response.get("count"));
                    
                    for(int i=0;i<result_ids.size();i++){
                        ids.add(result_ids.get(i).get(0));
                    }
 
-               }
-               // exceptions are captured instead of thrown, 
-               // primarily to better support async requests
-               if (req.failed()) {
-                   req.getFailure().printStackTrace();
-                   return null;
-               }
-               
                
                System.out.println("Ids " + ids);
                
@@ -225,32 +212,13 @@ public class SearchCatalog {
         * @param searchWords the search words
         * @return the object
         */
-       public Object searchCatalog(String searchWords){
-               
-               
-        Method method = new Method(METHOD_SLIM_RETRIVE);
+       public Object searchCatalog(String searchWords) 
+                       throws NoNetworkAccessException, NoAccessToServer{
 
-        method.addParam("keyword");
-        method.addParam(searchWords);
+        Object response = Utils.doRequest(conn, SERVICE, METHOD_SLIM_RETRIVE, cm, new Object[]{"keyword", searchWords});
         
+        return response;
         
-        // sync test
-        HttpRequest req = new GatewayRequest(conn, SERVICE, method).send();
-        Object resp;
-        while ( (resp = req.recv()) != null) {
-            System.out.println("Sync Response: " + resp);
-            return resp;
-        }
-     
-        
-        // exceptions are captured instead of thrown, 
-        // primarily to better support async requests
-        if (req.failed()) {
-            req.getFailure().printStackTrace();
-            return null;
-        }
-        
-        return null;
        }
        
        /**
@@ -272,11 +240,11 @@ public class SearchCatalog {
        }
 
        
-       public Object getLocationCount(Integer recordID, Integer orgID, Integer orgDepth){
-               
-               List<?> list = (List<?>)Utils.doRequest(conn, SERVICE, METHOD_COPY_LOCATION_COUNTS, new Object[]{recordID, orgID, orgDepth});
+       public Object getLocationCount(Integer recordID, Integer orgID, Integer orgDepth) throws NoNetworkAccessException, NoAccessToServer{
                
+               List<?> list = (List<?>)Utils.doRequest(conn, SERVICE, METHOD_COPY_LOCATION_COUNTS, cm, new Object[]{recordID, orgID, orgDepth});
                return list;
+               
        }
        
        /**
index 677e9a2..30aa996 100644 (file)
@@ -6,13 +6,16 @@ import java.util.List;
 import org.evergreen.android.R;
 import org.evergreen.android.accountAccess.holds.PlaceHold;
 import org.evergreen.android.globals.GlobalConfigs;
-
-import com.google.android.maps.ItemizedOverlay;
+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.AlertDialog;
 import android.app.ProgressDialog;
 import android.content.Context;
 import android.content.Intent;
+import android.net.ConnectivityManager;
 import android.os.Bundle;
 import android.util.Log;
 import android.view.ContextMenu;
@@ -78,7 +81,7 @@ public class SearchCatalogListView extends Activity{
         globalConfigs = GlobalConfigs.getGlobalConfigs(this);
         
         context = this;
-        search = SearchCatalog.getInstance();
+        search = SearchCatalog.getInstance((ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE));
                 
         recordList= new ArrayList<RecordInfo>();
 
@@ -111,6 +114,7 @@ public class SearchCatalogListView extends Activity{
        // Set the ListView adapter
        lv.setAdapter(adapter);
 
+       searchResults = new ArrayList<RecordInfo>();
        
        registerForContextMenu(lv);
        
@@ -135,7 +139,16 @@ public class SearchCatalogListView extends Activity{
                                                
                                                @Override
                                                public void run() {
-                                                       searchResults = search.getSearchResults(text,recordList.size()-1);
+                                                       
+                                                       searchResults.clear();
+                                                       
+                                                       try {
+                                                               searchResults = search.getSearchResults(text,recordList.size()-1);
+                                                       } catch (NoNetworkAccessException e) {
+                                                               Utils.showNetworkNotAvailableDialog(context);
+                                                       } catch (NoAccessToServer e) {
+                                                               Utils.showServerNotAvailableDialog(context);
+                                                       }
                                                        
                                                        runOnUiThread(new Runnable() {
                                                                
@@ -202,7 +215,7 @@ public class SearchCatalogListView extends Activity{
                                progressDialog = new ProgressDialog(context);
                                
                                progressDialog.setMessage("Fetching data");
-                               progressDialog.show();
+                               //progressDialog.show();
                                
                                if(text.length()>0){
                                        
@@ -210,14 +223,26 @@ public class SearchCatalogListView extends Activity{
                                                
                                                @Override
                                                public void run() {
-                                                       searchResults = search.getSearchResults(text,0);
                                                        
+                                                       searchResults.clear();
+                                                       
+                                                       try {
+                                                               searchResults = search.getSearchResults(text,0);
+                                                       } catch (NoNetworkAccessException e) {  
+                                                               System.out.println("no network access in search");
+                                                               SearchCatalogListView.this.runOnUiThread(Utils.showNetworkNotAvailableDialog(context));
+                                                               
+                                                       } catch (NoAccessToServer e) {
+                                                               SearchCatalogListView.this.runOnUiThread(Utils.showServerNotAvailableDialog(context));                                                          
+                                                       }
+                                                               
                                                        runOnUiThread(new Runnable() {
                                                                
                                                                @Override
                                                                public void run() {
 
                                                                        recordList.clear();
+                                                                       
                                                                        if(searchResults.size()>0){
                                                                                
                                                                                for(int j=0;j<searchResults.size();j++)
@@ -253,13 +278,14 @@ public class SearchCatalogListView extends Activity{
         
         int selectedPos = 0;
         ArrayList<String> list = new ArrayList<String>();
-        for(int i=0;i<globalConfigs.organisations.size();i++){
-               list.add(globalConfigs.organisations.get(i).padding + globalConfigs.organisations.get(i).name);
-               
-               if(globalConfigs.organisations.get(i).level -1 == 0)
-                       selectedPos = i;
+        if(globalConfigs.organisations != null){
+               for(int i=0;i<globalConfigs.organisations.size();i++){
+                       list.add(globalConfigs.organisations.get(i).padding + globalConfigs.organisations.get(i).name);
+                       
+                       if(globalConfigs.organisations.get(i).level -1 == 0)
+                               selectedPos = i;
+               }
         }
-        
         ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,list);
         choseOrganisation.setAdapter(adapter);
        
index f3063ed..c458dd8 100644 (file)
@@ -1,6 +1,9 @@
 package org.evergreen.android.searchCatalog;
 
 import org.evergreen.android.R;
+import org.evergreen.android.globals.NoAccessToServer;
+import org.evergreen.android.globals.NoNetworkAccessException;
+import org.evergreen.android.globals.Utils;
 import org.evergreen.android.utils.ui.AdvancedDetailsFragment;
 import org.evergreen.android.utils.ui.BaseSampleActivity;
 import org.evergreen.android.utils.ui.BasicDetailsFragment;
@@ -8,6 +11,8 @@ import org.evergreen.android.utils.ui.TabPageIndicator;
 import org.evergreen.android.utils.ui.TestFragment;
 import org.evergreen.android.utils.ui.TestFragmentAdapter;
 
+import android.content.Context;
+import android.net.ConnectivityManager;
 import android.os.Bundle;
 import android.support.v4.app.Fragment;
 import android.support.v4.app.FragmentManager;
@@ -32,11 +37,16 @@ public class TabsView extends BaseSampleActivity {
         
         mAdapter = new SearchFragmentAdapter(getSupportFragmentManager());
 
-        search = SearchCatalog.getInstance();
-        search.getLocationCount(record.doc_id, orgID, orgDepth);
-        
-        
+        search = SearchCatalog.getInstance((ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE));    
         
+        try {
+                       search.getLocationCount(record.doc_id, orgID, orgDepth);
+               } catch (NoNetworkAccessException e) {
+                       Utils.showNetworkNotAvailableDialog(this);
+               } catch (NoAccessToServer e) {
+                       Utils.showServerNotAvailableDialog(this);
+               }
+
         //mAdapter.getItem(0).
         
         mPager = (ViewPager)findViewById(R.id.pager);
index e470e05..9d7fec3 100644 (file)
@@ -3,7 +3,7 @@ package org.evergreen.android.views;
 import org.evergreen.android.R;
 import org.evergreen.android.accountAccess.AccountAccess;
 import org.evergreen.android.globals.GlobalConfigs;
-import org.evergreen.android.globals.NoAccessToHttpAddress;
+import org.evergreen.android.globals.NoAccessToServer;
 import org.evergreen.android.globals.NoNetworkAccessException;
 import org.evergreen.android.globals.Utils;
 
@@ -87,9 +87,9 @@ public class ApplicationPreferences extends PreferenceActivity implements OnShar
                        public void run() {
                                
                                boolean routeToAddress = true;
-                               AccountAccess account = AccountAccess.getAccountAccess(GlobalConfigs.httpAddress);
+                               AccountAccess account = AccountAccess.getAccountAccess(GlobalConfigs.httpAddress,(ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE));
                                try{
-                                       Utils.checkNetworkStatus((ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE), context);
+                                       Utils.checkNetworkStatus((ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE));
                                }catch(NoNetworkAccessException e){
                                        routeToAddress = false;
                                        
@@ -108,7 +108,7 @@ public class ApplicationPreferences extends PreferenceActivity implements OnShar
                                                }
                                        });
 
-                               }catch(NoAccessToHttpAddress e){
+                               }catch(NoAccessToServer e){
                                        
                                        Log.d(TAG, " no route to hoast");
                                        routeToAddress = false;
@@ -125,30 +125,35 @@ public class ApplicationPreferences extends PreferenceActivity implements OnShar
 
                                
                                if(routeToAddress){
-                                       if(account.authenticate()){
-                                                                       
-                                               runOnUiThread(new Runnable() {
-                                                       
-                                                       @Override
-                                                       public void run() {
-                                                               if(reference != null){
-                                                                       progressDialog.dismiss();
-                                                                       Toast.makeText(context, "Autenthication successfully established :" + GlobalConfigs.httpAddress, Toast.LENGTH_LONG).show();
+                                       
+                                       try{
+                                               if(account.authenticate()){
+                                                                               
+                                                       runOnUiThread(new Runnable() {
+                                                               
+                                                               @Override
+                                                               public void run() {
+                                                                       if(reference != null){
+                                                                               progressDialog.dismiss();
+                                                                               Toast.makeText(context, "Autenthication successfully established :" + GlobalConfigs.httpAddress, Toast.LENGTH_LONG).show();
+                                                                       }
                                                                }
-                                                       }
-                                               });
-                                       }else{
-                                               runOnUiThread(new Runnable() {
-                                                       
-                                                       @Override
-                                                       public void run() {
-                                                               if(reference != null){
-                                                                       progressDialog.dismiss();
-                                                                       Toast.makeText(context, "Please check username and password ", Toast.LENGTH_LONG).show();
+                                                       });
+                                               }else{
+                                                       runOnUiThread(new Runnable() {
+                                                               
+                                                               @Override
+                                                               public void run() {
+                                                                       if(reference != null){
+                                                                               progressDialog.dismiss();
+                                                                               Toast.makeText(context, "Please check username and password ", Toast.LENGTH_LONG).show();
+                                                                       }
                                                                }
-                                                       }
-                                               });
-                                       }
+                                                       });
+                                               }
+                                               
+                                       }catch(Exception e){}
+                                       
                                }
                                else
                                        runOnUiThread(new Runnable() {
diff --git a/Open-ILS/src/Android/src/org/evergreen/android/views/splashscreen/LoadingTask.java b/Open-ILS/src/Android/src/org/evergreen/android/views/splashscreen/LoadingTask.java
new file mode 100644 (file)
index 0000000..2854f21
--- /dev/null
@@ -0,0 +1,70 @@
+package org.evergreen.android.views.splashscreen;
+
+import android.os.AsyncTask;
+import android.util.Log;
+import android.widget.ProgressBar;
+
+public class LoadingTask extends AsyncTask<String, Integer, Integer> {
+
+       public interface LoadingTaskFinishedListener {
+               void onTaskFinished(); // If you want to pass something back to the listener add a param to this method
+       }
+
+       // This is the progress bar you want to update while the task is in progress
+       private final ProgressBar progressBar;
+       // This is the listener that will be told when this task is finished
+       private final LoadingTaskFinishedListener finishedListener;
+
+       /**
+        * A Loading task that will load some resources that are necessary for the app to start
+        * @param progressBar - the progress bar you want to update while the task is in progress
+        * @param finishedListener - the listener that will be told when this task is finished
+        */
+       public LoadingTask(ProgressBar progressBar, LoadingTaskFinishedListener finishedListener) {
+               this.progressBar = progressBar;
+               this.finishedListener = finishedListener;
+       }
+
+       @Override
+       protected Integer doInBackground(String... params) {
+               Log.i("Tutorial", "Starting task with url: "+params[0]);
+               if(resourcesDontAlreadyExist()){
+                       downloadResources();
+               }
+               // Perhaps you want to return something to your post execute
+               return 1234;
+       }
+
+       private boolean resourcesDontAlreadyExist() {
+               // Here you would query your app's internal state to see if this download had been performed before
+               // Perhaps once checked save this in a shared preference for speed of access next time
+               return true; // returning true so we show the splash every time
+       }
+
+
+       private void downloadResources() {
+               // We are just imitating some process thats takes a bit of time (loading of resources / downloading)
+               int count = 10;
+               for (int i = 0; i < count; i++) {
+
+                       // Update the progress bar after every step
+                       int progress = (int) ((i / (float) count) * 100);
+                       publishProgress(progress);
+
+                       // Do some long loading things
+                       try { Thread.sleep(1000); } catch (InterruptedException ignore) {}
+               }
+       }
+
+       @Override
+       protected void onProgressUpdate(Integer... values) {
+               super.onProgressUpdate(values);
+               progressBar.setProgress(values[0]); // This is ran on the UI thread so it is ok to update our progress bar ( a UI view ) here
+       }
+
+       @Override
+       protected void onPostExecute(Integer result) {
+               super.onPostExecute(result);
+               finishedListener.onTaskFinished(); // Tell whoever was listening we have finished
+       }
+}
\ No newline at end of file
diff --git a/Open-ILS/src/Android/src/org/evergreen/android/views/splashscreen/SplashActivity.java b/Open-ILS/src/Android/src/org/evergreen/android/views/splashscreen/SplashActivity.java
new file mode 100644 (file)
index 0000000..8b265d3
--- /dev/null
@@ -0,0 +1,42 @@
+package org.evergreen.android.views.splashscreen;
+
+
+
+import org.evergreen.android.R;
+import org.evergreen.android.views.MainScreenDashboard;
+import org.evergreen.android.views.splashscreen.LoadingTask.LoadingTaskFinishedListener;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.widget.ProgressBar;
+
+public class SplashActivity extends Activity implements LoadingTaskFinishedListener {
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        // Show the splash screen
+        setContentView(R.layout.activity_splash);
+        // Find the progress bar
+        ProgressBar progressBar = (ProgressBar) findViewById(R.id.activity_splash_progress_bar);
+        // Start your loading
+        new LoadingTask(progressBar, this).execute("www.google.co.uk"); // Pass in whatever you need a url is just an example we don't use it in this tutorial
+    }
+
+    // This is the callback for when your async task has finished
+    @Override
+       public void onTaskFinished() {
+               completeSplash();
+       }
+
+    private void completeSplash(){
+               startApp();
+               finish(); // Don't forget to finish this Splash Activity so the user can't return to it!
+    }
+
+    private void startApp() {
+               Intent intent = new Intent(SplashActivity.this, MainScreenDashboard.class);
+               startActivity(intent);
+       }
+}
\ No newline at end of file