30 lines
764 B
Kotlin
30 lines
764 B
Kotlin
/*
|
|
* *
|
|
* * Copyright (c) 2020 . All rights reserved @Navi
|
|
*
|
|
*/
|
|
|
|
package com.naviapp.firebasedb
|
|
|
|
import com.google.firebase.database.DataSnapshot
|
|
import com.google.firebase.database.DatabaseError
|
|
import com.google.firebase.database.ValueEventListener
|
|
import com.naviapp.utils.log
|
|
|
|
class FirebaseReceiveDataHandler(private val listener: FirebaseDataReceiveListener?) :
|
|
ValueEventListener {
|
|
|
|
override fun onDataChange(dataSnapshot: DataSnapshot) {
|
|
try {
|
|
dataSnapshot.getValue(FirebaseResponse::class.java)
|
|
?.let {
|
|
listener?.onDataReceive(it)
|
|
}
|
|
} catch (e: Exception) {
|
|
e.log()
|
|
}
|
|
}
|
|
|
|
override fun onCancelled(databaseError: DatabaseError) {
|
|
}
|
|
} |