| 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;
|
|
|
14 |
import android.os.AsyncTask;
|
| 15356 |
manas |
15 |
import android.os.Bundle;
|
| 14792 |
manas |
16 |
import android.os.PersistableBundle;
|
| 15356 |
manas |
17 |
import android.support.v4.app.ActionBarDrawerToggle;
|
|
|
18 |
import android.support.v4.widget.DrawerLayout;
|
| 14792 |
manas |
19 |
import android.support.v7.app.ActionBarActivity;
|
| 15356 |
manas |
20 |
import android.util.Log;
|
| 14792 |
manas |
21 |
import android.view.KeyEvent;
|
|
|
22 |
import android.view.Menu;
|
|
|
23 |
import android.view.MenuItem;
|
|
|
24 |
import android.view.View;
|
|
|
25 |
import android.view.ViewConfiguration;
|
|
|
26 |
import android.view.Window;
|
|
|
27 |
import android.widget.AdapterView;
|
|
|
28 |
import android.widget.ListView;
|
|
|
29 |
import android.widget.Toast;
|
| 15356 |
manas |
30 |
|
| 14792 |
manas |
31 |
import com.facebook.Session;
|
|
|
32 |
import com.google.android.gms.analytics.HitBuilders;
|
|
|
33 |
import com.google.android.gms.analytics.Tracker;
|
|
|
34 |
import com.google.android.gms.common.ConnectionResult;
|
|
|
35 |
import com.google.android.gms.common.api.GoogleApiClient;
|
|
|
36 |
import com.google.android.gms.plus.Plus;
|
|
|
37 |
import com.mixpanel.android.mpmetrics.MixpanelAPI;
|
|
|
38 |
import com.saholic.profittill.Constants.ProfitTillConstants;
|
| 15356 |
manas |
39 |
import com.saholic.profittill.R;
|
|
|
40 |
import com.saholic.profittill.Utils.UtilityFunctions;
|
| 14792 |
manas |
41 |
import com.saholic.profittill.navigationdrawer.NavDrawerItem;
|
|
|
42 |
import com.saholic.profittill.navigationdrawer.NavDrawerListAdapter;
|
|
|
43 |
import com.testin.agent.TestinAgent;
|
|
|
44 |
|
|
|
45 |
import org.apache.http.HttpEntity;
|
|
|
46 |
import org.apache.http.HttpResponse;
|
|
|
47 |
import org.apache.http.NameValuePair;
|
|
|
48 |
import org.apache.http.client.HttpClient;
|
|
|
49 |
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
|
|
50 |
import org.apache.http.client.methods.HttpPost;
|
|
|
51 |
import org.apache.http.impl.client.DefaultHttpClient;
|
|
|
52 |
import org.apache.http.message.BasicNameValuePair;
|
|
|
53 |
import org.json.JSONException;
|
|
|
54 |
import org.json.JSONObject;
|
|
|
55 |
|
|
|
56 |
import java.lang.reflect.Field;
|
|
|
57 |
import java.lang.reflect.Method;
|
|
|
58 |
import java.text.SimpleDateFormat;
|
|
|
59 |
import java.util.ArrayList;
|
|
|
60 |
import java.util.Date;
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
public class MainActivity extends ActionBarActivity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
|
|
|
64 |
private DrawerLayout mDrawerLayout;
|
|
|
65 |
private ListView mDrawerList;
|
|
|
66 |
private ActionBarDrawerToggle mDrawerToggle;
|
|
|
67 |
public GoogleApiClient mGoogleApiClient;
|
|
|
68 |
SharedPreferences userData;
|
|
|
69 |
SharedPreferences apiData;
|
|
|
70 |
boolean glogout;
|
|
|
71 |
SharedPreferences.Editor userDataEditor;
|
|
|
72 |
SharedPreferences.Editor apiSettingsEditor;
|
|
|
73 |
SharedPreferences.Editor inviteDataEditor;
|
|
|
74 |
SharedPreferences inviteData;
|
|
|
75 |
private String[] navMenuTitles;
|
|
|
76 |
private TypedArray navMenuIcons;
|
|
|
77 |
String type1;
|
|
|
78 |
private ArrayList<NavDrawerItem> navDrawerItems;
|
|
|
79 |
private NavDrawerListAdapter adapter;
|
|
|
80 |
int flag;
|
|
|
81 |
boolean shouldGoInvisible;
|
|
|
82 |
int titleVisible;
|
|
|
83 |
StringBuilder subtag,sb;
|
|
|
84 |
String userIdAffliate;
|
|
|
85 |
Date dateAffliate;
|
|
|
86 |
String stringDateAffliate;
|
|
|
87 |
SimpleDateFormat dateFormatAffliate;
|
|
|
88 |
String redirectUrl;
|
|
|
89 |
MixpanelAPI mixpanel;
|
|
|
90 |
String notificationURL;
|
|
|
91 |
ArrayList<NameValuePair> nameValuePairsGcm;
|
|
|
92 |
@Override
|
|
|
93 |
protected void onCreate(Bundle savedInstanceState) {
|
|
|
94 |
super.onCreate(savedInstanceState);
|
|
|
95 |
setContentView(R.layout.activity_main);
|
|
|
96 |
TestinAgent.init(this);
|
|
|
97 |
userData = getApplicationContext().getSharedPreferences("User_Data", MODE_PRIVATE);
|
|
|
98 |
apiData = getApplicationContext().getSharedPreferences("API_Data", MODE_PRIVATE);
|
|
|
99 |
userDataEditor = userData.edit();
|
|
|
100 |
apiSettingsEditor = apiData.edit();
|
|
|
101 |
inviteData = getApplicationContext().getSharedPreferences("Invite_Data", Context.MODE_PRIVATE);
|
|
|
102 |
inviteDataEditor = inviteData.edit();
|
|
|
103 |
TestinAgent.setUserInfo(userData.getString("id",""));
|
|
|
104 |
mixpanel = MixpanelAPI.getInstance(getApplicationContext(), ProfitTillConstants.MIX_PANEL_TOKEN);
|
|
|
105 |
type1 = userData.getString("type",null);
|
|
|
106 |
|
|
|
107 |
if(getIntent().getAction()=="20"){
|
| 15588 |
manas |
108 |
Tracker t = ((GoogleAnalyticsTracker) getApplicationContext()).getTracker(
|
|
|
109 |
GoogleAnalyticsTracker.TrackerName.APP_TRACKER);
|
|
|
110 |
t.send(new HitBuilders.EventBuilder()
|
|
|
111 |
.setCategory("Notification")
|
|
|
112 |
.setAction("Notification Opened ")
|
|
|
113 |
.setLabel("For User Id " + userData.getString("id","0"))
|
|
|
114 |
.build());
|
| 14792 |
manas |
115 |
flag=20;
|
|
|
116 |
notificationURL = String.valueOf(getIntent().getData());
|
|
|
117 |
nameValuePairsGcm = new ArrayList<>();
|
|
|
118 |
nameValuePairsGcm.add(new BasicNameValuePair("user_id",userData.getString("id","")));
|
|
|
119 |
nameValuePairsGcm.add(new BasicNameValuePair("cid",getIntent().getExtras().getString("cid")));
|
| 15356 |
manas |
120 |
nameValuePairsGcm.add(new BasicNameValuePair("timestamp", UtilityFunctions.notificationDate()));
|
| 14792 |
manas |
121 |
nameValuePairsGcm.add(new BasicNameValuePair("result","opened"));
|
|
|
122 |
getIntent().getExtras().remove("cid");
|
|
|
123 |
new NotificationOpenedData().execute(nameValuePairsGcm);
|
|
|
124 |
}else if(getIntent().getAction()=="15"){
|
| 15588 |
manas |
125 |
Tracker t = ((GoogleAnalyticsTracker) getApplicationContext()).getTracker(
|
|
|
126 |
GoogleAnalyticsTracker.TrackerName.APP_TRACKER);
|
|
|
127 |
t.send(new HitBuilders.EventBuilder()
|
|
|
128 |
.setCategory("Notification")
|
|
|
129 |
.setAction("Notification Opened ")
|
|
|
130 |
.setLabel("For User Id " + userData.getString("id","0"))
|
|
|
131 |
.build());
|
| 14792 |
manas |
132 |
flag=15;
|
|
|
133 |
nameValuePairsGcm = new ArrayList<>();
|
|
|
134 |
nameValuePairsGcm.add(new BasicNameValuePair("user_id",userData.getString("id","")));
|
|
|
135 |
nameValuePairsGcm.add(new BasicNameValuePair("cid",getIntent().getExtras().getString("cid")));
|
| 15356 |
manas |
136 |
nameValuePairsGcm.add(new BasicNameValuePair("timestamp",UtilityFunctions.notificationDate()));
|
| 14792 |
manas |
137 |
nameValuePairsGcm.add(new BasicNameValuePair("result","opened"));
|
|
|
138 |
getIntent().getExtras().remove("cid");
|
|
|
139 |
new NotificationOpenedData().execute(nameValuePairsGcm);
|
|
|
140 |
}else if(getIntent().getAction()=="7"){
|
| 15588 |
manas |
141 |
Tracker t = ((GoogleAnalyticsTracker) getApplicationContext()).getTracker(
|
|
|
142 |
GoogleAnalyticsTracker.TrackerName.APP_TRACKER);
|
|
|
143 |
t.send(new HitBuilders.EventBuilder()
|
|
|
144 |
.setCategory("Notification")
|
|
|
145 |
.setAction("Notification Opened ")
|
|
|
146 |
.setLabel("For User Id " + userData.getString("id","0"))
|
|
|
147 |
.build());
|
| 14792 |
manas |
148 |
flag=7;
|
|
|
149 |
nameValuePairsGcm = new ArrayList<>();
|
|
|
150 |
nameValuePairsGcm.add(new BasicNameValuePair("user_id",userData.getString("id","")));
|
|
|
151 |
nameValuePairsGcm.add(new BasicNameValuePair("cid",getIntent().getExtras().getString("cid")));
|
| 15356 |
manas |
152 |
nameValuePairsGcm.add(new BasicNameValuePair("timestamp",UtilityFunctions.notificationDate()));
|
| 14792 |
manas |
153 |
nameValuePairsGcm.add(new BasicNameValuePair("result","opened"));
|
|
|
154 |
getIntent().getExtras().remove("cid");
|
|
|
155 |
new NotificationOpenedData().execute(nameValuePairsGcm);
|
|
|
156 |
}else if(getIntent().getAction()=="6"){
|
| 15588 |
manas |
157 |
Tracker t = ((GoogleAnalyticsTracker) getApplicationContext()).getTracker(
|
|
|
158 |
GoogleAnalyticsTracker.TrackerName.APP_TRACKER);
|
|
|
159 |
t.send(new HitBuilders.EventBuilder()
|
|
|
160 |
.setCategory("Notification")
|
|
|
161 |
.setAction("Notification Opened ")
|
|
|
162 |
.setLabel("For User Id " + userData.getString("id","0"))
|
|
|
163 |
.build());
|
| 14792 |
manas |
164 |
flag=6;
|
|
|
165 |
nameValuePairsGcm = new ArrayList<>();
|
|
|
166 |
nameValuePairsGcm.add(new BasicNameValuePair("user_id",userData.getString("id","")));
|
|
|
167 |
nameValuePairsGcm.add(new BasicNameValuePair("cid",getIntent().getExtras().getString("cid")));
|
| 15356 |
manas |
168 |
nameValuePairsGcm.add(new BasicNameValuePair("timestamp",UtilityFunctions.notificationDate()));
|
| 14792 |
manas |
169 |
nameValuePairsGcm.add(new BasicNameValuePair("result","opened"));
|
|
|
170 |
getIntent().getExtras().remove("cid");
|
|
|
171 |
new NotificationOpenedData().execute(nameValuePairsGcm);
|
| 16080 |
manas |
172 |
}else if(getIntent().getAction()=="31"){
|
|
|
173 |
Tracker t = ((GoogleAnalyticsTracker) getApplicationContext()).getTracker(
|
|
|
174 |
GoogleAnalyticsTracker.TrackerName.APP_TRACKER);
|
|
|
175 |
t.send(new HitBuilders.EventBuilder()
|
|
|
176 |
.setCategory("Email Url Opener")
|
|
|
177 |
.setAction("Email Url Opened ")
|
|
|
178 |
.setLabel("For User Id " + userData.getString("id","0"))
|
|
|
179 |
.build());
|
|
|
180 |
flag=20;
|
|
|
181 |
String emailURL= String.valueOf(getIntent().getData());
|
|
|
182 |
notificationURL =new UtilityFunctions().getEmailUrlFromMap(getApplicationContext(), emailURL,apiData.getString("mobile.website.url",""))+"?user_id="+userData.getString("id","");
|
| 14792 |
manas |
183 |
}else {
|
|
|
184 |
Bundle i = getIntent().getExtras();
|
|
|
185 |
if (i != null) {
|
|
|
186 |
flag = Integer.parseInt(i.getString("displayView"));
|
|
|
187 |
if (flag == 31) {
|
|
|
188 |
redirectUrl = i.getString("redirectUrl");
|
|
|
189 |
}
|
|
|
190 |
}
|
|
|
191 |
}
|
|
|
192 |
|
|
|
193 |
|
|
|
194 |
|
|
|
195 |
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.WHITE));
|
|
|
196 |
getSupportActionBar().setIcon(R.drawable.logo_cirlce_1);
|
|
|
197 |
getSupportActionBar().setDisplayShowCustomEnabled(true);
|
|
|
198 |
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
|
|
199 |
|
|
|
200 |
try {
|
|
|
201 |
ViewConfiguration config = ViewConfiguration.get(this);
|
|
|
202 |
Field menuKeyField = ViewConfiguration.class
|
|
|
203 |
.getDeclaredField("sHasPermanentMenuKey");
|
|
|
204 |
if (menuKeyField != null) {
|
|
|
205 |
menuKeyField.setAccessible(true);
|
|
|
206 |
menuKeyField.setBoolean(config, false);
|
|
|
207 |
}
|
|
|
208 |
} catch (Exception ex) {
|
|
|
209 |
Log.d("Exception","Message"+ex);
|
|
|
210 |
}
|
|
|
211 |
|
|
|
212 |
if(type1!=null && type1.equalsIgnoreCase("google")) {
|
|
|
213 |
mGoogleApiClient = new GoogleApiClient.Builder(this)
|
|
|
214 |
.addConnectionCallbacks(this)
|
|
|
215 |
.addOnConnectionFailedListener(this).addApi(Plus.API)
|
|
|
216 |
.addScope(Plus.SCOPE_PLUS_LOGIN).build();
|
|
|
217 |
mGoogleApiClient.connect();
|
|
|
218 |
}
|
|
|
219 |
|
|
|
220 |
/*mTitle = mDrawerTitle = getTitle();*/
|
|
|
221 |
// load slide menu items
|
|
|
222 |
navMenuTitles = getResources().getStringArray(R.array.nav_drawer_items);
|
|
|
223 |
|
|
|
224 |
// nav drawer icons from resources
|
|
|
225 |
navMenuIcons = getResources()
|
|
|
226 |
.obtainTypedArray(R.array.nav_drawer_icons);
|
|
|
227 |
|
|
|
228 |
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
|
|
|
229 |
mDrawerList = (ListView) findViewById(R.id.list_slidermenu);
|
|
|
230 |
mDrawerLayout.setBackgroundColor(getResources().getColor(R.color.White));
|
|
|
231 |
navDrawerItems = new ArrayList<NavDrawerItem>();
|
|
|
232 |
|
|
|
233 |
|
|
|
234 |
|
|
|
235 |
navDrawerItems.add(new NavDrawerItem(navMenuTitles[0], navMenuIcons.getResourceId(0, -1)));
|
|
|
236 |
navDrawerItems.add(new NavDrawerItem(navMenuTitles[1], navMenuIcons.getResourceId(1, 0)));
|
|
|
237 |
navDrawerItems.add(new NavDrawerItem(navMenuTitles[2], navMenuIcons.getResourceId(2, -1)));
|
|
|
238 |
navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons.getResourceId(3, -1)));
|
|
|
239 |
navDrawerItems.add(new NavDrawerItem(navMenuTitles[4], navMenuIcons.getResourceId(4, -1)));
|
|
|
240 |
navDrawerItems.add(new NavDrawerItem(navMenuTitles[5], navMenuIcons.getResourceId(5, -1)));
|
|
|
241 |
navDrawerItems.add(new NavDrawerItem(navMenuTitles[6], navMenuIcons.getResourceId(6, -1)));
|
|
|
242 |
navDrawerItems.add(new NavDrawerItem(navMenuTitles[7], navMenuIcons.getResourceId(7, -1)));
|
|
|
243 |
navDrawerItems.add(new NavDrawerItem(navMenuTitles[8], navMenuIcons.getResourceId(8, -1)));
|
| 16080 |
manas |
244 |
/* navDrawerItems.add(new NavDrawerItem(navMenuTitles[9], navMenuIcons.getResourceId(9, -1)));*/
|
| 14792 |
manas |
245 |
navMenuIcons.recycle();
|
|
|
246 |
|
|
|
247 |
mDrawerList.setOnItemClickListener(new SlideMenuClickListener());
|
|
|
248 |
|
|
|
249 |
// setting the nav drawer list adapter
|
|
|
250 |
adapter = new NavDrawerListAdapter(getApplicationContext(),navDrawerItems);
|
|
|
251 |
mDrawerList.setAdapter(adapter);
|
|
|
252 |
|
|
|
253 |
// enabling action bar app icon and behaving it as toggle button
|
|
|
254 |
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
|
|
255 |
getSupportActionBar().setHomeButtonEnabled(true);
|
|
|
256 |
|
|
|
257 |
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
|
| 16080 |
manas |
258 |
R.drawable.menu_button_2, //nav menu toggle icon
|
| 14792 |
manas |
259 |
R.string.hello_world, // nav drawer open - description for accessibility
|
|
|
260 |
R.string.hello_world// nav drawer close - description for accessibility
|
|
|
261 |
) {
|
|
|
262 |
public void onDrawerClosed(View view) {
|
|
|
263 |
if(titleVisible!=0) {
|
|
|
264 |
if(titleVisible==1)
|
|
|
265 |
getSupportActionBar().setCustomView(R.layout.actionbarmyfavorites);
|
|
|
266 |
|
|
|
267 |
if(titleVisible==2)
|
|
|
268 |
getSupportActionBar().setCustomView(R.layout.actionbarprefernces);
|
|
|
269 |
|
|
|
270 |
if(titleVisible==3)
|
|
|
271 |
getSupportActionBar().setCustomView(R.layout.actionbarmywallet);
|
|
|
272 |
|
|
|
273 |
if(titleVisible==4)
|
|
|
274 |
getSupportActionBar().setCustomView(R.layout.actionbarmyorders);
|
|
|
275 |
|
|
|
276 |
if(titleVisible==5)
|
|
|
277 |
getSupportActionBar().setCustomView(R.layout.actionbarpendingcashback);
|
|
|
278 |
|
|
|
279 |
if(titleVisible==6)
|
|
|
280 |
getSupportActionBar().setCustomView(R.layout.actionbarmyprofile);
|
|
|
281 |
|
|
|
282 |
|
|
|
283 |
}
|
|
|
284 |
else{
|
|
|
285 |
if (getTitle().equals("Deals")) {
|
|
|
286 |
getSupportActionBar().setCustomView(R.layout.actionbardeals);
|
|
|
287 |
}
|
|
|
288 |
if (getTitle().equals("Saholic") || getTitle().equals("Flipkart") || getTitle().equals("Snapdeal") || getTitle().equals("Amazon")) {
|
|
|
289 |
getSupportActionBar().setCustomView(R.layout.actionbarprofittill);
|
|
|
290 |
}
|
|
|
291 |
if (getTitle().equals("FAQ")) {
|
|
|
292 |
getSupportActionBar().setCustomView(R.layout.actionbaraboutus);
|
|
|
293 |
}
|
|
|
294 |
if (getTitle().equals("Contact Us")) {
|
|
|
295 |
getSupportActionBar().setCustomView(R.layout.actionbarcontactus);
|
|
|
296 |
}
|
|
|
297 |
if (getTitle().equals("Search")) {
|
|
|
298 |
getSupportActionBar().setCustomView(R.layout.actionbarsearch);
|
|
|
299 |
}
|
|
|
300 |
if (getTitle().equals("How It Works")) {
|
|
|
301 |
getSupportActionBar().setCustomView(R.layout.actionbarhowitworks);
|
|
|
302 |
}
|
|
|
303 |
}
|
|
|
304 |
shouldGoInvisible = false;
|
|
|
305 |
invalidateOptionsMenu();
|
|
|
306 |
}
|
|
|
307 |
|
|
|
308 |
public void onDrawerOpened(View drawerView) {
|
|
|
309 |
getSupportActionBar().setCustomView(R.layout.actionbarprofittill);
|
|
|
310 |
shouldGoInvisible = true;
|
|
|
311 |
invalidateOptionsMenu();
|
|
|
312 |
}
|
|
|
313 |
@Override
|
|
|
314 |
public void onDrawerSlide(View drawerView, float slideOffset) {
|
|
|
315 |
|
|
|
316 |
|
|
|
317 |
}
|
|
|
318 |
|
|
|
319 |
};
|
|
|
320 |
mDrawerLayout.setDrawerListener(mDrawerToggle);
|
|
|
321 |
|
|
|
322 |
if (savedInstanceState == null) {
|
|
|
323 |
|
|
|
324 |
if (flag == 7) {
|
|
|
325 |
getSupportActionBar().setCustomView(R.layout.actionbarhowitworks);
|
|
|
326 |
displayView(flag);
|
|
|
327 |
} else if (flag == 6) {
|
|
|
328 |
getSupportActionBar().setCustomView(R.layout.actionbarcontactus);
|
|
|
329 |
displayView(flag);
|
|
|
330 |
} else if (flag == 15) {
|
|
|
331 |
getSupportActionBar().setCustomView(R.layout.actionbarmyprofile);
|
|
|
332 |
MyProfile myProfile = new MyProfile();
|
|
|
333 |
this.getFragmentManager().beginTransaction()
|
|
|
334 |
.replace(R.id.frame_container, myProfile, "Mike")
|
|
|
335 |
.addToBackStack(null)
|
|
|
336 |
.commit();
|
|
|
337 |
}else if (flag == 20) {
|
|
|
338 |
getSupportActionBar().setCustomView(R.layout.actionbardeals);
|
|
|
339 |
JSONObject propsNotification = new JSONObject();
|
|
|
340 |
try {
|
|
|
341 |
mixpanel.identify(userData.getString("id",null));
|
|
|
342 |
propsNotification.put("Screen", "Notification Url opened");
|
|
|
343 |
mixpanel.track("Notification Opened", propsNotification);
|
|
|
344 |
} catch (JSONException e) {
|
|
|
345 |
e.printStackTrace();
|
|
|
346 |
}
|
|
|
347 |
Bundle args = new Bundle();
|
|
|
348 |
DealsHomeFragment notifcationFragment = new DealsHomeFragment();
|
|
|
349 |
args.putString("key", notificationURL);
|
|
|
350 |
this.getFragmentManager().beginTransaction()
|
|
|
351 |
.replace(R.id.frame_container, notifcationFragment, "Mike")
|
|
|
352 |
.addToBackStack(null)
|
|
|
353 |
.commit();
|
|
|
354 |
notifcationFragment.setArguments(args);
|
|
|
355 |
}else if (flag == 31) {
|
|
|
356 |
getSupportActionBar().setCustomView(R.layout.actionbardeals);
|
|
|
357 |
Bundle args = new Bundle();
|
|
|
358 |
DealsHomeFragment redirectUrlFragment = new DealsHomeFragment();
|
|
|
359 |
args.putString("key", redirectUrl);
|
|
|
360 |
this.getFragmentManager().beginTransaction()
|
|
|
361 |
.replace(R.id.frame_container, redirectUrlFragment, "Mike")
|
|
|
362 |
.addToBackStack(null)
|
|
|
363 |
.commit();
|
|
|
364 |
redirectUrlFragment.setArguments(args);
|
|
|
365 |
}else {
|
|
|
366 |
getSupportActionBar().setCustomView(R.layout.actionbardeals);
|
|
|
367 |
displayView(0);
|
|
|
368 |
}
|
|
|
369 |
|
|
|
370 |
}
|
|
|
371 |
}
|
|
|
372 |
|
|
|
373 |
/**
|
|
|
374 |
* Slide menu item click listener
|
|
|
375 |
* */
|
|
|
376 |
private class SlideMenuClickListener implements
|
|
|
377 |
ListView.OnItemClickListener {
|
|
|
378 |
@Override
|
|
|
379 |
public void onItemClick(AdapterView<?> parent, View view, int position,
|
|
|
380 |
long id) {
|
|
|
381 |
// display view for selected nav drawer item
|
|
|
382 |
displayView(position);
|
|
|
383 |
}
|
|
|
384 |
}
|
|
|
385 |
|
|
|
386 |
@Override
|
|
|
387 |
public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
388 |
mainMenu=menu;
|
|
|
389 |
super.onCreateOptionsMenu(menu);
|
|
|
390 |
getMenuInflater().inflate(R.menu.menu_main, menu);
|
|
|
391 |
|
|
|
392 |
return true;
|
|
|
393 |
}
|
|
|
394 |
|
|
|
395 |
@Override
|
|
|
396 |
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
397 |
Fragment menuFragment= null;
|
|
|
398 |
JSONObject props = new JSONObject();
|
|
|
399 |
Bundle args = new Bundle();
|
|
|
400 |
String id = userData.getString("id",null);
|
|
|
401 |
if (mDrawerToggle.onOptionsItemSelected(item)) {
|
|
|
402 |
return true;
|
|
|
403 |
}
|
|
|
404 |
getSupportActionBar().setDisplayShowCustomEnabled(true);
|
|
|
405 |
switch (item.getItemId()) {
|
|
|
406 |
case R.id.action_settings:
|
|
|
407 |
android.webkit.CookieManager cookieManager = android.webkit.CookieManager.getInstance();
|
|
|
408 |
android.webkit.CookieSyncManager.createInstance(this);
|
|
|
409 |
cookieManager.removeAllCookie();
|
|
|
410 |
try {
|
|
|
411 |
mixpanel.identify(userData.getString("id",null));
|
|
|
412 |
props.put("Screen", "Signing Out");
|
|
|
413 |
mixpanel.track("Signing Out", props);
|
|
|
414 |
} catch (JSONException e) {
|
|
|
415 |
e.printStackTrace();
|
|
|
416 |
}
|
|
|
417 |
try{
|
|
|
418 |
if (mGoogleApiClient.isConnected()) {
|
|
|
419 |
Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
|
|
|
420 |
mGoogleApiClient.disconnect();
|
|
|
421 |
mGoogleApiClient.connect();
|
|
|
422 |
userDataEditor.clear().commit();
|
|
|
423 |
inviteDataEditor.clear().commit();
|
|
|
424 |
startActivity(new Intent(MainActivity.this, LoginActivity.class));
|
|
|
425 |
}
|
|
|
426 |
else if(Session.getActiveSession() != null){
|
|
|
427 |
Session.getActiveSession().closeAndClearTokenInformation();
|
|
|
428 |
Session.setActiveSession(null);
|
|
|
429 |
userDataEditor.clear().commit();
|
|
|
430 |
inviteDataEditor.clear().commit();
|
|
|
431 |
startActivity(new Intent(MainActivity.this, LoginActivity.class));
|
|
|
432 |
}
|
|
|
433 |
else{
|
|
|
434 |
if(!mGoogleApiClient.isConnected() || Session.getActiveSession()==null){
|
|
|
435 |
userDataEditor.clear().commit();
|
|
|
436 |
inviteDataEditor.clear().commit();
|
|
|
437 |
startActivity(new Intent(MainActivity.this, LoginActivity.class));
|
|
|
438 |
}
|
|
|
439 |
|
|
|
440 |
/*Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
|
|
|
441 |
mGoogleApiClient.disconnect();
|
|
|
442 |
mGoogleApiClient.connect();*/
|
|
|
443 |
//userDataEditor.clear().commit();
|
|
|
444 |
}
|
|
|
445 |
/*if(type1.equalsIgnoreCase("facebook")) {
|
|
|
446 |
Log.d("fblogout","logout");
|
|
|
447 |
if (Session.getActiveSession() != null) {
|
|
|
448 |
Session.getActiveSession().closeAndClearTokenInformation();
|
|
|
449 |
|
|
|
450 |
}
|
|
|
451 |
Session.setActiveSession(null);
|
|
|
452 |
userDataEditor.remove("id");
|
|
|
453 |
userDataEditor.remove("type");
|
|
|
454 |
userDataEditor.remove("email");
|
|
|
455 |
userDataEditor.commit();
|
|
|
456 |
startActivity(new Intent(MainActivity.this, LoginActivity.class));
|
|
|
457 |
}
|
|
|
458 |
else{
|
|
|
459 |
signOutFromGplus();
|
|
|
460 |
if(glogout==true){
|
|
|
461 |
startActivity(new Intent(MainActivity.this, LoginActivity.class));
|
|
|
462 |
}
|
|
|
463 |
}*/
|
|
|
464 |
}catch (Exception e){
|
|
|
465 |
Log.d("Exception ","Exception");
|
|
|
466 |
/* if (Session.getActiveSession() != null) {
|
|
|
467 |
Session.getActiveSession().closeAndClearTokenInformation();
|
|
|
468 |
}else{
|
|
|
469 |
signOutFromGplus();
|
|
|
470 |
}*/
|
|
|
471 |
userDataEditor.clear().commit();
|
|
|
472 |
startActivity(new Intent(MainActivity.this, LoginActivity.class));
|
|
|
473 |
}
|
|
|
474 |
return true;
|
|
|
475 |
|
|
|
476 |
case R.id.my_wallet:
|
|
|
477 |
titleVisible=3;
|
|
|
478 |
getSupportActionBar().setCustomView(R.layout.actionbarmywallet);
|
|
|
479 |
try {
|
|
|
480 |
mixpanel.identify(userData.getString("id",null));
|
|
|
481 |
props.put("Screen", "My Wallet");
|
|
|
482 |
mixpanel.track("My Wallet", props);
|
|
|
483 |
} catch (JSONException e) {
|
|
|
484 |
e.printStackTrace();
|
|
|
485 |
}
|
|
|
486 |
MyWallet myWallet= new MyWallet();
|
|
|
487 |
this.getFragmentManager().beginTransaction()
|
|
|
488 |
.replace(R.id.frame_container, myWallet,"Mike")
|
|
|
489 |
.addToBackStack(null)
|
|
|
490 |
.commit();
|
|
|
491 |
return true;
|
|
|
492 |
case R.id.pending_cashback:
|
|
|
493 |
titleVisible=5;
|
|
|
494 |
getSupportActionBar().setCustomView(R.layout.actionbarpendingcashback);
|
|
|
495 |
try {
|
|
|
496 |
mixpanel.identify(userData.getString("id",null));
|
|
|
497 |
props.put("Screen", "Cashback Status");
|
|
|
498 |
mixpanel.track("Cashback Status", props);
|
|
|
499 |
} catch (JSONException e) {
|
|
|
500 |
e.printStackTrace();
|
|
|
501 |
}
|
| 16080 |
manas |
502 |
/*PendingCashback pendingCashback= new PendingCashback();
|
| 14792 |
manas |
503 |
this.getFragmentManager().beginTransaction()
|
|
|
504 |
.replace(R.id.frame_container, pendingCashback,"Mike")
|
|
|
505 |
.addToBackStack(null)
|
| 16080 |
manas |
506 |
.commit();*/
|
|
|
507 |
args.putString("key", apiData.getString("pendingcashback.url",null)+"?user_id="+id);
|
|
|
508 |
DealsHomeFragment orderFragment= new DealsHomeFragment();
|
|
|
509 |
this.getFragmentManager().beginTransaction()
|
|
|
510 |
.replace(R.id.frame_container, orderFragment,"Mike")
|
|
|
511 |
.addToBackStack(null)
|
| 14792 |
manas |
512 |
.commit();
|
| 16080 |
manas |
513 |
orderFragment.setArguments(args);
|
|
|
514 |
|
| 14792 |
manas |
515 |
return true;
|
|
|
516 |
case R.id.my_favorites:
|
|
|
517 |
titleVisible=1;
|
|
|
518 |
getSupportActionBar().setCustomView(R.layout.actionbarmyfavorites);
|
|
|
519 |
try {
|
|
|
520 |
mixpanel.identify(userData.getString("id",null));
|
|
|
521 |
props.put("Screen", "My Favorites");
|
|
|
522 |
mixpanel.track("My Favorites", props);
|
|
|
523 |
} catch (JSONException e) {
|
|
|
524 |
e.printStackTrace();
|
|
|
525 |
}
|
|
|
526 |
args.putString("key", apiData.getString("myfavourite.url",null)+"?user_id="+id);
|
|
|
527 |
DealsHomeFragment favoritesFragment= new DealsHomeFragment();
|
|
|
528 |
this.getFragmentManager().beginTransaction()
|
|
|
529 |
.replace(R.id.frame_container, favoritesFragment,"Mike")
|
|
|
530 |
.addToBackStack(null)
|
|
|
531 |
.commit();
|
|
|
532 |
favoritesFragment.setArguments(args);
|
|
|
533 |
return true;
|
|
|
534 |
case R.id.my_profile:
|
|
|
535 |
titleVisible=6;
|
|
|
536 |
getSupportActionBar().setCustomView(R.layout.actionbarmyprofile);
|
|
|
537 |
try {
|
|
|
538 |
mixpanel.identify(userData.getString("id",null));
|
|
|
539 |
props.put("Screen", "My Profile");
|
|
|
540 |
mixpanel.track("My profile", props);
|
|
|
541 |
} catch (JSONException e) {
|
|
|
542 |
e.printStackTrace();
|
|
|
543 |
}
|
|
|
544 |
MyProfile myProfile= new MyProfile();
|
|
|
545 |
this.getFragmentManager().beginTransaction()
|
|
|
546 |
.replace(R.id.frame_container, myProfile,"Mike")
|
|
|
547 |
.addToBackStack(null)
|
|
|
548 |
.commit();
|
|
|
549 |
return true;
|
|
|
550 |
case R.id.my_order:
|
|
|
551 |
titleVisible=4;
|
|
|
552 |
getSupportActionBar().setCustomView(R.layout.actionbarmyorders);
|
|
|
553 |
try {
|
|
|
554 |
mixpanel.identify(userData.getString("id",null));
|
|
|
555 |
props.put("Screen", "My Orders");
|
|
|
556 |
mixpanel.track("My Orders", props);
|
|
|
557 |
} catch (JSONException e) {
|
|
|
558 |
e.printStackTrace();
|
|
|
559 |
}
|
|
|
560 |
args.putString("key", apiData.getString("myorders.url",null)+"?user_id="+id);
|
| 16080 |
manas |
561 |
DealsHomeFragment preferenceFragment= new DealsHomeFragment();
|
| 14792 |
manas |
562 |
this.getFragmentManager().beginTransaction()
|
| 16080 |
manas |
563 |
.replace(R.id.frame_container, preferenceFragment,"Mike")
|
| 14792 |
manas |
564 |
.addToBackStack(null)
|
|
|
565 |
.commit();
|
| 16080 |
manas |
566 |
preferenceFragment.setArguments(args);
|
| 14792 |
manas |
567 |
|
|
|
568 |
return true;
|
|
|
569 |
case R.id.my_preferences:
|
|
|
570 |
titleVisible=2;
|
|
|
571 |
getSupportActionBar().setCustomView(R.layout.actionbarprefernces);
|
|
|
572 |
try {
|
|
|
573 |
mixpanel.identify(userData.getString("id",null));
|
|
|
574 |
props.put("Screen", "My Preferences");
|
|
|
575 |
mixpanel.track("My Preferences", props);
|
|
|
576 |
} catch (JSONException e) {
|
|
|
577 |
e.printStackTrace();
|
|
|
578 |
}
|
| 16080 |
manas |
579 |
userDataEditor.remove("preferences").commit();
|
| 14792 |
manas |
580 |
PreferencesFragment my_preferences = new PreferencesFragment();
|
|
|
581 |
this.getFragmentManager().beginTransaction()
|
|
|
582 |
.replace(R.id.frame_container, my_preferences,"Mike")
|
|
|
583 |
.addToBackStack(null)
|
|
|
584 |
.commit();
|
|
|
585 |
|
|
|
586 |
return true;
|
|
|
587 |
default:
|
|
|
588 |
return super.onOptionsItemSelected(item);
|
|
|
589 |
}
|
|
|
590 |
|
|
|
591 |
|
|
|
592 |
}
|
|
|
593 |
public void signOutFromGplus() {
|
|
|
594 |
|
|
|
595 |
|
|
|
596 |
if (mGoogleApiClient.isConnected()) {
|
|
|
597 |
Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
|
|
|
598 |
mGoogleApiClient.disconnect();
|
|
|
599 |
mGoogleApiClient.connect();
|
|
|
600 |
glogout=true;
|
|
|
601 |
userDataEditor.remove("id");
|
|
|
602 |
userDataEditor.remove("type");
|
|
|
603 |
userDataEditor.remove("email");
|
|
|
604 |
userDataEditor.commit();
|
|
|
605 |
} else {
|
|
|
606 |
glogout=false;
|
|
|
607 |
}
|
|
|
608 |
}
|
|
|
609 |
|
|
|
610 |
@Override
|
|
|
611 |
public void onConnected(Bundle bundle) {
|
|
|
612 |
|
|
|
613 |
}
|
|
|
614 |
|
|
|
615 |
@Override
|
|
|
616 |
public void onConnectionSuspended(int i) {
|
|
|
617 |
|
|
|
618 |
}
|
|
|
619 |
|
|
|
620 |
@Override
|
|
|
621 |
public void onConnectionFailed(ConnectionResult connectionResult) {
|
|
|
622 |
|
|
|
623 |
}
|
|
|
624 |
|
|
|
625 |
@Override
|
|
|
626 |
public void onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState) {
|
|
|
627 |
super.onSaveInstanceState(outState, outPersistentState);
|
|
|
628 |
}
|
|
|
629 |
@Override
|
|
|
630 |
protected void onRestoreInstanceState(Bundle savedInstanceState) {
|
|
|
631 |
super.onRestoreInstanceState(savedInstanceState);
|
| 16080 |
manas |
632 |
Intent i= new Intent(MainActivity.this,MainActivity.class);
|
| 14792 |
manas |
633 |
i.putExtra("displayView","0");
|
|
|
634 |
startActivity(i);
|
|
|
635 |
}
|
|
|
636 |
|
|
|
637 |
@Override
|
|
|
638 |
public boolean onMenuOpened(int featureId, Menu menu)
|
|
|
639 |
{
|
|
|
640 |
if(featureId == Window.FEATURE_ACTION_BAR && menu != null){
|
|
|
641 |
if(menu.getClass().getSimpleName().equals("MenuBuilder")){
|
|
|
642 |
try{
|
|
|
643 |
Method m = menu.getClass().getDeclaredMethod(
|
|
|
644 |
"setOptionalIconsVisible", Boolean.TYPE);
|
|
|
645 |
m.setAccessible(true);
|
|
|
646 |
m.invoke(menu, true);
|
|
|
647 |
|
|
|
648 |
}
|
|
|
649 |
catch(Exception e){
|
|
|
650 |
throw new RuntimeException(e);
|
|
|
651 |
}
|
|
|
652 |
}
|
|
|
653 |
}
|
|
|
654 |
return super.onMenuOpened(featureId, menu);
|
|
|
655 |
}
|
|
|
656 |
|
|
|
657 |
private void displayView(int position) {
|
|
|
658 |
titleVisible=0;
|
|
|
659 |
Bundle args = new Bundle();
|
|
|
660 |
Tracker t = ((GoogleAnalyticsTracker) getApplicationContext()).getTracker(
|
|
|
661 |
GoogleAnalyticsTracker.TrackerName.APP_TRACKER);
|
|
|
662 |
String id = userData.getString("id",null);
|
|
|
663 |
Fragment fragment = null;
|
|
|
664 |
switch (position) {
|
|
|
665 |
case 0:
|
|
|
666 |
JSONObject props = new JSONObject();
|
|
|
667 |
try {
|
|
|
668 |
mixpanel.getPeople().set( "$last_login",new Date());
|
|
|
669 |
mixpanel.identify(userData.getString("id",null));
|
|
|
670 |
props.put("Screen", "Deals Screen");
|
|
|
671 |
mixpanel.track("Deals", props);
|
|
|
672 |
} catch (JSONException e) {
|
|
|
673 |
e.printStackTrace();
|
|
|
674 |
}
|
|
|
675 |
|
|
|
676 |
t.send(new HitBuilders.EventBuilder()
|
|
|
677 |
.setCategory("Menu")
|
|
|
678 |
.setAction("Deals ")
|
|
|
679 |
.setLabel("Deals Clicked")
|
|
|
680 |
.build());
|
|
|
681 |
args.putString("key", apiData.getString("mobile.website.url","")+"?user_id="+id);
|
|
|
682 |
fragment = new DealsHomeFragment();
|
|
|
683 |
fragment.setArguments(args);
|
|
|
684 |
break;
|
|
|
685 |
case 1:
|
|
|
686 |
JSONObject props1 = new JSONObject();
|
|
|
687 |
try {
|
|
|
688 |
mixpanel.identify(userData.getString("id",null));
|
|
|
689 |
props1.put("Screen", "Search");
|
|
|
690 |
mixpanel.track("Search", props1);
|
|
|
691 |
} catch (JSONException e) {
|
|
|
692 |
e.printStackTrace();
|
|
|
693 |
}
|
|
|
694 |
t.send(new HitBuilders.EventBuilder()
|
|
|
695 |
.setCategory("Menu")
|
|
|
696 |
.setAction("Search ")
|
|
|
697 |
.setLabel("Search Clicked")
|
|
|
698 |
.build());
|
|
|
699 |
args.putString("key", apiData.getString("search.url",null)+"?user_id="+id);
|
|
|
700 |
fragment = new DealsHomeFragment();
|
|
|
701 |
fragment.setArguments(args);
|
|
|
702 |
break;
|
|
|
703 |
case 2:
|
|
|
704 |
JSONObject propsAmazon = new JSONObject();
|
|
|
705 |
try {
|
|
|
706 |
mixpanel.identify(userData.getString("id",null));
|
|
|
707 |
propsAmazon.put("Screen", "Amazon");
|
|
|
708 |
mixpanel.track("Amazon", propsAmazon);
|
|
|
709 |
} catch (JSONException e) {
|
|
|
710 |
e.printStackTrace();
|
|
|
711 |
}
|
|
|
712 |
t.send(new HitBuilders.EventBuilder()
|
|
|
713 |
.setCategory("Menu")
|
|
|
714 |
.setAction("Amazon ")
|
|
|
715 |
.setLabel("Amazon Clicked")
|
|
|
716 |
.build());
|
| 16080 |
manas |
717 |
//args.putString("key", apiData.getString("affiliate.url.redirect","")+"?user_id="+userData.getString("id","")+"&store_id="+apiData.getString("store.code.amazon",""));
|
|
|
718 |
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 |
719 |
fragment = new DealsHomeFragment();
|
|
|
720 |
fragment.setArguments(args);
|
|
|
721 |
break;
|
|
|
722 |
case 3:
|
|
|
723 |
JSONObject propsFlipkart = new JSONObject();
|
|
|
724 |
try {
|
|
|
725 |
mixpanel.identify(userData.getString("id",null));
|
|
|
726 |
propsFlipkart.put("Screen", "Flipkart");
|
|
|
727 |
mixpanel.track("Flipkart", propsFlipkart);
|
|
|
728 |
} catch (JSONException e) {
|
|
|
729 |
e.printStackTrace();
|
|
|
730 |
}
|
|
|
731 |
t.send(new HitBuilders.EventBuilder()
|
|
|
732 |
.setCategory("Menu")
|
|
|
733 |
.setAction("Flipkart ")
|
|
|
734 |
.setLabel("Flipkart Clicked")
|
|
|
735 |
.build());
|
| 16080 |
manas |
736 |
//args.putString("key", apiData.getString("affiliate.url.redirect","")+"?user_id="+userData.getString("id","")+"&store_id="+apiData.getString("store.code.flipkart",""));
|
|
|
737 |
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));
|
|
|
738 |
//args.putString("key","http://m.shopclues.com");
|
| 14792 |
manas |
739 |
fragment = new DealsHomeFragment();
|
|
|
740 |
fragment.setArguments(args);
|
|
|
741 |
break;
|
|
|
742 |
case 4:
|
|
|
743 |
JSONObject propsSaholic = new JSONObject();
|
|
|
744 |
try {
|
|
|
745 |
mixpanel.identify(userData.getString("id",null));
|
|
|
746 |
propsSaholic.put("Screen", "Saholic");
|
|
|
747 |
mixpanel.track("Saholic", propsSaholic);
|
|
|
748 |
} catch (JSONException e) {
|
|
|
749 |
e.printStackTrace();
|
|
|
750 |
}
|
|
|
751 |
t.send(new HitBuilders.EventBuilder()
|
|
|
752 |
.setCategory("Menu")
|
|
|
753 |
.setAction("Saholic ")
|
|
|
754 |
.setLabel("Saholic Clicked")
|
|
|
755 |
.build());
|
|
|
756 |
args.putString("key", apiData.getString("saholic.autologin.url","")+"?user_id="+userData.getString("id",""));
|
|
|
757 |
fragment = new DealsHomeFragment();
|
|
|
758 |
fragment.setArguments(args);
|
|
|
759 |
break;
|
| 16080 |
manas |
760 |
/*case 5:
|
|
|
761 |
JSONObject propsShopclues = new JSONObject();
|
|
|
762 |
try {
|
|
|
763 |
mixpanel.identify(userData.getString("id",null));
|
|
|
764 |
propsShopclues.put("Screen", "Shopclues");
|
|
|
765 |
mixpanel.track("Shopclues", propsShopclues);
|
|
|
766 |
} catch (JSONException e) {
|
|
|
767 |
e.printStackTrace();
|
|
|
768 |
}
|
|
|
769 |
t.send(new HitBuilders.EventBuilder()
|
|
|
770 |
.setCategory("Menu")
|
|
|
771 |
.setAction("Shopclues ")
|
|
|
772 |
.setLabel("Shopclues Clicked")
|
|
|
773 |
.build());
|
|
|
774 |
//args.putString("key", apiData.getString("affiliate.url.redirect","")+"?user_id="+userData.getString("id","")+"&store_id="+apiData.getString("store.code.snapdeal",""));
|
|
|
775 |
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,")),"shopclues");
|
|
|
776 |
args.putString("key", url);
|
|
|
777 |
CookieSyncManager.createInstance(getApplicationContext());
|
|
|
778 |
CookieManager cookieManager = CookieManager.getInstance();
|
|
|
779 |
cookieManager.setCookie(url, "token=" + userData.getString("token", ""));
|
|
|
780 |
cookieManager.setCookie(url, "walletAuthentication=true");
|
|
|
781 |
cookieManager.setCookie(url, "shopcluesActive=true");
|
|
|
782 |
fragment = new DealsHomeFragment();
|
|
|
783 |
fragment.setArguments(args);
|
|
|
784 |
break;*/
|
| 14792 |
manas |
785 |
case 5:
|
|
|
786 |
JSONObject propsSnapdeal = new JSONObject();
|
|
|
787 |
try {
|
|
|
788 |
mixpanel.identify(userData.getString("id",null));
|
|
|
789 |
propsSnapdeal.put("Screen", "Snapdeal");
|
|
|
790 |
mixpanel.track("Snapdeal", propsSnapdeal);
|
|
|
791 |
} catch (JSONException e) {
|
|
|
792 |
e.printStackTrace();
|
|
|
793 |
}
|
|
|
794 |
t.send(new HitBuilders.EventBuilder()
|
|
|
795 |
.setCategory("Menu")
|
|
|
796 |
.setAction("Snapdeal ")
|
|
|
797 |
.setLabel("Snapdeal Clicked")
|
|
|
798 |
.build());
|
| 16080 |
manas |
799 |
//args.putString("key", apiData.getString("affiliate.url.redirect","")+"?user_id="+userData.getString("id","")+"&store_id="+apiData.getString("store.code.snapdeal",""));
|
|
|
800 |
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 |
801 |
fragment = new DealsHomeFragment();
|
|
|
802 |
fragment.setArguments(args);
|
|
|
803 |
break;
|
|
|
804 |
case 6:
|
|
|
805 |
JSONObject propsContactUs = new JSONObject();
|
|
|
806 |
try {
|
|
|
807 |
mixpanel.identify(userData.getString("id",null));
|
|
|
808 |
propsContactUs.put("Screen", "Contact Us");
|
|
|
809 |
mixpanel.track("Contact Us", propsContactUs);
|
|
|
810 |
} catch (JSONException e) {
|
|
|
811 |
e.printStackTrace();
|
|
|
812 |
}
|
|
|
813 |
t.send(new HitBuilders.EventBuilder()
|
|
|
814 |
.setCategory("Menu")
|
|
|
815 |
.setAction("Contact Us ")
|
|
|
816 |
.setLabel("Contact us Clicked")
|
|
|
817 |
.build());
|
|
|
818 |
fragment = new ContactUsFragment();
|
|
|
819 |
break;
|
|
|
820 |
case 7:
|
|
|
821 |
JSONObject propsHowItWorks = new JSONObject();
|
|
|
822 |
try {
|
|
|
823 |
mixpanel.identify(userData.getString("id",null));
|
|
|
824 |
propsHowItWorks.put("Screen", "How it Works");
|
|
|
825 |
mixpanel.track("How it Works", propsHowItWorks);
|
|
|
826 |
} catch (JSONException e) {
|
|
|
827 |
e.printStackTrace();
|
|
|
828 |
}
|
|
|
829 |
t.send(new HitBuilders.EventBuilder()
|
|
|
830 |
.setCategory("Menu")
|
|
|
831 |
.setAction("Tutorials ")
|
|
|
832 |
.setLabel("Tutorials Clicked")
|
|
|
833 |
.build());
|
|
|
834 |
fragment = new HowItWorksFragment();
|
|
|
835 |
break;
|
|
|
836 |
case 8:
|
|
|
837 |
JSONObject propsAboutUs = new JSONObject();
|
|
|
838 |
try {
|
|
|
839 |
mixpanel.identify(userData.getString("id",null));
|
|
|
840 |
propsAboutUs.put("Screen", "About Us");
|
|
|
841 |
mixpanel.track("About Us", propsAboutUs);
|
|
|
842 |
} catch (JSONException e) {
|
|
|
843 |
e.printStackTrace();
|
|
|
844 |
}
|
|
|
845 |
t.send(new HitBuilders.EventBuilder()
|
|
|
846 |
.setCategory("Menu")
|
|
|
847 |
.setAction("About Us ")
|
|
|
848 |
.setLabel("About us Clicked")
|
|
|
849 |
.build());
|
|
|
850 |
fragment = new AboutUsFragment();
|
|
|
851 |
break;
|
|
|
852 |
default:
|
|
|
853 |
break;
|
|
|
854 |
}
|
|
|
855 |
if (fragment != null) {
|
|
|
856 |
FragmentManager fragmentManager = getFragmentManager();
|
|
|
857 |
fragmentManager.beginTransaction().replace(R.id.frame_container, fragment).commit();
|
|
|
858 |
mDrawerList.setItemChecked(position, true);
|
|
|
859 |
mDrawerList.setSelection(position);
|
|
|
860 |
setTitle(navMenuTitles[position]);
|
|
|
861 |
mDrawerLayout.closeDrawer(mDrawerList);
|
|
|
862 |
} else {
|
|
|
863 |
Log.e("MainActivity", "Error in creating fragment");
|
|
|
864 |
}
|
|
|
865 |
}
|
|
|
866 |
|
|
|
867 |
|
|
|
868 |
|
|
|
869 |
@Override
|
|
|
870 |
protected void onPostCreate(Bundle savedInstanceState) {
|
|
|
871 |
super.onPostCreate(savedInstanceState);
|
|
|
872 |
mDrawerToggle.syncState();
|
|
|
873 |
}
|
|
|
874 |
|
|
|
875 |
@Override
|
|
|
876 |
public boolean onPrepareOptionsMenu(Menu menu) {
|
|
|
877 |
boolean drawerOpen = shouldGoInvisible;
|
|
|
878 |
hideMenuItems(menu, !drawerOpen);
|
|
|
879 |
return super.onPrepareOptionsMenu(menu);
|
|
|
880 |
}
|
|
|
881 |
private void hideMenuItems(Menu menu, boolean visible)
|
|
|
882 |
{
|
|
|
883 |
for(int i = 0; i < menu.size(); i++){
|
|
|
884 |
menu.getItem(i).setVisible(visible);
|
|
|
885 |
}
|
|
|
886 |
}
|
|
|
887 |
@Override
|
|
|
888 |
public void onConfigurationChanged(Configuration newConfig) {
|
|
|
889 |
super.onConfigurationChanged(newConfig);
|
|
|
890 |
mDrawerToggle.onConfigurationChanged(newConfig);
|
|
|
891 |
}
|
|
|
892 |
@Override
|
|
|
893 |
public boolean onKeyUp(int keycode, KeyEvent e) {
|
|
|
894 |
switch(keycode) {
|
|
|
895 |
case KeyEvent.KEYCODE_MENU:
|
|
|
896 |
|
|
|
897 |
if (mainMenu !=null) {
|
|
|
898 |
mainMenu.performIdentifierAction(R.id.overflowMenu,0);
|
|
|
899 |
}
|
|
|
900 |
}
|
|
|
901 |
|
|
|
902 |
return super.onKeyUp(keycode, e);
|
|
|
903 |
}
|
|
|
904 |
@Override
|
|
|
905 |
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
906 |
|
|
|
907 |
switch(keyCode) {
|
|
|
908 |
case KeyEvent.KEYCODE_MENU:
|
|
|
909 |
if (mainMenu !=null) {
|
|
|
910 |
mainMenu.performIdentifierAction(R.id.overflowMenu,0);
|
|
|
911 |
}
|
|
|
912 |
}
|
|
|
913 |
return super.onKeyUp(keyCode, event);
|
|
|
914 |
}
|
|
|
915 |
private Menu mainMenu;
|
|
|
916 |
public final boolean isInternetOn() {
|
|
|
917 |
|
|
|
918 |
ConnectivityManager connec =
|
|
|
919 |
(ConnectivityManager)getSystemService(this.getBaseContext().CONNECTIVITY_SERVICE);
|
|
|
920 |
|
|
|
921 |
if ( connec.getNetworkInfo(0).getState() == android.net.NetworkInfo.State.CONNECTED ||
|
|
|
922 |
connec.getNetworkInfo(0).getState() == android.net.NetworkInfo.State.CONNECTING ||
|
|
|
923 |
connec.getNetworkInfo(1).getState() == android.net.NetworkInfo.State.CONNECTING ||
|
|
|
924 |
connec.getNetworkInfo(1).getState() == android.net.NetworkInfo.State.CONNECTED ) {
|
|
|
925 |
|
|
|
926 |
Toast.makeText(this, " Connected ", Toast.LENGTH_LONG).show();
|
|
|
927 |
return true;
|
|
|
928 |
|
|
|
929 |
} else if (
|
|
|
930 |
connec.getNetworkInfo(0).getState() == android.net.NetworkInfo.State.DISCONNECTED ||
|
|
|
931 |
connec.getNetworkInfo(1).getState() == android.net.NetworkInfo.State.DISCONNECTED ) {
|
|
|
932 |
|
|
|
933 |
Toast.makeText(this, " Not Connected ", Toast.LENGTH_LONG).show();
|
|
|
934 |
return false;
|
|
|
935 |
}
|
|
|
936 |
return false;
|
|
|
937 |
}
|
|
|
938 |
class NotificationOpenedData extends AsyncTask<ArrayList<NameValuePair>, Integer, String> {
|
|
|
939 |
|
|
|
940 |
@Override
|
|
|
941 |
protected void onPreExecute() {
|
|
|
942 |
super.onPreExecute();
|
|
|
943 |
|
|
|
944 |
}
|
|
|
945 |
|
|
|
946 |
@Override
|
|
|
947 |
protected String doInBackground(ArrayList<NameValuePair>... arg0) {
|
|
|
948 |
|
|
|
949 |
try {
|
|
|
950 |
HttpClient httpclient = new DefaultHttpClient();
|
|
|
951 |
HttpPost httppost = new HttpPost(apiData.getString("notification.data.url","http://api.profittill.com/pushnotifications/add"));
|
|
|
952 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
|
|
953 |
httppost.setEntity(new UrlEncodedFormEntity(arg0[0]));
|
|
|
954 |
HttpResponse response = httpclient.execute(httppost);
|
|
|
955 |
HttpEntity entity = response.getEntity();
|
|
|
956 |
int status = response.getStatusLine().getStatusCode();
|
|
|
957 |
|
|
|
958 |
if(status == 200){
|
|
|
959 |
Log.d("Notification Opened","Notication opened and main activity page and sent successfully");
|
|
|
960 |
Log.d("ResponseCode GCM ",status+"");
|
|
|
961 |
} else {
|
|
|
962 |
Log.d("ResponseCode GCM ",status+"");
|
|
|
963 |
}
|
|
|
964 |
|
|
|
965 |
nameValuePairsGcm.clear();
|
|
|
966 |
Log.e("pass 1", "connection success ");
|
|
|
967 |
} catch (Exception e) {
|
|
|
968 |
Log.e("Fail 1", e.toString());
|
|
|
969 |
|
|
|
970 |
}
|
|
|
971 |
return "success";
|
|
|
972 |
}
|
|
|
973 |
|
|
|
974 |
@Override
|
|
|
975 |
protected void onPostExecute(String result) {
|
|
|
976 |
super.onPostExecute(result);
|
|
|
977 |
Log.d("Notification Opened","Notication opened and main activity page");
|
|
|
978 |
}
|
|
|
979 |
}
|
|
|
980 |
}
|