Important milestone: session timeout handled gracefully. Activity runnables now...
authorkenstir <kenstir@gmail.com>
Wed, 4 Dec 2013 02:12:45 +0000 (21:12 -0500)
committerkenstir <kenstir@gmail.com>
Wed, 4 Dec 2013 02:12:45 +0000 (21:12 -0500)
    getHoldsRunnable = new Runnable() {
        public void run() {
            try {
                holdRecords = accountAccess.getHolds();
            } catch (SessionNotFoundException e) {
                try {
                    if (accountAccess.reauthenticate(HoldsListView.this))
                        holdRecords = accountAccess.getHolds();
                } catch (Exception eauth) {
                    System.out.println("Exception in reauth");
                }
            }
        }
    }

At the same time,
* removed obsolete exceptions
* added support for Intellij IDE

36 files changed:
Open-ILS/src/Android/.gitignore
Open-ILS/src/Android/.idea/.name [new file with mode: 0644]
Open-ILS/src/Android/.idea/compiler.xml [new file with mode: 0644]
Open-ILS/src/Android/.idea/copyright/profiles_settings.xml [new file with mode: 0644]
Open-ILS/src/Android/.idea/dictionaries/kenstir.xml [new file with mode: 0644]
Open-ILS/src/Android/.idea/encodings.xml [new file with mode: 0644]
Open-ILS/src/Android/.idea/misc.xml [new file with mode: 0644]
Open-ILS/src/Android/.idea/modules.xml [new file with mode: 0644]
Open-ILS/src/Android/.idea/scopes/scope_settings.xml [new file with mode: 0644]
Open-ILS/src/Android/.idea/uiDesigner.xml [new file with mode: 0644]
Open-ILS/src/Android/.idea/vcs.xml [new file with mode: 0644]
Open-ILS/src/Android/EvergreenApp.iml [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/bookbags/BookBagDetails.java
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/bookbags/BookbagsListView.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/NoAccessToServer.java [deleted file]
Open-ILS/src/Android/src/org/evergreen/android/globals/NoNetworkAccessException.java [deleted file]
Open-ILS/src/Android/src/org/evergreen/android/globals/ShowNetworkNotAvailableRunnable.java [deleted file]
Open-ILS/src/Android/src/org/evergreen/android/globals/ShowSessionNotAvailableRunnable.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/AdvancedSearchActivity.java
Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/MoreCopyInformation.java
Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SampleUnderlinesNoFade.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/services/ScheduledIntentService.java
Open-ILS/src/Android/src/org/evergreen/android/utils/ui/BasicDetailsFragment.java
Open-ILS/src/Android/src/org/evergreen/android/views/ApplicationPreferences.java
Open-ILS/src/Android/src/org/evergreen/android/views/ConfigureApplicationActivity.java
Open-ILS/src/Android/src/org/evergreen/android/views/splashscreen/LoadingTask.java

index a284b92..9d93ab6 100644 (file)
@@ -1,6 +1,7 @@
-#ignore class objects
 *.class
 *.dex
+.idea/workspace.xml
+.idea/tasks.xml
 bin/
 gen/
 .settings
diff --git a/Open-ILS/src/Android/.idea/.name b/Open-ILS/src/Android/.idea/.name
new file mode 100644 (file)
index 0000000..a4eaec3
--- /dev/null
@@ -0,0 +1 @@
+EvergreenApp
\ No newline at end of file
diff --git a/Open-ILS/src/Android/.idea/compiler.xml b/Open-ILS/src/Android/.idea/compiler.xml
new file mode 100644 (file)
index 0000000..217af47
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="CompilerConfiguration">
+    <option name="DEFAULT_COMPILER" value="Javac" />
+    <resourceExtensions />
+    <wildcardResourcePatterns>
+      <entry name="!?*.java" />
+      <entry name="!?*.form" />
+      <entry name="!?*.class" />
+      <entry name="!?*.groovy" />
+      <entry name="!?*.scala" />
+      <entry name="!?*.flex" />
+      <entry name="!?*.kt" />
+      <entry name="!?*.clj" />
+    </wildcardResourcePatterns>
+    <annotationProcessing>
+      <profile default="true" name="Default" enabled="false">
+        <processorPath useClasspath="true" />
+      </profile>
+    </annotationProcessing>
+  </component>
+</project>
+
diff --git a/Open-ILS/src/Android/.idea/copyright/profiles_settings.xml b/Open-ILS/src/Android/.idea/copyright/profiles_settings.xml
new file mode 100644 (file)
index 0000000..3572571
--- /dev/null
@@ -0,0 +1,5 @@
+<component name="CopyrightManager">
+  <settings default="">
+    <module2copyright />
+  </settings>
+</component>
\ No newline at end of file
diff --git a/Open-ILS/src/Android/.idea/dictionaries/kenstir.xml b/Open-ILS/src/Android/.idea/dictionaries/kenstir.xml
new file mode 100644 (file)
index 0000000..3ada50e
--- /dev/null
@@ -0,0 +1,7 @@
+<component name="ProjectDictionaryState">
+  <dictionary name="kenstir">
+    <words>
+      <w>textcode</w>
+    </words>
+  </dictionary>
+</component>
\ No newline at end of file
diff --git a/Open-ILS/src/Android/.idea/encodings.xml b/Open-ILS/src/Android/.idea/encodings.xml
new file mode 100644 (file)
index 0000000..e206d70
--- /dev/null
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
+</project>
+
diff --git a/Open-ILS/src/Android/.idea/misc.xml b/Open-ILS/src/Android/.idea/misc.xml
new file mode 100644 (file)
index 0000000..591776d
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="EntryPointsManager">
+    <entry_points version="2.0" />
+  </component>
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
+    <output url="file://$PROJECT_DIR$/classes" />
+  </component>
+</project>
+
diff --git a/Open-ILS/src/Android/.idea/modules.xml b/Open-ILS/src/Android/.idea/modules.xml
new file mode 100644 (file)
index 0000000..dbe6f3a
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/EvergreenApp.iml" filepath="$PROJECT_DIR$/EvergreenApp.iml" />
+    </modules>
+  </component>
+</project>
+
diff --git a/Open-ILS/src/Android/.idea/scopes/scope_settings.xml b/Open-ILS/src/Android/.idea/scopes/scope_settings.xml
new file mode 100644 (file)
index 0000000..922003b
--- /dev/null
@@ -0,0 +1,5 @@
+<component name="DependencyValidationManager">
+  <state>
+    <option name="SKIP_IMPORT_STATEMENTS" value="false" />
+  </state>
+</component>
\ No newline at end of file
diff --git a/Open-ILS/src/Android/.idea/uiDesigner.xml b/Open-ILS/src/Android/.idea/uiDesigner.xml
new file mode 100644 (file)
index 0000000..3b00020
--- /dev/null
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Palette2">
+    <group name="Swing">
+      <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
+      </item>
+      <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
+      </item>
+      <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
+      </item>
+      <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
+        <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
+      </item>
+      <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
+        <initial-values>
+          <property name="text" value="Button" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
+        <initial-values>
+          <property name="text" value="RadioButton" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
+        <initial-values>
+          <property name="text" value="CheckBox" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
+        <initial-values>
+          <property name="text" value="Label" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+          <preferred-size width="150" height="-1" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+          <preferred-size width="150" height="-1" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+          <preferred-size width="150" height="-1" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
+      </item>
+      <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
+          <preferred-size width="200" height="200" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
+          <preferred-size width="200" height="200" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
+      </item>
+      <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
+      </item>
+      <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
+      </item>
+      <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
+      </item>
+      <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
+          <preferred-size width="-1" height="20" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
+      </item>
+      <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
+      </item>
+    </group>
+  </component>
+</project>
+
diff --git a/Open-ILS/src/Android/.idea/vcs.xml b/Open-ILS/src/Android/.idea/vcs.xml
new file mode 100644 (file)
index 0000000..808ed2a
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="" vcs="" />
+    <mapping directory="$PROJECT_DIR$/../../.." vcs="Git" />
+  </component>
+</project>
+
diff --git a/Open-ILS/src/Android/EvergreenApp.iml b/Open-ILS/src/Android/EvergreenApp.iml
new file mode 100644 (file)
index 0000000..0d4bb02
--- /dev/null
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+  <component name="EclipseModuleManager" forced_jdk="true">
+    <libelement value="jar://$MODULE_DIR$/libs/android-support-v4.jar!/" />
+    <libelement value="jar://$MODULE_DIR$/libs/org.opensrf2_serialized_reg.jar!/" />
+    <libelement value="jar://$MODULE_DIR$/libs/zxing_barcode.jar!/" />
+    <libelement value="jar://$MODULE_DIR$/libs/androwrapee-1.1.0.jar!/" />
+    <conelement value="com.android.ide.eclipse.adt.DEPENDENCIES" />
+    <src_description expected_position="5">
+      <src_folder value="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK" expected_position="0" />
+      <src_folder value="com.android.ide.eclipse.adt.LIBRARIES" expected_position="1" />
+      <src_folder value="file://$MODULE_DIR$/src" expected_position="6" />
+      <src_folder value="file://$MODULE_DIR$/gen" expected_position="7" />
+    </src_description>
+  </component>
+  <component name="FacetManager">
+    <facet type="android" name="Android">
+      <configuration />
+    </facet>
+  </component>
+  <component name="NewModuleRootManager" inherit-compiler-output="false">
+    <output url="file://$MODULE_DIR$/bin/classes" />
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" />
+    </content>
+    <orderEntry type="jdk" jdkName="Android 4.4 Platform" jdkType="Android SDK" />
+    <orderEntry type="module-library">
+      <library name="android-support-v4.jar">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/libs/android-support-v4.jar!/" />
+        </CLASSES>
+        <JAVADOC>
+          <root url="file://E:/tools/adt-bundle-windows-x86_64-20130917/sdk/extras/android/support/v4/docs" />
+        </JAVADOC>
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="org.opensrf2_serialized_reg.jar">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/libs/org.opensrf2_serialized_reg.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="zxing_barcode.jar">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/libs/zxing_barcode.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="androwrapee-1.1.0.jar">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/libs/androwrapee-1.1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>
+
index 5af29a9..f5ab55a 100644 (file)
@@ -19,6 +19,7 @@
  */
 package org.evergreen.android.accountAccess;
 
+import java.io.IOException;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.util.ArrayList;
@@ -26,23 +27,23 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import android.accounts.*;
+import android.app.Activity;
+import android.os.Bundle;
+import android.os.Looper;
+import android.text.TextUtils;
 import org.evergreen.android.accountAccess.bookbags.BookBag;
 import org.evergreen.android.accountAccess.bookbags.BookBagItem;
 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;
-import org.opensrf.net.http.GatewayRequest;
+import org.evergreen_ils.auth.Const;
 import org.opensrf.net.http.HttpConnection;
-import org.opensrf.net.http.HttpRequest;
 import org.opensrf.util.OSRFObject;
 
 import android.net.ConnectivityManager;
-import android.util.Log;
 
 /**
  * The Class AuthenticateUser. Singleton class
@@ -193,7 +194,6 @@ public class AccountAccess {
      * Instantiates a new authenticate user.
      *
      * @param httpAddress the http address
-     * @param cm the cm
      */
     private AccountAccess(String httpAddress) {
 
@@ -230,7 +230,6 @@ public class AccountAccess {
      * Gets the account access.
      *
      * @param httpAddress the http address
-     * @param cm the cm
      * @return the account access
      */
     public static AccountAccess getAccountAccess(String httpAddress) {
@@ -323,33 +322,17 @@ public class AccountAccess {
     }
 
     /**
-     * Authenticate.
-     *
-     * @return true, if successful
-     * @throws NoNetworkAccessException the no network access exception
-     * @throws NoAccessToServer the no access to server
-     */
-    public boolean authenticate() throws NoNetworkAccessException,
-            NoAccessToServer {
-
-        //TODO this is a giant hack
-        return true;
-    }
-
-    /**
      * Retrieve session.
-     * @throws NoAccessToServer 
-     * @throws NoNetworkAccessException 
-     * @throws SessionNotFoundException 
+     * @throws SessionNotFoundException
      */
-    public boolean initSession(String auth_token) throws NoNetworkAccessException, NoAccessToServer, SessionNotFoundException {
+    public boolean retrieveSession(String auth_token) throws SessionNotFoundException {
 
         if (this.haveSession && this.authToken.equals(auth_token))
             return true;
         this.haveSession = false;
         this.authToken = auth_token;
         
-        Object resp = Utils.doRequest(conn, SERVICE_AUTH, METHOD_AUTH_SESSION_RETRV, authToken, null, new Object[] {authToken});
+        Object resp = Utils.doRequest(conn, SERVICE_AUTH, METHOD_AUTH_SESSION_RETRV, authToken, new Object[] {authToken});
         if (resp != null) {
             OSRFObject au = (OSRFObject) resp;
             userID = au.getInt("id");
@@ -359,28 +342,31 @@ public class AccountAccess {
             this.haveSession = true;
         }
         return this.haveSession;
-        /*
-        Method method = new Method(METHOD_AUTH_SESSION_RETRV);
-
-        method.addParam(authToken);
-
-        // sync request
-        HttpRequest req = new GatewayRequest(conn, SERVICE_AUTH, method).send();
-        Object resp;
-
-        while ((resp = req.recv()) != null) {
-            System.out.println("Sync Response: " + resp);
-            OSRFObject au = (OSRFObject) resp;
-            userID = au.getInt("id");
-            homeLibraryID = au.getInt("home_ou");
-            String s = au.getString("usrname");
+    }
 
-            System.out.println("User Id " + userID);
+    public static boolean runningOnUIThread() {
+        return (Looper.myLooper() == Looper.getMainLooper());
+    }
 
-            this.haveSession = true;
-        }
-        return this.haveSession;
-        */
+    /** invalidate current auth token and get a new one
+     *
+     * @param activity
+     * @return true if auth successful
+     */
+    public boolean reauthenticate(Activity activity) throws SessionNotFoundException, AuthenticatorException, OperationCanceledException, IOException {
+        boolean ok = false;
+        final AccountManager am = AccountManager.get(activity);
+        final Account account = new Account(userName, Const.ACCOUNT_TYPE);
+        am.invalidateAuthToken(Const.ACCOUNT_TYPE, authToken);
+        haveSession = false;
+        authToken = null;
+        if (runningOnUIThread())
+            return false;
+        Bundle b = am.getAuthToken(account, Const.AUTHTOKEN_TYPE, null, activity, null, null).getResult();
+        final String new_authToken = b.getString(AccountManager.KEY_AUTHTOKEN);
+        if (TextUtils.isEmpty(new_authToken))
+            return false;
+        return retrieveSession(new_authToken);
     }
 
     // ------------------------Checked Out Items Section
@@ -395,8 +381,7 @@ public class AccountAccess {
      * @throws NoAccessToServer the no access to server
      */
     public ArrayList<CircRecord> getItemsCheckedOut()
-            throws SessionNotFoundException, NoNetworkAccessException,
-            NoAccessToServer {
+            throws SessionNotFoundException {
 
         ArrayList<CircRecord> circRecords = new ArrayList<CircRecord>();
         /*
@@ -415,7 +400,7 @@ public class AccountAccess {
         List<String> out_id;
 
         Object resp = Utils.doRequest(conn, SERVICE_ACTOR,
-                METHOD_FETCH_CHECKED_OUT_SUM, authToken, cm, new Object[] {
+                METHOD_FETCH_CHECKED_OUT_SUM, authToken, new Object[] {
                         authToken, userID });
 
         long_overdue_id = (List<String>) ((Map<String, ?>) resp)
@@ -481,15 +466,12 @@ public class AccountAccess {
      * @param id the id
      * @return the oSRF object
      * @throws SessionNotFoundException the session not found exception
-     * @throws NoNetworkAccessException the no network access exception
-     * @throws NoAccessToServer the no access to server
      */
     private OSRFObject retrieveCircRecord(String id)
-            throws SessionNotFoundException, NoNetworkAccessException,
-            NoAccessToServer {
+            throws SessionNotFoundException {
 
         OSRFObject circ = (OSRFObject) Utils.doRequest(conn, SERVICE_CIRC,
-                METHOD_FETCH_CIRC_BY_ID, authToken, cm, new Object[] {
+                METHOD_FETCH_CIRC_BY_ID, authToken, new Object[] {
                         authToken, id });
         return circ;
     }
@@ -506,12 +488,9 @@ public class AccountAccess {
      * @param target_copy the target_copy
      * @param circRecord the circ record
      * @return the oSRF object
-     * @throws NoNetworkAccessException the no network access exception
-     * @throws NoAccessToServer the no access to server
      */
     private OSRFObject fetchInfoForCheckedOutItem(Integer target_copy,
-            CircRecord circRecord) throws NoNetworkAccessException,
-            NoAccessToServer {
+            CircRecord circRecord) {
 
         if (target_copy == null)
             return null;
@@ -543,11 +522,8 @@ public class AccountAccess {
      *
      * @param target_copy the target_copy
      * @return the oSRF object
-     * @throws NoNetworkAccessException the no network access exception
-     * @throws NoAccessToServer the no access to server
      */
-    private OSRFObject fetchModsFromCopy(Integer target_copy)
-            throws NoNetworkAccessException, NoAccessToServer {
+    private OSRFObject fetchModsFromCopy(Integer target_copy) {
 
         // sync request
         OSRFObject mvr = (OSRFObject) Utils.doRequest(conn, SERVICE_SEARCH,
@@ -561,11 +537,8 @@ public class AccountAccess {
      *
      * @param target_copy the target_copy
      * @return the oSRF object
-     * @throws NoNetworkAccessException the no network access exception
-     * @throws NoAccessToServer the no access to server
      */
-    private OSRFObject fetchAssetCopy(Integer target_copy)
-            throws NoNetworkAccessException, NoAccessToServer {
+    private OSRFObject fetchAssetCopy(Integer target_copy) {
 
         OSRFObject acp = (OSRFObject) Utils.doRequest(conn, SERVICE_SEARCH,
                 METHOD_FETCH_COPY, cm, new Object[] { target_copy });
@@ -584,12 +557,9 @@ public class AccountAccess {
      * @throws MaxRenewalsException the max renewals exception
      * @throws ServerErrorMessage the server error message
      * @throws SessionNotFoundException the session not found exception
-     * @throws NoNetworkAccessException the no network access exception
-     * @throws NoAccessToServer the no access to server
      */
     public void renewCirc(Integer target_copy) throws MaxRenewalsException,
-            ServerErrorMessage, SessionNotFoundException,
-            NoNetworkAccessException, NoAccessToServer {
+            ServerErrorMessage, SessionNotFoundException {
 
         HashMap<String, Integer> complexParam = new HashMap<String, Integer>();
         complexParam.put("patron", this.userID);
@@ -597,7 +567,7 @@ public class AccountAccess {
         complexParam.put("opac_renewal", 1);
 
         Object a_lot = (Object) Utils.doRequest(conn, SERVICE_CIRC,
-                METHOD_RENEW_CIRC, authToken, cm, new Object[] { authToken,
+                METHOD_RENEW_CIRC, authToken, new Object[] { authToken,
                         complexParam });
 
         Map<String, String> resp = (Map<String, String>) a_lot;
@@ -620,12 +590,9 @@ public class AccountAccess {
      * @param setting the setting
      * @return the object
      * @throws SessionNotFoundException the session not found exception
-     * @throws NoNetworkAccessException the no network access exception
-     * @throws NoAccessToServer the no access to server
      */
     public Object fetchOrgSettings(Integer org_id, String setting)
-            throws SessionNotFoundException, NoNetworkAccessException,
-            NoAccessToServer {
+            throws SessionNotFoundException {
 
         OSRFObject response = (OSRFObject) Utils
                 .doRequest(conn, SERVICE_ACTOR, METHOD_FETCH_ORG_SETTINGS, cm,
@@ -639,11 +606,8 @@ public class AccountAccess {
      *
      * @return the holds
      * @throws SessionNotFoundException the session not found exception
-     * @throws NoNetworkAccessException the no network access exception
-     * @throws NoAccessToServer the no access to server
      */
-    public List<HoldRecord> getHolds() throws SessionNotFoundException,
-            NoNetworkAccessException, NoAccessToServer {
+    public List<HoldRecord> getHolds() throws SessionNotFoundException {
 
         ArrayList<HoldRecord> holds = new ArrayList<HoldRecord>();
 
@@ -651,7 +615,7 @@ public class AccountAccess {
         List<OSRFObject> listHoldsAhr = null;
 
         Object resp = Utils.doRequest(conn, SERVICE_CIRC, METHOD_FETCH_HOLDS,
-                authToken, cm, new Object[] { authToken, userID });
+                authToken, new Object[] { authToken, userID });
         if (resp == null) {
             System.out.println("Result: null");
             return holds;
@@ -684,11 +648,8 @@ public class AccountAccess {
      * @param holdArhObject the hold arh object
      * @param hold the hold
      * @return the object
-     * @throws NoNetworkAccessException the no network access exception
-     * @throws NoAccessToServer the no access to server
      */
-    private Object fetchHoldTitleInfo(OSRFObject holdArhObject, HoldRecord hold)
-            throws NoNetworkAccessException, NoAccessToServer {
+    private Object fetchHoldTitleInfo(OSRFObject holdArhObject, HoldRecord hold) {
 
         String holdType = (String) holdArhObject.get("hold_type");
 
@@ -732,11 +693,8 @@ public class AccountAccess {
      * @param hold the hold
      * @param holdObj the hold obj
      * @return the oSRF object
-     * @throws NoNetworkAccessException the no network access exception
-     * @throws NoAccessToServer the no access to server
      */
-    private OSRFObject holdFetchObjects(OSRFObject hold, HoldRecord holdObj)
-            throws NoNetworkAccessException, NoAccessToServer {
+    private OSRFObject holdFetchObjects(OSRFObject hold, HoldRecord holdObj) {
 
         String type = (String) hold.get("hold_type");
 
@@ -779,7 +737,6 @@ public class AccountAccess {
                     System.err.println("Can't get types of resurce type"
                             + e.getMessage());
                 }
-                ;
             }
 
             return copyObject;
@@ -813,7 +770,6 @@ public class AccountAccess {
                 System.err.println("Can't get types of resurce type"
                         + e.getMessage());
             }
-            ;
         } else if (type.equals("I")) {
             OSRFObject issuance = (OSRFObject) Utils.doRequest(conn,
                     SERVICE_SERIAL, METHOD_FETCH_ISSUANCE, cm,
@@ -861,7 +817,6 @@ public class AccountAccess {
                 System.err.println("Can't get types of resurce type"
                         + e.getMessage());
             }
-            ;
         }
 
         return null;
@@ -873,18 +828,15 @@ public class AccountAccess {
      * @param hold the hold
      * @param holdObj the hold obj
      * @throws SessionNotFoundException the session not found exception
-     * @throws NoNetworkAccessException the no network access exception
-     * @throws NoAccessToServer the no access to server
      */
     public void fetchHoldStatus(OSRFObject hold, HoldRecord holdObj)
-            throws SessionNotFoundException, NoNetworkAccessException,
-            NoAccessToServer {
+            throws SessionNotFoundException {
 
         Integer hold_id = hold.getInt("id");
         // MAP : potential_copies, status, total_holds, queue_position,
         // estimated_wait
         Object resp = Utils.doRequest(conn, SERVICE_CIRC,
-                METHOD_FETCH_HOLD_STATUS, authToken, cm, new Object[] {
+                METHOD_FETCH_HOLD_STATUS, authToken, new Object[] {
                         authToken, hold_id });
 
         Map<String, Integer> map = (Map<String, Integer>)resp;
@@ -901,16 +853,13 @@ public class AccountAccess {
      * @param hold the hold
      * @return true, if successful
      * @throws SessionNotFoundException the session not found exception
-     * @throws NoNetworkAccessException the no network access exception
-     * @throws NoAccessToServer the no access to server
      */
-    public boolean cancelHold(OSRFObject hold) throws SessionNotFoundException,
-            NoNetworkAccessException, NoAccessToServer {
+    public boolean cancelHold(OSRFObject hold) throws SessionNotFoundException {
 
         Integer hold_id = hold.getInt("id");
 
         Object response = Utils.doRequest(conn, SERVICE_CIRC,
-                METHOD_CANCEL_HOLD, authToken, cm, new Object[] { authToken,
+                METHOD_CANCEL_HOLD, authToken, new Object[] { authToken,
                         hold_id });
 
         // delete successful
@@ -931,13 +880,10 @@ public class AccountAccess {
      * @param thaw_date the thaw_date
      * @return the object
      * @throws SessionNotFoundException the session not found exception
-     * @throws NoNetworkAccessException the no network access exception
-     * @throws NoAccessToServer the no access to server
      */
     public Object updateHold(OSRFObject ahr, Integer pickup_lib,
             boolean suspendHold, String expire_time, String thaw_date)
-            throws SessionNotFoundException, NoNetworkAccessException,
-            NoAccessToServer {
+            throws SessionNotFoundException {
         // TODO verify that object is correct passed to the server
 
         ahr.put("pickup_lib", pickup_lib);
@@ -948,7 +894,7 @@ public class AccountAccess {
         ahr.put("thaw_date", thaw_date);
 
         Object response = Utils.doRequest(conn, SERVICE_CIRC,
-                METHOD_UPDATE_HOLD, authToken, cm, new Object[] { authToken,
+                METHOD_UPDATE_HOLD, authToken, new Object[] { authToken,
                         ahr });
 
         return response;
@@ -967,14 +913,11 @@ public class AccountAccess {
      * @param thaw_date the thaw_date
      * @return the string[]
      * @throws SessionNotFoundException the session not found exception
-     * @throws NoNetworkAccessException the no network access exception
-     * @throws NoAccessToServer the no access to server
      */
     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 {
+            throws SessionNotFoundException {
 
         OSRFObject ahr = new OSRFObject("ahr");
         ahr.put("target", recordID);
@@ -996,7 +939,7 @@ public class AccountAccess {
         // extra parameters (not mandatory for hold creation)
 
         Object response = Utils.doRequest(conn, SERVICE_CIRC,
-                METHOD_CREATE_HOLD, authToken, cm, new Object[] { authToken,
+                METHOD_CREATE_HOLD, authToken, new Object[] { authToken,
                         ahr });
 
         String[] resp = new String[3];
@@ -1017,7 +960,6 @@ public class AccountAccess {
             resp[1] = ((Map<String, String>) map).get("textcode");
             resp[2] = ((Map<String, String>) map).get("desc");
         }
-        ;
 
         System.out.println("Result " + resp[1] + " " + resp[2]);
 
@@ -1033,12 +975,9 @@ public class AccountAccess {
      * @param recordID the record id
      * @return the object
      * @throws SessionNotFoundException the session not found exception
-     * @throws NoNetworkAccessException the no network access exception
-     * @throws NoAccessToServer the no access to server
      */
     public Object isHoldPossible(Integer pickup_lib, Integer recordID)
-            throws SessionNotFoundException, NoNetworkAccessException,
-            NoAccessToServer {
+            throws SessionNotFoundException {
 
         HashMap<String, Integer> mapAsk = getHoldPreCreateInfo(recordID,
                 pickup_lib);
@@ -1055,7 +994,7 @@ public class AccountAccess {
         // "patronid":2,"depth":0,"pickup_lib":"8","partid":null}
 
         Object response = Utils.doRequest(conn, SERVICE_CIRC,
-                METHOD_VERIFY_HOLD_POSSIBLE, authToken, cm, new Object[] {
+                METHOD_VERIFY_HOLD_POSSIBLE, authToken, new Object[] {
                         authToken, mapAsk });
 
         return response;
@@ -1068,12 +1007,9 @@ public class AccountAccess {
      * @param recordID the record id
      * @param pickup_lib the pickup_lib
      * @return the hold pre create info
-     * @throws NoNetworkAccessException the no network access exception
-     * @throws NoAccessToServer the no access to server
      */
     public HashMap<String, Integer> getHoldPreCreateInfo(Integer recordID,
-            Integer pickup_lib) throws NoNetworkAccessException,
-            NoAccessToServer {
+            Integer pickup_lib) {
 
         HashMap<String, Integer> param = new HashMap<String, Integer>();
 
@@ -1110,15 +1046,12 @@ public class AccountAccess {
      *
      * @return the fines summary
      * @throws SessionNotFoundException the session not found exception
-     * @throws NoNetworkAccessException the no network access exception
-     * @throws NoAccessToServer the no access to server
      */
-    public float[] getFinesSummary() throws SessionNotFoundException,
-            NoNetworkAccessException, NoAccessToServer {
+    public float[] getFinesSummary() throws SessionNotFoundException {
 
         // mous object
         OSRFObject finesSummary = (OSRFObject) Utils.doRequest(conn,
-                SERVICE_ACTOR, METHOD_FETCH_FINES_SUMMARY, authToken, cm,
+                SERVICE_ACTOR, METHOD_FETCH_FINES_SUMMARY, authToken,
                 new Object[] { authToken, userID });
 
         float fines[] = new float[3];
@@ -1138,17 +1071,14 @@ public class AccountAccess {
      *
      * @return the transactions
      * @throws SessionNotFoundException the session not found exception
-     * @throws NoNetworkAccessException the no network access exception
-     * @throws NoAccessToServer the no access to server
      */
     public ArrayList<FinesRecord> getTransactions()
-            throws SessionNotFoundException, NoNetworkAccessException,
-            NoAccessToServer {
+            throws SessionNotFoundException {
 
         ArrayList<FinesRecord> finesRecords = new ArrayList<FinesRecord>();
 
         Object transactions = Utils.doRequest(conn, SERVICE_ACTOR,
-                METHOD_FETCH_TRANSACTIONS, authToken, cm, new Object[] {
+                METHOD_FETCH_TRANSACTIONS, authToken, new Object[] {
                         authToken, userID });
 
         // get Array
@@ -1175,14 +1105,11 @@ public class AccountAccess {
      *
      * @return the bookbags
      * @throws SessionNotFoundException the session not found exception
-     * @throws NoNetworkAccessException the no network access exception
-     * @throws NoAccessToServer the no access to server
      */
-    public boolean retrieveBookbags() throws SessionNotFoundException,
-            NoNetworkAccessException, NoAccessToServer {
+    public boolean retrieveBookbags() throws SessionNotFoundException {
 
         Object response = Utils.doRequest(conn, SERVICE_ACTOR,
-                METHOD_FLESH_CONTAINERS, authToken, cm, new Object[] {
+                METHOD_FLESH_CONTAINERS, authToken, new Object[] {
                         authToken, userID, "biblio", "bookbag" });
 
         List<OSRFObject> bookbags = (List<OSRFObject>) response;
@@ -1215,15 +1142,12 @@ public class AccountAccess {
      * @param bookbagID the bookbag id
      * @return the bookbag content
      * @throws SessionNotFoundException the session not found exception
-     * @throws NoNetworkAccessException the no network access exception
-     * @throws NoAccessToServer the no access to server
      */
     private Object getBookbagContent(BookBag bag, Integer bookbagID)
-            throws SessionNotFoundException, NoNetworkAccessException,
-            NoAccessToServer {
+            throws SessionNotFoundException {
 
         Map<String, ?> map = (Map<String, ?>) Utils.doRequest(conn,
-                SERVICE_ACTOR, METHOD_FLESH_PUBLIC_CONTAINER, authToken, cm,
+                SERVICE_ACTOR, METHOD_FLESH_PUBLIC_CONTAINER, authToken,
                 new Object[] { authToken, "biblio", bookbagID });
         
         List<OSRFObject> items  = new ArrayList<OSRFObject>();
@@ -1248,11 +1172,8 @@ public class AccountAccess {
      *
      * @param id the id
      * @throws SessionNotFoundException the session not found exception
-     * @throws NoNetworkAccessException the no network access exception
-     * @throws NoAccessToServer the no access to server
      */
-    public void removeBookbagItem(Integer id) throws SessionNotFoundException,
-            NoNetworkAccessException, NoAccessToServer {
+    public void removeBookbagItem(Integer id) throws SessionNotFoundException {
 
         removeContainer("biblio", id);
 
@@ -1263,11 +1184,8 @@ public class AccountAccess {
      *
      * @param name the name
      * @throws SessionNotFoundException the session not found exception
-     * @throws NoNetworkAccessException the no network access exception
-     * @throws NoAccessToServer the no access to server
      */
-    public void createBookbag(String name) throws SessionNotFoundException,
-            NoNetworkAccessException, NoAccessToServer {
+    public void createBookbag(String name) throws SessionNotFoundException {
 
         OSRFObject cbreb = new OSRFObject("cbreb");
         cbreb.put("btype", "bookbag");
@@ -1283,14 +1201,11 @@ public class AccountAccess {
      *
      * @param id the id
      * @throws SessionNotFoundException the session not found exception
-     * @throws NoNetworkAccessException the no network access exception
-     * @throws NoAccessToServer the no access to server
      */
-    public void deleteBookBag(Integer id) throws SessionNotFoundException,
-            NoNetworkAccessException, NoAccessToServer {
+    public void deleteBookBag(Integer id) throws SessionNotFoundException {
 
         Object response = Utils.doRequest(conn, SERVICE_ACTOR,
-                METHOD_CONTAINER_FULL_DELETE, authToken, cm, new Object[] {
+                METHOD_CONTAINER_FULL_DELETE, authToken, new Object[] {
                         authToken, "biblio", id });
     }
 
@@ -1300,12 +1215,9 @@ public class AccountAccess {
      * @param record_id the record_id
      * @param bookbag_id the bookbag_id
      * @throws SessionNotFoundException the session not found exception
-     * @throws NoAccessToServer the no access to server
-     * @throws NoNetworkAccessException the no network access exception
      */
     public void addRecordToBookBag(Integer record_id, Integer bookbag_id)
-            throws SessionNotFoundException, NoAccessToServer,
-            NoNetworkAccessException {
+            throws SessionNotFoundException {
 
         OSRFObject cbrebi = new OSRFObject("cbrebi");
         cbrebi.put("bucket", bookbag_id);
@@ -1313,7 +1225,7 @@ public class AccountAccess {
         cbrebi.put("id", null);
 
         Object response = Utils.doRequest(conn, SERVICE_ACTOR,
-                METHOD_CONTAINER_ITEM_CREATE, authToken, cm, new Object[] {
+                METHOD_CONTAINER_ITEM_CREATE, authToken, new Object[] {
                         authToken, "biblio", cbrebi });
     }
 
@@ -1323,15 +1235,12 @@ public class AccountAccess {
      * @param container the container
      * @param id the id
      * @throws SessionNotFoundException the session not found exception
-     * @throws NoNetworkAccessException the no network access exception
-     * @throws NoAccessToServer the no access to server
      */
     private void removeContainer(String container, Integer id)
-            throws SessionNotFoundException, NoNetworkAccessException,
-            NoAccessToServer {
+            throws SessionNotFoundException {
 
         Object response = Utils.doRequest(conn, SERVICE_ACTOR,
-                METHOD_CONTAINER_DELETE, authToken, cm, new Object[] {
+                METHOD_CONTAINER_DELETE, authToken, new Object[] {
                         authToken, container, id });
     }
 
@@ -1341,15 +1250,12 @@ public class AccountAccess {
      * @param container the container
      * @param parameter the parameter
      * @throws SessionNotFoundException the session not found exception
-     * @throws NoNetworkAccessException the no network access exception
-     * @throws NoAccessToServer the no access to server
      */
     private void createContainer(String container, Object parameter)
-            throws SessionNotFoundException, NoNetworkAccessException,
-            NoAccessToServer {
+            throws SessionNotFoundException {
 
         Object response = Utils.doRequest(conn, SERVICE_ACTOR,
-                METHOD_CONTAINER_CREATE, authToken, cm, new Object[] {
+                METHOD_CONTAINER_CREATE, authToken, new Object[] {
                         authToken, container, parameter });
     }
 }
index 81377f3..c6b96d1 100644 (file)
@@ -25,8 +25,6 @@ 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.searchCatalog.RecordInfo;
 import org.evergreen.android.searchCatalog.SearchCatalog;
 import org.evergreen.android.searchCatalog.SearchCatalogListView;
@@ -52,7 +50,6 @@ import android.widget.AdapterView;
 import android.widget.AdapterView.OnItemSelectedListener;
 import android.widget.ArrayAdapter;
 import android.widget.Button;
-import android.widget.ImageButton;
 import android.widget.ListView;
 import android.widget.TextView;
 import android.widget.Toast;
@@ -146,13 +143,6 @@ public class BookBagDetails extends Activity {
                         try {
                             accountAccess.deleteBookBag(bookBag.id);
                         } catch (SessionNotFoundException e) {
-                            // TODO Auto-generated catch block
-                            e.printStackTrace();
-                        } catch (NoNetworkAccessException e) {
-                            // TODO Auto-generated catch block
-                            e.printStackTrace();
-                        } catch (NoAccessToServer e) {
-                            // TODO Auto-generated catch block
                             e.printStackTrace();
                         }
                         runOnUiThread(new Runnable() {
@@ -333,22 +323,11 @@ public class BookBagDetails extends Activity {
                             try {
                                 accountAccess.removeBookbagItem(record.id);
                             } catch (SessionNotFoundException e) {
-
                                 try {
-                                    if (accountAccess.authenticate())
-                                        accountAccess
-                                                .removeBookbagItem(record.id);
+                                    if (accountAccess.reauthenticate(BookBagDetails.this))
+                                        accountAccess.removeBookbagItem(record.id);
                                 } catch (Exception e1) {
                                 }
-                                ;
-
-                                e.printStackTrace();
-                            } catch (NoNetworkAccessException e) {
-                                // TODO Auto-generated catch block
-                                e.printStackTrace();
-                            } catch (NoAccessToServer e) {
-                                // TODO Auto-generated catch block
-                                e.printStackTrace();
                             }
 
                             runOnUiThread(new Runnable() {
index d5067cc..fe8ddee 100644 (file)
@@ -25,8 +25,6 @@ import java.util.List;
 import org.evergreen.android.R;
 import org.evergreen.android.accountAccess.AccountAccess;
 import org.evergreen.android.accountAccess.SessionNotFoundException;
-import org.evergreen.android.globals.NoAccessToServer;
-import org.evergreen.android.globals.NoNetworkAccessException;
 import org.evergreen.android.globals.Utils;
 import org.evergreen.android.searchCatalog.SearchCatalogListView;
 import org.evergreen.android.views.AccountScreenDashboard;
@@ -48,7 +46,6 @@ import android.widget.ArrayAdapter;
 import android.widget.Button;
 import android.widget.CheckBox;
 import android.widget.EditText;
-import android.widget.ImageButton;
 import android.widget.ListView;
 import android.widget.TextView;
 import android.widget.Toast;
@@ -210,7 +207,7 @@ public class BookbagsListView extends Activity {
                     bookBags = accountAccess.getBookbags();
 
                 } catch (NoNetworkAccessException e) {
-                    Utils.showNetworkNotAvailableDialog(context);
+                    Utils.showSessionNotAvailableDialog(context);
                 } catch (NoAccessToServer e) {
                     Utils.showServerNotAvailableDialog(context);
 
index 3456550..645d50a 100644 (file)
 package org.evergreen.android.accountAccess.checkout;
 
 import java.util.ArrayList;
-import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 
-import org.androwrapee.db.DefaultDAO;
 import org.evergreen.android.R;
 import org.evergreen.android.accountAccess.AccountAccess;
 import org.evergreen.android.accountAccess.MaxRenewalsException;
 import org.evergreen.android.accountAccess.ServerErrorMessage;
 import org.evergreen.android.accountAccess.SessionNotFoundException;
-import org.evergreen.android.database.DatabaseManager;
-import org.evergreen.android.globals.NoAccessToServer;
-import org.evergreen.android.globals.NoNetworkAccessException;
 import org.evergreen.android.globals.Utils;
 import org.evergreen.android.searchCatalog.SearchCatalogListView;
 import org.evergreen.android.views.AccountScreenDashboard;
 import org.evergreen.android.views.splashscreen.SplashActivity;
 
 import android.app.Activity;
-import android.app.AlarmManager;
-import android.app.PendingIntent;
 import android.app.ProgressDialog;
 import android.content.Context;
 import android.content.Intent;
@@ -146,7 +139,7 @@ public class ItemsCheckOutListView extends Activity {
                 try {
                     circRecords = accountAccess.getItemsCheckedOut();
                 } catch (NoNetworkAccessException e) {
-                    Utils.showNetworkNotAvailableDialog(context);
+                    Utils.showSessionNotAvailableDialog(context);
                 } catch (NoAccessToServer e) {
                     Utils.showServerNotAvailableDialog(context);
 
@@ -344,7 +337,7 @@ public class ItemsCheckOutListView extends Activity {
                                                 .println("Exception in reAuth");
                                     }
                                 } catch (NoNetworkAccessException e1) {
-                                    Utils.showNetworkNotAvailableDialog(context);
+                                    Utils.showSessionNotAvailableDialog(context);
                                 } catch (NoAccessToServer e1) {
                                     Utils.showServerNotAvailableDialog(context);
                                 }
@@ -355,7 +348,7 @@ public class ItemsCheckOutListView extends Activity {
                                         circRecords = accountAccess
                                                 .getItemsCheckedOut();
                                     } catch (NoNetworkAccessException e) {
-                                        Utils.showNetworkNotAvailableDialog(context);
+                                        Utils.showSessionNotAvailableDialog(context);
                                     } catch (NoAccessToServer e) {
                                         Utils.showServerNotAvailableDialog(context);
 
index c6d7248..0e9c171 100644 (file)
@@ -26,8 +26,6 @@ import java.util.List;
 import org.evergreen.android.R;
 import org.evergreen.android.accountAccess.AccountAccess;
 import org.evergreen.android.accountAccess.SessionNotFoundException;
-import org.evergreen.android.globals.NoAccessToServer;
-import org.evergreen.android.globals.NoNetworkAccessException;
 import org.evergreen.android.globals.Utils;
 import org.evergreen.android.searchCatalog.SearchCatalogListView;
 import org.evergreen.android.views.AccountScreenDashboard;
@@ -46,7 +44,6 @@ import android.view.View.OnClickListener;
 import android.view.ViewGroup;
 import android.widget.ArrayAdapter;
 import android.widget.Button;
-import android.widget.ImageButton;
 import android.widget.ListView;
 import android.widget.TextView;
 
@@ -139,31 +136,21 @@ public class FinesActivity extends Activity {
                     finesR = ac.getFinesSummary();
                 } catch (SessionNotFoundException e) {
                     try {
-                        if (ac.authenticate())
+                        if (ac.reauthenticate(FinesActivity.this))
                             finesR = ac.getFinesSummary();
                     } catch (Exception e1) {
                     }
-                } catch (NoNetworkAccessException e) {
-                    Utils.showNetworkNotAvailableDialog(context);
-                } catch (NoAccessToServer e) {
-                    Utils.showServerNotAvailableDialog(context);
                 }
 
                 ArrayList<FinesRecord> frecords = null;
                 try {
                     frecords = ac.getTransactions();
                 } catch (SessionNotFoundException e) {
-
                     try {
-                        if (ac.authenticate())
+                        if (ac.reauthenticate(FinesActivity.this))
                             frecords = ac.getTransactions();
                     } catch (Exception e1) {
                     }
-
-                } catch (NoNetworkAccessException e) {
-                    Utils.showNetworkNotAvailableDialog(context);
-                } catch (NoAccessToServer e) {
-                    Utils.showServerNotAvailableDialog(context);
                 }
 
                 final ArrayList<FinesRecord> finesRecords = frecords;
index 35b8407..6457b1d 100644 (file)
@@ -27,8 +27,6 @@ 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.SearchCatalogListView;
 import org.evergreen.android.views.AccountScreenDashboard;
@@ -56,7 +54,6 @@ import android.widget.CompoundButton;
 import android.widget.CompoundButton.OnCheckedChangeListener;
 import android.widget.DatePicker;
 import android.widget.EditText;
-import android.widget.ImageButton;
 import android.widget.Spinner;
 import android.widget.TextView;
 import android.widget.Toast;
@@ -239,16 +236,9 @@ public class HoldDetails extends Activity {
                                                 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())
+                                                        if (accountAccess.reauthenticate(HoldDetails.this))
                                                             accountAccess
                                                                     .cancelHold(record.ahr);
                                                     } catch (Exception eauth) {
@@ -293,15 +283,9 @@ public class HoldDetails extends Activity {
                     accountAccess.updateHold(record.ahr, selectedOrgPos,
                             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())
+                        if (accountAccess.reauthenticate(HoldDetails.this))
                             accountAccess.updateHold(record.ahr,
                                     selectedOrgPos,
                                     suspendHold.isChecked(), expire_date_s,
index ffb6bb0..414903e 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.evergreen.android.accountAccess.holds;
 
-import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -27,8 +26,6 @@ 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.ImageDownloader;
 import org.evergreen.android.searchCatalog.SearchCatalogListView;
@@ -49,7 +46,6 @@ import android.widget.AdapterView;
 import android.widget.AdapterView.OnItemClickListener;
 import android.widget.ArrayAdapter;
 import android.widget.Button;
-import android.widget.ImageButton;
 import android.widget.ImageView;
 import android.widget.ListView;
 import android.widget.TextView;
@@ -138,16 +134,14 @@ public class HoldsListView extends Activity {
                 try {
                     holdRecords = accountAccess.getHolds();
                 } catch (SessionNotFoundException e) {
-                    System.out.println("no session!");
-                    // TODO other way?
                     try {
-                        if (accountAccess.authenticate())
+                        if (accountAccess.reauthenticate(HoldsListView.this))
                             holdRecords = accountAccess.getHolds();
                     } catch (Exception eauth) {
-                        System.out.println("Exception in reAuth");
+                        System.out.println("Exception in reauth");
                     }
                 } catch (NoNetworkAccessException e) {
-                    Utils.showNetworkNotAvailableDialog(context);
+                    Utils.showSessionNotAvailableDialog(context);
                 } catch (NoAccessToServer e) {
                     Utils.showServerNotAvailableDialog(context);
                 }
index 616550e..7ffb7c6 100644 (file)
@@ -27,8 +27,6 @@ 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 org.evergreen.android.searchCatalog.SearchCatalogListView;
@@ -54,7 +52,6 @@ import android.widget.CompoundButton;
 import android.widget.CompoundButton.OnCheckedChangeListener;
 import android.widget.DatePicker;
 import android.widget.EditText;
-import android.widget.ImageButton;
 import android.widget.Spinner;
 import android.widget.TextView;
 import android.widget.Toast;
@@ -228,9 +225,8 @@ public class PlaceHold extends Activity {
                                     .getText().toString(), suspendHold
                                     .isChecked(), expire_date_s, thaw_date_s);
                 } catch (SessionNotFoundException e) {
-
                     try {
-                        if (accountAccess.authenticate())
+                        if (accountAccess.reauthenticate(PlaceHold.this))
                             stringResponse = accountAccess.createHold(
                                     record_id, selectedOrgID,
                                     email_notification.isChecked(),
@@ -240,11 +236,6 @@ public class PlaceHold extends Activity {
                                     thaw_date_s);
                     } catch (Exception e1) {
                     }
-
-                } catch (NoNetworkAccessException e) {
-                    Utils.showNetworkNotAvailableDialog(context);
-                } catch (NoAccessToServer e) {
-                    Utils.showServerNotAvailableDialog(context);
                 }
 
                 final String[] holdPlaced = stringResponse;
index 8198f73..0a4508b 100644 (file)
@@ -250,9 +250,7 @@ public class GlobalConfigs {
             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
+            } catch (SessionNotFoundException e) {
             }
 
         }
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
deleted file mode 100644 (file)
index 0806491..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2012 Evergreen Open-ILS
- * @author Daniel-Octavian Rizea
- * 
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * or the License, or (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be usefull,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software 
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
- * 
- */
-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/NoNetworkAccessException.java b/Open-ILS/src/Android/src/org/evergreen/android/globals/NoNetworkAccessException.java
deleted file mode 100644 (file)
index 9ca9c73..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2012 Evergreen Open-ILS
- * @author Daniel-Octavian Rizea
- * 
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * or the License, or (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be usefull,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software 
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
- * 
- */
-package org.evergreen.android.globals;
-
-public class NoNetworkAccessException 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
deleted file mode 100644 (file)
index cc4aec1..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2012 Evergreen Open-ILS
- * @author Daniel-Octavian Rizea
- * 
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * or the License, or (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be usefull,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software 
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
- * 
- */
-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/ShowSessionNotAvailableRunnable.java b/Open-ILS/src/Android/src/org/evergreen/android/globals/ShowSessionNotAvailableRunnable.java
new file mode 100644 (file)
index 0000000..9b73f1c
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2012 Evergreen Open-ILS
+ * @author Daniel-Octavian Rizea
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * or the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be usefull,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software 
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ * 
+ */
+package org.evergreen.android.globals;
+
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+
+class ShowSessionNotAvailableRunnable implements Runnable {
+
+    public Context context;
+
+    public ShowSessionNotAvailableRunnable(Context context) {
+        this.context = context;
+    }
+
+    @Override
+    public void run() {
+        AlertDialog alertDialog = new AlertDialog.Builder(context).create();
+        alertDialog.setTitle("Error");
+        alertDialog.setMessage("No session");
+        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 6604fbd..c2fe416 100644 (file)
@@ -29,6 +29,8 @@ import java.net.URL;
 import java.net.URLConnection;
 import java.util.Map;
 
+import android.os.Looper;
+import android.text.TextUtils;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.HttpClient;
 import org.apache.http.client.methods.HttpGet;
@@ -43,7 +45,6 @@ import android.content.Context;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
 import android.util.Log;
 import android.widget.ImageView;
 
@@ -118,8 +119,7 @@ public class Utils {
         return in;
     }
 
-    public static boolean checkIfNetAddressIsReachable(String url)
-            throws NoAccessToServer {
+    public static boolean checkIfNetAddressIsReachable(String url) {
 
        // The old method of fetching the URL to see if the net is "reachable" was not good;
         // it wasted bandwidth and time.  For now just check if the url is empty.
@@ -193,15 +193,19 @@ public class Utils {
 
     }
 
-    public static Object doRequest(HttpConnection conn, String service,
-            String methodName, String authToken, ConnectivityManager cm,
-            Object[] params) throws SessionNotFoundException,
-            NoNetworkAccessException, NoAccessToServer {
+    public static String getResponseTextcode(Object response) {
+        String textcode = null;
+        try {
+            textcode = ((Map<String, String>) response).get("textcode");
+        } catch (Exception e) {
+        }
+        return textcode;
+    }
 
-        // check to see if EG http server is reachable
-        checkIfNetAddressIsReachable(GlobalConfigs.httpAddress);
+    public static Object doRequest(HttpConnection conn, String service,
+                                   String methodName, String authToken,
+                                   Object[] params) throws SessionNotFoundException {
 
-        // TODO check params and throw errors
         Method method = new Method(methodName);
 
         Log.d(TAG, "doRequest Method :" + methodName + ": token :"+authToken+":");
@@ -229,21 +233,13 @@ public class Utils {
             Log.d(TAG, "Sync Response: " + resp);
             Object response = (Object) resp;
 
-            String textcode = null;
-            try {
-                textcode = ((Map<String, String>) response).get("textcode");
-            } catch (Exception e) {
-                //System.err.println(e.getMessage());
-            }
-            if (textcode != null) {
-                if (textcode.equals("NO_SESSION")) {
-                    Log.d(TAG, textcode);
-                    throw new SessionNotFoundException();
-                }
+            String textcode = getResponseTextcode(resp);
+            if (TextUtils.equals(textcode, "NO_SESSION")) {
+                Log.d(TAG, textcode);
+                throw new SessionNotFoundException();
             }
 
             return response;
-
         }
         return null;
 
@@ -251,11 +247,7 @@ public class Utils {
 
     // does not require authToken
     public static Object doRequest(HttpConnection conn, String service,
-            String methodName, ConnectivityManager cm, Object[] params)
-            throws NoNetworkAccessException, NoAccessToServer {
-
-        // check to see if EG http server is reachable
-        checkIfNetAddressIsReachable(GlobalConfigs.httpAddress);
+            String methodName, ConnectivityManager cm, Object[] params) {
 
         Method method = new Method(methodName);
 
@@ -284,6 +276,12 @@ public class Utils {
     // is fast than with checks for multiple method invocations like in search
     public static Object doRequestSimple(HttpConnection conn, String service,
             String methodName, Object[] params) {
+
+        if (Looper.myLooper() == Looper.getMainLooper()) {
+            // running on UI thread!
+            throw new NullPointerException();
+        }
+
         Method method = new Method(methodName);
         System.out.println("doRequestSimple Method :" + methodName);
         for (int i = 0; i < params.length; i++) {
@@ -305,16 +303,10 @@ public class Utils {
         return null;
     }
 
-    public static ShowServerNotAvailableRunnable showServerNotAvailableDialog(
-            Context context) {
-
-        return new ShowServerNotAvailableRunnable(context);
-    }
-
-    public static ShowNetworkNotAvailableRunnable showNetworkNotAvailableDialog(
+    public static ShowSessionNotAvailableRunnable showSessionNotAvailableDialog(
             Context context) {
 
-        return new ShowNetworkNotAvailableRunnable(context);
+        return new ShowSessionNotAvailableRunnable(context);
     }
 
 }
index 93641c0..052ff36 100644 (file)
@@ -155,7 +155,7 @@ public class AdvancedSearchActivity extends Activity {
                 }
 
                 TextView text = new TextView(context);
-                text.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
+                text.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
                         LayoutParams.WRAP_CONTENT));
                 text.setText(searchText);
                 layout.addView(text);
index 5ca240b..5f2f95c 100644 (file)
  */
 package org.evergreen.android.searchCatalog;
 
-import java.util.ArrayList;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Set;
 import java.util.Map.Entry;
 
 import org.evergreen.android.R;
-import org.evergreen.android.accountAccess.AccountAccess;
-import org.evergreen.android.accountAccess.SessionNotFoundException;
-import org.evergreen.android.accountAccess.fines.FinesRecord;
 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.views.AccountScreenDashboard;
 import org.evergreen.android.views.splashscreen.SplashActivity;
 
 import android.app.Activity;
-import android.app.ProgressDialog;
 import android.content.Context;
 import android.content.Intent;
-import android.graphics.Color;
 import android.os.Bundle;
-import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.view.ViewGroup.LayoutParams;
 import android.view.ViewGroup;
-import android.widget.ArrayAdapter;
 import android.widget.Button;
-import android.widget.ImageButton;
 import android.widget.LinearLayout;
-import android.widget.ListView;
 import android.widget.TextView;
 
 public class MoreCopyInformation extends Activity {
@@ -140,7 +126,7 @@ public class MoreCopyInformation extends Activity {
 
             // insert into main view
             insertPoint.addView(copy_info_view, new ViewGroup.LayoutParams(
-                    ViewGroup.LayoutParams.FILL_PARENT,
+                    LayoutParams.MATCH_PARENT,
                     ViewGroup.LayoutParams.WRAP_CONTENT));
 
             LinearLayout copy_statuses = (LinearLayout) copy_info_view
index 2765958..1da7060 100644 (file)
 package org.evergreen.android.searchCatalog;
 
 import java.util.ArrayList;
-import java.util.List;
 
 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.BaseSampleActivity;
 import org.evergreen.android.utils.ui.BasicDetailsFragment;
@@ -144,7 +141,7 @@ public class SampleUnderlinesNoFade extends BaseSampleActivity {
                             records.size());
                 } catch (NoNetworkAccessException e) {
                     runOnUiThread(Utils
-                            .showNetworkNotAvailableDialog(context));
+                            .showSessionNotAvailableDialog(context));
                 } catch (NoAccessToServer e) {
                     runOnUiThread(Utils
                             .showServerNotAvailableDialog(context));
index e65eff1..25dc918 100644 (file)
@@ -26,8 +26,6 @@ import java.util.List;
 import java.util.Map;
 
 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.opensrf.Method;
 import org.opensrf.net.http.GatewayRequest;
@@ -135,11 +133,6 @@ public class SearchCatalog {
 
     /**
      * Instantiates a new search catalog.
-     * 
-     * @param httpAddress
-     *            the http address
-     * @param locale
-     *            the locale
      */
     private SearchCatalog(ConnectivityManager cm) {
         super();
@@ -168,7 +161,7 @@ public class SearchCatalog {
      * @return the search results
      */
     public ArrayList<RecordInfo> getSearchResults(String searchWords,
-            Integer offset) throws NoNetworkAccessException, NoAccessToServer {
+            Integer offset) {
 
         searchText = searchWords;
         
@@ -290,8 +283,7 @@ public class SearchCatalog {
      *            the search words
      * @return the object
      */
-    public Object searchCatalog(String searchWords)
-            throws NoNetworkAccessException, NoAccessToServer {
+    public Object searchCatalog(String searchWords) {
 
         Object response = Utils.doRequest(conn, SERVICE, METHOD_SLIM_RETRIVE,
                 cm, new Object[] { "keyword", searchWords });
index 641f20e..cefe6ef 100644 (file)
@@ -30,8 +30,6 @@ import org.evergreen.android.accountAccess.bookbags.BookBag;
 import org.evergreen.android.accountAccess.holds.PlaceHold;
 import org.evergreen.android.barcodescan.CaptureActivity;
 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.views.AccountScreenDashboard;
 import org.evergreen.android.views.ApplicationPreferences;
@@ -267,17 +265,7 @@ public class SearchCatalogListView extends Activity {
                     }
                 });
 
-                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));
-                }
+                searchResults = search.getSearchResults(text, 0);
 
                 runOnUiThread(new Runnable() {
 
@@ -334,16 +322,8 @@ public class SearchCatalogListView extends Activity {
 
                             searchResults.clear();
 
-                            try {
-                                searchResults = search.getSearchResults(text,
-                                        recordList.size());
-                            } catch (NoNetworkAccessException e) {
-                                runOnUiThread(Utils
-                                        .showNetworkNotAvailableDialog(context));
-                            } catch (NoAccessToServer e) {
-                                runOnUiThread(Utils
-                                        .showServerNotAvailableDialog(context));
-                            }
+                            searchResults = search.getSearchResults(text,
+                                    recordList.size());
 
                             runOnUiThread(new Runnable() {
 
@@ -447,17 +427,9 @@ public class SearchCatalogListView extends Activity {
                                                 .toString();
                                         searchResults.clear();
 
-                                        try {
-                                            searchResults = search
-                                                    .getSearchResults(text,
-                                                            adapter.getCount());
-                                        } catch (NoNetworkAccessException e) {
-                                            runOnUiThread(Utils
-                                                    .showNetworkNotAvailableDialog(context));
-                                        } catch (NoAccessToServer e) {
-                                            runOnUiThread(Utils
-                                                    .showServerNotAvailableDialog(context));
-                                        }
+                                        searchResults = search
+                                                .getSearchResults(text,
+                                                        adapter.getCount());
 
                                         runOnUiThread(new Runnable() {
 
@@ -666,12 +638,6 @@ public class SearchCatalogListView extends Activity {
                                 } catch (SessionNotFoundException e) {
                                     // TODO Auto-generated catch block
                                     e.printStackTrace();
-                                } catch (NoAccessToServer e) {
-                                    // TODO Auto-generated catch block
-                                    e.printStackTrace();
-                                } catch (NoNetworkAccessException e) {
-                                    // TODO Auto-generated catch block
-                                    e.printStackTrace();
                                 }
 
                                 runOnUiThread(new Runnable() {
index 953566c..f40db46 100644 (file)
@@ -31,8 +31,6 @@ import org.evergreen.android.accountAccess.SessionNotFoundException;
 import org.evergreen.android.accountAccess.checkout.CircRecord;
 import org.evergreen.android.database.DatabaseManager;
 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;
 
@@ -41,7 +39,6 @@ import android.app.IntentService;
 import android.app.PendingIntent;
 import android.content.Intent;
 import android.content.SharedPreferences;
-import android.net.ConnectivityManager;
 import android.preference.PreferenceManager;
 import android.util.Log;
 
@@ -97,10 +94,7 @@ public class ScheduledIntentService extends IntentService {
         boolean auth = true;
         try {
             accountAccess.authenticate();
-        } catch (NoNetworkAccessException e) {
-            auth = false;
-            e.printStackTrace();
-        } catch (NoAccessToServer e) {
+        } catch (Exception e) {
             auth = false;
             e.printStackTrace();
         }
@@ -120,10 +114,6 @@ public class ScheduledIntentService extends IntentService {
             // get the circ records
             try {
                 circRecords = accountAccess.getItemsCheckedOut();
-            } catch (NoNetworkAccessException e) {
-                // not suppose to happen
-            } catch (NoAccessToServer e) {
-                // not suppose to happen
             } catch (SessionNotFoundException e) {
                 // auth just earlier realized, not supose to happen
             }
index 036914b..d73d517 100644 (file)
@@ -30,8 +30,6 @@ import org.evergreen.android.accountAccess.SessionNotFoundException;
 import org.evergreen.android.accountAccess.bookbags.BookBag;
 import org.evergreen.android.accountAccess.holds.PlaceHold;
 import org.evergreen.android.globals.GlobalConfigs;
-import org.evergreen.android.globals.NoAccessToServer;
-import org.evergreen.android.globals.NoNetworkAccessException;
 import org.evergreen.android.searchCatalog.CopyInformation;
 import org.evergreen.android.searchCatalog.ImageDownloader;
 import org.evergreen.android.searchCatalog.MoreCopyInformation;
@@ -40,9 +38,7 @@ import org.evergreen.android.searchCatalog.SearchCatalog;
 
 import android.app.Dialog;
 import android.app.ProgressDialog;
-import android.content.Context;
 import android.content.Intent;
-import android.graphics.Bitmap;
 import android.os.Bundle;
 import android.support.v4.app.Fragment;
 import android.view.LayoutInflater;
@@ -224,12 +220,6 @@ public class BasicDetailsFragment extends Fragment {
                         } catch (SessionNotFoundException e) {
                             // TODO Auto-generated catch block
                             e.printStackTrace();
-                        } catch (NoAccessToServer e) {
-                            // TODO Auto-generated catch block
-                            e.printStackTrace();
-                        } catch (NoNetworkAccessException e) {
-                            // TODO Auto-generated catch block
-                            e.printStackTrace();
                         }
 
                         getActivity().runOnUiThread(new Runnable() {
@@ -370,7 +360,7 @@ public class BasicDetailsFragment extends Fragment {
 
             // insert into main view
             insertPoint.addView(copy_info_view, new ViewGroup.LayoutParams(
-                    ViewGroup.LayoutParams.FILL_PARENT,
+                    LayoutParams.MATCH_PARENT,
                     ViewGroup.LayoutParams.WRAP_CONTENT));
 
             LinearLayout copy_statuses = (LinearLayout) copy_info_view
index 1c67a61..f2d53b7 100644 (file)
@@ -24,16 +24,11 @@ import java.util.Calendar;
 import org.evergreen.android.R;
 import org.evergreen.android.accountAccess.AccountAccess;
 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.services.NotificationAlert;
-import org.evergreen.android.services.NotificationReceiver;
 import org.evergreen.android.services.PeriodicServiceBroadcastReceiver;
 import org.evergreen.android.services.ScheduledIntentService;
 
 import android.app.AlarmManager;
-import android.app.AlertDialog;
 import android.app.PendingIntent;
 import android.app.ProgressDialog;
 import android.content.Context;
@@ -46,7 +41,6 @@ import android.os.Bundle;
 import android.preference.PreferenceActivity;
 import android.preference.PreferenceManager;
 import android.provider.Settings;
-import android.util.Log;
 import android.widget.Toast;
 
 public class ApplicationPreferences extends PreferenceActivity implements
@@ -119,7 +113,6 @@ public class ApplicationPreferences extends PreferenceActivity implements
                 AccountAccess account = AccountAccess.getAccountAccess(GlobalConfigs.httpAddress);
 
                 if (routeToAddress) {
-
                     try {
                         if (account.authenticate()) {
 
index b723fd9..f37f127 100644 (file)
@@ -22,15 +22,12 @@ 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.NoAccessToServer;
 import org.evergreen.android.globals.Utils;
 
 import android.app.Activity;
 import android.app.ProgressDialog;
-import android.app.Service;
 import android.content.Context;
 import android.content.SharedPreferences;
-import android.net.ConnectivityManager;
 import android.os.Bundle;
 import android.preference.PreferenceManager;
 import android.util.Log;
@@ -87,13 +84,9 @@ public class ConfigureApplicationActivity extends Activity {
                         boolean server_address = false;
                         boolean auth = false;
 
-                        try {
-                            server_address = Utils
-                                    .checkIfNetAddressIsReachable(server_http
-                                            .getText().toString());
-                        } catch (NoAccessToServer e) {
-                            server_address = false;
-                        }
+                        server_address = Utils
+                                .checkIfNetAddressIsReachable(server_http
+                                        .getText().toString());
 
                         if (server_address == true) {
                             
index 771bb3e..13242db 100644 (file)
  */
 package org.evergreen.android.views.splashscreen;
 
-import java.security.PublicKey;
-
 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_ils.auth.Const;
 
 import android.accounts.Account;
 import android.accounts.AccountManager;
-import android.accounts.AccountManagerCallback;
 import android.accounts.AccountManagerFuture;
 import android.app.Activity;
-import android.net.ConnectivityManager;
-import android.os.AsyncTask;
 import android.os.Bundle;
 import android.util.Log;
-import android.widget.ProgressBar;
-import android.widget.TextView;
 
 /** This is basically the same as an AsyncTask<String,String,String>, except that it uses
  * a Thread.  Starting with HONEYCOMB, tasks are executed on a single thread and the 2nd
@@ -123,7 +114,7 @@ public class LoadingTask {
             boolean haveSession = false;
             boolean retry = false;
             try {
-                haveSession = ac.initSession(auth_token);
+                haveSession = ac.retrieveSession(auth_token);
             } catch (SessionNotFoundException e) {
                 mAccountManager.invalidateAuthToken(Const.ACCOUNT_TYPE, auth_token);
                 retry = true;
@@ -138,7 +129,7 @@ public class LoadingTask {
                 Log.d(TAG, tag+"account_name="+account_name+" token="+auth_token);
                 if (account_name == null)
                     return "no account";
-                haveSession = ac.initSession(auth_token);
+                haveSession = ac.retrieveSession(auth_token);
             }
             if (!haveSession)
                 return "no session";