35.8 Adding the Conversion Method
When the Convert button is clicked, it is going to call a method on the ViewModel to perform the conversion calculation and place the euro value in the result LiveData variable. Add this method now within the MainViewModel.java file:
.
.
public class MainViewModel extends ViewModel {
private static final Float usd_to_eu_rate = 0.74F;
public MutableLiveData<String> dollarValue = new MutableLiveData<>();
public MutableLiveData<Float> result = new MutableLiveData<>();
public void convertValue() {
if ((dollarValue.getValue() != null) &&
(!dollarValue.getValue().equals(""...