private void updateView() {
    sendConfirmButton.setEnabled(everythingValid());

    if (address == null) {
      setVisible(sendToAddressView);
      setGone(sendToStaticAddressView);
      setVisible(scanQrCodeButton);
      setGone(eraseAddressButton);

      if (actionMode != null) {
        actionMode.finish();
        actionMode = null;
      }
    } else {
      setGone(sendToAddressView);
      setVisible(sendToStaticAddressView);
      sendToStaticAddressView.setAddressAndLabel(address);
      setGone(scanQrCodeButton);
      setVisible(eraseAddressButton);
    }

    if (sendCoinAmountView.resetType(sendAmountType)) {
      amountCalculatorLink.setExchangeRate(getCurrentRate());
    }

    startOrStopMarketRatePolling();

    // enable actions
    scanQrCodeButton.setEnabled(state == State.INPUT);
    eraseAddressButton.setEnabled(state == State.INPUT);
  }
  public void reset() {
    // No-op if the view is not created
    if (getView() == null) return;

    clearAddress(true);
    hideTxMessage();
    sendToAddressView.setVisibility(View.VISIBLE);
    sendToStaticAddressView.setVisibility(View.GONE);
    amountCalculatorLink.setPrimaryAmount(null);
    sendAmount = null;
    state = State.INPUT;
    addressError.setVisibility(View.GONE);
    amountError.setVisibility(View.GONE);
    amountWarning.setVisibility(View.GONE);
    updateView();
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_send, container, false);

    sendToAddressView = (AutoCompleteTextView) view.findViewById(R.id.send_to_address);
    sendToAddressViewAdapter = new ReceivingAddressViewAdapter(application);
    sendToAddressView.setAdapter(sendToAddressViewAdapter);
    sendToAddressView.setOnFocusChangeListener(receivingAddressListener);
    sendToAddressView.addTextChangedListener(receivingAddressListener);

    sendToStaticAddressView = (AddressView) view.findViewById(R.id.send_to_address_static);
    sendToStaticAddressView.setOnClickListener(addressOnClickListener);

    sendCoinAmountView = (AmountEditView) view.findViewById(R.id.send_coin_amount);
    sendCoinAmountView.resetType(sendAmountType);
    if (sendAmount != null) sendCoinAmountView.setAmount(sendAmount, false);

    AmountEditView sendLocalAmountView = (AmountEditView) view.findViewById(R.id.send_local_amount);
    sendLocalAmountView.setFormat(FiatType.FRIENDLY_FORMAT);

    amountCalculatorLink = new CurrencyCalculatorLink(sendCoinAmountView, sendLocalAmountView);
    amountCalculatorLink.setExchangeDirection(config.getLastExchangeDirection());
    amountCalculatorLink.setExchangeRate(getCurrentRate());

    addressError = (TextView) view.findViewById(R.id.address_error_message);
    addressError.setVisibility(View.GONE);
    amountError = (TextView) view.findViewById(R.id.amount_error_message);
    amountError.setVisibility(View.GONE);
    amountWarning = (TextView) view.findViewById(R.id.amount_warning_message);
    amountWarning.setVisibility(View.GONE);

    scanQrCodeButton = (ImageButton) view.findViewById(R.id.scan_qr_code);
    scanQrCodeButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            handleScan();
          }
        });

    eraseAddressButton = (ImageButton) view.findViewById(R.id.erase_address);
    eraseAddressButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            clearAddress(true);
            updateView();
          }
        });

    txMessageButton = (Button) view.findViewById(R.id.tx_message_add_remove);
    txMessageLabel = (TextView) view.findViewById(R.id.tx_message_label);
    txMessageView = (EditText) view.findViewById(R.id.tx_message);
    txMessageCounter = (TextView) view.findViewById(R.id.tx_message_counter);

    if (pocket != null && pocket.getCoinType().canHandleMessages()) {
      enableTxMessage(view);
    }

    sendConfirmButton = (Button) view.findViewById(R.id.send_confirm);
    sendConfirmButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            validateAddress();
            validateAmount();
            if (everythingValid()) handleSendConfirm();
            else requestFocusFirst();
          }
        });

    return view;
  }