Hello every one, am trying to retrieve data from F...
# android
m
Hello every one, am trying to retrieve data from Firestore database but its slow what could be the best practices that I can use to enhance the speed of loading
Copy code
private fun loadDoctorInfo(doctorId: String) {
    db!!.collection("doctorProfileInfo").document(doctorId)
        .get()
        .addOnSuccessListener(OnSuccessListener { documentSnapshot: DocumentSnapshot? ->
            if (documentSnapshot!!.exists()) {
                doctorName!!.text = if (documentSnapshot.getString("D_name") != null) documentSnapshot.getString("D_name") else "N/A"
                doctorContact!!.text = if (documentSnapshot.getString("contact") != null) documentSnapshot.getString("contact") else "N/A"
                doctorDegree!!.text = if (documentSnapshot.getString("degree") != null) documentSnapshot.getString("degree") else "N/A"
                doctorSpeciality!!.text = if (documentSnapshot.getString("speciality") != null) documentSnapshot.getString("speciality") else "N/A"
                doctorDescription!!.text = if (documentSnapshot.getString("description") != null) documentSnapshot.getString("description") else "N/A"
                doctorEmail!!.text = if (documentSnapshot.getString("email") != null) documentSnapshot.getString("email") else "N/A"

                val imageUrl = documentSnapshot.getString("D_profileImageUrl")
                if (imageUrl != null && !imageUrl.isEmpty()) {
                    Glide.with(requireActivity())
                        .asBitmap()
                        .load(imageUrl)
                        .placeholder(R.drawable.ic_person_white) //.apply(RequestOptions.bitmapTransform(WebpTranscoder()))
                        .into(doctorProfileImage!!)
                } else {
                    doctorProfileImage!!.setImageResource(R.drawable.ic_person_white)
                }
                doctorProfileImage!!.tag = imageUrl
            } else {
                Toast.makeText(activity, "Doctor profile not found", Toast.LENGTH_SHORT)
                    .show()
            }
        })
        .addOnFailureListener(OnFailureListener { e: Exception? ->
            Toast.makeText(
                activity,
                "Failed to load doctor information",
                Toast.LENGTH_SHORT
            ).show()
        })
}
not kotlin but kotlin colored 2
🧵 2
c
Image from iOS.jpg
1
This is a workspace from JetBrains dedicated for the Kotlin programming language. Your general Android question should be asked in a different forum.