Reputation: 138
I have a ToggleButton which calls my function and function calls service in it:
@CheckedChange(R.id.tbValetMode)
protected void toggleValetMode(boolean isChecked) {
mPresenter.sendValetModeState(isChecked);
}
I activate the button and change the fragment, and when I return to the same fragment, the button looks deactivated. However, I called the service once in the background.
So when I press the button again, I get an error by the service.
I wrote a method to check the latest status of Vale Mode. This method returns data from the GET service.
public void checkValetMode(Boolean result) {
tbValetMode.setChecked(result);
}
But the setChecked () method calls the button as if it was pressed again, and when I change the fragment and come back, the button appears to be open but I get an error because it calls the service again.
Expectation: To display the Toggle Button according to the response of the method returned by the GET Service, even if the fragment changes.
Upvotes: 0
Views: 185