| 21478 |
rajender |
1 |
package com.saholic.profittill.main;
|
|
|
2 |
|
|
|
3 |
import android.app.Application;
|
|
|
4 |
import android.content.Context;
|
|
|
5 |
|
|
|
6 |
import com.android.volley.RequestQueue;
|
|
|
7 |
import com.android.volley.toolbox.Volley;
|
|
|
8 |
import com.google.android.gms.analytics.GoogleAnalytics;
|
|
|
9 |
import com.google.android.gms.analytics.Tracker;
|
|
|
10 |
import com.saholic.profittill.R;
|
|
|
11 |
|
|
|
12 |
import java.util.HashMap;
|
|
|
13 |
|
|
|
14 |
public class GoogleAnalyticsTracker extends Application {
|
|
|
15 |
private static final String PROPERTY_ID = "UA-59241805-2";
|
|
|
16 |
public static int GENERAL_TRACKER = 0;
|
|
|
17 |
private RequestQueue mRequestQueue;
|
|
|
18 |
private static GoogleAnalyticsTracker mInstance;
|
|
|
19 |
|
|
|
20 |
public static synchronized GoogleAnalyticsTracker getInstance() {
|
|
|
21 |
return mInstance;
|
|
|
22 |
}
|
|
|
23 |
|
|
|
24 |
public static Context getAppContext(){
|
|
|
25 |
return mInstance.getApplicationContext();
|
|
|
26 |
}
|
|
|
27 |
|
|
|
28 |
public enum TrackerName {
|
|
|
29 |
APP_TRACKER, GLOBAL_TRACKER, ECOMMERCE_TRACKER,
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
public HashMap mTrackers = new HashMap();
|
|
|
33 |
|
|
|
34 |
public GoogleAnalyticsTracker() {
|
|
|
35 |
super();
|
|
|
36 |
}
|
|
|
37 |
public synchronized Tracker getTracker(TrackerName appTracker) {
|
|
|
38 |
if (!mTrackers.containsKey(appTracker)) {
|
|
|
39 |
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
|
|
|
40 |
Tracker t = (appTracker == TrackerName.APP_TRACKER) ? analytics.newTracker(PROPERTY_ID) : (appTracker == TrackerName.GLOBAL_TRACKER) ? analytics.newTracker(R.xml.global_tracker) : analytics.newTracker(R.xml.ecommerce_tracker);
|
|
|
41 |
mTrackers.put(appTracker, t);
|
|
|
42 |
}
|
|
|
43 |
return (Tracker) mTrackers.get(appTracker);
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
@Override
|
|
|
48 |
public void onCreate() {
|
|
|
49 |
super.onCreate();
|
|
|
50 |
mInstance = this;
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
public RequestQueue getRequestQueue() {
|
|
|
54 |
if (mRequestQueue == null) {
|
|
|
55 |
mRequestQueue = Volley.newRequestQueue(getApplicationContext());
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
return mRequestQueue;
|
|
|
59 |
}
|
|
|
60 |
}
|