本文整理汇总了Java中android.arch.lifecycle.MediatorLiveData类的典型用法代码示例。如果您正苦于以下问题:Java MediatorLiveData类的具体用法?Java MediatorLiveData怎么用?Java MediatorLiveData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MediatorLiveData类属于android.arch.lifecycle包,在下文中一共展示了MediatorLiveData类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Holder
import android.arch.lifecycle.MediatorLiveData; //导入依赖的package包/类
public Holder() {
data = new MediatorLiveData<>();
data.addSource(rawData, str -> {
data.setValue(str);
});
transData.setValue(false);
}
示例2: DataRepository
import android.arch.lifecycle.MediatorLiveData; //导入依赖的package包/类
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);
}
}
});
}
示例3: ProductListViewModel
import android.arch.lifecycle.MediatorLiveData; //导入依赖的package包/类
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);
}
示例4: DataRepository
import android.arch.lifecycle.MediatorLiveData; //导入依赖的package包/类
private DataRepository(final AppDatabase database) {
mDatabase = database;
mObservableProducts = new MediatorLiveData<>();
mObservableProducts.addSource(mDatabase.productDao().loadAllProducts(),
productEntities -> {
if (mDatabase.getDatabaseCreated().getValue() != null) {
mObservableProducts.postValue(productEntities);
}
});
}
示例5: MergeResource
import android.arch.lifecycle.MediatorLiveData; //导入依赖的package包/类
MergeResource(AppExecutors executors) {
this.executors = executors;
result = new MediatorLiveData<>();
}
示例6: creat
import android.arch.lifecycle.MediatorLiveData; //导入依赖的package包/类
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);
}
示例7: ListIssuesViewModel
import android.arch.lifecycle.MediatorLiveData; //导入依赖的package包/类
public ListIssuesViewModel() {
mApiResponse = new MediatorLiveData<>();
mIssueRepository = new IssueRepositoryImpl();
}