小编sow*_*mia的帖子

Android - DataBinding - 如何以及何时生成绑定类?

数据绑定指南

  By default, a Binding class will be generated based on the name of the layout 
file, converting it to Pascal case and suffixing “Binding” to it. 
The above layout file was activity_main.xml so the generate class was ActivityMainBinding.
Run Code Online (Sandbox Code Playgroud)

什么时候会生成Binding类,比如说ActivityMainBinding.我有编译时错误."无法解析ActivityMainBinding".

ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.main_activity);
Run Code Online (Sandbox Code Playgroud)

任何帮助表示赞赏.谢谢

data-binding android

66
推荐指数
5
解决办法
5万
查看次数

干净的架构:无法将 PagingSource<Int, Entities> 映射到 PagingSource<RepositoryModel>

我的要求是使用干净的架构和离线支持在页面中显示注释。我正在使用 Paging 库进行分页。下面是用于获取笔记的简洁架构图。

在此输入图像描述

注意:请在新选项卡中打开上图并缩放以清晰查看。

我有四层UIUseCaseRepositoryDatasource。我打算抽象数据源的内部实现。为此,我需要NotesEntities在跨越边界之前映射到另一个模型。

class TimelineDao{
    @Transaction
    @Query("SELECT * FROM NotesEntities ORDER BY timeStamp DESC")
    abstract fun getPagingSourceForNotes(): PagingSource<Int, NotesEntities>
}
Run Code Online (Sandbox Code Playgroud)

目前的实施:

internal class NotesLocalDataSourceImpl @Inject constructor(
    private val notesDao: NotesDao
) : NotesLocalDataSource {
    override suspend fun insertNotes(notes: NotesEntities) {
        notesDao.insert(NotesEntities)
    }

    override fun getNotesPagingSource(): PagingSource<Int, NotesEntities> {
        return notesDao.getPagingSourceForNotes()
    }
}
Run Code Online (Sandbox Code Playgroud)

预期实施:

internal class NotesLocalDataSourceImpl @Inject constructor(
    private val notesDao: NotesDao
) : NotesLocalDataSource {
    override suspend …
Run Code Online (Sandbox Code Playgroud)

paging clean-architecture android-room android-paging android-paging-3

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

Android单元测试:Cucumber-jvm + Android Instrumentation

使用:带有Android Instrumentation + Espresso的Cucumber-JVM).

参考Github链接:https://github.com/mfellner/cucumber-android.简单的样本工作正常.

使用cucumber-jvm + android检测问题: 但是在链接中的示例中,它使用了不推荐使用的ActivityInstrumentationTestCase2.我想使用谷歌所说的@Rule - ActivityTestRule类.

这里我的问题是: 对于使用cucumber-jvm,我使用的是CucumberInstrumentationCore而不是testInstrumentationRunner"android.support.test.runner.AndroidJUnitRunner".

因此,像@Rule for ActivityTestRule的Android junit注释不会被CucumberInstrumentation解析.那么有可能克服这个问题吗?

然后我决定使用cucumber-jvm + android工具必须恢复原状.我的问题不仅仅是对于已弃用的类,而且全局是使用cucumber-jvm + android检测的好主意,因为它因为注释解析而无法使用检测功能.

android android-testing cucumber-jvm

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