Open guilmarc opened 6 years ago
Here, when the mUserLiveData is fetched, UI is not updated
public void fetchProfile(@NonNull int userId ) { setIsLoading(true); getCompositeDisposable().add(getDataManager() .getUserApiCall( userId ) .subscribeOn(getSchedulerProvider().io()) .observeOn(getSchedulerProvider().ui()) .subscribe(response -> { if (response != null) { mUserLiveData.setValue( response ); } setIsLoading(false); }, throwable -> { setIsLoading(false); getNavigator().handleError(throwable); })); } public String getFirstName() { return mUserLiveData.getValue().getFirstName(); } public String getLastName() { return mUserLiveData.getValue().getLastName(); }
UI
<android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentEnd="true" android:layout_alignTop="@+id/profile_thumbnail_circleimageview" android:layout_toEndOf="@+id/profile_thumbnail_circleimageview"> <android.support.design.widget.TextInputEditText android:id="@+id/profile_firstname_edittext" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/translate_firstname" android:inputType="textCapSentences|textPersonName" android:text="@={viewModel.firstName}"/> </android.support.design.widget.TextInputLayout> <!-- Name Label --> <android.support.design.widget.TextInputLayout android:id="@+id/textInputLayout2" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignBottom="@+id/profile_thumbnail_circleimageview" android:layout_toEndOf="@+id/profile_thumbnail_circleimageview"> <android.support.design.widget.TextInputEditText android:id="@+id/profile_lastname_edittext" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/translate_lastname" android:inputType="textCapSentences|textPersonName" android:text="@={viewModel.lastName}"/> </android.support.design.widget.TextInputLayout>
Here, when the mUserLiveData is fetched, UI is not updated
UI