Skip to content

Commit c73455d

Browse files
author
Ray Chen
committed
API Change: MediaScannerConnection.ScanResultListener -> MediaScannerConnection.OnScanCompletedListener.
Change-Id: I1386394dbccda4c01e50d89b8fdeca97ee65a29f
1 parent 254f0e9 commit c73455d

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,17 @@
4848
*/
4949
public class ExternalStorage extends Activity {
5050
ViewGroup mLayout;
51-
51+
5252
static class Item {
5353
View mRoot;
5454
Button mCreate;
5555
Button mDelete;
5656
}
57-
57+
5858
Item mExternalStoragePublicPicture;
5959
Item mExternalStoragePrivatePicture;
6060
Item mExternalStoragePrivateFile;
61-
61+
6262
@Override
6363
protected void onCreate(Bundle savedInstanceState) {
6464
super.onCreate(savedInstanceState);
@@ -114,10 +114,10 @@ public void onClick(View v) {
114114
}
115115
});
116116
mLayout.addView(mExternalStoragePrivateFile.mRoot);
117-
117+
118118
startWatchingExternalStorage();
119119
}
120-
120+
121121
@Override
122122
protected void onDestroy() {
123123
super.onDestroy();
@@ -135,12 +135,12 @@ void handleExternalStorageState(boolean available, boolean writeable) {
135135
mExternalStoragePrivateFile.mCreate.setEnabled(writeable && !has);
136136
mExternalStoragePrivateFile.mDelete.setEnabled(writeable && has);
137137
}
138-
138+
139139
// BEGIN_INCLUDE(monitor_storage)
140140
BroadcastReceiver mExternalStorageReceiver;
141141
boolean mExternalStorageAvailable = false;
142142
boolean mExternalStorageWriteable = false;
143-
143+
144144
void updateExternalStorageState() {
145145
String state = Environment.getExternalStorageState();
146146
if (Environment.MEDIA_MOUNTED.equals(state)) {
@@ -154,7 +154,7 @@ void updateExternalStorageState() {
154154
handleExternalStorageState(mExternalStorageAvailable,
155155
mExternalStorageWriteable);
156156
}
157-
157+
158158
void startWatchingExternalStorage() {
159159
mExternalStorageReceiver = new BroadcastReceiver() {
160160
@Override
@@ -169,12 +169,12 @@ public void onReceive(Context context, Intent intent) {
169169
registerReceiver(mExternalStorageReceiver, filter);
170170
updateExternalStorageState();
171171
}
172-
172+
173173
void stopWatchingExternalStorage() {
174174
unregisterReceiver(mExternalStorageReceiver);
175175
}
176176
// END_INCLUDE(monitor_storage)
177-
177+
178178
// BEGIN_INCLUDE(public_picture)
179179
void createExternalStoragePublicPicture() {
180180
// Create a path where we will place our picture in the user's
@@ -185,11 +185,11 @@ void createExternalStoragePublicPicture() {
185185
File path = Environment.getExternalStoragePublicDirectory(
186186
Environment.DIRECTORY_PICTURES);
187187
File file = new File(path, "DemoPicture.jpg");
188-
188+
189189
try {
190190
// Make sure the Pictures directory exists.
191191
path.mkdirs();
192-
192+
193193
// Very simple code to copy a picture from the application's
194194
// resource into the external file. Note that this code does
195195
// no error checking, and assumes the picture is small (does not
@@ -202,12 +202,12 @@ void createExternalStoragePublicPicture() {
202202
os.write(data);
203203
is.close();
204204
os.close();
205-
205+
206206
// Tell the media scanner about the new file so that it is
207207
// immediately available to the user.
208208
MediaScannerConnection.scanFile(this,
209209
new String[] { file.toString() }, null,
210-
new MediaScannerConnection.ScanResultListener() {
210+
new MediaScannerConnection.OnScanCompletedListener() {
211211
public void onScanCompleted(String path, Uri uri) {
212212
Log.i("ExternalStorage", "Scanned " + path + ":");
213213
Log.i("ExternalStorage", "-> uri=" + uri);
@@ -219,7 +219,7 @@ public void onScanCompleted(String path, Uri uri) {
219219
Log.w("ExternalStorage", "Error writing " + file, e);
220220
}
221221
}
222-
222+
223223
void deleteExternalStoragePublicPicture() {
224224
// Create a path where we will place our picture in the user's
225225
// public pictures directory and delete the file. If external
@@ -229,7 +229,7 @@ void deleteExternalStoragePublicPicture() {
229229
File file = new File(path, "DemoPicture.jpg");
230230
file.delete();
231231
}
232-
232+
233233
boolean hasExternalStoragePublicPicture() {
234234
// Create a path where we will place our picture in the user's
235235
// public pictures directory and check if the file exists. If
@@ -241,7 +241,7 @@ boolean hasExternalStoragePublicPicture() {
241241
return file.exists();
242242
}
243243
// END_INCLUDE(public_picture)
244-
244+
245245
// BEGIN_INCLUDE(private_picture)
246246
void createExternalStoragePrivatePicture() {
247247
// Create a path where we will place our picture in our own private
@@ -252,7 +252,7 @@ void createExternalStoragePrivatePicture() {
252252
// your media for display to the user.
253253
File path = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
254254
File file = new File(path, "DemoPicture.jpg");
255-
255+
256256
try {
257257
// Very simple code to copy a picture from the application's
258258
// resource into the external file. Note that this code does
@@ -266,12 +266,12 @@ void createExternalStoragePrivatePicture() {
266266
os.write(data);
267267
is.close();
268268
os.close();
269-
269+
270270
// Tell the media scanner about the new file so that it is
271271
// immediately available to the user.
272272
MediaScannerConnection.scanFile(this,
273273
new String[] { file.toString() }, null,
274-
new MediaScannerConnection.ScanResultListener() {
274+
new MediaScannerConnection.OnScanCompletedListener() {
275275
public void onScanCompleted(String path, Uri uri) {
276276
Log.i("ExternalStorage", "Scanned " + path + ":");
277277
Log.i("ExternalStorage", "-> uri=" + uri);
@@ -283,7 +283,7 @@ public void onScanCompleted(String path, Uri uri) {
283283
Log.w("ExternalStorage", "Error writing " + file, e);
284284
}
285285
}
286-
286+
287287
void deleteExternalStoragePrivatePicture() {
288288
// Create a path where we will place our picture in the user's
289289
// public pictures directory and delete the file. If external
@@ -294,7 +294,7 @@ void deleteExternalStoragePrivatePicture() {
294294
file.delete();
295295
}
296296
}
297-
297+
298298
boolean hasExternalStoragePrivatePicture() {
299299
// Create a path where we will place our picture in the user's
300300
// public pictures directory and check if the file exists. If
@@ -308,13 +308,13 @@ boolean hasExternalStoragePrivatePicture() {
308308
return false;
309309
}
310310
// END_INCLUDE(private_picture)
311-
311+
312312
// BEGIN_INCLUDE(private_file)
313313
void createExternalStoragePrivateFile() {
314314
// Create a path where we will place our private file on external
315315
// storage.
316316
File file = new File(getExternalFilesDir(null), "DemoFile.jpg");
317-
317+
318318
try {
319319
// Very simple code to copy a picture from the application's
320320
// resource into the external file. Note that this code does
@@ -334,7 +334,7 @@ void createExternalStoragePrivateFile() {
334334
Log.w("ExternalStorage", "Error writing " + file, e);
335335
}
336336
}
337-
337+
338338
void deleteExternalStoragePrivateFile() {
339339
// Get path for the file on external storage. If external
340340
// storage is not currently mounted this will fail.
@@ -343,7 +343,7 @@ void deleteExternalStoragePrivateFile() {
343343
file.delete();
344344
}
345345
}
346-
346+
347347
boolean hasExternalStoragePrivateFile() {
348348
// Get path for the file on external storage. If external
349349
// storage is not currently mounted this will fail.
@@ -354,7 +354,7 @@ boolean hasExternalStoragePrivateFile() {
354354
return false;
355355
}
356356
// END_INCLUDE(private_file)
357-
357+
358358
Item createStorageControls(CharSequence label, File path,
359359
View.OnClickListener createClick,
360360
View.OnClickListener deleteClick) {

0 commit comments

Comments
 (0)