Subversion Repositories SmartDukaan

Rev

Rev 22130 | Rev 22830 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 22130 Rev 22381
Line 36... Line 36...
36
import android.util.Log;
36
import android.util.Log;
37
import android.view.KeyEvent;
37
import android.view.KeyEvent;
38
import android.view.LayoutInflater;
38
import android.view.LayoutInflater;
39
import android.view.Menu;
39
import android.view.Menu;
40
import android.view.MenuInflater;
40
import android.view.MenuInflater;
-
 
41
import android.view.MenuItem;
41
import android.view.View;
42
import android.view.View;
42
import android.view.ViewGroup;
43
import android.view.ViewGroup;
43
import android.webkit.CookieManager;
44
import android.webkit.CookieManager;
44
import android.webkit.CookieSyncManager;
45
import android.webkit.CookieSyncManager;
45
import android.webkit.HttpAuthHandler;
46
import android.webkit.HttpAuthHandler;
46
import android.webkit.JavascriptInterface;
47
import android.webkit.JavascriptInterface;
47
import android.webkit.ValueCallback;
48
import android.webkit.ValueCallback;
48
import android.webkit.WebChromeClient;
49
import android.webkit.WebChromeClient;
-
 
50
import android.webkit.WebResourceResponse;
49
import android.webkit.WebSettings;
51
import android.webkit.WebSettings;
50
import android.webkit.WebView;
52
import android.webkit.WebView;
51
import android.webkit.WebViewClient;
53
import android.webkit.WebViewClient;
52
import android.widget.CheckBox;
54
import android.widget.CheckBox;
53
import android.widget.CompoundButton;
55
import android.widget.CompoundButton;
Line 81... Line 83...
81
import org.json.JSONObject;
83
import org.json.JSONObject;
82
 
84
 
83
import java.io.File;
85
import java.io.File;
84
import java.io.IOException;
86
import java.io.IOException;
85
import java.io.InputStream;
87
import java.io.InputStream;
-
 
88
import java.io.StringBufferInputStream;
86
import java.io.UnsupportedEncodingException;
89
import java.io.UnsupportedEncodingException;
87
import java.text.SimpleDateFormat;
90
import java.text.SimpleDateFormat;
88
import java.util.ArrayList;
91
import java.util.ArrayList;
89
import java.util.Date;
92
import java.util.Date;
90
import java.util.HashMap;
93
import java.util.HashMap;
Line 170... Line 173...
170
            notifciationCount.setText(userData.getInt("notification_count", 0) + "");
173
            notifciationCount.setText(userData.getInt("notification_count", 0) + "");
171
        } else {
174
        } else {
172
            notifciationCount.setVisibility(View.GONE);
175
            notifciationCount.setVisibility(View.GONE);
173
        }*/
176
        }*/
174
    }
177
    }
175
 
-
 
176
    @Override
178
    @Override
-
 
179
    public boolean onOptionsItemSelected(MenuItem item) {
-
 
180
        Fragment menuFragment = null;
-
 
181
        JSONObject props = new JSONObject();
-
 
182
        Bundle args = new Bundle();
-
 
183
        String id = userData.getString("id", null);
-
 
184
        /*if (mDrawerToggle.onOptionsItemSelected(item)) {
-
 
185
            return true;
-
 
186
        }
-
 
187
*/
-
 
188
        switch (item.getItemId()) {
-
 
189
 
-
 
190
            case android.R.id.home:
-
 
191
                Intent i = new Intent(getActivity(), MainActivity.class);
-
 
192
                i.putExtra("displayView", "0");
-
 
193
                startActivity(i);
-
 
194
                return true;
-
 
195
 
-
 
196
        }
-
 
197
        return super.onOptionsItemSelected(item);
-
 
198
    }
-
 
199
 
-
 
200
        @Override
