private void displayButtons() { boolean ButtonsPresentFlag = false; LinearLayout layout = (LinearLayout) findViewById(R.id.activeCodesButtonLayout); if (buttonList != null) { String codeString = getCodeString(ACTIVE_CODES_SET); if (codeString != null) { // displayLog("Code String not null"); GetLocationFromServer getLocationFromServer = new GetLocationFromServer(); getLocationFromServer.getLocation(codeString); for (ButtonObjectForReceive buttonObject : buttonList) { displayLog("iterating button list"); buttonObject.getButton().setVisibility(View.GONE); long remainingTime = buttonObject.getUnixStartTime() + buttonObject.getDuration() - getUnixTime(); if (buttonObject.getStatus() == 1) { if (remainingTime > 0) { displayLog("updating location for" + buttonObject.getButton().getText()); layout.setVisibility(View.VISIBLE); ButtonsPresentFlag = true; buttonObject.getButton().setVisibility(View.VISIBLE); String name = buttonObject.getName(); buttonObject.getButton().setText(name); double lat = buttonObject.getLatitude(); double lng = buttonObject.getLongitude(); double previousLat = buttonObject.getPreviousLatitude(); double previousLng = buttonObject.getPreviousLongitude(); // displayLog("Setting new marker for " + buttonObject.getButton().getText() + " at: // " + String.valueOf(lat) + " , " + String.valueOf(lng)); String title; displayLog("Gonna start showing marker"); if (buttonObject.getStopFlag() == 1) { displayLog("Inside if"); // Change the marker status to inactive to notify the user. if (buttonObject.isIdleToActive()) { buttonObject.setIdleToActiveFlag(false); if (buttonObject.getMarker() != null) { buttonObject.getMarker().setTitle(buttonObject.getName() + ": Inactive"); buttonObject.getMarker().showInfoWindow(); } } title = buttonObject.getName() + ": Inactive"; buttonObject.getButton().setBackgroundResource(R.drawable.user_button_white); buttonObject.getButton().setTextColor(0xFFCCCCCC); } else { displayLog("Inside else"); // User is active if (buttonObject.isIdleToActive()) { buttonObject.setIdleToActiveFlag(false); if (buttonObject.getMarker() != null) { buttonObject.getMarker().setTitle(buttonObject.getName() + ": Active"); buttonObject.getMarker().showInfoWindow(); } } title = buttonObject.getName() + ": Active"; buttonObject.getButton().setBackgroundResource(R.drawable.user_button_white); buttonObject.getButton().setTextColor(0xFF428f89); } buttonObject.setMarker(setMarker(buttonObject.getMarker(), lat, lng, title)); if (buttonObject.getFocusCount() == FOCUS_COUNT) { gotoLocation(lat, lng, mMap.getCameraPosition().zoom); if (buttonObject.getStopFlag() != 1) { buttonObject.getButton().setBackgroundResource(R.drawable.user_button); buttonObject.getButton().setTextColor(0xFF428f89); } } if (previousLat != 0) { drawLine(previousLat, previousLng, lat, lng, 0xff64B5F6, 20); drawLine(previousLat, previousLng, lat, lng, 0xff2196F3, 10); } } else if (((getUnixTime() - buttonObject.getUnixStartTime()) / (3600)) >= 24) { displayToast("Removing expired dead code " + buttonObject.getCode()); displayLog("Removing dead code after 24 hours"); removeCode(buttonObject.getCode()); } else { removeMarker(buttonObject.getMarker()); } } } } } if (ButtonsPresentFlag == false) { layout.setVisibility(View.GONE); } }