content: ' entry point of GridScreen
  ' Note that we need to import this file in GridScreen.xml using relative path.
  sub Init()
    m.rowList = m.top.FindNode("rowList")
    m.rowList.SetFocus(true)
    ' label with item description
    m.descriptionLabel = m.top.FindNode("descriptionLabel")
    ' observe visible field so we can GridScreen change visibility
    m.top.ObserveField("visible", "OnVisibleChange")
    ' label with item title
    m.titleLabel = m.top.FindNode("titleLabel")
    ' observe rowItemFocused so we can know when another item of rowList will be focused
    m.rowList.ObserveField("rowItemFocused", "OnItemFocused")
  end sub
  
  sub OnVisibleChange() ' invoked when GridScreen change visibility
    if m.top.visible = true
      m.rowList.SetFocus(true) ' set focus to rowList if GridScreen visible
    end if
  end sub
  
  sub OnItemFocused() ' invoked when another item is focused
    focusedIndex = m.rowList.rowItemFocused ' get position of focused item
    row = m.rowList.content.GetChild(focusedIndex[0]) ' get all items of row
    item = row.GetChild(focusedIndex[1]) ' get focused item
    ' update description label with description of focused item
    m.descriptionLabel.text = item.description
    ' update title label with title of focused item
    m.titleLabel.text = item.title
    ' adding length of playback to the title if item length field was populated
    if item.length <> invalid
      m.titleLabel.text += " | " + GetTime(item.length)
    end if
  end sub
  
  ' this method convert seconds to mm:ss format
  ' getTime(138) returns 2:18
  function GetTime(length as integer) as string
    minutes = (length \ 60).ToStr()
    seconds = length mod 60
    if seconds < 10
      seconds = "0" + seconds.ToStr()
    else
      seconds = seconds.ToStr()
    end if
    return minutes + ":" + seconds
  end function