public void setRole() {
    Employee e = getTestEmployee();
    if (e == null) {
      return;
    }
    final String role = roleSpinner.getSelectedItem().toString();
    e.setRole(getRoleFromString(role));
    employeeConnector.updateEmployee(
        e,
        new EmployeeConnector.EmployeeCallback<Employee>() {
          @Override
          public void onServiceSuccess(Employee result, ResultStatus status) {
            if (status.getStatusCode() / 100 == 2) {
              toast("Successfully set the test employee role to '" + role + "'.");
            } else {
              toast("Unable to set the test employee role: " + status.getStatusMessage());
            }
          }

          @Override
          public void onServiceFailure(ResultStatus status) {
            toast("Unable to set the test employee role: " + status.getStatusMessage());
          }
        });
  }
  public void setPin() {
    Employee e = getTestEmployee();
    if (e == null) {
      return;
    }
    final String pin = pinEditText.getText().toString().trim();
    e.setPin(pin);
    employeeConnector.updateEmployee(
        e,
        new EmployeeConnector.EmployeeCallback<Employee>() {
          @Override
          public void onServiceSuccess(Employee result, ResultStatus status) {
            if (status.getStatusCode() / 100 == 2) {
              toast("Successfully set the test employee pin to '" + pin + "'.");
            } else {
              toast("Unable to set the test employee pin: " + status.getStatusMessage());
            }
          }

          @Override
          public void onServiceFailure(ResultStatus status) {
            toast("Unable to set the test employee pin: " + status.getStatusMessage());
          }
        });
  }
  private void createTestEmployee() {
    Employee employee = null;
    employee = new Employee();
    employee.setName(TEST_EMPLOYEE_NAME);
    employee.setNickname("Tester");
    employee.setCustomId("test123");
    employee.setEmail("*****@*****.**");
    employee.setPin("123456");
    employee.setRole(AccountRole.EMPLOYEE);
    employeeConnector.createEmployee(
        employee,
        new EmployeeConnector.EmployeeCallback<Employee>() {
          @Override
          public void onServiceSuccess(Employee result, ResultStatus status) {
            if (status.getStatusCode() / 100 != 2) {
              toast("Unable to create employee: " + status.getStatusMessage());
              return;
            }
            toast("Successfully created test employee.");
          }

          @Override
          public void onServiceFailure(ResultStatus status) {
            toast("Unable to create test employee: " + status.getStatusMessage());
          }
        });
  }
 private void disconnect() {
   if (employeeConnector != null) {
     employeeConnector.disconnect();
     employeeConnector = null;
   }
   if (merchantConnector != null) {
     merchantConnector.disconnect();
     merchantConnector = null;
   }
 }
 private void connect() {
   disconnect();
   if (account != null) {
     employeeConnector = new EmployeeConnector(this, account, this);
     employeeConnector.connect();
     merchantConnector = new MerchantConnector(this, account, this);
     merchantConnector.setOnMerchantChangedListener(merchantListener);
     merchantConnector.connect();
   }
 }
 @Override
 public void onReceive(Context context, Intent intent) {
   String employeeId = intent.getStringExtra(Intents.EXTRA_EMPLOYEE_ID);
   account = EmployeeIntent.getAccount(intent);
   connect();
   employeeConnector.getEmployee(
       employeeId,
       new EmployeeConnector.EmployeeCallback<Employee>() {
         @Override
         public void onServiceSuccess(Employee result, ResultStatus status) {
           notifyActiveEmployeeChanged(result);
         }
       });
 }
  private void getActiveEmployee() {
    employeeConnector.getEmployee(
        new EmployeeConnector.EmployeeCallback<Employee>() {
          @Override
          public void onServiceSuccess(Employee result, ResultStatus status) {
            super.onServiceSuccess(result, status);
            updateActiveEmployee("get active employee success", status, result);
          }

          @Override
          public void onServiceFailure(ResultStatus status) {
            super.onServiceFailure(status);
            updateActiveEmployee("get active employee failure", status, null);
          }

          @Override
          public void onServiceConnectionFailure() {
            super.onServiceConnectionFailure();
            updateActiveEmployee("get active employee failure", null, null);
          }
        });
  }
  private void logout() {
    employeeConnector.logout(
        new EmployeeConnector.EmployeeCallback<Void>() {
          @Override
          public void onServiceSuccess(Void result, ResultStatus status) {
            super.onServiceSuccess(result, status);
            updateLogout("logout success", status);
          }

          @Override
          public void onServiceFailure(ResultStatus status) {
            super.onServiceFailure(status);
            updateLogout("logout failed", status);
          }

          @Override
          public void onServiceConnectionFailure() {
            super.onServiceConnectionFailure();
            updateLogout("logout failed", null);
          }
        });
  }
  private void getEmployees() {
    employeeConnector.getEmployees(
        new EmployeeConnector.EmployeeCallback<List<Employee>>() {
          @Override
          public void onServiceSuccess(List<Employee> result, ResultStatus status) {
            super.onServiceSuccess(result, status);
            employees = result;
            updateEmployees("get employees success", status, result);
          }

          @Override
          public void onServiceFailure(ResultStatus status) {
            super.onServiceFailure(status);
            updateEmployees("get employees failure", status, null);
          }

          @Override
          public void onServiceConnectionFailure() {
            super.onServiceConnectionFailure();
            updateEmployees("get employees failure", null, null);
          }
        });
  }
  private void deleteTestEmployee() {
    Employee e = getTestEmployee();
    if (e == null) {
      return;
    }
    employeeConnector.deleteEmployee(
        e.getId(),
        new EmployeeConnector.EmployeeCallback<Void>() {
          @Override
          public void onServiceSuccess(Void result, ResultStatus status) {
            if (status.getStatusCode() / 100 != 2) {
              toast("Unable to delete test employee: " + status.getStatusMessage());
            } else {
              toast("Successfully deleted test employee.");
            }
          }

          @Override
          public void onServiceFailure(ResultStatus status) {
            toast("Unable to delete test employee: " + status.getStatusMessage());
          }
        });
  }