Added ViewByID functions

This commit is contained in:
anoshenko 2021-11-04 21:21:42 +03:00
parent d254664655
commit 79fb34f29f
3 changed files with 26 additions and 2 deletions

View File

@ -9,7 +9,7 @@ type audioPlayerData struct {
}
// NewAudioPlayer create new MediaPlayer object and return it
func NewAudioPlayer(session Session, params Params) MediaPlayer {
func NewAudioPlayer(session Session, params Params) AudioPlayer {
view := new(audioPlayerData)
view.Init(session)
view.tag = "AudioPlayer"

View File

@ -28,7 +28,7 @@ type videoPlayerData struct {
}
// NewVideoPlayer create new MediaPlayer object and return it
func NewVideoPlayer(session Session, params Params) MediaPlayer {
func NewVideoPlayer(session Session, params Params) VideoPlayer {
view := new(videoPlayerData)
view.Init(session)
view.tag = "VideoPlayer"

View File

@ -312,3 +312,27 @@ func VideoPlayerByID(rootView View, id string) VideoPlayer {
}
return nil
}
// ImageViewByID return a ImageView with id equal to the argument of the function or
// nil if there is no such View or View is not ImageView
func ImageViewByID(rootView View, id string) ImageView {
if view := ViewByID(rootView, id); view != nil {
if canvas, ok := view.(ImageView); ok {
return canvas
}
ErrorLog(`ImageViewByID(_, "` + id + `"): The found View is not ImageView`)
}
return nil
}
// TableViewByID return a TableView with id equal to the argument of the function or
// nil if there is no such View or View is not TableView
func TableViewByID(rootView View, id string) TableView {
if view := ViewByID(rootView, id); view != nil {
if canvas, ok := view.(TableView); ok {
return canvas
}
ErrorLog(`TableViewByID(_, "` + id + `"): The found View is not TableView`)
}
return nil
}