|
@@ -173,7 +173,7 @@ public class WiFiP2pSyncActivity extends Activity implements AdapterView.OnItemC
|
|
|
|
|
|
@Override
|
|
|
public void discoveredDevices(List<WifiP2pDevice> peers) {
|
|
|
- Log.d("WiFiP2pSyncActivity", "Actualise devices list" + ".");
|
|
|
+ Log.d("WiFiP2pSyncActivity", "Actualise devices list");
|
|
|
this.activity.updateDeviceListView(peers);
|
|
|
}
|
|
|
|
|
@@ -186,7 +186,7 @@ public class WiFiP2pSyncActivity extends Activity implements AdapterView.OnItemC
|
|
|
|
|
|
@Override
|
|
|
public void didConnect(boolean isHost, WifiP2pInfo connectionInfo) {
|
|
|
- Log.d("WiFiP2pSyncActivity", "Did connect" + ".");
|
|
|
+ Log.d("WiFiP2pSyncActivity", "Did connect");
|
|
|
|
|
|
String progressTitle = PROGRESS_TITLE_LOADING;
|
|
|
if (this.activity.progressDialog != null){
|
|
@@ -197,30 +197,30 @@ public class WiFiP2pSyncActivity extends Activity implements AdapterView.OnItemC
|
|
|
|
|
|
this.activity.setHost(isHost);
|
|
|
if (isHost){
|
|
|
- Log.d("WiFiP2pSyncActivity", "Connected as HOST" + ".");
|
|
|
+ Log.d("WiFiP2pSyncActivity", "Connected as HOST");
|
|
|
this.activity.startHost();
|
|
|
} else {
|
|
|
- Log.d("WiFiP2pSyncActivity", "Connected as Client" + ".");
|
|
|
+ Log.d("WiFiP2pSyncActivity", "Connected as Client");
|
|
|
this.activity.startClient(connectionInfo);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void failedToConnect() {
|
|
|
- Log.d("WiFiP2pSyncActivity", "Failed to connect" + ".");
|
|
|
+ Log.d("WiFiP2pSyncActivity", "Failed to connect");
|
|
|
Toast.makeText(this.activity, COULD_NOT_CONNECT_MESSAGE , Toast.LENGTH_LONG).show();
|
|
|
this.activity.progressDialog.dismiss();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void didDisconnect() {
|
|
|
- Log.d("WiFiP2pSyncActivity", "Did disconnect" + ".");
|
|
|
+ Log.d("WiFiP2pSyncActivity", "Did disconnect");
|
|
|
this.activity.progressDialog.dismiss();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void failedToDisconnect() {
|
|
|
- Log.d("WiFiP2pSyncActivity", "Failed to disconnect" + ".");
|
|
|
+ Log.d("WiFiP2pSyncActivity", "Failed to disconnect");
|
|
|
//Toast.makeText(this.activity, "Could not disconnect with device. Retry.", Toast.LENGTH_LONG).show();
|
|
|
// Other device did disconnect a while before.
|
|
|
this.activity.progressDialog.dismiss();
|
|
@@ -275,16 +275,18 @@ public class WiFiP2pSyncActivity extends Activity implements AdapterView.OnItemC
|
|
|
public void didSucceed() {
|
|
|
Toast.makeText(this.activity, SYNCHRONIZATION_COMPLETE_MESSAGE , Toast.LENGTH_SHORT).show();
|
|
|
this.activity.wifiEventHandler().disconnect();
|
|
|
+ this.activity.hostTask.setInterrupted(true);
|
|
|
this.activity.hostTask = null;
|
|
|
- this.activity.clientTask = null;
|
|
|
+ //this.activity.clientTask = null;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void didFail() {
|
|
|
Toast.makeText(this.activity, SYNCHRONIZATION_FAILED_MESSAGE, Toast.LENGTH_LONG).show();
|
|
|
this.activity.wifiEventHandler().disconnect();
|
|
|
+ this.activity.hostTask.setInterrupted(true);
|
|
|
this.activity.hostTask = null;
|
|
|
- this.activity.clientTask = null;
|
|
|
+ //this.activity.clientTask = null;
|
|
|
}
|
|
|
}.init(this);
|
|
|
}
|
|
@@ -334,16 +336,15 @@ public class WiFiP2pSyncActivity extends Activity implements AdapterView.OnItemC
|
|
|
*/
|
|
|
private void startHost()
|
|
|
{
|
|
|
- if (this.hostTask == null){
|
|
|
- Log.d("WiFiP2pSyncActivity", "Starting HOST Task" + ".");
|
|
|
+ if (this.hostTask == null || this.hostTask.isInterrupted()){
|
|
|
+ Log.d("WiFiP2pSyncActivity", "Starting HOST Task");
|
|
|
//Toast.makeText(this, PERFORMING_TASK_AS_HOST , Toast.LENGTH_SHORT).show();
|
|
|
this.hostTask = new SyncHostTask(this.ownDevice, this.syncCompletionListener(), getApplicationContext());
|
|
|
this.executingTask = this.hostTask;
|
|
|
this.hostTask.execute();
|
|
|
} else {
|
|
|
- Log.d("WiFiP2pSyncActivity", "Preventing third device for any syncing" + ".");
|
|
|
+ Log.d("WiFiP2pSyncActivity", "Preventing third device for any syncing.");
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -352,16 +353,10 @@ public class WiFiP2pSyncActivity extends Activity implements AdapterView.OnItemC
|
|
|
*/
|
|
|
private void startClient(WifiP2pInfo info)
|
|
|
{
|
|
|
- if (this.clientTask == null){
|
|
|
- Log.d("WiFiP2pSyncActivity", "Starting CLIENT Task" + ".");
|
|
|
- //Toast.makeText(this, PERFORMING_TASK_AS_CLIENT, Toast.LENGTH_SHORT).show();
|
|
|
- this.clientTask = new SyncClientTask( info.groupOwnerAddress.getHostAddress(),this.ownDevice, this.syncCompletionListener(), getApplicationContext() );
|
|
|
- this.executingTask = this.clientTask;
|
|
|
- this.clientTask.execute();
|
|
|
- } else {
|
|
|
- Log.d("WiFiP2pSyncActivity", "Preventing third device for syncing" + ".");
|
|
|
- }
|
|
|
-
|
|
|
+ Log.d("WiFiP2pSyncActivity", "Starting CLIENT Task");
|
|
|
+ this.clientTask = new SyncClientTask( info.groupOwnerAddress.getHostAddress(),this.ownDevice, this.syncCompletionListener(), getApplicationContext() );
|
|
|
+ this.executingTask = this.clientTask;
|
|
|
+ this.clientTask.execute();
|
|
|
}
|
|
|
|
|
|
/**
|