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