# HG changeset patch # User Nikita Kozlov # Date 1257512970 -3600 # Node ID daccdb7f4237081a00cdbd247e09166497777d90 # Parent 77c573c8217ec2463bffa11fcca02974fd9d9079 #Feature 198 C'est fait, faudrait peut etre ajouter une petite dialog box precisant que le timer est en cour. diff -r 77c573c8217e -r daccdb7f4237 .classpath --- a/.classpath Tue Nov 03 01:49:00 2009 +0100 +++ b/.classpath Fri Nov 06 14:09:30 2009 +0100 @@ -2,7 +2,7 @@ - + diff -r 77c573c8217e -r daccdb7f4237 src/com/beem/project/beem/service/Contact.java --- 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()); - } + } diff -r 77c573c8217e -r daccdb7f4237 src/com/beem/project/beem/ui/Login.java --- 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(); }