我在将RecyclerView集成到我的应用程序时遇到了问题。
它给我这个例外
05-17 16:47:40.866 32761-32761/com.isdsw.infinitytv E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.isdsw.infinitytv, PID: 32761
com.firebase.client.FirebaseException: Failed to bounce to type
at com.firebase.client.DataSnapshot.getValue(DataSnapshot.java:183)
at com.firebase.ui.FirebaseRecyclerAdapter.parseSnapshot(FirebaseRecyclerAdapter.java:161)
at com.firebase.ui.FirebaseRecyclerAdapter.getItem(FirebaseRecyclerAdapter.java:150)
at com.firebase.ui.FirebaseRecyclerAdapter.onBindViewHolder(FirebaseRecyclerAdapter.java:190)
at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:5471)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:5504)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4741)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4617)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1993)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1390)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1353)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:574)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3028)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2906)
at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1482)
at android.support.v7.widget.RecyclerView.access$400(RecyclerView.java:147)
at android.support.v7.widget.RecyclerView$1.run(RecyclerView.java:294)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:603)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "-KHvEl9amJFCS7CREZD2" (class com.isdsw.infinitytv.stream.data.StreamData), not marked as ignorable (6 known properties: , "custom", "online", "condition", "image", "id", "info"])
at [Source: java.io.StringReader@7c8eb8c; line: 1, column: 26] (through reference chain: com.isdsw.infinitytv.stream.data.StreamData["-KHvEl9amJFCS7CREZD2"])
at com.fasterxml.jackson.databind.DeserializationContext.reportUnknownProperty(DeserializationContext.java:555)
at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:708)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1160)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:315)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:121)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:2888)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2034)
at com.firebase.client.DataSnapshot.getValue(DataSnapshot.java:181)
at com.firebase.ui.FirebaseRecyclerAdapter.parseSnapshot(FirebaseRecyclerAdapter.java:161)
at com.firebase.ui.FirebaseRecyclerAdapter.getItem(FirebaseRecyclerAdapter.java:150)
at com.firebase.ui.FirebaseRecyclerAdapter.onBindViewHolder(FirebaseRecyclerAdapter.java:190)
at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:5471)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:5504)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4741)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4617)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1993)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1390)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1353)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:574)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3028)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2906)
at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1482)
at android.support.v7.widget.RecyclerView.access$400(RecyclerView.java:147)
at android.support.v7.widget.RecyclerView$1.run(RecyclerView.java:294)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:603)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
05-17 16:52:40.918 32761-32761 / com.isdsw.infinitytv I / Process:发送信号。 PID:32761 SIG:9
这是我创建de adapter
的地方mAdapter = new FirebaseRecyclerAdapter<StreamData, StreamerViewHolder>(StreamData.class, R.layout.cv_stream, StreamerViewHolder.class, refStreamers) {
@Override
protected void populateViewHolder(StreamerViewHolder streamerViewHolder, StreamData streamData, int i) {
Log.e("TAG", String.valueOf(mAdapter.getItemCount()));
streamerViewHolder.name.setText(streamData.getInfo().getName());
streamerViewHolder.display_name.setText(streamData.getInfo().getDisplay_name());
streamerViewHolder.game.setText(streamData.getInfo().getGame());
}
};
和它所破坏的数据对象就是这个
public class StreamData {
private ConditionData condition;
private InfoData info;
private ImageData image;
private CustomData custom;
private String online;
public StreamData(ConditionData condition, InfoData info, ImageData image, CustomData custom, String online) {
this.condition = condition;
this.info = info;
this.image = image;
this.custom = custom;
this.online = online;
}
public StreamData() {
}
public ConditionData getCondition() {
return condition;
}
public void setCondition(ConditionData condition) {
this.condition = condition;
}
public InfoData getInfo() {
return info;
}
public void setInfo(InfoData info) {
this.info = info;
}
public ImageData getImage() {
return image;
}
public void setImage(ImageData image) {
this.image = image;
}
public CustomData getCustom() {
return custom;
}
public void setCustom(CustomData custom) {
this.custom = custom;
}
public String getOnline() {
return online;
}
public void setOnline(String online) {
this.online = online;
}
}
我听说杰克逊是一个问题,但对于像序列化JSON这样的事情我是新手。如果您需要任何额外信息,请问我,我会告诉您:)
修改
添加了我的数据库对象的示例
{
"-KHvEl9amJFCS7CREZD2" : {
"condition" : {
"active" : true,
"banner" : false,
"display_name" : true,
"logo" : false,
"profile_banner" : false,
"status" : false,
"video_banner" : false
},
"custom" : {
"display_name" : "Prueba",
"show" : "video_banner",
"video_banner" : ""
},
"image" : {
"logo" : "https://static-cdn.jtvnw.net/jtv_user_pictures/misslaia-profile_image-7bc81446a0a045b5-300x300.jpeg",
"preview_large" : "",
"preview_medium" : "",
"preview_small" : "",
"preview_template" : "",
"profile_banner" : "https://static-cdn.jtvnw.net/jtv_user_pictures/misslaia-profile_banner-9b043043de1029ad-480.png"
},
"info" : {
"display_name" : "MissLaia",
"followers" : 6125,
"game" : "Counter-Strike: Global Offensive",
"name" : "misslaia",
"status" : "[ESP] CS:GO ◕ ‿‿ ◕ || Giveaway twitter ---> !sorteo",
"url" : "https://www.twitch.tv/misslaia",
"views" : 95055
},
"online" : false
}
}