177
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
201
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
178
                             Bundle savedInstanceState) {
202
                             Bundle savedInstanceState) {
179
 
203
 
180
 
204
 
181
        View rootView = inflater.inflate(R.layout.fragment_deals_home, container, false);
205
        View rootView = inflater.inflate(R.layout.fragment_deals_home, container, false);
Line 191... Line 215...
191
        actionBar.setDisplayShowCustomEnabled(true);
215
        actionBar.setDisplayShowCustomEnabled(true);
192
        actionBar.setDisplayShowTitleEnabled(false);
216
        actionBar.setDisplayShowTitleEnabled(false);
193
        actionBar.setDisplayHomeAsUpEnabled(true);
217
        actionBar.setDisplayHomeAsUpEnabled(true);
194
        actionBar.setHomeButtonEnabled(true);
218
        actionBar.setHomeButtonEnabled(true);
195
        actionBar.setCustomView(R.layout.actionbarprofittill);
219
        actionBar.setCustomView(R.layout.actionbarprofittill);
196
        actionBar.show();
220
        actionBar.hide();
197
        amazonData = getActivity().getSharedPreferences("Amazon_Data", Context.MODE_PRIVATE);
221
        amazonData = getActivity().getSharedPreferences("Amazon_Data", Context.MODE_PRIVATE);
198
        userData = getActivity().getSharedPreferences("User_Data", Context.MODE_PRIVATE);
222
        userData = getActivity().getSharedPreferences("User_Data", Context.MODE_PRIVATE);
199
        apiData = getActivity().getSharedPreferences("API_Data", Context.MODE_PRIVATE);
223
        apiData = getActivity().getSharedPreferences("API_Data", Context.MODE_PRIVATE);
200
        flipkartData = getActivity().getSharedPreferences("Flipkart_Data", Context.MODE_PRIVATE);
224
        flipkartData = getActivity().getSharedPreferences("Flipkart_Data", Context.MODE_PRIVATE);
201
        userDataEditor = userData.edit();
225
        userDataEditor = userData.edit();
Line 244... Line 268...
244
            webView.getSettings().setDomStorageEnabled(true);
268
            webView.getSettings().setDomStorageEnabled(true);
245
            webView.getSettings().setDatabaseEnabled(true);
269
            webView.getSettings().setDatabaseEnabled(true);
246
            webView.getSettings().setJavaScriptEnabled(true);
270
            webView.getSettings().setJavaScriptEnabled(true);
247
            webView.getSettings().setAllowContentAccess(true);
271
            webView.getSettings().setAllowContentAccess(true);
248
            webView.getSettings().setAllowFileAccess(true);
272
            webView.getSettings().setAllowFileAccess(true);
249
            //webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
273
            //webView.getSettings().setAppCacheEnabled(false);
250
            webView.addJavascriptInterface(new javascriptInterface(webView),"HTMLOUT");
274
            webView.addJavascriptInterface(new javascriptInterface(webView),"HTMLOUT");
251
            if(Build.VERSION.SDK_INT >= 21){
275
            if(Build.VERSION.SDK_INT >= 21){
252
                webView.getSettings().setMixedContentMode(0);
276
                webView.getSettings().setMixedContentMode(0);
253
                webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
277
                webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
254
            }else if(Build.VERSION.SDK_INT >= 19){
278
            }else if(Build.VERSION.SDK_INT >= 19){
Line 599... Line 623...
599
            }
623
            }
600
            return false;
624
            return false;
601
 
625
 
602
        }
626
        }
603
 
627
 
-
 
628
 
604
        @Override
629
        @Override
605
        public synchronized void onPageStarted(final WebView view, String url, Bitmap favicon) {
630
        public synchronized void onPageStarted(final WebView view, String url, Bitmap favicon) {
606
            super.onPageStarted(view, url, favicon);
631
            super.onPageStarted(view, url, favicon);
607
            final CharSequence[] items = {" Don't show me again "};
632
            final CharSequence[] items = {" Don't show me again "};
608
            final ArrayList seletedItems = new ArrayList();
633
            final ArrayList seletedItems = new ArrayList();
Line 718... Line 743...
718
                            startActivity(i);
743
                            startActivity(i);
719
                            pageRedirect = 0;
744
                            pageRedirect = 0;
720
                        }
745
                        }
721
                        else {
746
                        else {
722
                            landingURL = url;
747
                            landingURL = url;
723
                            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"))) {
748
                           /* 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"))) {
724
                                pd = new ProgressDialog(getActivity());
749
                                pd = new ProgressDialog(getActivity());
725
                                pd.setTitle("Please wait");
750
                                pd.setTitle("Please wait");
726
                                pd.setMessage("Loading..");
751
                                pd.setMessage("Loading..");
727
                                pd.show();
752
                                pd.show();
728
                            }
753
                            }*/
729
                            getOrderSuccessUrlConfirmation(url);
754
                            getOrderSuccessUrlConfirmation(url);
730
                            if (displayActionBar) {
755
                            if (displayActionBar) {
731
                                pd1 = new ProgressDialog(getActivity());
756
                                pd1 = new ProgressDialog(getActivity());
732
                                pd1.setTitle("Please wait");
757
                                pd1.setTitle("Please wait");
733
                                pd1.setMessage("Loading..");
758
                                pd1.setMessage("Loading..");
Line 766... Line 791...
766
                nextFrag.setArguments(args);
791
                nextFrag.setArguments(args);
767
                getActivity().getFragmentManager().beginTransaction().replace(R.id.frame_container,nextFrag).addToBackStack(null).commitAllowingStateLoss();
792
                getActivity().getFragmentManager().beginTransaction().replace(R.id.frame_container,nextFrag).addToBackStack(null).commitAllowingStateLoss();
768
 
793
 
769
            }
794
            }
770
        }
795
        }
