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