@Override
 public boolean onOptionsItemSelected(MenuItem item) {
   if (menuEnabled && menuResetItem != null && menuResetItem.getTitle().equals(item.getTitle())) {
     connection.reset();
     return true; // connection only needs to reset once
   }
   return super.onOptionsItemSelected(item);
 }
 @Override
 public String getRecreationKey() {
   return fixRecreationKey(
       SPINNER_FRAGMENT
           + SEP
           + pos.getRecreationKey()
           + SEP
           + ip
           + SEP
           + connection.getType().toString()
           + SEP
           + menu
           + SEP);
 }
 @Override
 public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
   if (command == null) {
     // Spinner not configured to control a device
     return;
   }
   TcpInformation information = connection.getBufferedInformation(responseClassifier);
   if (information != null) {
     spinner.setSelection(
         adapter.getPosition(
             information
                 .getStringValue())); // jump back to previous position so no wrong information is
                                      // displayed
   }
   if (spinnerActive) {
     if (information == null
         || !information.isStringAvailable()
         || !information.getStringValue().equals(spinnerItemNames[pos])) {
       connection.sendRawCommand(Util.createCommandChain(command, spinnerItemValues[pos]));
     }
   } else {
     spinnerActive = true;
   }
 }
 @Override
 public void onPrepareOptionsMenu(Menu menu) {
   if (menuEnabled && !connection.isConnected()) {
     String menuResetEntry = getString(R.string.action_reconnect_receiver, ip);
     boolean first = true;
     for (int i = 0; i < menu.size(); i++) {
       if (menu.getItem(i).getTitle().equals(menuResetEntry)) {
         first = false;
       }
     }
     if (first) {
       menuResetItem = menu.add(Menu.NONE, Menu.NONE, MENU_ORDER, menuResetEntry);
     }
   }
   super.onPrepareOptionsMenu(menu);
 }
 private void setSpinnerContent() {
   ArrayList<String> list = new ArrayList<>();
   spinnerItemNames =
       TcpConnectionManager.getCommandNameArray(getResources(), connection, menu, false);
   spinnerItemValues = TcpConnectionManager.getCommandValueArray(getResources(), connection, menu);
   list.addAll(Arrays.asList(spinnerItemNames));
   if (Util.SCREENSHOT) {
     if (list.isEmpty()) {
       spinnerItemValues = new String[] {""};
     } else {
       list.remove(0);
     }
     list.add(0, getString(R.string.fragment_spinner));
   }
   adapter =
       new ArrayAdapter<>(getActivity(), R.layout.support_simple_spinner_dropdown_item, list);
   spinner.setAdapter(adapter);
   updateUI(connection.getBufferedInformation(responseClassifier));
 }
 @Override
 public boolean isConnected() {
   return connection.isConnected();
 }