771
 
-
 
772
        @Override
796
        @Override
773
        public synchronized void onPageFinished(WebView view, String url) {
797
        public synchronized void onPageFinished(WebView view, String url) {
774
            super.onPageFinished(view, url);
798
            super.onPageFinished(view, url);
-
 
799
 
-
 
800
 
-
 
801
 
775
            if(url.contains(apiData.getString("Web_Uri","http://pm.shop2020.in/entry-point"))){
802
            if(url.contains(apiData.getString("Web_Uri","http://pm.shop2020.in/entry-point"))){
776
 
803
 
777
 
804
 
778
                // if(url.contains(ProfitTillConstants.Web_Uri)){
805
                // if(url.contains(ProfitTillConstants.Web_Uri)){
779
                String js1 =("javascript:document.getElementById('authToken').value ='" +userData.getString("token","")+"'");
806
                String js1 =("javascript:document.getElementById('authToken').value ='" +userData.getString("token","")+"'");
Line 793... Line 820...
793
                String js = ("javascript:window.localStorage.removeItem('android.otpReceived');");
820
                String js = ("javascript:window.localStorage.removeItem('android.otpReceived');");
794
                Log.d("storage",js);
821
                Log.d("storage",js);
795
                view.loadUrl(js);
822
                view.loadUrl(js);
796
            }
823
            }
797
 
824
 
798
            if(url.contains("http://pm.shop2020.in")){
825
            if(url.contains("http://pm.shop2020.in")|| url.contains("about:blank")){
799
                // ((AppCompatActivity)getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
826
                // ((AppCompatActivity)getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
800
                ((AppCompatActivity)getActivity()).getSupportActionBar().hide();
827
                ((AppCompatActivity)getActivity()).getSupportActionBar().hide();
801
            }
828
            }
802
            else{
829
            else{
803
                ((AppCompatActivity)getActivity()).getSupportActionBar().show();
830
                ((AppCompatActivity)getActivity()).getSupportActionBar().show();
804
            }
831
            }
-
 
832
 
-
 
833
                view.loadUrl("javascript:try{" +
-
 
834
                        "var lastUrl=document.URL;" +
-
 
835
                        "setInterval(function(){var currentUrl=document.URL;" +
-
 
836
                        "if(currentUrl!=lastUrl){window.HTMLOUT.angularUrls(currentUrl);lastUrl=currentUrl;}},2000)" +
-
 
837
                        "}catch(error){Android.onError(error.message);}");
-
 
838
 
805
            try {
839
            try {
806
                if (url.equalsIgnoreCase("about:blank")) {
840
                if (url.equalsIgnoreCase("about:blank")) {
807
                    Log.d("Blankl Url", "Blank Url");
841
                    Log.d("Blankl Url", "Blank Url");
808
                }
842
                }
809
                else {
843
                else {
Line 829... Line 863...
829
                            if (url.contains(s)) {
863
                            if (url.contains(s)) {
830
                                snapdealException = 0;
864
                                snapdealException = 0;
831
                            }
865
                            }
832
                        }
866
                        }
833
                    }
867
                    }
834
                    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"))) {
868
                  /*  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"))) {
835
                        pd.dismiss();
869
                        pd.dismiss();
836
                    }
870
                    }*/
837
                    if (snapdealPageLoad == 1) {
871
                    if (snapdealPageLoad == 1) {
838
                        snapdealPageLoad = 0;
872
                        snapdealPageLoad = 0;
839
                    }
873
                    }
840
                    if (pd2 != null) {
874
                    if (pd2 != null) {
841
                        pd2.dismiss();
875
                        pd2.dismiss();
Line 943... Line 977...
943
                    }
977
                    }
944
 
978
 
945
 
979
 
946
                    view.setOnKeyListener(new View.OnKeyListener() {
980
                    view.setOnKeyListener(new View.OnKeyListener() {
947
                        @Override
981
                        @Override
948
                        public boolean onKey(View v, int keyCode, KeyEvent event) {
982
        public boolean onKey(View v, int keyCode, KeyEvent event) {
949
                            if (event.getAction() == KeyEvent.ACTION_DOWN) {
983
            if (event.getAction() == KeyEvent.ACTION_DOWN) {
950
                                WebView webView = (WebView) v;
984
                WebView webView = (WebView) v;
951
                                switch (keyCode) {
985
                switch (keyCode) {
952
                                    case KeyEvent.KEYCODE_BACK:
986
                    case KeyEvent.KEYCODE_BACK:
953
                                        String veb=webView.getUrl();
987
                        String veb=webView.getUrl();
954
                                        if ((webView.canGoBack() && !webView.getUrl().contains("http://pm.shop2020.in/pages/home/dashboard") && !webView.getUrl().contains("http://pm.shop2020.in/pages/mobileOtp")&& !webView.getUrl().contains("http://pm.shop2020.in/pages/registration") && !webView.getUrl().contains("http://pm.shop2020.in/pages/checkRegistration"))|| pageRedirect == 2) {
988
                        if ((webView.canGoBack() && !webView.getUrl().contains(apiData.getString("dashboard","http://pm.shop2020.in/pages/home/dashboard")) && !webView.getUrl().contains(apiData.getString("mobileOtp","http://pm.shop2020.in/pages/mobileOtp"))&& !webView.getUrl().contains(apiData.getString("registration","http://pm.shop2020.in/pages/registration")) && !webView.getUrl().contains(apiData.getString("checkRegistration","http://pm.shop2020.in/pages/checkRegistration"))&&!webView.getUrl().contains(apiData.getString("thankYou","http://pm.shop2020.in/pages/home/thankYou")))|| pageRedirect == 2) {
955
                                            webView.goBack();
989
                            webView.goBack();
956
                                            pageRedirect = 0;
990
                            pageRedirect = 0;
957
                                            snapdealPageLoad = 0;
991
                            snapdealPageLoad = 0;
958
                                            return true;
992
                            return true;
959
                                        } else if (affliateUrl.contains("flipkart") || affliateUrl.contains("amazon") || affliateUrl.contains("snapdeal") || affliateUrl.contains("saholic") || affliateUrl.contains(apiData.getString("myorders.url", "")) || affliateUrl.contains(apiData.getString("search.url", ""))) {
993
                        } else if (affliateUrl.contains("flipkart") || affliateUrl.contains("amazon") || affliateUrl.contains("snapdeal") || affliateUrl.contains("saholic") || affliateUrl.contains(apiData.getString("myorders.url", "")) || affliateUrl.contains(apiData.getString("search.url", ""))) {
960
                                            Intent i = new Intent(getActivity(), MainActivity.class);
994
                            Intent i = new Intent(getActivity(), MainActivity.class);
961
                                            i.putExtra("displayView", "0");
995
                            i.putExtra("displayView", "0");
-
 
996
                            startActivity(i);
-
 
997
                            return true;
-
 
998
                        }
-
 
999
                        else if (webView.getUrl().contains(apiData.getString("domain","http://pm.shop2020.in"))) {
-
 
1000
                            //else if(webView.getUrl().contains(ProfitTillConstants.Web_Uri)){
-
 
1001
                            if (doubleBackToExitPressedOnce) {
-
 
1002
                                new AlertDialog.Builder(getActivity())
-
 
1003
                                        .setIcon(R.drawable.symbol)
962
                                            startActivity(i);
1004
                                        .setTitle("Exit!")
-
 
1005
                                        .setMessage("Are you sure you want to close?")
-
 
1006
                                        .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
963
                                            return true;
1007
                                            @Override
-
 
1008
                                    public void onClick(DialogInterface dialog, int which) {
-
 
1009
                                        if(userData.getString("userStatus","").equals("notRegistered")||userData.getString("userStatus","").equals("registered")||userData.getString("userStatus","").equals("notVerifiedRetailer"))
-
 
1010
                                        {
-
 
1011
                                            Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
-
 
1012
                                            mGoogleApiClient.disconnect();
-
 
1013
                                            userDataEditor.clear().commit();
-
 
1014
                                            mGoogleApiClient.connect();
-
 
1015
                                            userDataEditor.clear().commit();
-
 
1016
                                            startActivity(new Intent(getActivity(), LoginActivity.class));
-
 
1017
 
964
                                        }
1018
                                        }
965
                                        else if (webView.getUrl().contains("http://pm.shop2020.in")) {
-
 
966
                                            //else if(webView.getUrl().contains(ProfitTillConstants.Web_Uri)){
-
 
967
                                            if (doubleBackToExitPressedOnce) {
-
 
968
                                                new AlertDialog.Builder(getActivity())
-
 
969
                                                        .setIcon(R.drawable.symbol)
-
 
970
                                                        .setTitle("Exit!")
-
 
971
                                                        .setMessage("Are you sure you want to close?")
-
 
972
                                                        .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
-
 
973
                                                            @Override
-
 
974
                                                            public void onClick(DialogInterface dialog, int which) {
-
 
975
                                                                if(userData.getString("userStatus","").equals("notRegistered"))
-
 
976
                                                                {
-
 
977
                                                                    Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
-
 
978
                                                                    mGoogleApiClient.disconnect();
-
 
979
                                                                    userDataEditor.clear().commit();
-
 
980
                                                                    mGoogleApiClient.connect();
-
 
981
                                                                    userDataEditor.clear().commit();
-
 
982
                                                                    startActivity(new Intent(getActivity(), LoginActivity.class));
-
 
983
 
-
 
984
                                                                }
-
 
985
                                                                else{
1019
                                        else{
986
                                                                    Intent startMain = new Intent(Intent.ACTION_MAIN);
1020
                                           Intent startMain = new Intent(Intent.ACTION_MAIN);
987
                                                                    startMain.addCategory(Intent.CATEGORY_HOME);
1021
                                            startMain.addCategory(Intent.CATEGORY_HOME);
988
                                                                    startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
1022
                                            startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
989
 
-
 
990
                                                                    startActivity(startMain);
-
 
991
                                                                }
-
 
992
                                                            }
-
 
993
 
-
 
994
                                                        })
-
 
995
                                                        .setNegativeButton("No", null)
-
 
996
                                                        .show();
-
 
997
                                                return true;
-
 
998
                                            }
-
 
999
                                            doubleBackToExitPressedOnce = true;
-
 
1000
                                            Toast.makeText(getActivity(), "Please click BACK again to exit", Toast.LENGTH_SHORT).show();
-
 
1001
 
-
 
1002
                                            new Handler().postDelayed(new Runnable() {
-
 
1003
 
-
 
1004
                                                @Override
-
 
1005
                                                public void run() {
-
 
1006
                                                    doubleBackToExitPressedOnce = false;
-
 
1007
                                                }
-
 
1008
                                            }, 5000);
-
 
1009
                                        } else {
-
 
1010
                                            Intent i = new Intent(getActivity(), MainActivity.class);
-
 
1011
                                            i.putExtra("displayView", "0");
-
 
1012
                                            startActivity(i);
1023
                                            startActivity(startMain);
1013
                                            return true;
-
 
1014
                                        }
1024
                                        }
-
 
1025
                                    }
1015
 
1026
 
1016
                                        break;
1027
                                })
-
 
1028
                                .setNegativeButton("No", null)
1017
                                }
1029
                                .show();
-
 
1030
                        return true;
1018
                            }
1031
                            }
-
 
1032
                            doubleBackToExitPressedOnce = true;
-
 
1033
                            Toast.makeText(getActivity(), "Please click BACK again to exit", Toast.LENGTH_SHORT).show();
-
 
1034
 
-
 
1035
                            new Handler().postDelayed(new Runnable() {
-
 
1036
 
-
 
1037
                                @Override
-
 
1038
                                public void run() {
-
 
1039
                                    doubleBackToExitPressedOnce = false;
-
 
1040
                                }
-
 
1041
                            }, 5000);
-
 
1042
                        } else {
-
 
1043
                            Intent i = new Intent(getActivity(), MainActivity.class);
-
 
1044
                            i.putExtra("displayView", "0");
-
 
1045
                            startActivity(i);
1019
                            return false;
1046
                            return true;
1020
                        }
1047
                        }
-
 
1048
 
1021
                    });
1049
                        break;
1022
                }
1050
                }
1023
            } catch (Exception e) {
-
 
1024
                e.printStackTrace();
-
 
1025
                TestinAgent.uploadException(getActivity(), "On Page Finished", e);
-
 
1026
            }
