Repository: square/leakcanary
File: leakcanary-android-core/src/main/java/leakcanary/internal/activity/screen/HeapDumpScreen.kt (Kotlin)

Code before:
      }
    }

    val listView = findViewById<ListView>(R.id.leak_canary_list)

    val leaks = heapAnalysis.allLeaks.sortedByDescending { it.leakTraces.size }
        .toList()

    listView.adapter = object : BaseAdapter() {
      override fun getView(
        position: Int,
        convertView: View?,
        parent: ViewGroup
      ) = when (getItemViewType(position)) {
        METADATA -> {
          val view = convertView ?: parent.inflate(R.layout.leak_canary_leak_header)
          val textView = view.findViewById<TextView>(R.id.leak_canary_header_text)
          textView.movementMethod = LinkMovementMethod.getInstance()

          val explore =
            if (heapDumpFileExist) """Explore <a href="explore_hprof">Heap Dump</a><br><br>""" else ""
          val shareAnalysis = """Share <a href="share">Heap Dump analysis</a><br><br>"""
          val shareFile =
            if (heapDumpFileExist) """Share <a href="share_hprof">Heap Dump file</a><br><br>""" else ""

          val dumpDurationMillis = if (heapAnalysis.dumpDurationMillis > -1) {
            "${heapAnalysis.dumpDurationMillis} ms"
          } else {
            "Unknown"
          }
          val titleText = explore + shareAnalysis + shareFile +
              (heapAnalysis.metadata + mapOf(
                  "Analysis duration" to "${heapAnalysis.analysisDurationMillis} ms",
                  "Heap dump file path" to heapAnalysis.heapDumpFile.absolutePath,
                  "Heap dump timestamp" to "${heapAnalysis.createdAtTimeMillis}",
                  "Heap dump duration" to dumpDurationMillis
              ))
                  .map { "<b>${it.key}:</b> ${it.value}" }
                  .joinToString("<br>")
          val title = Html.fromHtml(titleText) as SpannableStringBuilder

          UiUtils.replaceUrlSpanWithAction(title) { urlSpan ->
            when (urlSpan) {
              "explore_hprof" -> {
                {
                  goTo(HprofExplorerScreen(heapAnalysis.heapDumpFile))
                }
              }
              "share" -> {
                {
                  share(heapAnalysis.toString())

Review comment (suggestion):
```
val dumpDurationMillis = if (heapAnalysis.dumpDurationMillis != DUMP_DURATION_UNKNOWN) {
```

Code after:
            }
      }
    }

    val listView = findViewById<ListView>(R.id.leak_canary_list)

    val leaks = heapAnalysis.allLeaks.sortedByDescending { it.leakTraces.size }
        .toList()

    listView.adapter = object : BaseAdapter() {
      override fun getView(
        position: Int,
        convertView: View?,
        parent: ViewGroup
      ) = when (getItemViewType(position)) {
        METADATA -> {
          val view = convertView ?: parent.inflate(R.layout.leak_canary_leak_header)
          val textView = view.findViewById<TextView>(R.id.leak_canary_header_text)
          textView.movementMethod = LinkMovementMethod.getInstance()

          val explore =
            if (heapDumpFileExist) """Explore <a href="explore_hprof">Heap Dump</a><br><br>""" else ""
          val shareAnalysis = """Share <a href="share">Heap Dump analysis</a><br><br>"""
          val shareFile =
            if (heapDumpFileExist) """Share <a href="share_hprof">Heap Dump file</a><br><br>""" else ""

          val dumpDurationMillis =
            if (heapAnalysis.dumpDurationMillis != HeapAnalysis.DUMP_DURATION_UNKNOWN) {
              "${heapAnalysis.dumpDurationMillis} ms"
            } else {
              "Unknown"
            }
          val titleText = explore + shareAnalysis + shareFile +
              (heapAnalysis.metadata + mapOf(
                  "Analysis duration" to "${heapAnalysis.analysisDurationMillis} ms",
                  "Heap dump file path" to heapAnalysis.heapDumpFile.absolutePath,
                  "Heap dump timestamp" to "${heapAnalysis.createdAtTimeMillis}",
                  "Heap dump duration" to dumpDurationMillis
              ))
                  .map { "<b>${it.key}:</b> ${it.value}" }
                  .joinToString("<br>")
          val title = Html.fromHtml(titleText) as SpannableStringBuilder

          UiUtils.replaceUrlSpanWithAction(title) { urlSpan ->
            when (urlSpan) {
              "explore_hprof" -> {
                {
                  goTo(HprofExplorerScreen(heapAnalysis.heapDumpFile))
                }
              }
              "share" -> {