Scala on androids
Upcoming SlideShare
Loading in...5
×
 

Scala on androids

on

  • 2,394 views

Talk on Scala development on Android

Talk on Scala development on Android

Statistics

Views

Total Views
2,394
Views on SlideShare
2,392
Embed Views
2

Actions

Likes
6
Downloads
87
Comments
1

2 Embeds 2

https://twimg0-a.akamaihd.net 1
https://twitter.com 1

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • Presentation at JavaZone: http://streaming.java.no/tcs/?id=97A469FD-3DDE-4692-85E9-651CFFCCC918 (in norwegian)
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • <br />
  • <br />
  • <br />
  • Fringe: J2ME and Windows Mobile <br /> No working market <br /> Mainstream: Android and iPhone <br /> Android bigger than iPhone <br /> GOOGLE <br /> Customisable: Open source, Linux <br /> Exploding platform <br /> Mobile, TV, Pad <br /> Specialised devices will come <br />
  • Telephones running UNIX <br /> (OpenCore media library) <br /> Dalvik ~= JVM <br /> Develop in java <br /> Harmony - Subset base class library <br /> GUI, bluetooth, WiFi, telephony, location, other hardware <br />
  • Telephones running UNIX <br /> (OpenCore media library) <br /> Dalvik ~= JVM <br /> Develop in java <br /> Harmony - Subset base class library <br /> GUI, bluetooth, WiFi, telephony, location, other hardware <br />
  • Telephones running UNIX <br /> (OpenCore media library) <br /> Dalvik ~= JVM <br /> Develop in java <br /> Harmony - Subset base class library <br /> GUI, bluetooth, WiFi, telephony, location, other hardware <br />
  • Telephones running UNIX <br /> (OpenCore media library) <br /> Dalvik ~= JVM <br /> Develop in java <br /> Harmony - Subset base class library <br /> GUI, bluetooth, WiFi, telephony, location, other hardware <br />
  • Telephones running UNIX <br /> (OpenCore media library) <br /> Dalvik ~= JVM <br /> Develop in java <br /> Harmony - Subset base class library <br /> GUI, bluetooth, WiFi, telephony, location, other hardware <br />
  • Telephones running UNIX <br /> (OpenCore media library) <br /> Dalvik ~= JVM <br /> Develop in java <br /> Harmony - Subset base class library <br /> GUI, bluetooth, WiFi, telephony, location, other hardware <br />
  • Telephones running UNIX <br /> (OpenCore media library) <br /> Dalvik ~= JVM <br /> Develop in java <br /> Harmony - Subset base class library <br /> GUI, bluetooth, WiFi, telephony, location, other hardware <br />
  • Telephones running UNIX <br /> (OpenCore media library) <br /> Dalvik ~= JVM <br /> Develop in java <br /> Harmony - Subset base class library <br /> GUI, bluetooth, WiFi, telephony, location, other hardware <br />
  • Telephones running UNIX <br /> (OpenCore media library) <br /> Dalvik ~= JVM <br /> Develop in java <br /> Harmony - Subset base class library <br /> GUI, bluetooth, WiFi, telephony, location, other hardware <br />
  • Telephones running UNIX <br /> (OpenCore media library) <br /> Dalvik ~= JVM <br /> Develop in java <br /> Harmony - Subset base class library <br /> GUI, bluetooth, WiFi, telephony, location, other hardware <br />
  • Telephones running UNIX <br /> (OpenCore media library) <br /> Dalvik ~= JVM <br /> Develop in java <br /> Harmony - Subset base class library <br /> GUI, bluetooth, WiFi, telephony, location, other hardware <br />
  • Telephones running UNIX <br /> (OpenCore media library) <br /> Dalvik ~= JVM <br /> Develop in java <br /> Harmony - Subset base class library <br /> GUI, bluetooth, WiFi, telephony, location, other hardware <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • Build system <br /> Used in Scala-community <br /> <br />
  • <br />
  • build.properties <br /> Version, project name, scala version <br /> build - project definition <br /> plugins - definition of plugins used <br />
  • build.properties <br /> Version, project name, scala version <br /> build - project definition <br /> plugins - definition of plugins used <br />
  • build.properties <br /> Version, project name, scala version <br /> build - project definition <br /> plugins - definition of plugins used <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • ProjectInfo - external properties, paths <br /> Eclipsify <br /> Eclipse for nice colours <br />
  • ProjectInfo - external properties, paths <br /> Eclipsify <br /> Eclipse for nice colours <br />
  • ProjectInfo - external properties, paths <br /> Eclipsify <br /> Eclipse for nice colours <br />
  • ProGuard <br /> Reflection <br /> Hello world example -> 5kb <br /> Littlebro + 2.7.7 -> 100kb <br /> Littlebro + 2.8.0 -> 200kb <br />
  • ProGuard <br /> Reflection <br /> Hello world example -> 5kb <br /> Littlebro + 2.7.7 -> 100kb <br /> Littlebro + 2.8.0 -> 200kb <br />
  • ProGuard <br /> Reflection <br /> Hello world example -> 5kb <br /> Littlebro + 2.7.7 -> 100kb <br /> Littlebro + 2.8.0 -> 200kb <br />
  • ProGuard <br /> Reflection <br /> Hello world example -> 5kb <br /> Littlebro + 2.7.7 -> 100kb <br /> Littlebro + 2.8.0 -> 200kb <br />
  • ProGuard <br /> Reflection <br /> Hello world example -> 5kb <br /> Littlebro + 2.7.7 -> 100kb <br /> Littlebro + 2.8.0 -> 200kb <br />
  • ProGuard <br /> Reflection <br /> Hello world example -> 5kb <br /> Littlebro + 2.7.7 -> 100kb <br /> Littlebro + 2.8.0 -> 200kb <br />
  • ProGuard <br /> Reflection <br /> Hello world example -> 5kb <br /> Littlebro + 2.7.7 -> 100kb <br /> Littlebro + 2.8.0 -> 200kb <br />
  • ProGuard <br /> Reflection <br /> Hello world example -> 5kb <br /> Littlebro + 2.7.7 -> 100kb <br /> Littlebro + 2.8.0 -> 200kb <br />
  • ProGuard <br /> Reflection <br /> Hello world example -> 5kb <br /> Littlebro + 2.7.7 -> 100kb <br /> Littlebro + 2.8.0 -> 200kb <br />
  • ProGuard <br /> Reflection <br /> Hello world example -> 5kb <br /> Littlebro + 2.7.7 -> 100kb <br /> Littlebro + 2.8.0 -> 200kb <br />
  • ProGuard <br /> Reflection <br /> Hello world example -> 5kb <br /> Littlebro + 2.7.7 -> 100kb <br /> Littlebro + 2.8.0 -> 200kb <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • R[esources].java <br /> Aids resource lookup <br />
  • <br />
  • Type lost <br />
  • Type lost <br />
  • Type lost <br />
  • Type lost <br />
  • Needs cast <br /> Scala accepts casting very reluctantly <br /> asInstanceOf is a method (final) <br /> Accept a generic argument <br />
  • Needs cast <br /> Scala accepts casting very reluctantly <br /> asInstanceOf is a method (final) <br /> Accept a generic argument <br />
  • Needs cast <br /> Scala accepts casting very reluctantly <br /> asInstanceOf is a method (final) <br /> Accept a generic argument <br />
  • Needs cast <br /> Scala accepts casting very reluctantly <br /> asInstanceOf is a method (final) <br /> Accept a generic argument <br />
  • Needs cast <br /> Scala accepts casting very reluctantly <br /> asInstanceOf is a method (final) <br /> Accept a generic argument <br />
  • Generated by SBT android plugin <br /> with TypedActivity <br />
  • Generated by SBT android plugin <br /> with TypedActivity <br />
  • Generated by SBT android plugin <br /> with TypedActivity <br />
  • Generated by SBT android plugin <br /> with TypedActivity <br />
  • Generated by SBT android plugin <br /> with TypedActivity <br />
  • <br />
  • <br />
  • In java <br /> In scala <br /> Can we do better? <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • Button extends View <br /> Can not add functions <br />
  • Button extends View <br /> Can not add functions <br />
  • Button extends View <br /> Can not add functions <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • Add methods to class <br /> Implicit conversion <br /> Must be imported <br /> onClick <br /> View => Unit <br />
  • Add methods to class <br /> Implicit conversion <br /> Must be imported <br /> onClick <br /> View => Unit <br />
  • Add methods to class <br /> Implicit conversion <br /> Must be imported <br /> onClick <br /> View => Unit <br />
  • Add methods to class <br /> Implicit conversion <br /> Must be imported <br /> onClick <br /> View => Unit <br />
  • Add methods to class <br /> Implicit conversion <br /> Must be imported <br /> onClick <br /> View => Unit <br />
  • Add methods to class <br /> Implicit conversion <br /> Must be imported <br /> onClick <br /> View => Unit <br />
  • Add methods to class <br /> Implicit conversion <br /> Must be imported <br /> onClick <br /> View => Unit <br />
  • Add methods to class <br /> Implicit conversion <br /> Must be imported <br /> onClick <br /> View => Unit <br />
  • Add methods to class <br /> Implicit conversion <br /> Must be imported <br /> onClick <br /> View => Unit <br />
  • Add methods to class <br /> Implicit conversion <br /> Must be imported <br /> onClick <br /> View => Unit <br />
  • <br />
  • I.e calculation or network <br /> 5 seconds & a touch <br /> Developer guide <br /> Design for responsiveness <br />
  • <br />
  • Android provided asynchronous task <br /> Drawback: Single thread; not thread pool <br />
  • Android provided asynchronous task <br /> Drawback: Single thread; not thread pool <br />
  • Android provided asynchronous task <br /> Drawback: Single thread; not thread pool <br />
  • Android provided asynchronous task <br /> Drawback: Single thread; not thread pool <br />
  • Android provided asynchronous task <br /> Drawback: Single thread; not thread pool <br />
  • We need to update GUI <br />
  • Activity.runOnUiThread(Runnable) <br />
  • Activity.runOnUiThread(Runnable) <br />
  • Activity.runOnUiThread(Runnable) <br />
  • Activity.runOnUiThread(Runnable) <br />
  • Combined version <br /> Drop noise code <br /> Same trick as with listeners <br />
  • Combined version <br /> Drop noise code <br /> Same trick as with listeners <br />
  • Combined version <br /> Drop noise code <br /> Same trick as with listeners <br />
  • Combined version <br /> Drop noise code <br /> Same trick as with listeners <br />
  • Combined version <br /> Drop noise code <br /> Same trick as with listeners <br />
  • Combined version <br /> Drop noise code <br /> Same trick as with listeners <br />
  • Combined version <br /> Drop noise code <br /> Same trick as with listeners <br />
  • Combined version <br /> Drop noise code <br /> Same trick as with listeners <br />
  • Drop more noise code <br /> Drop AsyncTask object <br /> Drop execute <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • Pass data needed with success and failure path <br />
  • Pass data needed with success and failure path <br />
  • Pass data needed with success and failure path <br />
  • Pass data needed with success and failure path <br />
  • Pass data needed with success and failure path <br />
  • Pass data needed with success and failure path <br />
  • Pass data needed with success and failure path <br />
  • Pass data needed with success and failure path <br />
  • Pass data needed with success and failure path <br />
  • Pass data needed with success and failure path <br />
  • Pass data needed with success and failure path <br />
  • Pass data needed with success and failure path <br />
  • Pass data needed with success and failure path <br />
  • Pass data needed with success and failure path <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />

