我想在以后的活动中使用相同的MutableLiveData。
public class DocumentDetailViewModel extends BaseViewModel<DocumentDetailNavigator> {
private final MutableLiveData<DocumentDetail> documentDetailTicketsListLiveData;
private int docId;
public ObservableField<String> caseNumber;
public DocumentDetailViewModel(DataManager dataManager,
SchedulerProvider schedulerProvider) {
super(dataManager, schedulerProvider);
documentDetailTicketsListLiveData = new MutableLiveData<>();
fetchDocumentDetails();
}
public void fetchDocumentDetails() {
setIsLoading(true);
getCompositeDisposable().add(getDataManager()
.getDocumentDetailAppCall(docId)
.subscribeOn(getSchedulerProvider().io())
.observeOn(getSchedulerProvider().ui())
.subscribe(DocumentDetailResponse -> {
if (DocumentDetailResponse != null) {
documentDetailTicketsListLiveData.setValue(DocumentDetailResponse);
caseNumber = new ObservableField<>(DocumentDetailResponse.getDocuments().getCaseNumber());
}
setIsLoading(false);
}, throwable -> {
setIsLoading(false);
getNavigator().handleError(throwable);
}));
}
public LiveData<DocumentDetail> getDocumentDetailLiveData() {
return documentDetailTicketsListLiveData;
}
public void setDocId(int docId) {
this.docId = docId;
}
}
我想在其他活动中访问documentDetailTicketsListLiveData。