Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Edison0716 committed Sep 21, 2017
0 parents commit aea9985
Show file tree
Hide file tree
Showing 70 changed files with 3,141 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
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
22 changes: 22 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 49 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
36 changes: 36 additions & 0 deletions app/build.gradle
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')
}
25 changes: 25 additions & 0 deletions app/proguard-rules.pro
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
37 changes: 37 additions & 0 deletions app/src/main/AndroidManifest.xml
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>
46 changes: 46 additions & 0 deletions app/src/main/java/com/junlong0716/rxretrofit/Api.java
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);

}
64 changes: 64 additions & 0 deletions app/src/main/java/com/junlong0716/rxretrofit/DownloadService.java
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);
}
}
33 changes: 33 additions & 0 deletions app/src/main/java/com/junlong0716/rxretrofit/GlideImageLoader.java
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() {

}
}
Loading

0 comments on commit aea9985

Please sign in to comment.