static LiveData<LogcatContent> creat (int id, LiveData<LogcatContent> rawData, String grep) { /** * ${rawData}变量是Source中的MediatorLiveData */ MediatorLiveData<LogcatContent> rawMediaData = (MediatorLiveData) rawData; if (grep.equals("")) { writeClearCache(id, GrepFilter.RAW_SIGNAL); rawMediaData.setValue(clearCache); return rawData; } rawMediaData.setValue(clearCache); return GrepFilter.grepData(rawData, grep); }
public Holder() { data = new MediatorLiveData<>(); data.addSource(rawData, str -> { data.setValue(str); }); transData.setValue(false); }
private DataRepository(final SearchHistoryDatabase database) { this.database = database; observableSearchHistory = new MediatorLiveData<>(); observableSearchHistory.addSource(database.searchHistoryDao().getAll(), new Observer<List<SearchHistoryEntity>>() { @Override public void onChanged(@Nullable List<SearchHistoryEntity> searchHistoryEntities) { if (database.getDatabaseCreated().getValue() != null) { observableSearchHistory.postValue(searchHistoryEntities); } } }); }
public ProductListViewModel(Application application) { super(application); mObservableProducts = new MediatorLiveData<>(); // set by default null, until we get data from the database. mObservableProducts.setValue(null); LiveData<List<ProductEntity>> products = ((BasicApp) application).getRepository() .getProducts(); // observe the changes of the products from the database and forward them mObservableProducts.addSource(products, mObservableProducts::setValue); }
private DataRepository(final AppDatabase database) { mDatabase = database; mObservableProducts = new MediatorLiveData<>(); mObservableProducts.addSource(mDatabase.productDao().loadAllProducts(), productEntities -> { if (mDatabase.getDatabaseCreated().getValue() != null) { mObservableProducts.postValue(productEntities); } }); }
MergeResource(AppExecutors executors) { this.executors = executors; result = new MediatorLiveData<>(); }
public ListIssuesViewModel() { mApiResponse = new MediatorLiveData<>(); mIssueRepository = new IssueRepositoryImpl(); }