Hmm. Looks like I just hit a case which makes "can...
# announcements
d
Hmm. Looks like I just hit a case which makes "can be joined with assignment" inspection wrong:
Copy code
class MyView : View {
  private val textView: TextView
  private val progressVisualizationView: ProgressVisualizationView

  constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
    context.layoutInflater().inflate(R.layout.view_progress_bar, this, true)

    progressVisualizationView = getChildAt(0) as ProgressVisualizationView
    textView = getChildAt(1) as TextView
  }
}
Intention suggests me do the following:
Copy code
class MyView : View {
  private val textView: TextView = getChildAt(1) as TextView
  private val progressVisualizationView: ProgressVisualizationView = getChildAt(0) as ProgressVisualizationView

  constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
    context.layoutInflater().inflate(R.layout.view_progress_bar, this, true)
  }
}
but in android those
getChild()
lines depend on the line above - the view must be inflated and populated with children, so I could invoke
getChildAt()
on it. Without giving it much thought I done what was suggested and app crashed ­čÖé