public HttpConnection conn;
/** The http address. */
- public String httpAddress = "http://ulysses.calvin.edu";
+ private String httpAddress = "http://ulysses.calvin.edu";
/** The TAG. */
public String TAG = "AuthenticareUser";
}
+ public boolean isAuthenticated(){
+
+ if(authToken != null)
+ return true;
+
+ return false;
+ }
+
public static AccountAccess getAccountAccess(String httpAddress){
if(accountAccess == null){
accountAccess = new AccountAccess(httpAddress);
}
+ System.out.println(" Addresses " + httpAddress + " " + accountAccess.httpAddress);
if(!httpAddress.equals(accountAccess.httpAddress))
accountAccess.updateHttpAddress(httpAddress);
* Change the Http conn to a new library address
*/
public void updateHttpAddress(String httpAddress){
-
+ System.out.println("update http address of account access to " + httpAddress);
try {
// configure the connection
-
+ this.httpAddress = httpAddress;
System.out.println("Connection with " + httpAddress);
conn = new HttpConnection(httpAddress + "/osrf-gateway-v1");
complexParam.put("username", userName);
complexParam.put("password", hash);
+ System.out.println("Password " + password);
System.out.println("Compelx param " + complexParam);
Object resp = Utils.doRequest(conn, SERVICE_AUTH, METHOD_AUTH_COMPLETE, new Object[]{complexParam});
context = this;
accountAccess = AccountAccess.getAccountAccess();
- lv = (ListView) findViewById(R.id.checkout_items_list);
-
- circRecords = accountAccess.getItemsCheckedOut();
+ Thread getCirc = new Thread(new Runnable() {
+
+ @Override
+ public void run() {
+ lv = (ListView) findViewById(R.id.checkout_items_list);
+ circRecords = accountAccess.getItemsCheckedOut();
+ listAdapter = new CheckOutArrayAdapter(context, R.layout.checkout_list_item, circRecords);
+ lv.setAdapter(listAdapter);
+
+ listAdapter.notifyDataSetChanged();
+
+ runOnUiThread(new Runnable() {
+
+ @Override
+ public void run() {
+ progressDialog.dismiss();
+ }
+ });
+ }
+ });
- listAdapter = new CheckOutArrayAdapter(this, R.layout.checkout_list_item, circRecords);
- lv.setAdapter(listAdapter);
+ if(accountAccess.isAuthenticated()){
+ progressDialog = new ProgressDialog(context);
+ progressDialog.setMessage("Please wait while retrieving circ data");
+ getCirc.start();
+
+ }
+ else
+ Toast.makeText(context, "You must be authenticated to retrieve circ records", Toast.LENGTH_LONG);
-
- listAdapter.notifyDataSetChanged();
}
private static String TAG = "GlobalConfigs";
+ public static boolean loadedIDL = false;
+
+ public static boolean loadedOrgTree = false;
+
/** The locale. */
public String locale = "en-US";
return false;
}
- private static void loadIDLFile(){
+ public void loadIDLFile(){
String idlFile = "/reports/fm_IDL.xml";
try{
System.err.println("Error in parsing IDL file " + idlFile + " " + e.getMessage());
};
+ loadedIDL = true;
}
/**
*
* @return the organisations
*/
- private void getOrganisations(){
+ public void getOrganisations(){
String orgFile = null;
try{
level ++;
}
organisations = orgs;
+
+ loadedOrgTree = true;
}
}
}
private String TAG = "ApplicationPreferences";
private Thread connectionThread = null;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.application_preference_screen);
-
+
context = this;
reference = this;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
}else
if(key.equals("library_url")){
GlobalConfigs.httpAddress = sharedPreferences.getString("library_url", "");
+
+ if(GlobalConfigs.loadedIDL == false){
+
+ progressDialog = new ProgressDialog(context);
+ progressDialog.setMessage("Please wait while downloading FM IDL file and OrgTree");
+
+ Thread loadIDLThread = new Thread(new Runnable() {
+
+ @Override
+ public void run() {
+ System.out.println("FM idl download");
+ GlobalConfigs sg = GlobalConfigs.getGlobalConfigs(context);
+ sg.loadIDLFile();
+ sg.getOrganisations();
+ }
+ });
+
+ loadIDLThread.start();
+
+ //wait for execution
+ try{
+ loadIDLThread.join();
+ }catch(Exception e){}
+
+ progressDialog.dismiss();
+ }
+
}
+
//test connection
if(!isFinishing())
progressDialog = ProgressDialog.show(this, "Account login", "Please wait while we test the new user account information");