fun getTextOfView()

in facebook-core/src/main/java/com/facebook/appevents/codeless/internal/ViewHierarchy.kt [271:310]


  fun getTextOfView(view: View?): String {
    var textObj: Any? = null
    if (view is TextView) {
      textObj = view.text
      if (view is Switch) {
        val isOn = view.isChecked
        textObj = if (isOn) "1" else "0"
      }
    } else if (view is Spinner) {
      if (view.count > 0) {
        val selectedItem = view.selectedItem
        if (selectedItem != null) {
          textObj = selectedItem.toString()
        }
      }
    } else if (view is DatePicker) {
      val y = view.year
      val m = view.month
      val d = view.dayOfMonth
      textObj = String.format("%04d-%02d-%02d", y, m, d)
    } else if (view is TimePicker) {
      val h = view.currentHour
      val m = view.currentMinute
      textObj = String.format("%02d:%02d", h, m)
    } else if (view is RadioGroup) {
      val checkedId = view.checkedRadioButtonId
      val childCount = view.childCount
      for (i in 0 until childCount) {
        val child = view.getChildAt(i)
        if (child.id == checkedId && child is RadioButton) {
          textObj = child.text
          break
        }
      }
    } else if (view is RatingBar) {
      val rating = view.rating
      textObj = rating.toString()
    }
    return textObj?.toString() ?: ""
  }