|
@@ -105,19 +105,22 @@ public class ServicesListAdapter extends ArrayAdapter<ServicesListItem> {
|
|
ServicesListItem item = (ServicesListItem) buttonView.getTag();
|
|
ServicesListItem item = (ServicesListItem) buttonView.getTag();
|
|
mProfile = ProfileManager.getInstance().getCurrentActivatedProfile();
|
|
mProfile = ProfileManager.getInstance().getCurrentActivatedProfile();
|
|
if (!HelperUtils.isNetworkAvailable(mActivity)) {
|
|
if (!HelperUtils.isNetworkAvailable(mActivity)) {
|
|
- new AlertDialog.Builder(mActivity)
|
|
|
|
- .setTitle(R.string.information)
|
|
|
|
- .setMessage(R.string.wifi_not_connected_msg)
|
|
|
|
- .setPositiveButton(android.R.string.ok,
|
|
|
|
- new DialogInterface.OnClickListener() {
|
|
|
|
- public void onClick(DialogInterface dialog,
|
|
|
|
- int which) {
|
|
|
|
|
|
+ if(!MainActivity.getInstance().getHostageService().hasRunningListeners()) {
|
|
|
|
+ new AlertDialog.Builder(mActivity)
|
|
|
|
+ .setTitle(R.string.information)
|
|
|
|
+ .setMessage(R.string.wifi_not_connected_msg)
|
|
|
|
+ .setPositiveButton(android.R.string.ok,
|
|
|
|
+ new DialogInterface.OnClickListener() {
|
|
|
|
+ public void onClick(DialogInterface dialog,
|
|
|
|
+ int which) {
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- )
|
|
|
|
- .setIcon(android.R.drawable.ic_dialog_info).show();
|
|
|
|
-
|
|
|
|
- buttonView.setChecked(false);
|
|
|
|
|
|
+ )
|
|
|
|
+ .setIcon(android.R.drawable.ic_dialog_info).show();
|
|
|
|
+ if (buttonView.isChecked()) {
|
|
|
|
+ buttonView.setChecked(false);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
//check if switch is set to ON and start the concrete listener for the protocol
|
|
//check if switch is set to ON and start the concrete listener for the protocol
|
|
if (isChecked) {
|
|
if (isChecked) {
|
|
@@ -136,11 +139,15 @@ public class ServicesListAdapter extends ArrayAdapter<ServicesListItem> {
|
|
mServicesSwitch.setChecked(true);
|
|
mServicesSwitch.setChecked(true);
|
|
mServicesSwitch.setOnCheckedChangeListener(mListener);
|
|
mServicesSwitch.setOnCheckedChangeListener(mListener);
|
|
|
|
|
|
- buttonView.setChecked(true);
|
|
|
|
|
|
+ if(!buttonView.isChecked()) {
|
|
|
|
+ buttonView.setChecked(true);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- buttonView.setChecked(false);
|
|
|
|
|
|
+ if(buttonView.isChecked()) {
|
|
|
|
+ buttonView.setChecked(false);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (!MainActivity.getInstance().getHostageService().isRunning(item.protocol)) {
|
|
else if (!MainActivity.getInstance().getHostageService().isRunning(item.protocol)) {
|
|
@@ -150,9 +157,13 @@ public class ServicesListAdapter extends ArrayAdapter<ServicesListItem> {
|
|
mServicesSwitch.setOnCheckedChangeListener(null);
|
|
mServicesSwitch.setOnCheckedChangeListener(null);
|
|
mServicesSwitch.setChecked(true);
|
|
mServicesSwitch.setChecked(true);
|
|
mServicesSwitch.setOnCheckedChangeListener(mListener);
|
|
mServicesSwitch.setOnCheckedChangeListener(mListener);
|
|
- buttonView.setChecked(true);
|
|
|
|
|
|
+ if(!buttonView.isChecked()) {
|
|
|
|
+ buttonView.setChecked(true);
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
- buttonView.setChecked(true);
|
|
|
|
|
|
+ if(!buttonView.isChecked()) {
|
|
|
|
+ buttonView.setChecked(true);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
if(item.protocol.equals("GHOST")) {
|
|
if(item.protocol.equals("GHOST")) {
|
|
@@ -164,12 +175,16 @@ public class ServicesListAdapter extends ArrayAdapter<ServicesListItem> {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- buttonView.setChecked(false);
|
|
|
|
|
|
+ if(buttonView.isChecked()) {
|
|
|
|
+ buttonView.setChecked(false);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
else if (MainActivity.getInstance().getHostageService().isRunning(item.protocol)) {
|
|
else if (MainActivity.getInstance().getHostageService().isRunning(item.protocol)) {
|
|
MainActivity.getInstance().getHostageService().stopListener(item.protocol);
|
|
MainActivity.getInstance().getHostageService().stopListener(item.protocol);
|
|
}
|
|
}
|
|
- buttonView.setChecked(false);
|
|
|
|
|
|
+ if(buttonView.isChecked()) {
|
|
|
|
+ buttonView.setChecked(false);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -200,7 +215,9 @@ public class ServicesListAdapter extends ArrayAdapter<ServicesListItem> {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(ghostActive){
|
|
if(ghostActive){
|
|
- holder.activated.setChecked(true);
|
|
|
|
|
|
+ if(!holder.activated.isChecked()) {
|
|
|
|
+ holder.activated.setChecked(true);
|
|
|
|
+ }
|
|
|
|
|
|
if (!MainActivity.getInstance().getHostageService().hasProtocolActiveAttacks(item.protocol)) {
|
|
if (!MainActivity.getInstance().getHostageService().hasProtocolActiveAttacks(item.protocol)) {
|
|
if (item.attacks > 0) {
|
|
if (item.attacks > 0) {
|
|
@@ -216,10 +233,14 @@ public class ServicesListAdapter extends ArrayAdapter<ServicesListItem> {
|
|
}
|
|
}
|
|
|
|
|
|
} else if (item.attacks > 0) {
|
|
} else if (item.attacks > 0) {
|
|
- holder.activated.setChecked(false);
|
|
|
|
|
|
+ if(holder.activated.isChecked()) {
|
|
|
|
+ holder.activated.setChecked(false);
|
|
|
|
+ }
|
|
setBackground(holder, R.drawable.services_circle_yellow);
|
|
setBackground(holder, R.drawable.services_circle_yellow);
|
|
} else {
|
|
} else {
|
|
- holder.activated.setChecked(false);
|
|
|
|
|
|
+ if(holder.activated.isChecked()) {
|
|
|
|
+ holder.activated.setChecked(false);
|
|
|
|
+ }
|
|
setBackground(holder, R.drawable.services_circle);
|
|
setBackground(holder, R.drawable.services_circle);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -228,7 +249,9 @@ public class ServicesListAdapter extends ArrayAdapter<ServicesListItem> {
|
|
|
|
|
|
}
|
|
}
|
|
else if (MainActivity.getInstance().getHostageService().isRunning(item.protocol)) {
|
|
else if (MainActivity.getInstance().getHostageService().isRunning(item.protocol)) {
|
|
- holder.activated.setChecked(true);
|
|
|
|
|
|
+ if(!holder.activated.isChecked()) {
|
|
|
|
+ holder.activated.setChecked(true);
|
|
|
|
+ }
|
|
if (!MainActivity.getInstance().getHostageService().hasProtocolActiveAttacks(item.protocol)) {
|
|
if (!MainActivity.getInstance().getHostageService().hasProtocolActiveAttacks(item.protocol)) {
|
|
if (item.attacks > 0) {
|
|
if (item.attacks > 0) {
|
|
setBackground(holder, R.drawable.services_circle_yellow);
|
|
setBackground(holder, R.drawable.services_circle_yellow);
|
|
@@ -242,10 +265,14 @@ public class ServicesListAdapter extends ArrayAdapter<ServicesListItem> {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else if (item.attacks > 0) {
|
|
} else if (item.attacks > 0) {
|
|
- holder.activated.setChecked(false);
|
|
|
|
|
|
+ if(holder.activated.isChecked()) {
|
|
|
|
+ holder.activated.setChecked(false);
|
|
|
|
+ }
|
|
setBackground(holder, R.drawable.services_circle_yellow);
|
|
setBackground(holder, R.drawable.services_circle_yellow);
|
|
} else {
|
|
} else {
|
|
- holder.activated.setChecked(false);
|
|
|
|
|
|
+ if(holder.activated.isChecked()) {
|
|
|
|
+ holder.activated.setChecked(false);
|
|
|
|
+ }
|
|
setBackground(holder, R.drawable.services_circle);
|
|
setBackground(holder, R.drawable.services_circle);
|
|
}
|
|
}
|
|
holder.recordedAttacks
|
|
holder.recordedAttacks
|