private void updateUi(Receiver receiver) {
   if (receiver == null) {
     layoutMasterSlave.setVisibility(View.GONE);
     layoutDip.setVisibility(View.GONE);
     layoutAutoPair.setVisibility(View.GONE);
     layoutUniversal.setVisibility(View.GONE);
   } else if (Receiver.TYPE_AUTOPAIR.equals(receiver.getType())) {
     layoutMasterSlave.setVisibility(View.GONE);
     layoutDip.setVisibility(View.GONE);
     layoutAutoPair.setVisibility(View.VISIBLE);
     layoutUniversal.setVisibility(View.GONE);
   } else if (Receiver.TYPE_DIPS.equals(receiver.getType())) {
     layoutMasterSlave.setVisibility(View.GONE);
     layoutDip.setVisibility(View.VISIBLE);
     layoutAutoPair.setVisibility(View.GONE);
     layoutUniversal.setVisibility(View.GONE);
   } else if (Receiver.TYPE_MASTER_SLAVE.equals(receiver.getType())) {
     layoutMasterSlave.setVisibility(View.VISIBLE);
     layoutDip.setVisibility(View.GONE);
     layoutAutoPair.setVisibility(View.GONE);
     layoutUniversal.setVisibility(View.GONE);
   } else if (Receiver.TYPE_UNIVERSAL.equals(receiver.getType())) {
     layoutMasterSlave.setVisibility(View.GONE);
     layoutDip.setVisibility(View.GONE);
     layoutAutoPair.setVisibility(View.GONE);
     layoutUniversal.setVisibility(View.VISIBLE);
   }
 }
 private void initType(Receiver receiver) {
   if (Receiver.TYPE_AUTOPAIR.equals(receiver.getType())) {
     currentAutoPairReceiver = receiver;
     updateUi(receiver);
   } else if (Receiver.TYPE_DIPS.equals(receiver.getType())) {
     updateUi(receiver);
     initData((DipReceiver) receiver);
   } else if (Receiver.TYPE_MASTER_SLAVE.equals(receiver.getType())) {
     updateUi(receiver);
     initData((MasterSlaveReceiver) receiver);
   } else if (Receiver.TYPE_UNIVERSAL.equals(receiver.getType())) {
     updateUi(receiver);
     initData((UniversalReceiver) receiver);
   }
 }
public class RC3500_A_IP44_DE extends Receiver implements DipReceiver {

  static String BRAND = Receiver.BRAND_BAT;
  static String MODEL = Receiver.getModelName(RC3500_A_IP44_DE.class.getCanonicalName());

  LinkedList<DipSwitch> dipList;
  private String tx433version = "1,";

  private String sSpeedConnAir = "14";
  private String headConnAir = "TXP:0,0,10,5600,350,25,";
  private String tailConnAir = tx433version + sSpeedConnAir + ";";

  private String sSpeedITGW = "125,";
  private String headITGW = "0,0,10,11200,350,26,0,";
  private String tailITGW = tx433version + sSpeedITGW + "0";

  public RC3500_A_IP44_DE(
      Context context, Long id, String name, LinkedList<Boolean> dips, Long roomId) {
    super(context, id, name, BRAND, MODEL, TYPE_DIPS, roomId);
    dipList = new LinkedList<>();

    if (dips != null && dips.size() == 10) {
      dipList.add(new DipSwitch("1", dips.get(0)));
      dipList.add(new DipSwitch("2", dips.get(1)));
      dipList.add(new DipSwitch("3", dips.get(2)));
      dipList.add(new DipSwitch("4", dips.get(3)));
      dipList.add(new DipSwitch("5", dips.get(4)));
      dipList.add(new DipSwitch("A", dips.get(5)));
      dipList.add(new DipSwitch("B", dips.get(6)));
      dipList.add(new DipSwitch("C", dips.get(7)));
      dipList.add(new DipSwitch("D", dips.get(8)));
      dipList.add(new DipSwitch("E", dips.get(9)));
    } else {
      dipList.add(new DipSwitch("1", false));
      dipList.add(new DipSwitch("2", false));
      dipList.add(new DipSwitch("3", false));
      dipList.add(new DipSwitch("4", false));
      dipList.add(new DipSwitch("5", false));
      dipList.add(new DipSwitch("A", false));
      dipList.add(new DipSwitch("B", false));
      dipList.add(new DipSwitch("C", false));
      dipList.add(new DipSwitch("D", false));
      dipList.add(new DipSwitch("E", false));
    }

    buttons.add(new Button(Button.BUTTON_ON_ID, context.getString(R.string.on), id));
    buttons.add(new Button(Button.BUTTON_OFF_ID, context.getString(R.string.off), id));
  }

  public List<String> getDipNames() {
    List<String> d = new LinkedList<>();
    for (DipSwitch dipSwitch : dipList) {
      d.add(dipSwitch.getName());
    }
    return d;
  }

  @Override
  protected String getSignal(Gateway gateway, String action)
      throws GatewayNotSupportedException, ActionNotSupportedException {
    boolean actionSupported = false;
    for (Button button : buttons) {
      if (button.getName().equals(action)) {
        actionSupported = true;
        break;
      }
    }
    if (!actionSupported) {
      throw new ActionNotSupportedException();
    }

    String seq = "";
    String lo = "1,";
    String hi = "3,";

    // segments of four
    String seqLo = lo + hi + lo + hi; // low
    @SuppressWarnings("unused")
    String seqHi = hi + lo + hi + lo; // high (never used)
    String seqFl = lo + hi + hi + lo; // floating

    String on = seqLo + seqFl;
    String off = seqFl + seqLo;

    for (DipSwitch dip : dipList) {
      if (dip.isChecked()) {
        seq += seqLo;
      } else {
        seq += seqFl;
      }
    }

    if (gateway.getClass() == ConnAir.class) {
      if (action.equals(context.getString(R.string.on))) {
        String ON = headConnAir + seq + on + tailConnAir;
        return ON;
      } else {
        String OFF = headConnAir + seq + off + tailConnAir;
        return OFF;
      }
    } else if (gateway.getClass() == BrematicGWY433.class) {
      if (action.equals(context.getString(R.string.on))) {
        String ON = headConnAir + seq + on + tailConnAir;
        return ON;
      } else {
        String OFF = headConnAir + seq + off + tailConnAir;
        return OFF;
      }
    } else if (gateway.getClass() == ITGW433.class) {
      if (action.equals(context.getString(R.string.on))) {
        String ON = headITGW + seq + on + tailITGW;
        return ON;
      } else {
        String OFF = headITGW + seq + off + tailITGW;
        return OFF;
      }
    } else {
      throw new GatewayNotSupportedException();
    }
  }

  @Override
  public LinkedList<DipSwitch> getDips() {
    return dipList;
  }
}