Upgrade to Pro — share decks privately, control downloads, hide ads and more …

unraveling custom drawing

unraveling custom drawing

Matheus Cassiano Candido

August 07, 2018
Tweet

More Decks by Matheus Cassiano Candido

Other Decks in Programming

Transcript

  1. performance • evite alocações no onDraw • faça clip nas

    regiões que não for desenhar • use as ferramentas de profiling para verificar overdraw e debugar quebra de frames
  2. acessibilidade getVirtualViewAt(x: Float, y: Float) getVisibleVirtualViews(virtualViewIds: MutableList<Int>) onPerformActionForVirtualView( virtualViewId: Int,

    action: Int, arguments: Bundle? ) onPopulateNodeForVirtualView( virtualViewId: Int, node: AccessibilityNodeInfoCompat )
  3. virtual view data class VirtualView( var id: Int = View.NO_ID,

    var contentDescription: CharSequence, val rect: Rect = Rect() )
  4. node provider override fun getVirtualViewAt( x: Float, y: Float ):

    Int { val view = virtualViews.find{ it.rect.contains(x, y) } return view?.id ?: HOST_ID }
  5. node provider override fun onPopulateNodeForVirtualView( virtualViewId: Int, node: AccessibilityNodeInfoCompat )

    { val view = virtualViews.find { it.id == virtualViewId } view?.let { node.setBoundsInParent(it.rect) node.contentDescription = it.contentDescription } }