当前位置: 首页>>代码示例>>Java>>正文


Java MediatorLiveData类代码示例

本文整理汇总了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);
}
 
开发者ID:Zane96,项目名称:Fairy,代码行数:8,代码来源:ExampleUnitTest.java

示例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);
        }
      }
    });
}
 
开发者ID:mapbox,项目名称:mapbox-plugins-android,代码行数:15,代码来源:DataRepository.java

示例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);
}
 
开发者ID:googlesamples,项目名称:android-architecture-components,代码行数:14,代码来源:ProductListViewModel.java

示例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);
                }
            });
}
 
开发者ID:googlesamples,项目名称:android-architecture-components,代码行数:12,代码来源:DataRepository.java

示例5: MergeResource

import android.arch.lifecycle.MediatorLiveData; //导入依赖的package包/类
MergeResource(AppExecutors executors) {
    this.executors = executors;
    result = new MediatorLiveData<>();
}
 
开发者ID:Zane96,项目名称:Fairy,代码行数:5,代码来源:MergeResource.java

示例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);
}
 
开发者ID:Zane96,项目名称:Fairy,代码行数:14,代码来源:LogcatContentRepository.java

示例7: ListIssuesViewModel

import android.arch.lifecycle.MediatorLiveData; //导入依赖的package包/类
public ListIssuesViewModel() {
    mApiResponse = new MediatorLiveData<>();
    mIssueRepository = new IssueRepositoryImpl();
}
 
开发者ID:shahbazahmed1269,项目名称:AndroidGithubIssues,代码行数:5,代码来源:ListIssuesViewModel.java


注:本文中的android.arch.lifecycle.MediatorLiveData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。