Created
October 29, 2011 20:11
-
-
Save arschles/1325020 to your computer and use it in GitHub Desktop.
Android PhotosLoader in Scala
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
import scala.actor._ | |
class PhotosLoader extends Actor { | |
override def act() { | |
loop { | |
react { | |
case photoToLoad:PhotoToLoad => | |
val bmp = getBitmap(photoToLoad.url) | |
if(bmp != null) { | |
cache.put(photoToLoad.url, bmp) | |
} | |
val expectedURL = photoToLoad.imageView.getTag.asInstanceOf[String] | |
if (expectedURL.equals(photoToLoad.url)) { | |
photoToLoad.bitmap = bmp; | |
val a = photoToLoad.imageView.getContext().asInstanceOf[Activity] | |
a.runOnUiThread(photoToLoad) | |
} | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment