| 21480 |
rajender |
1 |
package com.saholic.profittill.main;
|
|
|
2 |
import android.Manifest;
|
| 22132 |
rajender |
3 |
import android.annotation.TargetApi;
|
| 21480 |
rajender |
4 |
import android.app.AlarmManager;
|
|
|
5 |
import android.app.Fragment;
|
|
|
6 |
import android.app.FragmentManager;
|
|
|
7 |
import android.app.PendingIntent;
|
|
|
8 |
import android.content.Context;
|
|
|
9 |
import android.content.Intent;
|
|
|
10 |
import android.content.SharedPreferences;
|
| 22832 |
rajender |
11 |
import android.content.pm.ActivityInfo;
|
| 21480 |
rajender |
12 |
import android.content.pm.PackageManager;
|
|
|
13 |
import android.content.res.Configuration;
|
|
|
14 |
import android.graphics.Color;
|
| 22132 |
rajender |
15 |
import android.graphics.PorterDuff;
|
| 21480 |
rajender |
16 |
import android.graphics.drawable.ColorDrawable;
|
| 22132 |
rajender |
17 |
import android.graphics.drawable.Drawable;
|
| 21480 |
rajender |
18 |
import android.net.ConnectivityManager;
|
|
|
19 |
import android.net.Uri;
|
|
|
20 |
import android.os.AsyncTask;
|
| 22132 |
rajender |
21 |
import android.os.Build;
|
| 21480 |
rajender |
22 |
import android.os.Bundle;
|
|
|
23 |
import android.os.PersistableBundle;
|
|
|
24 |
import android.os.SystemClock;
|
|
|
25 |
import android.support.v4.app.ActionBarDrawerToggle;
|
|
|
26 |
import android.support.v4.app.ActivityCompat;
|
|
|
27 |
import android.support.v4.content.ContextCompat;
|
|
|
28 |
import android.support.v4.widget.DrawerLayout;
|
|
|
29 |
import android.support.v7.app.ActionBarActivity;
|
|
|
30 |
import android.util.Log;
|
|
|
31 |
import android.view.KeyEvent;
|
|
|
32 |
import android.view.Menu;
|
| 22832 |
rajender |
33 |
import android.view.View;
|
| 21480 |
rajender |
34 |
import android.view.ViewConfiguration;
|
|
|
35 |
import android.view.Window;
|
|
|
36 |
import android.webkit.CookieManager;
|
|
|
37 |
import android.webkit.CookieSyncManager;
|
|
|
38 |
import android.widget.ExpandableListView;
|
|
|
39 |
import android.widget.LinearLayout;
|
|
|
40 |
|
|
|
41 |
import com.google.android.gms.analytics.HitBuilders;
|
|
|
42 |
import com.google.android.gms.analytics.Tracker;
|
|
|
43 |
import com.google.android.gms.common.ConnectionResult;
|
|
|
44 |
import com.google.android.gms.common.api.GoogleApiClient;
|
|
|
45 |
import com.google.android.gms.plus.Plus;
|
|
|
46 |
import com.mixpanel.android.mpmetrics.MixpanelAPI;
|
|
|
47 |
import com.saholic.profittill.Constants.ProfitTillConstants;
|
|
|
48 |
import com.saholic.profittill.Network.NotificationCount;
|
|
|
49 |
import com.saholic.profittill.R;
|
|
|
50 |
import com.saholic.profittill.Services.PollingService;
|
|
|
51 |
import com.saholic.profittill.Utils.AnalyticsUtility;
|
|
|
52 |
import com.saholic.profittill.Utils.DESEncrypter;
|
|
|
53 |
import com.saholic.profittill.Utils.UtilityFunctions;
|
|
|
54 |
import com.saholic.profittill.Volley.Analytics;
|
|
|
55 |
import com.saholic.profittill.Volley.AnalyticsErrorResponse;
|
|
|
56 |
import com.saholic.profittill.Volley.AnalyticsJsonResponse;
|
| 22132 |
rajender |
57 |
|
| 21480 |
rajender |
58 |
import com.testin.agent.TestinAgent;
|
|
|
59 |
|
|
|
60 |
import org.apache.http.HttpEntity;
|
|
|
61 |
import org.apache.http.HttpResponse;
|
|
|
62 |
import org.apache.http.NameValuePair;
|
|
|
63 |
import org.apache.http.client.HttpClient;
|
|
|
64 |
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
|
|
65 |
import org.apache.http.client.methods.HttpPost;
|
|
|
66 |
import org.apache.http.impl.client.DefaultHttpClient;
|
|
|
67 |
import org.apache.http.message.BasicNameValuePair;
|
|
|
68 |
import org.json.JSONException;
|
|
|
69 |
import org.json.JSONObject;
|
|
|
70 |
|
|
|
71 |
import java.lang.reflect.Field;
|
|
|
72 |
import java.lang.reflect.Method;
|
|
|
73 |
import java.util.ArrayList;
|
|
|
74 |
import java.util.Date;
|
|
|
75 |
import java.util.HashMap;
|
|
|
76 |
import java.util.List;
|
|
|
77 |
import java.util.Map;
|
|
|
78 |
|
|
|
79 |
|
|
|
80 |
public class MainActivity extends ActionBarActivity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
|
|
|
81 |
public GoogleApiClient mGoogleApiClient;
|
|
|
82 |
SharedPreferences userData;
|
|
|
83 |
SharedPreferences apiData;
|
|
|
84 |
boolean glogout;
|
|
|
85 |
SharedPreferences.Editor userDataEditor;
|
|
|
86 |
SharedPreferences.Editor apiSettingsEditor;
|
|
|
87 |
SharedPreferences.Editor inviteDataEditor;
|
|
|
88 |
SharedPreferences inviteData;
|
|
|
89 |
String type1;
|
|
|
90 |
int flag;
|
| 22132 |
rajender |
91 |
Context context;
|
| 21480 |
rajender |
92 |
boolean shouldGoInvisible;
|
|
|
93 |
int titleVisible;
|
|
|
94 |
String redirectUrl;
|
|
|
95 |
MixpanelAPI mixpanel;
|
|
|
96 |
String notificationURL;
|
|
|
97 |
ArrayList<NameValuePair> nameValuePairsGcm;
|
|
|
98 |
private DrawerLayout mDrawerLayout;
|
|
|
99 |
private ExpandableListView mDrawerList;
|
|
|
100 |
private LinearLayout navDrawerView;
|
| 22132 |
rajender |
101 |
//ExpandableNavigationAdapter customAdapter;
|
| 21480 |
rajender |
102 |
private ActionBarDrawerToggle mDrawerToggle;
|
|
|
103 |
private CharSequence mDrawerTitle;
|
|
|
104 |
private CharSequence mTitle;
|
|
|
105 |
private String[] mPlanetTitles;
|
|
|
106 |
private String[] mHelpTtiles;
|
|
|
107 |
private int selectedPosition;
|
| 22132 |
rajender |
108 |
//List<ExpandableNavigationItem> listParent;
|
| 21480 |
rajender |
109 |
HashMap<String, List<String>> listDataChild;
|
|
|
110 |
public static final int SMS_RECIEVE_PERMISSION = 100;
|
| 22132 |
rajender |
111 |
public static final int CAMERA_PERMISSION = 101;
|
|
|
112 |
public static final int Storage_permission=102;
|
| 21480 |
rajender |
113 |
private boolean PermissionIngranted=false;
|
|
|
114 |
|
|
|
115 |
|
|
|
116 |
@Override
|
|
|
117 |
protected void onCreate(Bundle savedInstanceState) {
|
|
|
118 |
super.onCreate(savedInstanceState);
|
|
|
119 |
setContentView(R.layout.activity_main);
|
| 22832 |
rajender |
120 |
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
| 21480 |
rajender |
121 |
TestinAgent.init(this);
|
| 22132 |
rajender |
122 |
getSupportActionBar().hide();
|
| 22832 |
rajender |
123 |
int InstanceId = MainActivity.class.hashCode();
|
| 21480 |
rajender |
124 |
userData = getApplicationContext().getSharedPreferences("User_Data", MODE_PRIVATE);
|
|
|
125 |
apiData = getApplicationContext().getSharedPreferences("API_Data", MODE_PRIVATE);
|
|
|
126 |
userDataEditor = userData.edit();
|
|
|
127 |
apiSettingsEditor = apiData.edit();
|
| 22132 |
rajender |
128 |
checkPermission();
|
| 21480 |
rajender |
129 |
inviteData = getApplicationContext().getSharedPreferences("Invite_Data", Context.MODE_PRIVATE);
|
|
|
130 |
inviteDataEditor = inviteData.edit();
|
|
|
131 |
TestinAgent.setUserInfo(userData.getString("id",""));
|
|
|
132 |
mixpanel = MixpanelAPI.getInstance(getApplicationContext(), ProfitTillConstants.MIX_PANEL_TOKEN);
|
|
|
133 |
type1 = userData.getString("type",null);
|
|
|
134 |
|
|
|
135 |
if(getIntent().getAction()=="20"){
|
|
|
136 |
Tracker t = ((GoogleAnalyticsTracker) getApplicationContext()).getTracker(
|
|
|
137 |
GoogleAnalyticsTracker.TrackerName.APP_TRACKER);
|
|
|
138 |
t.send(new HitBuilders.EventBuilder()
|
|
|
139 |
.setCategory("Notification")
|
|
|
140 |
.setAction("Notification Opened ")
|
|
|
141 |
.setLabel("For User Id " + userData.getString("id","0"))
|
|
|
142 |
.build());
|
|
|
143 |
new Analytics(ProfitTillConstants.ANALYTICS_URL,
|
|
|
144 |
AnalyticsUtility.getAnalyticsRequest(MainActivity.this,userData.getString("id",""),"Notification","Notification Opened",getIntent().getExtras().getString("cid")),
|
|
|
145 |
AnalyticsJsonResponse.getAnalyticsRequestInstance(),
|
|
|
146 |
AnalyticsErrorResponse.getAnalyitcsResponseInstance()).anlyticsRequest(MainActivity.this);
|
|
|
147 |
flag=20;
|
|
|
148 |
notificationURL = String.valueOf(getIntent().getData());
|
|
|
149 |
nameValuePairsGcm = new ArrayList<>();
|
|
|
150 |
nameValuePairsGcm.add(new BasicNameValuePair("user_id",userData.getString("id","")));
|
|
|
151 |
nameValuePairsGcm.add(new BasicNameValuePair("cid",getIntent().getExtras().getString("cid")));
|
|
|
152 |
nameValuePairsGcm.add(new BasicNameValuePair("timestamp", UtilityFunctions.notificationDate()));
|
|
|
153 |
nameValuePairsGcm.add(new BasicNameValuePair("result","opened"));
|
|
|
154 |
getIntent().getExtras().remove("cid");
|
|
|
155 |
new NotificationOpenedData().execute(nameValuePairsGcm);
|
| 22832 |
rajender |
156 |
}
|
|
|
157 |
else if(getIntent().getAction()=="15"){
|
| 21480 |
rajender |
158 |
Tracker t = ((GoogleAnalyticsTracker) getApplicationContext()).getTracker(
|
|
|
159 |
GoogleAnalyticsTracker.TrackerName.APP_TRACKER);
|
|
|
160 |
t.send(new HitBuilders.EventBuilder()
|
|
|
161 |
.setCategory("Notification")
|
|
|
162 |
.setAction("Notification Opened ")
|
|
|
163 |
.setLabel("For User Id " + userData.getString("id","0"))
|
|
|
164 |
.build());
|
|
|
165 |
flag=15;
|
|
|
166 |
new Analytics(ProfitTillConstants.ANALYTICS_URL,
|
|
|
167 |
AnalyticsUtility.getAnalyticsRequest(MainActivity.this,userData.getString("id",""),"Notification","Notification Opened",getIntent().getExtras().getString("cid")),
|
|
|
168 |
AnalyticsJsonResponse.getAnalyticsRequestInstance(),
|
|
|
169 |
AnalyticsErrorResponse.getAnalyitcsResponseInstance()).anlyticsRequest(MainActivity.this);
|
|
|
170 |
nameValuePairsGcm = new ArrayList<>();
|
|
|
171 |
nameValuePairsGcm.add(new BasicNameValuePair("user_id",userData.getString("id","")));
|
|
|
172 |
nameValuePairsGcm.add(new BasicNameValuePair("cid",getIntent().getExtras().getString("cid")));
|
|
|
173 |
nameValuePairsGcm.add(new BasicNameValuePair("timestamp",UtilityFunctions.notificationDate()));
|
|
|
174 |
nameValuePairsGcm.add(new BasicNameValuePair("result","opened"));
|
|
|
175 |
getIntent().getExtras().remove("cid");
|
|
|
176 |
new NotificationOpenedData().execute(nameValuePairsGcm);
|
| 22832 |
rajender |
177 |
}
|
|
|
178 |
else if(getIntent().getAction()=="7"){
|
| 21480 |
rajender |
179 |
Tracker t = ((GoogleAnalyticsTracker) getApplicationContext()).getTracker(
|
|
|
180 |
GoogleAnalyticsTracker.TrackerName.APP_TRACKER);
|
|
|
181 |
t.send(new HitBuilders.EventBuilder()
|
|
|
182 |
.setCategory("Notification")
|
|
|
183 |
.setAction("Notification Opened ")
|
|
|
184 |
.setLabel("For User Id " + userData.getString("id","0"))
|
|
|
185 |
.build());
|
|
|
186 |
new Analytics(ProfitTillConstants.ANALYTICS_URL,
|
|
|
187 |
AnalyticsUtility.getAnalyticsRequest(MainActivity.this,userData.getString("id",""),"Notification","Notification Opened",getIntent().getExtras().getString("cid")),
|
|
|
188 |
AnalyticsJsonResponse.getAnalyticsRequestInstance(),
|
|
|
189 |
AnalyticsErrorResponse.getAnalyitcsResponseInstance()).anlyticsRequest(MainActivity.this);
|
|
|
190 |
flag=7;
|
|
|
191 |
nameValuePairsGcm = new ArrayList<>();
|
|
|
192 |
nameValuePairsGcm.add(new BasicNameValuePair("user_id",userData.getString("id","")));
|
|
|
193 |
nameValuePairsGcm.add(new BasicNameValuePair("cid",getIntent().getExtras().getString("cid")));
|
|
|
194 |
nameValuePairsGcm.add(new BasicNameValuePair("timestamp",UtilityFunctions.notificationDate()));
|
|
|
195 |
nameValuePairsGcm.add(new BasicNameValuePair("result","opened"));
|
|
|
196 |
getIntent().getExtras().remove("cid");
|
|
|
197 |
new NotificationOpenedData().execute(nameValuePairsGcm);
|
| 22832 |
rajender |
198 |
}
|
|
|
199 |
else if(getIntent().getAction()=="6"){
|
| 21480 |
rajender |
200 |
Tracker t = ((GoogleAnalyticsTracker) getApplicationContext()).getTracker(
|
|
|
201 |
GoogleAnalyticsTracker.TrackerName.APP_TRACKER);
|
|
|
202 |
t.send(new HitBuilders.EventBuilder()
|
|
|
203 |
.setCategory("Notification")
|
|
|
204 |
.setAction("Notification Opened ")
|
|
|
205 |
.setLabel("For User Id " + userData.getString("id","0"))
|
|
|
206 |
.build());
|
|
|
207 |
new Analytics(ProfitTillConstants.ANALYTICS_URL,
|
|
|
208 |
AnalyticsUtility.getAnalyticsRequest(MainActivity.this,userData.getString("id",""),"Notification","Notification Opened",getIntent().getExtras().getString("cid")),
|
|
|
209 |
AnalyticsJsonResponse.getAnalyticsRequestInstance(),
|
|
|
210 |
AnalyticsErrorResponse.getAnalyitcsResponseInstance()).anlyticsRequest(MainActivity.this);
|
|
|
211 |
flag=6;
|
|
|
212 |
nameValuePairsGcm = new ArrayList<>();
|
|
|
213 |
nameValuePairsGcm.add(new BasicNameValuePair("user_id",userData.getString("id","")));
|
|
|
214 |
nameValuePairsGcm.add(new BasicNameValuePair("cid",getIntent().getExtras().getString("cid")));
|
|
|
215 |
nameValuePairsGcm.add(new BasicNameValuePair("timestamp",UtilityFunctions.notificationDate()));
|
|
|
216 |
nameValuePairsGcm.add(new BasicNameValuePair("result","opened"));
|
|
|
217 |
getIntent().getExtras().remove("cid");
|
|
|
218 |
new NotificationOpenedData().execute(nameValuePairsGcm);
|
|
|
219 |
}else if(getIntent().getAction()=="31"){
|
|
|
220 |
String emailURL= String.valueOf(getIntent().getData());
|
|
|
221 |
Uri url = Uri.parse(emailURL);
|
|
|
222 |
if(url.getQueryParameter("intent_type").equalsIgnoreCase("url")){
|
|
|
223 |
String campaignId = url.getQueryParameter("campaign");
|
|
|
224 |
DESEncrypter desEncrypter = new DESEncrypter(ProfitTillConstants.AUTH_PASSWORD);
|
|
|
225 |
String urlOpen = desEncrypter.decrypt(url.getQueryParameter("key"));
|
|
|
226 |
String campaignUserId=urlOpen.split("user_id=")[1];
|
|
|
227 |
Tracker t = ((GoogleAnalyticsTracker) getApplicationContext()).getTracker(
|
|
|
228 |
GoogleAnalyticsTracker.TrackerName.APP_TRACKER);
|
|
|
229 |
t.send(new HitBuilders.EventBuilder()
|
|
|
230 |
.setCategory("Message/Email")
|
|
|
231 |
.setAction("Message/Email Opened For User Id " + UtilityFunctions.campaignUserId(url))
|
|
|
232 |
.setLabel("Campaign Id " + campaignId)
|
|
|
233 |
.build());
|
|
|
234 |
|
|
|
235 |
new Analytics(ProfitTillConstants.ANALYTICS_URL,
|
|
|
236 |
AnalyticsUtility.getAnalyticsRequest(MainActivity.this,UtilityFunctions.campaignUserId(url),"Message","Message Opened",campaignId),
|
|
|
237 |
AnalyticsJsonResponse.getAnalyticsRequestInstance(),
|
|
|
238 |
AnalyticsErrorResponse.getAnalyitcsResponseInstance()).anlyticsRequest(MainActivity.this);
|
|
|
239 |
|
|
|
240 |
nameValuePairsGcm = new ArrayList<>();
|
|
|
241 |
nameValuePairsGcm.add(new BasicNameValuePair("user_id",campaignUserId));
|
|
|
242 |
nameValuePairsGcm.add(new BasicNameValuePair("cid",campaignId));
|
|
|
243 |
nameValuePairsGcm.add(new BasicNameValuePair("timestamp",UtilityFunctions.notificationDate()));
|
|
|
244 |
nameValuePairsGcm.add(new BasicNameValuePair("result","message_opened"));
|
|
|
245 |
new NotificationOpenedData().execute(nameValuePairsGcm);
|
|
|
246 |
flag=20;
|
|
|
247 |
notificationURL=urlOpen.replace("?user_id="+campaignUserId,"?user_id="+userData.getString("id",""));
|
| 22832 |
rajender |
248 |
}
|
|
|
249 |
else if (url.getQueryParameter("intent_type").equalsIgnoreCase("native")){
|
| 21480 |
rajender |
250 |
String campaignId = url.getQueryParameter("campaign");
|
|
|
251 |
DESEncrypter desEncrypter = new DESEncrypter(ProfitTillConstants.AUTH_PASSWORD);
|
|
|
252 |
Tracker t = ((GoogleAnalyticsTracker) getApplicationContext()).getTracker(
|
|
|
253 |
GoogleAnalyticsTracker.TrackerName.APP_TRACKER);
|
|
|
254 |
t.send(new HitBuilders.EventBuilder()
|
|
|
255 |
.setCategory("Message/Email")
|
|
|
256 |
.setAction("Message/Email Opened For User Id " + userData.getString("id",""))
|
|
|
257 |
.setLabel("Campaign Id " + campaignId)
|
|
|
258 |
.build());
|
|
|
259 |
|
|
|
260 |
new Analytics(ProfitTillConstants.ANALYTICS_URL,
|
|
|
261 |
AnalyticsUtility.getAnalyticsRequest(MainActivity.this,userData.getString("id",""),"Message","Message Opened",campaignId),
|
|
|
262 |
AnalyticsJsonResponse.getAnalyticsRequestInstance(),
|
|
|
263 |
AnalyticsErrorResponse.getAnalyitcsResponseInstance()).anlyticsRequest(MainActivity.this);
|
|
|
264 |
|
|
|
265 |
nameValuePairsGcm = new ArrayList<>();
|
|
|
266 |
nameValuePairsGcm.add(new BasicNameValuePair("user_id",userData.getString("id","")));
|
|
|
267 |
nameValuePairsGcm.add(new BasicNameValuePair("cid",campaignId));
|
|
|
268 |
nameValuePairsGcm.add(new BasicNameValuePair("timestamp",UtilityFunctions.notificationDate()));
|
|
|
269 |
nameValuePairsGcm.add(new BasicNameValuePair("result","message_opened"));
|
|
|
270 |
new NotificationOpenedData().execute(nameValuePairsGcm);
|
|
|
271 |
|
|
|
272 |
if(desEncrypter.decrypt(url.getQueryParameter("key")).equalsIgnoreCase("profile")){
|
|
|
273 |
flag=15;
|
|
|
274 |
}
|
|
|
275 |
else if(desEncrypter.decrypt(url.getQueryParameter("key")).equalsIgnoreCase("contact")){
|
|
|
276 |
flag=6;
|
|
|
277 |
}
|
|
|
278 |
else if(desEncrypter.decrypt(url.getQueryParameter("key")).equalsIgnoreCase("tutorial")){
|
|
|
279 |
flag=7;
|
|
|
280 |
}else{
|
| 22832 |
rajender |
281 |
String dealsUrl=apiData.getString("Web_Uri","http://app.profitmandi.com/entry-point");
|
| 22132 |
rajender |
282 |
//String dealsUrl=ProfitTillConstants.Web_Uri;
|
| 21480 |
rajender |
283 |
flag=20;
|
|
|
284 |
notificationURL =dealsUrl;
|
|
|
285 |
}
|
|
|
286 |
}else if (url.getQueryParameter("intent_type").equalsIgnoreCase("update")){
|
|
|
287 |
String campaignId = url.getQueryParameter("campaign");
|
|
|
288 |
Tracker t = ((GoogleAnalyticsTracker) getApplicationContext()).getTracker(
|
|
|
289 |
GoogleAnalyticsTracker.TrackerName.APP_TRACKER);
|
|
|
290 |
t.send(new HitBuilders.EventBuilder()
|
|
|
291 |
.setCategory("Message/Email")
|
|
|
292 |
.setAction("Message/Email Opened For User Id " + userData.getString("id",""))
|
|
|
293 |
.setLabel("Campaign Id " + campaignId)
|
|
|
294 |
.build());
|
|
|
295 |
|
|
|
296 |
new Analytics(ProfitTillConstants.ANALYTICS_URL,
|
|
|
297 |
AnalyticsUtility.getAnalyticsRequest(MainActivity.this,userData.getString("id",""),"Message","Message Opened",campaignId),
|
|
|
298 |
AnalyticsJsonResponse.getAnalyticsRequestInstance(),
|
|
|
299 |
AnalyticsErrorResponse.getAnalyitcsResponseInstance()).anlyticsRequest(MainActivity.this);
|
|
|
300 |
|
|
|
301 |
nameValuePairsGcm = new ArrayList<>();
|
|
|
302 |
nameValuePairsGcm.add(new BasicNameValuePair("user_id",userData.getString("id","")));
|
|
|
303 |
nameValuePairsGcm.add(new BasicNameValuePair("cid",campaignId));
|
|
|
304 |
nameValuePairsGcm.add(new BasicNameValuePair("timestamp",UtilityFunctions.notificationDate()));
|
|
|
305 |
nameValuePairsGcm.add(new BasicNameValuePair("result","message_opened"));
|
|
|
306 |
new NotificationOpenedData().execute(nameValuePairsGcm);
|
|
|
307 |
|
|
|
308 |
Intent intent = null;
|
|
|
309 |
try {
|
|
|
310 |
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getApplicationContext().getPackageName()));
|
|
|
311 |
} catch (android.content.ActivityNotFoundException anfe) {
|
|
|
312 |
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + getApplicationContext().getPackageName()));
|
|
|
313 |
}
|
|
|
314 |
startActivity(intent);
|
|
|
315 |
}
|
|
|
316 |
else{
|
| 22832 |
rajender |
317 |
String dealsUrl=apiData.getString("Web_Uri","http://app.profitmandi.com/entry-point");
|
| 22132 |
rajender |
318 |
//String dealsUrl=ProfitTillConstants.Web_Uri;
|
| 21480 |
rajender |
319 |
flag=20;
|
|
|
320 |
notificationURL =dealsUrl;
|
|
|
321 |
}
|
|
|
322 |
}
|
|
|
323 |
else if(getIntent().getAction()=="11"){
|
|
|
324 |
flag=11;
|
|
|
325 |
}else {
|
|
|
326 |
Bundle i = getIntent().getExtras();
|
|
|
327 |
try{
|
| 22132 |
rajender |
328 |
if (i != null) {
|
|
|
329 |
flag = Integer.parseInt(i.getString("displayView"));
|
|
|
330 |
if (flag == 31) {
|
|
|
331 |
redirectUrl = i.getString("redirectUrl");
|
|
|
332 |
}
|
|
|
333 |
}}
|
| 21480 |
rajender |
334 |
catch (Exception e){
|
|
|
335 |
e.printStackTrace();
|
|
|
336 |
}
|
|
|
337 |
}
|
|
|
338 |
|
| 22381 |
rajender |
339 |
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.WHITE));
|
| 22132 |
rajender |
340 |
//getSupportActionBar().setIcon(R.drawable.backarrow);
|
| 21480 |
rajender |
341 |
getSupportActionBar().setDisplayShowCustomEnabled(true);
|
|
|
342 |
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
| 22132 |
rajender |
343 |
final Drawable upArrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
|
|
|
344 |
upArrow.setColorFilter(getResources().getColor(R.color.grey_black), PorterDuff.Mode.SRC_ATOP);
|
|
|
345 |
getSupportActionBar().setHomeAsUpIndicator(upArrow);
|
|
|
346 |
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
|
|
347 |
getSupportActionBar().setHomeButtonEnabled(true);
|
| 22381 |
rajender |
348 |
getSupportActionBar().setCustomView(R.layout.actionbarprofittill);
|
| 21480 |
rajender |
349 |
|
|
|
350 |
try {
|
|
|
351 |
ViewConfiguration config = ViewConfiguration.get(this);
|
|
|
352 |
Field menuKeyField = ViewConfiguration.class
|
|
|
353 |
.getDeclaredField("sHasPermanentMenuKey");
|
|
|
354 |
if (menuKeyField != null) {
|
|
|
355 |
menuKeyField.setAccessible(true);
|
|
|
356 |
menuKeyField.setBoolean(config, false);
|
|
|
357 |
}
|
|
|
358 |
} catch (Exception ex) {
|
|
|
359 |
Log.d("Exception","Message"+ex);
|
|
|
360 |
}
|
|
|
361 |
|
|
|
362 |
if(type1!=null && type1.equalsIgnoreCase("google")) {
|
|
|
363 |
mGoogleApiClient = new GoogleApiClient.Builder(this)
|
|
|
364 |
.addConnectionCallbacks(this)
|
|
|
365 |
.addOnConnectionFailedListener(this).addApi(Plus.API)
|
|
|
366 |
.addScope(Plus.SCOPE_PLUS_LOGIN).build();
|
|
|
367 |
mGoogleApiClient.connect();
|
|
|
368 |
}
|
|
|
369 |
|
| 22832 |
rajender |
370 |
/* mTitle = mDrawerTitle = getTitle();
|
| 21480 |
rajender |
371 |
|
| 22832 |
rajender |
372 |
navDrawerView = (LinearLayout) findViewById(R.id.navDrawerView);
|
| 21480 |
rajender |
373 |
mPlanetTitles = getResources().getStringArray(R.array.stores_array);
|
|
|
374 |
mHelpTtiles= getResources().getStringArray(R.array.help_array);
|
|
|
375 |
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
|
| 22832 |
rajender |
376 |
mDrawerList = (ExpandableListView) findViewById(R.id.nav_left_drawer);
|
|
|
377 |
if(userData.getString("registered","").equalsIgnoreCase("false")){
|
| 21480 |
rajender |
378 |
getSupportActionBar().hide();
|
|
|
379 |
mDrawerLayout.setVisibility(View.INVISIBLE);
|
|
|
380 |
|
| 22832 |
rajender |
381 |
}
|
|
|
382 |
listParent = new ArrayList<ExpandableNavigationItem>();
|
| 21480 |
rajender |
383 |
listDataChild = new HashMap<String, List<String>>();
|
|
|
384 |
listParent.add(new ExpandableNavigationItem(getString(R.string.Deals)));
|
|
|
385 |
listParent.add(new ExpandableNavigationItem(getString(R.string.Search)));
|
|
|
386 |
listParent.add(new ExpandableNavigationItem(getString(R.string.Stores)));
|
|
|
387 |
listParent.add(new ExpandableNavigationItem(getString(R.string.Help)));
|
|
|
388 |
listDataChild.put(getString(R.string.Deals), new ArrayList<String>());
|
|
|
389 |
listDataChild.put(getString(R.string.Search), new ArrayList<String>());
|
|
|
390 |
listDataChild.put(getString(R.string.Stores), Arrays.asList(mPlanetTitles));
|
|
|
391 |
listDataChild.put(getString(R.string.Help), Arrays.asList(mHelpTtiles));
|
|
|
392 |
|
|
|
393 |
customAdapter = new ExpandableNavigationAdapter(this, listParent, listDataChild);
|
|
|
394 |
|
|
|
395 |
mDrawerList.setAdapter(customAdapter);
|
| 22832 |
rajender |
396 |
mDrawerList.setChoiceMode(ExpandableListView.CHOICE_MODE_SINGLE);
|
| 21480 |
rajender |
397 |
|
| 22832 |
rajender |
398 |
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
|
|
399 |
getSupportActionBar().setHomeButtonEnabled(true);
|
|
|
400 |
mDrawerList.setOnChildClickListener(new ExpandableListViewChildClick());
|
| 21480 |
rajender |
401 |
mDrawerList.setOnGroupExpandListener(new ExpandableGroupExpandListener());
|
|
|
402 |
|
|
|
403 |
mDrawerList.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
|
|
|
404 |
@Override
|
|
|
405 |
public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
|
|
|
406 |
if(groupPosition==0 || groupPosition ==1) {
|
|
|
407 |
displayView(groupPosition);
|
|
|
408 |
mDrawerLayout.closeDrawer(navDrawerView);
|
|
|
409 |
mDrawerList.collapseGroup(2);
|
|
|
410 |
mDrawerList.collapseGroup(3);
|
|
|
411 |
return true;
|
|
|
412 |
}
|
|
|
413 |
return false;
|
|
|
414 |
}
|
|
|
415 |
});
|
|
|
416 |
mDrawerToggle = new ActionBarDrawerToggle(this,
|
|
|
417 |
mDrawerLayout,
|
|
|
418 |
R.drawable.menu_button_2,
|
|
|
419 |
R.string.drawer_open,
|
|
|
420 |
R.string.drawer_close
|
|
|
421 |
) {
|
| 22832 |
rajender |
422 |
/* public void onDrawerClosed(View view) {
|
| 21480 |
rajender |
423 |
if(titleVisible!=0) {
|
|
|
424 |
if(titleVisible==1)
|
|
|
425 |
getSupportActionBar().setCustomView(R.layout.actionbarmyfavorites);
|
|
|
426 |
|
|
|
427 |
if(titleVisible==2)
|
|
|
428 |
getSupportActionBar().setCustomView(R.layout.actionbarprefernces);
|
|
|
429 |
|
|
|
430 |
if(titleVisible==3)
|
|
|
431 |
getSupportActionBar().setCustomView(R.layout.actionbarmywallet);
|
|
|
432 |
|
|
|
433 |
if(titleVisible==4)
|
|
|
434 |
getSupportActionBar().setCustomView(R.layout.actionbarmyorders);
|
|
|
435 |
|
|
|
436 |
if(titleVisible==5)
|
|
|
437 |
getSupportActionBar().setCustomView(R.layout.actionbarpendingcashback);
|
|
|
438 |
|
|
|
439 |
if(titleVisible==6)
|
|
|
440 |
getSupportActionBar().setCustomView(R.layout.actionbarmyprofile);
|
|
|
441 |
}
|
|
|
442 |
shouldGoInvisible = false;
|
|
|
443 |
invalidateOptionsMenu();
|
|
|
444 |
}
|
|
|
445 |
|
|
|
446 |
public void onDrawerOpened(View drawerView) {
|
|
|
447 |
getSupportActionBar().setCustomView(R.layout.actionbarprofittill);
|
|
|
448 |
shouldGoInvisible = true;
|
|
|
449 |
invalidateOptionsMenu();
|
|
|
450 |
}
|
|
|
451 |
};
|
|
|
452 |
mDrawerLayout.setDrawerListener(mDrawerToggle);
|
| 22832 |
rajender |
453 |
*/
|
| 21480 |
rajender |
454 |
|
|
|
455 |
if (savedInstanceState == null) {
|
|
|
456 |
|
|
|
457 |
if (flag == 7) {
|
| 22832 |
rajender |
458 |
// getSupportActionBar().setCustomView(R.layout.actionbarhowitworks);
|
| 21480 |
rajender |
459 |
displayHelpChildView(1);
|
| 22832 |
rajender |
460 |
} /*else if (flag == 6) {
|
| 21480 |
rajender |
461 |
getSupportActionBar().setCustomView(R.layout.actionbarcontactus);
|
|
|
462 |
displayHelpChildView(0);
|
|
|
463 |
} else if (flag == 15) {
|
|
|
464 |
getSupportActionBar().setCustomView(R.layout.actionbarmyprofile);
|
|
|
465 |
MyProfile myProfile = new MyProfile();
|
|
|
466 |
this.getFragmentManager().beginTransaction()
|
|
|
467 |
.replace(R.id.frame_container, myProfile, "Mike")
|
|
|
468 |
.addToBackStack(null)
|
|
|
469 |
.commit();
|
| 22832 |
rajender |
470 |
}*/
|
|
|
471 |
else if(flag == 13){
|
|
|
472 |
displayView(1);
|
|
|
473 |
}
|
|
|
474 |
else if (flag == 20) {
|
|
|
475 |
getSupportActionBar().setCustomView(R.layout.actionbardeals);
|
| 21480 |
rajender |
476 |
JSONObject propsNotification = new JSONObject();
|
|
|
477 |
try {
|
|
|
478 |
mixpanel.identify(userData.getString("id",null));
|
|
|
479 |
propsNotification.put("Screen", "Notification Url opened");
|
|
|
480 |
mixpanel.track("Notification Opened", propsNotification);
|
|
|
481 |
} catch (JSONException e) {
|
|
|
482 |
e.printStackTrace();
|
|
|
483 |
}
|
|
|
484 |
Bundle args = new Bundle();
|
|
|
485 |
DealsHomeFragment notifcationFragment = new DealsHomeFragment();
|
|
|
486 |
args.putString("key", notificationURL);
|
|
|
487 |
notifcationFragment.setArguments(args);
|
| 22832 |
rajender |
488 |
FragmentManager fragmentManager = getFragmentManager();
|
|
|
489 |
fragmentManager.popBackStack(notifcationFragment.toString(),FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
|
|
490 |
fragmentManager.beginTransaction().replace(R.id.frame_container, notifcationFragment).addToBackStack(notifcationFragment.toString()).commit();
|
|
|
491 |
System.gc();
|
|
|
492 |
|
|
|
493 |
|
| 21480 |
rajender |
494 |
}else if (flag == 31) {
|
|
|
495 |
getSupportActionBar().setCustomView(R.layout.actionbardeals);
|
|
|
496 |
Bundle args = new Bundle();
|
|
|
497 |
DealsHomeFragment redirectUrlFragment = new DealsHomeFragment();
|
|
|
498 |
args.putString("key", redirectUrl);
|
| 22832 |
rajender |
499 |
redirectUrlFragment.setArguments(args);
|
| 21480 |
rajender |
500 |
this.getFragmentManager().beginTransaction()
|
|
|
501 |
.replace(R.id.frame_container, redirectUrlFragment, "Mike")
|
|
|
502 |
.addToBackStack(null)
|
|
|
503 |
.commit();
|
|
|
504 |
redirectUrlFragment.setArguments(args);
|
| 22832 |
rajender |
505 |
}/*else if (flag == 11) {
|
| 21480 |
rajender |
506 |
getSupportActionBar().setCustomView(R.layout.actionbaraboutus);
|
|
|
507 |
Bundle args = new Bundle();
|
|
|
508 |
AboutUsFragment redirectUrlFragment = new AboutUsFragment();
|
|
|
509 |
args.putString("key", redirectUrl);
|
|
|
510 |
this.getFragmentManager().beginTransaction()
|
|
|
511 |
.replace(R.id.frame_container, redirectUrlFragment, "Mike")
|
|
|
512 |
.addToBackStack(null)
|
|
|
513 |
.commit();
|
|
|
514 |
redirectUrlFragment.setArguments(args);
|
| 22832 |
rajender |
515 |
}*/
|
|
|
516 |
else {
|
|
|
517 |
// getSupportActionBar().setCustomView(R.layout.actionbardeals);
|
| 21480 |
rajender |
518 |
displayView(0);
|
|
|
519 |
}
|
| 22832 |
rajender |
520 |
}
|
|
|
521 |
// displayView(0);
|
| 21480 |
rajender |
522 |
}
|
|
|
523 |
|
|
|
524 |
|
|
|
525 |
|
| 22132 |
rajender |
526 |
|
|
|
527 |
|
|
|
528 |
/* private class ExpandableGroupExpandListener implements ExpandableListView.OnGroupExpandListener {
|
| 21480 |
rajender |
529 |
@Override
|
|
|
530 |
public void onGroupExpand(int groupPosition) {
|
|
|
531 |
int len = customAdapter.getGroupCount();
|
|
|
532 |
int index = mDrawerList.getFlatListPosition(ExpandableListView.getPackedPositionForGroup(groupPosition));
|
|
|
533 |
mDrawerList.setItemChecked(index, true);
|
|
|
534 |
String parentTitle = customAdapter.getGroup(groupPosition).getTitle();
|
|
|
535 |
if (groupPosition == 3) {
|
|
|
536 |
if (mDrawerList.isGroupExpanded(2)) {
|
|
|
537 |
mDrawerList.collapseGroup(2);
|
|
|
538 |
}
|
|
|
539 |
} else if (groupPosition == 2) {
|
|
|
540 |
if (mDrawerList.isGroupExpanded(3)) {
|
|
|
541 |
mDrawerList.collapseGroup(3);
|
|
|
542 |
}
|
|
|
543 |
}
|
|
|
544 |
setActionBarTitlte(parentTitle);
|
|
|
545 |
}
|
|
|
546 |
|
|
|
547 |
}
|
|
|
548 |
|
|
|
549 |
private class ExpandableListViewChildClick implements ExpandableListView.OnChildClickListener {
|
|
|
550 |
@Override
|
|
|
551 |
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
|
|
|
552 |
int index = parent.getFlatListPosition(ExpandableListView.getPackedPositionForChild(groupPosition, childPosition));
|
|
|
553 |
parent.setItemChecked(index, true);
|
|
|
554 |
mDrawerLayout.closeDrawer(navDrawerView);
|
|
|
555 |
if(groupPosition==2) {
|
|
|
556 |
displayChildView(childPosition);
|
|
|
557 |
}else if(groupPosition==3){
|
|
|
558 |
if (childPosition==0) {
|
|
|
559 |
getSupportActionBar().setCustomView(R.layout.actionbarcontactus);
|
|
|
560 |
}
|
|
|
561 |
else if (childPosition==1) {
|
|
|
562 |
getSupportActionBar().setCustomView(R.layout.actionbarhowitworks);
|
|
|
563 |
}
|
|
|
564 |
else if (childPosition==2) {
|
|
|
565 |
getSupportActionBar().setCustomView(R.layout.actionbaraboutus);
|
|
|
566 |
}
|
|
|
567 |
displayHelpChildView(childPosition);
|
|
|
568 |
}
|
|
|
569 |
return false;
|
|
|
570 |
}
|
|
|
571 |
|
|
|
572 |
}
|
| 22832 |
rajender |
573 |
*/
|
| 21480 |
rajender |
574 |
private void displayHelpChildView(int position) {
|
|
|
575 |
titleVisible=0;
|
|
|
576 |
Tracker t = ((GoogleAnalyticsTracker) getApplicationContext()).getTracker(
|
|
|
577 |
GoogleAnalyticsTracker.TrackerName.APP_TRACKER);
|
|
|
578 |
Fragment fragment = null;
|
|
|
579 |
Map<String, String> jsonParams;
|
|
|
580 |
switch (position) {
|
|
|
581 |
case 0:
|
|
|
582 |
JSONObject propsContactUs = new JSONObject();
|
|
|
583 |
try {
|
|
|
584 |
mixpanel.identify(userData.getString("id",null));
|
|
|
585 |
propsContactUs.put("Screen", "Contact Us");
|
|
|
586 |
mixpanel.track("Contact Us", propsContactUs);
|
|
|
587 |
} catch (JSONException e) {
|
|
|
588 |
e.printStackTrace();
|
|
|
589 |
}
|
|
|
590 |
t.send(new HitBuilders.EventBuilder()
|
|
|
591 |
.setCategory("Menu")
|
|
|
592 |
.setAction("Contact Us ")
|
|
|
593 |
.setLabel("Contact us Clicked")
|
|
|
594 |
.build());
|
| 22832 |
rajender |
595 |
// fragment = new ContactUsFragment();
|
| 21480 |
rajender |
596 |
break;
|
|
|
597 |
case 1:
|
|
|
598 |
JSONObject propsHowItWorks = new JSONObject();
|
|
|
599 |
try {
|
|
|
600 |
mixpanel.identify(userData.getString("id",null));
|
|
|
601 |
propsHowItWorks.put("Screen", "How it Works");
|
|
|
602 |
mixpanel.track("How it Works", propsHowItWorks);
|
|
|
603 |
} catch (JSONException e) {
|
|
|
604 |
e.printStackTrace();
|
|
|
605 |
}
|
|
|
606 |
t.send(new HitBuilders.EventBuilder()
|
|
|
607 |
.setCategory("Menu")
|
|
|
608 |
.setAction("Tutorials ")
|
|
|
609 |
.setLabel("Tutorials Clicked")
|
|
|
610 |
.build());
|
| 22832 |
rajender |
611 |
fragment = new HowItWorks();
|
| 21480 |
rajender |
612 |
break;
|
|
|
613 |
case 2:
|
|
|
614 |
JSONObject propsAboutUs = new JSONObject();
|
|
|
615 |
try {
|
|
|
616 |
mixpanel.identify(userData.getString("id",null));
|
|
|
617 |
propsAboutUs.put("Screen", "About Us");
|
|
|
618 |
mixpanel.track("About Us", propsAboutUs);
|
|
|
619 |
} catch (JSONException e) {
|
|
|
620 |
e.printStackTrace();
|
|
|
621 |
}
|
|
|
622 |
t.send(new HitBuilders.EventBuilder()
|
|
|
623 |
.setCategory("Menu")
|
|
|
624 |
.setAction("About Us ")
|
|
|
625 |
.setLabel("About us Clicked")
|
|
|
626 |
.build());
|
| 22832 |
rajender |
627 |
// fragment = new AboutUsFragment();
|
| 21480 |
rajender |
628 |
break;
|
|
|
629 |
default:
|
|
|
630 |
break;
|
|
|
631 |
}
|
| 22832 |
rajender |
632 |
/* if (fragment != null) {
|
| 21480 |
rajender |
633 |
FragmentManager fragmentManager = getFragmentManager();
|
|
|
634 |
fragmentManager.beginTransaction().replace(R.id.frame_container, fragment).commit();
|
|
|
635 |
|
|
|
636 |
} else {
|
|
|
637 |
Log.e("MainActivity", "Error in creating fragment");
|
|
|
638 |
}*/
|
| 22832 |
rajender |
639 |
if (fragment != null) {
|
| 21480 |
rajender |
640 |
FragmentManager fragmentManager = getFragmentManager();
|
|
|
641 |
fragmentManager.popBackStack(fragment.toString(),FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
|
|
642 |
fragmentManager.beginTransaction().replace(R.id.frame_container, fragment).addToBackStack(fragment.toString()).commit();
|
|
|
643 |
System.gc();
|
|
|
644 |
} else {
|
|
|
645 |
Log.e("MainActivity", "Error in creating fragment");
|
|
|
646 |
}
|
|
|
647 |
|
| 22832 |
rajender |
648 |
}
|
| 22132 |
rajender |
649 |
|
|
|
650 |
@TargetApi(Build.VERSION_CODES.M)
|
|
|
651 |
private void checkPermission() {
|
|
|
652 |
if (ContextCompat.checkSelfPermission(MainActivity.this,
|
|
|
653 |
Manifest.permission.READ_EXTERNAL_STORAGE) + ContextCompat
|
|
|
654 |
.checkSelfPermission(MainActivity.this,
|
|
|
655 |
Manifest.permission.CAMERA) + ContextCompat
|
|
|
656 |
.checkSelfPermission(MainActivity.this,Manifest.permission.RECEIVE_SMS)
|
|
|
657 |
!= PackageManager.PERMISSION_GRANTED) {
|
|
|
658 |
|
|
|
659 |
if (ActivityCompat.shouldShowRequestPermissionRationale
|
|
|
660 |
(MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) ||
|
|
|
661 |
ActivityCompat.shouldShowRequestPermissionRationale
|
|
|
662 |
(MainActivity.this, Manifest.permission.CAMERA)|| ActivityCompat.shouldShowRequestPermissionRationale
|
|
|
663 |
(MainActivity.this, Manifest.permission.RECEIVE_SMS)) {
|
|
|
664 |
|
|
|
665 |
requestPermissions(
|
|
|
666 |
new String[]{Manifest.permission
|
|
|
667 |
.READ_EXTERNAL_STORAGE, Manifest.permission.CAMERA,Manifest.permission
|
|
|
668 |
.RECEIVE_SMS},
|
|
|
669 |
123);
|
|
|
670 |
|
|
|
671 |
} else {
|
|
|
672 |
requestPermissions(
|
|
|
673 |
new String[]{Manifest.permission
|
|
|
674 |
.READ_EXTERNAL_STORAGE, Manifest.permission.CAMERA,Manifest.permission.RECEIVE_SMS},
|
|
|
675 |
123);
|
|
|
676 |
}
|
|
|
677 |
} else {
|
|
|
678 |
// write your logic code if permission already granted
|
|
|
679 |
}
|
| 21480 |
rajender |
680 |
}
|
|
|
681 |
@Override
|
|
|
682 |
public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
683 |
mainMenu=menu;
|
|
|
684 |
super.onCreateOptionsMenu(menu);
|
|
|
685 |
getMenuInflater().inflate(R.menu.menu_main, menu);
|
| 22132 |
rajender |
686 |
/* RelativeLayout badgeLayout = (RelativeLayout) mainMenu.findItem(R.id.action_notifications).getActionView();
|
| 21480 |
rajender |
687 |
ImageView k = (ImageView) badgeLayout.findViewById(R.id.inAppNotificationImage);
|
|
|
688 |
TextView notifciationCount = (TextView) badgeLayout.findViewById(R.id.inAppNotificationText);
|
|
|
689 |
k.setOnClickListener(new View.OnClickListener() {
|
|
|
690 |
@Override
|
|
|
691 |
public void onClick(View v) {
|
|
|
692 |
Bundle args = new Bundle();
|
| 22132 |
rajender |
693 |
args.putString("key", apiData.getString("notification.page.url", "http://staging.profittill.com/users/usernotification") + "?user_id=" + userData.getString("id", "") + "&android_id=" + UtilityFunctions.androidId(MainActivity.this));
|
| 21480 |
rajender |
694 |
new Analytics(ProfitTillConstants.ANALYTICS_URL,
|
|
|
695 |
AnalyticsUtility.getAnalyticsRequest(MainActivity.this,userData.getString("id",""),"Notification","Notification Icon","Notification Icon Clicked"),
|
|
|
696 |
AnalyticsJsonResponse.getAnalyticsRequestInstance(),
|
|
|
697 |
AnalyticsErrorResponse.getAnalyitcsResponseInstance()).anlyticsRequest(MainActivity.this);
|
|
|
698 |
|
|
|
699 |
Tracker t = ((GoogleAnalyticsTracker) getApplicationContext()).getTracker(
|
|
|
700 |
GoogleAnalyticsTracker.TrackerName.APP_TRACKER);
|
|
|
701 |
t.send(new HitBuilders.EventBuilder()
|
|
|
702 |
.setCategory("Menu")
|
|
|
703 |
.setAction("Search ")
|
|
|
704 |
.setLabel("Search Clicked")
|
|
|
705 |
.build());
|
|
|
706 |
DealsHomeFragment notificationFragment = new DealsHomeFragment();
|
|
|
707 |
getFragmentManager().beginTransaction()
|
|
|
708 |
.replace(R.id.frame_container, notificationFragment, "Mike")
|
|
|
709 |
.addToBackStack(null)
|
|
|
710 |
.commit();
|
|
|
711 |
notificationFragment.setArguments(args);
|
|
|
712 |
}
|
|
|
713 |
});
|
|
|
714 |
|
|
|
715 |
if(userData.getInt("notification_count",0)!=0) {
|
|
|
716 |
notifciationCount.setVisibility(View.VISIBLE);
|
|
|
717 |
notifciationCount.setText(userData.getInt("notification_count",0)+"");
|
|
|
718 |
}else{
|
|
|
719 |
notifciationCount.setVisibility(View.GONE);
|
| 22132 |
rajender |
720 |
}*/
|
| 21480 |
rajender |
721 |
return true;
|
|
|
722 |
}
|
|
|
723 |
|
| 22381 |
rajender |
724 |
/* @Override
|
| 21480 |
rajender |
725 |
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
726 |
Fragment menuFragment= null;
|
|
|
727 |
JSONObject props = new JSONObject();
|
|
|
728 |
Bundle args = new Bundle();
|
|
|
729 |
String id = userData.getString("id",null);
|
| 22132 |
rajender |
730 |
/*if (mDrawerToggle.onOptionsItemSelected(item)) {
|
| 21480 |
rajender |
731 |
return true;
|
|
|
732 |
}
|
| 22381 |
rajender |
733 |
|
| 21480 |
rajender |
734 |
switch (item.getItemId()) {
|
| 22132 |
rajender |
735 |
// Respond to the action bar's Up/Home button
|
|
|
736 |
case android.R.id.home:
|
|
|
737 |
new AlertDialog.Builder(this)
|
|
|
738 |
.setIcon(android.R.drawable.ic_dialog_alert)
|
|
|
739 |
.setTitle("Exit!")
|
|
|
740 |
.setMessage("Are you sure you want to close?")
|
|
|
741 |
.setPositiveButton("Yes", new DialogInterface.OnClickListener()
|
|
|
742 |
{
|
|
|
743 |
@Override
|
|
|
744 |
public void onClick(DialogInterface dialog, int which) {
|
|
|
745 |
Intent startMain = new Intent(Intent.ACTION_MAIN);
|
|
|
746 |
startMain.addCategory(Intent.CATEGORY_HOME);
|
|
|
747 |
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
748 |
startActivity(startMain);
|
|
|
749 |
}
|
|
|
750 |
})
|
|
|
751 |
.setNegativeButton("No", null)
|
|
|
752 |
.show();
|
|
|
753 |
}
|
| 22381 |
rajender |
754 |
return super.onOptionsItemSelected(item);*/
|
| 22132 |
rajender |
755 |
|
|
|
756 |
/* case R.id.action_settings:
|
| 21480 |
rajender |
757 |
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
|
|
|
758 |
Intent i = new Intent(this, PollingService.class);
|
|
|
759 |
PendingIntent pi = PendingIntent.getService(this, 0, i, 0);
|
|
|
760 |
am.cancel(pi);
|
|
|
761 |
userDataEditor.putString("alarm_set","false").commit();
|
|
|
762 |
android.webkit.CookieManager cookieManager = android.webkit.CookieManager.getInstance();
|
|
|
763 |
android.webkit.CookieSyncManager.createInstance(this);
|
|
|
764 |
cookieManager.removeAllCookie();
|
|
|
765 |
try {
|
|
|
766 |
mixpanel.identify(userData.getString("id",null));
|
|
|
767 |
props.put("Screen", "Signing Out");
|
|
|
768 |
mixpanel.track("Signing Out", props);
|
|
|
769 |
} catch (JSONException e) {
|
|
|
770 |
e.printStackTrace();
|
|
|
771 |
}
|
|
|
772 |
new Analytics(ProfitTillConstants.ANALYTICS_URL,
|
|
|
773 |
AnalyticsUtility.getAnalyticsRequest(MainActivity.this,userData.getString("id",""),"Menu","Sign Out","Sign Out Clicked"),
|
|
|
774 |
AnalyticsJsonResponse.getAnalyticsRequestInstance(),
|
|
|
775 |
AnalyticsErrorResponse.getAnalyitcsResponseInstance()).anlyticsRequest(MainActivity.this);
|
|
|
776 |
try{
|
|
|
777 |
if (mGoogleApiClient.isConnected()) {
|
|
|
778 |
Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
|
|
|
779 |
mGoogleApiClient.disconnect();
|
|
|
780 |
mGoogleApiClient.connect();
|
|
|
781 |
userDataEditor.clear().commit();
|
|
|
782 |
inviteDataEditor.clear().commit();
|
|
|
783 |
startActivity(new Intent(MainActivity.this, LoginActivity.class));
|
|
|
784 |
}
|
|
|
785 |
else{
|
|
|
786 |
if(!mGoogleApiClient.isConnected()){
|
|
|
787 |
userDataEditor.clear().commit();
|
|
|
788 |
inviteDataEditor.clear().commit();
|
|
|
789 |
startActivity(new Intent(MainActivity.this, LoginActivity.class));
|
| 22132 |
rajender |
790 |
}}
|
|
|
791 |
}
|
|
|
792 |
catch (Exception e){
|
| 21480 |
rajender |
793 |
userDataEditor.clear().commit();
|
|
|
794 |
startActivity(new Intent(MainActivity.this, LoginActivity.class));
|
|
|
795 |
}
|
| 22132 |
rajender |
796 |
return true;*/
|
| 21480 |
rajender |
797 |
|
| 22132 |
rajender |
798 |
/* case R.id.my_wallet:
|
| 21480 |
rajender |
799 |
titleVisible=3;
|
|
|
800 |
getSupportActionBar().setCustomView(R.layout.actionbarmywallet);
|
|
|
801 |
try {
|
|
|
802 |
mixpanel.identify(userData.getString("id",null));
|
|
|
803 |
props.put("Screen", "My Wallet");
|
|
|
804 |
mixpanel.track("My Wallet", props);
|
|
|
805 |
} catch (JSONException e) {
|
|
|
806 |
e.printStackTrace();
|
|
|
807 |
}
|
|
|
808 |
new Analytics(ProfitTillConstants.ANALYTICS_URL,
|
|
|
809 |
AnalyticsUtility.getAnalyticsRequest(MainActivity.this,userData.getString("id",""),"Menu","My Wallet","My Wallet Clicked"),
|
|
|
810 |
AnalyticsJsonResponse.getAnalyticsRequestInstance(),
|
|
|
811 |
AnalyticsErrorResponse.getAnalyitcsResponseInstance()).anlyticsRequest(MainActivity.this);
|
|
|
812 |
MyWallet myWallet= new MyWallet();
|
|
|
813 |
this.getFragmentManager().beginTransaction()
|
|
|
814 |
.replace(R.id.frame_container, myWallet,"Mike")
|
|
|
815 |
.addToBackStack(null)
|
|
|
816 |
.commit();
|
|
|
817 |
return true;
|
|
|
818 |
case R.id.pending_cashback:
|
|
|
819 |
titleVisible=5;
|
|
|
820 |
getSupportActionBar().setCustomView(R.layout.actionbarpendingcashback);
|
|
|
821 |
try {
|
|
|
822 |
mixpanel.identify(userData.getString("id",null));
|
|
|
823 |
props.put("Screen", "Cashback Status");
|
|
|
824 |
mixpanel.track("Cashback Status", props);
|
|
|
825 |
} catch (JSONException e) {
|
|
|
826 |
e.printStackTrace();
|
|
|
827 |
}
|
|
|
828 |
new Analytics(ProfitTillConstants.ANALYTICS_URL,
|
|
|
829 |
AnalyticsUtility.getAnalyticsRequest(MainActivity.this,userData.getString("id",""),"Menu","Cashback Status","Cashback Status Clicked"),
|
|
|
830 |
AnalyticsJsonResponse.getAnalyticsRequestInstance(),
|
|
|
831 |
AnalyticsErrorResponse.getAnalyitcsResponseInstance()).anlyticsRequest(MainActivity.this);
|
|
|
832 |
args.putString("key", apiData.getString("pendingcashback.url",null)+"?user_id="+id);
|
|
|
833 |
DealsHomeFragment orderFragment= new DealsHomeFragment();
|
|
|
834 |
this.getFragmentManager().beginTransaction()
|
|
|
835 |
.replace(R.id.frame_container, orderFragment,"Mike")
|
|
|
836 |
.addToBackStack(null)
|
|
|
837 |
.commit();
|
|
|
838 |
orderFragment.setArguments(args);
|
|
|
839 |
|
|
|
840 |
return true;
|
|
|
841 |
case R.id.my_favorites:
|
|
|
842 |
titleVisible=1;
|
|
|
843 |
getSupportActionBar().setCustomView(R.layout.actionbarmyfavorites);
|
|
|
844 |
try {
|
|
|
845 |
mixpanel.identify(userData.getString("id",null));
|
|
|
846 |
props.put("Screen", "My Favorites");
|
|
|
847 |
mixpanel.track("My Favorites", props);
|
|
|
848 |
} catch (JSONException e) {
|
|
|
849 |
e.printStackTrace();
|
|
|
850 |
}
|
|
|
851 |
new Analytics(ProfitTillConstants.ANALYTICS_URL,
|
|
|
852 |
AnalyticsUtility.getAnalyticsRequest(MainActivity.this,userData.getString("id",""),"Menu","My Favorites","My Favorites Clicked"),
|
|
|
853 |
AnalyticsJsonResponse.getAnalyticsRequestInstance(),
|
|
|
854 |
AnalyticsErrorResponse.getAnalyitcsResponseInstance()).anlyticsRequest(MainActivity.this);
|
|
|
855 |
args.putString("key", apiData.getString("myfavourite.url",null)+"?user_id="+id);
|
|
|
856 |
DealsHomeFragment favoritesFragment= new DealsHomeFragment();
|
|
|
857 |
this.getFragmentManager().beginTransaction()
|
|
|
858 |
.replace(R.id.frame_container, favoritesFragment,"Mike")
|
|
|
859 |
.addToBackStack(null)
|
|
|
860 |
.commit();
|
|
|
861 |
favoritesFragment.setArguments(args);
|
|
|
862 |
return true;
|
|
|
863 |
case R.id.my_profile:
|
|
|
864 |
titleVisible=6;
|
|
|
865 |
getSupportActionBar().setCustomView(R.layout.actionbarmyprofile);
|
|
|
866 |
try {
|
|
|
867 |
mixpanel.identify(userData.getString("id",null));
|
|
|
868 |
props.put("Screen", "My Profile");
|
|
|
869 |
mixpanel.track("My profile", props);
|
|
|
870 |
} catch (JSONException e) {
|
|
|
871 |
e.printStackTrace();
|
|
|
872 |
}
|
|
|
873 |
new Analytics(ProfitTillConstants.ANALYTICS_URL,
|
|
|
874 |
AnalyticsUtility.getAnalyticsRequest(MainActivity.this,userData.getString("id",""),"Menu","My Profile","My Profile Clicked"),
|
|
|
875 |
AnalyticsJsonResponse.getAnalyticsRequestInstance(),
|
|
|
876 |
AnalyticsErrorResponse.getAnalyitcsResponseInstance()).anlyticsRequest(MainActivity.this);
|
|
|
877 |
MyProfile myProfile= new MyProfile();
|
|
|
878 |
this.getFragmentManager().beginTransaction()
|
|
|
879 |
.replace(R.id.frame_container, myProfile,"Mike")
|
|
|
880 |
.addToBackStack(null)
|
|
|
881 |
.commit();
|
|
|
882 |
return true;
|
|
|
883 |
case R.id.my_order:
|
|
|
884 |
titleVisible=4;
|
|
|
885 |
getSupportActionBar().setCustomView(R.layout.actionbarmyorders);
|
|
|
886 |
try {
|
|
|
887 |
mixpanel.identify(userData.getString("id",null));
|
|
|
888 |
props.put("Screen", "My Orders");
|
|
|
889 |
mixpanel.track("My Orders", props);
|
|
|
890 |
} catch (JSONException e) {
|
|
|
891 |
e.printStackTrace();
|
|
|
892 |
}
|
|
|
893 |
new Analytics(ProfitTillConstants.ANALYTICS_URL,
|
|
|
894 |
AnalyticsUtility.getAnalyticsRequest(MainActivity.this,userData.getString("id",""),"Menu","My Orders","My Orders Clicked"),
|
|
|
895 |
AnalyticsJsonResponse.getAnalyticsRequestInstance(),
|
|
|
896 |
AnalyticsErrorResponse.getAnalyitcsResponseInstance()).anlyticsRequest(MainActivity.this);
|
|
|
897 |
args.putString("key", apiData.getString("myorders.url",null)+"?user_id="+id);
|
|
|
898 |
DealsHomeFragment preferenceFragment= new DealsHomeFragment();
|
|
|
899 |
this.getFragmentManager().beginTransaction()
|
|
|
900 |
.replace(R.id.frame_container, preferenceFragment,"Mike")
|
|
|
901 |
.addToBackStack(null)
|
|
|
902 |
.commit();
|
|
|
903 |
preferenceFragment.setArguments(args);
|
|
|
904 |
|
|
|
905 |
return true;
|
|
|
906 |
case R.id.my_preferences:
|
|
|
907 |
titleVisible=2;
|
|
|
908 |
getSupportActionBar().setCustomView(R.layout.actionbarprefernces);
|
|
|
909 |
try {
|
|
|
910 |
mixpanel.identify(userData.getString("id",null));
|
|
|
911 |
props.put("Screen", "My Preferences");
|
|
|
912 |
mixpanel.track("My Preferences", props);
|
|
|
913 |
} catch (JSONException e) {
|
|
|
914 |
e.printStackTrace();
|
|
|
915 |
}
|
|
|
916 |
userDataEditor.remove("preferences").commit();
|
|
|
917 |
new Analytics(ProfitTillConstants.ANALYTICS_URL,
|
|
|
918 |
AnalyticsUtility.getAnalyticsRequest(MainActivity.this,userData.getString("id",""),"Menu","My Preferences","My Preferences Clicked"),
|
|
|
919 |
AnalyticsJsonResponse.getAnalyticsRequestInstance(),
|
|
|
920 |
AnalyticsErrorResponse.getAnalyitcsResponseInstance()).anlyticsRequest(MainActivity.this);
|
|
|
921 |
PreferencesFragment my_preferences = new PreferencesFragment();
|
|
|
922 |
this.getFragmentManager().beginTransaction()
|
|
|
923 |
.replace(R.id.frame_container, my_preferences,"Mike")
|
|
|
924 |
.addToBackStack(null)
|
|
|
925 |
.commit();
|
|
|
926 |
|
| 22132 |
rajender |
927 |
return true;*/
|
|
|
928 |
/* default:*/
|
|
|
929 |
// return super.onOptionsItemSelected(item);
|
| 21480 |
rajender |
930 |
|
|
|
931 |
|
|
|
932 |
|
| 22132 |
rajender |
933 |
|
| 22381 |
rajender |
934 |
|
| 21480 |
rajender |
935 |
@Override
|
|
|
936 |
public void onConnected(Bundle bundle) {
|
|
|
937 |
|
|
|
938 |
}
|
|
|
939 |
|
|
|
940 |
@Override
|
|
|
941 |
public void onConnectionSuspended(int i) {
|
|
|
942 |
|
|
|
943 |
}
|
|
|
944 |
|
|
|
945 |
@Override
|
|
|
946 |
public void onConnectionFailed(ConnectionResult connectionResult) {
|
|
|
947 |
|
|
|
948 |
}
|
|
|
949 |
|
|
|
950 |
@Override
|
|
|
951 |
public void onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState) {
|
|
|
952 |
super.onSaveInstanceState(outState, outPersistentState);
|
|
|
953 |
}
|
|
|
954 |
@Override
|
|
|
955 |
protected void onRestoreInstanceState(Bundle savedInstanceState) {
|
|
|
956 |
super.onRestoreInstanceState(savedInstanceState);
|
|
|
957 |
Intent i= new Intent(MainActivity.this,MainActivity.class);
|
|
|
958 |
i.putExtra("displayView","0");
|
|
|
959 |
startActivity(i);
|
|
|
960 |
}
|
|
|
961 |
|
|
|
962 |
@Override
|
|
|
963 |
public boolean onMenuOpened(int featureId, Menu menu)
|
|
|
964 |
{
|
|
|
965 |
if(featureId == Window.FEATURE_ACTION_BAR && menu != null){
|
|
|
966 |
if(menu.getClass().getSimpleName().equals("MenuBuilder")){
|
|
|
967 |
try{
|
|
|
968 |
Method m = menu.getClass().getDeclaredMethod(
|
|
|
969 |
"setOptionalIconsVisible", Boolean.TYPE);
|
|
|
970 |
m.setAccessible(true);
|
|
|
971 |
m.invoke(menu, true);
|
|
|
972 |
|
|
|
973 |
}
|
|
|
974 |
catch(Exception e){
|
|
|
975 |
throw new RuntimeException(e);
|
|
|
976 |
}
|
|
|
977 |
}
|
|
|
978 |
}
|
|
|
979 |
return super.onMenuOpened(featureId, menu);
|
|
|
980 |
}
|
|
|
981 |
|
|
|
982 |
private void displayView(int position) {
|
|
|
983 |
titleVisible=0;
|
|
|
984 |
|
|
|
985 |
Bundle args = new Bundle();
|
|
|
986 |
Tracker t = ((GoogleAnalyticsTracker) getApplicationContext()).getTracker(
|
|
|
987 |
GoogleAnalyticsTracker.TrackerName.APP_TRACKER);
|
|
|
988 |
String id = userData.getString("id",null);
|
|
|
989 |
Fragment fragment = null;
|
|
|
990 |
switch (position) {
|
|
|
991 |
case 0:
|
|
|
992 |
JSONObject props = new JSONObject();
|
|
|
993 |
try {
|
|
|
994 |
mixpanel.getPeople().set( "$last_login",new Date());
|
|
|
995 |
mixpanel.identify(userData.getString("id",null));
|
|
|
996 |
props.put("Screen", "Deals Screen");
|
|
|
997 |
mixpanel.track("Deals", props);
|
|
|
998 |
} catch (JSONException e) {
|
|
|
999 |
e.printStackTrace();
|
|
|
1000 |
}
|
|
|
1001 |
|
|
|
1002 |
t.send(new HitBuilders.EventBuilder()
|
|
|
1003 |
.setCategory("Menu")
|
|
|
1004 |
.setAction("Deals ")
|
|
|
1005 |
.setLabel("Deals Clicked")
|
|
|
1006 |
.build());
|
|
|
1007 |
new Analytics(ProfitTillConstants.ANALYTICS_URL,
|
|
|
1008 |
AnalyticsUtility.getAnalyticsRequest(MainActivity.this,userData.getString("id",""),"Menu","Deals","Deals Clicked"),
|
|
|
1009 |
AnalyticsJsonResponse.getAnalyticsRequestInstance(),
|
|
|
1010 |
AnalyticsErrorResponse.getAnalyitcsResponseInstance()).anlyticsRequest(MainActivity.this);
|
| 22381 |
rajender |
1011 |
String dealsUrl=apiData.getString("Web_Uri","http://app.profitmandi.com/entry-point");
|
| 22132 |
rajender |
1012 |
//String dealsUrl="http://192.168.120.96:4200/entry-point";
|
|
|
1013 |
//String dealsUrl=ProfitTillConstants.Web_Uri;
|
| 21480 |
rajender |
1014 |
args.putString("key",dealsUrl);
|
|
|
1015 |
fragment = new DealsHomeFragment();
|
|
|
1016 |
fragment.setArguments(args);
|
|
|
1017 |
break;
|
|
|
1018 |
case 1:
|
|
|
1019 |
JSONObject props1 = new JSONObject();
|
|
|
1020 |
try {
|
|
|
1021 |
mixpanel.identify(userData.getString("id",null));
|
| 22832 |
rajender |
1022 |
props1.put("Screen", "home");
|
|
|
1023 |
mixpanel.track("home", props1);
|
| 21480 |
rajender |
1024 |
} catch (JSONException e) {
|
|
|
1025 |
e.printStackTrace();
|
|
|
1026 |
}
|
|
|
1027 |
t.send(new HitBuilders.EventBuilder()
|
|
|
1028 |
.setCategory("Menu")
|
| 22832 |
rajender |
1029 |
.setAction("home ")
|
|
|
1030 |
.setLabel("home Clicked")
|
| 21480 |
rajender |
1031 |
.build());
|
|
|
1032 |
new Analytics(ProfitTillConstants.ANALYTICS_URL,
|
| 22832 |
rajender |
1033 |
AnalyticsUtility.getAnalyticsRequest(MainActivity.this,userData.getString("id",""),"Menu","home","home Clicked"),
|
| 21480 |
rajender |
1034 |
AnalyticsJsonResponse.getAnalyticsRequestInstance(),
|
|
|
1035 |
AnalyticsErrorResponse.getAnalyitcsResponseInstance()).anlyticsRequest(MainActivity.this);
|
| 22832 |
rajender |
1036 |
args.putString("key", apiData.getString("checkRegistration","http://app.profitmandi.com/pages/checkRegistration"));
|
| 21480 |
rajender |
1037 |
fragment = new DealsHomeFragment();
|
|
|
1038 |
fragment.setArguments(args);
|
|
|
1039 |
break;
|
|
|
1040 |
default:
|
|
|
1041 |
break;
|
|
|
1042 |
}
|
|
|
1043 |
/* if (fragment != null) {
|
|
|
1044 |
FragmentManager fragmentManager = getFragmentManager();
|
|
|
1045 |
fragmentManager.beginTransaction().replace(R.id.frame_container, fragment).commit();
|
|
|
1046 |
|
|
|
1047 |
} else {
|
|
|
1048 |
Log.e("MainActivity", "Error in creating fragment");
|
|
|
1049 |
}*/
|
|
|
1050 |
|
|
|
1051 |
if (fragment != null) {
|
|
|
1052 |
FragmentManager fragmentManager = getFragmentManager();
|
|
|
1053 |
fragmentManager.popBackStack(fragment.toString(),FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
|
|
1054 |
fragmentManager.beginTransaction().replace(R.id.frame_container, fragment).addToBackStack(fragment.toString()).commit();
|
|
|
1055 |
System.gc();
|
|
|
1056 |
} else {
|
|
|
1057 |
Log.e("MainActivity", "Error in creating fragment");
|
|
|
1058 |
}
|
|
|
1059 |
}
|
|
|
1060 |
|
|
|
1061 |
|
| 22832 |
rajender |
1062 |
/* private void displayChildView(int position) {
|
| 21480 |
rajender |
1063 |
titleVisible=0;
|
|
|
1064 |
Bundle args = new Bundle();
|
|
|
1065 |
Tracker t = ((GoogleAnalyticsTracker) getApplicationContext()).getTracker(
|
|
|
1066 |
GoogleAnalyticsTracker.TrackerName.APP_TRACKER);
|
|
|
1067 |
String id = userData.getString("id", null);
|
|
|
1068 |
Fragment fragment = null;
|
|
|
1069 |
Map<String, String> jsonParams;
|
|
|
1070 |
switch (position) {
|
|
|
1071 |
case 0:
|
|
|
1072 |
JSONObject propsAmazon = new JSONObject();
|
|
|
1073 |
try {
|
|
|
1074 |
mixpanel.identify(userData.getString("id",null));
|
|
|
1075 |
propsAmazon.put("Screen", "Amazon");
|
|
|
1076 |
mixpanel.track("Amazon", propsAmazon);
|
|
|
1077 |
} catch (JSONException e) {
|
|
|
1078 |
e.printStackTrace();
|
|
|
1079 |
}
|
|
|
1080 |
t.send(new HitBuilders.EventBuilder()
|
|
|
1081 |
.setCategory("Menu")
|
|
|
1082 |
.setAction("Amazon ")
|
|
|
1083 |
.setLabel("Amazon Clicked")
|
|
|
1084 |
.build());
|
|
|
1085 |
new Analytics(ProfitTillConstants.ANALYTICS_URL,
|
|
|
1086 |
AnalyticsUtility.getAnalyticsRequest(MainActivity.this,userData.getString("id",""),"Menu","Amazon","Amazon Clicked"),
|
|
|
1087 |
AnalyticsJsonResponse.getAnalyticsRequestInstance(),
|
|
|
1088 |
AnalyticsErrorResponse.getAnalyitcsResponseInstance()).anlyticsRequest(MainActivity.this);
|
|
|
1089 |
args.putString("key",apiData.getString("affiliate.url.redirect","")+"?user_id="+userData.getString("id","")+"&store_id="+UtilityFunctions.getNewStoreId(UtilityFunctions.generateStoreMap(apiData.getString("stores.code","amazon=1,flipkart=2,snapdeal=3,spice=4,shopclues=5,")),ProfitTillConstants.AMAZON));
|
|
|
1090 |
fragment = new DealsHomeFragment();
|
|
|
1091 |
fragment.setArguments(args);
|
|
|
1092 |
break;
|
|
|
1093 |
case 1:
|
|
|
1094 |
JSONObject propsFlipkart = new JSONObject();
|
|
|
1095 |
try {
|
|
|
1096 |
mixpanel.identify(userData.getString("id",null));
|
|
|
1097 |
propsFlipkart.put("Screen", "Flipkart");
|
|
|
1098 |
mixpanel.track("Flipkart", propsFlipkart);
|
|
|
1099 |
} catch (JSONException e) {
|
|
|
1100 |
e.printStackTrace();
|
|
|
1101 |
}
|
|
|
1102 |
t.send(new HitBuilders.EventBuilder()
|
|
|
1103 |
.setCategory("Menu")
|
|
|
1104 |
.setAction("Flipkart ")
|
|
|
1105 |
.setLabel("Flipkart Clicked")
|
|
|
1106 |
.build());
|
|
|
1107 |
|
|
|
1108 |
new Analytics(ProfitTillConstants.ANALYTICS_URL,
|
|
|
1109 |
AnalyticsUtility.getAnalyticsRequest(MainActivity.this,userData.getString("id",""),"Menu","Flipkart","Flipkart Clicked"),
|
|
|
1110 |
AnalyticsJsonResponse.getAnalyticsRequestInstance(),
|
|
|
1111 |
AnalyticsErrorResponse.getAnalyitcsResponseInstance()).anlyticsRequest(MainActivity.this);
|
|
|
1112 |
args.putString("key", apiData.getString("affiliate.url.redirect","")+"?user_id="+userData.getString("id","")+"&store_id="+UtilityFunctions.getNewStoreId(UtilityFunctions.generateStoreMap(apiData.getString("stores.code","amazon=1,flipkart=2,snapdeal=3,spice=4,shopclues=5,")),ProfitTillConstants.FLIPKART));
|
|
|
1113 |
fragment = new DealsHomeFragment();
|
|
|
1114 |
fragment.setArguments(args);
|
|
|
1115 |
break;
|
|
|
1116 |
case 2:
|
|
|
1117 |
t.send(new HitBuilders.EventBuilder()
|
|
|
1118 |
.setCategory("Menu")
|
|
|
1119 |
.setAction("HomeShop18 ")
|
|
|
1120 |
.setLabel("HomeShop18 Clicked")
|
|
|
1121 |
.build());
|
|
|
1122 |
|
|
|
1123 |
new Analytics(ProfitTillConstants.ANALYTICS_URL,
|
|
|
1124 |
AnalyticsUtility.getAnalyticsRequest(MainActivity.this,userData.getString("id",""),"Menu","HomeShop18","HomeShop18 Clicked"),
|
|
|
1125 |
AnalyticsJsonResponse.getAnalyticsRequestInstance(),
|
|
|
1126 |
AnalyticsErrorResponse.getAnalyitcsResponseInstance()).anlyticsRequest(MainActivity.this);
|
|
|
1127 |
args.putString("key", apiData.getString("affiliate.url.redirect","")+"?user_id="+userData.getString("id","")+"&store_id="+UtilityFunctions.getNewStoreId(UtilityFunctions.generateStoreMap(apiData.getString("stores.code","amazon=1,flipkart=2,snapdeal=3,spice=4,shopclues=5,paytm=6,homeshop18=7,")),ProfitTillConstants.HOMESHOP18));
|
|
|
1128 |
fragment = new DealsHomeFragment();
|
|
|
1129 |
fragment.setArguments(args);
|
|
|
1130 |
break;
|
|
|
1131 |
case 3:
|
|
|
1132 |
t.send(new HitBuilders.EventBuilder()
|
|
|
1133 |
.setCategory("Menu")
|
|
|
1134 |
.setAction("Paytm ")
|
|
|
1135 |
.setLabel("Paytm Clicked")
|
|
|
1136 |
.build());
|
|
|
1137 |
|
|
|
1138 |
new Analytics(ProfitTillConstants.ANALYTICS_URL,
|
|
|
1139 |
AnalyticsUtility.getAnalyticsRequest(MainActivity.this,userData.getString("id",""),"Menu","Paytm","Paytm Clicked"),
|
|
|
1140 |
AnalyticsJsonResponse.getAnalyticsRequestInstance(),
|
|
|
1141 |
AnalyticsErrorResponse.getAnalyitcsResponseInstance()).anlyticsRequest(MainActivity.this);
|
|
|
1142 |
args.putString("key", apiData.getString("affiliate.url.redirect","")+"?user_id="+userData.getString("id","")+"&store_id="+UtilityFunctions.getNewStoreId(UtilityFunctions.generateStoreMap(apiData.getString("stores.code","amazon=1,flipkart=2,snapdeal=3,spice=4,shopclues=5,")),ProfitTillConstants.PAYTM));
|
|
|
1143 |
fragment = new DealsHomeFragment();
|
|
|
1144 |
fragment.setArguments(args);
|
|
|
1145 |
break;
|
|
|
1146 |
case 4:
|
|
|
1147 |
JSONObject propsSaholic = new JSONObject();
|
|
|
1148 |
try {
|
|
|
1149 |
mixpanel.identify(userData.getString("id",null));
|
|
|
1150 |
propsSaholic.put("Screen", "Saholic");
|
|
|
1151 |
mixpanel.track("Saholic", propsSaholic);
|
|
|
1152 |
} catch (JSONException e) {
|
|
|
1153 |
e.printStackTrace();
|
|
|
1154 |
}
|
|
|
1155 |
t.send(new HitBuilders.EventBuilder()
|
|
|
1156 |
.setCategory("Menu")
|
|
|
1157 |
.setAction("Saholic ")
|
|
|
1158 |
.setLabel("Saholic Clicked")
|
|
|
1159 |
.build());
|
|
|
1160 |
new Analytics(ProfitTillConstants.ANALYTICS_URL,
|
|
|
1161 |
AnalyticsUtility.getAnalyticsRequest(MainActivity.this,userData.getString("id",""),"Menu","Saholic","Saholic Clicked"),
|
|
|
1162 |
AnalyticsJsonResponse.getAnalyticsRequestInstance(),
|
|
|
1163 |
AnalyticsErrorResponse.getAnalyitcsResponseInstance()).anlyticsRequest(MainActivity.this);
|
|
|
1164 |
args.putString("key", apiData.getString("saholic.autologin.url","")+"?user_id="+userData.getString("id",""));
|
|
|
1165 |
fragment = new DealsHomeFragment();
|
|
|
1166 |
fragment.setArguments(args);
|
|
|
1167 |
break;
|
|
|
1168 |
case 5:
|
|
|
1169 |
JSONObject propsShopclues = new JSONObject();
|
|
|
1170 |
try {
|
|
|
1171 |
mixpanel.identify(userData.getString("id",null));
|
|
|
1172 |
propsShopclues.put("Screen", "Shopclues");
|
|
|
1173 |
mixpanel.track("Shopclues", propsShopclues);
|
|
|
1174 |
} catch (JSONException e) {
|
|
|
1175 |
e.printStackTrace();
|
|
|
1176 |
}
|
|
|
1177 |
t.send(new HitBuilders.EventBuilder()
|
|
|
1178 |
.setCategory("Menu")
|
|
|
1179 |
.setAction("Shopclues ")
|
|
|
1180 |
.setLabel("Shopclues Clicked")
|
|
|
1181 |
.build());
|
|
|
1182 |
new Analytics(ProfitTillConstants.ANALYTICS_URL,
|
|
|
1183 |
AnalyticsUtility.getAnalyticsRequest(MainActivity.this,userData.getString("id",""),"Menu","Shopclues","Shopclues Clicked"),
|
|
|
1184 |
AnalyticsJsonResponse.getAnalyticsRequestInstance(),
|
|
|
1185 |
AnalyticsErrorResponse.getAnalyitcsResponseInstance()).anlyticsRequest(MainActivity.this);
|
|
|
1186 |
String url=apiData.getString("affiliate.url.redirect","")+"?user_id="+userData.getString("id","")+"&store_id="+UtilityFunctions.getNewStoreId(UtilityFunctions.generateStoreMap(apiData.getString("stores.code","amazon=1,flipkart=2,snapdeal=3,spice=4,shopclues=5,")),ProfitTillConstants.SHOPCLUES);
|
|
|
1187 |
args.putString("key", url);
|
|
|
1188 |
if(Uri.parse(url).getHost().equalsIgnoreCase(ProfitTillConstants.DOMAIN)) {
|
|
|
1189 |
CookieSyncManager.createInstance(getApplicationContext());
|
|
|
1190 |
CookieManager cookieManager1 = CookieManager.getInstance();
|
|
|
1191 |
cookieManager1.setCookie(url, "token=" + userData.getString("token", ""));
|
|
|
1192 |
cookieManager1.setCookie(url, "walletAuthentication=true");
|
|
|
1193 |
cookieManager1.setCookie(url, "shopcluesActive=true");
|
|
|
1194 |
}
|
|
|
1195 |
fragment = new DealsHomeFragment();
|
|
|
1196 |
fragment.setArguments(args);
|
|
|
1197 |
break;
|
|
|
1198 |
case 6:
|
|
|
1199 |
JSONObject propsSnapdeal = new JSONObject();
|
|
|
1200 |
try {
|
|
|
1201 |
mixpanel.identify(userData.getString("id",null));
|
|
|
1202 |
propsSnapdeal.put("Screen", "Snapdeal");
|
|
|
1203 |
mixpanel.track("Snapdeal", propsSnapdeal);
|
|
|
1204 |
} catch (JSONException e) {
|
|
|
1205 |
e.printStackTrace();
|
|
|
1206 |
}
|
|
|
1207 |
t.send(new HitBuilders.EventBuilder()
|
|
|
1208 |
.setCategory("Menu")
|
|
|
1209 |
.setAction("Snapdeal ")
|
|
|
1210 |
.setLabel("Snapdeal Clicked")
|
|
|
1211 |
.build());
|
|
|
1212 |
new Analytics(ProfitTillConstants.ANALYTICS_URL,
|
|
|
1213 |
AnalyticsUtility.getAnalyticsRequest(MainActivity.this,userData.getString("id",""),"Menu","Snapdeal","Snapdeal Clicked"),
|
|
|
1214 |
AnalyticsJsonResponse.getAnalyticsRequestInstance(),
|
|
|
1215 |
AnalyticsErrorResponse.getAnalyitcsResponseInstance()).anlyticsRequest(MainActivity.this);
|
|
|
1216 |
args.putString("key", apiData.getString("affiliate.url.redirect", "") + "?user_id=" + userData.getString("id", "") + "&store_id=" + UtilityFunctions.getNewStoreId(UtilityFunctions.generateStoreMap(apiData.getString("stores.code", "amazon=1,flipkart=2,snapdeal=3,spice=4,shopclues=5,")), ProfitTillConstants.SNAPDEAL));
|
|
|
1217 |
fragment = new DealsHomeFragment();
|
|
|
1218 |
fragment.setArguments(args);
|
|
|
1219 |
break;
|
|
|
1220 |
default:
|
|
|
1221 |
break;
|
|
|
1222 |
}
|
| 22832 |
rajender |
1223 |
if (fragment != null) {
|
| 21480 |
rajender |
1224 |
FragmentManager fragmentManager = getFragmentManager();
|
|
|
1225 |
fragmentManager.beginTransaction().replace(R.id.frame_container, fragment).commit();
|
|
|
1226 |
|
|
|
1227 |
} else {
|
|
|
1228 |
Log.e("MainActivity", "Error in creating fragment");
|
| 22832 |
rajender |
1229 |
}
|
| 21480 |
rajender |
1230 |
if (fragment != null) {
|
|
|
1231 |
FragmentManager fragmentManager = getFragmentManager();
|
|
|
1232 |
fragmentManager.popBackStack(fragment.toString(),FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
|
|
1233 |
fragmentManager.beginTransaction().replace(R.id.frame_container, fragment).addToBackStack(fragment.toString()).commit();
|
|
|
1234 |
System.gc();
|
|
|
1235 |
} else {
|
|
|
1236 |
Log.e("MainActivity", "Error in creating fragment");
|
|
|
1237 |
}
|
|
|
1238 |
}
|
|
|
1239 |
|
|
|
1240 |
|
| 22132 |
rajender |
1241 |
/* public void setActionBarTitlte(String parentTitle){
|
| 21480 |
rajender |
1242 |
if (parentTitle.equals("Deals")) {
|
|
|
1243 |
getSupportActionBar().setCustomView(R.layout.actionbardeals);
|
|
|
1244 |
}
|
|
|
1245 |
if (parentTitle.equalsIgnoreCase("Visit Other Stores")) {
|
|
|
1246 |
getSupportActionBar().setCustomView(R.layout.actionbarprofittill);
|
|
|
1247 |
}
|
|
|
1248 |
if (parentTitle.equals("FAQ")) {
|
|
|
1249 |
getSupportActionBar().setCustomView(R.layout.actionbaraboutus);
|
|
|
1250 |
}
|
|
|
1251 |
if (parentTitle.equals("Contact Us")) {
|
|
|
1252 |
getSupportActionBar().setCustomView(R.layout.actionbarcontactus);
|
|
|
1253 |
}
|
|
|
1254 |
if (parentTitle.equals("Search")) {
|
|
|
1255 |
getSupportActionBar().setCustomView(R.layout.actionbarsearch);
|
|
|
1256 |
}
|
|
|
1257 |
if (parentTitle.equals("How it Works")) {
|
|
|
1258 |
getSupportActionBar().setCustomView(R.layout.actionbarhowitworks);
|
|
|
1259 |
}
|
| 22132 |
rajender |
1260 |
}*/
|
| 21480 |
rajender |
1261 |
|
|
|
1262 |
@Override
|
|
|
1263 |
protected void onPostCreate(Bundle savedInstanceState) {
|
|
|
1264 |
super.onPostCreate(savedInstanceState);
|
| 22132 |
rajender |
1265 |
// mDrawerToggle.syncState();
|
| 21480 |
rajender |
1266 |
}
|
|
|
1267 |
|
|
|
1268 |
@Override
|
|
|
1269 |
public boolean onPrepareOptionsMenu(Menu menu) {
|
|
|
1270 |
boolean drawerOpen = shouldGoInvisible;
|
|
|
1271 |
hideMenuItems(menu, !drawerOpen);
|
|
|
1272 |
return super.onPrepareOptionsMenu(menu);
|
|
|
1273 |
}
|
|
|
1274 |
private void hideMenuItems(Menu menu, boolean visible)
|
|
|
1275 |
{
|
| 22132 |
rajender |
1276 |
for(int i = 0; i < menu.size(); i++){
|
|
|
1277 |
menu.getItem(i).setVisible(visible);
|
|
|
1278 |
}
|
| 21480 |
rajender |
1279 |
}
|
| 22832 |
rajender |
1280 |
/* @Override
|
| 21480 |
rajender |
1281 |
public void onConfigurationChanged(Configuration newConfig) {
|
|
|
1282 |
super.onConfigurationChanged(newConfig);
|
| 22832 |
rajender |
1283 |
//mDrawerToggle.onConfigurationChanged(newConfig);
|
|
|
1284 |
}*/
|
| 21480 |
rajender |
1285 |
@Override
|
|
|
1286 |
public boolean onKeyUp(int keycode, KeyEvent e) {
|
|
|
1287 |
switch(keycode) {
|
|
|
1288 |
case KeyEvent.KEYCODE_MENU:
|
|
|
1289 |
|
| 22132 |
rajender |
1290 |
/* if (mainMenu !=null) {
|
| 21480 |
rajender |
1291 |
mainMenu.performIdentifierAction(R.id.overflowMenu,0);
|
| 22132 |
rajender |
1292 |
}*/
|
| 21480 |
rajender |
1293 |
}
|
|
|
1294 |
|
|
|
1295 |
return super.onKeyUp(keycode, e);
|
|
|
1296 |
}
|
| 22832 |
rajender |
1297 |
|
| 21480 |
rajender |
1298 |
@Override
|
|
|
1299 |
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
1300 |
|
|
|
1301 |
switch(keyCode) {
|
|
|
1302 |
case KeyEvent.KEYCODE_MENU:
|
| 22132 |
rajender |
1303 |
/* if (mainMenu !=null) {
|
| 21480 |
rajender |
1304 |
mainMenu.performIdentifierAction(R.id.overflowMenu,0);
|
| 22132 |
rajender |
1305 |
}*/
|
| 21480 |
rajender |
1306 |
}
|
|
|
1307 |
return super.onKeyUp(keyCode, event);
|
|
|
1308 |
}
|
| 22832 |
rajender |
1309 |
|
|
|
1310 |
|
|
|
1311 |
|
| 21480 |
rajender |
1312 |
private Menu mainMenu;
|
|
|
1313 |
public final boolean isInternetOn() {
|
|
|
1314 |
|
|
|
1315 |
ConnectivityManager connec =
|
|
|
1316 |
(ConnectivityManager)getSystemService(this.getBaseContext().CONNECTIVITY_SERVICE);
|
|
|
1317 |
|
|
|
1318 |
if ( connec.getNetworkInfo(0).getState() == android.net.NetworkInfo.State.CONNECTED ||
|
|
|
1319 |
connec.getNetworkInfo(0).getState() == android.net.NetworkInfo.State.CONNECTING ||
|
|
|
1320 |
connec.getNetworkInfo(1).getState() == android.net.NetworkInfo.State.CONNECTING ||
|
|
|
1321 |
connec.getNetworkInfo(1).getState() == android.net.NetworkInfo.State.CONNECTED ) {
|
|
|
1322 |
return true;
|
|
|
1323 |
|
|
|
1324 |
} else if (
|
|
|
1325 |
connec.getNetworkInfo(0).getState() == android.net.NetworkInfo.State.DISCONNECTED ||
|
|
|
1326 |
connec.getNetworkInfo(1).getState() == android.net.NetworkInfo.State.DISCONNECTED ) {
|
|
|
1327 |
return false;
|
|
|
1328 |
}
|
|
|
1329 |
return false;
|
|
|
1330 |
}
|
|
|
1331 |
class NotificationOpenedData extends AsyncTask<ArrayList<NameValuePair>, Integer, String> {
|
|
|
1332 |
|
|
|
1333 |
@Override
|
|
|
1334 |
protected void onPreExecute() {
|
|
|
1335 |
super.onPreExecute();
|
|
|
1336 |
}
|
|
|
1337 |
|
|
|
1338 |
@Override
|
|
|
1339 |
protected String doInBackground(ArrayList<NameValuePair>... arg0) {
|
|
|
1340 |
|
|
|
1341 |
try {
|
|
|
1342 |
HttpClient httpclient = new DefaultHttpClient();
|
|
|
1343 |
HttpPost httppost = new HttpPost(apiData.getString("notification.data.url","http://api.profittill.com/pushnotifications/add"));
|
|
|
1344 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
|
|
1345 |
httppost.setEntity(new UrlEncodedFormEntity(arg0[0]));
|
|
|
1346 |
HttpResponse response = httpclient.execute(httppost);
|
|
|
1347 |
HttpEntity entity = response.getEntity();
|
|
|
1348 |
int status = response.getStatusLine().getStatusCode();
|
|
|
1349 |
|
|
|
1350 |
nameValuePairsGcm.clear();
|
|
|
1351 |
} catch (Exception e) {
|
|
|
1352 |
e.printStackTrace();
|
|
|
1353 |
}
|
|
|
1354 |
return "success";
|
|
|
1355 |
}
|
|
|
1356 |
|
|
|
1357 |
@Override
|
|
|
1358 |
protected void onPostExecute(String result) {
|
| 22132 |
rajender |
1359 |
|
| 21480 |
rajender |
1360 |
super.onPostExecute(result);
|
|
|
1361 |
}
|
|
|
1362 |
}
|
|
|
1363 |
@Override
|
|
|
1364 |
protected void onResume() {
|
|
|
1365 |
super.onResume();
|
|
|
1366 |
String userId = userData.getString("id","");
|
|
|
1367 |
String androidId=UtilityFunctions.androidId(MainActivity.this);
|
|
|
1368 |
if(!userId.isEmpty() && !androidId.isEmpty()) {
|
|
|
1369 |
String notificationUrl = apiData.getString("notification.count", "http://45.33.50.227:3001/getNotificationCount") + "?user_id=" + userId + "&android_id=" + androidId;
|
|
|
1370 |
new NotificationCount().getCount(MainActivity.this, null, notificationUrl);
|
|
|
1371 |
}
|
|
|
1372 |
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
|
|
|
1373 |
Intent i = new Intent(this, PollingService.class);
|
|
|
1374 |
PendingIntent pi = PendingIntent.getService(this, 0, i, 0);
|
|
|
1375 |
am.cancel(pi);
|
|
|
1376 |
am.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 60 * 1000, 30 * 60 * 1000, pi);
|
|
|
1377 |
invalidateOptionsMenu();
|
|
|
1378 |
}
|
|
|
1379 |
}
|