Просмотр исходного кода

imageloader、network集成完成

FANGLH 8 лет назад
Родитель
Сommit
e4f00085e7
35 измененных файлов с 2210 добавлено и 2 удалено
  1. 1 0
      app_core/imageload/build.gradle
  2. 37 0
      app_core/imageload/src/main/java/com/library/imageloader/BaseImageLoaderStrategy.java
  3. 133 0
      app_core/imageload/src/main/java/com/library/imageloader/ImageLoaderUtil.java
  4. 300 0
      app_core/imageload/src/main/java/com/library/imageloader/iml/GlideImageLoaderStrategy.java
  5. 11 0
      app_core/imageload/src/main/java/com/library/imageloader/listener/ImageSaveListener.java
  6. 14 0
      app_core/imageload/src/main/java/com/library/imageloader/listener/ProgressLoadListener.java
  7. 10 0
      app_core/imageload/src/main/java/com/library/imageloader/listener/SourceReadyListener.java
  8. 164 0
      app_core/imageload/src/main/java/com/library/imageloader/transformation/GlideCircleTransform.java
  9. 90 0
      app_core/imageload/src/main/java/com/library/imageloader/utils/FileUtils.java
  10. 32 0
      app_core/imageload/src/main/java/com/library/imageloader/utils/ImageUtils.java
  11. 96 0
      app_core/imageload/src/main/java/com/library/imageloader/utils/ScreenUtils.java
  12. 36 0
      app_core/imageload/src/main/java/com/library/imageloader/utils/Utils.java
  13. 11 0
      app_core/network/build.gradle
  14. 185 0
      app_core/network/src/main/java/network/app/base/BaseActivity.java
  15. 57 0
      app_core/network/src/main/java/network/app/base/BaseApplication.java
  16. 49 0
      app_core/network/src/main/java/network/app/http/HttpBase.java
  17. 338 0
      app_core/network/src/main/java/network/app/http/HttpClient.java
  18. 9 0
      app_core/network/src/main/java/network/app/http/Method.java
  19. 11 0
      app_core/network/src/main/java/network/app/http/cache/CacheType.java
  20. 170 0
      app_core/network/src/main/java/network/app/http/impl/RetrofitImpl.java
  21. 55 0
      app_core/network/src/main/java/network/app/http/interceptor/CacheInterceptor.java
  22. 99 0
      app_core/network/src/main/java/network/app/http/interceptor/LogInterceptor.java
  23. 31 0
      app_core/network/src/main/java/network/app/http/retrofit/StringConverterFactory.java
  24. 27 0
      app_core/network/src/main/java/network/app/http/retrofit/StringRequestBodyConverter.java
  25. 19 0
      app_core/network/src/main/java/network/app/http/retrofit/StringResponseBodyConverter.java
  26. 10 0
      app_core/network/src/main/java/network/app/http/rx/Result1Listener.java
  27. 11 0
      app_core/network/src/main/java/network/app/http/rx/Result2Listener.java
  28. 8 0
      app_core/network/src/main/java/network/app/http/rx/ResultListener.java
  29. 87 0
      app_core/network/src/main/java/network/app/http/rx/ResultSubscriber.java
  30. 23 0
      app_core/network/src/main/java/network/app/http/rx/RxJavaUtils.java
  31. 45 0
      app_core/network/src/main/java/network/app/http/service/ParamService.java
  32. 26 0
      app_core/network/src/main/java/network/app/http/ssl/TrustAllCerts.java
  33. 14 0
      app_core/network/src/main/java/network/app/http/ssl/TrustAllHostnameVerifier.java
  34. 1 1
      build.gradle
  35. 0 1
      version.gradle

+ 1 - 0
app_core/imageload/build.gradle

@@ -31,4 +31,5 @@ dependencies {
 
     compile 'com.android.support:appcompat-v7:24.2.1'
     testCompile 'junit:junit:4.12'
+    compile deps.glide
 }

+ 37 - 0
app_core/imageload/src/main/java/com/library/imageloader/BaseImageLoaderStrategy.java

@@ -0,0 +1,37 @@
+package com.library.imageloader;
+
+import android.content.Context;
+import android.widget.ImageView;
+
+import com.library.imageloader.listener.ImageSaveListener;
+import com.library.imageloader.listener.ProgressLoadListener;
+import com.library.imageloader.listener.SourceReadyListener;
+
+
+/**
+ * Created by Arison on 2017/5/22.
+ */
+public interface BaseImageLoaderStrategy {
+
+    void loadImage(String url, ImageView imageView);
+    void loadImageWithAppCxt(String url, ImageView imageView); //这里的context指定为ApplicationContext
+    void loadImage(String url, int placeholder, ImageView imageView);
+    void loadImage(Context context, String url, int placeholder, ImageView imageView);
+
+    void loadCircleImage(String url, int placeholder, ImageView imageView);
+    void loadCircleBorderImage(String url, int placeholder, ImageView imageView, float borderWidth, int borderColor);
+    void loadCircleBorderImage(String url, int placeholder, ImageView imageView, float borderWidth, int borderColor, int heightPx, int widthPx);
+
+    void loadGifImage(String url, int placeholder, ImageView imageView);
+
+    void loadImageWithProgress(String url, ImageView imageView, ProgressLoadListener listener);
+    void loadImageWithPrepareCall(String url, ImageView imageView, int placeholder, SourceReadyListener listener);
+    void loadGifWithPrepareCall(String url, ImageView imageView, SourceReadyListener listener);
+
+    void clearImageDiskCache(final Context context);//清除硬盘缓存
+    void clearImageMemoryCache(Context context);   //清除内存缓存
+    void trimMemory(Context context, int level);    //根据不同的内存状态,来响应不同的内存释放策略
+    String getCacheSize(Context context); //获取缓存大小
+
+    void saveImage(Context context, String url, String savePath, String saveFileName, ImageSaveListener listener);//保存图像
+}

+ 133 - 0
app_core/imageload/src/main/java/com/library/imageloader/ImageLoaderUtil.java

@@ -0,0 +1,133 @@
+
+package com.library.imageloader;
+
+import android.content.Context;
+import android.widget.ImageView;
+
+import com.uas.uu.imageloader.iml.GlideImageLoaderStrategy;
+
+public class ImageLoaderUtil{
+
+
+    private static ImageLoaderUtil mInstance;
+    private BaseImageLoaderStrategy mStrategy;
+
+    public ImageLoaderUtil() {
+        mStrategy = new GlideImageLoaderStrategy();
+    }
+
+    //单例模式,节省资源
+    public static ImageLoaderUtil getInstance() {
+        if (mInstance == null) {
+            synchronized (ImageLoaderUtil.class) {
+                if (mInstance == null) {
+                    mInstance = new ImageLoaderUtil();
+                    return mInstance;
+                }
+            }
+        }
+        return mInstance;
+    }
+
+
+    public void loadImage(String url, int placeholder, ImageView imageView) {
+        mStrategy.loadImage(imageView.getContext(), url, placeholder, imageView);
+    }
+
+    public void loadGifImage(String url, int placeholder, ImageView imageView) {
+        mStrategy.loadGifImage(url, placeholder, imageView);
+    }
+
+    public void loadCircleImage(String url, int placeholder, ImageView imageView) {
+        mStrategy.loadCircleImage(url,placeholder,imageView);
+    }
+
+    public void loadCircleBorderImage(String url, int placeholder, ImageView imageView, float borderWidth, int borderColor) {
+        mStrategy.loadCircleBorderImage(url, placeholder, imageView, borderWidth, borderColor);
+    }
+
+    public void loadCircleBorderImage(String url, int placeholder, ImageView imageView, float borderWidth, int borderColor, int heightPX,int widthPX) {
+        mStrategy.loadCircleBorderImage(url, placeholder, imageView, borderWidth, borderColor, heightPX,widthPX);
+    }
+
+    public void loadImage(String url, ImageView imageView) {
+        mStrategy.loadImage(url, imageView);
+    }
+
+    public void loadImageWithAppCxt(String url, ImageView imageView) {
+        mStrategy.loadImageWithAppCxt(url,imageView);
+    }
+
+    public void loadImageWithProgress(String url, ImageView imageView, ProgressLoadListener listener) {
+        mStrategy.loadImageWithProgress(url,imageView,listener);
+    }
+
+    public void loadGifWithPrepareCall(String url, ImageView imageView, SourceReadyListener listener) {
+        mStrategy.loadGifWithPrepareCall(url,imageView,listener);
+    }
+
+    public void loadImageWithPrepareCall(String url, ImageView imageView,int placeholder, SourceReadyListener listener) {
+        mStrategy.loadImageWithPrepareCall(url, imageView, placeholder, listener);
+    }
+
+    /**
+     * 策略模式的注入操作
+     *
+     * @param strategy
+     */
+    public void setLoadImgStrategy(BaseImageLoaderStrategy strategy) {
+        mStrategy = strategy;
+    }
+
+    /**
+     * 需要展示图片加载进度的请参考 GalleryAdapter
+     * 样例如下所示
+     */
+
+    /**
+     * 清除图片磁盘缓存
+     */
+    public void clearImageDiskCache(final Context context) {
+        mStrategy.clearImageDiskCache(context);
+    }
+
+    /**
+     * 清除图片内存缓存
+     */
+    public void clearImageMemoryCache(Context context) {
+        mStrategy.clearImageMemoryCache(context);
+    }
+
+    /**
+     * 根据不同的内存状态,来响应不同的内存释放策略
+     *
+     * @param context
+     * @param level
+     */
+    public void trimMemory(Context context, int level) {
+        mStrategy.trimMemory(context, level);
+    }
+
+    /**
+     * 清除图片所有缓存
+     */
+    public void clearImageAllCache(Context context) {
+        clearImageDiskCache(context.getApplicationContext());
+        clearImageMemoryCache(context.getApplicationContext());
+    }
+
+    /**
+     * 获取缓存大小
+     *
+     * @return CacheSize
+     */
+    public String getCacheSize(Context context) {
+        return mStrategy.getCacheSize(context);
+    }
+
+    public void saveImage(Context context, String url, String savePath, String saveFileName, ImageSaveListener listener) {
+        mStrategy.saveImage(context, url, savePath, saveFileName, listener);
+    }
+
+
+}

