This repository was archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathFlowApplication.java
More file actions
92 lines (74 loc) · 3.08 KB
/
FlowApplication.java
File metadata and controls
92 lines (74 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package com.uwflow.flow_android;
import android.app.Application;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import com.mixpanel.android.mpmetrics.MixpanelAPI;
import com.crashlytics.android.Crashlytics;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
import com.uwflow.flow_android.network.FlowAsyncClient;
import org.json.JSONObject;
public class FlowApplication extends Application {
public static final boolean isBlackberry = System.getProperty("os.name").equals("qnx");
private static final String IS_USER_LOGGED_IN_KEY = "is_user_logged_in";
private static final String MIXPANEL_TOKEN = "0a5e88bd3f288fe8a2d8adf94b452212";
private boolean mIsUserLoggedIn = false;
private MixpanelAPI mMixpanel = null;
@Override
public void onCreate() {
super.onCreate();
Crashlytics.start(this);
// Do init here
FlowAsyncClient.init(getApplicationContext());
DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
.cacheInMemory(true)
.cacheOnDisc(true)
.displayer(new FadeInBitmapDisplayer(500))
.build();
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
.defaultDisplayImageOptions(defaultOptions)
.build();
ImageLoader.getInstance().init(config);
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
if (preferences != null) {
mIsUserLoggedIn = preferences.getBoolean(IS_USER_LOGGED_IN_KEY, false);
}
getMixpanel();
}
public boolean isUserLoggedIn() {
return mIsUserLoggedIn;
}
public void setUserLoggedIn(boolean isUserLoggedIn) {
this.mIsUserLoggedIn = isUserLoggedIn;
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
if (preferences != null) {
preferences.edit().putBoolean(IS_USER_LOGGED_IN_KEY, isUserLoggedIn).commit();
}
}
/**
* @return A reference to the singleton Mixpanel API tracker object.
*/
public MixpanelAPI getMixpanel() {
if (mMixpanel == null) {
mMixpanel = MixpanelAPI.getInstance(getApplicationContext(), MIXPANEL_TOKEN);
}
return mMixpanel;
}
/**
* Records an event and sends to analytics loggers.
* @param eventName
*/
public void track(String eventName) {
track(eventName, new JSONObject());
}
/**
* Records an event and sends to analytics loggers.
* @param eventName
* @param properties Additional parameters for this event.
*/
public void track(String eventName, JSONObject properties) {
getMixpanel().track("Android: " + eventName, properties);
}
}