Android Programming The Big Nerd Ranch Guide by Bill Phillips, Chris Stewart, Kristin Marsicano (z-lib.org)
For the More Curious: Alternatives to AsyncTask For the More Curious: Alternatives to AsyncTask If you use an AsyncTask to load ...
Chapter 25 HTTP and Background Tasks Challenge: Gson Deserializing JSON in Java objects, as you did in Listing 25.12, is a comm ...
26. Loopers, Handlers, and HandlerThread Now that you have downloaded and parsed JSON from Flickr, your next task is to download ...
Chapter 26 Loopers, Handlers, and HandlerThread Next, update PhotoHolder to hold an ImageView instead of a TextView. Replace bi ...
Preparing RecyclerView to Display Images Update PhotoAdapter’s onBindViewHolder(...) to set the placeholder image as the ImageVi ...
Chapter 26 Loopers, Handlers, and HandlerThread Downloading Lots of Small Things Currently, PhotoGallery’s networking works lik ...
Communicating with the Main Thread In Android, the inbox that threads use is called a message queue. A thread that works by usin ...
Chapter 26 Loopers, Handlers, and HandlerThread Assembling a Background Thread Create a new class called ThumbnailDownloader th ...
Assembling a Background Thread Open PhotoGalleryFragment.java. Give PhotoGalleryFragment a ThumbnailDownloader member variable. ...
Chapter 26 Loopers, Handlers, and HandlerThread Finally, within PhotoAdapter.onBindViewHolder(...), call the thread’s queueThum ...
Handler anatomy The target of a Message is an instance of Handler. You can think of the name Handler as being short for “message ...
Chapter 26 Loopers, Handlers, and HandlerThread Multiple Handlers can be attached to one Looper (Figure 26.5). This means that ...
Using handlers Figure 26.6 shows the object relationships involved. Figure 26.6 Creating a Message and sending it In this case, ...
Chapter 26 Loopers, Handlers, and HandlerThread Next, add code to queueThumbnail(...) to update mRequestMap and to post a new m ...
Using handlers Finally, initialize mRequestHandler and define what that Handler will do when downloaded messages are pulled off ...
Chapter 26 Loopers, Handlers, and HandlerThread You implemented Handler.handleMessage(...) in your Handler subclass within onLo ...
Passing handlers You can also schedule work on the main thread from the background thread using a Handler attached to the main t ...
Chapter 26 Loopers, Handlers, and HandlerThread In ThumbnailDownloader.java, add the mResponseHandler variable seen above to ho ...
Passing handlers Next, modify PhotoGalleryFragment to pass a Handler attached to the main thread to ThumbnailDownloader. Also, s ...
Chapter 26 Loopers, Handlers, and HandlerThread In ThumbnailDownloader.handleRequest(), add the following code. Listing 26.12 ...
«
22
23
24
25
26
27
28
29
30
31
»
Free download pdf