小编Ita*_*ski的帖子

如何使用 Dagger2 将 Activity 范围内的依赖项替换为模拟

我的 Activity 中有范围依赖项,我想用一些模拟来测试该 Activity。我读过有关建议在测试期间用测试组件替换应用程序组件的不同方法,但我想要的是替换活动组件。

例如,我想在 MVP 设置中针对模拟演示者测试活动。

我相信通过在 Activity 上调用 setComponent() 来替换组件是行不通的,因为 Activity 依赖项已经通过字段注入注入了,所以在测试过程中,将使用真实的对象。

我该如何解决这个问题?匕首1呢?是否有同样的问题?

android unit-testing dependency-injection dagger dagger-2

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

Firebase数据库 - 反向索引中的安全性考虑因素

在Firebase指南中,建议之一是维护反向索引以跟踪用户操作.这是我所指的片段:

// An index to track Ada's memberships
{
  "users": {
    "alovelace": {
      "name": "Ada Lovelace",
      // Index Ada's groups in her profile
      "groups": {
         // the value here doesn't matter, just that the key exists
         "techpioneers": true,
         "womentechmakers": true
      }
    },
    ...
  },
  "groups": {
    "techpioneers": {
     "name": "Historical Tech Pioneers",
     "members": {
        "alovelace": true,
        "ghopper": true,
        "eclarke": true
      }
    },
    ...
  }
}
Run Code Online (Sandbox Code Playgroud)

每个用户在反向索引中跟踪他/她的组 - 在这种情况下,密钥保持实际值,并且值无关紧要.


更新

我不确定如何在技术上更新索引但我在经过一些研究后得到了它:setValue可以采用所有变量,而不仅仅是键值对.这意味着更新索引非常简单:只需获取引用groups/$group_id/members/$member_id并将其值设置为true.

现在我的问题不同了:

让我们说所有团体都是私人的.意味着用户只能通过邀请加入组 - 当前组成员必须将另一个用户添加到成员列表.因此,如果我是 …

indexing json firebase firebase-security firebase-realtime-database

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

Firebase数据库 - 检索多个条目

我的数据是非规范化的,并使用像firebase团队建议的反向索引.类似的东西:

{
  "users": {
    "alovelace": {
      "name": "Ada Lovelace",
      // Index Ada's groups in her profile
      "groups": {
         // the value here doesn't matter, just that the key exists
         "techpioneers": true,
         "womentechmakers": true
      }
    },
    ...
  },
  "groups": {
    "techpioneers": {
      "name": "Historical Tech Pioneers",
      "members": {
        "alovelace": true,
        "ghopper": true,
        "eclarke": true
      }
    },
    ...
  }
}
Run Code Online (Sandbox Code Playgroud)

现在我想加载所有Ada的组.我可以很容易地获得她所属的组ID列表,因为它是她的用户对象的一部分.

有没有办法让我一次通过ID查询Ada的所有特定群组?或者我是否需要创建ValueEventListener每组ID并分别请求每个组?

在安全方面 - 让我们假设每个组只能由其成员读取,因此我无法查询所有组并在事后对其进行排序.

android firebase firebase-realtime-database

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

将相机渲染到多个表面 - 打开和关闭屏幕

我想将摄像机输出渲染到视图中,偶尔将摄像机输出帧保存到文件中,约束为 - 保存的帧应该与摄像机配置的分辨率相同,而视图小于相机输出(保持纵横比).

基于grafika中ContinuousCaptureActivity示例,我认为最好的方法是将摄像机发送到SurfaceTexture并通常渲染输出并将其缩小为a SurfaceView,并在需要时将整个帧渲染为不Surface具有视图的不同帧,以便按顺序排列从常规SurfaceView呈现并行检索字节缓冲区.

该示例与我的情况非常相似 - 预览呈现为较小尺寸的视图,可以通过a以全分辨率进行记录和保存VideoEncoder.

我用VideoEncoder自己的逻辑替换了逻辑,并试图提供Surface像编码器一样的全分辨率渲染.我该如何创建这样的Surface?我接近这个吗?


基于示例的一些代码构思:


surfaceCreated(SurfaceHolder holder)方法内(第350行):

@Override   // SurfaceHolder.Callback
public void surfaceCreated(SurfaceHolder holder) {
    Log.d(TAG, "surfaceCreated holder=" + holder);

    mEglCore = new EglCore(null, EglCore.FLAG_RECORDABLE);
    mDisplaySurface = new WindowSurface(mEglCore, holder.getSurface(), false);
    mDisplaySurface.makeCurrent();

    mFullFrameBlit = new FullFrameRect(
            new Texture2dProgram(Texture2dProgram.ProgramType.TEXTURE_EXT));
    mTextureId = mFullFrameBlit.createTextureObject();
    mCameraTexture = new SurfaceTexture(mTextureId);
    mCameraTexture.setOnFrameAvailableListener(this);

    Log.d(TAG, "starting camera preview"); …
Run Code Online (Sandbox Code Playgroud)

android surfaceview glsurfaceview android-camera

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