Scala on androids Scala on androids Presentation Transcript

  • Scala on Androids Thor Åge Eldby @thoraageeldby 1
  • Me C/C ++ a av lJ na so J2M r Pe E Java An dro id Scala 2
  • Arktekk • Started 2007 • Consultancy and training 3
  • Android Fringe to mainstream 4
  • Android 101 5
  • Android 101 Linux 5
  • Android 101 OpenCore Linux 5
  • Android 101 OpenCore SQLite Linux 5
  • Android 101 OpenGL OpenCore SQLite ES Linux 5
  • Android 101 OpenGL OpenCore SQLite WebKit ES Linux 5
  • Android 101 OpenGL OpenCore SQLite WebKit Other ES Linux 5
  • Android 101 Dalvik OpenGL OpenCore SQLite WebKit Other ES Linux 5
  • Android 101 Apache Harmony Dalvik OpenGL OpenCore SQLite WebKit Other ES Linux 5
  • Android 101 Apache HttpClient Harmony Dalvik OpenGL OpenCore SQLite WebKit Other ES Linux 5
  • Android 101 Apache HttpClient org.json Harmony Dalvik OpenGL OpenCore SQLite WebKit Other ES Linux 5
  • Android 101 Apache HttpClient org.json DOM/SAX Harmony Dalvik OpenGL OpenCore SQLite WebKit Other ES Linux 5
  • Android 101 Apache HttpClient org.json DOM/SAX Android Harmony Dalvik OpenGL OpenCore SQLite WebKit Other ES Linux 5
  • Android SDK
  • Android SDK .java files
  • Android SDK .java files
  • Android SDK .java files javac
  • Android SDK .java files javac
  • Android SDK .java files javac .class files
  • Android SDK .java files javac .class files
  • Android SDK .java files javac .class files dx
  • Android SDK .java files javac .class files dx
  • Android SDK .java files javac .class files .dex dx file
  • Android SDK .java files javac .class files .dex dx file
  • Android SDK .java files javac .class files .dex resou- dx file rces
  • Android SDK .java files javac .class files .dex resou- dx file rces
  • Android SDK .java files javac aapt .class files .dex resou- dx file rces
  • Android SDK .java files javac aapt .class files .dex resou- dx file rces
  • Android SDK .java files .apk file javac aapt .class files .dex resou- dx file rces
  • Android SDK .java files .apk file javac aapt .class files .dex resou- dx file rces
  • Android SDK .java adb files .apk file javac aapt .class files .dex resou- dx file rces
  • Android SDK .java adb files .apk file javac aapt .class files .dex resou- dx file rces
  • Android SDK .java adb files .apk file javac aapt .class files .dex resou- dx file rces
  • Android SDK .java adb files .apk file javac aapt .class files .dex resou- dx file rces 6
  • Android Development Components 7
  • Android Development Components Activity Text Text Done Cancel 7
  • Android Development Components Activity Service Text Text Done Cancel 7
  • Android Development Components Activity Service Broadcast- Receiver Text Text Done Cancel 7
  • Android Development Components Activity Service Broadcast- Receiver Text Text Done Cancel Intent 7
  • Android Development Components Activity Service Broadcast- Receiver Text Text Done Cancel Intent 7
  • Android Development Components Activity Service Broadcast- Receiver Text Text Done Cancel Intent 7
  • Littlebro http://github.com/thoraage/littlebro-android http://github.com/thoraage/jmx-rest-access 8
  • Overview Android Littlebro 9
  • Overview Android Littlebro Jetty / LIFT JMX REST Access 9
  • Overview Android Littlebro Jetty / LIFT JMX REST Access Glassfish JMX 9
  • Demo 10
  • SBT • http://code.google.com/p/simple-build-tool/ 11
  • SBT • Command line • Maven source structure • Configured in Scala 12
  • SBT Structure |-- project | |-- build | | `-- Littlebro.scala | |-- build.properties | `-- plugins | `-- Plugins.scala 13
  • SBT Structure |-- project | |-- build | | `-- Littlebro.scala | |-- build.properties | `-- plugins | `-- Plugins.scala 13
  • SBT Structure |-- project | |-- build | | `-- Littlebro.scala | |-- build.properties | `-- plugins | `-- Plugins.scala 13
  • SBT Structure |-- project | |-- build | | `-- Littlebro.scala | |-- build.properties | `-- plugins | `-- Plugins.scala 13
  • Scala 101 Traits trait A { def a = "aaa" } trait B { def b = "bbb" } 14
  • Scala 101 Traits trait A { def a = "aaa" } trait B { def b = "bbb" } class C extends A with B { def c = "ccc" } 14
  • Scala 101 Traits trait A { def a = "aaa" } trait B { def b = "bbb" } class C extends A with B { def c = "ccc" } val c = new C println(c.a + c.b + c.c) 14
  • Scala 101 Traits trait A { def a = "aaa" } trait B { def b = "bbb" } class C extends A with B { def c = "ccc" } val c = new C println(c.a + c.b + c.c) 14
  • Scala 101 Traits trait A { def a = "aaa" } trait B { def b = "bbb" } class C extends A with B { def c = "ccc" } val c = new C println(c.a + c.b + c.c) aaabbbccc 14
  • Project class Littlebro(info: ProjectInfo) extends AndroidProject(info) with TypedResources with Eclipsify { override def androidPlatformName = "android-1.5" } 15
  • Project class Littlebro(info: ProjectInfo) extends AndroidProject(info) with TypedResources with Eclipsify { override def androidPlatformName = "android-1.5" } 15
  • Project class Littlebro(info: ProjectInfo) extends AndroidProject(info) with TypedResources with Eclipsify { override def androidPlatformName = "android-1.5" } 15
  • Project class Littlebro(info: ProjectInfo) extends AndroidProject(info) with TypedResources with Eclipsify { override def androidPlatformName = "android-1.5" } 15
  • SBT & Android • http://github.com/jberkel/android-plugin 16
  • SBT & Android • http://github.com/jberkel/android-plugin scalac 16
  • SBT & Android • http://github.com/jberkel/android-plugin scalac 16
  • SBT & Android • http://github.com/jberkel/android-plugin scalac .class files 16
  • SBT & Android • http://github.com/jberkel/android-plugin scalac .class files 16
  • SBT & Android • http://github.com/jberkel/android-plugin scalac .class files ProGuard 16
  • SBT & Android • http://github.com/jberkel/android-plugin scalac .class files ProGuard 16
  • SBT & Android • http://github.com/jberkel/android-plugin scalac .class files less .class ProGuard files 16
  • SBT & Android • http://github.com/jberkel/android-plugin scalac .class files less .class ProGuard files 16
  • SBT & Android • http://github.com/jberkel/android-plugin scalac .class files less .class ProGuard files dx 16
  • SBT & Android • http://github.com/jberkel/android-plugin scalac .class files less .class ProGuard files dx 16
  • SBT & Android • http://github.com/jberkel/android-plugin scalac ... .class files less .class ProGuard files dx 16
  • Demo 17
  • SBT & Idea • http://github.com/mpeltonen/sbt-idea-plugin • Hacked to work with sbt-android-plugin: http://github.com/thoraage/sbt-idea-plugin • Generates project files • SBT processor 18
  • SBT & Eclipse • http://github.com/musk/SbtEclipsify • Not tested with Android 19
  • Scala on Androids Quick wins 20
  • Resources Resource xml’s and R.java 21
  • Layout definition <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:a="http://schemas.android.com/apk/res/android" ...> <TextView a:text="@string/host_address_text" .../> <EditText a:id="@+id/hostAddress" .../> <Button a:id="@+id/login" a:text="@string/login_button_text" .../> </LinearLayout> 22
  • Layout definition <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:a="http://schemas.android.com/apk/res/android" ...> <TextView a:text="@string/host_address_text" .../> <EditText a:id="@+id/hostAddress" .../> <Button a:id="@+id/login" a:text="@string/login_button_text" .../> </LinearLayout> 22
  • R.java public final class R { ... public static final class id { public static final int login=0x7f050001; } ... public static final class string { public static final int login_button_text=0x7f040003; } } 23
  • R.java public final class R { ... public static final class id { public static final int login=0x7f050001; } ... public static final class string { public static final int login_button_text=0x7f040003; } } 23
  • R.java public final class R { ... public static final class id { public static final int login=0x7f050001; } ... public static final class string { public static final int login_button_text=0x7f040003; } } 23
  • R.java Button? public final class R { ... public static final class id { public static final int login=0x7f050001; } ... public static final class string { public static final int login_button_text=0x7f040003; } } 23
  • R.java public final class R { ... public static final class id { public static final int login=0x7f050001; } ... public static final class string { public static final int login_button_text=0x7f040003; } } 23
  • R.java usage • In java • Button login = (Button) findViewById(R.id.login); 24
  • R.java usage • In java • Button login = (Button) findViewById(R.id.login); 24
  • R.java usage • In java • Button login = (Button) findViewById(R.id.login); 24
  • R.java usage • In java • Button login = (Button) findViewById(R.id.login); • In Scala • val login = findViewById(R.id.login).asInstanceOf[Button] 24
  • R.java usage • In java • Button login = (Button) findViewById(R.id.login); • In Scala • val login = findViewById(R.id.login).asInstanceOf[Button] 24
  • R.java usage • In java • Button login = (Button) findViewById(R.id.login); • In Scala • val login = findViewById(R.id.login).asInstanceOf[Button] 24
  • TR.scala ... object TR { val login = TypedResource[android.widget.Button](R.id.login) } ... trait TypedActivityHolder { def activity: Activity def findView[T](tr: TypedResource[T]) = activity.findViewById(tr.id).asInstanceOf[T] } trait TypedActivity extends Activity with TypedActivityHolder { def activity = this } 25
  • TR.scala ... object TR { val login = TypedResource[android.widget.Button](R.id.login) } ... trait TypedActivityHolder { def activity: Activity def findView[T](tr: TypedResource[T]) = activity.findViewById(tr.id).asInstanceOf[T] } trait TypedActivity extends Activity with TypedActivityHolder { def activity = this } 25
  • TR.scala ... object TR { val login = TypedResource[android.widget.Button](R.id.login) } ... trait TypedActivityHolder { def activity: Activity def findView[T](tr: TypedResource[T]) = activity.findViewById(tr.id).asInstanceOf[T] } trait TypedActivity extends Activity with TypedActivityHolder { def activity = this } 25
  • TR.scala ... object TR { val login = TypedResource[android.widget.Button](R.id.login) } ... trait TypedActivityHolder { def activity: Activity def findView[T](tr: TypedResource[T]) = activity.findViewById(tr.id).asInstanceOf[T] } trait TypedActivity extends Activity with TypedActivityHolder { def activity = this } 25
  • TR.scala ... object TR { val login = TypedResource[android.widget.Button](R.id.login) } ... trait TypedActivityHolder { def activity: Activity def findView[T](tr: TypedResource[T]) = activity.findViewById(tr.id).asInstanceOf[T] } trait TypedActivity extends Activity with TypedActivityHolder { def activity = this } 25
  • TR.scala ... object TR { val login = TypedResource[android.widget.Button](R.id.login) } ... trait TypedActivityHolder { def activity: Activity def findView[T](tr: TypedResource[T]) = activity.findViewById(tr.id).asInstanceOf[T] } trait TypedActivity extends Activity with TypedActivityHolder { def activity = this } 25
  • TR.java usage • With TR.scala • val login = findView(TR.login) 26
  • Listeners 27
  • Listeners login.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { ... } } 28
  • Listeners login.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { ... } } login.setOnClickListener(new View.OnClickListener() { override def onClick(view: View) { ... } }) 28
  • Scala 101 Anonymous functions class Printer[A](list: List[A]) { def printSome(p: A => Boolean): Unit = for (elem <- list) if (p(elem)) println(elem.toString) } 29
  • Scala 101 Anonymous functions class Printer[A](list: List[A]) { def printSome(p: A => Boolean): Unit = for (elem <- list) if (p(elem)) println(elem.toString) } 29
  • Scala 101 Anonymous functions class Printer[A](list: List[A]) { def printSome(p: A => Boolean): Unit = for (elem <- list) if (p(elem)) println(elem.toString) } 29
  • Scala 101 Anonymous functions class Printer[A](list: List[A]) { def printSome(p: A => Boolean): Unit = for (elem <- list) if (p(elem)) println(elem.toString) } 29
  • Scala 101 Anonymous functions class Printer[A](list: List[A]) { def printSome(p: A => Boolean): Unit = for (elem <- list) if (p(elem)) println(elem.toString) } 29
  • Scala 101 Anonymous functions class Printer[A](list: List[A]) { def printSome(p: A => Boolean): Unit = for (elem <- list) if (p(elem)) println(elem.toString) } val printer = new Printer(List("yo", "doh", "hi")) printer.printSome { e => e.contains("o") } 29
  • Scala 101 Anonymous functions class Printer[A](list: List[A]) { def printSome(p: A => Boolean): Unit = for (elem <- list) if (p(elem)) println(elem.toString) } val printer = new Printer(List("yo", "doh", "hi")) printer.printSome { e => e.contains("o") } 29
  • Scala 101 Anonymous functions class Printer[A](list: List[A]) { def printSome(p: A => Boolean): Unit = for (elem <- list) if (p(elem)) println(elem.toString) } val printer = new Printer(List("yo", "doh", "hi")) printer.printSome { e => e.contains("o") } 29
  • Scala 101 Anonymous functions class Printer[A](list: List[A]) { def printSome(p: A => Boolean): Unit = for (elem <- list) if (p(elem)) println(elem.toString) } val printer = new Printer(List("yo", "doh", "hi")) printer.printSome { e => e.contains("o") } 29
  • Scala 101 Anonymous functions class Printer[A](list: List[A]) { def printSome(p: A => Boolean): Unit = for (elem <- list) if (p(elem)) println(elem.toString) } val printer = new Printer(List("yo", "doh", "hi")) printer.printSome { e => e.contains("o") } 29
  • Scala 101 Anonymous functions class Printer[A](list: List[A]) { def printSome(p: A => Boolean): Unit = for (elem <- list) if (p(elem)) println(elem.toString) } val printer = new Printer(List("yo", "doh", "hi")) printer.printSome { e => e.contains("o") } printer.printSome(_.contains("o")) 29
  • Scala 101 Anonymous functions class Printer[A](list: List[A]) { def printSome(p: A => Boolean): Unit = for (elem <- list) if (p(elem)) println(elem.toString) } val printer = new Printer(List("yo", "doh", "hi")) printer.printSome { e => e.contains("o") } printer.printSome(_.contains("o")) 29
  • Listeners def onClick(f: View => Unit) { setOnClickListener(new View.OnClickListener { override def onClick(v: View) = f(v) }) } 30
  • Listeners def onClick(f: View => Unit) { setOnClickListener(new View.OnClickListener { override def onClick(v: View) = f(v) }) } 30
  • Listeners def onClick(f: View => Unit) { setOnClickListener(new View.OnClickListener { override def onClick(v: View) = f(v) }) } 30
  • Listeners def onClick(f: View => Unit) { setOnClickListener(new View.OnClickListener { override def onClick(v: View) = f(v) }) } login.onClick { view => ... } 30
  • Scala 101 Implicit conversion class AmendedString(s: String) { def rot13 = new String(for (c <- s) yield rotC(c)) def rotC(c: Char) = (((c - 97) + 13) % 26 + 97).asInstanceOf[Char] } 31
  • Scala 101 Implicit conversion class AmendedString(s: String) { def rot13 = new String(for (c <- s) yield rotC(c)) def rotC(c: Char) = (((c - 97) + 13) % 26 + 97).asInstanceOf[Char] } 31
  • Scala 101 Implicit conversion class AmendedString(s: String) { def rot13 = new String(for (c <- s) yield rotC(c)) def rotC(c: Char) = (((c - 97) + 13) % 26 + 97).asInstanceOf[Char] } 31
  • Scala 101 Implicit conversion class AmendedString(s: String) { def rot13 = new String(for (c <- s) yield rotC(c)) def rotC(c: Char) = (((c - 97) + 13) % 26 + 97).asInstanceOf[Char] } new AmendedString("yodude").rot13 31
  • Scala 101 Implicit conversion class AmendedString(s: String) { def rot13 = new String(for (c <- s) yield rotC(c)) def rotC(c: Char) = (((c - 97) + 13) % 26 + 97).asInstanceOf[Char] } new AmendedString("yodude").rot13 implicit def string2amendedString(s: String) = new AmendedString(s) 31
  • Scala 101 Implicit conversion class AmendedString(s: String) { def rot13 = new String(for (c <- s) yield rotC(c)) def rotC(c: Char) = (((c - 97) + 13) % 26 + 97).asInstanceOf[Char] } new AmendedString("yodude").rot13 implicit def string2amendedString(s: String) = new AmendedString(s) 31
  • Scala 101 Implicit conversion class AmendedString(s: String) { def rot13 = new String(for (c <- s) yield rotC(c)) def rotC(c: Char) = (((c - 97) + 13) % 26 + 97).asInstanceOf[Char] } new AmendedString("yodude").rot13 implicit def string2amendedString(s: String) = new AmendedString(s) 31
  • Scala 101 Implicit conversion class AmendedString(s: String) { def rot13 = new String(for (c <- s) yield rotC(c)) def rotC(c: Char) = (((c - 97) + 13) % 26 + 97).asInstanceOf[Char] } new AmendedString("yodude").rot13 implicit def string2amendedString(s: String) = new AmendedString(s) 31
  • Scala 101 Implicit conversion class AmendedString(s: String) { def rot13 = new String(for (c <- s) yield rotC(c)) def rotC(c: Char) = (((c - 97) + 13) % 26 + 97).asInstanceOf[Char] } new AmendedString("yodude").rot13 implicit def string2amendedString(s: String) = new AmendedString(s) "yodude".rot13 31
  • Scala 101 Implicit conversion class AmendedString(s: String) { def rot13 = new String(for (c <- s) yield rotC(c)) def rotC(c: Char) = (((c - 97) + 13) % 26 + 97).asInstanceOf[Char] } new AmendedString("yodude").rot13 implicit def string2amendedString(s: String) = new AmendedString(s) "yodude".rot13 31
  • Scala 101 Implicit conversion class AmendedString(s: String) { def rot13 = new String(for (c <- s) yield rotC(c)) def rotC(c: Char) = (((c - 97) + 13) % 26 + 97).asInstanceOf[Char] } new AmendedString("yodude").rot13 implicit def string2amendedString(s: String) = new AmendedString(s) "yodude".rot13 lbqhqr 31
  • Listeners class AmendedView(view: View) { def onClick(f: View => Unit) { view.setOnClickListener(new View.OnClickListener { override def onClick(v: View) = f(v) }) } } 32
  • Listeners class AmendedView(view: View) { def onClick(f: View => Unit) { view.setOnClickListener(new View.OnClickListener { override def onClick(v: View) = f(v) }) } } 32
  • Listeners class AmendedView(view: View) { def onClick(f: View => Unit) { view.setOnClickListener(new View.OnClickListener { override def onClick(v: View) = f(v) }) } } 32
  • Listeners class AmendedView(view: View) { def onClick(f: View => Unit) { view.setOnClickListener(new View.OnClickListener { override def onClick(v: View) = f(v) }) } } 32
  • Listeners class AmendedView(view: View) { def onClick(f: View => Unit) { view.setOnClickListener(new View.OnClickListener { override def onClick(v: View) = f(v) }) } } 32
  • Listeners class AmendedView(view: View) { def onClick(f: View => Unit) { view.setOnClickListener(new View.OnClickListener { override def onClick(v: View) = f(v) }) } } implicit def view2AmendedView(view: View) = new AmendedView(view) 32
  • Listeners class AmendedView(view: View) { def onClick(f: View => Unit) { view.setOnClickListener(new View.OnClickListener { override def onClick(v: View) = f(v) }) } } implicit def view2AmendedView(view: View) = new AmendedView(view) 32
  • Listeners class AmendedView(view: View) { def onClick(f: View => Unit) { view.setOnClickListener(new View.OnClickListener { override def onClick(v: View) = f(v) }) } } implicit def view2AmendedView(view: View) = new AmendedView(view) 32
  • Listeners class AmendedView(view: View) { def onClick(f: View => Unit) { view.setOnClickListener(new View.OnClickListener { override def onClick(v: View) = f(v) }) } } implicit def view2AmendedView(view: View) = new AmendedView(view) 32
  • Listeners class AmendedView(view: View) { def onClick(f: View => Unit) { view.setOnClickListener(new View.OnClickListener { override def onClick(v: View) = f(v) }) } } implicit def view2AmendedView(view: View) = new AmendedView(view) 32
  • Listeners class AmendedView(view: View) { def onClick(f: View => Unit) { view.setOnClickListener(new View.OnClickListener { override def onClick(v: View) = f(v) }) } } implicit def view2AmendedView(view: View) = new AmendedView(view) login.onClick { view => ... } 32
  • Concurrency 33
  • Responsiveness • Separate work and GUI GUI thread 34
  • Responsiveness • Separate work and GUI GUI thread 34
  • Responsiveness GUI thread worker Start worker 35
  • Responsiveness new AsyncTask[Object, Void, Object]() { override def doInBackground(objects: Object*): Object = { ... do hard work } }.execute() 36
  • Responsiveness new AsyncTask[Object, Void, Object]() { override def doInBackground(objects: Object*): Object = { ... do hard work } }.execute() 36
  • Responsiveness new AsyncTask[Object, Void, Object]() { override def doInBackground(objects: Object*): Object = { ... do hard work } }.execute() 36
  • Responsiveness new AsyncTask[Object, Void, Object]() { override def doInBackground(objects: Object*): Object = { ... do hard work } }.execute() 36
  • Responsiveness new AsyncTask[Object, Void, Object]() { override def doInBackground(objects: Object*): Object = { ... do hard work } }.execute() 36
  • Responsiveness new AsyncTask[Object, Void, Object]() { override def doInBackground(objects: Object*): Object = { ... do hard work } }.execute() 36
  • Responsiveness GUI thread worker Start worker Update GUI 37
  • Responsiveness runOnUiThread(new Runnable() { def run: Unit = { ... update GUI } }) 38
  • Responsiveness runOnUiThread(new Runnable() { def run: Unit = { ... update GUI } }) 38
  • Responsiveness runOnUiThread(new Runnable() { def run: Unit = { ... update GUI } }) 38
  • Responsiveness runOnUiThread(new Runnable() { def run: Unit = { ... update GUI } }) 38
  • Responsiveness runOnUiThread(new Runnable() { def run: Unit = { ... update GUI } }) 38
  • Responsiveness new AsyncTask[Object, Void, Object]() { override def doInBackground(objects: Object*): Object = { ... do hard work runOnUiThread(new Runnable() { def run: Unit = { ... update GUI } }) } }.execute() 39
  • Responsiveness new AsyncTask[Object, Void, Object]() { override def doInBackground(objects: Object*): Object = { ... do hard work runOnUiThread(new Runnable() { def run: Unit = { ... update GUI } }) } }.execute() 39
  • Responsiveness new AsyncTask[Object, Void, Object]() { override def doInBackground(objects: Object*): Object = { ... do hard work runOnUiThread(new Runnable() { def run: Unit = { ... update GUI } }) } }.execute() 39
  • Responsiveness new AsyncTask[Object, Void, Object]() { override def doInBackground(objects: Object*): Object = { ... do hard work runOnUiThread(new Runnable() { def run: Unit = { ... update GUI } }) } }.execute() 39
  • Responsiveness new AsyncTask[Object, Void, Object]() { override def doInBackground(objects: Object*): Object = { ... do hard work runOnUiThread(new Runnable() { def run: Unit = { ... update GUI } }) } }.execute() 39
  • Responsiveness new AsyncTask[Object, Void, Object]() { override def doInBackground(objects: Object*): Object = { ... do hard work runOnUiThread(new Runnable() { def run: Unit = { ... update GUI } }) } }.execute() 39
  • Responsiveness new AsyncTask[Object, Void, Object]() { override def doInBackground(objects: Object*): Object = { ... do hard work runOnUiThread(new Runnable() { def run: Unit = { ... update GUI } }) } }.execute() 39
  • Responsiveness new AsyncTask[Object, Void, Object]() { override def doInBackground(objects: Object*): Object = { ... do hard work runOnUiThread(new Runnable() { def run: Unit = { ... update GUI } }) } }.execute() 39
  • Responsiveness new AsyncTask[Object, Void, Object]() { override def doInBackground(objects: Object*): Object = { ... do hard work runOnUiThread(new Runnable() { def run: Unit = { ... update GUI } }) } }.execute() 39
  • Responsiveness new AsyncTask[Object, Void, Object]() { override def doInBackground(objects: Object*): Object = { ... do hard work onUiThread { ... update GUI } } }.execute() 40
  • Responsiveness asyncTask { ... do hard work onUiThread { ... update GUI } } 41
  • Further 42
  • Actors Organizing with asynchronous message passing 43
  • Scala 101 Actors object MyActor extends Actor { def act { loop { react { case msg:String => println(msg) case other => println("Say what") } } } start } 44
  • Scala 101 Actors object MyActor extends Actor { def act { loop { react { case msg:String => println(msg) case other => println("Say what") } } } start } 44
  • Scala 101 Actors object MyActor extends Actor { def act { loop { react { case msg:String => println(msg) case other => println("Say what") } } } start } 44
  • Scala 101 Actors object MyActor extends Actor { def act { loop { react { case msg:String => println(msg) case other => println("Say what") } } } start } 44
  • Scala 101 Actors object MyActor extends Actor { def act { loop { react { case msg:String => println(msg) case other => println("Say what") } } } start } 44
  • Scala 101 Actors object MyActor extends Actor { def act { loop { react { case msg:String => println(msg) case other => println("Say what") } } } start } 44
  • Scala 101 Actors object MyActor extends Actor { def act { loop { react { case msg:String => println(msg) case other => println("Say what") } } } start } 44
  • Scala 101 Actors object MyActor extends Actor { def act { loop { react { case msg:String => println(msg) case other => println("Say what") } } } start } 44
  • Scala 101 Actors object MyActor extends Actor { def act { loop { react { case msg:String => println(msg) case other => println("Say what") } } } start } 44
  • Scala 101 Actors object MyActor extends Actor { def act { loop { react { case msg:String => println(msg) case other => println("Say what") } } } start } 44
  • Scala 101 Actors object MyActor extends Actor { def act { loop { react { case msg:String => println(msg) case other => println("Say what") } } } start } 44
  • Scala 101 Actors object MyActor extends Actor { def act { loop { react { case msg:String => println(msg) case other => println("Say what") } } } start } 44
  • Scala 101 Actors object MyActor extends Actor { def act { loop { react { case msg:String => println(msg) case other => println("Say what") } } } start } 44
  • Scala 101 Actors object MyActor extends Actor { def act { loop { react { case msg:String => println(msg) case other => println("Say what") } } } start } 44
  • Scala 101 Actors object MyActor extends Actor { def act { loop { react { case msg:String => println(msg) case other => println("Say what") } } } start } MyActor ! "Yo dude" 44
  • Scala 101 Actors object MyActor extends Actor { def act { loop { react { case msg:String => println(msg) case other => println("Say what") } } } start } MyActor ! "Yo dude" 44
  • Scala 101 Actors object MyActor extends Actor { def act { loop { react { case msg:String => println(msg) case other => println("Say what") } } } start } MyActor ! "Yo dude" 44
  • Scala 101 Actors object MyActor extends Actor { def act { loop { react { case msg:String => println(msg) case other => println("Say what") } } } start } MyActor ! "Yo dude" 44
  • Scala 101 Actors object MyActor extends Actor { def act { loop { react { case msg:String => println(msg) case other => println("Say what") } } } start } MyActor ! "Yo dude" Yo dude 44
  • Actors GUI Connection Model Factory ViewStack href, (xml, error) httperror, none xml, (model, error) xmlerror, none model, (model) model, none 45
  • Actors GUI Connection Model Factory ViewStack href, (xml, error) httperror, none xml, (model, error) xmlerror, none model, (model) model, none 45
  • Actors GUI Connection Model Factory ViewStack href, (xml, error) httperror, none xml, (model, error) xmlerror, none model, (model) model, none 45
  • Actors GUI Connection Model Factory ViewStack href, (xml, error) httperror, none xml, (model, error) xmlerror, none model, (model) model, none 45
  • Actors GUI Connection Model Factory ViewStack href, (xml, error) httperror, none xml, (model, error) xmlerror, none model, (model) model, none 45
  • Actors GUI Connection Model Factory ViewStack href, (xml, error) httperror, none xml, (model, error) xmlerror, none model, (model) model, none 45
  • Actors GUI Connection Model Factory ViewStack href, (xml, error) httperror, none xml, (model, error) xmlerror, none model, (model) model, none 45
  • Actors GUI Connection Model Factory ViewStack href, (xml, error) httperror, none xml, (model, error) xmlerror, none model, (model) model, none 45
  • Actors GUI Connection Model Factory ViewStack href, (xml, error) httperror, none xml, (model, error) xmlerror, none model, (model) model, none 45
  • Actors GUI Connection Model Factory ViewStack href, (xml, error) httperror, none xml, (model, error) xmlerror, none model, (model) model, none 45
  • Actors GUI Connection Model Factory ViewStack href, (xml, error) httperror, none xml, (model, error) xmlerror, none model, (model) model, none 45
  • Actors GUI Connection Model Factory ViewStack href, (xml, error) httperror, none xml, (model, error) xmlerror, none model, (model) model, none 45
  • Actors GUI Connection Model Factory ViewStack href, (xml, error) httperror, none xml, (model, error) xmlerror, none model, (model) model, none 45
  • Actors GUI Connection Model Factory ViewStack href, (xml, error) httperror, none xml, (model, error) xmlerror, none model, (model) model, none 45
  • Actors GUI Connection Model Factory ViewStack href, (xml, error) httperror, none xml, (model, error) xmlerror, none model, (model) model, none 45
  • Actors case class Routing(success: Option[Actor], failure: Option[Actor]) case class HttpRequestMsg(href: URL, routing: Routing) 46
  • Actors case class Routing(success: Option[Actor], failure: Option[Actor]) case class HttpRequestMsg(href: URL, routing: Routing) 46
  • Actors case class Routing(success: Option[Actor], failure: Option[Actor]) case class HttpRequestMsg(href: URL, routing: Routing) 46
  • Actors case class Routing(success: Option[Actor], failure: Option[Actor]) case class HttpRequestMsg(href: URL, routing: Routing) 46
  • Actors case class Routing(success: Option[Actor], failure: Option[Actor]) case class HttpRequestMsg(href: URL, routing: Routing) 46
  • Actors case class Routing(success: Option[Actor], failure: Option[Actor]) case class HttpRequestMsg(href: URL, routing: Routing) 46
  • Actors case class Routing(success: Option[Actor], failure: Option[Actor]) case class HttpRequestMsg(href: URL, routing: Routing) 46
  • Actors case class Routing(success: Option[Actor], failure: Option[Actor]) case class HttpRequestMsg(href: URL, routing: Routing) 46
  • Actors case class Routing(success: Option[Actor], failure: Option[Actor]) case class HttpRequestMsg(href: URL, routing: Routing) 46
  • Actors case class Routing(success: Option[Actor], failure: Option[Actor]) case class HttpRequestMsg(href: URL, routing: Routing) 46
  • Actors case class Routing(success: Option[Actor], failure: Option[Actor]) case class HttpRequestMsg(href: URL, routing: Routing) 46
  • Actors case class Routing(success: Option[Actor], failure: Option[Actor]) case class HttpRequestMsg(href: URL, routing: Routing) retrieveData.onClick { Connection ! new HttpRequestMsg( "http://s.no/dig/url", new Routing(Some(ModelFactory), Some(GUI))) } 46
  • Actors case class Routing(success: Option[Actor], failure: Option[Actor]) case class HttpRequestMsg(href: URL, routing: Routing) retrieveData.onClick { Connection ! new HttpRequestMsg( "http://s.no/dig/url", new Routing(Some(ModelFactory), Some(GUI))) } 46
  • Actors case class Routing(success: Option[Actor], failure: Option[Actor]) case class HttpRequestMsg(href: URL, routing: Routing) retrieveData.onClick { Connection ! new HttpRequestMsg( "http://s.no/dig/url", new Routing(Some(ModelFactory), Some(GUI))) } 46
  • Actors case class Routing(success: Option[Actor], failure: Option[Actor]) case class HttpRequestMsg(href: URL, routing: Routing) retrieveData.onClick { Connection ! new HttpRequestMsg( "http://s.no/dig/url", new Routing(Some(ModelFactory), Some(GUI))) } 46
  • Actors case class Routing(success: Option[Actor], failure: Option[Actor]) case class HttpRequestMsg(href: URL, routing: Routing) retrieveData.onClick { Connection ! new HttpRequestMsg( "http://s.no/dig/url", new Routing(Some(ModelFactory), Some(GUI))) } 46
  • Actors case class Routing(success: Option[Actor], failure: Option[Actor]) case class HttpRequestMsg(href: URL, routing: Routing) retrieveData.onClick { Connection ! new HttpRequestMsg( "http://s.no/dig/url", new Routing(Some(ModelFactory), Some(GUI))) } 46
  • Actors case class Routing(success: Option[Actor], failure: Option[Actor]) case class HttpRequestMsg(href: URL, routing: Routing) retrieveData.onClick { Connection ! new HttpRequestMsg( "http://s.no/dig/url", new Routing(Some(ModelFactory), Some(GUI))) } 46
  • Actors case class Routing(success: Option[Actor], failure: Option[Actor]) case class HttpRequestMsg(href: URL, routing: Routing) retrieveData.onClick { Connection ! new HttpRequestMsg( "http://s.no/dig/url", new Routing(Some(ModelFactory), Some(GUI))) } 46
  • Actors case class Routing(success: Option[Actor], failure: Option[Actor]) case class HttpRequestMsg(href: URL, routing: Routing) retrieveData.onClick { Connection ! new HttpRequestMsg( "http://s.no/dig/url", new Routing(Some(ModelFactory), Some(GUI))) } 46
  • Actors case class Routing(success: Option[Actor], failure: Option[Actor]) case class HttpRequestMsg(href: URL, routing: Routing) retrieveData.onClick { Connection ! new HttpRequestMsg( "http://s.no/dig/url", new Routing(Some(ModelFactory), Some(GUI))) } 46
  • Actors case class Routing(success: Option[Actor], failure: Option[Actor]) case class HttpRequestMsg(href: URL, routing: Routing) retrieveData.onClick { Connection ! new HttpRequestMsg( "http://s.no/dig/url", new Routing(Some(ModelFactory), Some(GUI))) } 46
  • Actors case class Routing(success: Option[Actor], failure: Option[Actor]) case class HttpRequestMsg(href: URL, routing: Routing) retrieveData.onClick { Connection ! new HttpRequestMsg( "http://s.no/dig/url", new Routing(Some(ModelFactory), Some(GUI))) } 46
  • Actors case class Routing(success: Option[Actor], failure: Option[Actor]) case class HttpRequestMsg(href: URL, routing: Routing) retrieveData.onClick { Connection ! new HttpRequestMsg( "http://s.no/dig/url", new Routing(Some(ModelFactory), Some(GUI))) } 46
  • Actor object Connection extends Actor { def retrieve(href: String): Either[Node, Failure] = Right(new Failure()) def act { loop { react { case HttpRequestMsg(href, Routing(success, failure)) => retrieve(href) match { case Left(node) => success.map(_ ! node) case Right(error) => failure.map(_ ! error) } case _ => println("Say what") } } } start } 47
  • Actor object Connection extends Actor { def retrieve(href: String): Either[Node, Failure] = Right(new Failure()) def act { loop { react { case HttpRequestMsg(href, Routing(success, failure)) => retrieve(href) match { case Left(node) => success.map(_ ! node) case Right(error) => failure.map(_ ! error) } case _ => println("Say what") } } } start } 47
  • Actor object Connection extends Actor { def retrieve(href: String): Either[Node, Failure] = Right(new Failure()) def act { loop { react { case HttpRequestMsg(href, Routing(success, failure)) => retrieve(href) match { case Left(node) => success.map(_ ! node) case Right(error) => failure.map(_ ! error) } case _ => println("Say what") } } } start } 47
  • Actor object Connection extends Actor { def retrieve(href: String): Either[Node, Failure] = Right(new Failure()) def act { loop { react { case HttpRequestMsg(href, Routing(success, failure)) => retrieve(href) match { case Left(node) => success.map(_ ! node) case Right(error) => failure.map(_ ! error) } case _ => println("Say what") } } } start } 47
  • Actor object Connection extends Actor { def retrieve(href: String): Either[Node, Failure] = Right(new Failure()) def act { loop { react { case HttpRequestMsg(href, Routing(success, failure)) => retrieve(href) match { case Left(node) => success.map(_ ! node) case Right(error) => failure.map(_ ! error) } case _ => println("Say what") } } } start } 47
  • Actor object Connection extends Actor { def retrieve(href: String): Either[Node, Failure] = Right(new Failure()) def act { loop { react { case HttpRequestMsg(href, Routing(success, failure)) => retrieve(href) match { case Left(node) => success.map(_ ! node) case Right(error) => failure.map(_ ! error) } case _ => println("Say what") } } } start } 47
  • Actor object Connection extends Actor { def retrieve(href: String): Either[Node, Failure] = Right(new Failure()) def act { loop { react { case HttpRequestMsg(href, Routing(success, failure)) => retrieve(href) match { case Left(node) => success.map(_ ! node) case Right(error) => failure.map(_ ! error) } case _ => println("Say what") } } } start } 47
  • Actor object Connection extends Actor { def retrieve(href: String): Either[Node, Failure] = Right(new Failure()) def act { loop { react { case HttpRequestMsg(href, Routing(success, failure)) => retrieve(href) match { case Left(node) => success.map(_ ! node) case Right(error) => failure.map(_ ! error) } case _ => println("Say what") } } } start } 47
  • Actor object Connection extends Actor { def retrieve(href: String): Either[Node, Failure] = Right(new Failure()) def act { loop { react { case HttpRequestMsg(href, Routing(success, failure)) => retrieve(href) match { case Left(node) => success.map(_ ! node) case Right(error) => failure.map(_ ! error) } case _ => println("Say what") } } } start } 47
  • Actor object Connection extends Actor { def retrieve(href: String): Either[Node, Failure] = Right(new Failure()) def act { loop { react { case HttpRequestMsg(href, Routing(success, failure)) => retrieve(href) match { case Left(node) => success.map(_ ! node) case Right(error) => failure.map(_ ! error) } case _ => println("Say what") } } } start } 47
  • Actor object Connection extends Actor { def retrieve(href: String): Either[Node, Failure] = Right(new Failure()) def act { loop { react { case HttpRequestMsg(href, Routing(success, failure)) => retrieve(href) match { case Left(node) => success.map(_ ! node) case Right(error) => failure.map(_ ! error) } case _ => println("Say what") } } } start } 47
  • Actor object Connection extends Actor { def retrieve(href: String): Either[Node, Failure] = Right(new Failure()) def act { loop { react { case HttpRequestMsg(href, Routing(success, failure)) => retrieve(href) match { case Left(node) => success.map(_ ! node) case Right(error) => failure.map(_ ! error) } case _ => println("Say what") } } } start } 47
  • Actor object Connection extends Actor { def retrieve(href: String): Either[Node, Failure] = Right(new Failure()) def act { loop { react { case HttpRequestMsg(href, Routing(success, failure)) => retrieve(href) match { case Left(node) => success.map(_ ! node) case Right(error) => failure.map(_ ! error) } case _ => println("Say what") } } } start } 47
  • Androids on Scala Fini @thoraageeldby 48