Created
April 1, 2011 16:37
-
-
Save abscondment/898450 to your computer and use it in GitHub Desktop.
LazyImageView refresh
This file contains hidden or 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
def setSrcUrl(url:String):void | |
@src_url = url | |
@path = File.new(cache_dir, "" + @src_url.hashCode + ".jpg").getCanonicalPath | |
end | |
def load:void | |
unless @loaded || @src_url.nil? || @path.nil? | |
AsyncDownload.new(Handler.new(self), @src_url, @path) | |
end | |
end | |
def refresh:void | |
unless display_from_path() | |
setImageResource @placeholder | |
end | |
end | |
protected | |
def display_from_path | |
d = safe_image_to_drawable(@path, 180) | |
unless d.nil? | |
setImageDrawable(d) | |
@loaded = true | |
else | |
@resizing = false | |
@loaded = false | |
end | |
return @loaded | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment