|
@@ -208,81 +208,49 @@ public class ServicesListAdapter extends ArrayAdapter<ServicesListItem> {
|
|
* @param holder ViewHolder which represents the item in the View
|
|
* @param holder ViewHolder which represents the item in the View
|
|
*/
|
|
*/
|
|
private void updateStatus(ServicesListItem item, ViewHolder holder) {
|
|
private void updateStatus(ServicesListItem item, ViewHolder holder) {
|
|
- if(item.protocol.equals("GHOST")){
|
|
|
|
- mProfile = ProfileManager.getInstance().getCurrentActivatedProfile();
|
|
|
|
- mGhostPorts = mProfile.getGhostPorts();
|
|
|
|
|
|
+ boolean serviceIsActive = false;
|
|
|
|
+ // determine if service is active
|
|
|
|
+ if(item.protocol.equals("GHOST")) {
|
|
|
|
+ mProfile = ProfileManager.getInstance().getCurrentActivatedProfile();
|
|
|
|
+ mGhostPorts = mProfile.getGhostPorts();
|
|
|
|
+
|
|
|
|
+ for (Integer port : mGhostPorts) {
|
|
|
|
+ if (port != null && MainActivity.getInstance().getHostageService()
|
|
|
|
+ .isRunning("GHOST", port)) {
|
|
|
|
+ serviceIsActive = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if (MainActivity.getInstance().getHostageService().isRunning(item.protocol)) {
|
|
|
|
+ serviceIsActive = true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (serviceIsActive){
|
|
|
|
+ if(!holder.activated.isChecked()) {
|
|
|
|
+ holder.activated.setChecked(true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (item.attacks == 0) {
|
|
|
|
+ setBackground(holder, R.drawable.services_circle_green);
|
|
|
|
+ } else { // attacks > 0 (will never be negative)
|
|
|
|
+ if (MainActivity.getInstance().getHostageService().hasProtocolActiveAttacks(item.protocol)) {
|
|
|
|
+ setBackground(holder, R.drawable.services_circle_red);
|
|
|
|
+ } else {
|
|
|
|
+ setBackground(holder, R.drawable.services_circle_yellow);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if(holder.activated.isChecked()) {
|
|
|
|
+ holder.activated.setChecked(false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (item.attacks > 0) {
|
|
|
|
+ setBackground(holder, R.drawable.services_circle_yellow);
|
|
|
|
+ } else {
|
|
|
|
+ setBackground(holder, R.drawable.services_circle);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- boolean ghostActive = false;
|
|
|
|
- if(mGhostPorts.length != 0) {
|
|
|
|
- for (Integer port : mGhostPorts) {
|
|
|
|
- if(port != null){
|
|
|
|
- if (MainActivity.getInstance().getHostageService().isRunning("GHOST", port)) {
|
|
|
|
- ghostActive = true;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if(ghostActive){
|
|
|
|
- if(!holder.activated.isChecked()) {
|
|
|
|
- holder.activated.setChecked(true);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!MainActivity.getInstance().getHostageService().hasProtocolActiveAttacks(item.protocol)) {
|
|
|
|
- if (item.attacks > 0) {
|
|
|
|
- setBackground(holder, R.drawable.services_circle_yellow);
|
|
|
|
- } else {
|
|
|
|
- setBackground(holder, R.drawable.services_circle_green);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- } else {
|
|
|
|
- if (MainActivity.getInstance().getHostageService().hasProtocolActiveAttacks(item.protocol)) {
|
|
|
|
- setBackground(holder, R.drawable.services_circle_red);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- } else if (item.attacks > 0) {
|
|
|
|
- if(holder.activated.isChecked()) {
|
|
|
|
- holder.activated.setChecked(false);
|
|
|
|
- }
|
|
|
|
- setBackground(holder, R.drawable.services_circle_yellow);
|
|
|
|
- } else {
|
|
|
|
- if(holder.activated.isChecked()) {
|
|
|
|
- holder.activated.setChecked(false);
|
|
|
|
- }
|
|
|
|
- setBackground(holder, R.drawable.services_circle);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- else if (MainActivity.getInstance().getHostageService().isRunning(item.protocol)) {
|
|
|
|
- if(!holder.activated.isChecked()) {
|
|
|
|
- holder.activated.setChecked(true);
|
|
|
|
- }
|
|
|
|
- if (!MainActivity.getInstance().getHostageService().hasProtocolActiveAttacks(item.protocol)) {
|
|
|
|
- if (item.attacks > 0) {
|
|
|
|
- setBackground(holder, R.drawable.services_circle_yellow);
|
|
|
|
- } else {
|
|
|
|
- setBackground(holder, R.drawable.services_circle_green);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- } else {
|
|
|
|
- if (MainActivity.getInstance().getHostageService().hasProtocolActiveAttacks(item.protocol)) {
|
|
|
|
- setBackground(holder, R.drawable.services_circle_red);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else if (item.attacks > 0) {
|
|
|
|
- if(holder.activated.isChecked()) {
|
|
|
|
- holder.activated.setChecked(false);
|
|
|
|
- }
|
|
|
|
- setBackground(holder, R.drawable.services_circle_yellow);
|
|
|
|
- } else {
|
|
|
|
- if(holder.activated.isChecked()) {
|
|
|
|
- holder.activated.setChecked(false);
|
|
|
|
- }
|
|
|
|
- setBackground(holder, R.drawable.services_circle);
|
|
|
|
- }
|
|
|
|
holder.recordedAttacks
|
|
holder.recordedAttacks
|
|
.setText(String.format(MainActivity.getContext().getResources().getString(R.string.recorded_attacks) + " %d", Integer.valueOf(item.attacks)));
|
|
.setText(String.format(MainActivity.getContext().getResources().getString(R.string.recorded_attacks) + " %d", Integer.valueOf(item.attacks)));
|
|
}
|
|
}
|