1051
            }
-
 
1052
            return false;
-
 
1053
                }
-
 
1054
            });
1027
        }}
1055
        }
-
 
1056
    } catch (Exception e) {
-
 
1057
        e.printStackTrace();
-
 
1058
        TestinAgent.uploadException(getActivity(), "On Page Finished", e);
-
 
1059
    }
-
 
1060
}}
1028
    public class Callback extends WebViewClient{
1061
    public class Callback extends WebViewClient{
1029
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl){
1062
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl){
1030
            Toast.makeText(getActivity(), "Failed loading app!", Toast.LENGTH_SHORT).show();
1063
            Toast.makeText(getActivity(), "Failed loading app!", Toast.LENGTH_SHORT).show();
1031
        }
1064
        }
1032
    }
1065
    }
Line 1159... Line 1192...
1159
        getView().setOnKeyListener(new View.OnKeyListener() {
1192
        getView().setOnKeyListener(new View.OnKeyListener() {
1160
            @Override
1193
            @Override
1161
            public boolean onKey(View v, int keyCode, KeyEvent event) {
1194
            public boolean onKey(View v, int keyCode, KeyEvent event) {
1162
 
1195
 
1163
                if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_BACK) {
1196
                if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_BACK) {
1164
                    try {
1197
                   try {
-
 
1198
                       String veb=webView.getUrl();
1165
                        if (landingURL.contains("http://pm.shop2020.in")) {
1199
                        if (webView.getUrl().contains(apiData.getString("dashboard","http://pm.shop2020.in/pages/home/dashboard"))||webView.getUrl().contains(apiData.getString("mobileOtp","http://pm.shop2020.in/pages/mobileOtp"))||webView.getUrl().contains(apiData.getString("registration","http://pm.shop2020.in/pages/registration"))||webView.getUrl().contains(apiData.getString("checkRegistration","http://pm.shop2020.in/pages/checkRegistration"))||webView.getUrl().contains(apiData.getString("thankYou","http://pm.shop2020.in/pages/home/thankYou"))) {
1166
                            if (doubleBackToExitPressedOnce) {
1200
                        if (doubleBackToExitPressedOnce) {
1167
                                new AlertDialog.Builder(getActivity())
1201
                        new AlertDialog.Builder(getActivity())
1168
                                        .setIcon(R.drawable.symbol)
1202
                                .setIcon(R.drawable.symbol)
1169
                                        .setTitle("Exit!")
1203
                                .setTitle("Exit!")
1170
                                        .setMessage("Are you sure you want to close?")
1204
                                .setMessage("Are you sure you want to close?")
1171
                                        .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
1205
                                .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
1172
                                            @Override
1206
                                    @Override
1173
                                            public void onClick(DialogInterface dialog, int which) {
1207
                                    public void onClick(DialogInterface dialog, int which) {
1174
                                                if(userData.getString("userStatus","").equals("notRegistered"))
1208
                        if(userData.getString("userStatus","").equals("notRegistered")||userData.getString("userStatus","").equals("registered")||userData.getString("userStatus","").equals("notVerifiedRetailer"))
1175
                                                {
1209
                        {
1176
                                                    Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
1210
                            Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
1177
                                                    mGoogleApiClient.disconnect();
1211
                                    mGoogleApiClient.disconnect();
1178
                                                    userDataEditor.clear().commit();
1212
                                    userDataEditor.clear().commit();
1179
                                                    mGoogleApiClient.connect();
1213
                                    mGoogleApiClient.connect();
1180
                                                    startActivity(new Intent(getActivity(), LoginActivity.class));
1214
                                    startActivity(new Intent(getActivity(), LoginActivity.class));
1181
 
-
 
1182
 
-
 
1183
                                                }
1215
                        }
1184
                                                else{
1216
                        else{
1185
                                                    Intent startMain = new Intent(Intent.ACTION_MAIN);
1217
                            Intent startMain = new Intent(Intent.ACTION_MAIN);
1186
                                                    startMain.addCategory(Intent.CATEGORY_HOME);
1218
                            startMain.addCategory(Intent.CATEGORY_HOME);
1187
                                                    startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
1219
                            startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
1188
 
1220
 
1189
                                                    startActivity(startMain);
1221
                            startActivity(startMain);
1190
                                                }}
1222
                        }}
1191
 
1223
 
1192
                                        })
1224
                })
1193
                                        .setNegativeButton("No", null)
1225
                        .setNegativeButton("No", null)
1194
                                        .show();
1226
                        .show();
1195
                                return true;
1227
                        return true;
1196
                            }
1228
                    }
1197
                            doubleBackToExitPressedOnce = true;
1229
                    doubleBackToExitPressedOnce = true;
1198
                            Toast.makeText(getActivity(), "Please click BACK again to exit", Toast.LENGTH_SHORT).show();
1230
                    Toast.makeText(getActivity(), "Please click BACK again to exit", Toast.LENGTH_SHORT).show();
1199
 
-
 
1200
                            new Handler().postDelayed(new Runnable() {
-
 
1201
 
1231
 
1202
                                @Override
-
 
1203
                                public void run() {
1232
                    new Handler().postDelayed(new Runnable() {
1204
                                    doubleBackToExitPressedOnce = false;
-
 
1205
                                }
-
 
1206
                            }, 5000);
-
 
1207
                        }else {
-
 
1208
                            if (webView.canGoBack()) {
-
 
1209
                                webView.goBack();
-
 
1210
                            } else {
-
 
1211
                                Intent i = new Intent(getActivity(), MainActivity.class);
-
 
1212
                                i.putExtra("displayView", "0");
-
 
1213
                                startActivity(i);
-
 
1214
                            }
-
 
1215
                            return true;
-
 
1216
 
1233
 
-
 
1234
                        @Override
-
 
1235
                        public void run() {
-
 
1236
                            doubleBackToExitPressedOnce = false;
1217
                        }
1237
                        }
-
 
1238
                    }, 5000);
-
 
1239
                    }
-
 
1240
                    else {
-
 
1241
                    if (webView.canGoBack()) {
-
 
1242
                        webView.goBack();
-
 
1243
                    } else {
1218
 
-
 
-
 
1244
                        Intent i = new Intent(getActivity(), MainActivity.class);
-
 
1245
                        i.putExtra("displayView", "0");
-
 
1246
                        startActivity(i);
-
 
1247
                    }
-
 
1248
                    return true;
-
 
1249
                    }}
1219
                    } catch (Exception e) {
1250
                    catch (Exception e) {
1220
                        e.printStackTrace();
1251
                        e.printStackTrace();
1221
                        return false;
1252
                        return false;
1222
                    }
1253
                    }
1223
                }
1254
                }
