tutorial query example datasnapshot java android firebase nullpointerexception firebase-database

query - Se esperaba un mapa mientras se deserializaba, pero obtuve una clase java.lang.Long



get value firebase android (0)

He estado obteniendo este error "Se esperaba un mapa mientras deserializaba, pero obtuve una clase java.lang.Long" mientras uso la base de datos de firebase. Busqué alguna pregunta sobre el mismo problema en stackoverflow pero no encontré una solución relevante.

Esta es mi clase POJO para almacenar los datos de Firebase.

public class News { public String topic; public String detail; public String user; public Map<String, String> timestamp = null; public News(){ } public News(String topic, String detail, String user, HashMap<String, String> timeStamp){ this.topic = topic; this.detail = detail; this.user = user; this.timestamp = timeStamp; //this.timestamp.put("timestamp", timeStamp); //this.timestamp.put("timestamp", ServerValue.TIMESTAMP); } public String getTopic(){ return topic; } public String getDetail(){ return detail; } @Exclude public Map<String, Object> toMap() { HashMap<String, Object> result = new HashMap<>(); result.put("topic", topic); result.put("detail", detail); result.put("user", user); result.put("timestamp", timestamp); return result; } }

Y esta es la clase principal donde obtengo datos de la base de fuego.

public class News_M extends AppCompatActivity { FirebaseListAdapter mAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_news); ListView messagesView = (ListView) findViewById(R.id.listview); DatabaseReference ref = FirebaseDatabase.getInstance().getReference().child("abc").child("news"); //News msg = new News("Holiday", "28 October", "fayeed", ServerValue.TIMESTAMP); //ref.push().setValue(msg); mAdapter = new FirebaseListAdapter<News>(this, News.class, android.R.layout.two_line_list_item, ref) { @Override protected void populateView(View view, News newsMessage, int position) { ((TextView)view.findViewById(android.R.id.text1)).setText(newsMessage.getTopic()); ((TextView)view.findViewById(android.R.id.text2)).setText(newsMessage.getDetail( )); } }; messagesView.setAdapter(mAdapter); } @Override protected void onDestroy() { super.onDestroy(); mAdapter.cleanup(); } }