Skip to content

Commit

Permalink
发布1.0.4版本
Browse files Browse the repository at this point in the history
  • Loading branch information
pengjianbo committed Oct 8, 2015
1 parent 334b746 commit 72efff3
Show file tree
Hide file tree
Showing 91 changed files with 5,630 additions and 65 deletions.
11 changes: 9 additions & 2 deletions .gitignore 100644 → 100755
@@ -1,3 +1,10 @@
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
# Created by https://www.gitignore.io

### Android ###
Expand Down Expand Up @@ -47,7 +54,7 @@ gradle-app.setting
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm

*.iml
OkHttpFinal.iml
app.iml
## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:
Expand Down Expand Up @@ -89,4 +96,4 @@ atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
crashlytics-build.properties
1 change: 0 additions & 1 deletion OkHttpFinal/.gitignore 100644 → 100755
@@ -1,2 +1 @@
/build
OkHttpFinal-OkHttpFinal.iml
9 changes: 7 additions & 2 deletions OkHttpFinal/build.gradle 100644 → 100755
Expand Up @@ -2,13 +2,13 @@ apply plugin: 'com.android.library'

android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc3"
buildToolsVersion '23.0.1'

defaultConfig {
minSdkVersion 8
targetSdkVersion 22
versionCode 1
versionName "1.0"
versionName project_version
}
buildTypes {
release {
Expand All @@ -20,4 +20,9 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'cn.finalteam:toolsfinal:+'
}

apply from: 'https://raw.githubusercontent.com/FinalTeam/ToolsFinal/master/bintray.gradle'
20 changes: 20 additions & 0 deletions OkHttpFinal/gradle.properties
@@ -0,0 +1,20 @@
# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

project_artifactId=okhttpfinal
Empty file modified OkHttpFinal/proguard-rules.pro 100644 → 100755
Empty file.
@@ -1,4 +1,4 @@
package cn.paojiao.okhttpfinal;
package cn.finalteam.okhttpfinal;

import android.app.Application;
import android.test.ApplicationTestCase;
Expand Down
8 changes: 1 addition & 7 deletions OkHttpFinal/src/main/AndroidManifest.xml 100644 → 100755
@@ -1,10 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cn.paojiao.okhttpfinal">

<application android:allowBackup="true"
android:label="@string/app_name"
>

</application>
package="cn.finalteam.okhttpfinal">

</manifest>
@@ -0,0 +1,10 @@
package cn.finalteam.okhttpfinal;

/**
* Desction:接口响应基类
* Author:pengjianbo
* Date:15/7/3 下午2:26
*/
public interface ApiResponse {

}
@@ -0,0 +1,51 @@
package cn.finalteam.okhttpfinal;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

/**
* Desction:请求回调类
* Author:pengjianbo
* Date:15/7/3 上午11:41
*/
public class BaseHttpRequestCallback<T extends ApiResponse> {

public static final int ERROR_RESPONSE_NULL = 1001;
public static final int ERROR_RESPONSE_JSON_EXCEPTION = 1002;
public static final int ERROR_RESPONSE_UNKNOWN = 1003;
public static final int ERROR_RESPONSE_TIMEOUT = 1004;

public BaseHttpRequestCallback() {
}

public void onStart() {
}

public void onFinish() {
}

public void onSuccess(T t) {
}

public void onFailure(int errorCode, String msg) {
}

public Class getModelClazz() {
return getGenericType(0);
}

private Class getGenericType(int index) {
Type genType = getClass().getGenericSuperclass();
if (!(genType instanceof ParameterizedType)) {
return Object.class;
}
Type[] params = ((ParameterizedType) genType).getActualTypeArguments();
if (index >= params.length || index < 0) {
throw new RuntimeException("Index outof bounds");
}
if (!(params[index] instanceof Class)) {
return Object.class;
}
return (Class) params[index];
}
}
16 changes: 16 additions & 0 deletions OkHttpFinal/src/main/java/cn/finalteam/okhttpfinal/Constants.java
@@ -0,0 +1,16 @@
package cn.finalteam.okhttpfinal;

import java.io.File;

/**
* Desction:
* Author:pengjianbo
* Date:15/9/21 上午9:54
*/
public class Constants {
protected static boolean DEBUG = BuildConfig.DEBUG;
//下载管理目标文件夹
public static final String DM_TARGET_FOLDER = File.separator + "download" + File.separator;
//Http请求超时时间
public static final int REQ_TIMEOUT = 30000;
}
@@ -0,0 +1,32 @@
package cn.finalteam.okhttpfinal;

/**
* Desction:文件内容类型
* Author:pengjianbo
* Date:15/9/21 上午10:53
*/
public enum ContentType {
TEXT("text/plain; charset=UTF-8"),
PNG("image/png; charset=UTF-8"),
JPEG("image/jpeg; charset=UTF-8");

private String contentType;

private ContentType(String contentType){
this.contentType = contentType;
}

/**
* @return the contentType
*/
public String getContentType() {
return contentType;
}

/**
* @param contentType the contentType to set
*/
public void setContentType(String contentType) {
this.contentType = contentType;
}
}
@@ -0,0 +1,10 @@
package cn.finalteam.okhttpfinal;

/**
* Desction:
* Author:pengjianbo
* Date:15/9/21 上午11:20
*/
public interface HttpCycleContext {
String getHttpTaskKey();
}
@@ -0,0 +1,46 @@
package cn.finalteam.okhttpfinal;

import java.io.InputStream;
import java.io.Serializable;

/**
* Desction:上传文件数据模型
* Author:pengjianbo
* Date:15/7/3 上午11:10
*/
public class HttpFileInputStream implements Serializable {
private static final long serialVersionUID = 1L;
private InputStream inputStream;
private String name;
private long fileSize;

public HttpFileInputStream(InputStream inputStream, String name, long fileSize) {
this.inputStream = inputStream;
this.name = name;
this.fileSize = fileSize;
}

public InputStream getInputStream() {
return inputStream;
}

public void setInputStream(InputStream inputStream) {
this.inputStream = inputStream;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public long getFileSize() {
return fileSize;
}

public void setFileSize(long fileSize) {
this.fileSize = fileSize;
}
}
@@ -0,0 +1,59 @@
package cn.finalteam.okhttpfinal;

/**
* Desction:http请求类
* Author:pengjianbo
* Date:15/9/22 下午10:17
*/
public class HttpRequest {

public static void setDebug(boolean debug) {
Constants.DEBUG = debug;
}

public static void get(String url) {
get(url, null, null);
}

public static void get(String url, RequestParams params) {
get(url, params, null);
}

public static void get(String url, BaseHttpRequestCallback callback) {
get(url, null, callback);
}

public static void get(String url, RequestParams params, BaseHttpRequestCallback callback) {
get(url, params, callback, Constants.REQ_TIMEOUT);
}

public static void get(String url, RequestParams params, BaseHttpRequestCallback callback, int timeOut) {
executeRequest(url, params, callback, timeOut);
}

public static void post(String url) {
post(url, null, null);
}

public static void post(String url, RequestParams params) {
post(url, params, null);
}

public static void post(String url, BaseHttpRequestCallback callback) {
post(url, null, callback);
}

public static void post(String url, RequestParams params, BaseHttpRequestCallback callback) {
post(url, params, callback, Constants.REQ_TIMEOUT);
}

public static void post(String url, RequestParams params, BaseHttpRequestCallback callback, int timeOut) {
executeRequest(url, params, callback, timeOut);
}

private static void executeRequest(String url, RequestParams params, BaseHttpRequestCallback callback, int timeout) {
HttpTask task = new HttpTask(url, params, callback, timeout);
task.execute();
}

}

0 comments on commit 72efff3

Please sign in to comment.