75 lines
3.2 KiB
Java
75 lines
3.2 KiB
Java
package com.diyidan.game.network;
|
|
|
|
import android.content.Context;
|
|
import com.alipay.sdk.sys.a;
|
|
import com.android.volley.DefaultRetryPolicy;
|
|
import com.android.volley.Response;
|
|
import com.diyidan.game.network.util.DydStringRequest;
|
|
import com.diyidan.game.network.util.VolleySingleton;
|
|
import com.diyidan.game.util.Utils;
|
|
import java.util.Map;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
/* JADX INFO: loaded from: C:\Users\11789\Documents\Projects\Codex_ws\myrzx_fang\analysis\base_classes.dex */
|
|
public class BaseNetwork2<T> {
|
|
protected INetworkHandler callbackHandler;
|
|
protected Context mContext;
|
|
protected Response.ErrorListener mErrorListener;
|
|
protected Response.Listener<String> mSuccessListener;
|
|
protected int requestTag;
|
|
protected String url;
|
|
|
|
public BaseNetwork2(Context context, INetworkHandler iNetworkHandler, int i) {
|
|
this.mContext = context;
|
|
this.callbackHandler = iNetworkHandler;
|
|
this.requestTag = i;
|
|
}
|
|
|
|
protected void initSuccessListener(Class<T> cls) {
|
|
this.mSuccessListener = new SuccessListener(this.callbackHandler, this.requestTag, cls);
|
|
}
|
|
|
|
protected void initErrorListener() {
|
|
this.mErrorListener = new DydErrorListener(this.mContext, this.requestTag, this.callbackHandler);
|
|
}
|
|
|
|
protected void addRequestToQueue(int i, String str, Map<String, String> map, Response.Listener<String> listener, Response.ErrorListener errorListener) {
|
|
if (str != null) {
|
|
String str2 = "versionCode=1.0.1&buildNumber=2016122900&appChannel=" + Utils.getAppChannel(this.mContext);
|
|
if (str.contains("?")) {
|
|
str = str + a.b + str2;
|
|
} else {
|
|
str = str + "?" + str2;
|
|
}
|
|
}
|
|
String str3 = str;
|
|
this.url = str3;
|
|
DydStringRequest dydStringRequest = new DydStringRequest(i, str3, map, listener, errorListener);
|
|
if (i == 1) {
|
|
dydStringRequest.setRetryPolicy(new DefaultRetryPolicy((int) TimeUnit.SECONDS.toMillis(15L), 0, 1.0f));
|
|
} else {
|
|
dydStringRequest.setRetryPolicy(new DefaultRetryPolicy((int) TimeUnit.SECONDS.toMillis(15L), 0, 1.0f));
|
|
}
|
|
VolleySingleton.getInstance(this.mContext).addToRequestQueue(dydStringRequest);
|
|
}
|
|
|
|
protected void addRequestToQueueWithLongRetry(int i, String str, Map<String, String> map, Response.Listener<String> listener, Response.ErrorListener errorListener) {
|
|
if (str != null) {
|
|
String str2 = "versionCode=" + Utils.getVersionCode(this.mContext) + "&appChannel=" + Utils.getAppChannel(this.mContext);
|
|
if (str.contains("?")) {
|
|
str = str + a.b + str2;
|
|
} else {
|
|
str = str + "?" + str2;
|
|
}
|
|
}
|
|
String str3 = str;
|
|
this.url = str3;
|
|
DydStringRequest dydStringRequest = new DydStringRequest(i, str3, map, listener, errorListener);
|
|
if (i == 1) {
|
|
dydStringRequest.setRetryPolicy(new DefaultRetryPolicy((int) TimeUnit.SECONDS.toMillis(30L), 0, 1.0f));
|
|
} else {
|
|
dydStringRequest.setRetryPolicy(new DefaultRetryPolicy((int) TimeUnit.SECONDS.toMillis(30L), 0, 1.0f));
|
|
}
|
|
VolleySingleton.getInstance(this.mContext).addToRequestQueue(dydStringRequest);
|
|
}
|
|
} |