forked from ebaronov/AndroidCourseResources
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errata.txt
108 lines (84 loc) · 5.55 KB
/
errata.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
Course 8/6/2012
Chapter 6, Fragments And The Fragment Manager
Pg 80, Figure 6.11: On TableLayout: layout_height="wrap_content"
Pg 81, "The first thing to consider when preparing a fragment to
host an activity..." should be "The first thing to consider when
preparing an activity to host a fragment..."
Pg 81, Figure 6.13: crime_fragment should be fragment_crime
Chapter 9, ListView
Pg 147, Figure 9.29: focusable has already been set to "true" on the previous page.
Pg 147, Figure 9.29: CheckBox also needs android:clickable="false"
Chapter 10, Multiple Activities
Pg 156, Figure 10.13: Crime is a reference, so this code is not necessary
Pg 162, Figure 10.25: LinearLayout should not be deleted here
Chapter 11, Menus
Pg 165, Instructions on this page omit the xhdpi folder.
Pg 166, Figure 11.4: This listing includes two mysterious strings which are never used. They should be ignored.
Pg 176, "Now you can run..." You cannot at this point use the home button to navigate up,
because it has not been enabled. Call "setDisplayHomeAsUpEnabled(true)" as depicted
on page 178 to enable the Home button.
Chapter 12, File I/O
Pg 181, under "Creating the CriminalIntentJSONSerializer class":
"Right-click/Command-click" should be "Right-click/Control-click" (thanks to Dirk Stoop)
Chapter 13, Camera
Pg 195, Figure 13.10: New code is not bold. (thanks to Dirk Stoop)
Pg 197, Figure 13.12: holder.setType and SURFACE_TYPE_PUSH_BUFFERS are both deprecated. The text should
mention the reason for this: while these calls are deprecated and poorly documented, they
are required on older devices for your Camera preview to work. (thanks to Dirk Stoop)
Pg 199, Figure 13.15: The Camera.open(int) method is only available on SDK 9 and up. To prevent
Android Lint from producing an error from this code, change your project's minSdkVersion
to "9" in your AndroidManifest.xml.
Pg 207, 13.26: "watson.CRIME_ID" should be "criminalintent.CRIME_ID"; STATE_CRIME also appears here, and
should not. (thanks to Dirk Stoop)
Pg 210, Figure 13.29: The code here disagrees with the text on page 209. The code is right; the text
is wrong. Bitmaps are large, and we need to be aggressive about releasing them. Also, when the
image returns from the CrimeCameraActivity, onActivityResult is only called *after* onStart is called.
Pg 210, Figure 13.29: onPause is missing code from earlier in the book. Preserve the existing code
in your project here.
The code for this chapter causes the photo in the button to appear to "blink" out before CrimeNotesActivity
in subsequent chapters. To fix this behavior, move the code to clear the photoButton from onPause to onStop.
(thanks to Dirk Stoop)
Chapter 14, Implicit Intents
Pg 199, Figure 14.11: The suspect choosing Intent should be structured like so:
Intent i = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
startActivityForResult(i, REQUEST_CONTACT);
Chapter 15, Touch Events
Pg 236, below figure 15.15: "If you leave out the call to postInvalidate(), you will get unattractive trailing"
The call to postInvalidate is not actually necessary here. (thanks to Dirk Stoop)
Pg 240, "All is not perfect..." For some reason, this paragraph ends with the sentence, "ImageView." This
is an error.
Pg 241, Figure 15.24:
This code:
public Note(JSONObject json) throws JSONException {
text = json.getString(JSON_TEXT);
originX = json.getInt(JSON_ORIGIN_X);
originY = json.getInt(JSON_ORIGIN_Y);
currentX = json.getInt(JSON_CURRENT_X);
currentY = json.getInt(JSON_CURRENT_Y);
}
Should be this instead:
public Note(JSONObject json) throws JSONException {
text = json.getString(JSON_TEXT);
originX = (float)json.getDouble(JSON_ORIGIN_X);
originY = (float)json.getDouble(JSON_ORIGIN_Y);
currentX = (float)json.getDouble(JSON_CURRENT_X);
currentY = (float)json.getDouble(JSON_CURRENT_Y);
}
Pg 243, "If you were puzzled..." These two paragraphs should read as follows:
Your implementation here of addNote(Note) should be self explanatory. onLayout(...), though,
requires some explanation. See, a user of this class will typically want to configure it in
onCreateView(...). The problem is that in onCreateView(...), the views have not been laid out
yet. That means that NoteDrawingView has no width or height! If you look back at your implementation
of getLayoutParams(...), you can see that it will produce a view with a width and height of 0
under those conditions.
The solution is to, for the time being, use those bogus layout params to set the child to be sizeless.
By the time onLayout(...) is called, NoteDrawingView will know how big it is, and getLayoutParams(...)
will return useful values. So in your onLayout(...) implementation, you double check the layout
params values before calling through to super to let FrameLayout.onLayout(...) do its thing.
Pg 248, Figure 16.4: .setNeutralButton() implementation here should be omitted.
Chapter 22, Local Services
Pg 328, Figure 22.29: downloadThread.loadPhoto(photo) here should be downloadThread.downloadPhoto(photo).
Pg 324, Figure 22.23: In this change set, this line of code:
photos = new ArrayList<Photo>();
Should be changed to this:
photos = fetcher.getCachedPhotos();