-
-
Save LeonidIvankin/48ade4ab6d6cde33a6e1d2f5b7aff95c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.leonidivankin.draftandroid.articles.benchmark | |
import android.graphics.Color | |
import android.os.Bundle | |
import android.util.Log | |
import android.widget.FrameLayout | |
import androidx.appcompat.app.AppCompatActivity | |
class CodeDepthActivity : AppCompatActivity() { | |
var time = 0L | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
title = "code, depth" | |
val myDensity = 3 | |
val colors = listOf( | |
"#F44336", | |
"#E91E63", | |
"#9C27B0", | |
"#673AB7", | |
"#3F51B5", | |
"#2196F3", | |
"#03A9F4", | |
"#00BCD4", | |
"#009688", | |
"#4CAF50", | |
"#8BC34A", | |
"#CDDC39", | |
"#FFEB3B", | |
"#FFC107", | |
"#FF9800", | |
"#FF5722", | |
) | |
.map { Color.parseColor(it) } | |
time = System.currentTimeMillis() | |
val head = FrameLayout(this) | |
head.setBackgroundColor(colors[0]) | |
head.setPadding(4 * myDensity, 4 * myDensity, 4 * myDensity, 4 * myDensity) | |
var tail = head | |
for (i in 1..48) { | |
val layout = FrameLayout(this) | |
layout.setBackgroundColor(colors[i % colors.size]) | |
layout.setPadding(4 * myDensity, 4 * myDensity, 4 * myDensity, 4 * myDensity) | |
tail.addView(layout) | |
tail = layout | |
} | |
setContentView(head) | |
} | |
override fun onResume() { | |
super.onResume() | |
Log.d("Benchmark", "CodeDepthActivity onResume: ${System.currentTimeMillis() - time}") | |
} | |
override fun onWindowFocusChanged(hasFocus: Boolean) { | |
super.onWindowFocusChanged(hasFocus) | |
if (hasFocus) { | |
Log.d( | |
"Benchmark", | |
"CodeDepthActivity onWindowFocusChanged: ${System.currentTimeMillis() - time}" | |
) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment