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


Java Transformations.map方法代码示例

本文整理汇总了Java中android.arch.lifecycle.Transformations.map方法的典型用法代码示例。如果您正苦于以下问题:Java Transformations.map方法的具体用法?Java Transformations.map怎么用?Java Transformations.map使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.arch.lifecycle.Transformations的用法示例。


在下文中一共展示了Transformations.map方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: grepData

import android.arch.lifecycle.Transformations; //导入方法依赖的package包/类
@MainThread
static LiveData<LogcatContent> grepData(LiveData<LogcatContent> rawData, String grep) {
    return Transformations.map(rawData, logcatData -> {
        String content = logcatData.getContent();
        if (GREP_SIGNAL.equals(content)) {
            return logcatData;
        }


        if (content != null) {
            logcatData.setContent(parseHtml2(content,grep));
        }

        return logcatData;

    });
}
 
开发者ID:Zane96,项目名称:Fairy,代码行数:18,代码来源:GrepFilter.java

示例2: subscribeToDbChanges

import android.arch.lifecycle.Transformations; //导入方法依赖的package包/类
private void subscribeToDbChanges() {
    LiveData<List<LoanWithUserAndBook>> loans
            = mDb.loanModel().findLoansByNameAfter("Mike", getYesterdayDate());

    // Instead of exposing the list of Loans, we can apply a transformation and expose Strings.
    mLoansResult = Transformations.map(loans,
            new Function<List<LoanWithUserAndBook>, String>() {
        @Override
        public String apply(List<LoanWithUserAndBook> loansWithUserAndBook) {
            StringBuilder sb = new StringBuilder();
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm",
                    Locale.US);

            for (LoanWithUserAndBook loan : loansWithUserAndBook) {
                sb.append(String.format("%s\n  (Returned: %s)\n",
                        loan.bookTitle,
                        simpleDateFormat.format(loan.endTime)));
            }
            return sb.toString();
        }
    });
}
 
开发者ID:googlecodelabs,项目名称:android-persistence,代码行数:23,代码来源:CustomResultViewModel.java

示例3: subscribeToDbChanges

import android.arch.lifecycle.Transformations; //导入方法依赖的package包/类
private void subscribeToDbChanges() {
    // TODO: Modify this query to show only recent loans from specific user
    LiveData<List<LoanWithUserAndBook>> loans
            = mDb.loanModel().findAllWithUserAndBook();

    // Instead of exposing the list of Loans, we can apply a transformation and expose Strings.
    mLoansResult = Transformations.map(loans,
            new Function<List<LoanWithUserAndBook>, String>() {
        @Override
        public String apply(List<LoanWithUserAndBook> loansWithUserAndBook) {
            StringBuilder sb = new StringBuilder();
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm",
                    Locale.US);

            for (LoanWithUserAndBook loan : loansWithUserAndBook) {
                sb.append(String.format("%s\n  (Returned: %s)\n",
                        loan.bookTitle,
                        simpleDateFormat.format(loan.endTime)));
            }
            return sb.toString();
        }
    });
}
 
开发者ID:googlecodelabs,项目名称:android-persistence,代码行数:24,代码来源:CustomResultViewModel.java

示例4: loadOrdered

import android.arch.lifecycle.Transformations; //导入方法依赖的package包/类
public LiveData<List<Repo>> loadOrdered(List<Integer> repoIds) {
  SparseIntArray order = new SparseIntArray();
  int index = 0;
  for (Integer repoId : repoIds) {
    order.put(repoId, index++);
  }
  return Transformations.map(loadById(repoIds), repositories -> {
    Collections.sort(repositories, (r1, r2) -> {
      int pos1 = order.get(r1.id);
      int pos2 = order.get(r2.id);
      return pos1 - pos2;
    });
    return repositories;
  });
}
 
开发者ID:charlesng,项目名称:SampleAppArch,代码行数:16,代码来源:RepoDao.java

示例5: loadOrdered

import android.arch.lifecycle.Transformations; //导入方法依赖的package包/类
public LiveData<List<Repo>> loadOrdered(List<Integer> repoIds) {
    SparseIntArray order = new SparseIntArray();
    int index = 0;
    for (Integer repoId : repoIds) {
        order.put(repoId, index++);
    }
    return Transformations.map(loadById(repoIds), repositories -> {
        Collections.sort(repositories, (r1, r2) -> {
            int pos1 = order.get(r1.id);
            int pos2 = order.get(r2.id);
            return pos1 - pos2;
        });
        return repositories;
    });
}
 
开发者ID:googlesamples,项目名称:android-architecture-components,代码行数:16,代码来源:RepoDao.java

示例6: liveData

import android.arch.lifecycle.Transformations; //导入方法依赖的package包/类
public LiveData<Type> liveData() {
    return Transformations.map(manager.paramRecordLiveData, record -> getValueOnRecord(record));
}
 
开发者ID:strudelauxpommes,项目名称:FitnessHabits,代码行数:4,代码来源:Param.java

示例7: liveData

import android.arch.lifecycle.Transformations; //导入方法依赖的package包/类
public LiveData<Type> liveData() {
    return Transformations.map(this.weightRepository.weightRecordLiveData, record -> field.getRecordValue(record));
}
 
开发者ID:strudelauxpommes,项目名称:FitnessHabits,代码行数:4,代码来源:FieldInstance.java

示例8: init

import android.arch.lifecycle.Transformations; //导入方法依赖的package包/类
public void init(ParamRepository paramRepository) {
    this.paramRepository = paramRepository;
    date = Transformations.map(paramRepository.param().currentViewDate().liveData(),
            CalendarDate::getCalendardate);
}
 
开发者ID:strudelauxpommes,项目名称:FitnessHabits,代码行数:6,代码来源:MainActivityViewModel.java

示例9: cartTotalLiveData

import android.arch.lifecycle.Transformations; //导入方法依赖的package包/类
@Override public LiveData<BigDecimal> cartTotalLiveData() {
  return Transformations.map(cartLiveData, cart -> cart != null ? cart.totalPrice() : BigDecimal.ZERO);
}
 
开发者ID:Shopify,项目名称:mobile-buy-sdk-android,代码行数:4,代码来源:RealCartViewModel.java


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