fun updateAppearanceOfView()

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


  fun updateAppearanceOfView(view: View, json: JSONObject, displayDensity: Float) {
    try {
      val textStyle = JSONObject()
      if (view is TextView) {
        val textView = view
        val typeface = textView.typeface
        if (typeface != null) {
          textStyle.put(TEXT_SIZE, textView.textSize.toDouble())
          textStyle.put(TEXT_IS_BOLD, typeface.isBold)
          textStyle.put(TEXT_IS_ITALIC, typeface.isItalic)
          json.put(TEXT_STYLE, textStyle)
        }
      }
      if (view is ImageView) {
        val drawable = view.drawable
        if (drawable is BitmapDrawable) {
          if (view.getHeight() / displayDensity <= ICON_MAX_EDGE_LENGTH &&
              view.getWidth() / displayDensity <= ICON_MAX_EDGE_LENGTH) {
            val bitmap = drawable.bitmap
            if (bitmap != null) {
              val byteArrayOutputStream = ByteArrayOutputStream()
              bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream)
              val byteArray = byteArrayOutputStream.toByteArray()
              val encoded = Base64.encodeToString(byteArray, Base64.DEFAULT)
              json.put(ICON_BITMAP, encoded)
            }
          }
        }
      }
    } catch (e: JSONException) {
      logd(TAG, e)
    }
  }