1224
                return false;
1255
                return false;
1225
            }
1256
            }
1226
 
1257
 
1227
        });
1258
        });
-
 
1259
 
1228
    }
1260
      }
-
 
1261
 
1229
 
1262
 
1230
    public void fetchOrderDetails() {
1263
    public void fetchOrderDetails() {
1231
        if (isInternetOn()) {
1264
        if (isInternetOn()) {
1232
            new FetchOrderURLS().execute();
1265
            new FetchOrderURLS().execute();
1233
        }
1266
        }
Line 1376... Line 1409...
1376
            }
1409
            }
1377
        }
1410
        }
1378
 
1411
 
1379
        @Override
1412
        @Override
1380
        protected void onPostExecute(String result) {
1413
        protected void onPostExecute(String result) {
-
 
1414
 
1381
            super.onPostExecute(result);
1415
            super.onPostExecute(result);
-
 
1416
 
1382
        }
1417
        }
1383
    }
1418
    }
1384
 
1419
 
1385
    ArrayList<NameValuePair> nameValuePairsRawHtml = new ArrayList<NameValuePair>();
1420
    ArrayList<NameValuePair> nameValuePairsRawHtml = new ArrayList<NameValuePair>();
1386
    ArrayList<NameValuePair> nameValuePairsRawHtmlAmazon = new ArrayList<NameValuePair>();
