Example #1
0
 @Override
 protected String doInBackground(String... params) {
   String regId = ""; // mHomePage.getPreference().getString(
   // AppConstants.PREFPUSHREGISTRATIONID, "");
   if (Tabbars.getInstance() != null)
     regId =
         Tabbars.getInstance()
             .getPreference()
             .getString(AppConstants.PREFPUSHREGISTRATIONID, "");
   else if (RotiHomeActivity.getInstance() != null)
     regId =
         RotiHomeActivity.getInstance()
             .getPreference()
             .getString(AppConstants.PREFPUSHREGISTRATIONID, "");
   List<NameValuePair> nameparams = new ArrayList<NameValuePair>();
   nameparams.add(new BasicNameValuePair("email", params[0]));
   mEmailID = params[0];
   nameparams.add(new BasicNameValuePair("password", params[1]));
   nameparams.add(new BasicNameValuePair("android_id", params[2]));
   nameparams.add(new BasicNameValuePair("sign_in_device_type", AppConstants.DEVICE_TYPE));
   nameparams.add(new BasicNameValuePair("register_type", AppConstants.REGISTERTYPE));
   nameparams.add(new BasicNameValuePair("appkey", AppConstants.APPKEY));
   nameparams.add(new BasicNameValuePair("device_token", regId));
   nameparams.add(new BasicNameValuePair("device_id", AppConstants.getDeviceID(mHomePage)));
   nameparams.add(new BasicNameValuePair("phone_model", manufacturer + " " + model));
   nameparams.add(new BasicNameValuePair("os", androidOS));
   String result =
       WebHTTPMethodClass.executeHttPost("/user/login", nameparams); // loginService();
   return result;
 }
Example #2
0
    @Override
    protected void onPreExecute() {
      if (Tabbars.getInstance() != null
          && Tabbars.getInstance().getProgressDialog() != null
          && !Tabbars.getInstance().getProgressDialog().isShowing())
        Tabbars.getInstance().getProgressDialog().show();
      else if (RotiHomeActivity.getInstance() != null
          && RotiHomeActivity.getInstance().getProgressDialog() != null
          && !RotiHomeActivity.getInstance().getProgressDialog().isShowing())
        RotiHomeActivity.getInstance().getProgressDialog().show();
      // progressBar.setVisibility(View.VISIBLE);

    }
