morozov
08/20/2019, 8:09 AMEfe
08/20/2019, 8:22 AMmorozov
08/20/2019, 8:27 AMaddTarget()
from this file.
And add target.
Here is gist: https://gist.github.com/mnewlive/a6a1d4fe1e28920da34c7bc12133fdeemorozov
08/20/2019, 8:34 AM-LmfEVnx-y7c3oh8_U9F
Efe
08/20/2019, 8:38 AMEfe
08/20/2019, 8:38 AMEfe
08/20/2019, 8:39 AMmorozov
08/20/2019, 8:44 AM-LmfEVnx-y7c3oh8_U9F
morozov
08/20/2019, 8:51 AMdatabaseReference?.child("targets")?.child("users")
?.child(uid)?.child("targets")
and after this a log the data:
val data = dataSnapshot.value as? HashMap<String, String>?
Log.d("some", "dataSnap: $data")
i get next:
dataSnap: {-LmfOGKjqy-OC4HzxBHF={name=ggg, description=bhhh, guid=-LmfOGKiiQAIcIIWQh8i}, -LmfOLEMiZrgw2m4GgLd={name=hhh, description=nnnj, guid=-LmfOLELLWTos6SXQxIv}, -LmfX6dkBtZzSKbTbnLO={name=щщщщ, description=щщщщ, guid=-LmfX6djA3iflD3yQytN}}
morozov
08/20/2019, 10:16 AMprivate fun fetchTarget(guid: String) {
val targetsRef = databaseReference!!.child("targets").child("users").child(uid.toString()).child("targets")
val query = targetsRef.orderByChild("guid").equalTo(guid)
val valueEventListener = object : ValueEventListener {
override fun onDataChange(dataSnapshot: DataSnapshot) {
for (targetSnapshot in dataSnapshot.children) {
val target = targetSnapshot.getValue(Target::class.java)
val name = target?.name ?: ""
val description = target?.description ?: ""
if (name.isEmpty()) Log.d("some", "nameIsEmpty")
else updateViewsContent(name = name, description = description)
}
}
override fun onCancelled(databaseError: DatabaseError) {
Log.d("some", databaseError.message)
}
}
query.addListenerForSingleValueEvent(valueEventListener)
}