Example #1
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);
            }
          }
        });
  }