Example #3
0
  public void onCreate(boolean b, final String tabName) {
    isLovePrevPage = false;
    isInfo = b;
    mTabName = tabName;
    mHomePage = Tabbars.getInstance();

    //		Tracker tracker = GoogleAnalytics.getInstance(mHomePage).getTracker(
    //				AppConstants.GA_TRACK_ID);
    //		tracker.send(MapBuilder.createAppView()
    //				.set(Fields.SCREEN_NAME, "Email Login").build());

    if (mHomePage == null) mHomePage = RotiHomeActivity.getInstance();
    emailEdit = (EditText) mParentLayout.findViewById(R.id.login_edit_email);
    pwdEdit = (EditText) mParentLayout.findViewById(R.id.login_edit_password);
    TextView loginText = (TextView) mParentLayout.findViewById(R.id.loginText);
    TextView forgotPassword = (TextView) mParentLayout.findViewById(R.id.forgotPassword);
    //		ImageView signupFB = (ImageView) mParentLayout
    //				.findViewById(R.id.login_image_facebook);
    TextView topTitle = (TextView) mParentLayout.findViewById(R.id.topTitle);
    AppConstants.gothamNarrowMediumTextView(
        topTitle, 18, AppConstants.COLORWHITERGB, mHomePage.getAssets());

    AppConstants.fontDinLightTextView(
        loginText, 26, AppConstants.COLORBLACKRGB, mHomePage.getAssets());

    AppConstants.gothamNarrowBookTextView(
        forgotPassword, 14, AppConstants.COLOR_GRAY_TEXT, mHomePage.getAssets());

    AppConstants.gothamNarrowBookTextView(
        emailEdit, 13, AppConstants.COLOR_LIGHT_GRAY_TEXT, mHomePage.getAssets());
    AppConstants.gothamNarrowBookTextView(
        pwdEdit, 13, AppConstants.COLOR_LIGHT_GRAY_TEXT, mHomePage.getAssets());

    // progressBar = (ProgressBar) mParentLayout
    // .findViewById(R.id.greenProgressBar);

    //		emailEdit.setOnFocusChangeListener(new OnFocusChangeListener() {
    //
    //			@Override
    //			public void onFocusChange(View v, boolean hasFocus) {
    //				if (hasFocus)
    //					emailEdit.setBackgroundResource(R.drawable.formfield);
    //				else if (emailEdit.getText().toString().equals(""))
    //					emailEdit.setBackgroundResource(R.drawable.promo_btn_gray);
    //			}
    //		});
    //
    //		pwdEdit.setOnFocusChangeListener(new OnFocusChangeListener() {
    //
    //			@Override
    //			public void onFocusChange(View v, boolean hasFocus) {
    //				if (hasFocus)
    //					pwdEdit.setBackgroundResource(R.drawable.formfield);
    //				else if (pwdEdit.getText().toString().equals(""))
    //					pwdEdit.setBackgroundResource(R.drawable.promo_btn_gray);
    //			}
    //		});

    loginBtn = (ImageView) mParentLayout.findViewById(R.id.login_image_login);
    SetTextWatcherForAmountEditView(emailEdit);
    SetTextWatcherForAmountEditView(pwdEdit);
    // loginBtn.setBackgroundResource(R.drawable.log_in_btn_idle);
    loginBtn.setEnabled(false);

    // Login Feature implementation
    loginBtn.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            try {
              InputMethodManager inputManager =
                  (InputMethodManager) mHomePage.getSystemService(Activity.INPUT_METHOD_SERVICE);
              inputManager.hideSoftInputFromWindow(
                  emailEdit.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
            } catch (Exception e) {
            }
            String email = emailEdit.getText().toString();
            String mPassword = pwdEdit.getText().toString();
            String android_id = Secure.getString(mHomePage.getContentResolver(), Secure.ANDROID_ID);
            if (AppConstants.isNetworkAvailable(mHomePage)) {
              String[] param = new String[] {email, mPassword, android_id};
              // Login Async Task
              new submitLoginDetailsToServer().execute(param);
            } else {
              AppConstants.showMsgDialog("Alert", AppConstants.ERRORNETWORKCONNECTION, mHomePage);
            }
          }
        });

    //		signupFB.setOnClickListener(new OnClickListener() {
    //			@Override
    //			public void onClick(View v) {
    //				String mrefer = "0";
    //				String android_id = Secure.getString(
    //						mHomePage.getContentResolver(), Secure.ANDROID_ID);
    //				SharedPreferences preferences = PreferenceManager
    //						.getDefaultSharedPreferences(mHomePage);
    //				SharedPreferences.Editor editor = preferences.edit();
    //
    //				editor.putString("android_id", android_id);
    //				editor.commit();
    //
    //				if (AppConstants.isNetworkAvailable(mHomePage)) {
    //					// mHomePage.postMessage(false, mrefer);
    //					if (Tabbars.getInstance() != null) {
    //						Tabbars.getInstance().doNotFinishAllActivities = true;
    //						Tabbars tabbar = Tabbars.getInstance();
    //						tabbar.pageDestinationAfterFbLogin = pageDestination;
    //						tabbar.postMessage(false, mrefer);
    //					}
    //				} else {
    //					AppConstants.showMsgDialog("Alert",
    //							AppConstants.ERRORNETWORKCONNECTION, mHomePage);
    //				}
    //
    //			}
    //		});

    // Forget password implementation
    forgotPassword.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            try {
              InputMethodManager inputManager =
                  (InputMethodManager) mHomePage.getSystemService(Activity.INPUT_METHOD_SERVICE);
              inputManager.hideSoftInputFromWindow(
                  emailEdit.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
            } catch (Exception e) {
            }
            // Info.getInstance().showForgetPasswordPage(isInfo);
            if (tabName.equals("INFO") && Info.getInstance() != null) {
              Info.getInstance().showForgetPasswordPage(isInfo);
            } else if (tabName.equals("SNAP") && Snap.getInstance() != null) {
              Snap.getInstance().showForgetPasswordPage(isInfo);
            } else if (tabName.equals("ROTIHOMEACTIVITY")
                && RotiHomeActivity.getInstance() != null) {
              RotiHomeActivity.getInstance().showForgetPasswordPage(isInfo);
            } else if (tabName.equals("REWARDS") && Rewards.getInstance() != null) {
              Rewards.getInstance().showForgetPasswordPage(isInfo);
            }
          }
        });
  }
