Skip to content

Instantly share code, notes, and snippets.

@pscollins
Last active August 29, 2015 14:19
Show Gist options
  • Save pscollins/aa38866eeaae5ea39920 to your computer and use it in GitHub Desktop.
Save pscollins/aa38866eeaae5ea39920 to your computer and use it in GitHub Desktop.
Lab 1
class Greeting extends SActivity {
val LOCATION_DEFAULT = "Location not available."
override def onCreate(savedInstanceState: Bundle) {
super.onCreate(savedInstanceState)
var latText: STextView = null
var lonText: STextView = null
contentView = new SVerticalLayout {
STextView(s"${R.string.prompt.r2String}! ${getIntent.getStringExtra("name")}") textSize 75.dip
latText = STextView(LOCATION_DEFAULT) textSize 50.dip
lonText = STextView(LOCATION_DEFAULT) textSize 50.dip
SButton("Back", startActivity[HelloScaloidActivity])
}
val locListener = new LocationListener {
override def onLocationChanged(location: Location): Unit = {
latText setText s"Latitude: ${location.getLatitude.toString}"
lonText setText s"Longitude: ${location.getLongitude.toString}"
}
override def onProviderEnabled(s: String): Unit = ()
override def onStatusChanged(s: String, i: Int, bundle: Bundle): Unit = ()
override def onProviderDisabled(s: String): Unit = ()
}
locationManager getAllProviders() foreach(locationManager.requestLocationUpdates(_, 0, 0, locListener))
}
}
class HelloScaloidActivity extends SActivity {
onCreate {
var box: SEditText = null contentView = new SVerticalLayout {
STextView(R.string.whats_your_name) textSize 75.dip
box = SEditText() hint "John Smith"
SButton("Done", startActivity(SIntent[Greeting] putExtra("name", box.getText.toString)))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment