Advertisement
Guest User

Untitled

a guest
May 19th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. class TagRow {
  2.  
  3. /***
  4. * The available spans that the current row has.
  5. */
  6. var freeSpans = MeasureHelper.SPAN_COUNT
  7.  
  8. /***
  9. * List of the Tags hosted in the current row.
  10. */
  11. val tagList = mutableListOf<Tag>()
  12.  
  13. /***
  14. * List of the spans required by each holder hosted in the current row.
  15. */
  16. val spanList = mutableListOf<Int>()
  17.  
  18. fun addTag(spanRequired: Float, tag: Tag) : Boolean {
  19.  
  20. // if the current row has enough available span
  21. if (spanRequired < freeSpans)
  22. if (tagList.add(tag)) {
  23.  
  24. // Round the required span to Int
  25. val spanRequiredInt = ceil(spanRequired).toInt()
  26.  
  27. // Add the required span to spanList
  28. spanList.add(spanRequiredInt)
  29.  
  30. // Minus the required span from the available span.
  31. freeSpans -= spanRequiredInt
  32.  
  33. return true
  34. }
  35.  
  36. return false
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement