src/com/beem/project/beem/utils/BeemBroadcastReceiver.java
changeset 502 3091acfe31f4
parent 474 dd6d3c09d0d1
child 503 93e5d2d9953f
--- a/src/com/beem/project/beem/utils/BeemBroadcastReceiver.java	Wed Nov 11 17:58:26 2009 +0100
+++ b/src/com/beem/project/beem/utils/BeemBroadcastReceiver.java	Wed Nov 11 19:21:44 2009 +0100
@@ -12,59 +12,65 @@
 
 /**
  * Manage broadcast disconnect intent.
+ * 
  * @author nikita
  */
 public class BeemBroadcastReceiver extends BroadcastReceiver {
 
-    /**
-     * Broadcast intent type.
-     */
-    public static final String BEEM_CONNECTION_CLOSED = "BeemConnectionClosed";
-    private ServiceConnection mService;
-    private boolean mIsBinded;
+	/**
+	 * Broadcast intent type.
+	 */
+	public static final String BEEM_CONNECTION_CLOSED = "BeemConnectionClosed";
+	private ServiceConnection mService;
+	private boolean mIsBinded;
 
-    /**
-     * constructor.
-     * @param service service observed
-     */
-    public BeemBroadcastReceiver(final ServiceConnection service) {
-	mService = service;
-	mIsBinded = false;
-    }
+	/**
+	 * constructor.
+	 * 
+	 * @param service
+	 *            service observed
+	 */
+	public BeemBroadcastReceiver(final ServiceConnection service) {
+		mService = service;
+		mIsBinded = false;
+	}
 
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void onReceive(Context context, Intent intent) {
-	Log.d("Broadcast", "onReceive");
-	if (mIsBinded)
-	    context.unbindService(mService);
-	setBinded(false);
-	// start activity if unexpected disconnection
-	if (!intent.getBooleanExtra("normally", false))
-	    context.startActivity(new Intent(context, Login.class));
-	CharSequence message = intent.getCharSequenceExtra("message");
-	Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
-	if (context instanceof Activity) {
-	    Activity act = (Activity) context;
-	    act.finish();
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void onReceive(Context context, Intent intent) {
+		Log.d("Broadcast", "onReceive");
+		if (mIsBinded)
+			context.unbindService(mService);
+		setBinded(false);
+		// start activity if unexpected disconnection
+		if (!intent.getBooleanExtra("normally", false))
+			context.startActivity(new Intent(context, Login.class));
+		CharSequence message = intent.getCharSequenceExtra("message");
+		Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
+		if (context instanceof Activity) {
+			Activity act = (Activity) context;
+			act.finish();
+		}
 	}
-    }
 
-    /**
-     * service is binded.
-     * @param binded the state of the bind.
-     */
-    public void setBinded(boolean binded) {
-	mIsBinded = binded;
-    }
+	/**
+	 * service is binded.
+	 * 
+	 * @param binded
+	 *            the state of the bind.
+	 */
+	public void setBinded(boolean binded) {
+		mIsBinded = binded;
+	}
 
-    /**
-     * return service bind status.
-     * @return service bind status.
-     */
-    public boolean isBinded() {
-	return mIsBinded;
-    }
+	/**
+	 * return service bind status.
+	 * 
+	 * @return service bind status.
+	 */
+	public boolean isBinded() {
+		return mIsBinded;
+	}
 }