1421
    ArrayList<NameValuePair> nameValuePairsRawHtmlAmazon = new ArrayList<NameValuePair>();
Line 1584... Line 1619...
1584
                Flipkartflag = true;
1619
                Flipkartflag = true;
1585
                userDataEditor.putString("flipkartOrder", "true").commit();
1620
                userDataEditor.putString("flipkartOrder", "true").commit();
1586
                userDataEditor.putBoolean("flipkartLoggedIn", true).commit();
1621
                userDataEditor.putBoolean("flipkartLoggedIn", true).commit();
1587
            }
1622
            }
1588
        }
1623
        }
-
 
1624
        @JavascriptInterface
-
 
1625
        public void angularUrls(String url) {
-
 
1626
            if(!isInternetOn()){
-
 
1627
                SearchFragment nextFrag = new SearchFragment();
-
 
1628
                Bundle args = new Bundle();
-
 
1629
                args.putString("finishingurl", url);
-
 
1630
                nextFrag.setArguments(args);
-
 
1631
                getActivity().getFragmentManager().beginTransaction().replace(R.id.frame_container,nextFrag).addToBackStack(null).commitAllowingStateLoss();
-
 
1632
 
-
 
1633
            }
-
 
1634
            else{
-
 
1635
            try {
-
 
1636
                obj = new JSONObject();
-
 
1637
                JSONObject j = new JSONObject();
-
 
1638
                JSONArray jsArray = new JSONArray();
-
 
1639
                j.put("url", url);
-
 
1640
                j.put("user_id", userData.getString("id", null));
-
 
1641
                j.put("time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
-
 
1642
                jsArray.put(j);
-
 
1643
                obj.put("pushdata", jsArray);
-
 
1644
                new pushData().execute(obj);
-
 
1645
            } catch (Exception e) {
-
 
1646
                e.printStackTrace();
-
 
1647
            }}}
1589
    }
