Results of some experiments to determine which Activity lifecycle methods get called in certain situations.
Launch:
- activity.onCreate()
- activity.onStart()
- activity.onResume()
- activity.onWindowFocusChanged(true)
| private fun drawTextInsideRectangle(canvas: Canvas, rect: Rect, str: String) { | |
| val xOffset = textPaint.measureText(str) * 0.5f | |
| val yOffset = textPaint.fontMetrics.ascent * -0.4f | |
| val textX = (rect.exactCenterX()) - xOffset | |
| val textY = (rect.exactCenterY()) + yOffset | |
| canvas.drawText(str, textX, textY, textPaint) | |
| } |
| private fun drawTextInsideRectangle(canvas: Canvas, rect: Rect, str: String) { | |
| val textX = (rect.exactCenterX()) | |
| val textY = (rect.exactCenterY()) | |
| canvas.drawText(str, textX, textY, textPaint) | |
| } |
| private lateinit var squares: Array<Array<Rect>> | |
| private lateinit var squareData: Array<Array<String>> | |
| ... | |
| private fun initializeTicTacToeSquares() { | |
| squares = Array(3, { Array(3, { Rect() }) }) | |
| squareData = Array(3, { Array(3, { "" }) }) | |
| val xUnit = (width * X_PARTITION_RATIO).toInt() // one unit on x-axis | |
| val yUnit = (height * Y_PARTITION_RATIO).toInt() // one unit on y-axis |
| val X_PARTITION_RATIO = 1 / 3f | |
| ... | |
| private fun drawVerticalLines(canvas: Canvas) { | |
| canvas.drawLine(width * X_PARTITION_RATIO, 0f, width * X_PARTITION_RATIO, | |
| height.toFloat(), paint); | |
| canvas.drawLine(width * (2 * X_PARTITION_RATIO), 0f, width * (2 * X_PARTITION_RATIO), | |
| height.toFloat(), paint); | |
| } |
| class CustomView : View { | |
| constructor(context: Context?) : super(context) | |
| constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) | |
| constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) | |
| constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) | |
| override fun onDraw(canvas: Canvas) { | |
| super.onDraw(canvas) | |
| } |
| private fun initializeTicTacToeSquares() { | |
| squares = Array(3, { Array(3, { Rect() }) }) | |
| squareData = Array(3, { Array(3, { "" }) }) | |
| val xUnit = (width * X_PARTITION_RATIO).toInt() // one unit on x-axis | |
| val yUnit = (height * Y_PARTITION_RATIO).toInt() // one unit on y-axis | |
| for (j in 0..COUNT - 1) { | |
| for (i in 0..COUNT - 1) { | |
| squares[i][j] = Rect(i * xUnit, j * yUnit, (i + 1) * xUnit, (j + 1) * yUnit) |
| // |
| package com.jiocartseller.jio.ui.filter; | |
| import android.content.Context; | |
| import android.support.v7.widget.RecyclerView; | |
| import android.view.View; | |
| import android.view.ViewGroup; | |
| import java.util.ArrayList; | |
| import butterknife.ButterKnife; |
| package com.jiocartseller.base.ui.widget; | |
| import android.annotation.TargetApi; | |
| import android.content.Context; | |
| import android.content.res.TypedArray; | |
| import android.os.Build; | |
| import android.support.v7.widget.AppCompatTextView; | |
| import android.text.Editable; | |
| import android.text.TextUtils; | |
| import android.text.TextWatcher; |