小编Flo*_*lin的帖子

Android TV Custom Presenter错误:请勿在布局或滚动中设置LayoutFrozen

我试图用一个自定义视图控件创建一个自定义演示者,将视频播放到表面视图中,并在第一次绑定后收到此错误消息。有什么问题?我没有设置任何布尔值来冻结裁员或类似的信息。

整个项目可以在这里找到

    java.lang.IllegalStateException: Do not setLayoutFrozen in layout or scroll
at android.support.v7.widget.RecyclerView.assertNotInLayoutOrScroll(RecyclerView.java:2164)
at android.support.v7.widget.RecyclerView.setLayoutFrozen(RecyclerView.java:1750)
at android.support.v17.leanback.app.BaseRowFragment.onTransitionStart(BaseRowFragment.java:199)
at android.support.v17.leanback.app.RowsFragment.onExpandTransitionStart(RowsFragment.java:483)
at android.support.v17.leanback.app.BrowseFragment.startHeadersTransitionInternal(BrowseFragment.java:435)
at android.support.v17.leanback.app.BrowseFragment.access$200(BrowseFragment.java:77)
at android.support.v17.leanback.app.BrowseFragment$3.onRequestChildFocus(BrowseFragment.java:546)
at android.support.v17.leanback.widget.BrowseFrameLayout.requestChildFocus(BrowseFrameLayout.java:124)
at android.view.ViewGroup.requestChildFocus(ViewGroup.java:740)
at android.view.ViewGroup.requestChildFocus(ViewGroup.java:740)
at android.view.ViewGroup.requestChildFocus(ViewGroup.java:740)
at android.support.v7.widget.RecyclerView.requestChildFocus(RecyclerView.java:2081)
at android.view.ViewGroup.requestChildFocus(ViewGroup.java:740)
at android.view.ViewGroup.requestChildFocus(ViewGroup.java:740)
at android.view.ViewGroup.requestChildFocus(ViewGroup.java:740)
at android.support.v7.widget.RecyclerView.requestChildFocus(RecyclerView.java:2081)
at android.view.ViewGroup.addViewInner(ViewGroup.java:4341)
at android.view.ViewGroup.addView(ViewGroup.java:4145)
at android.view.ViewGroup.addView(ViewGroup.java:4086)
at android.support.v7.widget.RecyclerView$5.addView(RecyclerView.java:591)
at android.support.v7.widget.ChildHelper.addView(ChildHelper.java:107)
at android.support.v7.widget.RecyclerView$LayoutManager.addViewInt(RecyclerView.java:6708)
at android.support.v7.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:6666)
at android.support.v7.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:6654)
at android.support.v17.leanback.widget.GridLayoutManager$2.cre    ateItem(GridLayoutManager.java:1473)
at android.support.v17.leanback.widget.SingleRow.appendVisibleItems(SingleRow.java:111)
at android.support.v17.leanback.widget.Grid.appendOneColumnVisibleItems(Grid.java:364)
at android.support.v17.leanback.widget.GridLayoutManager.appendOneColumnVisibleItems(GridLayoutManager.java:1696)
at android.support.v17.leanback.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:1881)
at android.support.v7.widget.RecyclerView.disp    atchLayoutStep2(RecyclerView.java:3026)
at android.support.v7.widget.RecyclerView.disp    atchLayout(RecyclerView.java:2903)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3277)
at …
Run Code Online (Sandbox Code Playgroud)

android television leanback android-recyclerview

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

Retrofit2 - 发送带有重复键的动态键

我需要发送带有重复键的动态键。

这就是我需要的:

https://myApi.com/pepole?name=yoni&name=albert&brand=nike
Run Code Online (Sandbox Code Playgroud)

所有的关键都是动态(名称,品牌)。

所以要动态地做到这一点,我用于@Querymap示例:

Map<String, String> parms = new HashMap<>();

parms.put(dynamicKey, dynamicValue);

parms.put(anotherDynamicKey,anotherDynamicValue);
Run Code Online (Sandbox Code Playgroud)

这是我的界面:

@Get("pepole")
Call<List> searchPepole(
@Querymap Map<String, String> options);
Run Code Online (Sandbox Code Playgroud)

并且工作正常,但是当我有重复的密钥时,我的问题就开始了。

那么如何使用带有重复键的动态键进行呼叫?

android retrofit retrofit2

5
推荐指数
0
解决办法
430
查看次数

Firebase序列化名称

我创建了一个对象来向firebase发送一些数据.作为示例,我使用firebase用户示例:

public class User {
    public String username;
    public String email;

    public User() {
        // Default constructor required for calls to DataSnapshot.getValue(User.class)
    }

    public User(String username, String email) {
        this.username = username;
        this.email = email;
    }
}
Run Code Online (Sandbox Code Playgroud)

我想编码发送到firebase的属性名称.目前,密钥是使用变量名称发送的.我想编码键类似Useraname,并EmailGson在做什么.我不想更改变量名称.

@SerializateName("Username")
public String username;
@SerializateName("Username")
public String email;
Run Code Online (Sandbox Code Playgroud)

我用过@SerializateName(),但没用.与@PropertyNameFirebse使用的相同,不起作用.我可以使用什么来序列化自定义键?

更新1

public class Pojo {
    @PropertyName("Guid")
    public String guid;

   @PropertyName("Name")
   public String name;

   public String getPojoGuid() {
       return guid;
   }

   public void setPojoGuid(String …
Run Code Online (Sandbox Code Playgroud)

android firebase firebase-realtime-database

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

Android Dagger 2 - 如何使自定义范围成为本地单例

根据这样的教程一个:在Dagger2我们能够提供使用自定义范围本地单一对象。

我已经有一个全局 appComponent,我的目标是创建一个活动范围,允许子组件拥有本地单例提供程序。

我的问题是当我创建一个自定义范围并两次注入我的活动时,我看到提供的对象不是同一个,即使我用自定义范围标记了它。对于使用 @Singleton 注释的 appComponent 来说,它虽然工作正常。让我们来看看我是如何做到的:

这是自定义活动范围:

@Scope
@Retention(RetentionPolicy.RUNTIME)
public @interface ActivityScope {
}
Run Code Online (Sandbox Code Playgroud)

这是我定义子组件的方式:

@ActivityScope
@Subcomponent(modules = {PresenterModule.class, UseCaseModule.class})
public interface ActivitySubComponent {
    void inject(LoginActivity target);
    void inject(LoginPresenter target);
    void inject(UCGetFireBaseAccount target);
}
Run Code Online (Sandbox Code Playgroud)

请注意,我已经使用上面自定义的 @ActivityScope 注释标记了这个子组件。现在让我们看看 appComponent,它是父组件和全局组件:

@Singleton
@Component(modules = {AppModule.class, NetworkModule.class, RepositoryModule.class})
public interface AppComponent {
    void inject(myappCloudRepo target);
    void inject (FireBaseCloudRepo target);
    ActivitySubComponent plus(PresenterModule presenterModule, UseCaseModule useCaseModule);
}
Run Code Online (Sandbox Code Playgroud)

注意 ActivitySubComponent 在这里被定义为一个子组件。

最后让我们看一下 PresenterModule 类,看看我想作为单例提供什么:

@Module
public class PresenterModule {

        @Provides
        @ActivityScope
        LoginPresenter provideLoginPresenter(Context …
Run Code Online (Sandbox Code Playgroud)

android dagger-2

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

java.lang.IllegalStateException 由于 okhttp 异步 HTTP POST 请求中的 onResponse 代码

我在这里写了一段代码:

public class Wizard1 extends GuidedStepFragment implements Callback {

    private boolean sendPhoneNumber(String userPhoneNumber) {

        OkHttpClient client = new OkHttpClient();

        RequestBody requestBody = new MultipartBody.Builder()
                .setType(MultipartBody.FORM)
                .addFormDataPart("request_magic_code", Urls.REQUEST_MAGIC_CODE)
                .build();

        Request request = new Request.Builder()
                .url(Urls.HOST + Urls.SEND_PHONE_NUMBER)
                .post(requestBody)
                .build();

        client.newCall(request).enqueue(this);
        return success;
    }

    @Override
    public void onFailure(@NonNull Call call, @NonNull IOException e) {
        e.printStackTrace();
    }

    @Override
    public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
        ResponseBody myResponse = response.body();
        Log.d("SS", response.body().string());

    Log.d("SS", response.body().string());

        if (myResponse != null) {
            success …
Run Code Online (Sandbox Code Playgroud)

android okhttp leanback retrofit2

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

如何运行多个firebase promises,然后完成后执行功能

我需要执行2 firebase calls以从数据库中检索特定数据。Once these promises resolve,我想用检索到的数据调用另一个函数。我怎样才能做到这一点?..东西Promise.All?

代码如下:

app.post('/testtwilio', function(req, res) {
  //save request variables
  var to_UID = req.body.to;
  var from_UID = req.body.from;
  var experience_id = req.body.exp_id;

  //Query firebase and save 'zone_id' which we need later
  firebase.database().ref('experiences').child(experience_id).once('value').then((snap) => {
    zone_id = snap.val().ZoneID;
  });

  //Query firebase and save 'from_name' which we need later
  firebase.database().ref('users').child(from_UID).once('value').then((snap) => {
    from_name = snap.val().Name;
  });

  //Once we have the two variables returned and saved
  //Call a final firebase query and a twilio …
Run Code Online (Sandbox Code Playgroud)

node.js promise firebase firebase-realtime-database

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