导航菜单

页面标题

页面副标题

Crafto v9.3.3 - VolleyPostRequest.java 源代码

正在查看: Crafto v9.3.3 应用的 VolleyPostRequest.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.paytmpayments.customuisdk.NetworkHandler;

import androidx.annotation.NonNull;
import com.android.volley.AuthFailureError;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.NetworkResponse;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.HttpHeaderParser;
import com.google.gson.i;
import com.paytmpayments.customuisdk.Utils.GzipUtils;
import com.paytmpayments.customuisdk.base.DependencyProvider;
import com.paytmpayments.customuisdk.common.model.CustomVolleyError;
import com.paytmpayments.customuisdk.common.utils.LogUtility;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;

public class VolleyPostRequest extends Request {
    private static final String PROTOCOL_CHARSET = "utf-8";
    private static final String PROTOCOL_CONTENT_TYPE = "application/json; charset=utf-8";
    private final String TAG;
    private Class classType;
    private Response.ErrorListener mErrorListener;
    private Map<String, String> mHeaders;
    private Response.Listener mListener;
    private Map<String, String> mParams;
    private final String mRequestBody;
    private String mUrl;
    private Request.Priority requestPriority;

    public VolleyPostRequest(int i, String str, Map<String, String> map, Map<String, String> map2, String str2, Response.Listener listener, Response.ErrorListener errorListener) {
        super(i, str, errorListener);
        this.TAG = VolleyPostRequest.class.getName();
        this.mHeaders = map;
        this.mRequestBody = str2;
        this.mParams = map2;
        this.mUrl = str;
        this.mListener = listener;
        this.mErrorListener = errorListener;
    }

    public int compareTo(@NonNull Object obj) {
        return 0;
    }

    public void deliverError(com.android.volley.VolleyError r11) {
        throw new UnsupportedOperationException("Method not decompiled: com.paytmpayments.customuisdk.NetworkHandler.VolleyPostRequest.deliverError(com.android.volley.VolleyError):void");
    }

    public void deliverResponse(Object obj) {
        try {
            Response.Listener listener = this.mListener;
            if (listener != null) {
                listener.onResponse(obj);
            }
        } catch (Exception e) {
            if (DependencyProvider.getEventLogger() != null) {
                DependencyProvider.getEventLogger().sendCrashLogs("com.paytmpayments.customuisdk.data", "deliverResponse", e);
            }
            e.printStackTrace();
        }
    }

    public byte[] getBody() {
        try {
            String str = this.mRequestBody;
            return str == null ? super.getBody() : str.getBytes(PROTOCOL_CHARSET);
        } catch (UnsupportedEncodingException e) {
            if (DependencyProvider.getEventLogger() != null) {
                DependencyProvider.getEventLogger().sendCrashLogs("com.paytmpayments.customuisdk.data", "getBody", e);
            }
            return super.getBody();
        }
    }

    public String getBodyContentType() {
        try {
            return getParams() != null ? "application/x-www-form-urlencoded" : PROTOCOL_CONTENT_TYPE;
        } catch (AuthFailureError e) {
            if (DependencyProvider.getEventLogger() != null) {
                DependencyProvider.getEventLogger().sendCrashLogs("com.paytmpayments.customuisdk.data", "getBodyContentType", e);
            }
            e.printStackTrace();
            return PROTOCOL_CONTENT_TYPE;
        }
    }

    public Map<String, String> getHeaders() {
        if (this.mHeaders == null) {
            this.mHeaders = new HashMap();
        }
        this.mHeaders.put("Accept-Encoding", "gzip");
        Map<String, String> map = this.mHeaders;
        return map != null ? map : super.getHeaders();
    }

    public Map<String, String> getParams() {
        Map<String, String> map = this.mParams;
        return map != null ? map : super.getParams();
    }

    public Request.Priority getPriority() {
        Request.Priority priority = this.requestPriority;
        return priority != null ? priority : super.getPriority();
    }

    public Response parseNetworkResponse(NetworkResponse networkResponse) {
        try {
            String str = (String) networkResponse.headers.get("Content-Encoding");
            String str2 = networkResponse.data != null ? (str == null || !str.equals("gzip")) ? new String(networkResponse.data) : GzipUtils.convertString(GzipUtils.convertReader(networkResponse.data)) : "";
            LogUtility.d(this.TAG, "=====response======" + str2);
            Class cls = this.classType;
            if (cls == String.class) {
                return Response.success(str2, HttpHeaderParser.parseCacheHeaders(networkResponse));
            }
            if (cls != JSONObject.class) {
                return Response.success(new i().c(this.classType, str2), HttpHeaderParser.parseCacheHeaders(networkResponse));
            }
            try {
                return Response.success(new JSONObject(str2), HttpHeaderParser.parseCacheHeaders(networkResponse));
            } catch (JSONException e) {
                e.printStackTrace();
                return Response.error(new CustomVolleyError(networkResponse, this.mUrl, e.getLocalizedMessage()));
            }
        } catch (Exception e2) {
            LogUtility.d("VolleyPostRequest", e2.toString());
            return Response.error(new CustomVolleyError(networkResponse, this.mUrl, e2.getLocalizedMessage()));
        }
    }

    public void setRequestPriority(Request.Priority priority) {
        this.requestPriority = priority;
    }

    public VolleyPostRequest(int i, String str, Map<String, String> map, Map<String, String> map2, String str2, Response.Listener listener, Response.ErrorListener errorListener, Class cls) {
        super(i, str, errorListener);
        String name = VolleyPostRequest.class.getName();
        this.TAG = name;
        this.mHeaders = map;
        this.mRequestBody = str2;
        this.mParams = map2;
        this.mUrl = str;
        this.mListener = listener;
        this.classType = cls;
        this.mErrorListener = errorListener;
        LogUtility.d(name, "====request====" + str2);
        LogUtility.d(name, "=======url====" + str);
        setRetryPolicy(new DefaultRetryPolicy(0, 1, 1.0f));
    }

    public VolleyError parseNetworkError(VolleyError volleyError) {
        return volleyError;
    }
}