| Line 6... |
Line 6... |
| 6 |
import android.content.ComponentName;
|
6 |
import android.content.ComponentName;
|
| 7 |
import android.content.Context;
|
7 |
import android.content.Context;
|
| 8 |
import android.content.DialogInterface;
|
8 |
import android.content.DialogInterface;
|
| 9 |
import android.content.Intent;
|
9 |
import android.content.Intent;
|
| 10 |
import android.content.SharedPreferences;
|
10 |
import android.content.SharedPreferences;
|
| 11 |
import android.content.pm.PackageManager;
|
- |
|
| 12 |
import android.content.pm.ResolveInfo;
|
11 |
import android.content.pm.ResolveInfo;
|
| 13 |
import android.graphics.Bitmap;
|
12 |
import android.graphics.Bitmap;
|
| 14 |
import android.net.ConnectivityManager;
|
13 |
import android.net.ConnectivityManager;
|
| 15 |
import android.net.Uri;
|
14 |
import android.net.Uri;
|
| 16 |
import android.os.AsyncTask;
|
15 |
import android.os.AsyncTask;
|
| Line 38... |
Line 37... |
| 38 |
import android.widget.CompoundButton;
|
37 |
import android.widget.CompoundButton;
|
| 39 |
import android.widget.RelativeLayout;
|
38 |
import android.widget.RelativeLayout;
|
| 40 |
import android.widget.TextView;
|
39 |
import android.widget.TextView;
|
| 41 |
import android.widget.Toast;
|
40 |
import android.widget.Toast;
|
| 42 |
|
41 |
|
| 43 |
import com.android.volley.toolbox.HttpClientStack;
|
- |
|
| 44 |
import com.facebook.Session;
|
42 |
import com.facebook.Session;
|
| 45 |
import com.google.android.gms.common.ConnectionResult;
|
43 |
import com.google.android.gms.common.ConnectionResult;
|
| 46 |
import com.google.android.gms.common.api.GoogleApiClient;
|
44 |
import com.google.android.gms.common.api.GoogleApiClient;
|
| 47 |
import com.google.android.gms.plus.Plus;
|
45 |
import com.google.android.gms.plus.Plus;
|
| 48 |
import com.saholic.profittill.Constants.ProfitTillConstants;
|
46 |
import com.saholic.profittill.Constants.ProfitTillConstants;
|
| Line 50... |
Line 48... |
| 50 |
import com.saholic.profittill.Network.NotificationCount;
|
48 |
import com.saholic.profittill.Network.NotificationCount;
|
| 51 |
import com.saholic.profittill.R;
|
49 |
import com.saholic.profittill.R;
|
| 52 |
import com.saholic.profittill.Utils.UtilityFunctions;
|
50 |
import com.saholic.profittill.Utils.UtilityFunctions;
|
| 53 |
import com.testin.agent.TestinAgent;
|
51 |
import com.testin.agent.TestinAgent;
|
| 54 |
|
52 |
|
| 55 |
import org.apache.http.Header;
|
- |
|
| 56 |
import org.apache.http.HttpEntity;
|
53 |
import org.apache.http.HttpEntity;
|
| 57 |
import org.apache.http.HttpResponse;
|
54 |
import org.apache.http.HttpResponse;
|
| 58 |
import org.apache.http.NameValuePair;
|
55 |
import org.apache.http.NameValuePair;
|
| 59 |
import org.apache.http.client.ClientProtocolException;
|
56 |
import org.apache.http.client.ClientProtocolException;
|
| 60 |
import org.apache.http.client.HttpClient;
|
57 |
import org.apache.http.client.HttpClient;
|
| Line 72... |
Line 69... |
| 72 |
import java.io.IOException;
|
69 |
import java.io.IOException;
|
| 73 |
import java.io.InputStream;
|
70 |
import java.io.InputStream;
|
| 74 |
import java.text.SimpleDateFormat;
|
71 |
import java.text.SimpleDateFormat;
|
| 75 |
import java.util.ArrayList;
|
72 |
import java.util.ArrayList;
|
| 76 |
import java.util.Date;
|
73 |
import java.util.Date;
|
| - |
|
74 |
import java.util.HashMap;
|
| 77 |
import java.util.Iterator;
|
75 |
import java.util.Iterator;
|
| 78 |
import java.util.LinkedList;
|
76 |
import java.util.LinkedList;
|
| 79 |
import java.util.List;
|
77 |
import java.util.List;
|
| - |
|
78 |
import java.util.Map;
|
| 80 |
import java.util.StringTokenizer;
|
79 |
import java.util.StringTokenizer;
|
| 81 |
import java.util.regex.Matcher;
|
80 |
import java.util.regex.Matcher;
|
| 82 |
import java.util.regex.Pattern;
|
81 |
import java.util.regex.Pattern;
|
| 83 |
|
82 |
|
| 84 |
public class DealsHomeFragment extends Fragment implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
|
83 |
public class DealsHomeFragment extends Fragment implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
|
| 85 |
|
84 |
|
| 86 |
public DealsHomeFragment(){
|
85 |
public DealsHomeFragment() {
|
| 87 |
|
86 |
|
| 88 |
}
|
87 |
}
|
| 89 |
|
88 |
|
| 90 |
static boolean FLAG=false,REDIRECT=false,PAGE_LOAD=false,PAYTMFLAG=false,isPause=false,Flipkartflag=false;
|
89 |
static boolean FLAG = false, REDIRECT = false, PAGE_LOAD = false, PAYTMFLAG = false, isPause = false, Flipkartflag = false;
|
| 91 |
int snapdealException=0;
|
90 |
int snapdealException = 0;
|
| 92 |
static String BASIC_AUTH = "Basic " + Base64.encodeToString("dtr:dtr18Feb2015".getBytes(), Base64.NO_WRAP);
|
91 |
static String BASIC_AUTH = "Basic " + Base64.encodeToString("dtr:dtr18Feb2015".getBytes(), Base64.NO_WRAP);
|
| 93 |
public static WebView webView;
|
92 |
public static WebView webView;
|
| 94 |
WebView amazonWebView,amazonOrderHistoryWebView,amazonOrderHistoryCancelledWebView,paytmWebView,flipkartWebView,flipkartOrderHistoryWebView,flipkartOrderHistoryCancelledWebView;
|
93 |
WebView amazonWebView, OrderHistoryWebView, amazonOrderHistoryWebView, amazonOrderHistoryCancelledWebView, paytmWebView;
|
| 95 |
WebView amazonAllUrlsWebView;
|
94 |
WebView amazonAllUrlsWebView;
|
| 96 |
SharedPreferences userData;
|
95 |
SharedPreferences userData;
|
| 97 |
SharedPreferences apiData;
|
96 |
SharedPreferences apiData;
|
| 98 |
SharedPreferences flipkartData;
|
97 |
SharedPreferences flipkartData;
|
| 99 |
SharedPreferences.Editor userDataEditor;
|
98 |
SharedPreferences.Editor userDataEditor;
|
| Line 102... |
Line 101... |
| 102 |
OrderTransactionDetails orderDetails;
|
101 |
OrderTransactionDetails orderDetails;
|
| 103 |
LinkedList<ArrayList<NameValuePair>> orderLinkedList;
|
102 |
LinkedList<ArrayList<NameValuePair>> orderLinkedList;
|
| 104 |
SharedPreferences amazonData;
|
103 |
SharedPreferences amazonData;
|
| 105 |
String affliateUrl;
|
104 |
String affliateUrl;
|
| 106 |
String landingURL;
|
105 |
String landingURL;
|
| 107 |
boolean val=false;
|
106 |
boolean val = false;
|
| 108 |
String redirectUrls;
|
107 |
String redirectUrls;
|
| 109 |
String pageLoad;
|
108 |
String pageLoad;
|
| 110 |
SharedPreferences.Editor amazonapiSettingsEditor;
|
109 |
SharedPreferences.Editor amazonapiSettingsEditor;
|
| 111 |
List<NameValuePair> amazonOrderTrackingData;
|
110 |
List<NameValuePair> amazonOrderTrackingData;
|
| 112 |
int pageRedirect=0;
|
111 |
int pageRedirect = 0;
|
| 113 |
int snapdealPageLoad;
|
112 |
int snapdealPageLoad;
|
| 114 |
String packageName=null;
|
113 |
String packageName = null;
|
| 115 |
final ArrayList<String> redirectUrlsList = new ArrayList<String>();
|
114 |
final ArrayList<String> redirectUrlsList = new ArrayList<String>();
|
| 116 |
final ArrayList<String> pageLoadList = new ArrayList<String>();
|
115 |
final ArrayList<String> pageLoadList = new ArrayList<String>();
|
| 117 |
String flipkartUrl;
|
116 |
String flipkartUrl;
|
| 118 |
View checkBoxView;
|
117 |
View checkBoxView;
|
| 119 |
boolean flipkartFlag;
|
118 |
boolean flipkartFlag;
|
| Line 123... |
Line 122... |
| 123 |
String snapdealJavascriptUrl;
|
122 |
String snapdealJavascriptUrl;
|
| 124 |
String type1;
|
123 |
String type1;
|
| 125 |
ArrayList<String> orderSuccessUrlList;
|
124 |
ArrayList<String> orderSuccessUrlList;
|
| 126 |
public GoogleApiClient mGoogleApiClient;
|
125 |
public GoogleApiClient mGoogleApiClient;
|
| 127 |
ProgressDialog pd1 = null;
|
126 |
ProgressDialog pd1 = null;
|
| - |
|
127 |
|
| 128 |
@Override
|
128 |
@Override
|
| 129 |
public void onCreate(Bundle savedInstanceState) {
|
129 |
public void onCreate(Bundle savedInstanceState) {
|
| 130 |
super.onCreate(savedInstanceState);
|
130 |
super.onCreate(savedInstanceState);
|
| 131 |
setRetainInstance(true);
|
131 |
setRetainInstance(true);
|
| 132 |
setHasOptionsMenu(true);
|
132 |
setHasOptionsMenu(true);
|
| Line 135... |
Line 135... |
| 135 |
@Override
|
135 |
@Override
|
| 136 |
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
136 |
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
| 137 |
super.onCreateOptionsMenu(menu, inflater);
|
137 |
super.onCreateOptionsMenu(menu, inflater);
|
| 138 |
RelativeLayout badgeLayout = (RelativeLayout) menu.findItem(R.id.action_notifications).getActionView();
|
138 |
RelativeLayout badgeLayout = (RelativeLayout) menu.findItem(R.id.action_notifications).getActionView();
|
| 139 |
TextView notifciationCount = (TextView) badgeLayout.findViewById(R.id.inAppNotificationText);
|
139 |
TextView notifciationCount = (TextView) badgeLayout.findViewById(R.id.inAppNotificationText);
|
| 140 |
if(userData.getInt("notification_count",0)!=0) {
|
140 |
if (userData.getInt("notification_count", 0) != 0) {
|
| 141 |
notifciationCount.setVisibility(View.VISIBLE);
|
141 |
notifciationCount.setVisibility(View.VISIBLE);
|
| 142 |
notifciationCount.setText(userData.getInt("notification_count",0)+"");
|
142 |
notifciationCount.setText(userData.getInt("notification_count", 0) + "");
|
| 143 |
}else{
|
143 |
} else {
|
| 144 |
notifciationCount.setVisibility(View.GONE);
|
144 |
notifciationCount.setVisibility(View.GONE);
|
| 145 |
}
|
145 |
}
|
| 146 |
}
|
146 |
}
|
| 147 |
|
147 |
|
| 148 |
@Override
|
148 |
@Override
|
| Line 151... |
Line 151... |
| 151 |
|
151 |
|
| 152 |
|
152 |
|
| 153 |
View rootView = inflater.inflate(R.layout.fragment_deals_home, container, false);
|
153 |
View rootView = inflater.inflate(R.layout.fragment_deals_home, container, false);
|
| 154 |
|
154 |
|
| 155 |
TestinAgent.init(getActivity());
|
155 |
TestinAgent.init(getActivity());
|
| 156 |
amazonData= getActivity().getSharedPreferences("Amazon_Data", Context.MODE_PRIVATE);
|
156 |
amazonData = getActivity().getSharedPreferences("Amazon_Data", Context.MODE_PRIVATE);
|
| 157 |
userData = getActivity().getSharedPreferences("User_Data", Context.MODE_PRIVATE);
|
157 |
userData = getActivity().getSharedPreferences("User_Data", Context.MODE_PRIVATE);
|
| 158 |
apiData = getActivity().getSharedPreferences("API_Data", Context.MODE_PRIVATE);
|
158 |
apiData = getActivity().getSharedPreferences("API_Data", Context.MODE_PRIVATE);
|
| 159 |
flipkartData = getActivity().getSharedPreferences("Flipkart_Data", Context.MODE_PRIVATE);
|
159 |
flipkartData = getActivity().getSharedPreferences("Flipkart_Data", Context.MODE_PRIVATE);
|
| 160 |
userDataEditor = userData.edit();
|
160 |
userDataEditor = userData.edit();
|
| 161 |
apiSettingsEditor = apiData.edit();
|
161 |
apiSettingsEditor = apiData.edit();
|
| 162 |
TestinAgent.setUserInfo(userData.getString("id",""));
|
162 |
TestinAgent.setUserInfo(userData.getString("id", ""));
|
| 163 |
amazonapiSettingsEditor = amazonData.edit();
|
163 |
amazonapiSettingsEditor = amazonData.edit();
|
| 164 |
flipkartDataEditor = flipkartData.edit();
|
164 |
flipkartDataEditor = flipkartData.edit();
|
| 165 |
affliateUrl=getArguments().getString("key");
|
165 |
affliateUrl = getArguments().getString("key");
|
| 166 |
orderDetails = new OrderTransactionDetails(getActivity());
|
166 |
orderDetails = new OrderTransactionDetails(getActivity());
|
| 167 |
|
167 |
|
| 168 |
orderSuccessUrlList = new ArrayList<String>();
|
168 |
orderSuccessUrlList = new ArrayList<String>();
|
| 169 |
String issues =apiData.getString("list.order.success.url","blank");
|
169 |
String issues = apiData.getString("list.order.success.url", "blank");
|
| 170 |
StringTokenizer st2 = new StringTokenizer(issues, "|");
|
170 |
StringTokenizer st2 = new StringTokenizer(issues, "|");
|
| 171 |
|
171 |
|
| 172 |
while (st2.hasMoreElements()) {
|
172 |
while (st2.hasMoreElements()) {
|
| 173 |
orderSuccessUrlList.add(st2.nextToken());
|
173 |
orderSuccessUrlList.add(st2.nextToken());
|
| 174 |
}
|
174 |
}
|
| 175 |
if(isInternetOn()) {
|
175 |
if (isInternetOn()) {
|
| 176 |
if(orderDetails.countTotalRecords()>0){
|
176 |
if (orderDetails.countTotalRecords() > 0) {
|
| 177 |
sendQueuedResponse();
|
177 |
sendQueuedResponse();
|
| 178 |
}
|
178 |
}
|
| 179 |
type1 = userData.getString("type",null);
|
179 |
type1 = userData.getString("type", null);
|
| 180 |
if(type1!=null && type1.equalsIgnoreCase("google")) {
|
180 |
if (type1 != null && type1.equalsIgnoreCase("google")) {
|
| 181 |
mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
|
181 |
mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
|
| 182 |
.addConnectionCallbacks(this)
|
182 |
.addConnectionCallbacks(this)
|
| 183 |
.addOnConnectionFailedListener(this).addApi(Plus.API)
|
183 |
.addOnConnectionFailedListener(this).addApi(Plus.API)
|
| 184 |
.addScope(Plus.SCOPE_PLUS_LOGIN).build();
|
184 |
.addScope(Plus.SCOPE_PLUS_LOGIN).build();
|
| 185 |
mGoogleApiClient.connect();
|
185 |
mGoogleApiClient.connect();
|
| 186 |
}
|
186 |
}
|
| 187 |
redirectUrls=apiData.getString("profitmandi.redirect.urls","");
|
187 |
redirectUrls = apiData.getString("profitmandi.redirect.urls", "");
|
| 188 |
StringTokenizer st = new StringTokenizer(redirectUrls,"|");
|
188 |
StringTokenizer st = new StringTokenizer(redirectUrls, "|");
|
| 189 |
while(st.hasMoreTokens()){
|
189 |
while (st.hasMoreTokens()) {
|
| 190 |
redirectUrlsList.add( st.nextToken());
|
190 |
redirectUrlsList.add(st.nextToken());
|
| 191 |
}
|
191 |
}
|
| 192 |
pageLoad =apiData.getString("profitmandi.pageloads.pattern","");
|
192 |
pageLoad = apiData.getString("profitmandi.pageloads.pattern", "");
|
| 193 |
StringTokenizer st1 = new StringTokenizer(pageLoad,"|");
|
193 |
StringTokenizer st1 = new StringTokenizer(pageLoad, "|");
|
| 194 |
while(st1.hasMoreTokens()){
|
194 |
while (st1.hasMoreTokens()) {
|
| 195 |
pageLoadList.add( st1.nextToken());
|
195 |
pageLoadList.add(st1.nextToken());
|
| 196 |
}
|
196 |
}
|
| 197 |
WebClientClass webViewClient = new WebClientClass();
|
197 |
WebClientClass webViewClient = new WebClientClass();
|
| 198 |
if(webView !=null){
|
198 |
if (webView != null) {
|
| 199 |
webView.loadUrl("about:blank");
|
199 |
webView.loadUrl("about:blank");
|
| 200 |
}
|
200 |
}
|
| 201 |
webView = (WebView) rootView.findViewById(R.id.webView);
|
201 |
webView = (WebView) rootView.findViewById(R.id.webView);
|
| 202 |
webView.setClickable(true);
|
202 |
webView.setClickable(true);
|
| 203 |
webView.setFocusableInTouchMode(true);
|
203 |
webView.setFocusableInTouchMode(true);
|
| Line 213... |
Line 213... |
| 213 |
webView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
213 |
webView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
| 214 |
webView.getSettings().setAllowContentAccess(true);
|
214 |
webView.getSettings().setAllowContentAccess(true);
|
| 215 |
CookieManager cookieManager1 = CookieManager.getInstance();
|
215 |
CookieManager cookieManager1 = CookieManager.getInstance();
|
| 216 |
cookieManager1.setAcceptThirdPartyCookies(webView, true);
|
216 |
cookieManager1.setAcceptThirdPartyCookies(webView, true);
|
| 217 |
}
|
217 |
}
|
| 218 |
if(Uri.parse(getArguments().getString("key")).getHost().contains("api.profittill")) {
|
218 |
if (Uri.parse(getArguments().getString("key")).getHost().contains("api.profittill")) {
|
| 219 |
userDataEditor.putString("saholic.data",UtilityFunctions.clearCookiesNew(getArguments().getString("key"),getActivity())).commit();
|
219 |
userDataEditor.putString("saholic.data", UtilityFunctions.clearCookiesNew(getArguments().getString("key"), getActivity())).commit();
|
| 220 |
}
|
220 |
}
|
| 221 |
String url = getArguments().getString("key");
|
221 |
String url = getArguments().getString("key");
|
| 222 |
if(Uri.parse(url).getHost().equalsIgnoreCase(ProfitTillConstants.DOMAIN)) {
|
222 |
if (Uri.parse(url).getHost().equalsIgnoreCase(ProfitTillConstants.DOMAIN)) {
|
| 223 |
CookieSyncManager.createInstance(getActivity());
|
223 |
CookieSyncManager.createInstance(getActivity());
|
| 224 |
CookieManager cookieManager1 = CookieManager.getInstance();
|
224 |
CookieManager cookieManager1 = CookieManager.getInstance();
|
| 225 |
cookieManager1.setCookie(url, "token=" + userData.getString("token", ""));
|
225 |
cookieManager1.setCookie(url, "token=" + userData.getString("token", ""));
|
| 226 |
cookieManager1.setCookie(url, "walletAuthentication=true");
|
226 |
cookieManager1.setCookie(url, "walletAuthentication=true");
|
| 227 |
cookieManager1.setCookie(url, "shopcluesActive=true");
|
227 |
cookieManager1.setCookie(url, "shopcluesActive=true");
|
| 228 |
cookieManager1.setCookie(url, "paytmActive=true");
|
228 |
cookieManager1.setCookie(url, "paytmActive=true");
|
| 229 |
cookieManager1.setCookie(url, "shareApps=true");
|
229 |
cookieManager1.setCookie(url, "shareApps=true");
|
| 230 |
cookieManager1.setCookie(url, "homeshop18=true");
|
230 |
cookieManager1.setCookie(url, "homeshop18=true");
|
| 231 |
cookieManager1.setCookie(url, "isRedirect=true");
|
231 |
cookieManager1.setCookie(url, "isRedirect=true");
|
| 232 |
}
|
232 |
}
|
| 233 |
if(!(userData.getBoolean("paytmLoggedIn",false))){
|
233 |
if (!(userData.getBoolean("paytmLoggedIn", false))) {
|
| 234 |
Log.d("User Not Logged In","User Not logged In");
|
234 |
Log.d("User Not Logged In", "User Not logged In");
|
| 235 |
}else {
|
235 |
} else {
|
| 236 |
if (userData.getString("paytmOrder", "").equalsIgnoreCase("true")) {
|
236 |
if (userData.getString("paytmOrder", "").equalsIgnoreCase("true")) {
|
| 237 |
long nextFetchTime=userData.getLong("paytmNextFetchTime", 0);
|
237 |
long nextFetchTime = userData.getLong("paytmNextFetchTime", 0);
|
| 238 |
if (nextFetchTime == 0 || nextFetchTime< System.currentTimeMillis()) {
|
238 |
if (nextFetchTime == 0 || nextFetchTime < System.currentTimeMillis()) {
|
| 239 |
if(isInternetOn()) {
|
239 |
if (isInternetOn()) {
|
| 240 |
new PaytmOrderURL().execute();
|
240 |
new PaytmOrderURL().execute();
|
| 241 |
}
|
241 |
}
|
| 242 |
} else {
|
242 |
} else {
|
| 243 |
Log.d("Paytm False", "Paytm Time False");
|
243 |
Log.d("Paytm False", "Paytm Time False");
|
| 244 |
}
|
244 |
}
|
| 245 |
} else {
|
245 |
} else {
|
| 246 |
Log.d("Paytm False", "Paytm False No orders");
|
246 |
Log.d("Paytm False", "Paytm False No orders");
|
| 247 |
}
|
247 |
}
|
| 248 |
}
|
248 |
}
|
| 249 |
if(!(userData.getBoolean("amazonLoggedIn",false))){
|
249 |
if (!(userData.getBoolean("amazonLoggedIn", false))) {
|
| 250 |
Log.d("Not In Amazon","Amazon" );
|
250 |
Log.d("Not In Amazon", "Amazon");
|
| - |
|
251 |
}
|
| 251 |
}else {
|
252 |
else {
|
| 252 |
if (userData.getString("amazonOrder", "").equalsIgnoreCase("true")) {
|
253 |
if (userData.getString("amazonOrder", "").equalsIgnoreCase("true")) {
|
| 253 |
long nextFetchTime=userData.getLong("amazonNextFetchTime", 0);
|
254 |
long nextFetchTime = userData.getLong("amazonNextFetchTime", 0);
|
| 254 |
if (nextFetchTime == 0 || nextFetchTime< System.currentTimeMillis()) {
|
255 |
if (nextFetchTime == 0 || nextFetchTime < System.currentTimeMillis()) {
|
| 255 |
if(isInternetOn()) {
|
256 |
if (isInternetOn()) {
|
| 256 |
new FetchOrderURLS().execute();
|
257 |
new FetchOrderURLS().execute();
|
| 257 |
}
|
258 |
}
|
| 258 |
} else {
|
259 |
} else {
|
| 259 |
Log.d("Amazon False", "Amazon Time False" + userData.getLong("amazonNextFetchTime", 0));
|
260 |
Log.d("Amazon False", "Amazon Time False" + userData.getLong("amazonNextFetchTime", 0));
|
| 260 |
}
|
261 |
}
|
| 261 |
} else {
|
262 |
} else {
|
| 262 |
Log.d("Amazon False", "Amazon False No orders");
|
263 |
Log.d("Amazon False", "Amazon False No orders");
|
| 263 |
}
|
264 |
}
|
| 264 |
}
|
265 |
}
|
| 265 |
if(!(userData.getBoolean("flipkartLoggedIn", false))){
|
- |
|
| 266 |
Log.d("Not IN Flipkart","Flipkart");
|
- |
|
| 267 |
}else{
|
- |
|
| 268 |
if(userData.getString("flipkartOrder", "").equalsIgnoreCase("true")){
|
- |
|
| 269 |
long nextFetchTime=userData.getLong("flipkartNextFetchTime", 0);
|
- |
|
| 270 |
if (nextFetchTime == 0 || nextFetchTime< System.currentTimeMillis()) {
|
- |
|
| 271 |
if(isInternetOn()) {
|
- |
|
| 272 |
new FlipkartOrderURLS().execute();
|
- |
|
| 273 |
}
|
- |
|
| 274 |
} else {
|
- |
|
| 275 |
Log.d("Flipkart False", "Flipkart Time False" + userData.getLong("flipkartNextFetchTime", 0));
|
- |
|
| 276 |
}
|
- |
|
| 277 |
} else {
|
- |
|
| 278 |
Log.d("Flipkart False", "Flipkart False No orders");
|
- |
|
| 279 |
}
|
- |
|
| 280 |
}
|
- |
|
| 281 |
webView.loadUrl(url);
|
266 |
webView.loadUrl(url);
|
| 282 |
webView.setWebViewClient(webViewClient);
|
267 |
webView.setWebViewClient(webViewClient);
|
| 283 |
|
268 |
|
| 284 |
}
|
- |
|
| 285 |
else{
|
269 |
} else {
|
| 286 |
SearchFragment nextFrag= new SearchFragment();
|
270 |
SearchFragment nextFrag = new SearchFragment();
|
| 287 |
Bundle args = new Bundle();
|
271 |
Bundle args = new Bundle();
|
| 288 |
args.putString("finishingurl", getArguments().getString("key"));
|
272 |
args.putString("finishingurl", getArguments().getString("key"));
|
| 289 |
args.putString("fragmentNumber", "1");
|
273 |
args.putString("fragmentNumber", "1");
|
| 290 |
nextFrag.setArguments(args);
|
274 |
nextFrag.setArguments(args);
|
| 291 |
getActivity().getFragmentManager().beginTransaction()
|
275 |
getActivity().getFragmentManager().beginTransaction()
|
| Line 315... |
Line 299... |
| 315 |
|
299 |
|
| 316 |
@Override
|
300 |
@Override
|
| 317 |
public void onConnectionFailed(ConnectionResult connectionResult) {
|
301 |
public void onConnectionFailed(ConnectionResult connectionResult) {
|
| 318 |
|
302 |
|
| 319 |
}
|
303 |
}
|
| - |
|
304 |
|
| 320 |
public class WebClientClass extends WebViewClient {
|
305 |
public class WebClientClass extends WebViewClient {
|
| 321 |
ProgressDialog pd = null;
|
306 |
ProgressDialog pd = null;
|
| 322 |
|
307 |
|
| 323 |
ProgressDialog pd2 = null;
|
308 |
ProgressDialog pd2 = null;
|
| 324 |
|
309 |
|
| Line 331... |
Line 316... |
| 331 |
}
|
316 |
}
|
| 332 |
|
317 |
|
| 333 |
@Override
|
318 |
@Override
|
| 334 |
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
319 |
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
| 335 |
|
320 |
|
| 336 |
if(apiData.getString("snapdealException","false").equalsIgnoreCase("true")){
|
321 |
if (apiData.getString("snapdealException", "false").equalsIgnoreCase("true")) {
|
| 337 |
List<String> snapdealExceptionUrls = new ArrayList<>();
|
322 |
List<String> snapdealExceptionUrls = new ArrayList<>();
|
| 338 |
StringTokenizer st = new StringTokenizer(apiData.getString("snapdeal.exception.urls",""),"|");
|
323 |
StringTokenizer st = new StringTokenizer(apiData.getString("snapdeal.exception.urls", ""), "|");
|
| 339 |
while(st.hasMoreTokens()){
|
324 |
while (st.hasMoreTokens()) {
|
| 340 |
snapdealExceptionUrls.add( st.nextToken());
|
325 |
snapdealExceptionUrls.add(st.nextToken());
|
| 341 |
}
|
326 |
}
|
| 342 |
try {
|
327 |
try {
|
| 343 |
Log.d("Count","Count " +apiData.getString("snapdeal.exception.count","1"));
|
328 |
Log.d("Count", "Count " + apiData.getString("snapdeal.exception.count", "1"));
|
| 344 |
for(String s:snapdealExceptionUrls){
|
329 |
for (String s : snapdealExceptionUrls) {
|
| 345 |
if(url.contains(s)){
|
330 |
if (url.contains(s)) {
|
| 346 |
if(snapdealException<=Integer.parseInt(apiData.getString("snapdeal.exception.count","1"))){
|
331 |
if (snapdealException <= Integer.parseInt(apiData.getString("snapdeal.exception.count", "1"))) {
|
| 347 |
webView.reload();
|
332 |
webView.reload();
|
| 348 |
snapdealException+=1;
|
333 |
snapdealException += 1;
|
| 349 |
}
|
334 |
}
|
| 350 |
return false;
|
335 |
return false;
|
| 351 |
}
|
336 |
}
|
| 352 |
}
|
337 |
}
|
| 353 |
}catch(Exception e){
|
338 |
} catch (Exception e) {
|
| 354 |
e.printStackTrace();
|
339 |
e.printStackTrace();
|
| 355 |
}
|
340 |
}
|
| 356 |
}
|
341 |
}
|
| 357 |
if(apiData.getString("isRedirect","false").equalsIgnoreCase("true")){
|
342 |
if (apiData.getString("isRedirect", "false").equalsIgnoreCase("true")) {
|
| 358 |
List<String> browserRedirectUrl = new ArrayList<>();
|
343 |
List<String> browserRedirectUrl = new ArrayList<>();
|
| 359 |
StringTokenizer st = new StringTokenizer(apiData.getString("redirect.urls",""),"|");
|
344 |
StringTokenizer st = new StringTokenizer(apiData.getString("redirect.urls", ""), "|");
|
| 360 |
while(st.hasMoreTokens()){
|
345 |
while (st.hasMoreTokens()) {
|
| 361 |
browserRedirectUrl.add( st.nextToken());
|
346 |
browserRedirectUrl.add(st.nextToken());
|
| 362 |
}
|
347 |
}
|
| 363 |
for(String s:browserRedirectUrl){
|
348 |
for (String s : browserRedirectUrl) {
|
| 364 |
if(url.contains(s)){
|
349 |
if (url.contains(s)) {
|
| 365 |
isPause=true;
|
350 |
isPause = true;
|
| 366 |
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
351 |
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
| 367 |
startActivity(intent);
|
352 |
startActivity(intent);
|
| 368 |
return true;
|
353 |
return true;
|
| 369 |
}
|
354 |
}
|
| 370 |
}
|
355 |
}
|
| 371 |
}
|
356 |
}
|
| 372 |
if(url.contains("apprub")){
|
357 |
if (url.contains("apprub")) {
|
| 373 |
onShareClick(url);
|
358 |
onShareClick(url);
|
| 374 |
return true;
|
359 |
return true;
|
| 375 |
}
|
360 |
}
|
| 376 |
if(url.contains(apiData.getString("wallet.auth","api.profittill.com/special/native/login")) || userData.getString("id","").isEmpty()){
|
361 |
if (url.contains(apiData.getString("wallet.auth", "api.profittill.com/special/native/login")) || userData.getString("id", "").isEmpty()) {
|
| 377 |
android.webkit.CookieManager cookieManager = android.webkit.CookieManager.getInstance();
|
362 |
android.webkit.CookieManager cookieManager = android.webkit.CookieManager.getInstance();
|
| 378 |
android.webkit.CookieSyncManager.createInstance(getActivity());
|
363 |
android.webkit.CookieSyncManager.createInstance(getActivity());
|
| 379 |
cookieManager.removeAllCookie();
|
364 |
cookieManager.removeAllCookie();
|
| 380 |
AlertDialog alert;
|
365 |
AlertDialog alert;
|
| 381 |
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
366 |
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
| 382 |
builder.setMessage(apiData.getString("wallet.auth.message","You are not authenticated. Please log in again")).setCancelable(false);
|
367 |
builder.setMessage(apiData.getString("wallet.auth.message", "You are not authenticated. Please log in again")).setCancelable(false);
|
| 383 |
alert = builder.create();
|
368 |
alert = builder.create();
|
| 384 |
alert.show();
|
369 |
alert.show();
|
| 385 |
try{
|
370 |
try {
|
| 386 |
if (mGoogleApiClient.isConnected()) {
|
371 |
if (mGoogleApiClient.isConnected()) {
|
| 387 |
Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
|
372 |
Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
|
| 388 |
mGoogleApiClient.disconnect();
|
373 |
mGoogleApiClient.disconnect();
|
| 389 |
mGoogleApiClient.connect();
|
374 |
mGoogleApiClient.connect();
|
| 390 |
redirectPage(alert);
|
375 |
redirectPage(alert);
|
| 391 |
}
|
- |
|
| 392 |
else if(Session.getActiveSession() != null){
|
376 |
} else if (Session.getActiveSession() != null) {
|
| 393 |
Session.getActiveSession().closeAndClearTokenInformation();
|
377 |
Session.getActiveSession().closeAndClearTokenInformation();
|
| 394 |
Session.setActiveSession(null);
|
378 |
Session.setActiveSession(null);
|
| 395 |
redirectPage(alert);
|
379 |
redirectPage(alert);
|
| 396 |
}
|
- |
|
| 397 |
else{
|
380 |
} else {
|
| 398 |
if(!mGoogleApiClient.isConnected() || Session.getActiveSession()==null){
|
381 |
if (!mGoogleApiClient.isConnected() || Session.getActiveSession() == null) {
|
| 399 |
redirectPage(alert);
|
382 |
redirectPage(alert);
|
| 400 |
}
|
383 |
}
|
| 401 |
}
|
384 |
}
|
| 402 |
}catch (Exception e){
|
385 |
} catch (Exception e) {
|
| 403 |
redirectPage(alert);
|
386 |
redirectPage(alert);
|
| 404 |
}
|
387 |
}
|
| 405 |
return true;
|
388 |
return true;
|
| 406 |
}
|
389 |
}
|
| 407 |
if(url.contains("com.saholic.profittill")){
|
390 |
if (url.contains("com.saholic.profittill")) {
|
| 408 |
Intent intent = null;
|
391 |
Intent intent = null;
|
| 409 |
try {
|
392 |
try {
|
| 410 |
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getActivity().getPackageName()));
|
393 |
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getActivity().getPackageName()));
|
| 411 |
} catch (android.content.ActivityNotFoundException anfe) {
|
394 |
} catch (android.content.ActivityNotFoundException anfe) {
|
| 412 |
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + getActivity().getPackageName()));
|
395 |
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + getActivity().getPackageName()));
|
| 413 |
}
|
396 |
}
|
| 414 |
startActivity(intent);
|
397 |
startActivity(intent);
|
| 415 |
return true;
|
398 |
return true;
|
| 416 |
}
|
399 |
}
|
| 417 |
if(snapdealPageLoad==1){
|
400 |
if (snapdealPageLoad == 1) {
|
| 418 |
pd2 = new ProgressDialog(getActivity());
|
401 |
pd2 = new ProgressDialog(getActivity());
|
| 419 |
pd2.setMessage("Wait for a moment and click again.");
|
402 |
pd2.setMessage("Wait for a moment and click again.");
|
| 420 |
pd2.setProgress(view.getProgress());
|
403 |
pd2.setProgress(view.getProgress());
|
| 421 |
pd2.show();
|
404 |
pd2.show();
|
| 422 |
return true;
|
405 |
return true;
|
| 423 |
}
|
406 |
}
|
| 424 |
if(url.startsWith("tel")){
|
407 |
if (url.startsWith("tel")) {
|
| 425 |
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
408 |
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
| 426 |
startActivity(intent);
|
409 |
startActivity(intent);
|
| 427 |
return true;
|
410 |
return true;
|
| 428 |
}
|
411 |
}
|
| 429 |
if(url.contains(apiData.getString("contactus.url", ""))){
|
412 |
if (url.contains(apiData.getString("contactus.url", ""))) {
|
| 430 |
Intent i = new Intent(getActivity(),MainActivity.class);
|
413 |
Intent i = new Intent(getActivity(), MainActivity.class);
|
| 431 |
i.putExtra("displayView","6");
|
414 |
i.putExtra("displayView", "6");
|
| 432 |
startActivity(i);
|
415 |
startActivity(i);
|
| 433 |
return true;
|
416 |
return true;
|
| 434 |
}
|
417 |
}
|
| 435 |
if(url.contains(apiData.getString("howitworks.url",""))){
|
418 |
if (url.contains(apiData.getString("howitworks.url", ""))) {
|
| 436 |
Intent i = new Intent(getActivity(),MainActivity.class);
|
419 |
Intent i = new Intent(getActivity(), MainActivity.class);
|
| 437 |
i.putExtra("displayView", "7");
|
420 |
i.putExtra("displayView", "7");
|
| 438 |
startActivity(i);
|
421 |
startActivity(i);
|
| 439 |
return true;
|
422 |
return true;
|
| 440 |
}
|
423 |
}
|
| 441 |
if(url.contains(apiData.getString("myprofile.url", "http://api.profittill.com/aboutus/profile"))){
|
424 |
if (url.contains(apiData.getString("myprofile.url", "http://api.profittill.com/aboutus/profile"))) {
|
| 442 |
Intent i = new Intent(getActivity(),MainActivity.class);
|
425 |
Intent i = new Intent(getActivity(), MainActivity.class);
|
| 443 |
i.putExtra("displayView","15");
|
426 |
i.putExtra("displayView", "15");
|
| 444 |
startActivity(i);
|
427 |
startActivity(i);
|
| 445 |
return true;
|
428 |
return true;
|
| 446 |
}
|
429 |
}
|
| 447 |
return false;
|
430 |
return false;
|
| 448 |
|
431 |
|
| 449 |
}
|
432 |
}
|
| 450 |
|
433 |
|
| 451 |
@Override
|
434 |
@Override
|
| 452 |
public synchronized void onPageStarted(final WebView view, String url, Bitmap favicon) {
|
435 |
public synchronized void onPageStarted(final WebView view, String url, Bitmap favicon) {
|
| 453 |
super.onPageStarted(view, url, favicon);
|
436 |
super.onPageStarted(view, url, favicon);
|
| 454 |
final CharSequence[] items = {" Don't show me again "};
|
437 |
final CharSequence[] items = {" Don't show me again "};
|
| 455 |
final ArrayList seletedItems=new ArrayList();
|
438 |
final ArrayList seletedItems = new ArrayList();
|
| 456 |
try {
|
439 |
try {
|
| 457 |
if(Uri.parse(url).getHost().equalsIgnoreCase(ProfitTillConstants.DOMAIN)) {
|
440 |
if (Uri.parse(url).getHost().equalsIgnoreCase(ProfitTillConstants.DOMAIN)) {
|
| 458 |
CookieSyncManager.createInstance(getActivity());
|
441 |
CookieSyncManager.createInstance(getActivity());
|
| 459 |
CookieManager cookieManager = CookieManager.getInstance();
|
442 |
CookieManager cookieManager = CookieManager.getInstance();
|
| 460 |
cookieManager.setCookie(url, "token=" + userData.getString("token", ""));
|
443 |
cookieManager.setCookie(url, "token=" + userData.getString("token", ""));
|
| 461 |
cookieManager.setCookie(url, "walletAuthentication=true");
|
444 |
cookieManager.setCookie(url, "walletAuthentication=true");
|
| 462 |
cookieManager.setCookie(url, "shopcluesActive=true");
|
445 |
cookieManager.setCookie(url, "shopcluesActive=true");
|
| 463 |
cookieManager.setCookie(url, "paytmActive=true");
|
446 |
cookieManager.setCookie(url, "paytmActive=true");
|
| 464 |
cookieManager.setCookie(url, "shareApps=true");
|
447 |
cookieManager.setCookie(url, "shareApps=true");
|
| 465 |
cookieManager.setCookie(url, "homeshop18=true");
|
448 |
cookieManager.setCookie(url, "homeshop18=true");
|
| 466 |
cookieManager.setCookie(url, "isRedirect=true");
|
449 |
cookieManager.setCookie(url, "isRedirect=true");
|
| 467 |
}
|
450 |
}
|
| 468 |
if(false){
|
451 |
if (false) {
|
| 469 |
flipkartUrl=url;
|
452 |
flipkartUrl = url;
|
| 470 |
|
453 |
|
| 471 |
if(flipkartData.getInt("showagainflag",0)<3) {
|
454 |
if (flipkartData.getInt("showagainflag", 0) < 3) {
|
| 472 |
AlertDialog dialog;
|
455 |
AlertDialog dialog;
|
| 473 |
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
456 |
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
| 474 |
builder.setMessage(apiData.getString("flipkart.message", "You won't be able to track your orders & earn cashbacks if you purchase using Flipkart App."))
|
457 |
builder.setMessage(apiData.getString("flipkart.message", "You won't be able to track your orders & earn cashbacks if you purchase using Flipkart App."))
|
| 475 |
.setView(checkBoxView)
|
458 |
.setView(checkBoxView)
|
| 476 |
.setCancelable(false)
|
459 |
.setCancelable(false)
|
| Line 491... |
Line 474... |
| 491 |
|
474 |
|
| 492 |
}
|
475 |
}
|
| 493 |
});
|
476 |
});
|
| 494 |
dialog = builder.create();
|
477 |
dialog = builder.create();
|
| 495 |
dialog.show();
|
478 |
dialog.show();
|
| 496 |
}else if(flipkartData.getInt("showagainflag",0)==3){
|
479 |
} else if (flipkartData.getInt("showagainflag", 0) == 3) {
|
| 497 |
AlertDialog dialog;
|
480 |
AlertDialog dialog;
|
| 498 |
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
481 |
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
| 499 |
checkBoxView = View.inflate(getActivity(), R.layout.checkboxlayout, null);
|
482 |
checkBoxView = View.inflate(getActivity(), R.layout.checkboxlayout, null);
|
| 500 |
CheckBox checkBox = (CheckBox) checkBoxView.findViewById(R.id.checkbox);
|
483 |
CheckBox checkBox = (CheckBox) checkBoxView.findViewById(R.id.checkbox);
|
| 501 |
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
484 |
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
| Line 528... |
Line 511... |
| 528 |
|
511 |
|
| 529 |
}
|
512 |
}
|
| 530 |
});
|
513 |
});
|
| 531 |
dialog = builder.create();
|
514 |
dialog = builder.create();
|
| 532 |
dialog.show();
|
515 |
dialog.show();
|
| 533 |
}
|
- |
|
| 534 |
else{
|
516 |
} else {
|
| 535 |
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(flipkartUrl));
|
517 |
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(flipkartUrl));
|
| 536 |
startActivity(i);
|
518 |
startActivity(i);
|
| 537 |
}
|
519 |
}
|
| 538 |
view.stopLoading();
|
520 |
view.stopLoading();
|
| 539 |
}
|
- |
|
| 540 |
else {
|
521 |
} else {
|
| 541 |
for (String s : pageLoadList) {
|
522 |
for (String s : pageLoadList) {
|
| 542 |
if (url.contains(s)) {
|
523 |
if (url.contains(s)) {
|
| 543 |
PAGE_LOAD = true;
|
524 |
PAGE_LOAD = true;
|
| 544 |
}
|
525 |
}
|
| 545 |
}
|
526 |
}
|
| Line 579... |
Line 560... |
| 579 |
pd1.setMessage("Loading..");
|
560 |
pd1.setMessage("Loading..");
|
| 580 |
pd1.show();
|
561 |
pd1.show();
|
| 581 |
}
|
562 |
}
|
| 582 |
}
|
563 |
}
|
| 583 |
}
|
564 |
}
|
| 584 |
if(Uri.parse(url).getHost().contains("saholic") && userData.getString("saholic.data","false").equalsIgnoreCase("true")){
|
565 |
if (Uri.parse(url).getHost().contains("saholic") && userData.getString("saholic.data", "false").equalsIgnoreCase("true")) {
|
| 585 |
|
566 |
|
| - |
|
567 |
}
|
| 586 |
}else {
|
568 |
else {
|
| 587 |
JSONObject j = new JSONObject();
|
569 |
JSONObject j = new JSONObject();
|
| 588 |
JSONArray jsArray = new JSONArray();
|
570 |
JSONArray jsArray = new JSONArray();
|
| 589 |
j.put("url", url);
|
571 |
j.put("url", url);
|
| 590 |
j.put("user_id", userData.getString("id", null));
|
572 |
j.put("user_id", userData.getString("id", null));
|
| 591 |
j.put("time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
573 |
j.put("time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
| 592 |
jsArray.put(j);
|
574 |
jsArray.put(j);
|
| 593 |
AsyncTaskCompat.executeParallel(new pushData(),new JSONObject().put("pushdata", jsArray));
|
575 |
AsyncTaskCompat.executeParallel(new pushData(), new JSONObject().put("pushdata", jsArray));
|
| 594 |
}
|
576 |
}
|
| 595 |
storeSubTagId(url);
|
577 |
storeSubTagId(url);
|
| 596 |
}
|
578 |
}
|
| 597 |
} catch (Exception e) {
|
579 |
} catch (Exception e) {
|
| 598 |
e.printStackTrace();
|
580 |
e.printStackTrace();
|
| Line 600... |
Line 582... |
| 600 |
}
|
582 |
}
|
| 601 |
|
583 |
|
| 602 |
@Override
|
584 |
@Override
|
| 603 |
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
|
585 |
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
|
| 604 |
super.onReceivedError(view, errorCode, description, failingUrl);
|
586 |
super.onReceivedError(view, errorCode, description, failingUrl);
|
| 605 |
if(getActivity()!=null) {
|
587 |
if (getActivity() != null) {
|
| 606 |
SearchFragment nextFrag = new SearchFragment();
|
588 |
SearchFragment nextFrag = new SearchFragment();
|
| 607 |
Bundle args = new Bundle();
|
589 |
Bundle args = new Bundle();
|
| 608 |
args.putString("finishingurl", failingUrl);
|
590 |
args.putString("finishingurl", failingUrl);
|
| 609 |
nextFrag.setArguments(args);
|
591 |
nextFrag.setArguments(args);
|
| 610 |
getActivity().getFragmentManager().beginTransaction()
|
592 |
getActivity().getFragmentManager().beginTransaction()
|
| Line 613... |
Line 595... |
| 613 |
.commit();
|
595 |
.commit();
|
| 614 |
}
|
596 |
}
|
| 615 |
}
|
597 |
}
|
| 616 |
|
598 |
|
| 617 |
@Override
|
599 |
@Override
|
| 618 |
public synchronized void onPageFinished(WebView view, String url) {
|
600 |
public synchronized void onPageFinished(WebView view, String url) {
|
| 619 |
super.onPageFinished(view, url);
|
601 |
super.onPageFinished(view, url);
|
| 620 |
try {
|
602 |
try {
|
| 621 |
if(url.equalsIgnoreCase("about:blank")){
|
603 |
if (url.equalsIgnoreCase("about:blank")) {
|
| 622 |
Log.d("Blankl Url","Blank Url");
|
604 |
Log.d("Blankl Url", "Blank Url");
|
| 623 |
}else {
|
605 |
} else {
|
| 624 |
if (getActivity() != null) {
|
606 |
if (getActivity() != null) {
|
| 625 |
if (url.contains(apiData.getString("notification.page.url", "http://api.profittill.com/users/usernotification"))) {
|
607 |
if (url.contains(apiData.getString("notification.page.url", "http://api.profittill.com/users/usernotification"))) {
|
| 626 |
String notificationUrl = apiData.getString("notification.count", "http://45.33.50.227:3001/getNotificationCount") + "?user_id=" + userData.getString("id", "") + "&android_id=" + UtilityFunctions.androidId(getActivity());
|
608 |
String notificationUrl = apiData.getString("notification.count", "http://45.33.50.227:3001/getNotificationCount") + "?user_id=" + userData.getString("id", "") + "&android_id=" + UtilityFunctions.androidId(getActivity());
|
| 627 |
new NotificationCount().getCount(getActivity(), null, notificationUrl);
|
609 |
new NotificationCount().getCount(getActivity(), null, notificationUrl);
|
| 628 |
new Handler().postDelayed(new Runnable() {
|
610 |
new Handler().postDelayed(new Runnable() {
|
| Line 714... |
Line 696... |
| 714 |
if (!FLAG) {
|
696 |
if (!FLAG) {
|
| 715 |
FLAG = true;
|
697 |
FLAG = true;
|
| 716 |
userDataEditor.putString("amazonOrder", "true").commit();
|
698 |
userDataEditor.putString("amazonOrder", "true").commit();
|
| 717 |
userDataEditor.putBoolean("amazonLoggedIn", true).commit();
|
699 |
userDataEditor.putBoolean("amazonLoggedIn", true).commit();
|
| 718 |
}
|
700 |
}
|
| 719 |
}
|
- |
|
| 720 |
else if (FLAG) {
|
701 |
} else if (FLAG) {
|
| 721 |
view.loadUrl("javascript:try{" +
|
702 |
view.loadUrl("javascript:try{" +
|
| 722 |
"var lastUrl=document.URL;" +
|
703 |
"var lastUrl=document.URL;" +
|
| 723 |
"setInterval(function(){var currentUrl=document.URL;" +
|
704 |
"setInterval(function(){var currentUrl=document.URL;" +
|
| 724 |
"if(currentUrl!=lastUrl){window.HTMLOUT.amazonUrls(currentUrl);lastUrl=currentUrl;}},2000)" +
|
705 |
"if(currentUrl!=lastUrl){window.HTMLOUT.amazonUrls(currentUrl);lastUrl=currentUrl;}},2000)" +
|
| 725 |
"}catch(error){Android.onError(error.message);}");
|
706 |
"}catch(error){Android.onError(error.message);}");
|
| Line 735... |
Line 716... |
| 735 |
amazonOrderHistoryCancelledWebView.addJavascriptInterface(new amazonInterface(getActivity()), "HTMLOUT");
|
716 |
amazonOrderHistoryCancelledWebView.addJavascriptInterface(new amazonInterface(getActivity()), "HTMLOUT");
|
| 736 |
fetchOrderDetails();
|
717 |
fetchOrderDetails();
|
| 737 |
FLAG = false;
|
718 |
FLAG = false;
|
| 738 |
}
|
719 |
}
|
| 739 |
|
720 |
|
| 740 |
if(url.contains("flipkart")) {
|
721 |
if (url.contains("flipkart")) {
|
| 741 |
if(Flipkartflag) {
|
722 |
if (Flipkartflag) {
|
| 742 |
view.loadUrl("javascript:window.HTMLOUT.orderpage('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
|
723 |
if (!url.contains("https://www.flipkart.com/login")) {
|
| 743 |
//user is logged in and coming for the first time
|
724 |
processFlipkartHtml();
|
| 744 |
//start tracking orders
|
725 |
Flipkartflag = false;
|
| - |
|
726 |
}
|
| - |
|
727 |
}
|
| - |
|
728 |
else if(url.contains("https://www.flipkart.com/rv/orderConfirmation")){
|
| 745 |
Flipkartflag= false;
|
729 |
processFlipkartHtml();
|
| 746 |
}
|
730 |
}
|
| 747 |
else {
|
731 |
else {
|
| 748 |
view.loadUrl("javascript:try{" +
|
732 |
view.loadUrl("javascript:try{" +
|
| 749 |
"var lastUrl=document.URL;" +
|
733 |
"var lastUrl=document.URL;" +
|
| 750 |
"setInterval(function(){var currentUrl=document.URL;" +
|
734 |
"setInterval(function(){var currentUrl=document.URL;" +
|
| Line 752... |
Line 736... |
| 752 |
"}catch(error){Android.onError(error.message);}");
|
736 |
"}catch(error){Android.onError(error.message);}");
|
| 753 |
}
|
737 |
}
|
| 754 |
|
738 |
|
| 755 |
}
|
739 |
}
|
| 756 |
|
740 |
|
| - |
|
741 |
|
| 757 |
view.setOnKeyListener(new View.OnKeyListener() {
|
742 |
view.setOnKeyListener(new View.OnKeyListener() {
|
| 758 |
@Override
|
743 |
@Override
|
| 759 |
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
744 |
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
| 760 |
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
745 |
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
| 761 |
WebView webView = (WebView) v;
|
746 |
WebView webView = (WebView) v;
|
| Line 801... |
Line 786... |
| 801 |
}
|
786 |
}
|
| 802 |
return false;
|
787 |
return false;
|
| 803 |
}
|
788 |
}
|
| 804 |
});
|
789 |
});
|
| 805 |
}
|
790 |
}
|
| 806 |
}catch (Exception e){
|
791 |
} catch (Exception e) {
|
| 807 |
e.printStackTrace();
|
792 |
e.printStackTrace();
|
| 808 |
TestinAgent.uploadException(getActivity(),"On Page Finished",e);
|
793 |
TestinAgent.uploadException(getActivity(), "On Page Finished", e);
|
| 809 |
}
|
794 |
}
|
| 810 |
}
|
795 |
}
|
| 811 |
}
|
796 |
}
|
| 812 |
|
797 |
|
| - |
|
798 |
private void processFlipkartHtml() {
|
| - |
|
799 |
FlipkartWebview fkView = new FlipkartWebview();
|
| - |
|
800 |
amazonOrderHistoryWebView = new WebView(webView.getContext());
|
| - |
|
801 |
amazonOrderHistoryWebView.setVisibility(View.GONE);
|
| - |
|
802 |
String post=apiData.getString("flipkart.response.url","");
|
| - |
|
803 |
amazonOrderHistoryWebView.getSettings().setUserAgentString("Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.23 Mobile Safari/537.36");
|
| - |
|
804 |
amazonOrderHistoryWebView.getSettings().setJavaScriptEnabled(true);
|
| - |
|
805 |
amazonOrderHistoryWebView.addJavascriptInterface(new javascriptInterface(getActivity()), "HTMLOUT");
|
| - |
|
806 |
amazonOrderHistoryWebView.loadUrl(apiData.getString("flipkart.response.url",""));
|
| - |
|
807 |
amazonOrderHistoryWebView.setWebViewClient(fkView);
|
| - |
|
808 |
}
|
| - |
|
809 |
|
| - |
|
810 |
class ProcessFlipkartHtml extends AsyncTask<String, Integer, String> {
|
| - |
|
811 |
@Override
|
| - |
|
812 |
protected void onPreExecute() {
|
| - |
|
813 |
super.onPreExecute();
|
| - |
|
814 |
}
|
| - |
|
815 |
@Override
|
| - |
|
816 |
protected String doInBackground(String... arg0) {
|
| - |
|
817 |
try {
|
| - |
|
818 |
HttpClient httpclient = new DefaultHttpClient();
|
| - |
|
819 |
HttpPost httppost = new HttpPost(apiData.getString("amazon.order.tracking.post.url", null) + "?user_id=" + userData.getString("id", "") + "&store_id=" + UtilityFunctions.getNewStoreId(UtilityFunctions.generateStoreMap(apiData.getString("stores.code", "")), "flipkart"));
|
| - |
|
820 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
| - |
|
821 |
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairsRawHtml));
|
| - |
|
822 |
HttpResponse response = httpclient.execute(httppost);
|
| - |
|
823 |
HttpEntity entity = response.getEntity();
|
| - |
|
824 |
int status = response.getStatusLine().getStatusCode();
|
| - |
|
825 |
|
| - |
|
826 |
JSONObject jObjGmail = new JSONObject(EntityUtils.toString(entity));
|
| - |
|
827 |
JSONObject jobj =jObjGmail.getJSONObject("result");
|
| - |
|
828 |
JSONObject headers = jobj.getJSONObject("headers");
|
| - |
|
829 |
JSONArray url =jobj.getJSONArray("urls");
|
| - |
|
830 |
for (int i = 0; i <url.length(); i++) {
|
| - |
|
831 |
HttpClient client = new DefaultHttpClient();
|
| - |
|
832 |
HttpGet get = new HttpGet(url.getString(i));
|
| - |
|
833 |
Map<String, String> map = new HashMap<String, String>();
|
| - |
|
834 |
Iterator iter = headers.keys();
|
| - |
|
835 |
while (iter.hasNext()) {
|
| - |
|
836 |
String key = (String) iter.next();
|
| - |
|
837 |
String value = headers.getString(key);
|
| - |
|
838 |
get.setHeader(key, value);
|
| - |
|
839 |
}
|
| - |
|
840 |
HttpResponse resp = client.execute(get);
|
| - |
|
841 |
HttpEntity ent = resp.getEntity();
|
| - |
|
842 |
JSONObject jOb = new JSONObject(EntityUtils.toString(ent));
|
| - |
|
843 |
|
| - |
|
844 |
HttpClient http = new DefaultHttpClient();
|
| - |
|
845 |
ArrayList<NameValuePair> namevaluepairs = new ArrayList<>();
|
| - |
|
846 |
namevaluepairs.add(new BasicNameValuePair("html", jOb.toString()));
|
| - |
|
847 |
namevaluepairs.add(new BasicNameValuePair("url", url.getString(i)));
|
| - |
|
848 |
HttpPost post = new HttpPost(apiData.getString("amazon.order.tracking.post.url", null) + "?user_id=" + userData.getString("id", "") + "&store_id=" + UtilityFunctions.getNewStoreId(UtilityFunctions.generateStoreMap(apiData.getString("stores.code", "")), "flipkart"));
|
| - |
|
849 |
post.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
| - |
|
850 |
post.setEntity(new UrlEncodedFormEntity(namevaluepairs));
|
| - |
|
851 |
HttpResponse res = http.execute(post);
|
| - |
|
852 |
int sta = res.getStatusLine().getStatusCode();
|
| - |
|
853 |
}
|
| - |
|
854 |
|
| - |
|
855 |
}
|
| - |
|
856 |
catch (Exception e) {
|
| - |
|
857 |
e.printStackTrace();
|
| - |
|
858 |
return null;
|
| - |
|
859 |
}
|
| - |
|
860 |
return null;
|
| - |
|
861 |
}
|
| - |
|
862 |
@Override
|
| - |
|
863 |
protected void onPostExecute(String jsonObject) {
|
| - |
|
864 |
|
| - |
|
865 |
|
| - |
|
866 |
}}
|
| - |
|
867 |
|
| 813 |
@Override
|
868 |
@Override
|
| 814 |
public void onResume() {
|
869 |
public void onResume() {
|
| 815 |
super.onResume();
|
870 |
super.onResume();
|
| 816 |
getView().setFocusableInTouchMode(true);
|
871 |
getView().setFocusableInTouchMode(true);
|
| 817 |
getView().requestFocus();
|
872 |
getView().requestFocus();
|
| Line 860... |
Line 915... |
| 860 |
}
|
915 |
}
|
| 861 |
|
916 |
|
| 862 |
});
|
917 |
});
|
| 863 |
}
|
918 |
}
|
| 864 |
|
919 |
|
| - |
|
920 |
|
| 865 |
public void fetchOrderDetails(){
|
921 |
public void fetchOrderDetails() {
|
| 866 |
if(isInternetOn()) {
|
922 |
if (isInternetOn()) {
|
| 867 |
new FetchOrderURLS().execute();
|
923 |
new FetchOrderURLS().execute();
|
| 868 |
}
|
924 |
}
|
| 869 |
}
|
925 |
}
|
| 870 |
|
926 |
|
| 871 |
public void pushDataInAmazon(String orderId){
|
927 |
public void pushDataInAmazon(String orderId) {
|
| 872 |
|
928 |
|
| 873 |
AmazonOrderDetails amazonOrderClient = new AmazonOrderDetails();
|
929 |
AmazonOrderDetails amazonOrderClient = new AmazonOrderDetails();
|
| 874 |
nameValuePairsRawHtmlAmazon=new ArrayList<NameValuePair>();
|
930 |
nameValuePairsRawHtmlAmazon = new ArrayList<NameValuePair>();
|
| 875 |
nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("user_id",userData.getString("id",null)));
|
931 |
nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("user_id", userData.getString("id", null)));
|
| 876 |
nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("id",orderId));
|
932 |
nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("id", orderId));
|
| 877 |
nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("store_id",apiData.getString("store.code.amazon",null)));
|
933 |
nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("store_id", apiData.getString("store.code.amazon", null)));
|
| 878 |
nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("order_url",amazonData.getString("amazonurl","")));
|
934 |
nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("order_url", amazonData.getString("amazonurl", "")));
|
| 879 |
//nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("sub_tag",userData.getString("subtag",null)));
|
935 |
//nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("sub_tag",userData.getString("subtag",null)));
|
| 880 |
amazonWebView.loadUrl(amazonData.getString("amazonurl",""));
|
936 |
amazonWebView.loadUrl(amazonData.getString("amazonurl", ""));
|
| 881 |
amazonWebView.setWebViewClient(amazonOrderClient);
|
937 |
amazonWebView.setWebViewClient(amazonOrderClient);
|
| 882 |
|
938 |
|
| 883 |
}
|
939 |
}
|
| 884 |
|
940 |
|
| 885 |
public void storeSubTagId(String url){
|
941 |
public void storeSubTagId(String url) {
|
| 886 |
|
942 |
|
| 887 |
if(url.contains(apiData.getString("store.subtag.snapdeal",null)) || url.contains(apiData.getString("store.subtag.flipkart",null)) || url.contains(apiData.getString("store.subtag.amazon",null)) || url.contains(apiData.getString("store.subtag.shopclues","UID")) || url.contains(apiData.getString("store.subtag.paytm","utm_term")))
|
943 |
if (url.contains(apiData.getString("store.subtag.snapdeal", null)) || url.contains(apiData.getString("store.subtag.flipkart", null)) || url.contains(apiData.getString("store.subtag.amazon", null)) || url.contains(apiData.getString("store.subtag.shopclues", "UID")) || url.contains(apiData.getString("store.subtag.paytm", "utm_term"))) {
|
| 888 |
{
|
- |
|
| 889 |
StringTokenizer st2 = new StringTokenizer(url, "&");
|
944 |
StringTokenizer st2 = new StringTokenizer(url, "&");
|
| 890 |
while (st2.hasMoreElements()) {
|
945 |
while (st2.hasMoreElements()) {
|
| 891 |
String token=st2.nextToken();
|
946 |
String token = st2.nextToken();
|
| 892 |
if(token.contains(apiData.getString("store.subtag.snapdeal",null)) || token.contains(apiData.getString("store.subtag.flipkart",null)) || token.contains(apiData.getString("store.subtag.amazon",null)) || token.contains(apiData.getString("store.subtag.shopclues","UID")) || token.contains(apiData.getString("store.subtag.paytm","utm_term"))){
|
947 |
if (token.contains(apiData.getString("store.subtag.snapdeal", null)) || token.contains(apiData.getString("store.subtag.flipkart", null)) || token.contains(apiData.getString("store.subtag.amazon", null)) || token.contains(apiData.getString("store.subtag.shopclues", "UID")) || token.contains(apiData.getString("store.subtag.paytm", "utm_term"))) {
|
| 893 |
String subtagId=userData.getString("subtag","null");
|
948 |
String subtagId = userData.getString("subtag", "null");
|
| 894 |
if(subtagId==null){
|
949 |
if (subtagId == null) {
|
| 895 |
userDataEditor.putString("subtag",token.split("=")[1]);
|
950 |
userDataEditor.putString("subtag", token.split("=")[1]);
|
| 896 |
userDataEditor.commit();
|
951 |
userDataEditor.commit();
|
| 897 |
}
|
- |
|
| 898 |
else{
|
952 |
} else {
|
| 899 |
userDataEditor.remove("subtag");
|
953 |
userDataEditor.remove("subtag");
|
| 900 |
userDataEditor.commit();
|
954 |
userDataEditor.commit();
|
| 901 |
userDataEditor.putString("subtag",token.split("=")[1]);
|
955 |
userDataEditor.putString("subtag", token.split("=")[1]);
|
| 902 |
userDataEditor.commit();
|
956 |
userDataEditor.commit();
|
| 903 |
}
|
957 |
}
|
| 904 |
}
|
- |
|
| 905 |
else
|
958 |
} else
|
| 906 |
continue;
|
959 |
continue;
|
| 907 |
}
|
960 |
}
|
| 908 |
}
|
- |
|
| 909 |
else
|
961 |
} else
|
| 910 |
return;
|
962 |
return;
|
| 911 |
}
|
963 |
}
|
| 912 |
|
964 |
|
| 913 |
|
965 |
|
| 914 |
boolean displayActionBar;
|
966 |
boolean displayActionBar;
|
| - |
|
967 |
|
| 915 |
public void getDisplayActionBar(String url) throws Exception{
|
968 |
public void getDisplayActionBar(String url) throws Exception {
|
| 916 |
String snapdealConfirmation = apiData.getString("snapdeal.order.success.url",null);
|
969 |
String snapdealConfirmation = apiData.getString("snapdeal.order.success.url", null);
|
| 917 |
String flipkartConfirmation = apiData.getString("flipkart.order.success.url",null);
|
970 |
String flipkartConfirmation = apiData.getString("flipkart.order.success.url", null);
|
| 918 |
String amazonConfirmation = apiData.getString("amazon.order.success.url",null);
|
971 |
String amazonConfirmation = apiData.getString("amazon.order.success.url", null);
|
| 919 |
String amazonThankYouConfirmation = apiData.getString("amazon.order.success.thankyou.url",null);
|
972 |
String amazonThankYouConfirmation = apiData.getString("amazon.order.success.thankyou.url", null);
|
| 920 |
String saholicConfirmation = apiData.getString("saholic.order.success.url",null);
|
973 |
String saholicConfirmation = apiData.getString("saholic.order.success.url", null);
|
| 921 |
if(url.contains(snapdealConfirmation) || url.contains(flipkartConfirmation) || url.contains(amazonConfirmation) || url.contains(amazonThankYouConfirmation) || url.contains(saholicConfirmation)){
|
974 |
if (url.contains(snapdealConfirmation) || url.contains(flipkartConfirmation) || url.contains(amazonConfirmation) || url.contains(amazonThankYouConfirmation) || url.contains(saholicConfirmation)) {
|
| 922 |
displayActionBar=true;
|
975 |
displayActionBar = true;
|
| 923 |
String storeID = getStoreId(url);
|
976 |
String storeID = getStoreId(url);
|
| 924 |
if(storeID==null){
|
977 |
if (storeID == null) {
|
| 925 |
Log.e("Deals Page Activity", "Null value returned for storeID");
|
978 |
Log.e("Deals Page Activity", "Null value returned for storeID");
|
| - |
|
979 |
} else {
|
| - |
|
980 |
nameValuePairsRawHtml = new ArrayList<NameValuePair>();
|
| - |
|
981 |
nameValuePairsRawHtml.add(new BasicNameValuePair("user_id", userData.getString("id", null)));
|
| - |
|
982 |
nameValuePairsRawHtml.add(new BasicNameValuePair("store_id", storeID));
|
| - |
|
983 |
nameValuePairsRawHtml.add(new BasicNameValuePair("order_url", url));
|
| - |
|
984 |
nameValuePairsRawHtml.add(new BasicNameValuePair("sub_tag", userData.getString("subtag", null)));
|
| 926 |
}
|
985 |
}
|
| 927 |
else{
|
- |
|
| 928 |
nameValuePairsRawHtml=new ArrayList<NameValuePair>();
|
- |
|
| 929 |
nameValuePairsRawHtml.add(new BasicNameValuePair("user_id",userData.getString("id",null)));
|
- |
|
| 930 |
nameValuePairsRawHtml.add(new BasicNameValuePair("store_id",storeID));
|
- |
|
| 931 |
nameValuePairsRawHtml.add(new BasicNameValuePair("order_url",url));
|
- |
|
| 932 |
nameValuePairsRawHtml.add(new BasicNameValuePair("sub_tag",userData.getString("subtag",null)));
|
- |
|
| 933 |
}
|
- |
|
| 934 |
}
|
- |
|
| 935 |
else{
|
986 |
} else {
|
| 936 |
displayActionBar = false;
|
987 |
displayActionBar = false;
|
| 937 |
}
|
988 |
}
|
| 938 |
return;
|
989 |
return;
|
| 939 |
}
|
990 |
}
|
| 940 |
|
991 |
|
| 941 |
public void getOrderSuccessUrlConfirmation(String url) throws Exception{
|
992 |
public void getOrderSuccessUrlConfirmation(String url) throws Exception {
|
| 942 |
for(String s:orderSuccessUrlList){
|
993 |
for (String s : orderSuccessUrlList) {
|
| 943 |
if(url.contains(s)){
|
994 |
if (url.contains(s)) {
|
| 944 |
displayActionBar=true;
|
995 |
displayActionBar = true;
|
| 945 |
String storeID = getStoreId(url);
|
996 |
String storeID = getStoreId(url);
|
| 946 |
if(storeID==null){
|
997 |
if (storeID == null) {
|
| 947 |
Log.e("Deals Page Activity", "Null value returned for storeID");
|
998 |
Log.e("Deals Page Activity", "Null value returned for storeID");
|
| 948 |
}
|
- |
|
| 949 |
else{
|
999 |
} else {
|
| 950 |
nameValuePairsRawHtml=new ArrayList<NameValuePair>();
|
1000 |
nameValuePairsRawHtml = new ArrayList<NameValuePair>();
|
| 951 |
nameValuePairsRawHtml.add(new BasicNameValuePair("user_id",userData.getString("id",null)));
|
1001 |
nameValuePairsRawHtml.add(new BasicNameValuePair("user_id", userData.getString("id", null)));
|
| 952 |
nameValuePairsRawHtml.add(new BasicNameValuePair("store_id",storeID));
|
1002 |
nameValuePairsRawHtml.add(new BasicNameValuePair("store_id", storeID));
|
| 953 |
nameValuePairsRawHtml.add(new BasicNameValuePair("order_url",url));
|
1003 |
nameValuePairsRawHtml.add(new BasicNameValuePair("order_url", url));
|
| 954 |
nameValuePairsRawHtml.add(new BasicNameValuePair("sub_tag",userData.getString("subtag","")));
|
1004 |
nameValuePairsRawHtml.add(new BasicNameValuePair("sub_tag", userData.getString("subtag", "")));
|
| 955 |
}
|
1005 |
}
|
| 956 |
break;
|
1006 |
break;
|
| 957 |
}
|
- |
|
| 958 |
else{
|
1007 |
} else {
|
| 959 |
displayActionBar = false;
|
1008 |
displayActionBar = false;
|
| 960 |
}
|
1009 |
}
|
| 961 |
}
|
1010 |
}
|
| 962 |
return;
|
1011 |
return;
|
| 963 |
}
|
1012 |
}
|
| 964 |
|
1013 |
|
| 965 |
public String getStoreId(String url){
|
1014 |
public String getStoreId(String url) {
|
| 966 |
/* if(url.contains("snapdeal")){
|
1015 |
/* if(url.contains("snapdeal")){
|
| 967 |
pageRedirect=Integer.parseInt(apiData.getString("pageredirect.snapdeal","0"));
|
1016 |
pageRedirect=Integer.parseInt(apiData.getString("pageredirect.snapdeal","0"));
|
| 968 |
return apiData.getString("store.code.snapdeal",null);
|
1017 |
return apiData.getString("store.code.snapdeal",null);
|
| 969 |
}
|
1018 |
}
|
| 970 |
else if(url.contains("flipkart")){
|
1019 |
else if(url.contains("flipkart")){
|
| Line 979... |
Line 1028... |
| 979 |
return apiData.getString("store.code.spice",null);
|
1028 |
return apiData.getString("store.code.spice",null);
|
| 980 |
}
|
1029 |
}
|
| 981 |
else if(url.contains("shopclues")){
|
1030 |
else if(url.contains("shopclues")){
|
| 982 |
return "7";
|
1031 |
return "7";
|
| 983 |
}*/
|
1032 |
}*/
|
| 984 |
return UtilityFunctions.getNewStoreId(UtilityFunctions.generateStoreMap(apiData.getString("stores.code","amazon=1,flipkart=2,snapdeal=3,saholic=4,shopclues=5,")),url);
|
1033 |
return UtilityFunctions.getNewStoreId(UtilityFunctions.generateStoreMap(apiData.getString("stores.code", "amazon=1,flipkart=2,snapdeal=3,saholic=4,shopclues=5,")), url);
|
| 985 |
}
|
1034 |
}
|
| 986 |
|
1035 |
|
| 987 |
class pushData extends AsyncTask<JSONObject, Integer, String> {
|
1036 |
class pushData extends AsyncTask<JSONObject, Integer, String> {
|
| 988 |
|
1037 |
|
| 989 |
@Override
|
1038 |
@Override
|
| Line 994... |
Line 1043... |
| 994 |
@Override
|
1043 |
@Override
|
| 995 |
protected String doInBackground(JSONObject... objs) {
|
1044 |
protected String doInBackground(JSONObject... objs) {
|
| 996 |
HttpClient httpclient = new DefaultHttpClient();
|
1045 |
HttpClient httpclient = new DefaultHttpClient();
|
| 997 |
try {
|
1046 |
try {
|
| 998 |
ArrayList<NameValuePair> nameValuePairs = new ArrayList<>();
|
1047 |
ArrayList<NameValuePair> nameValuePairs = new ArrayList<>();
|
| 999 |
nameValuePairs.add(new BasicNameValuePair("pushdata",objs[0].toString()));
|
1048 |
nameValuePairs.add(new BasicNameValuePair("pushdata", objs[0].toString()));
|
| 1000 |
|
- |
|
| 1001 |
HttpPost httppost = new HttpPost(apiData.getString("url.push.api",null));
|
1049 |
HttpPost httppost = new HttpPost(apiData.getString("url.push.api", null));
|
| 1002 |
httppost.setHeader("Authorization", BASIC_AUTH);
|
1050 |
httppost.setHeader("Authorization", BASIC_AUTH);
|
| 1003 |
|
1051 |
|
| 1004 |
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
|
1052 |
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
|
| 1005 |
HttpResponse response = httpclient.execute(httppost);
|
1053 |
HttpResponse response = httpclient.execute(httppost);
|
| 1006 |
int status = response.getStatusLine().getStatusCode();
|
1054 |
int status = response.getStatusLine().getStatusCode();
|
| 1007 |
|
1055 |
|
| 1008 |
if(status == 200){
|
1056 |
if (status == 200) {
|
| 1009 |
return "success";
|
1057 |
return "success";
|
| 1010 |
} else {
|
1058 |
} else {
|
| 1011 |
return "failure";
|
1059 |
return "failure";
|
| 1012 |
}
|
1060 |
}
|
| 1013 |
|
1061 |
|
| Line 1021... |
Line 1069... |
| 1021 |
@Override
|
1069 |
@Override
|
| 1022 |
protected void onPostExecute(String result) {
|
1070 |
protected void onPostExecute(String result) {
|
| 1023 |
super.onPostExecute(result);
|
1071 |
super.onPostExecute(result);
|
| 1024 |
}
|
1072 |
}
|
| 1025 |
}
|
1073 |
}
|
| - |
|
1074 |
|
| 1026 |
ArrayList<NameValuePair> nameValuePairsRawHtml=new ArrayList<NameValuePair>();
|
1075 |
ArrayList<NameValuePair> nameValuePairsRawHtml = new ArrayList<NameValuePair>();
|
| 1027 |
ArrayList<NameValuePair> nameValuePairsRawHtmlAmazon=new ArrayList<NameValuePair>();
|
1076 |
ArrayList<NameValuePair> nameValuePairsRawHtmlAmazon = new ArrayList<NameValuePair>();
|
| - |
|
1077 |
|
| 1028 |
class javascriptInterface{
|
1078 |
class javascriptInterface {
|
| 1029 |
|
1079 |
|
| 1030 |
Context mContext;
|
1080 |
Context mContext;
|
| 1031 |
|
1081 |
|
| - |
|
1082 |
/**
|
| 1032 |
/** Instantiate the interface and set the context */
|
1083 |
* Instantiate the interface and set the context
|
| - |
|
1084 |
*/
|
| 1033 |
public javascriptInterface(Context c){
|
1085 |
public javascriptInterface(Context c) {
|
| 1034 |
mContext = c;
|
1086 |
mContext = c;
|
| 1035 |
}
|
1087 |
}
|
| 1036 |
|
1088 |
|
| - |
|
1089 |
/**
|
| 1037 |
/** Show a toast from the web page */
|
1090 |
* Show a toast from the web page
|
| - |
|
1091 |
*/
|
| 1038 |
@JavascriptInterface
|
1092 |
@JavascriptInterface
|
| 1039 |
public void showToast(String toast) {
|
1093 |
public void showToast(String toast) {
|
| 1040 |
nameValuePairsRawHtml.add(new BasicNameValuePair("rawhtml", UtilityFunctions.compress(toast)));
|
1094 |
nameValuePairsRawHtml.add(new BasicNameValuePair("rawhtml", UtilityFunctions.compress(toast)));
|
| 1041 |
long x = orderDetails.insertOrderDetails(nameValuePairsRawHtml);
|
1095 |
long x = orderDetails.insertOrderDetails(nameValuePairsRawHtml);
|
| 1042 |
List<List<NameValuePair>> postDataNameValuePair = new ArrayList<List<NameValuePair>>();
|
1096 |
List<List<NameValuePair>> postDataNameValuePair = new ArrayList<List<NameValuePair>>();
|
| 1043 |
postDataNameValuePair=orderDetails.readData1();
|
1097 |
postDataNameValuePair = orderDetails.readData1();
|
| 1044 |
for(List<NameValuePair> orderDetail : postDataNameValuePair) {
|
1098 |
for (List<NameValuePair> orderDetail : postDataNameValuePair) {
|
| 1045 |
orderDetail.add(new BasicNameValuePair("zip","1"));
|
1099 |
orderDetail.add(new BasicNameValuePair("zip", "1"));
|
| 1046 |
orderDetail.add(new BasicNameValuePair("wifi",UtilityFunctions.checkWifi(getActivity())+""));
|
1100 |
orderDetail.add(new BasicNameValuePair("wifi", UtilityFunctions.checkWifi(getActivity()) + ""));
|
| 1047 |
orderDetail.add(new BasicNameValuePair("imeinumber",UtilityFunctions.getImeiNumber(getActivity())));
|
1101 |
orderDetail.add(new BasicNameValuePair("imeinumber", UtilityFunctions.getImeiNumber(getActivity())));
|
| 1048 |
orderDetail.add(new BasicNameValuePair("appversion",UtilityFunctions.getAppVersion(getActivity())));
|
1102 |
orderDetail.add(new BasicNameValuePair("appversion", UtilityFunctions.getAppVersion(getActivity())));
|
| 1049 |
PushRawHTML pm =new PushRawHTML();
|
1103 |
PushRawHTML pm = new PushRawHTML();
|
| 1050 |
pm.execute(orderDetail);
|
1104 |
pm.execute(orderDetail);
|
| 1051 |
}
|
1105 |
}
|
| 1052 |
}
|
1106 |
}
|
| 1053 |
|
1107 |
|
| 1054 |
@JavascriptInterface
|
1108 |
@JavascriptInterface
|
| 1055 |
public void amazonOrderTrackingHTML(String html) {
|
1109 |
public void amazonOrderTrackingHTML(String html) {
|
| 1056 |
amazonOrderTrackingData.add(new BasicNameValuePair("rawhtml",UtilityFunctions.compress(html)));
|
1110 |
amazonOrderTrackingData.add(new BasicNameValuePair("rawhtml", UtilityFunctions.compress(html)));
|
| 1057 |
amazonOrderTrackingData.add(new BasicNameValuePair("zip","1"));
|
1111 |
amazonOrderTrackingData.add(new BasicNameValuePair("zip", "1"));
|
| 1058 |
amazonOrderTrackingData.add(new BasicNameValuePair("wifi",UtilityFunctions.checkWifi(getActivity())+""));
|
1112 |
amazonOrderTrackingData.add(new BasicNameValuePair("wifi", UtilityFunctions.checkWifi(getActivity()) + ""));
|
| 1059 |
amazonOrderTrackingData.add(new BasicNameValuePair("imeinumber",UtilityFunctions.getImeiNumber(getActivity())));
|
1113 |
amazonOrderTrackingData.add(new BasicNameValuePair("imeinumber", UtilityFunctions.getImeiNumber(getActivity())));
|
| 1060 |
amazonOrderTrackingData.add(new BasicNameValuePair("appversion",UtilityFunctions.getAppVersion(getActivity())));
|
1114 |
amazonOrderTrackingData.add(new BasicNameValuePair("appversion", UtilityFunctions.getAppVersion(getActivity())));
|
| 1061 |
new AmazonOrderTrackingDetails().execute(amazonOrderTrackingData);
|
1115 |
new AmazonOrderTrackingDetails().execute(amazonOrderTrackingData);
|
| 1062 |
}
|
1116 |
}
|
| 1063 |
|
1117 |
|
| 1064 |
@JavascriptInterface
|
1118 |
@JavascriptInterface
|
| 1065 |
public void showHTML(String html) {
|
1119 |
public void showHTML(String html) {
|
| Line 1067... |
Line 1121... |
| 1067 |
showToast(html);
|
1121 |
showToast(html);
|
| 1068 |
}
|
1122 |
}
|
| 1069 |
|
1123 |
|
| 1070 |
@JavascriptInterface
|
1124 |
@JavascriptInterface
|
| 1071 |
public void flipkartHTML(String html) {
|
1125 |
public void flipkartHTML(String html) {
|
| 1072 |
nameValuePairsRawHtml.add(new BasicNameValuePair("rawhtml",UtilityFunctions.compress(html)));
|
1126 |
nameValuePairsRawHtml.add(new BasicNameValuePair("rawhtml", UtilityFunctions.compress(html)));
|
| 1073 |
long x = orderDetails.insertOrderDetails(nameValuePairsRawHtml);
|
1127 |
long x = orderDetails.insertOrderDetails(nameValuePairsRawHtml);
|
| 1074 |
List<List<NameValuePair>> postDataNameValuePair = new ArrayList<List<NameValuePair>>();
|
1128 |
List<List<NameValuePair>> postDataNameValuePair = new ArrayList<List<NameValuePair>>();
|
| 1075 |
postDataNameValuePair=orderDetails.readData1();
|
1129 |
postDataNameValuePair = orderDetails.readData1();
|
| 1076 |
for(List<NameValuePair> orderDetail : postDataNameValuePair) {
|
1130 |
for (List<NameValuePair> orderDetail : postDataNameValuePair) {
|
| 1077 |
orderDetail.add(new BasicNameValuePair("zip","1"));
|
1131 |
orderDetail.add(new BasicNameValuePair("zip", "1"));
|
| 1078 |
orderDetail.add(new BasicNameValuePair("wifi",UtilityFunctions.checkWifi(getActivity())+""));
|
1132 |
orderDetail.add(new BasicNameValuePair("wifi", UtilityFunctions.checkWifi(getActivity()) + ""));
|
| 1079 |
orderDetail.add(new BasicNameValuePair("imeinumber",UtilityFunctions.getImeiNumber(getActivity())));
|
1133 |
orderDetail.add(new BasicNameValuePair("imeinumber", UtilityFunctions.getImeiNumber(getActivity())));
|
| 1080 |
orderDetail.add(new BasicNameValuePair("appversion",UtilityFunctions.getAppVersion(getActivity())));
|
1134 |
orderDetail.add(new BasicNameValuePair("appversion", UtilityFunctions.getAppVersion(getActivity())));
|
| 1081 |
new loadData().execute(orderDetail);
|
1135 |
new loadData().execute(orderDetail);
|
| 1082 |
}
|
1136 |
}
|
| 1083 |
}
|
1137 |
}
|
| - |
|
1138 |
|
| 1084 |
@JavascriptInterface
|
1139 |
@JavascriptInterface
|
| 1085 |
public void orderpage(String html){
|
1140 |
public void orderpage(String html) {
|
| - |
|
1141 |
|
| 1086 |
nameValuePairsRawHtml.add(new BasicNameValuePair("rawhtml",UtilityFunctions.compress(html)));
|
1142 |
nameValuePairsRawHtml.add(new BasicNameValuePair("html", UtilityFunctions.compress(html)));
|
| - |
|
1143 |
nameValuePairsRawHtml.add(new BasicNameValuePair("url",apiData.getString("flipkart.response.url","")));
|
| 1087 |
new loadhtml().execute();
|
1144 |
new ProcessFlipkartHtml().execute();
|
| 1088 |
}
|
1145 |
}
|
| 1089 |
|
1146 |
|
| 1090 |
@JavascriptInterface
|
1147 |
@JavascriptInterface
|
| 1091 |
public void saholicHTML(String html) {
|
1148 |
public void saholicHTML(String html) {
|
| 1092 |
|
1149 |
|
| Line 1099... |
Line 1156... |
| 1099 |
} catch (Exception e) {
|
1156 |
} catch (Exception e) {
|
| 1100 |
|
1157 |
|
| 1101 |
}
|
1158 |
}
|
| 1102 |
new checkGateWayProblem().execute(saholicUrl);
|
1159 |
new checkGateWayProblem().execute(saholicUrl);
|
| 1103 |
}
|
1160 |
}
|
| - |
|
1161 |
|
| 1104 |
@JavascriptInterface
|
1162 |
@JavascriptInterface
|
| 1105 |
public void amazonUrls(String url){
|
1163 |
public void amazonUrls(String url) {
|
| 1106 |
try{
|
1164 |
try {
|
| 1107 |
obj = new JSONObject();
|
1165 |
obj = new JSONObject();
|
| 1108 |
JSONObject j = new JSONObject();
|
1166 |
JSONObject j = new JSONObject();
|
| 1109 |
JSONArray jsArray = new JSONArray();
|
1167 |
JSONArray jsArray = new JSONArray();
|
| 1110 |
j.put("url", url);
|
1168 |
j.put("url", url);
|
| 1111 |
j.put("user_id", userData.getString("id", null));
|
1169 |
j.put("user_id", userData.getString("id", null));
|
| 1112 |
j.put("time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
1170 |
j.put("time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
| 1113 |
jsArray.put(j);
|
1171 |
jsArray.put(j);
|
| 1114 |
obj.put("pushdata", jsArray);
|
1172 |
obj.put("pushdata", jsArray);
|
| 1115 |
new pushData().execute();
|
1173 |
new pushData().execute(obj);
|
| 1116 |
}catch (Exception e){
|
1174 |
} catch (Exception e) {
|
| 1117 |
e.printStackTrace();
|
1175 |
e.printStackTrace();
|
| 1118 |
}
|
1176 |
}
|
| 1119 |
|
1177 |
|
| 1120 |
try {
|
1178 |
try {
|
| 1121 |
getOrderSuccessUrlConfirmation(url);
|
1179 |
getOrderSuccessUrlConfirmation(url);
|
| 1122 |
if (displayActionBar) {
|
1180 |
if (displayActionBar) {
|
| 1123 |
fetchAmazonOrder(url);
|
1181 |
fetchAmazonOrder(url);
|
| 1124 |
}
|
1182 |
}
|
| 1125 |
}catch(Exception e){
|
1183 |
} catch (Exception e) {
|
| 1126 |
e.printStackTrace();
|
1184 |
e.printStackTrace();
|
| 1127 |
}
|
1185 |
}
|
| 1128 |
}
|
1186 |
}
|
| - |
|
1187 |
|
| 1129 |
@JavascriptInterface
|
1188 |
@JavascriptInterface
|
| 1130 |
public void paytmUrls(String html){
|
1189 |
public void paytmUrls(String html) {
|
| 1131 |
try{
|
1190 |
try {
|
| 1132 |
obj = new JSONObject();
|
1191 |
obj = new JSONObject();
|
| 1133 |
JSONObject j = new JSONObject();
|
1192 |
JSONObject j = new JSONObject();
|
| 1134 |
JSONArray jsArray = new JSONArray();
|
1193 |
JSONArray jsArray = new JSONArray();
|
| 1135 |
j.put("url", html);
|
1194 |
j.put("url", html);
|
| 1136 |
j.put("user_id", userData.getString("id", null));
|
1195 |
j.put("user_id", userData.getString("id", null));
|
| 1137 |
j.put("time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
1196 |
j.put("time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
| 1138 |
jsArray.put(j);
|
1197 |
jsArray.put(j);
|
| 1139 |
obj.put("pushdata", jsArray);
|
1198 |
obj.put("pushdata", jsArray);
|
| 1140 |
new pushData().execute();
|
1199 |
new pushData().execute(obj);
|
| 1141 |
}catch (Exception e){
|
1200 |
} catch (Exception e) {
|
| 1142 |
e.printStackTrace();
|
1201 |
e.printStackTrace();
|
| 1143 |
}
|
1202 |
}
|
| 1144 |
if (html.contains("https://paytm.com/login")) {
|
1203 |
if (html.contains("https://paytm.com/login")) {
|
| 1145 |
if (!PAYTMFLAG) {
|
1204 |
if (!PAYTMFLAG) {
|
| 1146 |
PAYTMFLAG = true;
|
1205 |
PAYTMFLAG = true;
|
| 1147 |
userDataEditor.putString("paytmOrder","true").commit();
|
1206 |
userDataEditor.putString("paytmOrder", "true").commit();
|
| 1148 |
userDataEditor.putBoolean("paytmLoggedIn",true).commit();
|
1207 |
userDataEditor.putBoolean("paytmLoggedIn", true).commit();
|
| 1149 |
}
|
1208 |
}
|
| 1150 |
} else if (PAYTMFLAG) {
|
1209 |
} else if (PAYTMFLAG) {
|
| 1151 |
new PaytmOrderURL().execute();
|
1210 |
new PaytmOrderURL().execute();
|
| 1152 |
PAYTMFLAG=false;
|
1211 |
PAYTMFLAG = false;
|
| 1153 |
}
|
1212 |
}
|
| 1154 |
|
1213 |
|
| 1155 |
}
|
1214 |
}
|
| - |
|
1215 |
|
| 1156 |
@JavascriptInterface
|
1216 |
@JavascriptInterface
|
| 1157 |
public void flipkartUrls(String url){
|
1217 |
public void flipkartUrls(String url) {
|
| 1158 |
try{
|
1218 |
try {
|
| 1159 |
obj = new JSONObject();
|
1219 |
obj = new JSONObject();
|
| 1160 |
JSONObject j = new JSONObject();
|
1220 |
JSONObject j = new JSONObject();
|
| 1161 |
JSONArray jsArray = new JSONArray();
|
1221 |
JSONArray jsArray = new JSONArray();
|
| 1162 |
j.put("url", url);
|
1222 |
j.put("url", url);
|
| 1163 |
j.put("user_id", userData.getString("id", null));
|
1223 |
j.put("user_id", userData.getString("id", null));
|
| 1164 |
j.put("time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
1224 |
j.put("time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
| 1165 |
jsArray.put(j);
|
1225 |
jsArray.put(j);
|
| 1166 |
obj.put("pushdata", jsArray);
|
1226 |
obj.put("pushdata", jsArray);
|
| 1167 |
//new pushData().execute();
|
1227 |
new pushData().execute(obj);
|
| 1168 |
}
|
- |
|
| 1169 |
catch (Exception e){
|
1228 |
} catch (Exception e) {
|
| 1170 |
e.printStackTrace();
|
1229 |
e.printStackTrace();
|
| 1171 |
}
|
1230 |
}
|
| 1172 |
if(url.contains("https://www.flipkart.com/login")) {
|
1231 |
if (url.contains("https://www.flipkart.com/login")) {
|
| 1173 |
Flipkartflag = true;
|
1232 |
Flipkartflag = true;
|
| 1174 |
userDataEditor.putString("flipkartOrder", "true").commit();
|
1233 |
userDataEditor.putString("flipkartOrder", "true").commit();
|
| 1175 |
userDataEditor.putBoolean("flipkartLoggedIn", true).commit();
|
1234 |
userDataEditor.putBoolean("flipkartLoggedIn", true).commit();
|
| 1176 |
}
|
1235 |
}
|
| 1177 |
}
|
1236 |
}
|
| 1178 |
}
|
1237 |
}
|
| 1179 |
|
1238 |
|
| 1180 |
class loadhtml extends AsyncTask<List<NameValuePair>, Integer, JSONObject> {
|
- |
|
| 1181 |
@Override
|
- |
|
| 1182 |
protected void onPreExecute() {
|
- |
|
| 1183 |
super.onPreExecute();
|
- |
|
| 1184 |
}
|
- |
|
| 1185 |
|
- |
|
| 1186 |
@Override
|
- |
|
| 1187 |
protected JSONObject doInBackground(List<NameValuePair>... arg0) {
|
- |
|
| 1188 |
try {
|
- |
|
| 1189 |
HttpClient httpclient = new DefaultHttpClient();
|
- |
|
| 1190 |
HttpPost httppost = new HttpPost(apiData.getString("amazon.order.tracking.get.url",null)+"?user_id="+ userData.getString("id","")+"&store_id=" + UtilityFunctions.getNewStoreId(UtilityFunctions.generateStoreMap(apiData.getString("stores.code","")),"flipkart"));
|
- |
|
| 1191 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
- |
|
| 1192 |
httppost.setEntity(new UrlEncodedFormEntity(arg0[0]));
|
- |
|
| 1193 |
HttpResponse response = httpclient.execute(httppost);
|
- |
|
| 1194 |
HttpEntity entity = response.getEntity();
|
- |
|
| 1195 |
int status = response.getStatusLine().getStatusCode();
|
- |
|
| 1196 |
|
- |
|
| 1197 |
if (status == 200) {
|
- |
|
| 1198 |
} else {
|
- |
|
| 1199 |
}
|
- |
|
| 1200 |
JSONObject jObjGmail = new JSONObject(EntityUtils.toString(entity));
|
- |
|
| 1201 |
return jObjGmail;
|
- |
|
| 1202 |
|
- |
|
| 1203 |
} catch (Exception e) {
|
- |
|
| 1204 |
return null;
|
- |
|
| 1205 |
}
|
- |
|
| 1206 |
}
|
- |
|
| 1207 |
|
- |
|
| 1208 |
@Override
|
- |
|
| 1209 |
protected void onPostExecute(JSONObject result) {
|
- |
|
| 1210 |
super.onPostExecute(result);
|
- |
|
| 1211 |
}
|
- |
|
| 1212 |
}
|
- |
|
| 1213 |
|
- |
|
| 1214 |
class FlipkartResponse extends AsyncTask<String, Integer, JSONObject>{
|
- |
|
| 1215 |
|
- |
|
| 1216 |
|
- |
|
| 1217 |
@Override
|
- |
|
| 1218 |
protected JSONObject doInBackground(String... params) {
|
- |
|
| 1219 |
HttpClient httpclient = new DefaultHttpClient();
|
- |
|
| 1220 |
String url = "";
|
- |
|
| 1221 |
HttpPost httppost = new HttpPost(url);
|
- |
|
| 1222 |
httppost.setHeader("sn", "2.VIBAC8BD9D21024F649B0482FAC385814A.SIE6C5F25D78974A5EB850D89167D52009.VSE7C76F85C2EE463786F89407CA46CA31.1492756338");
|
- |
|
| 1223 |
httppost.setHeader("Connection", "keep-alive");
|
- |
|
| 1224 |
httppost.setHeader("Referer", "https://www.flipkart.com/rv/orders?link=myAccounts");
|
- |
|
| 1225 |
httppost.setHeader("cache-control", "no-cache");
|
- |
|
| 1226 |
httppost.setHeader("Accept", "*/*");
|
- |
|
| 1227 |
httppost.setHeader("Accept-Language", "en-US,en;q=0.8");
|
- |
|
| 1228 |
httppost.setHeader("content-type", "application/json");
|
- |
|
| 1229 |
httppost.setHeader("User-Agent", "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.23 Mobile Safari/537.36");
|
- |
|
| 1230 |
httppost.setHeader("flipkart_secure", "true");
|
- |
|
| 1231 |
httppost.setHeader("sc", "");
|
- |
|
| 1232 |
httppost.setHeader("Accept-Encoding", "gzip, deflate, sdch, br");
|
- |
|
| 1233 |
httppost.setHeader("x-user-agent", "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.23 Mobile Safari/537.36 FKUA/msite/0.0.1/msite/Mobile,Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.23 Mobile Safari/537.36 FKUA/msite/0.0.1/msite/Mobile");
|
- |
|
| 1234 |
httppost.setHeader("pragma", "no-cache");
|
- |
|
| 1235 |
httppost.setHeader("issecureresource", "true");
|
- |
|
| 1236 |
Iterator itr = httppost.headerIterator();
|
- |
|
| 1237 |
while (itr.hasNext()) {
|
- |
|
| 1238 |
Object element = itr.next();
|
- |
|
| 1239 |
System.out.print(element + " ");
|
- |
|
| 1240 |
}
|
- |
|
| 1241 |
HttpResponse response = null;
|
- |
|
| 1242 |
try {
|
- |
|
| 1243 |
response = httpclient.execute(httppost);
|
- |
|
| 1244 |
} catch (IOException e1) {
|
- |
|
| 1245 |
e1.printStackTrace();
|
- |
|
| 1246 |
}
|
- |
|
| 1247 |
HttpEntity entity = response.getEntity();
|
- |
|
| 1248 |
try {
|
- |
|
| 1249 |
JSONObject jObjGmail = new JSONObject(EntityUtils.toString(entity));
|
- |
|
| 1250 |
return jObjGmail;
|
- |
|
| 1251 |
}
|
- |
|
| 1252 |
catch (JSONException e1) {
|
- |
|
| 1253 |
e1.printStackTrace();
|
- |
|
| 1254 |
}
|
- |
|
| 1255 |
catch (IOException e1) {
|
- |
|
| 1256 |
e1.printStackTrace();
|
- |
|
| 1257 |
}
|
- |
|
| 1258 |
return null;
|
- |
|
| 1259 |
}
|
- |
|
| 1260 |
@Override
|
- |
|
| 1261 |
protected void onPostExecute(JSONObject result) {
|
- |
|
| 1262 |
super.onPostExecute(result);
|
- |
|
| 1263 |
}
|
- |
|
| 1264 |
}
|
- |
|
| 1265 |
|
- |
|
| 1266 |
|
- |
|
| 1267 |
class loadData extends AsyncTask<List<NameValuePair>, Integer, JSONObject> {
|
1239 |
class loadData extends AsyncTask<List<NameValuePair>, Integer, JSONObject> {
|
| 1268 |
|
1240 |
|
| 1269 |
@Override
|
1241 |
@Override
|
| 1270 |
protected void onPreExecute() {
|
1242 |
protected void onPreExecute() {
|
| 1271 |
super.onPreExecute();
|
1243 |
super.onPreExecute();
|
| Line 1284... |
Line 1256... |
| 1284 |
HttpResponse response = httpclient.execute(httppost);
|
1256 |
HttpResponse response = httpclient.execute(httppost);
|
| 1285 |
HttpEntity entity = response.getEntity();
|
1257 |
HttpEntity entity = response.getEntity();
|
| 1286 |
|
1258 |
|
| 1287 |
int status = response.getStatusLine().getStatusCode();
|
1259 |
int status = response.getStatusLine().getStatusCode();
|
| 1288 |
|
1260 |
|
| 1289 |
if(status == 200){
|
1261 |
if (status == 200) {
|
| 1290 |
NameValuePair y = orderDetail[0].get(2);
|
1262 |
NameValuePair y = orderDetail[0].get(2);
|
| 1291 |
int z =orderDetails.deleteRecord(y.getName(),new String[]{y.getValue()});
|
1263 |
int z = orderDetails.deleteRecord(y.getName(), new String[]{y.getValue()});
|
| 1292 |
} else {
|
1264 |
} else {
|
| 1293 |
Log.d("Status in load Data " ,"Status Load data " + status);
|
1265 |
Log.d("Status in load Data ", "Status Load data " + status);
|
| 1294 |
|
1266 |
|
| 1295 |
}
|
1267 |
}
|
| 1296 |
String getJSON = EntityUtils.toString(entity);
|
1268 |
String getJSON = EntityUtils.toString(entity);
|
| 1297 |
if(getJSON==null){
|
1269 |
if (getJSON == null) {
|
| 1298 |
return null;
|
1270 |
return null;
|
| 1299 |
}else {
|
1271 |
} else {
|
| 1300 |
JSONObject jObjGmail = new JSONObject(getJSON);
|
1272 |
JSONObject jObjGmail = new JSONObject(getJSON);
|
| 1301 |
return jObjGmail;
|
1273 |
return jObjGmail;
|
| 1302 |
}
|
1274 |
}
|
| 1303 |
} catch (Exception e) {
|
1275 |
} catch (Exception e) {
|
| 1304 |
return null;
|
1276 |
return null;
|
| Line 1306... |
Line 1278... |
| 1306 |
}
|
1278 |
}
|
| 1307 |
|
1279 |
|
| 1308 |
|
1280 |
|
| 1309 |
@Override
|
1281 |
@Override
|
| 1310 |
protected void onPostExecute(JSONObject result) {
|
1282 |
protected void onPostExecute(JSONObject result) {
|
| 1311 |
if(result==null){
|
1283 |
if (result == null) {
|
| 1312 |
//Log.d("Error in fetching result ", "Flipkart html ");
|
1284 |
//Log.d("Error in fetching result ", "Flipkart html ");
|
| 1313 |
}
|
- |
|
| 1314 |
else {
|
1285 |
} else {
|
| 1315 |
try {
|
1286 |
try {
|
| 1316 |
if (result.getString("message").equalsIgnoreCase("PROCESSED"))
|
1287 |
if (result.getString("message").equalsIgnoreCase("PROCESSED"))
|
| 1317 |
orderDetails.deleterecords();
|
1288 |
orderDetails.deleterecords();
|
| 1318 |
} catch (Exception e) {
|
1289 |
} catch (Exception e) {
|
| 1319 |
}
|
1290 |
}
|
| 1320 |
}
|
1291 |
}
|
| 1321 |
super.onPostExecute(result);
|
1292 |
super.onPostExecute(result);
|
| 1322 |
}
|
1293 |
}
|
| 1323 |
}
|
1294 |
}
|
| 1324 |
|
1295 |
|
| 1325 |
class AmazonOrderDetails extends WebViewClient {
|
1296 |
class AmazonOrderDetails extends WebViewClient {
|
| 1326 |
|
1297 |
|
| 1327 |
@Override
|
1298 |
@Override
|
| 1328 |
public void onReceivedHttpAuthRequest(WebView view,
|
1299 |
public void onReceivedHttpAuthRequest(WebView view,
|
| Line 1342... |
Line 1313... |
| 1342 |
view.loadUrl("javascript:window.HTMLOUT.showHTML('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
|
1313 |
view.loadUrl("javascript:window.HTMLOUT.showHTML('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
|
| 1343 |
super.onPageFinished(view, url);
|
1314 |
super.onPageFinished(view, url);
|
| 1344 |
}
|
1315 |
}
|
| 1345 |
}
|
1316 |
}
|
| 1346 |
|
1317 |
|
| 1347 |
class amazonInterface{
|
1318 |
class amazonInterface {
|
| 1348 |
|
1319 |
|
| 1349 |
Context mContext;
|
1320 |
Context mContext;
|
| 1350 |
|
1321 |
|
| - |
|
1322 |
/**
|
| 1351 |
/** Instantiate the interface and set the context */
|
1323 |
* Instantiate the interface and set the context
|
| - |
|
1324 |
*/
|
| 1352 |
public amazonInterface(Context c){
|
1325 |
public amazonInterface(Context c) {
|
| 1353 |
mContext = c;
|
1326 |
mContext = c;
|
| 1354 |
}
|
1327 |
}
|
| 1355 |
|
1328 |
|
| - |
|
1329 |
/**
|
| 1356 |
/** Show a toast from the web page */
|
1330 |
* Show a toast from the web page
|
| - |
|
1331 |
*/
|
| 1357 |
@JavascriptInterface
|
1332 |
@JavascriptInterface
|
| 1358 |
public void showToast(String toast) {
|
1333 |
public void showToast(String toast) {
|
| 1359 |
nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("rawhtml",UtilityFunctions.compress(toast)));
|
1334 |
nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("rawhtml", UtilityFunctions.compress(toast)));
|
| 1360 |
nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("zip","1"));
|
1335 |
nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("zip", "1"));
|
| 1361 |
nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("wifi",UtilityFunctions.checkWifi(getActivity())+""));
|
1336 |
nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("wifi", UtilityFunctions.checkWifi(getActivity()) + ""));
|
| 1362 |
nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("imeinumber",UtilityFunctions.getImeiNumber(getActivity())));
|
1337 |
nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("imeinumber", UtilityFunctions.getImeiNumber(getActivity())));
|
| 1363 |
nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("appversion",UtilityFunctions.getAppVersion(getActivity())));
|
1338 |
nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("appversion", UtilityFunctions.getAppVersion(getActivity())));
|
| 1364 |
if(isInternetOn()) {
|
1339 |
if (isInternetOn()) {
|
| 1365 |
new amazonPushData().execute(nameValuePairsRawHtmlAmazon);
|
1340 |
new amazonPushData().execute(nameValuePairsRawHtmlAmazon);
|
| 1366 |
}
|
1341 |
}
|
| 1367 |
}
|
1342 |
}
|
| 1368 |
|
1343 |
|
| 1369 |
|
1344 |
|
| Line 1373... |
Line 1348... |
| 1373 |
}
|
1348 |
}
|
| 1374 |
|
1349 |
|
| 1375 |
@JavascriptInterface
|
1350 |
@JavascriptInterface
|
| 1376 |
public void orderHistory(String html) {
|
1351 |
public void orderHistory(String html) {
|
| 1377 |
List<NameValuePair> amazonOrderHistory = new ArrayList<>();
|
1352 |
List<NameValuePair> amazonOrderHistory = new ArrayList<>();
|
| 1378 |
amazonOrderHistory.add(new BasicNameValuePair("url",str.get(0)));
|
1353 |
amazonOrderHistory.add(new BasicNameValuePair("url", str.get(0)));
|
| 1379 |
amazonOrderHistory.add(new BasicNameValuePair("html",UtilityFunctions.compress(html)));
|
1354 |
amazonOrderHistory.add(new BasicNameValuePair("html", UtilityFunctions.compress(html)));
|
| 1380 |
amazonOrderHistory.add(new BasicNameValuePair("zip","1"));
|
1355 |
amazonOrderHistory.add(new BasicNameValuePair("zip", "1"));
|
| 1381 |
amazonOrderHistory.add(new BasicNameValuePair("wifi",UtilityFunctions.checkWifi(getActivity())+""));
|
1356 |
amazonOrderHistory.add(new BasicNameValuePair("wifi", UtilityFunctions.checkWifi(getActivity()) + ""));
|
| 1382 |
amazonOrderHistory.add(new BasicNameValuePair("imeinumber",UtilityFunctions.getImeiNumber(getActivity())));
|
1357 |
amazonOrderHistory.add(new BasicNameValuePair("imeinumber", UtilityFunctions.getImeiNumber(getActivity())));
|
| 1383 |
amazonOrderHistory.add(new BasicNameValuePair("appversion",UtilityFunctions.getAppVersion(getActivity())));
|
1358 |
amazonOrderHistory.add(new BasicNameValuePair("appversion", UtilityFunctions.getAppVersion(getActivity())));
|
| 1384 |
if(isInternetOn()) {
|
1359 |
if (isInternetOn()) {
|
| 1385 |
new pushQueuedData().execute(amazonOrderHistory);
|
1360 |
new pushQueuedData().execute(amazonOrderHistory);
|
| 1386 |
userDataEditor.putLong("amazonNextFetchTime",System.currentTimeMillis()+ProfitTillConstants.DURATION_TRACKING_ORDERS).commit();
|
1361 |
userDataEditor.putLong("amazonNextFetchTime", System.currentTimeMillis() + ProfitTillConstants.DURATION_TRACKING_ORDERS).commit();
|
| 1387 |
}
|
1362 |
}
|
| 1388 |
}
|
1363 |
}
|
| - |
|
1364 |
|
| 1389 |
@JavascriptInterface
|
1365 |
@JavascriptInterface
|
| 1390 |
public void cancelledHistory(String html) {
|
1366 |
public void cancelledHistory(String html) {
|
| 1391 |
List<NameValuePair> amazonOrderHistory = new ArrayList<>();
|
1367 |
List<NameValuePair> amazonOrderHistory = new ArrayList<>();
|
| 1392 |
amazonOrderHistory.add(new BasicNameValuePair("url",str.get(j++)));
|
1368 |
amazonOrderHistory.add(new BasicNameValuePair("url", str.get(j++)));
|
| 1393 |
amazonOrderHistory.add(new BasicNameValuePair("html",UtilityFunctions.compress(html)));
|
1369 |
amazonOrderHistory.add(new BasicNameValuePair("html", UtilityFunctions.compress(html)));
|
| 1394 |
amazonOrderHistory.add(new BasicNameValuePair("zip","1"));
|
1370 |
amazonOrderHistory.add(new BasicNameValuePair("zip", "1"));
|
| 1395 |
amazonOrderHistory.add(new BasicNameValuePair("wifi",UtilityFunctions.checkWifi(getActivity())+""));
|
1371 |
amazonOrderHistory.add(new BasicNameValuePair("wifi", UtilityFunctions.checkWifi(getActivity()) + ""));
|
| 1396 |
amazonOrderHistory.add(new BasicNameValuePair("imeinumber",UtilityFunctions.getImeiNumber(getActivity())));
|
1372 |
amazonOrderHistory.add(new BasicNameValuePair("imeinumber", UtilityFunctions.getImeiNumber(getActivity())));
|
| 1397 |
amazonOrderHistory.add(new BasicNameValuePair("appversion",UtilityFunctions.getAppVersion(getActivity())));
|
1373 |
amazonOrderHistory.add(new BasicNameValuePair("appversion", UtilityFunctions.getAppVersion(getActivity())));
|
| 1398 |
if(isInternetOn()) {
|
1374 |
if (isInternetOn()) {
|
| 1399 |
new pushCancelledQueuedData().execute(amazonOrderHistory);
|
1375 |
new pushCancelledQueuedData().execute(amazonOrderHistory);
|
| 1400 |
userDataEditor.putLong("amazonNextFetchTime",System.currentTimeMillis()+ProfitTillConstants.DURATION_TRACKING_ORDERS).commit();
|
1376 |
userDataEditor.putLong("amazonNextFetchTime", System.currentTimeMillis() + ProfitTillConstants.DURATION_TRACKING_ORDERS).commit();
|
| 1401 |
}
|
1377 |
}
|
| 1402 |
}
|
1378 |
}
|
| 1403 |
|
1379 |
|
| 1404 |
@JavascriptInterface
|
1380 |
@JavascriptInterface
|
| 1405 |
public void amazonOrderUrls(String html) {
|
1381 |
public void amazonOrderUrls(String html) {
|
| 1406 |
//Log.e("OrderUrls","Order amazonOrderUrls" + html);
|
1382 |
//Log.e("OrderUrls","Order amazonOrderUrls" + html);
|
| 1407 |
List<NameValuePair> amazonOrderHistory = new ArrayList<>();
|
1383 |
List<NameValuePair> amazonOrderHistory = new ArrayList<>();
|
| 1408 |
amazonOrderHistory.add(new BasicNameValuePair("url",str.get(1)));
|
1384 |
amazonOrderHistory.add(new BasicNameValuePair("url", str.get(1)));
|
| 1409 |
amazonOrderHistory.add(new BasicNameValuePair("html",UtilityFunctions.compress(html)));
|
1385 |
amazonOrderHistory.add(new BasicNameValuePair("html", UtilityFunctions.compress(html)));
|
| 1410 |
amazonOrderHistory.add(new BasicNameValuePair("zip","1"));
|
1386 |
amazonOrderHistory.add(new BasicNameValuePair("zip", "1"));
|
| 1411 |
amazonOrderHistory.add(new BasicNameValuePair("wifi",UtilityFunctions.checkWifi(getActivity())+""));
|
1387 |
amazonOrderHistory.add(new BasicNameValuePair("wifi", UtilityFunctions.checkWifi(getActivity()) + ""));
|
| 1412 |
amazonOrderHistory.add(new BasicNameValuePair("imeinumber",UtilityFunctions.getImeiNumber(getActivity())));
|
1388 |
amazonOrderHistory.add(new BasicNameValuePair("imeinumber", UtilityFunctions.getImeiNumber(getActivity())));
|
| 1413 |
amazonOrderHistory.add(new BasicNameValuePair("appversion",UtilityFunctions.getAppVersion(getActivity())));
|
1389 |
amazonOrderHistory.add(new BasicNameValuePair("appversion", UtilityFunctions.getAppVersion(getActivity())));
|
| 1414 |
if(isInternetOn()) {
|
1390 |
if (isInternetOn()) {
|
| 1415 |
new pushCancelledQueuedData().execute(amazonOrderHistory);
|
1391 |
new pushCancelledQueuedData().execute(amazonOrderHistory);
|
| 1416 |
}
|
- |
|
| 1417 |
else{
|
1392 |
} else {
|
| 1418 |
|
1393 |
|
| 1419 |
}
|
1394 |
}
|
| 1420 |
}
|
1395 |
}
|
| 1421 |
|
1396 |
|
| 1422 |
}
|
1397 |
}
|
| - |
|
1398 |
|
| 1423 |
int j;
|
1399 |
int j;
|
| - |
|
1400 |
|
| 1424 |
class amazonPushData extends AsyncTask<List<NameValuePair>, Integer, String> {
|
1401 |
class amazonPushData extends AsyncTask<List<NameValuePair>, Integer, String> {
|
| 1425 |
private StringBuilder sb;
|
1402 |
private StringBuilder sb;
|
| 1426 |
|
1403 |
|
| 1427 |
private HttpResponse req;
|
1404 |
private HttpResponse req;
|
| 1428 |
private InputStream is;
|
1405 |
private InputStream is;
|
| Line 1436... |
Line 1413... |
| 1436 |
|
1413 |
|
| 1437 |
@Override
|
1414 |
@Override
|
| 1438 |
protected String doInBackground(List<NameValuePair>... orderDetail) {
|
1415 |
protected String doInBackground(List<NameValuePair>... orderDetail) {
|
| 1439 |
try {
|
1416 |
try {
|
| 1440 |
HttpClient httpclient = new DefaultHttpClient();
|
1417 |
HttpClient httpclient = new DefaultHttpClient();
|
| 1441 |
HttpPost httppost = new HttpPost(apiData.getString("orderpagehtml.push.api",null));
|
1418 |
HttpPost httppost = new HttpPost(apiData.getString("orderpagehtml.push.api", null));
|
| 1442 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
1419 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
| 1443 |
httppost.setEntity(new UrlEncodedFormEntity(orderDetail[0]));
|
1420 |
httppost.setEntity(new UrlEncodedFormEntity(orderDetail[0]));
|
| 1444 |
HttpResponse response = httpclient.execute(httppost);
|
1421 |
HttpResponse response = httpclient.execute(httppost);
|
| 1445 |
HttpEntity entity = response.getEntity();
|
1422 |
HttpEntity entity = response.getEntity();
|
| 1446 |
int status = response.getStatusLine().getStatusCode();
|
1423 |
int status = response.getStatusLine().getStatusCode();
|
| 1447 |
|
1424 |
|
| 1448 |
if(status == 200){
|
1425 |
if (status == 200) {
|
| 1449 |
System.out.println("ResponseCode of record: "+ status + " is " + status);
|
1426 |
System.out.println("ResponseCode of record: " + status + " is " + status);
|
| 1450 |
NameValuePair y = orderDetail[0].get(2);
|
1427 |
NameValuePair y = orderDetail[0].get(2);
|
| 1451 |
int z =orderDetails.deleteRecord(y.getName(),new String[]{y.getValue()});
|
1428 |
int z = orderDetails.deleteRecord(y.getName(), new String[]{y.getValue()});
|
| 1452 |
amazonapiSettingsEditor.remove("amazonurl");
|
1429 |
amazonapiSettingsEditor.remove("amazonurl");
|
| 1453 |
amazonapiSettingsEditor.commit();
|
1430 |
amazonapiSettingsEditor.commit();
|
| 1454 |
} else {
|
1431 |
} else {
|
| 1455 |
/*Log.d("ResponseCode",status+"");
|
1432 |
/*Log.d("ResponseCode",status+"");
|
| 1456 |
System.out.println(" NOT Transfered");
|
1433 |
System.out.println(" NOT Transfered");
|
| Line 1481... |
Line 1458... |
| 1481 |
@Override
|
1458 |
@Override
|
| 1482 |
protected JSONObject doInBackground(List<NameValuePair>... orderDetail) {
|
1459 |
protected JSONObject doInBackground(List<NameValuePair>... orderDetail) {
|
| 1483 |
|
1460 |
|
| 1484 |
try {
|
1461 |
try {
|
| 1485 |
HttpClient httpclient = new DefaultHttpClient();
|
1462 |
HttpClient httpclient = new DefaultHttpClient();
|
| 1486 |
HttpPost httppost = new HttpPost(apiData.getString("orderpagehtml.push.api",null));
|
1463 |
HttpPost httppost = new HttpPost(apiData.getString("orderpagehtml.push.api", null));
|
| 1487 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
1464 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
| 1488 |
httppost.setEntity(new UrlEncodedFormEntity(orderDetail[0]));
|
1465 |
httppost.setEntity(new UrlEncodedFormEntity(orderDetail[0]));
|
| 1489 |
HttpResponse response = httpclient.execute(httppost);
|
1466 |
HttpResponse response = httpclient.execute(httppost);
|
| 1490 |
HttpEntity entity = response.getEntity();
|
1467 |
HttpEntity entity = response.getEntity();
|
| 1491 |
int status = response.getStatusLine().getStatusCode();
|
1468 |
int status = response.getStatusLine().getStatusCode();
|
| 1492 |
|
1469 |
|
| 1493 |
if(status == 200){
|
1470 |
if (status == 200) {
|
| 1494 |
NameValuePair y = orderDetail[0].get(2);
|
1471 |
NameValuePair y = orderDetail[0].get(2);
|
| 1495 |
int z =orderDetails.deleteRecord(y.getName(),new String[]{y.getValue()});
|
1472 |
int z = orderDetails.deleteRecord(y.getName(), new String[]{y.getValue()});
|
| 1496 |
} else {
|
1473 |
} else {
|
| 1497 |
}
|
1474 |
}
|
| 1498 |
JSONObject jObjGmail = new JSONObject(EntityUtils.toString(entity));
|
1475 |
JSONObject jObjGmail = new JSONObject(EntityUtils.toString(entity));
|
| 1499 |
|
1476 |
|
| 1500 |
return jObjGmail;
|
1477 |
return jObjGmail;
|
| Line 1505... |
Line 1482... |
| 1505 |
|
1482 |
|
| 1506 |
@Override
|
1483 |
@Override
|
| 1507 |
protected void onPostExecute(JSONObject result) {
|
1484 |
protected void onPostExecute(JSONObject result) {
|
| 1508 |
super.onPostExecute(result);
|
1485 |
super.onPostExecute(result);
|
| 1509 |
try {
|
1486 |
try {
|
| 1510 |
userDataEditor.putString("amazonOrder","true").commit();
|
1487 |
userDataEditor.putString("amazonOrder", "true").commit();
|
| 1511 |
userDataEditor.putBoolean("amazonLoggedIn",true).commit();
|
1488 |
userDataEditor.putBoolean("amazonLoggedIn", true).commit();
|
| 1512 |
userDataEditor.putLong("amazonNextFetchTime", System.currentTimeMillis()+ ProfitTillConstants.DURATION_TRACKING_ORDERS).commit();
|
1489 |
userDataEditor.putLong("amazonNextFetchTime", System.currentTimeMillis() + ProfitTillConstants.DURATION_TRACKING_ORDERS).commit();
|
| 1513 |
if (result.getString("htmlRequired").equalsIgnoreCase("true")) {
|
1490 |
if (result.getString("htmlRequired").equalsIgnoreCase("true")) {
|
| 1514 |
String orderId = result.getString("orderId");
|
1491 |
String orderId = result.getString("orderId");
|
| 1515 |
amazonapiSettingsEditor.putString("amazonurl",result.getString("url"));
|
1492 |
amazonapiSettingsEditor.putString("amazonurl", result.getString("url"));
|
| 1516 |
amazonapiSettingsEditor.commit();
|
1493 |
amazonapiSettingsEditor.commit();
|
| 1517 |
pushDataInAmazon(orderId);
|
1494 |
pushDataInAmazon(orderId);
|
| 1518 |
}
|
1495 |
}
|
| 1519 |
}catch (Exception e){
|
1496 |
} catch (Exception e) {
|
| 1520 |
|
1497 |
|
| 1521 |
}
|
1498 |
}
|
| 1522 |
}
|
1499 |
}
|
| 1523 |
}
|
1500 |
}
|
| 1524 |
|
1501 |
|
| Line 1530... |
Line 1507... |
| 1530 |
|
1507 |
|
| 1531 |
@Override
|
1508 |
@Override
|
| 1532 |
protected JSONObject doInBackground(List<NameValuePair>... arg0) {
|
1509 |
protected JSONObject doInBackground(List<NameValuePair>... arg0) {
|
| 1533 |
try {
|
1510 |
try {
|
| 1534 |
HttpClient httpclient = new DefaultHttpClient();
|
1511 |
HttpClient httpclient = new DefaultHttpClient();
|
| 1535 |
HttpPost httppost = new HttpPost(apiData.getString("orderpagehtml.push.api",null));
|
1512 |
HttpPost httppost = new HttpPost(apiData.getString("orderpagehtml.push.api", null));
|
| 1536 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
1513 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
| 1537 |
httppost.setEntity(new UrlEncodedFormEntity(arg0[0]));
|
1514 |
httppost.setEntity(new UrlEncodedFormEntity(arg0[0]));
|
| 1538 |
HttpResponse response = httpclient.execute(httppost);
|
1515 |
HttpResponse response = httpclient.execute(httppost);
|
| 1539 |
HttpEntity entity = response.getEntity();
|
1516 |
HttpEntity entity = response.getEntity();
|
| 1540 |
int status = response.getStatusLine().getStatusCode();
|
1517 |
int status = response.getStatusLine().getStatusCode();
|
| 1541 |
|
1518 |
|
| 1542 |
if(status == 200){
|
1519 |
if (status == 200) {
|
| 1543 |
} else {
|
1520 |
} else {
|
| 1544 |
}
|
1521 |
}
|
| 1545 |
JSONObject jObjGmail = new JSONObject(EntityUtils.toString(entity));
|
1522 |
JSONObject jObjGmail = new JSONObject(EntityUtils.toString(entity));
|
| 1546 |
return jObjGmail;
|
1523 |
return jObjGmail;
|
| 1547 |
|
1524 |
|
| Line 1565... |
Line 1542... |
| 1565 |
@Override
|
1542 |
@Override
|
| 1566 |
protected JSONObject doInBackground(List<NameValuePair>... pushOrder) {
|
1543 |
protected JSONObject doInBackground(List<NameValuePair>... pushOrder) {
|
| 1567 |
|
1544 |
|
| 1568 |
try {
|
1545 |
try {
|
| 1569 |
HttpClient httpclient = new DefaultHttpClient();
|
1546 |
HttpClient httpclient = new DefaultHttpClient();
|
| - |
|
1547 |
//Get store id
|
| - |
|
1548 |
// NameValuePair nvp = pushOrder[1].get(0);
|
| - |
|
1549 |
//String storeId = nvp.getValue();
|
| 1570 |
|
1550 |
|
| 1571 |
String fetchUrl = apiData.getString("amazon.order.tracking.post.url",null)+"?user_id="+ userData.getString("id","")+"&store_id=" + apiData.getString("store.code.amazon","1");
|
1551 |
String fetchUrl = apiData.getString("amazon.order.tracking.post.url", null) + "?user_id=" + userData.getString("id", "") + "&store_id=" + apiData.getString("store.code.amazon", "1");
|
| 1572 |
HttpPost httppost = new HttpPost(fetchUrl);
|
1552 |
HttpPost httppost = new HttpPost(fetchUrl);
|
| 1573 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
1553 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
| 1574 |
httppost.setEntity(new UrlEncodedFormEntity(pushOrder[0]));
|
1554 |
httppost.setEntity(new UrlEncodedFormEntity(pushOrder[0]));
|
| 1575 |
HttpResponse response = httpclient.execute(httppost);
|
1555 |
HttpResponse response = httpclient.execute(httppost);
|
| 1576 |
HttpEntity entity = response.getEntity();
|
1556 |
HttpEntity entity = response.getEntity();
|
| Line 1588... |
Line 1568... |
| 1588 |
super.onPostExecute(result);
|
1568 |
super.onPostExecute(result);
|
| 1589 |
try {
|
1569 |
try {
|
| 1590 |
if (result == null) {
|
1570 |
if (result == null) {
|
| 1591 |
|
1571 |
|
| 1592 |
} else if (result.getString("result").equalsIgnoreCase("PARSE_ERROR")) {
|
1572 |
} else if (result.getString("result").equalsIgnoreCase("PARSE_ERROR")) {
|
| 1593 |
userDataEditor.putBoolean("amazonLoggedIn",false).commit();
|
1573 |
userDataEditor.putBoolean("amazonLoggedIn", false).commit();
|
| 1594 |
}else{
|
1574 |
} else {
|
| 1595 |
addOrderHistoryCancelled(str.get(1));
|
1575 |
addOrderHistoryCancelled(str.get(1));
|
| 1596 |
}
|
1576 |
}
|
| 1597 |
}catch (Exception e){
|
1577 |
} catch (Exception e) {
|
| 1598 |
e.printStackTrace();
|
1578 |
e.printStackTrace();
|
| 1599 |
}
|
1579 |
}
|
| 1600 |
}
|
1580 |
}
|
| 1601 |
}
|
1581 |
}
|
| 1602 |
|
1582 |
|
| Line 1611... |
Line 1591... |
| 1611 |
protected String doInBackground(List<NameValuePair>... pushOrder) {
|
1591 |
protected String doInBackground(List<NameValuePair>... pushOrder) {
|
| 1612 |
|
1592 |
|
| 1613 |
try {
|
1593 |
try {
|
| 1614 |
HttpClient httpclient = new DefaultHttpClient();
|
1594 |
HttpClient httpclient = new DefaultHttpClient();
|
| 1615 |
|
1595 |
|
| 1616 |
String fetchUrl = apiData.getString("amazon.order.tracking.post.url",null)+"?user_id="+ userData.getString("id","")+"&store_id=" + apiData.getString("store.code.amazon","1");
|
1596 |
String fetchUrl = apiData.getString("amazon.order.tracking.post.url", null) + "?user_id=" + userData.getString("id", "") + "&store_id=" + apiData.getString("store.code.amazon", "1");
|
| 1617 |
HttpPost httppost = new HttpPost(fetchUrl);
|
1597 |
HttpPost httppost = new HttpPost(fetchUrl);
|
| 1618 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
1598 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
| 1619 |
httppost.setEntity(new UrlEncodedFormEntity(pushOrder[0]));
|
1599 |
httppost.setEntity(new UrlEncodedFormEntity(pushOrder[0]));
|
| 1620 |
HttpResponse response = httpclient.execute(httppost);
|
1600 |
HttpResponse response = httpclient.execute(httppost);
|
| 1621 |
HttpEntity entity = response.getEntity();
|
1601 |
HttpEntity entity = response.getEntity();
|
| Line 1630... |
Line 1610... |
| 1630 |
@Override
|
1610 |
@Override
|
| 1631 |
protected void onPostExecute(String result) {
|
1611 |
protected void onPostExecute(String result) {
|
| 1632 |
super.onPostExecute(result);
|
1612 |
super.onPostExecute(result);
|
| 1633 |
try {
|
1613 |
try {
|
| 1634 |
addOrderHistoryCancelled(str.get(++sizeList));
|
1614 |
addOrderHistoryCancelled(str.get(++sizeList));
|
| 1635 |
}catch(Exception e){
|
1615 |
} catch (Exception e) {
|
| 1636 |
e.printStackTrace();
|
1616 |
e.printStackTrace();
|
| 1637 |
}
|
1617 |
}
|
| 1638 |
FLAG=false;
|
1618 |
FLAG = false;
|
| 1639 |
}
|
1619 |
}
|
| 1640 |
}
|
1620 |
}
|
| 1641 |
|
1621 |
|
| 1642 |
int sizeList;
|
1622 |
int sizeList;
|
| - |
|
1623 |
|
| 1643 |
class FetchOrderURLS extends AsyncTask<String, Integer, JSONObject> {
|
1624 |
class FetchOrderURLS extends AsyncTask<String, Integer, JSONObject> {
|
| 1644 |
|
1625 |
|
| 1645 |
@Override
|
1626 |
@Override
|
| 1646 |
protected void onPreExecute() {
|
1627 |
protected void onPreExecute() {
|
| 1647 |
super.onPreExecute();
|
1628 |
super.onPreExecute();
|
| Line 1649... |
Line 1630... |
| 1649 |
|
1630 |
|
| 1650 |
@Override
|
1631 |
@Override
|
| 1651 |
protected JSONObject doInBackground(String... arg0) {
|
1632 |
protected JSONObject doInBackground(String... arg0) {
|
| 1652 |
HttpClient httpclient = new DefaultHttpClient();
|
1633 |
HttpClient httpclient = new DefaultHttpClient();
|
| 1653 |
try {
|
1634 |
try {
|
| 1654 |
String fetchUrl = apiData.getString("amazon.order.tracking.get.url",null)+"?user_id="+ userData.getString("id","")+"&store_id=" + apiData.getString("store.code.amazon","1");
|
1635 |
String fetchUrl = apiData.getString("amazon.order.tracking.get.url", null) + "?user_id=" + userData.getString("id", "") + "&store_id=" + apiData.getString("store.code.amazon", "1");
|
| 1655 |
HttpGet httppost = new HttpGet(fetchUrl);
|
1636 |
HttpGet httppost = new HttpGet(fetchUrl);
|
| 1656 |
|
1637 |
|
| 1657 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
1638 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
| 1658 |
HttpResponse response = httpclient.execute(httppost);
|
1639 |
HttpResponse response = httpclient.execute(httppost);
|
| 1659 |
HttpEntity entity = response.getEntity();
|
1640 |
HttpEntity entity = response.getEntity();
|
| Line 1662... |
Line 1643... |
| 1662 |
|
1643 |
|
| 1663 |
} catch (ClientProtocolException e) {
|
1644 |
} catch (ClientProtocolException e) {
|
| 1664 |
return null;
|
1645 |
return null;
|
| 1665 |
} catch (IOException e) {
|
1646 |
} catch (IOException e) {
|
| 1666 |
return null;
|
1647 |
return null;
|
| 1667 |
}
|
- |
|
| 1668 |
catch (Exception e){
|
1648 |
} catch (Exception e) {
|
| 1669 |
e.printStackTrace();
|
1649 |
e.printStackTrace();
|
| 1670 |
return null;
|
1650 |
return null;
|
| 1671 |
}
|
1651 |
}
|
| 1672 |
}
|
1652 |
}
|
| 1673 |
|
1653 |
|
| 1674 |
@Override
|
1654 |
@Override
|
| 1675 |
protected void onPostExecute(JSONObject result) {
|
1655 |
protected void onPostExecute(JSONObject result) {
|
| 1676 |
super.onPostExecute(result);
|
1656 |
super.onPostExecute(result);
|
| 1677 |
try {
|
1657 |
try {
|
| 1678 |
if(result==null){
|
1658 |
if (result == null) {
|
| 1679 |
userDataEditor.putString("amazonOrder","false").commit();
|
1659 |
userDataEditor.putString("amazonOrder", "false").commit();
|
| 1680 |
}else{
|
1660 |
} else {
|
| 1681 |
if (result.length() == 0) {
|
1661 |
if (result.length() == 0) {
|
| 1682 |
userDataEditor.putString("amazonOrder", "false").commit();
|
1662 |
userDataEditor.putString("amazonOrder", "false").commit();
|
| 1683 |
}else {
|
1663 |
} else {
|
| 1684 |
JSONArray js = result.getJSONArray("result");
|
1664 |
JSONArray js = result.getJSONArray("result");
|
| 1685 |
if(js.length()!=0) {
|
1665 |
if (js.length() != 0) {
|
| 1686 |
str = new ArrayList<>();
|
1666 |
str = new ArrayList<>();
|
| 1687 |
for (int i = 0; i < js.length(); i++) {
|
1667 |
for (int i = 0; i < js.length(); i++) {
|
| 1688 |
String s = js.getString(i);
|
1668 |
String s = js.getString(i);
|
| 1689 |
str.add(s);
|
1669 |
str.add(s);
|
| 1690 |
}
|
1670 |
}
|
| 1691 |
sizeList = 1;
|
1671 |
sizeList = 1;
|
| 1692 |
j = 1;
|
1672 |
j = 1;
|
| 1693 |
addOrderHistory(str.get(0));
|
1673 |
addOrderHistory(str.get(0));
|
| 1694 |
}else{
|
1674 |
} else {
|
| 1695 |
userDataEditor.putString("amazonOrder","false").commit();
|
1675 |
userDataEditor.putString("amazonOrder", "false").commit();
|
| 1696 |
}
|
1676 |
}
|
| 1697 |
}
|
1677 |
}
|
| 1698 |
}
|
1678 |
}
|
| 1699 |
}catch (Exception e){
|
1679 |
} catch (Exception e) {
|
| 1700 |
}
|
1680 |
}
|
| 1701 |
}
|
1681 |
}
|
| 1702 |
}
|
1682 |
}
|
| - |
|
1683 |
|
| 1703 |
int count=0;
|
1684 |
int count = 0;
|
| 1704 |
List<String> str;
|
1685 |
List<String> str;
|
| - |
|
1686 |
|
| 1705 |
public void addOrderHistory(String s){
|
1687 |
public void addOrderHistory(String s) {
|
| 1706 |
AmazonOrderHistoryDetails amazonOrderClient = new AmazonOrderHistoryDetails();
|
1688 |
AmazonOrderHistoryDetails amazonOrderClient = new AmazonOrderHistoryDetails();
|
| 1707 |
amazonOrderHistoryWebView = new WebView(webView.getContext());
|
1689 |
amazonOrderHistoryWebView = new WebView(webView.getContext());
|
| 1708 |
amazonOrderHistoryWebView.setVisibility(View.GONE);
|
1690 |
amazonOrderHistoryWebView.setVisibility(View.GONE);
|
| 1709 |
amazonOrderHistoryWebView.getSettings().setUserAgentString("Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36");
|
1691 |
amazonOrderHistoryWebView.getSettings().setUserAgentString("Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36");
|
| 1710 |
amazonOrderHistoryWebView.getSettings().setJavaScriptEnabled(true);
|
1692 |
amazonOrderHistoryWebView.getSettings().setJavaScriptEnabled(true);
|
| 1711 |
amazonOrderHistoryWebView.addJavascriptInterface(new amazonInterface(getActivity()), "HTMLOUT");
|
1693 |
amazonOrderHistoryWebView.addJavascriptInterface(new amazonInterface(getActivity()), "HTMLOUT");
|
| 1712 |
amazonOrderHistoryWebView.loadUrl(s);
|
1694 |
amazonOrderHistoryWebView.loadUrl(s);
|
| 1713 |
amazonOrderHistoryWebView.setWebViewClient(amazonOrderClient);
|
1695 |
amazonOrderHistoryWebView.setWebViewClient(amazonOrderClient);
|
| 1714 |
}
|
1696 |
}
|
| - |
|
1697 |
|
| 1715 |
public void addOrderHistoryCancelled(String s){
|
1698 |
public void addOrderHistoryCancelled(String s) {
|
| 1716 |
AmazonOrderCancelledDetails amazonOrderClient1 = new AmazonOrderCancelledDetails();
|
1699 |
AmazonOrderCancelledDetails amazonOrderClient1 = new AmazonOrderCancelledDetails();
|
| 1717 |
amazonOrderHistoryCancelledWebView = new WebView(webView.getContext());
|
1700 |
amazonOrderHistoryCancelledWebView = new WebView(webView.getContext());
|
| 1718 |
amazonOrderHistoryCancelledWebView.setVisibility(View.GONE);
|
1701 |
amazonOrderHistoryCancelledWebView.setVisibility(View.GONE);
|
| 1719 |
amazonOrderHistoryCancelledWebView.getSettings().setJavaScriptEnabled(true);
|
1702 |
amazonOrderHistoryCancelledWebView.getSettings().setJavaScriptEnabled(true);
|
| 1720 |
amazonOrderHistoryCancelledWebView.getSettings().setUserAgentString("Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36");
|
1703 |
amazonOrderHistoryCancelledWebView.getSettings().setUserAgentString("Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36");
|
| Line 1739... |
Line 1722... |
| 1739 |
}
|
1722 |
}
|
| 1740 |
|
1723 |
|
| 1741 |
@Override
|
1724 |
@Override
|
| 1742 |
public void onPageFinished(WebView view, String url) {
|
1725 |
public void onPageFinished(WebView view, String url) {
|
| 1743 |
super.onPageFinished(view, url);
|
1726 |
super.onPageFinished(view, url);
|
| 1744 |
if(url.contains("signin")){
|
1727 |
if (url.contains("signin")) {
|
| 1745 |
userDataEditor.putBoolean("amazonLoggedIn",false).commit();
|
1728 |
userDataEditor.putBoolean("amazonLoggedIn", false).commit();
|
| 1746 |
}
|
- |
|
| 1747 |
else {
|
1729 |
} else {
|
| 1748 |
view.loadUrl("javascript:window.HTMLOUT.orderHistory('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
|
1730 |
view.loadUrl("javascript:window.HTMLOUT.orderHistory('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
|
| 1749 |
}
|
1731 |
}
|
| 1750 |
}
|
1732 |
}
|
| 1751 |
}
|
1733 |
}
|
| 1752 |
|
1734 |
|
| Line 1770... |
Line 1752... |
| 1770 |
super.onPageFinished(view, url);
|
1752 |
super.onPageFinished(view, url);
|
| 1771 |
view.loadUrl("javascript:window.HTMLOUT.cancelledHistory('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
|
1753 |
view.loadUrl("javascript:window.HTMLOUT.cancelledHistory('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
|
| 1772 |
}
|
1754 |
}
|
| 1773 |
}
|
1755 |
}
|
| 1774 |
|
1756 |
|
| 1775 |
class FlipkartOrderURLS extends AsyncTask<String, Integer, JSONObject> {
|
- |
|
| 1776 |
|
- |
|
| 1777 |
@Override
|
- |
|
| 1778 |
protected void onPreExecute() {
|
- |
|
| 1779 |
super.onPreExecute();
|
- |
|
| 1780 |
}
|
- |
|
| 1781 |
|
- |
|
| 1782 |
@Override
|
- |
|
| 1783 |
protected JSONObject doInBackground(String... arg0) {
|
- |
|
| 1784 |
HttpClient httpclient = new DefaultHttpClient();
|
- |
|
| 1785 |
try {
|
- |
|
| 1786 |
|
- |
|
| 1787 |
String fetchUrl = apiData.getString("amazon.order.tracking.get.url",null)+"?user_id="+ userData.getString("id","")+"&store_id=" + UtilityFunctions.getNewStoreId(UtilityFunctions.generateStoreMap(apiData.getString("stores.code","")),"flipkart");
|
- |
|
| 1788 |
HttpGet httppost = new HttpGet(fetchUrl);
|
- |
|
| 1789 |
|
- |
|
| 1790 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
- |
|
| 1791 |
HttpResponse response = httpclient.execute(httppost);
|
- |
|
| 1792 |
HttpEntity entity = response.getEntity();
|
- |
|
| 1793 |
|
- |
|
| 1794 |
JSONObject jObjGmail = new JSONObject(EntityUtils.toString(entity));
|
- |
|
| 1795 |
return jObjGmail;
|
- |
|
| 1796 |
|
- |
|
| 1797 |
} catch (ClientProtocolException e) {
|
- |
|
| 1798 |
return null;
|
- |
|
| 1799 |
}
|
- |
|
| 1800 |
catch (IOException e) {
|
- |
|
| 1801 |
return null;
|
- |
|
| 1802 |
}
|
- |
|
| 1803 |
catch (Exception e){
|
- |
|
| 1804 |
return null;
|
- |
|
| 1805 |
}
|
- |
|
| 1806 |
}
|
- |
|
| 1807 |
|
- |
|
| 1808 |
@Override
|
- |
|
| 1809 |
protected void onPostExecute(JSONObject result) {
|
- |
|
| 1810 |
super.onPostExecute(result);
|
- |
|
| 1811 |
try {
|
- |
|
| 1812 |
if(result==null){
|
- |
|
| 1813 |
userDataEditor.putString("flipkartOrder","false").commit();
|
- |
|
| 1814 |
}else{
|
- |
|
| 1815 |
if (result.length() == 0) {
|
- |
|
| 1816 |
userDataEditor.putString("flipkartOrder", "false").commit();
|
- |
|
| 1817 |
}else {
|
- |
|
| 1818 |
JSONArray js = result.getJSONArray("result");
|
- |
|
| 1819 |
if(js.length()!=0) {
|
- |
|
| 1820 |
str = new ArrayList<>();
|
- |
|
| 1821 |
for (int i = 0; i < js.length(); i++) {
|
- |
|
| 1822 |
String s = js.getString(i);
|
- |
|
| 1823 |
str.add(s);
|
- |
|
| 1824 |
}
|
- |
|
| 1825 |
sizeList = 1;
|
- |
|
| 1826 |
j = 1;
|
- |
|
| 1827 |
|
- |
|
| 1828 |
}else{
|
- |
|
| 1829 |
userDataEditor.putString("flipkartOrder","false").commit();
|
- |
|
| 1830 |
}
|
- |
|
| 1831 |
}
|
- |
|
| 1832 |
}
|
- |
|
| 1833 |
}catch (Exception e){
|
- |
|
| 1834 |
}
|
- |
|
| 1835 |
}
|
- |
|
| 1836 |
}
|
- |
|
| 1837 |
|
1757 |
|
| 1838 |
public final boolean isInternetOn() {
|
1758 |
public final boolean isInternetOn() {
|
| 1839 |
|
1759 |
|
| 1840 |
ConnectivityManager connec =
|
1760 |
ConnectivityManager connec =
|
| 1841 |
(ConnectivityManager)getActivity().getSystemService(getActivity().getBaseContext().CONNECTIVITY_SERVICE);
|
1761 |
(ConnectivityManager) getActivity().getSystemService(getActivity().getBaseContext().CONNECTIVITY_SERVICE);
|
| 1842 |
|
1762 |
|
| 1843 |
if ( connec.getNetworkInfo(0).getState() == android.net.NetworkInfo.State.CONNECTED ||
|
1763 |
if (connec.getNetworkInfo(0).getState() == android.net.NetworkInfo.State.CONNECTED ||
|
| 1844 |
connec.getNetworkInfo(0).getState() == android.net.NetworkInfo.State.CONNECTING ||
|
1764 |
connec.getNetworkInfo(0).getState() == android.net.NetworkInfo.State.CONNECTING ||
|
| 1845 |
connec.getNetworkInfo(1).getState() == android.net.NetworkInfo.State.CONNECTING ||
|
1765 |
connec.getNetworkInfo(1).getState() == android.net.NetworkInfo.State.CONNECTING ||
|
| 1846 |
connec.getNetworkInfo(1).getState() == android.net.NetworkInfo.State.CONNECTED ) {
|
1766 |
connec.getNetworkInfo(1).getState() == android.net.NetworkInfo.State.CONNECTED) {
|
| 1847 |
return true;
|
1767 |
return true;
|
| 1848 |
|
1768 |
|
| 1849 |
} else if (
|
1769 |
} else if (
|
| 1850 |
connec.getNetworkInfo(0).getState() == android.net.NetworkInfo.State.DISCONNECTED ||
|
1770 |
connec.getNetworkInfo(0).getState() == android.net.NetworkInfo.State.DISCONNECTED ||
|
| 1851 |
connec.getNetworkInfo(1).getState() == android.net.NetworkInfo.State.DISCONNECTED ) {
|
1771 |
connec.getNetworkInfo(1).getState() == android.net.NetworkInfo.State.DISCONNECTED) {
|
| 1852 |
|
1772 |
|
| 1853 |
return false;
|
1773 |
return false;
|
| 1854 |
}
|
1774 |
}
|
| 1855 |
return false;
|
1775 |
return false;
|
| 1856 |
}
|
1776 |
}
|
| Line 1877... |
Line 1797... |
| 1877 |
jSaholic.put("time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
1797 |
jSaholic.put("time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
| 1878 |
jSaholic.put("httpstatus", status);
|
1798 |
jSaholic.put("httpstatus", status);
|
| 1879 |
jSaholic.put("cookies", CookieManager.getInstance().getCookie(arg0[0]));
|
1799 |
jSaholic.put("cookies", CookieManager.getInstance().getCookie(arg0[0]));
|
| 1880 |
jsArraySaholic.put(jSaholic);
|
1800 |
jsArraySaholic.put(jSaholic);
|
| 1881 |
obj.put("pushdata", jsArraySaholic);
|
1801 |
obj.put("pushdata", jsArraySaholic);
|
| 1882 |
Log.d("status " ,"Status in checkGatewayProbelm " + status);
|
1802 |
Log.d("status ", "Status in checkGatewayProbelm " + status);
|
| 1883 |
if(status == 200){
|
1803 |
if (status == 200) {
|
| 1884 |
return "success";
|
1804 |
return "success";
|
| 1885 |
} else {
|
1805 |
} else {
|
| 1886 |
return "failure";
|
1806 |
return "failure";
|
| 1887 |
}
|
1807 |
}
|
| 1888 |
|
1808 |
|
| 1889 |
} catch (ClientProtocolException e) {
|
1809 |
} catch (ClientProtocolException e) {
|
| 1890 |
return "failure";
|
1810 |
return "failure";
|
| 1891 |
} catch (IOException e) {
|
1811 |
} catch (IOException e) {
|
| 1892 |
return "failure";
|
1812 |
return "failure";
|
| 1893 |
}catch (JSONException e){
|
1813 |
} catch (JSONException e) {
|
| 1894 |
return "failure";
|
1814 |
return "failure";
|
| 1895 |
}
|
1815 |
}
|
| 1896 |
}
|
1816 |
}
|
| 1897 |
|
1817 |
|
| 1898 |
@Override
|
1818 |
@Override
|
| 1899 |
protected void onPostExecute(String result) {
|
1819 |
protected void onPostExecute(String result) {
|
| 1900 |
super.onPostExecute(result);
|
1820 |
super.onPostExecute(result);
|
| 1901 |
new pushData1().execute(obj);
|
1821 |
new pushData1().execute(obj);
|
| 1902 |
}
|
1822 |
}
|
| 1903 |
}
|
1823 |
}
|
| - |
|
1824 |
|
| 1904 |
class pushData1 extends AsyncTask<JSONObject, Integer, String> {
|
1825 |
class pushData1 extends AsyncTask<JSONObject, Integer, String> {
|
| 1905 |
|
1826 |
|
| 1906 |
@Override
|
1827 |
@Override
|
| 1907 |
protected void onPreExecute() {
|
1828 |
protected void onPreExecute() {
|
| 1908 |
super.onPreExecute();
|
1829 |
super.onPreExecute();
|
| Line 1911... |
Line 1832... |
| 1911 |
@Override
|
1832 |
@Override
|
| 1912 |
protected String doInBackground(JSONObject... arg0) {
|
1833 |
protected String doInBackground(JSONObject... arg0) {
|
| 1913 |
HttpClient httpclient = new DefaultHttpClient();
|
1834 |
HttpClient httpclient = new DefaultHttpClient();
|
| 1914 |
try {
|
1835 |
try {
|
| 1915 |
ArrayList<NameValuePair> nameValuePairs = new ArrayList<>();
|
1836 |
ArrayList<NameValuePair> nameValuePairs = new ArrayList<>();
|
| 1916 |
nameValuePairs.add(new BasicNameValuePair("pushdata",arg0[0].toString()));
|
1837 |
nameValuePairs.add(new BasicNameValuePair("pushdata", arg0[0].toString()));
|
| 1917 |
HttpPost httppost = new HttpPost(apiData.getString("url.push.api",null));
|
1838 |
HttpPost httppost = new HttpPost(apiData.getString("url.push.api", null));
|
| 1918 |
final String basicAuth = "Basic " + Base64.encodeToString("dtr:dtr18Feb2015".getBytes(), Base64.NO_WRAP);
|
1839 |
final String basicAuth = "Basic " + Base64.encodeToString("dtr:dtr18Feb2015".getBytes(), Base64.NO_WRAP);
|
| 1919 |
httppost.setHeader("Authorization", basicAuth);
|
1840 |
httppost.setHeader("Authorization", basicAuth);
|
| 1920 |
|
1841 |
|
| 1921 |
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
|
1842 |
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
|
| 1922 |
System.out.println("JSON object in push Data 1 " + arg0[0].toString());
|
1843 |
System.out.println("JSON object in push Data 1 " + arg0[0].toString());
|
| 1923 |
StringEntity se = new StringEntity(arg0[0].toString());
|
1844 |
StringEntity se = new StringEntity(arg0[0].toString());
|
| 1924 |
HttpResponse response = httpclient.execute(httppost);
|
1845 |
HttpResponse response = httpclient.execute(httppost);
|
| 1925 |
int status = response.getStatusLine().getStatusCode();
|
1846 |
int status = response.getStatusLine().getStatusCode();
|
| 1926 |
|
1847 |
|
| 1927 |
if(status == 200){
|
1848 |
if (status == 200) {
|
| 1928 |
return "success";
|
1849 |
return "success";
|
| 1929 |
} else {
|
1850 |
} else {
|
| 1930 |
return "failure";
|
1851 |
return "failure";
|
| 1931 |
}
|
1852 |
}
|
| 1932 |
|
1853 |
|
| Line 1941... |
Line 1862... |
| 1941 |
protected void onPostExecute(String result) {
|
1862 |
protected void onPostExecute(String result) {
|
| 1942 |
super.onPostExecute(result);
|
1863 |
super.onPostExecute(result);
|
| 1943 |
}
|
1864 |
}
|
| 1944 |
}
|
1865 |
}
|
| 1945 |
|
1866 |
|
| 1946 |
public void redirectPage(final AlertDialog builder){
|
1867 |
public void redirectPage(final AlertDialog builder) {
|
| 1947 |
Handler h =new Handler();
|
1868 |
Handler h = new Handler();
|
| 1948 |
h.postDelayed(new Runnable() {
|
1869 |
h.postDelayed(new Runnable() {
|
| 1949 |
@Override
|
1870 |
@Override
|
| 1950 |
public void run() {
|
1871 |
public void run() {
|
| 1951 |
if(builder!=null){
|
1872 |
if (builder != null) {
|
| 1952 |
builder.dismiss();
|
1873 |
builder.dismiss();
|
| 1953 |
}
|
1874 |
}
|
| 1954 |
userDataEditor.clear().commit();
|
1875 |
userDataEditor.clear().commit();
|
| 1955 |
startActivity(new Intent(getActivity(), LoginActivity.class));
|
1876 |
startActivity(new Intent(getActivity(), LoginActivity.class));
|
| 1956 |
}
|
1877 |
}
|
| 1957 |
},3000);
|
1878 |
}, 3000);
|
| 1958 |
|
1879 |
|
| 1959 |
}
|
1880 |
}
|
| 1960 |
|
1881 |
|
| 1961 |
public void sendQueuedResponse(){
|
1882 |
public void sendQueuedResponse() {
|
| 1962 |
|
1883 |
|
| 1963 |
List<List<NameValuePair>> postDataNameValuePair = new ArrayList<List<NameValuePair>>();
|
1884 |
List<List<NameValuePair>> postDataNameValuePair = new ArrayList<List<NameValuePair>>();
|
| 1964 |
postDataNameValuePair=orderDetails.readData1();
|
1885 |
postDataNameValuePair = orderDetails.readData1();
|
| 1965 |
for(List<NameValuePair> orderDetail : postDataNameValuePair) {
|
1886 |
for (List<NameValuePair> orderDetail : postDataNameValuePair) {
|
| 1966 |
orderDetail.add(new BasicNameValuePair("zip", "1"));
|
1887 |
orderDetail.add(new BasicNameValuePair("zip", "1"));
|
| 1967 |
orderDetail.add(new BasicNameValuePair("wifi",UtilityFunctions.checkWifi(getActivity())+""));
|
1888 |
orderDetail.add(new BasicNameValuePair("wifi", UtilityFunctions.checkWifi(getActivity()) + ""));
|
| 1968 |
orderDetail.add(new BasicNameValuePair("imeinumber",UtilityFunctions.getImeiNumber(getActivity())));
|
1889 |
orderDetail.add(new BasicNameValuePair("imeinumber", UtilityFunctions.getImeiNumber(getActivity())));
|
| 1969 |
orderDetail.add(new BasicNameValuePair("appversion",UtilityFunctions.getAppVersion(getActivity())));
|
1890 |
orderDetail.add(new BasicNameValuePair("appversion", UtilityFunctions.getAppVersion(getActivity())));
|
| 1970 |
PushRawHTML pm =new PushRawHTML();
|
1891 |
PushRawHTML pm = new PushRawHTML();
|
| 1971 |
pm.execute(orderDetail);
|
1892 |
pm.execute(orderDetail);
|
| 1972 |
}
|
1893 |
}
|
| 1973 |
}
|
1894 |
}
|
| 1974 |
|
1895 |
|
| 1975 |
|
1896 |
|
| Line 1980... |
Line 1901... |
| 1980 |
}
|
1901 |
}
|
| 1981 |
|
1902 |
|
| 1982 |
@Override
|
1903 |
@Override
|
| 1983 |
public void onPageFinished(WebView view, String url) {
|
1904 |
public void onPageFinished(WebView view, String url) {
|
| 1984 |
super.onPageFinished(view, url);
|
1905 |
super.onPageFinished(view, url);
|
| 1985 |
if(url.contains(apiData.getString("paytm.myorders.url","paytm.com/myorders"))){
|
1906 |
if (url.contains(apiData.getString("paytm.myorders.url", "paytm.com/myorders"))) {
|
| 1986 |
view.loadUrl("javascript:window.location='" + getPaytmUrl(url) + "';");
|
1907 |
view.loadUrl("javascript:window.location='" + getPaytmUrl(url) + "';");
|
| 1987 |
}else {
|
1908 |
} else {
|
| 1988 |
view.loadUrl("javascript:window.HTMLOUT.showHTML(document.getElementsByTagName('html')[0].innerHTML);");
|
1909 |
view.loadUrl("javascript:window.HTMLOUT.showHTML(document.getElementsByTagName('html')[0].innerHTML);");
|
| 1989 |
}
|
1910 |
}
|
| 1990 |
}
|
1911 |
}
|
| 1991 |
}
|
1912 |
}
|
| 1992 |
|
1913 |
|
| 1993 |
public String getPaytmUrl(String url){
|
1914 |
public String getPaytmUrl(String url) {
|
| 1994 |
String returnUrl=null;
|
1915 |
String returnUrl = null;
|
| 1995 |
//Pattern p = Pattern.compile("[/]myorders/(\\d+)");
|
1916 |
//Pattern p = Pattern.compile("[/]myorders/(\\d+)");
|
| 1996 |
Pattern p = Pattern.compile(apiData.getString("paytm.myorders.pattern","[/]myorders/(\\d+)"));
|
1917 |
Pattern p = Pattern.compile(apiData.getString("paytm.myorders.pattern", "[/]myorders/(\\d+)"));
|
| 1997 |
Matcher m = p.matcher(url);
|
1918 |
Matcher m = p.matcher(url);
|
| 1998 |
if (m.find()) {
|
1919 |
if (m.find()) {
|
| 1999 |
returnUrl=m.group(1);
|
1920 |
returnUrl = m.group(1);
|
| 2000 |
}
|
1921 |
}
|
| 2001 |
System.out.println(apiData.getString("paytm.orderdetail.url","https://paytm.com/shop/orderdetail/") + returnUrl + "?actions=1&channel=web&version=2");
|
1922 |
System.out.println(apiData.getString("paytm.orderdetail.url", "https://paytm.com/shop/orderdetail/") + returnUrl + "?actions=1&channel=web&version=2");
|
| 2002 |
return apiData.getString("paytm.orderdetail.url","https://paytm.com/shop/orderdetail/")+returnUrl+"?actions=1&channel=web&version=2";
|
1923 |
return apiData.getString("paytm.orderdetail.url", "https://paytm.com/shop/orderdetail/") + returnUrl + "?actions=1&channel=web&version=2";
|
| 2003 |
}
|
1924 |
}
|
| 2004 |
|
1925 |
|
| 2005 |
|
1926 |
|
| 2006 |
public String getPaytmReferer(String url){
|
1927 |
public String getPaytmReferer(String url) {
|
| 2007 |
String returnUrl=null;
|
1928 |
String returnUrl = null;
|
| 2008 |
Pattern p = Pattern.compile(apiData.getString("paytm.summary.pattern","[/]summary/(\\d+)"));
|
1929 |
Pattern p = Pattern.compile(apiData.getString("paytm.summary.pattern", "[/]summary/(\\d+)"));
|
| 2009 |
//Pattern p = Pattern.compile("[/]summary/(\\d+)");
|
1930 |
//Pattern p = Pattern.compile("[/]summary/(\\d+)");
|
| 2010 |
Matcher m = p.matcher(url);
|
1931 |
Matcher m = p.matcher(url);
|
| 2011 |
if (m.find()) {
|
1932 |
if (m.find()) {
|
| 2012 |
returnUrl=m.group(1);
|
1933 |
returnUrl = m.group(1);
|
| 2013 |
}
|
1934 |
}
|
| 2014 |
System.out.println( "In paytm Referer" + apiData.getString("paytm.myorders.url","https://paytm.com/myorders/") +returnUrl);
|
1935 |
System.out.println("In paytm Referer" + apiData.getString("paytm.myorders.url", "https://paytm.com/myorders/") + returnUrl);
|
| 2015 |
return apiData.getString("paytm.myorders.url","https://paytm.com/myorders/")+returnUrl;
|
1936 |
return apiData.getString("paytm.myorders.url", "https://paytm.com/myorders/") + returnUrl;
|
| 2016 |
}
|
1937 |
}
|
| 2017 |
|
1938 |
|
| 2018 |
|
1939 |
|
| 2019 |
class PaytmOrderURL extends AsyncTask<String, Integer, JSONObject> {
|
1940 |
class PaytmOrderURL extends AsyncTask<String, Integer, JSONObject> {
|
| 2020 |
|
1941 |
|
| Line 2025... |
Line 1946... |
| 2025 |
|
1946 |
|
| 2026 |
@Override
|
1947 |
@Override
|
| 2027 |
protected JSONObject doInBackground(String... arg0) {
|
1948 |
protected JSONObject doInBackground(String... arg0) {
|
| 2028 |
HttpClient httpclient = new DefaultHttpClient();
|
1949 |
HttpClient httpclient = new DefaultHttpClient();
|
| 2029 |
try {
|
1950 |
try {
|
| 2030 |
String fetchUrl = apiData.getString("amazon.order.tracking.get.url", null) + "?user_id=" + userData.getString("id", "") + "&store_id=" + UtilityFunctions.getNewStoreId(UtilityFunctions.generateStoreMap(apiData.getString("stores.code","")),"paytm");
|
1951 |
String fetchUrl = apiData.getString("amazon.order.tracking.get.url", null) + "?user_id=" + userData.getString("id", "") + "&store_id=" + UtilityFunctions.getNewStoreId(UtilityFunctions.generateStoreMap(apiData.getString("stores.code", "")), "paytm");
|
| 2031 |
HttpGet httppost = new HttpGet(fetchUrl);
|
1952 |
HttpGet httppost = new HttpGet(fetchUrl);
|
| 2032 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
1953 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
| 2033 |
HttpResponse response = httpclient.execute(httppost);
|
1954 |
HttpResponse response = httpclient.execute(httppost);
|
| 2034 |
HttpEntity entity = response.getEntity();
|
1955 |
HttpEntity entity = response.getEntity();
|
| 2035 |
int status = response.getStatusLine().getStatusCode();
|
1956 |
int status = response.getStatusLine().getStatusCode();
|
| Line 2053... |
Line 1974... |
| 2053 |
if (result != null) {
|
1974 |
if (result != null) {
|
| 2054 |
if (result.length() == 0) {
|
1975 |
if (result.length() == 0) {
|
| 2055 |
userDataEditor.putString("paytmOrder", "false").commit();
|
1976 |
userDataEditor.putString("paytmOrder", "false").commit();
|
| 2056 |
} else {
|
1977 |
} else {
|
| 2057 |
JSONArray js = result.getJSONArray("result");
|
1978 |
JSONArray js = result.getJSONArray("result");
|
| 2058 |
if(js.length()!=0) {
|
1979 |
if (js.length() != 0) {
|
| 2059 |
strPaytmUrls = new ArrayList<>();
|
1980 |
strPaytmUrls = new ArrayList<>();
|
| 2060 |
strPaytmReferer = new ArrayList<>();
|
1981 |
strPaytmReferer = new ArrayList<>();
|
| 2061 |
for (int i = 0; i < js.length(); i++) {
|
1982 |
for (int i = 0; i < js.length(); i++) {
|
| 2062 |
JSONObject paytmURLRef=js.getJSONObject(i);
|
1983 |
JSONObject paytmURLRef = js.getJSONObject(i);
|
| 2063 |
String url = paytmURLRef.getString("url");
|
1984 |
String url = paytmURLRef.getString("url");
|
| 2064 |
String referer = paytmURLRef.getString("referer");
|
1985 |
String referer = paytmURLRef.getString("referer");
|
| 2065 |
strPaytmUrls.add(url);
|
1986 |
strPaytmUrls.add(url);
|
| 2066 |
strPaytmReferer.add(referer);
|
1987 |
strPaytmReferer.add(referer);
|
| 2067 |
}
|
1988 |
}
|
| 2068 |
paytmOrderTracking(strPaytmUrls.get(0),strPaytmReferer.get(0));
|
1989 |
paytmOrderTracking(strPaytmUrls.get(0), strPaytmReferer.get(0));
|
| 2069 |
}else{
|
1990 |
} else {
|
| 2070 |
userDataEditor.putString("paytmOrder", "false").commit();
|
1991 |
userDataEditor.putString("paytmOrder", "false").commit();
|
| 2071 |
}
|
1992 |
}
|
| 2072 |
}
|
1993 |
}
|
| 2073 |
}
|
1994 |
}
|
| 2074 |
}catch (Exception e){
|
1995 |
} catch (Exception e) {
|
| 2075 |
e.printStackTrace();
|
1996 |
e.printStackTrace();
|
| 2076 |
}
|
1997 |
}
|
| 2077 |
|
1998 |
|
| 2078 |
}
|
1999 |
}
|
| 2079 |
}
|
2000 |
}
|
| Line 2098... |
Line 2019... |
| 2098 |
HttpResponse response = httpclient.execute(httppost);
|
2019 |
HttpResponse response = httpclient.execute(httppost);
|
| 2099 |
HttpEntity entity = response.getEntity();
|
2020 |
HttpEntity entity = response.getEntity();
|
| 2100 |
|
2021 |
|
| 2101 |
int status = response.getStatusLine().getStatusCode();
|
2022 |
int status = response.getStatusLine().getStatusCode();
|
| 2102 |
|
2023 |
|
| 2103 |
if(status == 200){
|
2024 |
if (status == 200) {
|
| 2104 |
NameValuePair y = orderDetail[0].get(2);
|
2025 |
NameValuePair y = orderDetail[0].get(2);
|
| 2105 |
int z =orderDetails.deleteRecord(y.getName(),new String[]{y.getValue()});
|
2026 |
int z = orderDetails.deleteRecord(y.getName(), new String[]{y.getValue()});
|
| 2106 |
} else {
|
2027 |
} else {
|
| 2107 |
}
|
2028 |
}
|
| 2108 |
String getJSON = EntityUtils.toString(entity);
|
2029 |
String getJSON = EntityUtils.toString(entity);
|
| 2109 |
if(getJSON==null){
|
2030 |
if (getJSON == null) {
|
| 2110 |
return null;
|
2031 |
return null;
|
| 2111 |
}else {
|
2032 |
} else {
|
| 2112 |
JSONObject jObjGmail = new JSONObject(getJSON);
|
2033 |
JSONObject jObjGmail = new JSONObject(getJSON);
|
| 2113 |
return jObjGmail;
|
2034 |
return jObjGmail;
|
| 2114 |
}
|
2035 |
}
|
| 2115 |
} catch (Exception e) {
|
2036 |
} catch (Exception e) {
|
| 2116 |
return null;
|
2037 |
return null;
|
| Line 2118... |
Line 2039... |
| 2118 |
}
|
2039 |
}
|
| 2119 |
|
2040 |
|
| 2120 |
|
2041 |
|
| 2121 |
@Override
|
2042 |
@Override
|
| 2122 |
protected void onPostExecute(JSONObject result) {
|
2043 |
protected void onPostExecute(JSONObject result) {
|
| 2123 |
if(result==null){
|
2044 |
if (result == null) {
|
| 2124 |
|
2045 |
|
| 2125 |
}
|
- |
|
| 2126 |
else {
|
2046 |
} else {
|
| 2127 |
userDataEditor.putString("paytmOrder", "true").commit();
|
2047 |
userDataEditor.putString("paytmOrder", "true").commit();
|
| 2128 |
userDataEditor.putLong("paytmNextFetchTime", System.currentTimeMillis()+ 21600000).commit();
|
2048 |
userDataEditor.putLong("paytmNextFetchTime", System.currentTimeMillis() + 21600000).commit();
|
| 2129 |
try {
|
2049 |
try {
|
| 2130 |
if (result.getString("message").equalsIgnoreCase("PROCESSED"))
|
2050 |
if (result.getString("message").equalsIgnoreCase("PROCESSED"))
|
| 2131 |
orderDetails.deleterecords();
|
2051 |
orderDetails.deleterecords();
|
| 2132 |
} catch (Exception e) {
|
2052 |
} catch (Exception e) {
|
| 2133 |
}
|
2053 |
}
|
| 2134 |
}
|
2054 |
}
|
| 2135 |
super.onPostExecute(result);
|
2055 |
super.onPostExecute(result);
|
| 2136 |
}
|
2056 |
}
|
| 2137 |
}
|
2057 |
}
|
| 2138 |
|
2058 |
|
| 2139 |
public void paytmOrderTracking(List<String> paytmUrls,List<String> paytmReferers){
|
2059 |
public void paytmOrderTracking(List<String> paytmUrls, List<String> paytmReferers) {
|
| 2140 |
for(int i=1;i<paytmReferers.size();i++) {
|
2060 |
for (int i = 1; i < paytmReferers.size(); i++) {
|
| 2141 |
PaytmOrderTrackingClient paytmOrderTrackingClient = new PaytmOrderTrackingClient(paytmUrls.get(i));
|
2061 |
PaytmOrderTrackingClient paytmOrderTrackingClient = new PaytmOrderTrackingClient(paytmUrls.get(i));
|
| 2142 |
paytmWebView = new WebView(webView.getContext());
|
2062 |
paytmWebView = new WebView(webView.getContext());
|
| 2143 |
paytmWebView.setVisibility(View.GONE);
|
2063 |
paytmWebView.setVisibility(View.GONE);
|
| 2144 |
paytmWebView.addJavascriptInterface(new paytmInterface(getActivity()), "HTMLOUT");
|
2064 |
paytmWebView.addJavascriptInterface(new paytmInterface(getActivity()), "HTMLOUT");
|
| 2145 |
paytmWebView.getSettings().setJavaScriptEnabled(true);
|
2065 |
paytmWebView.getSettings().setJavaScriptEnabled(true);
|
| 2146 |
paytmWebView.loadUrl(paytmReferers.get(i));
|
2066 |
paytmWebView.loadUrl(paytmReferers.get(i));
|
| 2147 |
paytmWebView.setWebViewClient(paytmOrderTrackingClient);
|
2067 |
paytmWebView.setWebViewClient(paytmOrderTrackingClient);
|
| 2148 |
}
|
2068 |
}
|
| 2149 |
userDataEditor.putLong("paytmNextFetchTime",System.currentTimeMillis()+21600000).commit();
|
2069 |
userDataEditor.putLong("paytmNextFetchTime", System.currentTimeMillis() + 21600000).commit();
|
| 2150 |
}
|
2070 |
}
|
| 2151 |
|
2071 |
|
| 2152 |
public void paytmOrderTracking(String paytmUrl,String paytmReferer){
|
2072 |
public void paytmOrderTracking(String paytmUrl, String paytmReferer) {
|
| 2153 |
PaytmOrderTrackingClient paytmOrderTrackingClient = new PaytmOrderTrackingClient(paytmUrl);
|
2073 |
PaytmOrderTrackingClient paytmOrderTrackingClient = new PaytmOrderTrackingClient(paytmUrl);
|
| 2154 |
paytmWebView = new WebView(webView.getContext());
|
2074 |
paytmWebView = new WebView(webView.getContext());
|
| 2155 |
paytmWebView.setVisibility(View.GONE);
|
2075 |
paytmWebView.setVisibility(View.GONE);
|
| 2156 |
paytmWebView.addJavascriptInterface(new paytmInterface(getActivity()), "HTMLOUT");
|
2076 |
paytmWebView.addJavascriptInterface(new paytmInterface(getActivity()), "HTMLOUT");
|
| 2157 |
paytmWebView.getSettings().setJavaScriptEnabled(true);
|
2077 |
paytmWebView.getSettings().setJavaScriptEnabled(true);
|
| 2158 |
paytmWebView.loadUrl(paytmReferer);
|
2078 |
paytmWebView.loadUrl(paytmReferer);
|
| 2159 |
paytmWebView.setWebViewClient(paytmOrderTrackingClient);
|
2079 |
paytmWebView.setWebViewClient(paytmOrderTrackingClient);
|
| 2160 |
userDataEditor.putLong("paytmNextFetchTime",System.currentTimeMillis()+21600000).commit();
|
2080 |
userDataEditor.putLong("paytmNextFetchTime", System.currentTimeMillis() + 21600000).commit();
|
| 2161 |
}
|
2081 |
}
|
| - |
|
2082 |
|
| 2162 |
class PaytmOrderTrackingClient extends WebViewClient {
|
2083 |
class PaytmOrderTrackingClient extends WebViewClient {
|
| 2163 |
String paytmUrlAfterReferer;
|
2084 |
String paytmUrlAfterReferer;
|
| - |
|
2085 |
|
| 2164 |
public PaytmOrderTrackingClient(String paytmUrl){
|
2086 |
public PaytmOrderTrackingClient(String paytmUrl) {
|
| 2165 |
paytmUrlAfterReferer=paytmUrl;
|
2087 |
paytmUrlAfterReferer = paytmUrl;
|
| 2166 |
}
|
2088 |
}
|
| - |
|
2089 |
|
| 2167 |
@Override
|
2090 |
@Override
|
| 2168 |
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
2091 |
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
| 2169 |
super.onPageStarted(view, url, favicon);
|
2092 |
super.onPageStarted(view, url, favicon);
|
| 2170 |
}
|
2093 |
}
|
| 2171 |
|
2094 |
|
| 2172 |
@Override
|
2095 |
@Override
|
| 2173 |
public void onPageFinished(WebView view, String url) {
|
2096 |
public void onPageFinished(WebView view, String url) {
|
| 2174 |
super.onPageFinished(view, url);
|
2097 |
super.onPageFinished(view, url);
|
| 2175 |
if(url.contains(apiData.getString("paytm.myorders.url","paytm.com/myorders"))){
|
2098 |
if (url.contains(apiData.getString("paytm.myorders.url", "paytm.com/myorders"))) {
|
| 2176 |
view.loadUrl("javascript:window.location='"+ paytmUrlAfterReferer+ "';");
|
2099 |
view.loadUrl("javascript:window.location='" + paytmUrlAfterReferer + "';");
|
| 2177 |
}else {
|
2100 |
} else {
|
| 2178 |
view.loadUrl("javascript:window.HTMLOUT.paytmTracking(document.getElementsByTagName('html')[0].innerHTML);");
|
2101 |
view.loadUrl("javascript:window.HTMLOUT.paytmTracking(document.getElementsByTagName('html')[0].innerHTML);");
|
| 2179 |
}
|
2102 |
}
|
| 2180 |
}
|
2103 |
}
|
| 2181 |
}
|
2104 |
}
|
| - |
|
2105 |
|
| 2182 |
List<String> strPaytmUrls,strPaytmReferer;
|
2106 |
List<String> strPaytmUrls, strPaytmReferer;
|
| 2183 |
int paytmCounter=0;
|
2107 |
int paytmCounter = 0;
|
| 2184 |
|
2108 |
|
| 2185 |
class PaytmPushTrackingUrls extends AsyncTask<List<NameValuePair>, Integer, JSONObject> {
|
2109 |
class PaytmPushTrackingUrls extends AsyncTask<List<NameValuePair>, Integer, JSONObject> {
|
| 2186 |
@Override
|
2110 |
@Override
|
| 2187 |
protected void onPreExecute() {
|
2111 |
protected void onPreExecute() {
|
| 2188 |
super.onPreExecute();
|
2112 |
super.onPreExecute();
|
| Line 2191... |
Line 2115... |
| 2191 |
@Override
|
2115 |
@Override
|
| 2192 |
protected JSONObject doInBackground(List<NameValuePair>... pushOrder) {
|
2116 |
protected JSONObject doInBackground(List<NameValuePair>... pushOrder) {
|
| 2193 |
|
2117 |
|
| 2194 |
try {
|
2118 |
try {
|
| 2195 |
HttpClient httpclient = new DefaultHttpClient();
|
2119 |
HttpClient httpclient = new DefaultHttpClient();
|
| 2196 |
String fetchUrl = apiData.getString("amazon.order.tracking.post.url",null)+"?user_id="+ userData.getString("id","")+"&store_id=" + "&store_id=" + UtilityFunctions.getNewStoreId(UtilityFunctions.generateStoreMap(apiData.getString("stores.code","")),"paytm");
|
2120 |
String fetchUrl = apiData.getString("amazon.order.tracking.post.url", null) + "?user_id=" + userData.getString("id", "") + "&store_id=" + "&store_id=" + UtilityFunctions.getNewStoreId(UtilityFunctions.generateStoreMap(apiData.getString("stores.code", "")), "paytm");
|
| 2197 |
HttpPost httppost = new HttpPost(fetchUrl);
|
2121 |
HttpPost httppost = new HttpPost(fetchUrl);
|
| 2198 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
2122 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
| 2199 |
httppost.setEntity(new UrlEncodedFormEntity(pushOrder[0]));
|
2123 |
httppost.setEntity(new UrlEncodedFormEntity(pushOrder[0]));
|
| 2200 |
HttpResponse response = httpclient.execute(httppost);
|
2124 |
HttpResponse response = httpclient.execute(httppost);
|
| 2201 |
HttpEntity entity = response.getEntity();
|
2125 |
HttpEntity entity = response.getEntity();
|
| Line 2211... |
Line 2135... |
| 2211 |
super.onPostExecute(result);
|
2135 |
super.onPostExecute(result);
|
| 2212 |
try {
|
2136 |
try {
|
| 2213 |
if (result == null) {
|
2137 |
if (result == null) {
|
| 2214 |
|
2138 |
|
| 2215 |
} else if (result.getString("result").equalsIgnoreCase("PARSE_ERROR")) {
|
2139 |
} else if (result.getString("result").equalsIgnoreCase("PARSE_ERROR")) {
|
| 2216 |
userDataEditor.putBoolean("paytmLoggedIn",false).commit();
|
2140 |
userDataEditor.putBoolean("paytmLoggedIn", false).commit();
|
| 2217 |
}else{
|
2141 |
} else {
|
| 2218 |
paytmOrderTracking(strPaytmUrls,strPaytmReferer);
|
2142 |
paytmOrderTracking(strPaytmUrls, strPaytmReferer);
|
| 2219 |
}
|
2143 |
}
|
| 2220 |
}catch(Exception e){
|
2144 |
} catch (Exception e) {
|
| 2221 |
e.printStackTrace();
|
2145 |
e.printStackTrace();
|
| 2222 |
}
|
2146 |
}
|
| 2223 |
}
|
2147 |
}
|
| 2224 |
}
|
2148 |
}
|
| 2225 |
|
2149 |
|
| Line 2254... |
Line 2178... |
| 2254 |
if (isInternetOn()) {
|
2178 |
if (isInternetOn()) {
|
| 2255 |
new PaytmPushTrackingUrls().execute(amazonOrderHistory);
|
2179 |
new PaytmPushTrackingUrls().execute(amazonOrderHistory);
|
| 2256 |
} else {
|
2180 |
} else {
|
| 2257 |
|
2181 |
|
| 2258 |
}
|
2182 |
}
|
| 2259 |
}catch(Exception e){
|
2183 |
} catch (Exception e) {
|
| 2260 |
e.printStackTrace();
|
2184 |
e.printStackTrace();
|
| 2261 |
}
|
2185 |
}
|
| 2262 |
|
2186 |
|
| 2263 |
}
|
2187 |
}
|
| 2264 |
}
|
2188 |
}
|
| 2265 |
|
2189 |
|
| 2266 |
public void onShareClick(String url){
|
2190 |
public void onShareClick(String url) {
|
| 2267 |
try {
|
2191 |
try {
|
| 2268 |
List<Intent> targetShareIntents = new ArrayList<Intent>();
|
2192 |
List<Intent> targetShareIntents = new ArrayList<Intent>();
|
| 2269 |
Intent shareIntent = new Intent();
|
2193 |
Intent shareIntent = new Intent();
|
| 2270 |
shareIntent.setAction(Intent.ACTION_SEND);
|
2194 |
shareIntent.setAction(Intent.ACTION_SEND);
|
| 2271 |
shareIntent.setType("text/plain");
|
2195 |
shareIntent.setType("text/plain");
|
| Line 2285... |
Line 2209... |
| 2285 |
Intent chooserIntent = Intent.createChooser(targetShareIntents.remove(0), "Choose app to share");
|
2209 |
Intent chooserIntent = Intent.createChooser(targetShareIntents.remove(0), "Choose app to share");
|
| 2286 |
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetShareIntents.toArray(new Parcelable[]{}));
|
2210 |
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetShareIntents.toArray(new Parcelable[]{}));
|
| 2287 |
startActivity(chooserIntent);
|
2211 |
startActivity(chooserIntent);
|
| 2288 |
}
|
2212 |
}
|
| 2289 |
}
|
2213 |
}
|
| 2290 |
}catch (Exception e){
|
2214 |
} catch (Exception e) {
|
| 2291 |
e.printStackTrace();
|
2215 |
e.printStackTrace();
|
| 2292 |
}
|
2216 |
}
|
| 2293 |
}
|
2217 |
}
|
| 2294 |
|
2218 |
|
| 2295 |
public void fetchAmazonOrder(String url){
|
2219 |
public void fetchAmazonOrder(String url) {
|
| 2296 |
pd1 = new ProgressDialog(getActivity());
|
2220 |
pd1 = new ProgressDialog(getActivity());
|
| 2297 |
pd1.setTitle("Please wait");
|
2221 |
pd1.setTitle("Please wait");
|
| 2298 |
pd1.setMessage("Placing your order...");
|
2222 |
pd1.setMessage("Placing your order...");
|
| 2299 |
pd1.show();
|
2223 |
pd1.show();
|
| 2300 |
webView.post(new Runnable() {
|
2224 |
webView.post(new Runnable() {
|
| Line 2307... |
Line 2231... |
| 2307 |
}
|
2231 |
}
|
| 2308 |
|
2232 |
|
| 2309 |
@Override
|
2233 |
@Override
|
| 2310 |
public void onPause() {
|
2234 |
public void onPause() {
|
| 2311 |
super.onPause();
|
2235 |
super.onPause();
|
| 2312 |
if(apiData.getString("deal.redirect","false").equalsIgnoreCase("true")) {
|
2236 |
if (apiData.getString("deal.redirect", "false").equalsIgnoreCase("true")) {
|
| 2313 |
if (webView != null) {
|
2237 |
if (webView != null) {
|
| 2314 |
if (isPause) {
|
2238 |
if (isPause) {
|
| 2315 |
webView.loadUrl(apiData.getString("mobile.website.url", "") + "?user_id=" + userData.getString("id", ""));
|
2239 |
webView.loadUrl(apiData.getString("mobile.website.url", "") + "?user_id=" + userData.getString("id", ""));
|
| 2316 |
isPause = false;
|
2240 |
isPause = false;
|
| 2317 |
}
|
2241 |
}
|
| 2318 |
}
|
2242 |
}
|
| 2319 |
}
|
2243 |
}
|
| 2320 |
}
|
2244 |
}
|
| - |
|
2245 |
|
| - |
|
2246 |
class FlipkartWebview extends WebViewClient {
|
| - |
|
2247 |
|
| - |
|
2248 |
@Override
|
| - |
|
2249 |
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
| - |
|
2250 |
super.onPageStarted(view, url, favicon);
|
| - |
|
2251 |
}
|
| - |
|
2252 |
|
| - |
|
2253 |
@Override
|
| - |
|
2254 |
public void onPageFinished(WebView view, String url) {
|
| - |
|
2255 |
super.onPageFinished(view, url);
|
| - |
|
2256 |
if(url.contains(apiData.getString("flipkart.response.url",""))) {
|
| - |
|
2257 |
view.loadUrl("javascript:window.HTMLOUT.orderpage('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
|
| - |
|
2258 |
}
|
| - |
|
2259 |
|
| - |
|
2260 |
}
|
| - |
|
2261 |
}
|
| 2321 |
}
|
2262 |
}
|