-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 26 | ||
buildToolsVersion "26.0.1" | ||
defaultConfig { | ||
applicationId "com.junlong0716.rxretrofit" | ||
minSdkVersion 19 | ||
targetSdkVersion 26 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(include: ['*.jar'], dir: 'libs') | ||
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { | ||
exclude group: 'com.android.support', module: 'support-annotations' | ||
}) | ||
compile 'com.android.support:appcompat-v7:26.+' | ||
compile 'com.android.support:design:26.+' | ||
compile 'com.android.support.constraint:constraint-layout:1.0.2' | ||
compile 'com.github.hss01248:NotifyUtil:1.0.1' | ||
compile 'com.github.bumptech.glide:glide:4.1.1' | ||
annotationProcessor 'com.github.bumptech.glide:compiler:4.1.1' | ||
compile 'com.lzy.widget:imagepicker:0.6.1' | ||
testCompile 'junit:junit:4.12' | ||
compile project(':retrofitutils') | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in /Users/mac/Library/Android/sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.junlong0716.rxretrofit"> | ||
<uses-permission android:name="android.permission.INTERNET"/> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> | ||
<uses-permission android:name="android.permission.INTERNET"/> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | ||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> | ||
|
||
<application | ||
android:name=".MyApp" | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
|
||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
</activity> | ||
<provider | ||
android:name="android.support.v4.content.FileProvider" | ||
android:authorities="com.junlong0716.rxretrofit.fileprovider" | ||
android:exported="false" | ||
android:grantUriPermissions="true"> | ||
<meta-data | ||
android:name="android.support.FILE_PROVIDER_PATHS" | ||
android:resource="@xml/file_paths" /> | ||
</provider> | ||
<service android:name=".DownloadService"/> | ||
</application> | ||
|
||
</manifest> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.junlong0716.rxretrofit; | ||
|
||
import java.util.ArrayList; | ||
|
||
import io.reactivex.Flowable; | ||
import io.reactivex.Observable; | ||
import okhttp3.MultipartBody; | ||
import okhttp3.ResponseBody; | ||
import retrofit2.http.Field; | ||
import retrofit2.http.FormUrlEncoded; | ||
import retrofit2.http.GET; | ||
import retrofit2.http.Multipart; | ||
import retrofit2.http.POST; | ||
import retrofit2.http.Part; | ||
import retrofit2.http.Query; | ||
import retrofit2.http.Streaming; | ||
import retrofit2.http.Url; | ||
|
||
/** | ||
* Created by ${巴黎没有摩天轮Li} on 2017/9/19. | ||
*/ | ||
|
||
public interface Api { | ||
String baseUrl = "http://order.htxcsoft.com/"; | ||
|
||
@GET("testForAz2.do") | ||
Observable<ResponseBody> getFoodType(@Query("page") String page); | ||
|
||
@Multipart | ||
@POST("testUploadPic.do") | ||
Flowable<ResultModel<String>> upload(@Part MultipartBody.Part file); | ||
|
||
|
||
@Multipart | ||
@POST("testUploadPic1.do") | ||
Flowable<ResultModel<String>> uploads(@Part ArrayList<MultipartBody.Part> files); | ||
|
||
@FormUrlEncoded | ||
@POST("testForAz1.do") | ||
Observable<ResponseBody> getPostData(@Field("page") String page); | ||
|
||
@Streaming | ||
@GET | ||
Flowable<ResponseBody> startDownLoad(@Url String fileUrl); | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.junlong0716.rxretrofit; | ||
|
||
import android.app.Service; | ||
import android.content.Intent; | ||
import android.os.IBinder; | ||
import android.support.annotation.Nullable; | ||
import android.widget.Toast; | ||
|
||
|
||
import com.hss01248.notifyutil.NotifyUtil; | ||
import com.junlong0716.retrofitutils.RetrofitUtils; | ||
import com.junlong0716.retrofitutils.download.DownLoadSubscriber; | ||
import com.junlong0716.rxretrofit.event.DownloadEvent; | ||
import com.junlong0716.rxretrofit.rxbus.RxBus; | ||
|
||
import static android.support.v4.app.NotificationCompat.VISIBILITY_PUBLIC; | ||
|
||
/** | ||
* Created by ${巴黎没有摩天轮Li} on 2017/9/20. | ||
*/ | ||
|
||
public class DownloadService extends Service { | ||
|
||
@Nullable | ||
@Override | ||
public IBinder onBind(Intent intent) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
} | ||
|
||
@Override | ||
public int onStartCommand(Intent intent, int flags, int startId) { | ||
|
||
RetrofitUtils.downLoadFile("qq.apk").safeSubscribe(new DownLoadSubscriber(this) { | ||
@Override | ||
protected void _onNext(String result) { | ||
Toast.makeText(getApplicationContext(), "下载成功!", Toast.LENGTH_SHORT).show(); | ||
RxBus.getDefault().post(new DownloadEvent("download_success", 100)); | ||
} | ||
|
||
@Override | ||
protected void _onProgress(Integer percent) { | ||
NotifyUtil.buildProgress(102, R.mipmap.ic_launcher, "正在下载", percent, 100, "下载进度:%d%%") | ||
.setOnGoing() | ||
.setSmallIcon(R.mipmap.ic_launcher) | ||
.setLockScreenVisiablity(VISIBILITY_PUBLIC) | ||
.show(); | ||
RxBus.getDefault().post(new DownloadEvent("download_running", percent)); | ||
} | ||
|
||
@Override | ||
protected void _onError(int errorCode, String msg) { | ||
NotifyUtil.cancel(102); | ||
RxBus.getDefault().post(new DownloadEvent("download_failed", 0)); | ||
Toast.makeText(getApplicationContext(), "下载失败!", Toast.LENGTH_SHORT).show(); | ||
} | ||
}); | ||
return super.onStartCommand(intent, flags, startId); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.junlong0716.rxretrofit; | ||
|
||
import android.app.Activity; | ||
import android.net.Uri; | ||
import android.widget.ImageView; | ||
|
||
import com.bumptech.glide.Glide; | ||
import com.lzy.imagepicker.loader.ImageLoader; | ||
|
||
import java.io.File; | ||
|
||
/** | ||
* Created by ${巴黎没有摩天轮Li} on 2017/9/19. | ||
*/ | ||
|
||
public class GlideImageLoader implements ImageLoader { | ||
@Override | ||
public void displayImage(Activity activity, String path, ImageView imageView, int width, int height) { | ||
Glide.with(activity)// | ||
.load(Uri.fromFile(new File(path)))// | ||
.into(imageView); | ||
} | ||
|
||
@Override | ||
public void displayImagePreview(Activity activity, String path, ImageView imageView, int width, int height) { | ||
|
||
} | ||
|
||
@Override | ||
public void clearMemoryCache() { | ||
|
||
} | ||
} |