Will the onChanged
method be called if we dont change the state of the activity or restart the activity? ( Even if the data changes ) . If it doesnt happen how shall i make it happen ?
onCreate() {
viewModel.getHolidaysDatesFromServer(..).observe(.....this,new Observer<GetHolidaysDatesFromServer>) {
onChanged(GetHolidaysDatesFromServer GetHolidaysDatesFromServer)
}
}
and my ViewModel class ...
public class CalendarLifeCycleOwner extends AndroidViewModel {
Context context;
MutableLiveData<GetHolidaysDatesFromServer> MutableLiveDataGetHolidays=new MutableLiveData<>();
public CalendarLifeCycleOwner(@NonNull Application application) {
super(application);
this.context=application.getApplicationContext();
}
public MutableLiveData<GetHolidaysDatesFromServer> getHolidaysDatesFromServer(String upd_token,int product_id) {
JustProductId justProductId=new JustProductId();
justProductId.setProduct_id(product_id);
UserListInterface userListInterface= UserListService.createService(UserListInterface.class, Utility.ACCEPT_HEADER_V4);
Call<GetHolidaysDatesFromServer> getHolidaysDatesFromServerCall=userListInterface.GetProductHolidays(upd_token,justProductId);
getHolidaysDatesFromServerCall.enqueue(new Callback<GetHolidaysDatesFromServer>() {
@Override
public void onResponse(Call<GetHolidaysDatesFromServer> call, Response<GetHolidaysDatesFromServer> response) {
if (response.isSuccessful()) {
GetHolidaysDatesFromServer getHolidaysDatesFromServer=response.body();
MutableLiveDataGetHolidays.postValue(getHolidaysDatesFromServer);
}
}
@Override
public void onFailure(Call<GetHolidaysDatesFromServer> call, Throwable t) {
ErrorObject errorObject=new ErrorObject(t);
GetHolidaysDatesFromServer getHolidaysDatesFromServer=new GetHolidaysDatesFromServer();
getHolidaysDatesFromServer.setErrorObject(errorObject);
MutableLiveDataGetHolidays.setValue(getHolidaysDatesFromServer);
}
});
return MutableLiveDataGetHolidays;
}
}
But after i just change the data onChanged()
is not getting called ...