1648
    }
1590
    class AuthTokenChange extends AsyncTask<String, Integer, String> {
1649
    class AuthTokenChange extends AsyncTask<String, Integer, String> {
1591
 
1650
 
1592
        @Override
1651
        @Override
1593
        protected void onPreExecute() {
1652
        protected void onPreExecute() {
Line 1597... Line 1656...
1597
 
1656
 
1598
        @Override
1657
        @Override
1599
        protected String doInBackground(String... params) {
1658
        protected String doInBackground(String... params) {
1600
            try {
1659
            try {
1601
                HttpClient httpclient = new DefaultHttpClient();
1660
                HttpClient httpclient = new DefaultHttpClient();
1602
                HttpGet httpget=new HttpGet(apiData.getString("Web_Api","http://shop2020.in:8080/profitmandi-web")+"/user/token-info");
1661
                HttpGet httpget=new HttpGet(apiData.getString("Web_Api_Tokeninfo","http://api.profitmandi.com:8080/profitmandi-web/user/token-info"));
1603
                // HttpGet httpget = new HttpGet(ProfitTillConstants.Web_Api + "/user/token-info");
1662
                // HttpGet httpget = new HttpGet(ProfitTillConstants.Web_Api + "/user/token-info");
1604
                httpget.setHeader("Auth-Token", userData.getString("token", ""));
1663
                httpget.setHeader("Auth-Token", userData.getString("token", ""));
1605
                HttpResponse response = httpclient.execute(httpget);
1664
                HttpResponse response = httpclient.execute(httpget);
1606
                HttpEntity entity = response.getEntity();
1665
                HttpEntity entity = response.getEntity();
1607
                int status = response.getStatusLine().getStatusCode();
1666
                int status = response.getStatusLine().getStatusCode();
Line 2131... Line 2190...
2131
        @Override
2190
        @Override
2132
        protected String doInBackground(String... params) {
2191
        protected String doInBackground(String... params) {
2133
            try {
2192
            try {
2134
 
2193
 
2135
                HttpClient httpclient = new DefaultHttpClient();
2194
                HttpClient httpclient = new DefaultHttpClient();
2136
                HttpPost httppost = new HttpPost(apiData.getString("Web_Api","http://shop2020.in:8080/profitmandi-web") + "/otp/parseOTP");
2195
                HttpPost httppost = new HttpPost(apiData.getString("Web_Api_Otp","http://api.profitmandi.com:8080/profitmandi-web/otp/parseOTP"));
2137
                //HttpPost httppost = new HttpPost(ProfitTillConstants.Web_Api + "/otp/parseOTP");
2196
                //HttpPost httppost = new HttpPost(ProfitTillConstants.Web_Api + "/otp/parseOTP");
2138
                httppost.setHeader("Auth-Token", userData.getString("token", ""));
2197
                httppost.setHeader("Auth-Token", userData.getString("token", ""));
2139
                httppost.setEntity(new UrlEncodedFormEntity(messageNameValuePair));
2198
                httppost.setEntity(new UrlEncodedFormEntity(messageNameValuePair));
2140
                HttpResponse response = httpclient.execute(httppost);
2199
                HttpResponse response = httpclient.execute(httppost);
2141
                HttpEntity entity = response.getEntity();
2200
                HttpEntity entity = response.getEntity();