Skip to content

Commit 522ac13

Browse files
committed
Merge pull request #113 from ParsePlatform/wangmengyan.t8120706_add_download_file_stream_api
Add new ParseFile download api
2 parents dbf80ec + 831fbbe commit 522ac13

File tree

5 files changed

+421
-58
lines changed

5 files changed

+421
-58
lines changed

Parse/src/main/java/com/parse/GetDataCallback.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ public interface GetDataCallback extends ParseCallback2<byte[], ParseException>
3737
@Override
3838
public void done(byte[] data, ParseException e);
3939
}
40+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (c) 2015-present, Parse, LLC.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*/
9+
package com.parse;
10+
11+
import java.io.InputStream;
12+
13+
/**
14+
* A {@code GetDataStreamCallback} is used to run code after a {@link ParseFile} fetches its data on
15+
* a background thread.
16+
* <p/>
17+
* The easiest way to use a {@code GetDataStreamCallback} is through an anonymous inner class.
18+
* Override the {@code done} function to specify what the callback should do after the fetch is
19+
* complete. The {@code done} function will be run in the UI thread, while the fetch happens in a
20+
* background thread. This ensures that the UI does not freeze while the fetch happens.
21+
* <p/>
22+
* <pre>
23+
* file.getDataStreamInBackground(new GetDataStreamCallback() {
24+
* public void done(InputSteam input, ParseException e) {
25+
* // ...
26+
* }
27+
* });
28+
* </pre>
29+
*/
30+
public interface GetDataStreamCallback extends ParseCallback2<InputStream, ParseException> {
31+
/**
32+
* Override this function with the code you want to run after the fetch is complete.
33+
*
34+
* @param input
35+
* The data that was retrieved, or {@code null} if it did not succeed.
36+
* @param e
37+
* The exception raised by the fetch, or {@code null} if it succeeded.
38+
*/
39+
@Override
40+
public void done(InputStream input, ParseException e);
41+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (c) 2015-present, Parse, LLC.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*/
9+
package com.parse;
10+
11+
import java.io.File;
12+
13+
/**
14+
* A {@code GetFileCallback} is used to run code after a {@link ParseFile} fetches its data on
15+
* a background thread.
16+
* <p/>
17+
* The easiest way to use a {@code GetFileCallback} is through an anonymous inner class.
18+
* Override the {@code done} function to specify what the callback should do after the fetch is
19+
* complete. The {@code done} function will be run in the UI thread, while the fetch happens in a
20+
* background thread. This ensures that the UI does not freeze while the fetch happens.
21+
* <p/>
22+
* <pre>
23+
* file.getFileInBackground(new GetFileCallback() {
24+
* public void done(File file, ParseException e) {
25+
* // ...
26+
* }
27+
* });
28+
* </pre>
29+
*/
30+
public interface GetFileCallback extends ParseCallback2<File, ParseException> {
31+
/**
32+
* Override this function with the code you want to run after the fetch is complete.
33+
*
34+
* @param file
35+
* The data that was retrieved, or {@code null} if it did not succeed.
36+
* @param e
37+
* The exception raised by the fetch, or {@code null} if it succeeded.
38+
*/
39+
@Override
40+
public void done(File file, ParseException e);
41+
}

0 commit comments

Comments
 (0)