-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
154 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
davinci/src/main/java/cn/hadcn/davinci/other/OnVinciDownloadListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package cn.hadcn.davinci.other; | ||
|
||
/** | ||
* | ||
* Created by 90Chris on 2016/7/6. | ||
*/ | ||
public interface OnVinciDownloadListener { | ||
void onVinciDownloadSuccess(); | ||
void onVinciDownloadFailed(String reason); | ||
} |
12 changes: 12 additions & 0 deletions
12
davinci/src/main/java/cn/hadcn/davinci/other/OnVinciUploadListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package cn.hadcn.davinci.other; | ||
|
||
import org.json.JSONObject; | ||
|
||
/** | ||
* | ||
* Created by 90Chris on 2016/7/6. | ||
*/ | ||
public interface OnVinciUploadListener { | ||
void onVinciUploadSuccess(JSONObject response); | ||
void onVinciUploadFailed(String reason); | ||
} |
59 changes: 59 additions & 0 deletions
59
davinci/src/main/java/cn/hadcn/davinci/other/impl/VinciDownload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package cn.hadcn.davinci.other.impl; | ||
|
||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
import java.nio.ByteBuffer; | ||
|
||
import cn.hadcn.davinci.image.base.ByteRequest; | ||
import cn.hadcn.davinci.log.VinciLog; | ||
import cn.hadcn.davinci.other.OnVinciDownloadListener; | ||
import cn.hadcn.davinci.volley.DefaultRetryPolicy; | ||
import cn.hadcn.davinci.volley.Request; | ||
import cn.hadcn.davinci.volley.RequestQueue; | ||
import cn.hadcn.davinci.volley.Response; | ||
import cn.hadcn.davinci.volley.VolleyError; | ||
|
||
/** | ||
* VinciDownload | ||
* Created by 90Chris on 2016/7/5. | ||
*/ | ||
public class VinciDownload { | ||
private RequestQueue mRequestQueue; | ||
private String mBody; | ||
|
||
public VinciDownload(RequestQueue mRequestQueue) { | ||
this.mRequestQueue = mRequestQueue; | ||
} | ||
|
||
public VinciDownload body(String body) { | ||
mBody = body; | ||
return this; | ||
} | ||
|
||
public void download(String url, final OutputStream out, final OnVinciDownloadListener listener) { | ||
ByteRequest request = new ByteRequest(Request.Method.POST, url, mBody, new Response.Listener<ByteBuffer>() { | ||
@Override | ||
public void onResponse(ByteBuffer response) { | ||
try { | ||
out.write(response.array()); | ||
listener.onVinciDownloadSuccess(); | ||
} catch (IOException e) { | ||
VinciLog.e("write out error", e); | ||
listener.onVinciDownloadFailed("write file failed"); | ||
} | ||
} | ||
}, new Response.ErrorListener() { | ||
@Override | ||
public void onErrorResponse(VolleyError error) { | ||
listener.onVinciDownloadFailed("net failed"); | ||
} | ||
}); | ||
request.setRetryPolicy(new DefaultRetryPolicy(4 * DefaultRetryPolicy.DEFAULT_TIMEOUT_MS, | ||
DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); | ||
mRequestQueue.add(request); | ||
} | ||
|
||
public interface Listener { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
davinci/src/main/java/cn/hadcn/davinci/upload/OnDaVinciUploadListener.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters