Android Programming The Big Nerd Ranch Guide, 3rd Edition
Networking Basics 477 Finally, create the PhotoGalleryFragment class. Retain the fragment, inflate the layout you just created, ...
Chapter 25 HTTP and Background Tasks 478 In FlickrFetchr.java, add implementations for getUrlBytes(String) and getUrlString(Str ...
Asking permission to network 479 Asking permission to network One other thing is required to get networking up and running: You ...
Chapter 25 HTTP and Background Tasks 480 Listing 25.5 Writing an AsyncTask, part I (PhotoGalleryFragment.java) public class Ph ...
You and Your Main Thread 481 Now that you have created a background thread and run some networking code on it, let’s take a clos ...
Chapter 25 HTTP and Background Tasks 482 The Flash is like the main thread in your application. It runs all the code that updat ...
Fetching JSON from Flickr 483 Fetching JSON from Flickr JSON stands for JavaScript Object Notation, a format that has become pop ...
Chapter 25 HTTP and Background Tasks 484 Listing 25.7 Adding constants (FlickrFetchr.java) public class FlickrFetchr { private ...
Fetching JSON from Flickr 485 Finally, modify the AsyncTask in PhotoGalleryFragment to call the new fetchItems() method. Listing ...
Chapter 25 HTTP and Background Tasks 486 Now that you have such fine JSON from Flickr, what should you do with it? You do what ...
Parsing JSON text 487 Parsing JSON text The JSON response displayed in your browser and Logcat window is hard to read. If you pr ...
Chapter 25 HTTP and Background Tasks 488 The org.json API provides Java objects corresponding to JSON text, such as JSONObject ...
Parsing JSON text 489 Write a method that pulls out information for each photo. Make a GalleryItem for each photo and add it to ...
Chapter 25 HTTP and Background Tasks 490 The parseItems(...) method needs a List and JSONObject. Update fetchItems() to call pa ...
From AsyncTask Back to the Main Thread 491 From AsyncTask Back to the Main Thread To finish off, let’s switch to the view layer ...
Chapter 25 HTTP and Background Tasks 492 Next, add a RecyclerView.Adapter to provide PhotoHolders as needed based on a list of ...
From AsyncTask Back to the Main Thread 493 Now that you have the appropriate nuts and bolts in place for RecyclerView, add code ...
Chapter 25 HTTP and Background Tasks 494 Now you need to call setupAdapter() after data has been fetched from Flickr. Your firs ...
Cleaning Up AsyncTasks 495 Cleaning Up AsyncTasks In this chapter, your AsyncTask and other code was carefully structured so tha ...
Chapter 25 HTTP and Background Tasks 496 For the More Curious: More on AsyncTask In this chapter you saw how to use the last ty ...
«
21
22
23
24
25
26
27
28
29
30
»
Free download pdf