fyne.Do in radios page and loading dots widget
This commit is contained in:
+20
-17
@@ -78,25 +78,28 @@ func (a *RadiosPage) load(searchOnLoad bool, scrollPos float32) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("error loading radios: %v", err.Error())
|
log.Printf("error loading radios: %v", err.Error())
|
||||||
}
|
}
|
||||||
if len(radios) == 0 {
|
|
||||||
a.noRadiosMsg.Show()
|
fyne.Do(func() {
|
||||||
} else {
|
if len(radios) == 0 {
|
||||||
a.noRadiosMsg.Hide()
|
a.noRadiosMsg.Show()
|
||||||
}
|
} else {
|
||||||
a.radios = radios
|
a.noRadiosMsg.Hide()
|
||||||
if searchOnLoad {
|
|
||||||
a.onSearched(a.searcher.Entry.Text)
|
|
||||||
if scrollPos != 0 {
|
|
||||||
a.list.list.ScrollToOffset(scrollPos)
|
|
||||||
}
|
}
|
||||||
} else {
|
a.radios = radios
|
||||||
a.list.SetRadios(a.radios)
|
if searchOnLoad {
|
||||||
if scrollPos != 0 {
|
a.onSearched(a.searcher.Entry.Text)
|
||||||
a.list.list.ScrollToOffset(scrollPos)
|
if scrollPos != 0 {
|
||||||
return
|
a.list.list.ScrollToOffset(scrollPos)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
a.list.SetRadios(a.radios)
|
||||||
|
if scrollPos != 0 {
|
||||||
|
a.list.list.ScrollToOffset(scrollPos)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
a.list.Refresh()
|
||||||
}
|
}
|
||||||
a.list.Refresh()
|
})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *RadiosPage) onPlay(station *mediaprovider.RadioStation) {
|
func (a *RadiosPage) onPlay(station *mediaprovider.RadioStation) {
|
||||||
|
|||||||
@@ -62,16 +62,16 @@ func (l *LoadingDots) Stop() {
|
|||||||
func (l *LoadingDots) animate(ctx context.Context) {
|
func (l *LoadingDots) animate(ctx context.Context) {
|
||||||
foreground := theme.ForegroundColor()
|
foreground := theme.ForegroundColor()
|
||||||
disabled := theme.DisabledColor()
|
disabled := theme.DisabledColor()
|
||||||
l.doTick(foreground, disabled)
|
|
||||||
ticker := time.NewTicker(333 * time.Millisecond)
|
ticker := time.NewTicker(333 * time.Millisecond)
|
||||||
for {
|
for {
|
||||||
|
fyne.Do(func() { l.doTick(foreground, disabled) })
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
ticker.Stop()
|
ticker.Stop()
|
||||||
l.running.Store(false)
|
l.running.Store(false)
|
||||||
return
|
return
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
fyne.Do(func() { l.doTick(foreground, disabled) })
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user