-
Notifications
You must be signed in to change notification settings - Fork 0
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
65 changed files
with
4,421 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,59 @@ | ||
package com.d.rxnet; | ||
|
||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.View; | ||
|
||
import com.d.lib.rxnet.RxNet; | ||
import com.d.lib.rxnet.api.API; | ||
import com.d.lib.rxnet.util.RxLog; | ||
import com.d.lib.rxnet.util.SSLUtil; | ||
import com.d.rxnet.request.Down; | ||
import com.d.rxnet.request.Get; | ||
import com.d.rxnet.request.Post; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
RxLog.d("dsiner_th_Main: " + Thread.currentThread().getId() + "--NAME--" + Thread.currentThread().getName()); | ||
setContentView(R.layout.activity_main); | ||
initView(); | ||
init(); | ||
} | ||
|
||
private void initView() { | ||
findViewById(R.id.btn_get).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
new Get(MainActivity.this).testAll(); | ||
} | ||
}); | ||
findViewById(R.id.btn_post).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
new Post(MainActivity.this).testAll(); | ||
} | ||
}); | ||
findViewById(R.id.btn_downFile).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
new Down(MainActivity.this).testAll(); | ||
} | ||
}); | ||
} | ||
|
||
private void init() { | ||
RxNet.init(getApplicationContext()) | ||
.baseUrl(API.API_BASE) | ||
.headers(null) | ||
.connectTimeout(10 * 1000) | ||
.readTimeout(10 * 1000) | ||
.readTimeout(10 * 1000) | ||
.retryCount(1) | ||
.retryDelayMillis(2 * 1000) | ||
.sslSocketFactory(SSLUtil.getSslSocketFactory(null, null, null)) | ||
.build(); | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
app/src/main/java/com/d/rxnet/model/MovieTopModelInfo.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,68 @@ | ||
package com.d.rxnet.model; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Created by D on 2017/10/26. | ||
*/ | ||
public class MovieTopModelInfo { | ||
public int count; | ||
public int start; | ||
public int total; | ||
public String title; | ||
public List<SubjectsBean> subjects; | ||
|
||
public static class SubjectsBean { | ||
public RatingBean rating; | ||
public String title; | ||
public int collect_count; | ||
public String original_title; | ||
public String subtype; | ||
public String year; | ||
public ImagesBean images; | ||
public String alt; | ||
public String id; | ||
public List<String> genres; | ||
public List<CastsBean> casts; | ||
public List<DirectorsBean> directors; | ||
|
||
public static class RatingBean { | ||
public int max; | ||
public double average; | ||
public String stars; | ||
public int min; | ||
} | ||
|
||
public static class ImagesBean { | ||
public String small; | ||
public String large; | ||
public String medium; | ||
} | ||
|
||
public static class CastsBean { | ||
public String alt; | ||
public AvatarsBean avatars; | ||
public String name; | ||
public String id; | ||
|
||
public static class AvatarsBean { | ||
public String small; | ||
public String large; | ||
public String medium; | ||
} | ||
} | ||
|
||
public static class DirectorsBean { | ||
public String alt; | ||
public AvatarsBeanX avatars; | ||
public String name; | ||
public String id; | ||
|
||
public static class AvatarsBeanX { | ||
public String small; | ||
public String large; | ||
public String medium; | ||
} | ||
} | ||
} | ||
} |
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,104 @@ | ||
package com.d.rxnet.request; | ||
|
||
import android.app.Activity; | ||
import android.app.ProgressDialog; | ||
import android.content.Context; | ||
import android.os.Environment; | ||
|
||
import com.d.lib.rxnet.RxNet; | ||
import com.d.lib.rxnet.exception.ApiException; | ||
import com.d.lib.rxnet.listener.DownloadCallBack; | ||
import com.d.lib.rxnet.util.RxLog; | ||
|
||
/** | ||
* Request Test --> Down | ||
* Created by D on 2017/10/26. | ||
*/ | ||
public class Down { | ||
private String fileUrl = "http://m10.music.126.net/20171027150016/9b65067112ac9ab0df434b955d2aadd4/ymusic/9e23/460b/3237/53cd858401aff035a9b3139d78d78b82.mp3"; | ||
private Context appContext; | ||
|
||
private ProgressDialog dialog; | ||
|
||
public Down(Activity activity) { | ||
appContext = activity.getApplicationContext(); | ||
dialog = new ProgressDialog(activity); | ||
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);// 设置进度条的形式为圆形转动的进度条 | ||
dialog.setMessage("正在下载..."); | ||
// 设置提示的title的图标,默认是没有的,如果没有设置title的话只设置Icon是不会显示图标的 | ||
dialog.setTitle("下载文件"); | ||
dialog.setMax(100); | ||
} | ||
|
||
public void testAll() { | ||
testIns(); | ||
// testNew(); | ||
} | ||
|
||
public void testIns() { | ||
RxNet.getInstance(appContext).download(fileUrl) | ||
.request(Environment.getExternalStorageDirectory().getPath() + "/test/", "" + System.currentTimeMillis() + ".mp3", new DownloadCallBack() { | ||
@Override | ||
public void onStart(long total) { | ||
RxLog.d("dsiner_th_onStart: " + Thread.currentThread().getId() + "--NAME--" + Thread.currentThread().getName()); | ||
RxLog.d("dsiner_down onStart: -->total: " + total); | ||
// dialog.show(); | ||
} | ||
|
||
@Override | ||
public void onProgresss(long download, long total) { | ||
RxLog.d("dsiner_th_onProgresss: " + Thread.currentThread().getId() + "--NAME--" + Thread.currentThread().getName()); | ||
RxLog.d("dsiner_down onProgresss: -->download: " + download + " total: " + total); | ||
// dialog.setProgress((int) (download * 100 / total)); | ||
} | ||
|
||
@Override | ||
public void onComplete() { | ||
RxLog.d("dsiner_th_onComplete: " + Thread.currentThread().getId() + "--NAME--" + Thread.currentThread().getName()); | ||
RxLog.d("dsiner_down onComplete:"); | ||
// dialog.setMessage("下载完成"); | ||
} | ||
|
||
@Override | ||
public void onError(ApiException e) { | ||
RxLog.d("dsiner_th_onError: " + Thread.currentThread().getId() + "--NAME--" + Thread.currentThread().getName()); | ||
RxLog.d("dsiner_down onError " + e.getMessage()); | ||
// dialog.dismiss(); | ||
} | ||
}); | ||
} | ||
|
||
public void testNew() { | ||
new RxNet(appContext).download(fileUrl) | ||
.connectTimeout(60 * 1000) | ||
.readTimeout(60 * 1000) | ||
.writeTimeout(60 * 1000) | ||
.retryCount(3) | ||
.retryDelayMillis(300) | ||
.request(Environment.getExternalStorageDirectory().getPath() + "/test/", "" + System.currentTimeMillis() + ".mp3", new DownloadCallBack() { | ||
@Override | ||
public void onStart(long total) { | ||
RxLog.d("dsiner_th_onStart: " + Thread.currentThread().getId() + "--NAME--" + Thread.currentThread().getName()); | ||
RxLog.d("dsiner_down onStart: -->total: " + total); | ||
} | ||
|
||
@Override | ||
public void onProgresss(long download, long total) { | ||
RxLog.d("dsiner_th_onProgresss: " + Thread.currentThread().getId() + "--NAME--" + Thread.currentThread().getName()); | ||
RxLog.d("dsiner_down onProgresss: -->download: " + download + " total: " + total); | ||
} | ||
|
||
@Override | ||
public void onComplete() { | ||
RxLog.d("dsiner_th_onComplete: " + Thread.currentThread().getId() + "--NAME--" + Thread.currentThread().getName()); | ||
RxLog.d("dsiner_down onComplete:"); | ||
} | ||
|
||
@Override | ||
public void onError(ApiException e) { | ||
RxLog.d("dsiner_th_onError: " + Thread.currentThread().getId() + "--NAME--" + Thread.currentThread().getName()); | ||
RxLog.d("dsiner_down onError " + e.getMessage()); | ||
} | ||
}); | ||
} | ||
} |
Oops, something went wrong.