+ 300 - 0
app_core/imageload/src/main/java/com/library/imageloader/iml/GlideImageLoaderStrategy.java

@@ -0,0 +1,300 @@
+package com.library.imageloader.iml;
+
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Looper;
+import android.text.TextUtils;
+import android.widget.ImageView;
+
+import com.bumptech.glide.Glide;
+import com.bumptech.glide.load.engine.DiskCacheStrategy;
+import com.bumptech.glide.load.resource.drawable.GlideDrawable;
+import com.bumptech.glide.load.resource.gif.GifDrawable;
+import com.bumptech.glide.request.RequestListener;
+import com.bumptech.glide.request.target.Target;
+import com.library.imageloader.BaseImageLoaderStrategy;
+import com.library.imageloader.listener.ImageSaveListener;
+import com.library.imageloader.listener.ProgressLoadListener;
+import com.library.imageloader.listener.SourceReadyListener;
+import com.library.imageloader.transformation.GlideCircleTransform;
+import com.library.imageloader.utils.FileUtils;
+import com.library.imageloader.utils.ImageUtils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.concurrent.ExecutionException;
+/**
+ * Created by Arison on 2017/5/22.
+ * 用GlideImageLoader加载图片
+ */
+public class GlideImageLoaderStrategy implements BaseImageLoaderStrategy {
+    @Override
+    public void loadImage(String url, ImageView imageView) {
+        Glide.with(imageView.getContext()).load(url)
+                .placeholder(imageView.getDrawable())
+                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
+                .into(imageView);
+    }
+
+    @Override
+    public void loadImageWithAppCxt(String url, ImageView imageView) {
+        Glide.with(imageView.getContext().getApplicationContext()).load(url)
+                .placeholder(imageView.getDrawable())
+                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
+                .into(imageView);
+    }
+
+    @Override
+    public void loadImage(String url, int placeholder, ImageView imageView) {
+        loadNormal(imageView.getContext(), url, placeholder, imageView);
+    }
+
+    @Override
+    public void loadImage(Context context, String url, int placeholder, ImageView imageView) {
+        loadNormal(context, url, placeholder, imageView);
+    }
+
+    @Override
+    public void loadCircleImage(String url, int placeholder, ImageView imageView) {
+        Glide.with(imageView.getContext())
+                .load(url)
+                .placeholder(placeholder).dontAnimate()
+                .transform(new GlideCircleTransform(imageView.getContext()))
+                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
+                .into(imageView);
+    }
+
+    @Override
+    public void loadCircleBorderImage(String url, int placeholder, ImageView imageView, float borderWidth, int borderColor) {
+        Glide.with(imageView.getContext())
+                .load(url)
+                .placeholder(placeholder)
+                .dontAnimate()
+                .transform(new GlideCircleTransform(imageView.getContext(), borderWidth, borderColor))
+                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
+                .into(imageView);
+    }
+
+    @Override
+    public void loadCircleBorderImage(String url, int placeholder, ImageView imageView, float borderWidth, int borderColor, int heightPx, int widthPx) {
+        Glide.with(imageView.getContext())
+                .load(url)
+                .placeholder(placeholder)
+                .dontAnimate()
+                .transform(new GlideCircleTransform(imageView.getContext(), borderWidth, borderColor, heightPx, widthPx))
+                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
+                .into(imageView);
+    }
+
+    @Override
+    public void loadGifImage(String url, int placeholder, ImageView imageView) {
+        loadGif(imageView.getContext(), url, placeholder, imageView);
+    }
+
+    /**
+      * @desc:图片加载进度 暂未实现
+      * @author:Arison on 2017/5/23
+      */
+    @Override
+    public void loadImageWithProgress(String url, ImageView imageView, ProgressLoadListener listener) {
+
+    }
+
+    @Override
+    public void loadImageWithPrepareCall(String url, ImageView imageView, int placeholder, final SourceReadyListener listener) {
+        Glide.with(imageView.getContext()).load(url)
+                .skipMemoryCache(true)
+                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
+                .placeholder(placeholder)
+                .listener(new RequestListener<String, GlideDrawable>() {
+                    @Override
+                    public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
+                        return false;
+                    }
+
+                    @Override
+                    public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
+                        listener.onResourceReady(resource.getIntrinsicWidth(), resource.getIntrinsicHeight());
+                        return false;
+                    }
+                }).into(imageView);
+    }
+
+    @Override
+    public void loadGifWithPrepareCall(String url, ImageView imageView, final SourceReadyListener listener) {
+        Glide.with(imageView.getContext()).load(url).asGif()
+                .skipMemoryCache(true)
+                .diskCacheStrategy(DiskCacheStrategy.SOURCE).
+                listener(new RequestListener<String, GifDrawable>() {
+                    @Override
+                    public boolean onException(Exception e, String model, Target<GifDrawable> target, boolean isFirstResource) {
+                        return false;
+                    }
+
+                    @Override
+                    public boolean onResourceReady(GifDrawable resource, String model, Target<GifDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
+                        listener.onResourceReady(resource.getIntrinsicWidth(), resource.getIntrinsicHeight());
+                        return false;
+                    }
+                }).into(imageView);
+    }
+
+    @Override
+    public void clearImageDiskCache(final Context context) {
+        try {
+            if (Looper.myLooper() == Looper.getMainLooper()) {
+                new Thread(new Runnable() {
+                    @Override
+                    public void run() {
+                        Glide.get(context.getApplicationContext()).clearDiskCache();
+                    }
+                }).start();
+            } else {
+                Glide.get(context.getApplicationContext()).clearDiskCache();
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public void clearImageMemoryCache(Context context) {
+        try {
+            if (Looper.myLooper() == Looper.getMainLooper()) {
+                //只能在主线程,即UI线程执行
+                Glide.get(context.getApplicationContext()).clearMemory();
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public void trimMemory(Context context, int level) {
+        Glide.get(context).trimMemory(level);
+    }
+
+    /**
+     * @desc:获取缓存文件的大小
+     * @author:Arison on 2017/5/23
+     */
+    @Override
+    public String getCacheSize(Context context) {
+        try {
+            return FileUtils.getFormatSize(FileUtils.getFolderSize(Glide.getPhotoCacheDir(context.getApplicationContext())));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    @Override
+    public void saveImage(Context context, String url, String savePath, String saveFileName, ImageSaveListener listener) {
+        if (!FileUtils.isSDCardExsit() || TextUtils.isEmpty(url)) {
+            listener.onSaveFail();
+            return;
+        }
+        InputStream fromStream=null;
+        OutputStream toStream=null;
+        try {
+            File cacheFile=Glide.with(context).load(url).downloadOnly(Target.SIZE_ORIGINAL,Target.SIZE_ORIGINAL).get();
+            if (cacheFile == null || !cacheFile.exists()) {
+                listener.onSaveFail();
+                return;
+            }
+
+            File dir = new File(savePath);
+            if (!dir.exists()) {
+                dir.mkdir();
+            }
+
+            File file = new File(dir, saveFileName + ImageUtils.getPicType(cacheFile.getAbsolutePath()));
+            fromStream = new FileInputStream(cacheFile);
+            toStream = new FileOutputStream(file);
+            byte length[] = new byte[1024];
+            int count;
+            while ((count = fromStream.read(length)) > 0) {
+                toStream.write(length, 0, count);
+            }
+            //用广播通知相册进行更新相册
+            Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
+            Uri uri = Uri.fromFile(file);
+            intent.setData(uri);
+            context.sendBroadcast(intent);
+            listener.onSaveSuccess();
+
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+            listener.onSaveFail();
+        } catch (ExecutionException e) {
+            e.printStackTrace();
+            listener.onSaveFail();
+        } catch (Exception e){
+            e.printStackTrace();
+            listener.onSaveFail();
+        }finally {
+            if (fromStream != null) {
+                try {
+                    fromStream.close();
+                    toStream.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                    fromStream = null;
+                    toStream = null;
+                }
+            }
+        }
+
+    }
+
+
+    /**
+     * load image with Glide
+     */
+    private void loadNormal(final Context ctx, final String url, int placeholder, ImageView imageView) {
+        Glide.with(ctx)
+                .load(url)
+                .placeholder(placeholder)
+                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
+                .listener(new RequestListener<String, GlideDrawable>() {
+                    @Override
+                    public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
+                        return false;
+                    }
+
+                    @Override
+                    public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
+                        return false;
+                    }
+                })
+                .into(imageView);
+    }
+
+
+    /**
+     * load image with Glide
+     */
+    private void loadGif(final Context ctx, String url, int placeholder, ImageView imageView) {
+        Glide.with(ctx).load(url)
+                .asGif()
+                .placeholder(placeholder)
+                .skipMemoryCache(true)//禁止内存缓存:
+                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
+                .listener(new RequestListener<String, GifDrawable>() {
+                    @Override
+                    public boolean onException(Exception e, String model, Target<GifDrawable> target, boolean isFirstResource) {
+                        return false;
+                    }
+
+                    @Override
+                    public boolean onResourceReady(GifDrawable resource, String model, Target<GifDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
+                        return false;
+                    }
+                }).into(imageView);
+    }
+}

+ 11 - 0
app_core/imageload/src/main/java/com/library/imageloader/listener/ImageSaveListener.java

@@ -0,0 +1,11 @@
+package com.library.imageloader.listener;
+
+/**
+ * Created by Arison on 2017/5/22.
+ * 图片保存监听器
+ */
+public interface ImageSaveListener {
+    void onSaveSuccess();
+
+    void onSaveFail();
+}

+ 14 - 0
app_core/imageload/src/main/java/com/library/imageloader/listener/ProgressLoadListener.java

@@ -0,0 +1,14 @@
+package com.library.imageloader.listener;
+
+/**
+ * Created by Arison on 2017/5/22.
+ * 图片加载进度
+ */
+public interface ProgressLoadListener {
+
+    void update(int bytesRead, int contentLength);
+
+    void onException();
+
+    void onResourceReady();
+}

+ 10 - 0
app_core/imageload/src/main/java/com/library/imageloader/listener/SourceReadyListener.java

@@ -0,0 +1,10 @@
+package com.library.imageloader.listener;
+
+/**
+ * 图片加载前
+ * 通知准备就绪
+ */
+public interface SourceReadyListener {
+
+    void onResourceReady(int width, int height);
+}

+ 164 - 0
app_core/imageload/src/main/java/com/library/imageloader/transformation/GlideCircleTransform.java

@@ -0,0 +1,164 @@
+package com.library.imageloader.transformation;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.BitmapShader;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.PorterDuff;
+import android.graphics.PorterDuffXfermode;
+import android.graphics.Rect;
+import android.graphics.RectF;
+
+import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
+import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
+import com.library.imageloader.utils.ScreenUtils;
+
+/**
+ * @desc:自定义BitmapTransformation来实现圆形图片加载
+ * @author:Arison on 2017/5/23
+ */
+public class GlideCircleTransform extends BitmapTransformation {
+
+    private Paint mBorderPaint;
+    private float mBorderWidth;
+
+    private int height = 0;
+    private int width = 0;
+    private int borderColor = 0;
+
+    public GlideCircleTransform(Context context) {
+        super(context);
+    }
+
+    public GlideCircleTransform(Context context, float borderWidth, int borderColor) {
+        super(context);
+        mBorderWidth = Resources.getSystem().getDisplayMetrics().density * borderWidth;
+        mBorderWidth = ScreenUtils.dip2px( borderWidth);
+        mBorderPaint = new Paint();
+        mBorderPaint.setDither(true);
+        mBorderPaint.setAntiAlias(true);
+        mBorderPaint.setColor(borderColor);
+        mBorderPaint.setStyle(Paint.Style.STROKE);
+        mBorderPaint.setStrokeWidth(mBorderWidth);
+    }
+
+    public GlideCircleTransform(Context context, float borderWidth, int borderColor, int heightPX, int widthPx) {
+        super(context);
+        mBorderWidth = Resources.getSystem().getDisplayMetrics().density * borderWidth;
+        mBorderWidth = ScreenUtils.dip2px(borderWidth);
+        mBorderPaint = new Paint();
+        mBorderPaint.setDither(true);
+        mBorderPaint.setAntiAlias(true);
+        mBorderPaint.setColor(borderColor);
+        mBorderPaint.setStyle(Paint.Style.STROKE);
+        mBorderPaint.setStrokeWidth(mBorderWidth);
+        width = widthPx;
+        height = heightPX;
+        this.borderColor = borderColor;
+    }
+
+
+    protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
+        if (width > 0) {
+            return circleCrop(pool, toTransform, outWidth, outHeight);
+        } else {
+            return circleCrop(pool, toTransform);
+        }
+    }
+
+    private Bitmap circleCrop(BitmapPool pool, Bitmap source) {
+        if (source == null) return null;
+
+        int size = (int) (Math.min(source.getWidth(), source.getHeight()) - (mBorderWidth / 2));
+        int x = (source.getWidth() - size) / 2;
+        int y = (source.getHeight() - size) / 2;
+        // TODO this could be acquired from the pool too
+        Bitmap squared = Bitmap.createBitmap(source, x, y, size, size);
+        Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888);
+        if (result == null) {
+            result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
+        }
+        Canvas canvas = new Canvas(result);
+        Paint paint = new Paint();
+        paint.setShader(new BitmapShader(squared, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
+        paint.setAntiAlias(true);
+        float r = size / 2f;
+        canvas.drawCircle(r, r, r, paint);
+        if (mBorderPaint != null) {
+            float borderRadius = r - mBorderWidth / 2;
+            canvas.drawCircle(r, r, borderRadius, mBorderPaint);
+        }
+        return result;
+    }
+
+    private Bitmap circleCrop(BitmapPool pool, Bitmap source, int outWidth, int outHeight) {
+        if (source == null) return null;
+        Bitmap result = pool.get(width, width, Bitmap.Config.ARGB_8888);
+        Bitmap output = Bitmap.createBitmap(width, width, Bitmap.Config.ARGB_8888);
+        Canvas canvas = new Canvas(output);
+        Paint paint = new Paint();
+        paint.setColor(borderColor);
+        paint.setAntiAlias(true);
+        Rect rect = new Rect(0, 0, width, width);
+        RectF rectF = new RectF(rect);
+        canvas.drawRoundRect(rectF, width, width, paint);
+        output = makeRoundCorner(output, width, borderColor);
+        result = makeRoundCorner(source, (int) (width - 2 * mBorderWidth), 0);
+        result = getAvatarInRoundBg(output, result);
+        return result;
+    }
+
+    //把头像保存成圆形图片
+    public Bitmap makeRoundCorner(Bitmap bitmap, int px, int borderColor) {
+        Bitmap output = Bitmap.createBitmap(px, px, Bitmap.Config.ARGB_8888);
+        Canvas canvas = new Canvas(output);
+        int color = 0xffffffff;
+        if (borderColor != 0) {
+            color = borderColor;
+        }
+        Paint paint = new Paint();
+        Rect rect = new Rect(0, 0, px, px);
+        RectF rectF = new RectF(rect);
+        paint.setAntiAlias(true);
+        canvas.drawARGB(0, 0, 0, 0);
+        paint.setColor(color);
+        canvas.drawRoundRect(rectF, px, px, paint);
+        paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
+
+//        if(bitmap.getWidth()/2-67>0 && bitmap.getHeight()/2-67>0) {
+        bitmap = Bitmap.createScaledBitmap(bitmap, px, px, true);
+//        }
+
+        canvas.drawBitmap(bitmap, rect, rect, paint);
+        return output;
+    }
+
+    //加上圆形背景环
+    private Bitmap getAvatarInRoundBg(Bitmap bg, Bitmap avatar) {
+        // 生成画布图像
+        Bitmap resultBitmap = Bitmap.createBitmap(width,
+                width, Bitmap.Config.ARGB_8888);
+        Canvas canvas = new Canvas(resultBitmap);// 使用空白图片生成canvas
+
+        // 将bmp1绘制在画布上
+        bg = Bitmap.createScaledBitmap(bg, width, width, true);
+        Rect srcRect = new Rect(0, 0, width, width);// 截取bmp1中的矩形区域
+        Rect dstRect = new Rect(0, 0, width, width);// bmp1在目标画布中的位置
+        canvas.drawBitmap(bg, srcRect, dstRect, null);
+
+        avatar = Bitmap.createScaledBitmap(avatar, (int) (width - 2 * mBorderWidth), (int) (width - 2 * mBorderWidth), true);
+        // 将bmp2绘制在画布上
+        srcRect = new Rect(0, 0, (int) (width - 2 * mBorderWidth), (int) (width - 2 * mBorderWidth));// 截取bmp1中的矩形区域
+        dstRect = new Rect((int) mBorderWidth, (int) mBorderWidth, (int) (width - mBorderWidth), (int) (width - mBorderWidth));// bmp2在目标画布中的位置
+        canvas.drawBitmap(avatar, srcRect, dstRect, null);
+        // 将bmp1,bmp2合并显示
+        return resultBitmap;
+    }
+
+    @Override
+    public String getId() {
+        return getClass().getName();
+    }
+}

+ 90 - 0
app_core/imageload/src/main/java/com/library/imageloader/utils/FileUtils.java

@@ -0,0 +1,90 @@
+package com.library.imageloader.utils;
+
+import android.os.Environment;
+
+import java.io.File;
+import java.math.BigDecimal;
+
+/**
+ * 文件操作
+ * 
+ * Created by Arison on 2017/5/17.
+ */
+public class FileUtils {
+
+    /**
+     * 获取SD卡的根目录
+     *
+     * @return
+     */
+    public static String getSDRoot() {
+        return Environment.getExternalStorageDirectory().getAbsolutePath();
+    }
+
+    public static boolean isSDCardExsit() {
+        String state = Environment.getExternalStorageState();
+        if (Environment.MEDIA_MOUNTED.equals(state)) {
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * 获取指定文件夹内所有文件大小的和
+     *
+     * @param file file
+     * @return size
+     * @throws Exception
+     */
+    public static long getFolderSize(File file) throws Exception {
+        long size = 0;
+        try {
+            File[] fileList = file.listFiles();
+            for (File aFileList : fileList) {
+                if (aFileList.isDirectory()) {
+                    size = size + getFolderSize(aFileList);
+                } else {
+                    size = size + aFileList.length();
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return size;
+    }
+
+    /**
+     * 格式化单位
+     *
+     * @param size size
+     * @return size
+     */
+    public static String getFormatSize(double size) {
+        
+        double kiloByte = size / 1024;
+        if (kiloByte < 1) {
+            return size + "Byte";
+        }
+
+        double megaByte = kiloByte / 1024;
+        if (megaByte < 1) {
+            BigDecimal result1 = new BigDecimal(Double.toString(kiloByte));
+            return result1.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "KB";
+        }
+
+        double gigaByte = megaByte / 1024;
+        if (gigaByte < 1) {
+            BigDecimal result2 = new BigDecimal(Double.toString(megaByte));
+            return result2.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "MB";
+        }
+
+        double teraBytes = gigaByte / 1024;
+        if (teraBytes < 1) {
+            BigDecimal result3 = new BigDecimal(Double.toString(gigaByte));
+            return result3.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "GB";
+        }
+        BigDecimal result4 = new BigDecimal(teraBytes);
+
+        return result4.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "TB";
+    }
+}

+ 32 - 0
app_core/imageload/src/main/java/com/library/imageloader/utils/ImageUtils.java

@@ -0,0 +1,32 @@
+package com.library.imageloader.utils;
+
+import android.graphics.BitmapFactory;
+import android.text.TextUtils;
+
+/**
+ * 图像处理工具类
+ * 
+ * Created by Arison on 2017/5/23.
+ */
+public class ImageUtils {
+
+    
+    
+    public static String getPicType(String pathName) {
+        BitmapFactory.Options options = new BitmapFactory.Options();
+        options.inJustDecodeBounds = true;
+        BitmapFactory.decodeFile(pathName, options);
+        String type = options.outMimeType;
+        if (!TextUtils.isEmpty(type)) {
+            try {
+                type = type.substring(6, type.length());
+                if ("gif".equals(type)) {
+                    return ".gif";
+                }
+            } catch (IndexOutOfBoundsException e) {
+                e.printStackTrace();
+            }
+        }
+        return ".jpg";
+    }
+}

+ 96 - 0
app_core/imageload/src/main/java/com/library/imageloader/utils/ScreenUtils.java

@@ -0,0 +1,96 @@
+package com.library.imageloader.utils;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.util.DisplayMetrics;
+
+import java.lang.reflect.Field;
+
+/**
+ * 屏幕相关工具类
+ * 
+ * Created by Arison on 2017/5/23.
+ */
+public class ScreenUtils {
+
+    public static int dip2px( float dpValue) {
+        final float scale = Utils.getContext().getResources().getDisplayMetrics().density;
+        return (int) (dpValue * scale + 0.5f);
+    }
+
+
+    public static int px2dip( float pxValue) {
+        final float scale = Utils.getContext().getResources().getDisplayMetrics().density;
+        return (int) (pxValue / scale + 0.5f);
+    }
+
+    public static int px2sp( float pxValue) {
+        final float scale = Utils.getContext().getResources().getDisplayMetrics().density;
+        return (int) (pxValue / scale + 0.5f);
+    }
+
+    public static int sp2px(float spValue) {
+        final float scale =Utils.getContext().getResources().getDisplayMetrics().density;
+        return (int) (spValue * scale + 0.5f);
+    }
+
+    public static int getScreenWidth(Context context) {
+        DisplayMetrics localDisplayMetrics = new DisplayMetrics();
+        ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics);
+        return localDisplayMetrics.widthPixels;
+    }
+
+    public static int getScreenHeight(Context context) {
+        DisplayMetrics localDisplayMetrics = new DisplayMetrics();
+        ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics);
+        return localDisplayMetrics.heightPixels - getStatusBarHeight(context);
+    }
+
+
+    /**
+     * @deprecated  use {@link #getScreenHeight(Context)} instead
+     * get screen size height in pixels
+     *
+     * @param context
+     * @return the pixels of the screen height
+     */
+    public static int getHeight(Activity context) {
+        DisplayMetrics dm = new DisplayMetrics();
+        context.getWindowManager().getDefaultDisplay().getMetrics(dm);
+        return dm.heightPixels;
+    }
+
+    public static int getStatusBarHeight(Context context){
+        Class<?> c = null;
+        Object obj = null;
+        Field field = null;
+        int x = 0, statusBarHeight = 0;
+        try {
+            c = Class.forName("com.android.internal.R$dimen");
+            obj = c.newInstance();
+            field = c.getField("status_bar_height");
+            x = Integer.parseInt(field.get(obj).toString());
+            statusBarHeight = context.getResources().getDimensionPixelSize(x);
+        } catch (Exception e1) {
+            e1.printStackTrace();
+        }
+        return statusBarHeight;
+    }
+
+
+    /**
+     * get toolbar height
+     *
+     * @param context
+     * @return
+     */
+    public static int getToolbarHeight(Context context) {
+        final TypedArray styledAttributes = context.getTheme().obtainStyledAttributes(
+                new int[]{android.R.attr.actionBarSize});
+        int toolbarHeight = (int) styledAttributes.getDimension(0, 0);
+        styledAttributes.recycle();
+
+        return toolbarHeight;
+    }
+}

+ 36 - 0
app_core/imageload/src/main/java/com/library/imageloader/utils/Utils.java

@@ -0,0 +1,36 @@
+package com.library.imageloader.utils;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+
+/**
+ * 需要注意Context对象为空的情况
+ * Created by Arison on 2017/5/24.
+ */
+public class Utils {
+    @SuppressLint("StaticFieldLeak")
+    private static Context context;
+
+    private Utils() {
+        throw new UnsupportedOperationException("u can't instantiate me...");
+    }
+
+    /**
+     * 初始化工具类
+     *
+     * @param context 上下文
+     */
+    public static void init(Context context) {
+        Utils.context = context.getApplicationContext();
+    }
+
+    /**
+     * 获取ApplicationContext
+     *
+     * @return ApplicationContext
+     */
+    public static Context getContext() {
+        if (context != null) return context;
+        throw new NullPointerException("u should init first");
+    }
+}

+ 11 - 0
app_core/network/build.gradle

@@ -28,7 +28,18 @@ dependencies {
     androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
         exclude group: 'com.android.support', module: 'support-annotations'
     })
+    compile project(':app_core')
+    compile fileTree(dir: 'libs', include: ['*.jar'])
+    testCompile deps.junit
+    compile deps.appcompatV7
 
     compile 'com.android.support:appcompat-v7:24.2.1'
     testCompile 'junit:junit:4.12'
+    compile deps.rxjava
+    compile deps.rxandroid
+    compile deps.okhttp
+    compile deps.retrofit
+    compile deps.converterGson
+    compile deps.adapterRxjava
+    compile deps.fastjson
 }

+ 185 - 0
app_core/network/src/main/java/network/app/base/BaseActivity.java

@@ -0,0 +1,185 @@
+package network.app.base;
+
+import android.os.Build;
+import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+
+/**
+ * 一般标准的activity基类封装
+ * 1:沉浸栏设置问题
+ * 2:
+ * Created by Arison on 2017/5/3.
+ */
+public abstract class BaseActivity extends AppCompatActivity implements View.OnClickListener{
+   
+    /*设置是否沉浸栏*/
+    private boolean isSetStatusBar = false;
+    /*设置是否全屏显示*/
+    private boolean isFullScreen = false;
+    /*设置是否禁止旋转屏幕*/
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        if (isSetStatusBar){
+            setStatusBar();
+        }
+        if (isFullScreen){
+            setAllowFullScreen(isFullScreen);
+        }
+        setContentView(getLayoutId());
+        initView();
+        setListener();
+        initData();
+    }
+
+    /**
+     * [沉浸状态栏]
+     */
+    private void setStatusBar() {
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
+            // 透明状态栏
+            getWindow().addFlags(
+                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
+            // 透明导航栏
+            getWindow().addFlags(
+                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
+        }
+    }
+
+    /**
+     * [是否允许全屏]
+     *
+     * @param allowFullScreen
+     */
+    protected void setAllowFullScreen(boolean allowFullScreen) {
+        if (allowFullScreen) {
+            requestWindowFeature(Window.FEATURE_NO_TITLE);
+            getWindow().setFlags(
+                    WindowManager.LayoutParams.FLAG_FULLSCREEN,
+                    WindowManager.LayoutParams.FLAG_FULLSCREEN
+            );
+        }
+    }
+
+    /**
+     * 获取状态栏高度
+     * @return
+     */
+/*    protected int getStatusBarHeight() {
+        int result = 0;
+        int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
+        if (resourceId > 0) {
+            result = getResources().getDimensionPixelSize(resourceId);
+        }
+        return result;
+    }*/
+
+    /**
+     * 设置ContentView
+     * @return R.layout.xxx
+     */
+    protected abstract int getLayoutId();
+
+    /**
+     * 初始化View
+     */
+    protected abstract void initView();
+
+    /**
+     * add Listener
+     */
+    protected abstract void setListener();
+
+    /**
+     * 初始化数据
+     */
+    protected abstract void initData();
+    
+    
+    @Override
+    public void onClick(View view) {
+        
+    }
+
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+    }
+
+    @Override
+    protected void onPause() {
+        super.onPause();
+    
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+    }
+
+    // findViewById
+ /*   public <T extends View> T $findViewById(int resId) {
+        return (T) findViewById(resId);
+    }*/
+
+    // Toast
+   /* protected void toast(CharSequence msg) {
+        Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
+    }*/
+
+    // Toast
+   /* protected void toast(int resId) {
+        Toast.makeText(this, resId, Toast.LENGTH_SHORT).show();
+    }*/
+
+    
+    // Log
+//    protected void $Log(String msg) {
+//        if (isDebug) {
+//            Log.d(this.getClass().getName(), msg);
+//        }
+//    }
+
+
+    // startActivity
+ /*   protected void startActivity(Class<?> cls) {
+        startActivity(cls, null);
+    }*/
+
+    // startActivity
+   /* protected void startActivity(Class<?> cls, Bundle bundle) {
+        Intent intent = new Intent(this, cls);
+        if (bundle != null) {
+            intent.putExtras(bundle);
+        }
+        startActivity(intent);
+    }*/
+
+    // startActivityForResult
+  /*  protected void startActivityForResult(Class<?> cls, int requestCode) {
+        startActivityForResult(cls, null, requestCode);
+    }*/
+
+    // startActivityForResult
+   /* protected void startActivityForResult(Class<?> cls, Bundle bundle, int requestCode) {
+        Intent intent = new Intent(this, cls);
+        if (bundle != null) {
+            intent.putExtras(bundle);
+        }
+        startActivityForResult(intent, requestCode);
+    }*/
+
+    // getIntent
+   /* protected Bundle getIntentExtra() {
+        Intent intent = getIntent();
+        Bundle bundle = null;
+        if (null != intent)
+            bundle = intent.getExtras();
+        return bundle;
+    }*/
+}

+ 57 - 0
app_core/network/src/main/java/network/app/base/BaseApplication.java

@@ -0,0 +1,57 @@
+package network.app.base;
+
+import android.app.Application;
+
+/**
+ * Created by Arison on 2017/5/15.
+ */
+public abstract class BaseApplication extends Application {
+    private static Application mApplication=null;
+    @Override
+    public void onCreate() {
+        super.onCreate();
+      
+        mApplication=this;
+        init();
+        //初始化网络库
+        initHttpClient();
+        //初始化图片库
+        initImageClient();
+        //初始化DBHelper
+        initDBHelper();
+        //初始化消息提醒库
+        initNotifyHelper();
+        //初始化日志打印
+        initLogHelper();
+      
+    }
+
+    public void initLogHelper() {
+//        Logger.init().
+//                logLevel(LogLevel.FULL)
+//                .methodCount(1);
+    }
+
+
+    public abstract void init();
+
+    public void initHttpClient() {
+
+    }
+
+    public void initImageClient() {
+
+    }
+
+    public void initDBHelper() {
+
+    }
+
+    public void initNotifyHelper() {
+
+    }
+
+    public static Application getInstance(){
+        return  mApplication;
+    }
+}

+ 49 - 0
app_core/network/src/main/java/network/app/http/HttpBase.java

@@ -0,0 +1,49 @@
+package network.app.http;
+
+
+import rx.Subscriber;
+
+public abstract class HttpBase {
+	
+	public HttpClient mbuilder;
+	/**
+	 * 设置全局builder 
+	 * 初始化全局参数
+	 * @param client
+	 */
+	public void setBuilder(HttpClient client) {
+		this.mbuilder=client;
+	}
+	
+    /**
+     * 初始化具体的网络请求客户端
+     * 初始化全局参数
+     * 比如Okhttp,Retrofit,Volley,HttpClient,HttpUrlConnection
+     */
+    public abstract void initClient();
+    
+	
+	/**
+	 * @param builder
+	 * @param s rxjava
+	 */
+	public  void send(HttpClient builder, Subscriber<Object> s){
+		if (builder.getMethod()==Method.GET) {
+			get(builder, s);
+		}
+		if (builder.getMethod()==Method.POST) {
+			post(builder, s);
+		}
+	}
+	/** 
+	  * @desc:上传功能 
+	 *         支持多文件上传
+	  * @author:Arison on 2017/5/17
+	  */
+	public void uploads(HttpClient builder,Subscriber<Object> s){}
+	
+	public abstract void get(HttpClient builder,Subscriber<Object> s);
+	
+	public abstract void post(HttpClient builder,Subscriber<Object> s);
+	
+}

+ 338 - 0
app_core/network/src/main/java/network/app/http/HttpClient.java

@@ -0,0 +1,338 @@
+package network.app.http;
+
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import network.app.http.impl.RetrofitImpl;
+
+
+/**
+ * @author Arison
+ * @desc:使用构建者设计模式封装
+ */
+public class HttpClient {
+
+    private String baseUrl;
+    private Map<String, Object> params = new HashMap<>();// 请求参数
+    private Map<String, Object> headers = new HashMap<>();//请求头
+
+    private long retryTimeout = 5;
+    private long connectTimeout;
+    private long readTimeout;
+    private long writeTimeout;
+
+    private int method;// 方法
+    private boolean isSyn;// 是否是同步
+    private int cacheType;// 缓存类型
+    private long cacheTime;//缓存时间
+    private File cacheFile;//缓存文件路径
+    private long cacheFileSize;//缓存文件大小
+    private int maxRetryCount;// 最大重试次数
+    private boolean isDebug;// 是否开启打印日志
+    private Builder mBuilder;
+
+    private HttpBase httpBase;
+    
+
+    public HttpClient(Builder builder) {
+        super();
+        setBuilder(builder);
+    }
+
+    private void setBuilder(Builder builder) {
+        this.baseUrl = builder.baseUrl;
+        this.params = builder.params;
+        this.headers = builder.headers;
+        this.retryTimeout = builder.retryTimeout;
+        this.connectTimeout = builder.connectTimeout;
+        this.readTimeout = builder.readTimeout;
+        this.writeTimeout = builder.writeTimeout;
+        this.method = builder.method;
+        this.isSyn = builder.isSyn;
+        this.cacheType = builder.cacheType;
+        this.cacheTime = builder.cacheTime;
+        this.cacheFile = builder.cacheFile;
+        this.cacheFileSize = builder.cacheFileSize;
+        this.maxRetryCount = builder.maxRetryCount;
+        this.isDebug = builder.isDebug;
+        this.httpBase = builder.httpBase;
+    }
+
+
+    private static HttpClient instance;
+    
+    public static HttpClient getInstance(){
+        if (instance == null) {
+            synchronized (HttpClient.class) {
+                if (instance == null) {
+                     instance=newInstance(new Builder());
+                }
+            }
+        }
+        return instance;
+    }
+
+    public static HttpClient getInstance(Builder builder) {
+        if (instance == null) {
+            synchronized (HttpClient.class) {
+                if (instance == null) {
+                    instance = newInstance(builder);
+                }
+            }
+        }
+        instance.setBuilder(builder);
+        return instance;
+    }
+
+    public static HttpClient newInstance(Builder builder) {
+        instance = new HttpClient(builder);
+        return instance;
+    }
+
+
+    public Builder newBuilder() {
+        return new Builder(this);
+    }
+
+
+    public static class Builder {
+
+        private String baseUrl;
+        private Map<String, Object> params = new HashMap<>();// 请求参数
+        private Map<String, Object> headers = new HashMap<>();//
+        private long connectTimeout;
+        private long readTimeout;
+        private long writeTimeout;
+        private int method;// 方法
+        private boolean isSyn;// 是否是同步
+        private int cacheType;// 缓存类型
+        private long cacheTime;//缓存时间
+        private File cacheFile;//缓存文件路径
+        private long cacheFileSize;//缓存文件大小
+        private int maxRetryCount;// 最大重试次数
+        private long retryTimeout = 5;//重试间隔时间
+        private boolean isDebug;// 是否开启打印日志
+        private HttpBase httpBase;//具体的网络请求类
+
+        //默认的参数
+        public Builder() {   
+            this.method = Method.GET;
+        }
+
+        public Builder(String url) {
+            this.baseUrl = url;
+        }
+
+        public Builder(HttpClient httpClient) {
+            this.baseUrl = httpClient.getBaseUrl();
+            this.params = httpClient.getParams();
+            this.headers = httpClient.getHeaders();
+            this.method = httpClient.getMethod();
+            this.connectTimeout = httpClient.getConnectTimeout();
+            this.readTimeout = httpClient.getReadTimeout();
+            this.retryTimeout = httpClient.getRetryTimeout();
+            this.writeTimeout = httpClient.getWriteTimeout();
+            this.isSyn = httpClient.isSyn();
+            this.isDebug = httpClient.isDebug();
+            this.cacheType = httpClient.getCacheType();
+            this.cacheTime = httpClient.getCacheTime();
+            this.cacheFileSize = httpClient.getCacheFileSize();
+            this.cacheFile = httpClient.getCacheFile();
+            this.maxRetryCount = httpClient.getMaxRetryCount();
+            this.httpBase = httpClient.Api();
+
+        }
+
+        public Builder url(String url) {
+            this.baseUrl = url;
+            return this;
+        }
+
+        public Builder add(String key, Object value) {
+            this.params.put(key, value);
+            return this;
+        }
+
+        public Builder header(String key, Object value) {
+            this.headers.put(key, value);
+            return this;
+        }
+
+        public Builder retryTimeout(long time) {
+            this.retryTimeout = time;
+            return this;
+        }
+
+        public Builder connectTimeout(long time) {
+            this.connectTimeout = time;
+            return this;
+        }
+
+        public Builder readTimeout(long time) {
+            this.readTimeout = time;
+            return this;
+        }
+
+        public Builder writeTimeout(long time) {
+            this.writeTimeout = time;
+            return this;
+        }
+
+        public Builder cacheType(int cacheType) {
+            this.cacheType = cacheType;
+            return this;
+        }
+
+        public Builder cacheTime(long cacheTime) {
+            this.cacheTime = cacheTime;
+            return this;
+        }
+
+        public Builder cacheFile(File cacheFile) {
+            this.cacheFile = cacheFile;
+            return this;
+        }
+
+        public Builder cacheFileSize(long cacheFileSize) {
+            this.cacheFileSize = cacheFileSize;
+            return this;
+        }
+
+        public Builder maxRetryCount(int maxRetryCount) {
+            this.maxRetryCount = maxRetryCount;
+            return this;
+        }
+
+        public Builder isDebug(boolean isDebug) {
+            this.isDebug = isDebug;
+            return this;
+        }
+
+        public Builder method(int method) {
+            this.method = method;
+            return this;
+        }
+
+        public Builder syn(boolean isSyn) {
+            this.isSyn = isSyn;
+            return this;
+        }
+
+        public Builder httpBase(HttpBase hb) {
+            this.httpBase = hb;
+            return this;
+        }
+
+        public HttpClient build() {
+            HttpClient client = newInstance(this);
+            return client;
+        }
+
+        public HttpClient build(boolean isSingle) {
+            if (isSingle) {
+                return getInstance(this);
+            } else {
+                return newInstance(this);
+            }
+        }
+    }
+
+
+    public String getBaseUrl() {
+        return baseUrl;
+    }
+
+    public Map<String, Object> getParams() {
+        return params;
+    }
+
+    public Map<String, Object> getHeaders() {
+        return headers;
+    }
+
+    public int getMethod() {
+        return method;
+    }
+
+    public boolean isSyn() {
+        return isSyn;
+    }
+
+    public int getCacheType() {
+        return cacheType;
+    }
+
+    public int getMaxRetryCount() {
+        return maxRetryCount;
+    }
+
+    public boolean isDebug() {
+        return isDebug;
+    }
+
+
+    public HttpBase Api() {
+        if (httpBase!=null) {
+            httpBase.setBuilder(this);
+            httpBase.initClient();
+        }else{
+            httpBase= RetrofitImpl.getInstance();
+        }
+        return httpBase;
+    }
+
+    public Builder getmBuilder() {
+        return mBuilder;
+    }
+
+    public void setmBuilder(Builder mBuilder) {
+        setBuilder(mBuilder);
+        this.mBuilder = mBuilder;
+    }
+
+
+    public long getRetryTimeout() {
+        return retryTimeout;
+    }
+
+    public long getConnectTimeout() {
+        return connectTimeout;
+    }
+
+    public long getReadTimeout() {
+        return readTimeout;
+    }
+
+    public long getWriteTimeout() {
+        return writeTimeout;
+    }
+
+
+    public long getCacheTime() {
+        return cacheTime;
+    }
+
+    public void setCacheTime(long cacheTime) {
+        this.cacheTime = cacheTime;
+    }
+
+
+    public File getCacheFile() {
+        return cacheFile;
+    }
+
+    public void setCacheFile(File cacheFile) {
+        this.cacheFile = cacheFile;
+    }
+
+    public long getCacheFileSize() {
+        return cacheFileSize;
+    }
+
+    public void setCacheFileSize(long cacheFileSize) {
+        this.cacheFileSize = cacheFileSize;
+    }
+  
+}

+ 9 - 0
app_core/network/src/main/java/network/app/http/Method.java

@@ -0,0 +1,9 @@
+package network.app.http;
+
+/**
+ * Created by Arison on 2017/5/12.
+ */
+public class Method {
+    public final static int GET = 0;
+    public final static int POST = 1;
+}

+ 11 - 0
app_core/network/src/main/java/network/app/http/cache/CacheType.java

@@ -0,0 +1,11 @@
+package network.app.http.cache;
+
+/**
+ * Created by Arison on 2017/5/12.
+ */
+public class CacheType {
+    public final static int ONLY_NETWORK = 0;//读取网络
+    public final static int ONLY_CACHED = 1;//读取缓存
+    public final static int CACHED_ELSE_NETWORK = 2;//先缓存后网络
+    public final static int NETWORK_ELSE_CACHED = 3;//先网络后缓存
+}

+ 170 - 0
app_core/network/src/main/java/network/app/http/impl/RetrofitImpl.java

@@ -0,0 +1,170 @@
+package network.app.http.impl;
+
+
+import com.google.gson.Gson;
+
+import java.io.File;
+import java.security.SecureRandom;
+import java.util.concurrent.TimeUnit;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManager;
+
+import network.app.http.HttpBase;
+import network.app.http.HttpClient;
+import network.app.http.interceptor.CacheInterceptor;
+import network.app.http.interceptor.LogInterceptor;
+import network.app.http.retrofit.StringConverterFactory;
+import network.app.http.rx.RxJavaUtils;
+import network.app.http.service.ParamService;
+import network.app.http.ssl.TrustAllCerts;
+import network.app.http.ssl.TrustAllHostnameVerifier;
+import okhttp3.Cache;
+import okhttp3.MultipartBody;
+import okhttp3.OkHttpClient;
+import okhttp3.OkHttpClient.Builder;
+import okhttp3.RequestBody;
+import retrofit2.Retrofit;
+import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
+import retrofit2.converter.gson.GsonConverterFactory;
+import rx.Observable;
+import rx.Subscriber;
+import rx.android.schedulers.AndroidSchedulers;
+import rx.functions.Func1;
+
+/**
+ * Retrofit封装Okhttp的方式进行网络操作
+ * 
+ * @author Arison
+ *
+ */
+public class RetrofitImpl extends HttpBase {
+
+	public Retrofit retrofit;
+	public ParamService paramService;
+	private static RetrofitImpl instance;
+	
+
+	public static RetrofitImpl getInstance() {
+		if (instance == null) {
+			synchronized (RetrofitImpl.class) {
+				if (instance == null) {
+					instance = new RetrofitImpl();
+				}
+			}
+		}
+
+		return instance;
+	}
+
+	@Override
+	public void initClient() {
+	  
+		Builder okBuilder = new Builder()
+				.connectTimeout(mbuilder.getConnectTimeout(), TimeUnit.SECONDS)
+				.readTimeout(mbuilder.getReadTimeout(), TimeUnit.SECONDS)
+				.writeTimeout(mbuilder.getWriteTimeout(), TimeUnit.SECONDS)
+				.sslSocketFactory(createSSLSocketFactory(), new TrustAllCerts())// 信任所有证书
+				.hostnameVerifier(new TrustAllHostnameVerifier());
+
+		LogInterceptor logInterceptor = new LogInterceptor();
+		logInterceptor.setBuilder(mbuilder);
+		okBuilder.addInterceptor(logInterceptor);	
+		okBuilder.cache(new Cache(mbuilder.getCacheFile(), mbuilder.getCacheFileSize()));
+		okBuilder.addInterceptor(new CacheInterceptor(String.valueOf(mbuilder.getCacheTime()),mbuilder.getCacheType()));
+
+
+		OkHttpClient client = okBuilder.build();
+		retrofit = new Retrofit.Builder().client(client)
+				.baseUrl(mbuilder.getBaseUrl())
+				.addConverterFactory(StringConverterFactory.create())
+				.addConverterFactory(GsonConverterFactory.create(new Gson()))
+				.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
+				.build();
+
+		paramService = initApi(ParamService.class);
+	}
+
+	public <T> T initApi(Class<T> service) {
+		return retrofit.create(service);
+	}
+
+	@Override
+	public void get(HttpClient builder, Subscriber<Object> s) {
+		Observable<Object> o = paramService.getParam(builder.getBaseUrl(), builder.getParams(), builder.getHeaders());
+		toSubscribe(o, s);
+		
+	}
+
+	@Override
+	public void post(HttpClient builder, Subscriber<Object> s) {
+		Observable<Object> o = paramService.postParam(builder.getBaseUrl(), builder.getParams(), builder.getHeaders());
+		toSubscribe(o, s);
+	}
+	
+	@Override
+	public void uploads(HttpClient mBuilder,Subscriber<Object> s){
+		MultipartBody.Builder builder = new MultipartBody.Builder();
+		builder.setType(MultipartBody.FORM);
+		//追加参数
+		for (String key : mBuilder.getParams().keySet()) {
+			Object object = mBuilder.getParams().get(key);
+			if (!(object instanceof File)) {
+				builder.addFormDataPart(key, object.toString());
+			} else {
+				File file = (File) object;
+				//其中参数“file”和服务器接收的参数 一一对应,保证多文件上传唯一key不变
+				builder.addFormDataPart("file", file.getName(), RequestBody.create(null, file));
+			}
+		}
+		//创建RequestBody
+		RequestBody body = builder.build();
+		Observable<Object> o=paramService.uploads(mBuilder.getBaseUrl(), body);
+		toSubscribe(o, s);
+	}
+
+	private <T> void toSubscribe(Observable<T> o, Subscriber<T> s) {
+		o.retryWhen(new Func1<Observable<? extends Throwable>, Observable<?>>() {
+
+			@Override
+			public Observable<?> call(Observable<? extends Throwable> t) {
+           
+				return t.flatMap(new Func1<Throwable, Observable<?>>() {
+					private int count = 0;
+                     
+					@Override
+					public Observable<?> call(Throwable t) {
+						if (++count <= mbuilder.getMaxRetryCount()) {
+//							Logger.d("请求重试"+count+":"+t.getMessage());
+							Observable<?> ob=	Observable.timer(mbuilder.getRetryTimeout(), TimeUnit.MILLISECONDS);
+							return ob;
+						}
+		
+						return Observable.error(t);
+					}
+				});
+			}
+		}).map(new Func1<T, T>() {
+
+			@Override
+			public T call(T t) {
+				return (T) t;
+			}
+		}).subscribeOn(RxJavaUtils.getScheduler("newThread"))
+				.observeOn(AndroidSchedulers.mainThread())
+				.subscribe(s);
+	}
+
+
+	public SSLSocketFactory createSSLSocketFactory() {
+		SSLSocketFactory ssfFactory = null;
+		try {
+			SSLContext sc = SSLContext.getInstance("TLS");
+			sc.init(null,  new TrustManager[] { new TrustAllCerts() }, new SecureRandom());
+			ssfFactory = sc.getSocketFactory();
+		} catch (Exception e) {
+		}
+		return ssfFactory;
+	}
+}

+ 55 - 0
app_core/network/src/main/java/network/app/http/interceptor/CacheInterceptor.java

@@ -0,0 +1,55 @@
+package network.app.http.interceptor;
+
+
+import java.io.IOException;
+
+import network.app.http.cache.CacheType;
+import okhttp3.CacheControl;
+import okhttp3.Interceptor;
+import okhttp3.Request;
+import okhttp3.Response;
+
+/**
+ * 缓存拦截器
+ * @author Arison
+ * 
+ */
+public class CacheInterceptor implements Interceptor {
+	
+	private String cacheTime;//缓存时间
+	private int cacheType;//缓存时间
+	
+	public CacheInterceptor(String cacheTime,int cacheType) {
+		super();
+		this.cacheTime = cacheTime;
+		this.cacheType=cacheType;
+	}
+
+	@Override
+	public Response intercept(Chain chain) throws IOException {
+		  Request request = chain.request();
+		  
+		  switch(cacheType) {
+		  	case CacheType.ONLY_NETWORK:
+		  		 request = request.newBuilder()
+               .cacheControl(CacheControl.FORCE_NETWORK)//只访问網絡
+               .build();
+			break;
+			case CacheType.ONLY_CACHED:
+				 request = request.newBuilder()
+               .cacheControl(CacheControl.FORCE_CACHE)//只访问缓存
+               .build();
+			break;
+			default:
+			break;
+		}
+	      Response response = chain.proceed(request);
+	      Response response1 = response.newBuilder()
+	                .removeHeader("Pragma")
+	                .removeHeader("Cache-Control")
+	                .header("Cache-Control", "max-age=" + cacheTime)
+	                .build();
+	        return response1;
+	}
+
+}

+ 99 - 0
app_core/network/src/main/java/network/app/http/interceptor/LogInterceptor.java

@@ -0,0 +1,99 @@
+package network.app.http.interceptor;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import network.app.http.HttpClient;
+import okhttp3.FormBody;
+import okhttp3.HttpUrl;
+import okhttp3.Interceptor;
+import okhttp3.Request;
+import okhttp3.Response;
+
+public class LogInterceptor implements Interceptor {
+	
+	private HttpClient builder;
+
+	public LogInterceptor() {
+	  super();
+	}
+	
+	public LogInterceptor(HttpClient builder) {
+		this.builder = builder;
+	}
+
+	@Override
+	public Response intercept(Chain chain) throws IOException {
+		  Request request = chain.request();
+		  Map<String, Object> headers;
+		  Map<String, Object> params;
+		  Map<String,Object> postParam=new HashMap<>();
+		  //添加公共Header,公共参数
+		  if (builder!=null) {
+			  headers=builder.getHeaders();
+			  params=builder.getParams();
+			if(!headers.isEmpty()){
+			  for (Map.Entry<String,Object> entry : headers.entrySet()) {
+				  request=request.newBuilder()
+						  .addHeader(entry.getKey(), String.valueOf(entry.getValue()))
+						  .build();
+				  }
+			}
+			if (!params.isEmpty()) {
+				  //get请求    添加公共参数
+				  if(request.method().equals("GET")){
+					  for (Map.Entry<String, Object> entry : params.entrySet()) {
+						  HttpUrl httpUrl=request.url().newBuilder()
+								  .addQueryParameter(entry.getKey(), String.valueOf(entry.getValue()))
+								  .build();
+						  postParam.put(entry.getKey(),  String.valueOf(entry.getValue()));
+						  request=request.newBuilder().url(httpUrl).build();
+						
+					} 
+				  }
+				  if(request.method().equals("POST")){
+					  if (request.body() instanceof FormBody) {
+						  FormBody.Builder bodyBuilder = new FormBody.Builder();
+						  FormBody formBody = (FormBody) request.body();
+						  for (int i = 0; i < formBody.size(); i++) {
+								postParam.put(formBody.encodedName(i), formBody.encodedValue(i));
+				                bodyBuilder.addEncoded(formBody.encodedName(i), formBody.encodedValue(i));
+				            }
+						  for (Map.Entry<String, Object> entry :params.entrySet()) {
+							  postParam.put(entry.getKey(), String.valueOf(entry.getValue()));
+							  formBody = bodyBuilder
+					                    .addEncoded(entry.getKey(), String.valueOf(entry.getValue()))
+					                    .build();
+						  }
+						  request = request.newBuilder().post(formBody).build();
+					  }
+				  }
+			}
+		  }
+		
+		  Response response = chain.proceed(request);
+		  okhttp3.MediaType mediaType = response.body().contentType();
+          String content = response.body().string();
+		
+         if (builder.isDebug()) {
+			/* Logger.init("PRETTYLOGGER")
+					 .hideThreadInfo()
+					 .methodCount(0);
+			 Logger.i("url:" + JSON.toJSONString(response.request().url().toString()));
+			 Logger.i("headers:"+ JSON.toJSONString(response.request().headers().toMultimap()));
+			 Logger.i("params:" + JSON.toJSONString(postParam));
+			 Logger.init("PRETTYLOGGER")
+					 .methodCount(1);*/
+		}
+    
+		return response.newBuilder()
+                .body(okhttp3.ResponseBody.create(mediaType, content))
+                .build();
+	}
+
+	public void setBuilder(HttpClient builder) {
+		this.builder = builder;
+	}
+	
+}

+ 31 - 0
app_core/network/src/main/java/network/app/http/retrofit/StringConverterFactory.java

@@ -0,0 +1,31 @@
+package network.app.http.retrofit;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import okhttp3.RequestBody;
+import okhttp3.ResponseBody;
+import retrofit2.Converter;
+import retrofit2.Retrofit;
+
+public class StringConverterFactory extends Converter.Factory{
+	
+	  public static StringConverterFactory create() {
+	        return new StringConverterFactory();
+	    }
+
+	    private StringConverterFactory() {
+
+	    }
+	 @Override
+	    public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations,
+	                                                            Retrofit retrofit) {
+	        return new StringResponseBodyConverter();
+	    }
+
+	    @Override
+	    public Converter<?, RequestBody> requestBodyConverter(Type type,
+	                                                          Annotation[] parameterAnnotations, Annotation[] methodAnnotations, Retrofit retrofit) {
+	        return new StringRequestBodyConverter();
+	    }
+}

+ 27 - 0
app_core/network/src/main/java/network/app/http/retrofit/StringRequestBodyConverter.java

@@ -0,0 +1,27 @@
+package network.app.http.retrofit;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.nio.charset.Charset;
+
+import okhttp3.MediaType;
+import okhttp3.RequestBody;
+import okio.Buffer;
+import retrofit2.Converter;
+
+public class StringRequestBodyConverter  implements Converter<String, RequestBody> {
+    private static final MediaType MEDIA_TYPE = MediaType.parse("application/json; charset=UTF-8");
+    private static final Charset UTF_8 = Charset.forName("UTF-8");
+
+    StringRequestBodyConverter() {
+    }
+
+    @Override public RequestBody convert(String value) throws IOException {
+        @SuppressWarnings("resource")
+		Buffer buffer = new Buffer();
+        Writer writer = new OutputStreamWriter(buffer.outputStream(), UTF_8);
+        writer.write(value);
+        writer.close();
+        return RequestBody.create(MEDIA_TYPE, buffer.readByteString());
+    }
+}

+ 19 - 0
app_core/network/src/main/java/network/app/http/retrofit/StringResponseBodyConverter.java

@@ -0,0 +1,19 @@
+package network.app.http.retrofit;
+
+import java.io.IOException;
+
+import okhttp3.ResponseBody;
+import retrofit2.Converter;
+
+public class StringResponseBodyConverter implements Converter<ResponseBody, String> {
+
+	@Override
+	public String convert(ResponseBody value) throws IOException {
+		  try {
+	            return value.string();
+	        } finally {
+	            value.close();
+	        }
+	}
+
+}

+ 10 - 0
app_core/network/src/main/java/network/app/http/rx/Result1Listener.java

@@ -0,0 +1,10 @@
+package network.app.http.rx;
+
+/**
+ * @author Arison
+ * 回调接口
+ * @param <T>
+ */
+public interface Result1Listener<T> extends ResultListener<T>{
+	void onResponse(T t);
+}

+ 11 - 0
app_core/network/src/main/java/network/app/http/rx/Result2Listener.java

@@ -0,0 +1,11 @@
+package network.app.http.rx;
+
+/**
+ * @author Arison
+ * 回调接口
+ * @param <T>
+ */
+public interface Result2Listener<T> extends ResultListener<T>{
+	 void onResponse(T t);
+	 void onFailure(Object t);
+}

+ 8 - 0
app_core/network/src/main/java/network/app/http/rx/ResultListener.java

@@ -0,0 +1,8 @@
+package network.app.http.rx;
+
+/**
+ * Created by Arison on 2017/5/16.
+ */
+public interface ResultListener<T> {
+    void onResponse(T t);
+}

+ 87 - 0
app_core/network/src/main/java/network/app/http/rx/ResultSubscriber.java

@@ -0,0 +1,87 @@
+package network.app.http.rx;
+
+import com.orhanobut.logger.Logger;
+
+import java.io.IOException;
+import java.net.ConnectException;
+import java.net.SocketTimeoutException;
+
+import retrofit2.adapter.rxjava.HttpException;
+import rx.Subscriber;
+
+/**
+ * @author Arison
+ * 网络订阅者
+ * @param <T>
+ */
+public class ResultSubscriber<T> extends Subscriber<T> {
+
+	private ResultListener<T> resultListener;
+	private Result2Listener<T> result2Listener;
+	
+	public ResultSubscriber(ResultListener<T> listener) {
+		if (listener!=null){
+			if (listener instanceof  Result2Listener){
+				this.result2Listener= (Result2Listener<T>) listener;
+			}
+			this.resultListener=listener;
+		}
+	}
+	
+	@Override
+	public void onStart() {
+		super.onStart();
+		//Logger.d("网络请求开始 onStart()");
+	}
+	
+	
+	@Override
+	public void onCompleted() {
+		//Logger.d("网络请求结束 onCompleted()");
+	}
+
+	@Override
+	public void onError(Throwable e) {
+		if (result2Listener!=null) {
+			if (e instanceof SocketTimeoutException) {
+				Logger.e("SocketTimeoutException");
+				result2Listener.onFailure(e);
+			} else if (e instanceof ConnectException) {
+				Logger.e("ConnectException");
+				result2Listener.onFailure(e);
+			} else if(e instanceof HttpException){
+				HttpException he = (HttpException) e;
+				try {
+					result2Listener.onFailure(he.response().errorBody().string());
+				} catch (IOException e1) {
+					e1.printStackTrace();
+				}
+			}else{
+				resultListener.onResponse((T)e);
+			}
+		}else{
+			if (e instanceof HttpException){
+				try {
+					resultListener.onResponse((T) ((HttpException) e).response().errorBody().string());
+				} catch (IOException e1) {
+					e1.printStackTrace();
+				}
+			}else if (e instanceof SocketTimeoutException){
+				resultListener.onResponse((T) e);
+			}else if(e instanceof ConnectException){
+				resultListener.onResponse((T)e);
+			}else {
+				resultListener.onResponse((T)e);
+			}
+			
+		}
+	}
+
+	@Override
+	public void onNext(T t) {
+		if (resultListener!=null){
+			resultListener.onResponse(t);
+		}
+	}
+
+}

+ 23 - 0
app_core/network/src/main/java/network/app/http/rx/RxJavaUtils.java

@@ -0,0 +1,23 @@
+package network.app.http.rx;
+
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+
+import rx.Scheduler;
+import rx.schedulers.Schedulers;
+
+/**
+ * Created by Arison on 2017/5/15.
+ */
+public class RxJavaUtils {
+
+    public static Scheduler getScheduler(final String name) {
+       return Schedulers.from(Executors.newCachedThreadPool(new ThreadFactory() {
+            @Override
+            public Thread newThread(Runnable runnable) {
+                return new Thread(runnable,name);
+            }
+        }));
+       // return Schedulers.from(Executors.newCachedThreadPool(r -> new Thread(r,name)));
+    }
+}

+ 45 - 0
app_core/network/src/main/java/network/app/http/service/ParamService.java

@@ -0,0 +1,45 @@
+package network.app.http.service;
+
+import java.util.Map;
+
+import okhttp3.RequestBody;
+import retrofit2.http.Body;
+import retrofit2.http.FieldMap;
+import retrofit2.http.FormUrlEncoded;
+import retrofit2.http.GET;
+import retrofit2.http.HeaderMap;
+import retrofit2.http.POST;
+import retrofit2.http.QueryMap;
+import retrofit2.http.Url;
+import rx.Observable;
+
+/**
+ * @desc:主要用于网络请求
+ * @name:ParamService
+ * @method:Rxjava+Retrofit
+ * @author Arison
+ */
+public interface ParamService {
+   
+	@GET()
+	Observable<Object> getParam(@Url String url);
+	@GET()
+	Observable<Object> getParam(@Url String url, @QueryMap Map<String, Object> param);
+	@GET()
+	Observable<Object> getParam(@Url String url, @QueryMap Map<String, Object> param, @HeaderMap Map<String, Object> header);
+	@FormUrlEncoded
+	@POST()
+	Observable<Object> postParam(@Url String url);
+	@FormUrlEncoded
+	@POST()
+	Observable<Object> postParam(@Url String url, @FieldMap Map<String, Object> param);
+	@FormUrlEncoded
+	@POST()
+	Observable<Object> postParam(@Url String url, @FieldMap Map<String, Object> param, @HeaderMap Map<String, Object> header);
+
+
+	@POST()
+	Observable<Object> uploads(
+            @Url String url,
+            @Body RequestBody body);
+}

+ 26 - 0
app_core/network/src/main/java/network/app/http/ssl/TrustAllCerts.java

@@ -0,0 +1,26 @@
+package network.app.http.ssl;
+
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.X509TrustManager;
+
+/**
+ * Created by Arison on 2017/5/15.
+ */
+public class TrustAllCerts implements X509TrustManager {
+    @Override
+    public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
+        
+    }
+
+    @Override
+    public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
+
+    }
+
+    @Override
+    public X509Certificate[] getAcceptedIssuers() {
+        return new X509Certificate[0];
+    }
+}

+ 14 - 0
app_core/network/src/main/java/network/app/http/ssl/TrustAllHostnameVerifier.java

@@ -0,0 +1,14 @@
+package network.app.http.ssl;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.SSLSession;
+
+/**
+ * Created by Arison on 2017/5/15.
+ */
+public class TrustAllHostnameVerifier implements HostnameVerifier {
+    @Override
+    public boolean verify(String s, SSLSession sslSession) {
+        return true;
+    }
+}

+ 1 - 1
build.gradle

@@ -1,5 +1,5 @@
 // Top-level build file where you can add configuration options common to all sub-projects/modules.
-
+apply from: "version.gradle"
 buildscript {
     repositories {
         jcenter()

+ 0 - 1
version.gradle

@@ -51,7 +51,6 @@ ext {
             adapterRxjava     : 'com.squareup.retrofit2:adapter-rxjava:' + depsVersion.retrofitVersion,
 
             glide             : 'com.github.bumptech.glide:glide:' + depsVersion.glideVersion,
-            
             supertoasts       :'com.github.johnpersano:supertoasts:'+depsVersion.supertoastsVersion,
             alerter            :'com.tapadoo.android:alerter:'+depsVersion.alerterVersion
     ]