Subversion Repositories SmartDukaan

Rev

Rev 18559 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 18559 Rev 19653
Line 20... Line 20...
20
import android.os.Parcelable;
20
import android.os.Parcelable;
21
import android.util.Base64;
21
import android.util.Base64;
22
import android.util.Log;
22
import android.util.Log;
23
import android.view.KeyEvent;
23
import android.view.KeyEvent;
24
import android.view.LayoutInflater;
24
import android.view.LayoutInflater;
-
 
25
import android.view.Menu;
-
 
26
import android.view.MenuInflater;
25
import android.view.View;
27
import android.view.View;
26
import android.view.ViewGroup;
28
import android.view.ViewGroup;
27
import android.webkit.CookieManager;
29
import android.webkit.CookieManager;
28
import android.webkit.CookieSyncManager;
30
import android.webkit.CookieSyncManager;
29
import android.webkit.HttpAuthHandler;
31
import android.webkit.HttpAuthHandler;
Line 31... Line 33...
31
import android.webkit.WebSettings;
33
import android.webkit.WebSettings;
32
import android.webkit.WebView;
34
import android.webkit.WebView;
33
import android.webkit.WebViewClient;
35
import android.webkit.WebViewClient;
34
import android.widget.CheckBox;
36
import android.widget.CheckBox;
35
import android.widget.CompoundButton;
37
import android.widget.CompoundButton;
-
 
38
import android.widget.RelativeLayout;
-
 
39
import android.widget.TextView;
36
import android.widget.Toast;
40
import android.widget.Toast;
37
 
41
 
38
import com.facebook.Session;
42
import com.facebook.Session;
39
import com.google.android.gms.common.ConnectionResult;
43
import com.google.android.gms.common.ConnectionResult;
40
import com.google.android.gms.common.api.GoogleApiClient;
44
import com.google.android.gms.common.api.GoogleApiClient;
41
import com.google.android.gms.plus.Plus;
45
import com.google.android.gms.plus.Plus;
42
import com.saholic.profittill.Constants.ProfitTillConstants;
46
import com.saholic.profittill.Constants.ProfitTillConstants;
43
import com.saholic.profittill.Database.OrderTransactionDetails;
47
import com.saholic.profittill.Database.OrderTransactionDetails;
-
 
48
import com.saholic.profittill.Network.NotificationCount;
44
import com.saholic.profittill.R;
49
import com.saholic.profittill.R;
45
import com.saholic.profittill.Utils.UtilityFunctions;
50
import com.saholic.profittill.Utils.UtilityFunctions;
46
import com.testin.agent.TestinAgent;
51
import com.testin.agent.TestinAgent;
47
 
52
 
48
import org.apache.http.HttpEntity;
53
import org.apache.http.HttpEntity;
Line 77... Line 82...
77
    public DealsHomeFragment(){
82
    public DealsHomeFragment(){
78
 
83
 
79
    }
84
    }
80
 
85
 
81
    static boolean FLAG=false,REDIRECT=false,PAGE_LOAD=false,PAYTMFLAG=false,isPause=false;
86
    static boolean FLAG=false,REDIRECT=false,PAGE_LOAD=false,PAYTMFLAG=false,isPause=false;
82
    static int snapdealException=0;
87
    int snapdealException=0;
83
    WebView webView;
88
    WebView webView;
84
    WebView amazonWebView,amazonOrderHistoryWebView,amazonOrderHistoryCancelledWebView,paytmWebView;
89
    WebView amazonWebView,amazonOrderHistoryWebView,amazonOrderHistoryCancelledWebView,paytmWebView;
85
    WebView amazonAllUrlsWebView;
90
    WebView amazonAllUrlsWebView;
86
    SharedPreferences userData;
91
    SharedPreferences userData;
87
    SharedPreferences apiData;
92
    SharedPreferences apiData;
Line 114... Line 119...
114
    String type1;
119
    String type1;
115
    ArrayList<String> orderSuccessUrlList;
120
    ArrayList<String> orderSuccessUrlList;
116
    public GoogleApiClient mGoogleApiClient;
121
    public GoogleApiClient mGoogleApiClient;
117
    ProgressDialog pd1 = null;
