| 16279 |
manas |
1 |
package com.saholic.profittill.Volley;
|
|
|
2 |
|
|
|
3 |
import android.content.Context;
|
|
|
4 |
|
|
|
5 |
import com.android.volley.AuthFailureError;
|
|
|
6 |
import com.android.volley.NetworkResponse;
|
|
|
7 |
import com.android.volley.Request;
|
|
|
8 |
import com.android.volley.RequestQueue;
|
|
|
9 |
import com.android.volley.Response;
|
|
|
10 |
import com.android.volley.toolbox.StringRequest;
|
|
|
11 |
import com.saholic.profittill.Constants.ProfitTillConstants;
|
|
|
12 |
|
|
|
13 |
import org.json.JSONObject;
|
|
|
14 |
|
|
|
15 |
import java.util.HashMap;
|
|
|
16 |
import java.util.Map;
|
|
|
17 |
|
|
|
18 |
/**
|
|
|
19 |
* Created by kshitij on 24/7/15.
|
|
|
20 |
*/
|
|
|
21 |
public class Analytics extends Request<JSONObject> {
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
private Response.Listener<JSONObject> listener;
|
| 17064 |
manas |
25 |
private Response.Listener<String> stringListener;
|
| 16279 |
manas |
26 |
private Response.ErrorListener errorListener ;
|
|
|
27 |
private Map<String, String> params;
|
|
|
28 |
private String analyticsUrl;
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
public Analytics(String url, Map<String, String> params,
|
| 17064 |
manas |
32 |
Response.Listener<JSONObject> reponseListener, Response.ErrorListener errorListener) {
|
| 16279 |
manas |
33 |
super(Method.GET, url, errorListener);
|
|
|
34 |
this.listener = reponseListener;
|
|
|
35 |
this.errorListener = errorListener;
|
|
|
36 |
this.params = params;
|
|
|
37 |
this.analyticsUrl=url;
|
|
|
38 |
}
|
|
|
39 |
|
| 17064 |
manas |
40 |
public Analytics(String url, Map<String, String> params,
|
|
|
41 |
Response.Listener<String> reponseListener, Response.ErrorListener errorListener,int i) {
|
|
|
42 |
super(Method.GET, url, errorListener);
|
|
|
43 |
this.stringListener = reponseListener;
|
|
|
44 |
this.errorListener = errorListener;
|
|
|
45 |
this.params = params;
|
|
|
46 |
this.analyticsUrl=url;
|
|
|
47 |
}
|
|
|
48 |
|
| 16279 |
manas |
49 |
public void anlyticsRequest(Context c){
|
|
|
50 |
RequestQueue queue = AnalyticsSingleton.getmInstance().getRequestQueue();
|
|
|
51 |
StringRequest request = new StringRequest(
|
| 17064 |
manas |
52 |
Method.POST,
|
| 16279 |
manas |
53 |
analyticsUrl,
|
|
|
54 |
AnalyticsStringResponse.getAnalyticsStringRequestInstance(),
|
|
|
55 |
errorListener
|
|
|
56 |
){
|
|
|
57 |
@Override
|
|
|
58 |
protected Map<String, String> getParams() throws AuthFailureError {
|
|
|
59 |
return params;
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
@Override
|
|
|
63 |
public Map<String, String> getHeaders() throws AuthFailureError {
|
|
|
64 |
HashMap<String, String> headers = new HashMap<String, String>();
|
|
|
65 |
String auth = ProfitTillConstants.BASIC_AUTH;
|
|
|
66 |
headers.put("Authorization", auth);
|
|
|
67 |
return headers;
|
|
|
68 |
}
|
|
|
69 |
};
|
|
|
70 |
queue.add(request);
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
@Override
|
|
|
74 |
protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) {
|
|
|
75 |
return null;
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
@Override
|
|
|
79 |
protected void deliverResponse(JSONObject response) {
|
|
|
80 |
|
|
|
81 |
}
|
|
|
82 |
}
|