#Feature 198
authorNikita Kozlov <nikita@beem-project.com>
Fri, 06 Nov 2009 14:09:30 +0100
changeset 490 daccdb7f4237
parent 489 77c573c8217e
child 491 a94c384bc3ba
child 493 56af5554a081
#Feature 198 C'est fait, faudrait peut etre ajouter une petite dialog box precisant que le timer est en cour.
.classpath
src/com/beem/project/beem/service/Contact.java
src/com/beem/project/beem/ui/Login.java
--- a/.classpath	Tue Nov 03 01:49:00 2009 +0100
+++ b/.classpath	Fri Nov 06 14:09:30 2009 +0100
@@ -2,7 +2,7 @@
 <classpath>
 	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
 	<classpathentry kind="lib" path="libs/smackx-debug.jar"/>
-	<classpathentry kind="lib" path="libs/smackx-jingle.jar" sourcepath="/home/marseille/smack_src_3_1_0/">
+	<classpathentry kind="lib" path="libs/smackx-jingle.jar" sourcepath="/home/nikita/devel/smack">
 		<attributes>
 			<attribute name="javadoc_location" value="file:/home/nikita/devel/smack_src_3_1_0/javadoc/"/>
 		</attributes>
--- a/src/com/beem/project/beem/service/Contact.java	Tue Nov 03 01:49:00 2009 +0100
+++ b/src/com/beem/project/beem/service/Contact.java	Fri Nov 06 14:09:30 2009 +0100
@@ -65,6 +65,20 @@
 	in.readStringList(mRes);
 	in.readStringList(mGroups);
     }
+    
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+	dest.writeInt(mID);
+	dest.writeInt(mStatus);
+	dest.writeString(mJID);
+	dest.writeString(mName);
+	dest.writeString(mMsgState);
+	dest.writeStringList(getMRes());
+	dest.writeStringList(getGroups());
+    }
 
     /**
      * Constructor.
@@ -335,18 +349,6 @@
 	return u;
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void writeToParcel(Parcel dest, int flags) {
-	dest.writeInt(mID);
-	dest.writeInt(mStatus);
-	dest.writeString(mJID);
-	dest.writeString(mName);
-	dest.writeString(mMsgState);
-	dest.writeStringList(getMRes());
-	dest.writeStringList(getGroups());
-    }
+
 
 }
--- a/src/com/beem/project/beem/ui/Login.java	Tue Nov 03 01:49:00 2009 +0100
+++ b/src/com/beem/project/beem/ui/Login.java	Fri Nov 06 14:09:30 2009 +0100
@@ -3,6 +3,7 @@
 import android.app.Activity;
 import android.app.AlertDialog;
 import android.app.ProgressDialog;
+import android.app.ActivityManager.RunningAppProcessInfo;
 import android.content.ComponentName;
 import android.content.DialogInterface;
 import android.content.Intent;
@@ -12,6 +13,7 @@
 import android.os.Handler;
 import android.os.IBinder;
 import android.os.RemoteException;
+import android.os.SystemClock;
 import android.preference.PreferenceManager;
 import android.util.Log;
 import android.view.Menu;
@@ -40,6 +42,7 @@
     }
 
     private final Handler mConnectionHandler = new Handler();
+    private ConnectionRunnable mConnectionRunnable = new ConnectionRunnable();
     private ProgressDialog mProgressDialog;
 
     private boolean mIsConnected;
@@ -48,6 +51,7 @@
 
     private SharedPreferences mSettings;
     private boolean mIsConfigured;
+    private int mRetry;
 
     /**
      * Constructor.
@@ -92,6 +96,14 @@
 	    unbindService(mServConn);
 	}
     }
+    
+    /**
+     * {@inheritDoc}
+     */
+    protected void onPause() {
+	super.onPause();
+	mConnectionHandler.removeCallbacks(mConnectionRunnable);
+    }
 
     /**
      * {@inheritDoc}
@@ -147,6 +159,21 @@
 	}
     }
 
+
+    private class ConnectionRunnable implements Runnable {
+	@Override
+	public void run() {
+	    if (mRetry++ > 3) {
+		Toast.makeText(Login.this, "Max retry", Toast.LENGTH_LONG).show();
+	    } else {
+		mIsConfigured = mSettings.getBoolean("PreferenceIsConfigured", false);
+		if (mIsConfigured)
+		    bindService(Login.SERVICE_INTENT, mServConn, BIND_AUTO_CREATE);
+	    }
+
+	}
+    }
+
     /**
      * Listener use to check the state of the connection with the server.
      */
@@ -188,6 +215,7 @@
 	    }
 	    dismissProgressDialog();
 	    showToast(errorMsg);
+	    mConnectionHandler.postAtTime(mConnectionRunnable, Integer.parseInt(mSettings.getString("settings_key_reco_delay", "10")) * 1000 + SystemClock.uptimeMillis());
 	}
 
 	/**
@@ -230,6 +258,7 @@
 	    dismissProgressDialog();
 	    Log.i(TAG, "Connected.");
 	    mXmppFacade.changeStatus(Status.CONTACT_STATUS_AVAILABLE, null);
+	    mRetry = 0;
 	    startActivity(new Intent(Login.this, ContactList.class));
 	    finish();
 	}