122
    ProgressDialog pd1 = null;
118
    @Override
123
    @Override
-
 
124
    public void onCreate(Bundle savedInstanceState) {
-
 
125
        super.onCreate(savedInstanceState);
-
 
126
        setHasOptionsMenu(true);
-
 
127
    }
-
 
128
 
-
 
129
    @Override
-
 
130
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
-
 
131
        super.onCreateOptionsMenu(menu, inflater);
-
 
132
        RelativeLayout badgeLayout = (RelativeLayout) menu.findItem(R.id.action_notifications).getActionView();
-
 
133
        TextView notifciationCount = (TextView) badgeLayout.findViewById(R.id.inAppNotificationText);
-
 
134
        if(userData.getInt("notification_count",0)!=0) {
-
 
135
            notifciationCount.setVisibility(View.VISIBLE);
-
 
136
            notifciationCount.setText(userData.getInt("notification_count",0)+"");
-
 
137
        }else{
-
 
138
            notifciationCount.setVisibility(View.GONE);
-
 
139
        }
-
 
140
    }
-
 
141
 
-
 
142
    @Override
119
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
143
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
120
                             Bundle savedInstanceState) {
144
                             Bundle savedInstanceState) {
121
 
145
 
122
 
146
 
123
        View rootView = inflater.inflate(R.layout.fragment_deals_home, container, false);
147
        View rootView = inflater.inflate(R.layout.fragment_deals_home, container, false);
Line 212... Line 236...
212
              } else {
236
              } else {
213
                  Log.d("Paytm False", "Paytm False No orders");
237
                  Log.d("Paytm False", "Paytm False No orders");
214
              }
238
              }
215
          }
239
          }
