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);
   }
 }