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