Subversion Repositories SmartDukaan

Rev

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

Rev 18503 Rev 18559
Line 77... Line 77...
77
    public DealsHomeFragment(){
77
    public DealsHomeFragment(){
78
 
78
 
79
    }
79
    }
80
 
80
 
81
    static boolean FLAG=false,REDIRECT=false,PAGE_LOAD=false,PAYTMFLAG=false,isPause=false;
81
    static boolean FLAG=false,REDIRECT=false,PAGE_LOAD=false,PAYTMFLAG=false,isPause=false;
-
 
82
    static int snapdealException=0;
82
    WebView webView;
83
    WebView webView;
83
    WebView amazonWebView,amazonOrderHistoryWebView,amazonOrderHistoryCancelledWebView,paytmWebView;
84
    WebView amazonWebView,amazonOrderHistoryWebView,amazonOrderHistoryCancelledWebView,paytmWebView;
84
    WebView amazonAllUrlsWebView;
85
    WebView amazonAllUrlsWebView;
85
    SharedPreferences userData;
86
    SharedPreferences userData;
86
    SharedPreferences apiData;
87
    SharedPreferences apiData;
Line 281... Line 282...
281
        }
282
        }
282
 
283
 
283
        @Override
284
        @Override
284
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
285
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
285
 
286
 
-
 
287
            if(apiData.getString("snapdealException","false").equalsIgnoreCase("true")){
-
 
288
                List<String> snapdealExceptionUrls = new ArrayList<>();
-
 
289
                StringTokenizer st = new StringTokenizer(apiData.getString("snapdeal.exception.urls",""),"|");
-
 
290
                while(st.hasMoreTokens()){
-
 
291
                    snapdealExceptionUrls.add( st.nextToken());
-
 
292
                }
-
 
293
                for(String s:snapdealExceptionUrls){
-
 
294
                    if(url.contains(s)){
-
 
295
                        if(snapdealException==0){
-
 
296
                            webView.reload();
-
 
297
                            snapdealException=1;
-
 
298
                        }
-
 
299
                        return false;
-
 
300
                    }
-
 
301
                }
-
 
302
            }
286
            if(apiData.getString("isRedirect","false").equalsIgnoreCase("true")){
303
            if(apiData.getString("isRedirect","false").equalsIgnoreCase("true")){
287
                List<String> browserRedirectUrl = new ArrayList<>();
304
                List<String> browserRedirectUrl = new ArrayList<>();
288
                StringTokenizer st = new StringTokenizer(apiData.getString("redirect.urls",""),"|");
305
                StringTokenizer st = new StringTokenizer(apiData.getString("redirect.urls",""),"|");
289
                while(st.hasMoreTokens()){
306
                while(st.hasMoreTokens()){
290
                    browserRedirectUrl.add( st.nextToken());
307
                    browserRedirectUrl.add( st.nextToken());
Line 516... Line 533...
516
        }
533
        }
517
 
534
 
518
        @Override
535
        @Override
519
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
536
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
520
            super.onReceivedError(view, errorCode, description, failingUrl);
537
            super.onReceivedError(view, errorCode, description, failingUrl);
-
 
538
            if(getActivity()!=null) {
521
            SearchFragment nextFrag= new SearchFragment();
539
                SearchFragment nextFrag = new SearchFragment();
522
            Bundle args = new Bundle();
540
                Bundle args = new Bundle();
523
            args.putString("finishingurl",failingUrl);
541
                args.putString("finishingurl", failingUrl);
524
            nextFrag.setArguments(args);
542
                nextFrag.setArguments(args);
525
            getActivity().getFragmentManager().beginTransaction()
543
                getActivity().getFragmentManager().beginTransaction()
526
                    .replace(R.id.frame_container, nextFrag)
544
                        .replace(R.id.frame_container, nextFrag)
527
                    .addToBackStack(null)
545
                        .addToBackStack(null)
528
                    .commit();
546
                        .commit();
-
 
547
            }
529
        }
548
        }
530
 
549
 
531
        @Override
550
        @Override
532
        public synchronized  void onPageFinished(WebView view, String url) {
551
        public synchronized  void onPageFinished(WebView view, String url) {
533
        super.onPageFinished(view, url);
552
        super.onPageFinished(view, url);
534
        try {
553
        try {
-
 
554
            if(apiData.getString("snapdealException","true").equalsIgnoreCase("true")){
-
 
555
                List<String> snapdealExceptionUrlsPass = new ArrayList<>();
-
 
556
                StringTokenizer st = new StringTokenizer(apiData.getString("snapdeal.exception.urls.pass",""),"|");
-
 
557
                while(st.hasMoreTokens()){
-
 
558
                    snapdealExceptionUrlsPass.add( st.nextToken());
-
 
559
                }
-
 
560
                for(String s:snapdealExceptionUrlsPass){
-
 
561
                    if(url.contains(s)){
-
 
562
                        snapdealException=0;
-
 
563
                    }
-
 
564
                }
535
 
565
            }
536
            if (url.contains(apiData.getString("mobile.website.url", "")) || url.equalsIgnoreCase("http://api.profittill.com/categorydeals")) {
566
            if (url.contains(apiData.getString("mobile.website.url", "")) || url.equalsIgnoreCase("http://api.profittill.com/categorydeals")) {
537
                pd.dismiss();
567
                pd.dismiss();
538
            }
568
            }
539
            if(snapdealPageLoad==1){
569
            if(snapdealPageLoad==1){
540
                snapdealPageLoad=0;
570
                snapdealPageLoad=0;
Line 2017... Line 2047...
2017
    }
2047
    }
2018
 
2048
 
2019
    @Override
2049
    @Override
2020
    public void onPause() {
2050
    public void onPause() {
2021
        super.onPause();
2051
        super.onPause();
-
 
2052
        if(apiData.getString("deal.redirect","false").equalsIgnoreCase("true")) {
2022
        if(webView!=null) {
2053
            if (webView != null) {
2023
            if(isPause) {
2054
                if (isPause) {
2024
                webView.loadUrl(apiData.getString("mobile.website.url", "") + "?user_id=" + userData.getString("id", ""));
2055
                    webView.loadUrl(apiData.getString("mobile.website.url", "") + "?user_id=" + userData.getString("id", ""));
2025
                isPause=false;
2056
                    isPause = false;
-
 
2057
                }
2026
            }
2058
            }
2027
        }
2059
        }
2028
    }
2060
    }
2029
}
2061
}