Skip to content

Commit c06e484

Browse files
author
Emre Demir
committed
HttpRequestQueque is used for requests. Old-fashioned methods removed.
New game api implemented. Useless classes/methods removed.
1 parent 5803fc9 commit c06e484

28 files changed

+633
-1442
lines changed

Source/GDApi/gdapi/libs/gdapi.jar

-267 KB
Binary file not shown.

Source/GDApi/gdapi/src/main/java/com/gd/analytics/GDCallback.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,8 @@
66

77
public abstract class GDCallback {
88

9-
public void callback(Object level){};
9+
public void callback(Object level) {
10+
}
11+
12+
;
1013
}

Source/GDApi/gdapi/src/main/java/com/gd/analytics/GDEvent.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
* Created by Emre Demir on 23.09.2016.
55
*/
66

7-
public class GDEvent
8-
{
7+
public class GDEvent {
98
public Object dimensions;
109
public boolean isInterstitial;
1110

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.gd.analytics;
2+
3+
/**
4+
* Created by demiremrece on 30.11.2017.
5+
*/
6+
7+
public class GDGameData {
8+
9+
public static String gameMd5, title;
10+
public static boolean enableAds, preRoll;
11+
public static int timeAds;
12+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.gd.analytics;
2+
3+
import android.content.Context;
4+
import com.android.volley.Request;
5+
import com.android.volley.RequestQueue;
6+
import com.android.volley.toolbox.Volley;
7+
8+
9+
/**
10+
* Created by demiremrece on 30.11.2017.
11+
*/
12+
13+
public class GDHttp {
14+
15+
private static GDHttp instance;
16+
private RequestQueue requestQueue;
17+
private Context context;
18+
19+
private GDHttp(Context context){
20+
this.context = context;
21+
this.requestQueue = getRequestQueue();
22+
}
23+
24+
private RequestQueue getRequestQueue() {
25+
if(this.requestQueue == null){
26+
this.requestQueue = Volley.newRequestQueue(this.context);
27+
}
28+
return this.requestQueue;
29+
}
30+
31+
public static synchronized GDHttp getInstance (Context context){
32+
if(instance == null){
33+
instance = new GDHttp(context);
34+
}return instance;
35+
}
36+
37+
public<T> void addToRequestQueue(Request<T> request) {
38+
requestQueue.add(request);
39+
}
40+
41+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.gd.analytics;
2+
3+
import com.android.volley.VolleyError;
4+
import com.google.gson.JsonObject;
5+
6+
import org.json.JSONObject;
7+
8+
/**
9+
* Created by demiremrece on 30.11.2017.
10+
*/
11+
12+
public interface GDHttpCallback {
13+
void onSuccess(JSONObject data);
14+
void onError(VolleyError error);
15+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.gd.analytics;
2+
3+
import android.content.Context;
4+
import com.android.volley.Response;
5+
import com.android.volley.VolleyError;
6+
import com.android.volley.toolbox.JsonObjectRequest;
7+
import com.google.gson.JsonObject;
8+
9+
import org.json.JSONObject;
10+
11+
/**
12+
* Created by demiremrece on 30.11.2017.
13+
*/
14+
15+
public class GDHttpRequest {
16+
17+
public static void sendHttpRequest (Context context, String url, int method, JsonObject data, final GDHttpCallback callback){
18+
19+
JsonObjectRequest jsObjRequest = new JsonObjectRequest
20+
(method, url, null, new Response.Listener<JSONObject>() {
21+
22+
@Override
23+
public void onResponse(JSONObject response) {
24+
callback.onSuccess(response);
25+
}
26+
}, new Response.ErrorListener() {
27+
28+
@Override
29+
public void onErrorResponse(VolleyError error) {
30+
callback.onError(error);
31+
}
32+
});
33+
34+
GDHttp.getInstance(context).addToRequestQueue(jsObjRequest);
35+
36+
}
37+
38+
}

0 commit comments

Comments
 (0)