小编cas*_*cal的帖子

AndroidViewModel与ViewModel

随着Android架构组件库的引入,引入了几个新类,包括AndroidViewModelViewModel.但是,我无法弄清楚这两个类之间的区别.该文件,简要地描述AndroidViewModel如下:

应用上下文感知 ViewModel

我很欣赏这种简洁,但究竟是什么意思呢?我们什么时候应该选择使用AndroidViewModel,ViewModel反之亦然?

android mvvm android-architecture-components

127
推荐指数
3
解决办法
2万
查看次数

如何在Scheme中的列表中使用lambdas

我在查找如何使用Scheme中列表中包含的lambda时遇到了一些麻烦.例如,我有以下代码:

(define abc '((lambda (x) (* x x))))
Run Code Online (Sandbox Code Playgroud)

我想从列表中取出第一个lambda并将其应用于某些数字.这是我到目前为止:

(map (car abc) '(1 2 3))
Run Code Online (Sandbox Code Playgroud)

但是,我收到以下错误:

;The object (lambda (x) (* x x)) is not applicable.
Run Code Online (Sandbox Code Playgroud)

但是,当我直接使用lambda尝试同样的事情时,它的工作原理是:

(map (lambda (x) (* x x)) '(1 2 3))
;Value 15: (1 4 9)
Run Code Online (Sandbox Code Playgroud)

有人能帮助我理解我做错了什么吗?

lisp lambda scheme higher-order-functions mit-scheme

4
推荐指数
1
解决办法
120
查看次数

找不到“com.firebase:firebase-jobdispatcher”

我正在尝试将 Firebase Job Dispatcher 添加到我的项目中,但由于以下错误而无法构建:

Gradle 同步失败:找不到 com.firebase:firebase-jobdispatcher:[版本]。需要者:项目:[模块]

我的build.gradle文件如下所示:

apply plugin: 'com.android.application'
apply plugin: 'android-apt'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 2
        versionName "1.0.1"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            zipAlignEnabled true
        }
    }
}

repositories {
    mavenCentral()
    maven {url "https://clojars.org/repo/"}
}

dependencies {
    debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
    releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
    testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'

    compile 'com.firebase:firebase-jobdispatcher:0.5.2'

    compile 'com.facebook.stetho:stetho:1.4.2'

    compile 'com.jakewharton:butterknife:8.4.0'
    apt 'com.jakewharton:butterknife-compiler:8.4.0'

    compile 'frankiesardo:icepick:3.2.0'
    provided 'frankiesardo:icepick-processor:3.2.0'

    compile 'org.greenrobot:eventbus:3.0.0'

    compile 'com.android.support:appcompat-v7:25.3.0'
    compile …
Run Code Online (Sandbox Code Playgroud)

android gradle build.gradle android-gradle-plugin firebase-job-dispatcher

1
推荐指数
1
解决办法
3796
查看次数

如何将 Completable 任务列表合并为一个 Completable 结果?

我有一个返回 a 的方法,Single<List<Item>>我想获取此列表中的每个项目并将其向下游传递给返回Completable. 我想等到每个项目成功完成并返回Completable结果。我最初的做法是分别处理每个项目使用flatMapIterable和组合使用的结果toList,但我不能把toList一个上Completable对象。有没有其他方法可以以这种方式将许多Completable任务“聚合”为一个Completable?这是我到目前为止所拥有的:

public Single<List<Item>> getListOfItems() {
    ...
}

public Completable doSomething(Item item) {
    ...
}

public Completable processItems() {
    return getListOfItems()     
        .toObservable()
        .flatMapIterable(items -> items)
        .flatMapCompletable(item -> doSomething(item))
        .toList()    // ERROR: No method .toList() for Completable
        .ignoreElements();
}
Run Code Online (Sandbox Code Playgroud)

java rx-java rx-android reactivex rx-java2

1
推荐指数
1
解决办法
2457
查看次数