Example #4
0
    @Override
    protected void onPostExecute(String result) {
      if (Tabbars.getInstance() != null
          && Tabbars.getInstance().getProgressDialog() != null
          && Tabbars.getInstance().getProgressDialog().isShowing())
        Tabbars.getInstance().getProgressDialog().dismiss();
      else if (RotiHomeActivity.getInstance() != null
          && RotiHomeActivity.getInstance().getProgressDialog() != null
          && RotiHomeActivity.getInstance().getProgressDialog().isShowing())
        RotiHomeActivity.getInstance().getProgressDialog().dismiss();
      // progressBar.setVisibility(View.GONE);

      if (result != null && !result.equals("")) {
        try {
          JSONObject resObject = new JSONObject(result);
          String sucess = resObject.getString("status");
          if (sucess != null && !sucess.equals("") && sucess.equals("true")) {
            Editor prefsEditor = null;
            if (Tabbars.getInstance() != null)
              prefsEditor = Tabbars.getInstance().getPreferenceEditor();
            else if (RotiHomeActivity.getInstance() != null)
              prefsEditor = RotiHomeActivity.getInstance().getPreferenceEditor();
            // Editor prefsEditor = mHomePage.getPreferenceEditor();
            prefsEditor.putString(AppConstants.PREFLOGINID, mEmailID);
            prefsEditor.putBoolean(AppConstants.PREFLOGOUTBUTTONTAG, false);

            String auth_token = "";
            try {
              if (resObject.has("auth_token")) {
                auth_token = resObject.getString("auth_token");
                prefsEditor.putString(AppConstants.PREFAUTH_TOKEN, auth_token);
                Log.d("auth_token", auth_token);
              }
            } catch (Exception e) {
            }
            prefsEditor.commit();
            // mHomePage.popPreviousView();
            // mHomePage.handleBackButton();
            // mHomePage.setNextView();
            if (mTabName.equals("INFO") && Info.getInstance() != null) {
              // Info.getInstance().showLoginOptionPage(isInfo,
              // mTabName);
              Info.getInstance().popPreviousView();
              Info.getInstance().handleBackButton();
              if (!Info.getInstance().getNextViewName().equals("fetchReferralRequest"))
                Info.getInstance().handleBackButton();
              Info.getInstance().setNextView();
            } else if (mTabName.equals("SNAP") && Snap.getInstance() != null) {
              Snap.getInstance().popPreviousView();
              Snap.getInstance().handleBackButton();
              if (pageDestination.equals("scanReceiptBarcode"))
                Snap.getInstance().showScanBarcodePage();
              else Snap.getInstance().setNextView();
            } else if (mTabName.equals("ROTIHOMEACTIVITY")
                && RotiHomeActivity.getInstance() != null) {
              if (pageDestination.equals("referFriend")) {
                RotiHomeActivity.getInstance().popPreviousView();
                RotiHomeActivity.getInstance().handleBackButton();
                RotiHomeActivity.getInstance().showReferFriendPage("info");
              } else if (pageDestination.equals("getSocial")) {
                RotiHomeActivity.getInstance().popPreviousView();
                RotiHomeActivity.getInstance().handleBackButton();
                RotiHomeActivity.getInstance().showGetSocialPage();
              } else {
                RotiHomeActivity.getInstance().popPreviousView();
                RotiHomeActivity.getInstance().handleBackButton();
                RotiHomeActivity.getInstance().setNextView();
              }
            } else if (mTabName.equals("REWARDS")
                && Rewards.getInstance() != null
                && !isLovePrevPage) {
              Rewards.getInstance().popPreviousView();
              Rewards.getInstance().handleBackButton();
              Rewards.getInstance().setNextView();
            } else if (mTabName.equals("REWARDS")
                && isLovePrevPage
                && Info.getInstance() != null
                && RotiHomeActivity.getInstance() != null) {
              Info.getInstance().popPreviousView();
              Info.getInstance().handleBackButton();
              RotiHomeActivity.getInstance().oPenTabView(1);
            }
            // if (isInfo && Info.getInstance() != null)
            // Info.getInstance().showInfoMainPage();
          } else AppConstants.parseInput(result, mHomePage);
        } catch (Exception e) {
          AppConstants.parseInput(result, mHomePage);
          AppConstants.showMsgDialog("Alert", AppConstants.ERRORFAILEDAPI, mHomePage);
          e.printStackTrace();
        }
        // progressBar.setVisibility(ProgressBar.GONE);
      } else {
        AppConstants.parseInput(result, mHomePage);
        AppConstants.showMsgDialog("Alert", AppConstants.ERRORFAILEDAPI, mHomePage);
      }
    }