Created
November 11, 2015 18:00
-
-
Save BrianCraig/bb2bb411a202b35c1a88 to your computer and use it in GitHub Desktop.
Simple App for GoMobile, that logs lifecycle and paints events for debugging purposes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// +build darwin linux | |
package main | |
import "fmt" | |
import "golang.org/x/mobile/app" | |
import "golang.org/x/mobile/event/lifecycle" | |
import "golang.org/x/mobile/event/paint" | |
func main() { | |
app.Main(func(a app.App) { | |
// each posible lyfecycle stage | |
stages := []lifecycle.Stage{lifecycle.StageDead, lifecycle.StageAlive, lifecycle.StageVisible, lifecycle.StageFocused} | |
for e := range a.Events() { | |
// when an events come's | |
switch e := a.Filter(e).(type) { | |
case lifecycle.Event: | |
// if it's a lifecycle status event | |
for _, stage := range stages { | |
// log each state | |
fmt.Println(stage, e.Crosses(stage)) | |
} | |
case paint.Event: | |
// if it's a paint event, log it | |
if e.External { | |
fmt.Println("paint external") | |
} else { | |
fmt.Println("paint internal") | |
} | |
a.Publish() | |
} | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment