Listener for monetary mask and call method

0

I have a class to apply the money mask, I apply this class in the editText listener.

Being this a discount field I need him to do two things 1 - show the value formatted in our currency ex R $ 21,36 (this is Ok) 2 - need to call a method to calculate the total that is nothing more than the value (unitario * quantity) - discount

Is it possible to have more than one listener?

 edtDesconto.addTextChangedListener(new MaskMonetaria(edtDesconto));

Let's use the MaskMonetaria class that is doing its paper correctly, and we will use the Fuzzy of the target that is when the user leaves the discount field the calculation of the total will be called this way we have what we want and it works! yes, everything works the most has a though, which is the reason of my question

How are you today?

  edtDesconto.addTextChangedListener(
            new MaskMonetaria(edtDesconto)
            );

    edtTotal.addTextChangedListener(
            new MaskMonetaria(edtTotal)
            );

    edtDesconto.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            EditText et = (EditText)v;

            if (hasFocus){
                // Fazer Nada
                Log.i(TAG, "onFocusChange" + "Tem Foco");
            } else {
                Log.i(TAG, "onFocusChange" + "Sem Foco");
                calculaTotais();
            }
        }
    });

Now the fields on the screen

- Produto
- valor unitário(desabilitado)
- quantidade
- desconto
- total(desabilitado) 

- Botão Gravar 

We noticed here that there is no change in focus between the Discount and the Save button because among them Total is disabled, the action of saving the data ends the activity so that the user does not even see the Total Value

As I can not get the listener class to have the formatting class and the method that calculates the totals at the same time I came looking for some answer because I believe that my intent should be very common.

    
asked by anonymous 25.05.2017 / 04:26

0 answers