216
          if(!(userData.getBoolean("amazonLoggedIn",false))){
240
          if(!(userData.getBoolean("amazonLoggedIn",false))){
217
              Log.d("User Not Logged In Amazon","User Not logged In Amazon" );
241
              Log.d("Not In Amazon","Amazon" );
218
          }else {
242
          }else {
219
              if (userData.getString("amazonOrder", "").equalsIgnoreCase("true")) {
243
              if (userData.getString("amazonOrder", "").equalsIgnoreCase("true")) {
220
                  long nextFetchTime=userData.getLong("amazonNextFetchTime", 0);
244
                  long nextFetchTime=userData.getLong("amazonNextFetchTime", 0);
221
                  if (nextFetchTime == 0 || nextFetchTime< System.currentTimeMillis()) {
245
                  if (nextFetchTime == 0 || nextFetchTime< System.currentTimeMillis()) {
222
                      if(isInternetOn()) {
246
                      if(isInternetOn()) {
Line 470... Line 494...
470
                            if (url.contains(s)) {
494
                            if (url.contains(s)) {
471
                                PAGE_LOAD = true;
495
                                PAGE_LOAD = true;
472
                            }
496
                            }
473
                        }
497
                        }
474
                        if (PAGE_LOAD) {
498
                        if (PAGE_LOAD) {
475
                            //clearCookies(url);
-
 
476
                            Log.d("Cookie after calling", "Cookie after calling" + CookieManager.getInstance().getCookie(url));
-
 
477
                            snapdealPageLoad = 1;
499
                            snapdealPageLoad = 1;
478
                            PAGE_LOAD = false;
500
                            PAGE_LOAD = false;
479
                        } else {
501
                        } else {
480
                            snapdealPageLoad = 0;
502
                            snapdealPageLoad = 0;
481
                            for (String s : redirectUrlsList) {
503
                            for (String s : redirectUrlsList) {
Line 494... Line 516...
494
                                i.putExtra("redirectUrl", apiData.getString("redirect.url", "") + "?user_id=" + userData.getString("id", ""));
516
                                i.putExtra("redirectUrl", apiData.getString("redirect.url", "") + "?user_id=" + userData.getString("id", ""));
495
                                startActivity(i);
517
                                startActivity(i);
496
                                pageRedirect = 0;
518
                                pageRedirect = 0;
497
                            } else {
519
                            } else {
498
                                landingURL = url;
520
                                landingURL = url;
499
                                if (url.contains(apiData.getString("mobile.website.url", null)) || url.equalsIgnoreCase("http://api.profittill.com/categorydeals")) {
521
                                if (url.contains(apiData.getString("mobile.website.url", "")) || url.equalsIgnoreCase("http://api.profittill.com/categorydeals") || url.contains(apiData.getString("notification.page.url", "http://api.profittill.com/users/usernotification"))) {
500
                                    pd = new ProgressDialog(getActivity());
522
                                    pd = new ProgressDialog(getActivity());
501
                                    pd.setTitle("Please wait");
523
                                    pd.setTitle("Please wait");
502
                                    pd.setMessage("Loading..");
524
                                    pd.setMessage("Loading..");
503
                                    pd.show();
525
                                    pd.show();
504
                                }
526
                                }
505
                                //getDisplayActionBar(url);
-
 
506
                                getOrderSuccessUrlConfirmation(url);
527
                                getOrderSuccessUrlConfirmation(url);
507
                                if (displayActionBar) {
528
                                if (displayActionBar) {
508
                                    pd1 = new ProgressDialog(getActivity());
529
                                    pd1 = new ProgressDialog(getActivity());
509
                                    pd1.setTitle("Please wait");
530
                                    pd1.setTitle("Please wait");
510
                                    pd1.setMessage("Loading..");
531
                                    pd1.setMessage("Loading..");
Line 549... Line 570...
549
 
570
 
550
        @Override
571
        @Override
551
        public synchronized  void onPageFinished(WebView view, String url) {
572
        public synchronized  void onPageFinished(WebView view, String url) {
552
        super.onPageFinished(view, url);
573
        super.onPageFinished(view, url);
553
        try {
574
        try {
-
 
575
            if(getActivity()!=null) {
-
 
576
                if (url.contains(apiData.getString("notification.page.url", "http://api.profittill.com/users/usernotification"))) {
-
 
577
                    String notificationUrl = apiData.getString("notification.count", "http://45.33.50.227:3001/getNotificationCount") + "?user_id=" + userData.getString("id", "") + "&android_id=" + UtilityFunctions.androidId(getActivity());
-
 
578
                    new NotificationCount().getCount(getActivity(), null, notificationUrl);
-
 
579
                    new Handler().postDelayed(new Runnable() {
-
 
580
                        @Override
-
 
581
                        public void run() {
-
 
582
                            getActivity().invalidateOptionsMenu();
-
 
583
                        }
-
 
584
                    },1000);
-
 
585
                }
-
 
586
            }
554
            if(apiData.getString("snapdealException","true").equalsIgnoreCase("true")){
587
            if(apiData.getString("snapdealException","true").equalsIgnoreCase("true")){
555
                List<String> snapdealExceptionUrlsPass = new ArrayList<>();
588
                List<String> snapdealExceptionUrlsPass = new ArrayList<>();
556
                StringTokenizer st = new StringTokenizer(apiData.getString("snapdeal.exception.urls.pass",""),"|");
589
                StringTokenizer st = new StringTokenizer(apiData.getString("snapdeal.exception.urls.pass",""),"|");
557
                while(st.hasMoreTokens()){
590
                while(st.hasMoreTokens()){
558
                    snapdealExceptionUrlsPass.add( st.nextToken());
591
                    snapdealExceptionUrlsPass.add( st.nextToken());
Line 561... Line 594...
561
                    if(url.contains(s)){
594
                    if(url.contains(s)){
562
                        snapdealException=0;
595
                        snapdealException=0;
563
                    }
596
                    }
564
                }
597
                }
565
            }
598
            }
566
            if (url.contains(apiData.getString("mobile.website.url", "")) || url.equalsIgnoreCase("http://api.profittill.com/categorydeals")) {
599
            if (url.contains(apiData.getString("mobile.website.url", "")) || url.equalsIgnoreCase("http://api.profittill.com/categorydeals") || url.contains(apiData.getString("notification.page.url", "http://api.profittill.com/users/usernotification"))) {
567
                pd.dismiss();
600
                pd.dismiss();
568
            }
601
            }
569
            if(snapdealPageLoad==1){
602
            if(snapdealPageLoad==1){
570
                snapdealPageLoad=0;
603
                snapdealPageLoad=0;
571
            }
604
            }