package com.wzgiceman.rxretrofitlibrary.retrofit_rx.Api;

import retrofit2.Retrofit;
import rx.Observable;

/**
 * 请求数据统一封装类
 * Created by WZG on 2016/7/16.
 */
public abstract class BaseApi {
    /*是否能取消加载框*/
    private boolean cancel = false;
    /*是否显示加载框*/
    private boolean showProgress = true;
    /*是否需要缓存处理*/
    private boolean cache = false;
    /*基础url*/
    private String baseUrl = "https://www.izaodao.com/Api/";
    /*方法-如果需要缓存必须设置这个参数；不需要不用設置*/
    private String method="";
    /*超时时间-默认6秒*/
    private int connectionTime = 6;
    /*有网情况下的本地缓存时间默认60秒*/
    private int cookieNetWorkTime = 60;
    /*无网络的情况下本地缓存时间默认30天*/
    private int cookieNoNetWorkTime = 24 * 60 * 60 * 30;
    /* retry次数*/
    private int retryCount = 1;
    /*retry延迟*/
    private long retryDelay = 100;
    /*retry叠加延迟*/
    private long retryIncreaseDelay = 100;

    /**
     * 设置参数
     *
     * @param retrofit
     * @return
     */
    public abstract Observable getObservable(Retrofit retrofit);



    public int getCookieNoNetWorkTime() {
        return cookieNoNetWorkTime;
    }

    public void setCookieNoNetWorkTime(int cookieNoNetWorkTime) {
        this.cookieNoNetWorkTime = cookieNoNetWorkTime;
    }

    public int getCookieNetWorkTime() {
        return cookieNetWorkTime;
    }

    public void setCookieNetWorkTime(int cookieNetWorkTime) {
        this.cookieNetWorkTime = cookieNetWorkTime;
    }


    public int getConnectionTime() {
        return connectionTime;
    }

    public void setConnectionTime(int connectionTime) {
        this.connectionTime = connectionTime;
    }

    public String getBaseUrl() {
        return baseUrl;
    }

    public void setBaseUrl(String baseUrl) {
        this.baseUrl = baseUrl;
    }

    public String getUrl() {
        return baseUrl + getMethod();
    }

    public boolean isCache() {
        return cache;
    }

    public void setCache(boolean cache) {
        this.cache = cache;
    }

    public boolean isShowProgress() {
        return showProgress;
    }

    public void setShowProgress(boolean showProgress) {
        this.showProgress = showProgress;
    }

    public boolean isCancel() {
        return cancel;
    }

    public void setCancel(boolean cancel) {
        this.cancel = cancel;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public int getRetryCount() {
        return retryCount;
    }

    public void setRetryCount(int retryCount) {
        this.retryCount = retryCount;
    }

    public long getRetryDelay() {
        return retryDelay;
    }

    public void setRetryDelay(long retryDelay) {
        this.retryDelay = retryDelay;
    }

    public long getRetryIncreaseDelay() {
        return retryIncreaseDelay;
    }

    public void setRetryIncreaseDelay(long retryIncreaseDelay) {
        this.retryIncreaseDelay = retryIncreaseDelay;
    }
}

@@ -482,17 +482,19 @@
 g method
-=
+ = 
 %22%22;%0A    
@@ -853,16 +853,65 @@
 y = 100;
+%0A    /*%E7%BC%93%E5%AD%98url-%E5%8F%AF%E6%89%8B%E5%8A%A8%E8%AE%BE%E7%BD%AE*/%0A    private String cacheUrl;
 %0A%0A    /*
@@ -1044,17 +1044,16 @@
 fit);%0A%0A%0A
-%0A
     publ
@@ -1814,32 +1814,122 @@
 ring getUrl() %7B%0A
+        /*%E5%9C%A8%E6%B2%A1%E6%9C%89%E6%89%8B%E5%8A%A8%E8%AE%BE%E7%BD%AEurl%E6%83%85%E5%86%B5%E4%B8%8B%EF%BC%8C%E7%AE%80%E5%8D%95%E6%8B%BC%E6%8E%A5*/%0A        if (null == cacheUrl %7C%7C %22%22.equals(cacheUrl)) %7B%0A    
         return b
@@ -1927,23 +1927,28 @@
  return 
-b
+getB
 aseUrl
+()
  + getMe
@@ -1955,16 +1955,56 @@
 thod();%0A
+        %7D%0A        return getCacheUrl();%0A
     %7D%0A%0A 
@@ -3066,32 +3066,32 @@
 ncreaseDelay) %7B%0A
-
         this.ret
@@ -3133,11 +3133,165 @@
 y;%0A    %7D
+%0A%0A    public String getCacheUrl() %7B%0A        return cacheUrl;%0A    %7D%0A%0A    public void setCacheUrl(String cacheUrl) %7B%0A        this.cacheUrl = cacheUrl;%0A    %7D
 %0A%7D%0A

添加cacheUrl手动设置功能，避免 多复用和共用接口无法成功使用缓存的问题