Assembling a Background Thread
Create a new class called ThumbnailDownloader that extends HandlerThread. Your ThumbnailDownloader’s user will need to use some object to identify each download, so give it one generic argument called Token by naming it ThumbnailDownloader<Token> in the class creation dialog. Then give it a constructor and a stub implementation of a method called queueThumbnail() (Listing 27.2).
Listing 27.2 Initial thread code (ThumbnailDownloader.java
)
public class ThumbnailDownloader<Token> extends HandlerThread { private static final String TAG = "ThumbnailDownloader"; public ThumbnailDownloader() ...
Get Android Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.