Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.saholic.profittill.Volley;import android.content.Context;import com.android.volley.AuthFailureError;import com.android.volley.NetworkResponse;import com.android.volley.Request;import com.android.volley.RequestQueue;import com.android.volley.Response;import com.android.volley.toolbox.StringRequest;import com.saholic.profittill.Constants.ProfitTillConstants;import org.json.JSONObject;import java.util.HashMap;import java.util.Map;/*** Created by kshitij on 24/7/15.*/public class Analytics extends Request<JSONObject> {private Response.Listener<JSONObject> listener;private Response.ErrorListener errorListener ;private Map<String, String> params;private String analyticsUrl;public Analytics(String url, Map<String, String> params,Response.Listener<JSONObject> reponseListener, Response.ErrorListener errorListener) {super(Method.GET, url, errorListener);this.listener = reponseListener;this.errorListener = errorListener;this.params = params;this.analyticsUrl=url;}public void anlyticsRequest(Context c){RequestQueue queue = AnalyticsSingleton.getmInstance().getRequestQueue();StringRequest request = new StringRequest(Request.Method.POST,analyticsUrl,AnalyticsStringResponse.getAnalyticsStringRequestInstance(),errorListener){@Overrideprotected Map<String, String> getParams() throws AuthFailureError {return params;}@Overridepublic Map<String, String> getHeaders() throws AuthFailureError {HashMap<String, String> headers = new HashMap<String, String>();String auth = ProfitTillConstants.BASIC_AUTH;headers.put("Authorization", auth);return headers;}};queue.add(request);}@Overrideprotected Response<JSONObject> parseNetworkResponse(NetworkResponse response) {return null;}@Overrideprotected void deliverResponse(JSONObject response) {}}