equal
deleted
inserted
replaced
1 package com.beem.project.beem.ui; |
1 package com.beem.project.beem.ui; |
2 |
2 |
3 import android.app.Activity; |
3 import android.app.Activity; |
4 import android.app.AlertDialog; |
4 import android.app.AlertDialog; |
5 import android.app.ProgressDialog; |
5 import android.app.ProgressDialog; |
|
6 import android.content.BroadcastReceiver; |
6 import android.content.ComponentName; |
7 import android.content.ComponentName; |
|
8 import android.content.Context; |
7 import android.content.DialogInterface; |
9 import android.content.DialogInterface; |
8 import android.content.Intent; |
10 import android.content.Intent; |
9 import android.content.ServiceConnection; |
11 import android.content.ServiceConnection; |
10 import android.content.SharedPreferences; |
12 import android.content.SharedPreferences; |
11 import android.os.Bundle; |
13 import android.os.Bundle; |
44 private final ServiceConnection mServConn = new BeemServiceConnection(); |
46 private final ServiceConnection mServConn = new BeemServiceConnection(); |
45 private IXmppFacade mXmppFacade; |
47 private IXmppFacade mXmppFacade; |
46 |
48 |
47 private SharedPreferences mSettings; |
49 private SharedPreferences mSettings; |
48 private boolean mIsConfigured; |
50 private boolean mIsConfigured; |
|
51 private BroadcastReceiver mReceiver; |
49 |
52 |
50 /** |
53 /** |
51 * Constructor. |
54 * Constructor. |
52 */ |
55 */ |
53 public Login() { |
56 public Login() { |
76 public void onCreate(Bundle savedInstanceState) { |
79 public void onCreate(Bundle savedInstanceState) { |
77 super.onCreate(savedInstanceState); |
80 super.onCreate(savedInstanceState); |
78 mSettings = getSharedPreferences(getString(R.string.settings_filename), MODE_PRIVATE); |
81 mSettings = getSharedPreferences(getString(R.string.settings_filename), MODE_PRIVATE); |
79 setContentView(R.layout.login); |
82 setContentView(R.layout.login); |
80 mProgressDialog = new ProgressDialog(this); |
83 mProgressDialog = new ProgressDialog(this); |
|
84 mReceiver = new BeemBroadcastReceiver(); |
81 } |
85 } |
82 |
86 |
83 @Override |
87 @Override |
84 protected void onDestroy() { |
88 protected void onDestroy() { |
85 super.onDestroy(); |
89 super.onDestroy(); |
170 /** |
174 /** |
171 * {@inheritDoc} |
175 * {@inheritDoc} |
172 */ |
176 */ |
173 @Override |
177 @Override |
174 public void connectionClosed() throws RemoteException { |
178 public void connectionClosed() throws RemoteException { |
175 mIsConnected = false; |
179 /*mIsConnected = false; |
176 if (mXmppFacade != null) { |
180 if (mXmppFacade != null) { |
177 Login.this.unbindService(mServConn); |
181 Login.this.unbindService(mServConn); |
178 Login.this.stopService(SERVICE_INTENT); |
182 Login.this.stopService(SERVICE_INTENT); |
179 mXmppFacade = null; |
183 mXmppFacade = null; |
180 } |
184 }*/ |
181 } |
185 } |
182 |
186 |
183 @Override |
187 @Override |
184 public void connectionClosedOnError() throws RemoteException { |
188 public void connectionClosedOnError() throws RemoteException { |
185 } |
189 } |
301 public void onServiceDisconnected(ComponentName name) { |
305 public void onServiceDisconnected(ComponentName name) { |
302 mIsConnected = false; |
306 mIsConnected = false; |
303 mXmppFacade = null; |
307 mXmppFacade = null; |
304 } |
308 } |
305 } |
309 } |
|
310 |
|
311 private class BeemBroadcastReceiver extends BroadcastReceiver { |
|
312 @Override |
|
313 public void onReceive(Context context, Intent intent) { |
|
314 unbindService(mServConn); |
|
315 stopService(SERVICE_INTENT); |
|
316 mIsConnected = false; |
|
317 mXmppFacade = null; |
|
318 } |
|
319 } |
306 |
320 |
307 } |
321 } |