-
Notifications
You must be signed in to change notification settings - Fork 0
/
errata.txt
99 lines (82 loc) · 3.88 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
Course 7/23/2012
Chapter 13, Camera
pg. 171: Use the following code for surfaceChanged:
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
// the surface has changed size; update the camera preview size
Camera.Parameters parameters = camera.getParameters();
Size s = null; // ????
parameters.setPreviewSize(s.width, s.height);
camera.setParameters(parameters);
s = null; // ???
parameters.setPictureSize(s.width, s.height);
try {
camera.startPreview();
} catch (Exception e) {
Log.e(TAG, "Could not start preview", e);
camera.release();
camera = null;
}
}
pg. 172: Use the following code for surfaceChanged:
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
// the surface has changed size; update the camera preview size
Camera.Parameters parameters = camera.getParameters();
Size s = getBestSupportedSize(parameters.getSupportedPreviewSizes(), w, h);
parameters.setPreviewSize(s.width, s.height);
s = getBestSupportedSize(parameters.getSupportedPictureSizes(), w, h);
parameters.setPictureSize(s.width, s.height);
camera.setParameters(parameters);
try {
camera.startPreview();
} catch (Exception e) {
Log.e(TAG, "Could not start preview", e);
camera.release();
camera = null;
}
}
pg. 182: Use the following alternative getScaledDrawable() implementation
(uses code from http://developer.android.com/training/displaying-bitmaps/load-bitmap.html):
public static BitmapDrawable getScaledDrawable(Activity a, String path) {
Display display = a.getWindowManager().getDefaultDisplay();
float destWidth = display.getWidth();
float destHeight = display.getHeight();
// read in the dimensions of the image on disk
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(path, options);
float srcWidth = options.outWidth;
float srcHeight = options.outHeight;
int inSampleSize = 1;
if (srcHeight > destHeight || srcWidth > destWidth) {
if (srcWidth > srcHeight) {
inSampleSize = Math.round((float)srcHeight / (float)destHeight);
} else {
inSampleSize = Math.round((float)srcWidth / (float)destWidth);
}
}
options = new BitmapFactory.Options();
options.inSampleSize = inSampleSize;
return new BitmapDrawable(BitmapFactory.decodeFile(path, options));
}
Chapter 16, Dialogs
pg. 215: Omit the setNeutralButton code from the text:
public static class NoteTextOptionsDialog extends NoteDialog {
public Dialog onCreateDialog(Bundle savedInstanceState) {
final String[] strings = getResources().getStringArray(R.array.dialog_note_text_options);
// initially set the note text to the default - will change
// if the user makes a selection
updateNoteText(strings[0]);
return new AlertDialog.Builder(getActivity())
.setTitle(R.string.dialog_note_text_options_title)
.setSingleChoiceItems(R.array.dialog_note_text_options, 0,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// set the note's text
updateNoteText(strings[which]);
dialog.dismiss();
}
})
.setPositiveButton(android.R.string.ok, null)
.create();
}
}