void UploadDocument() {

    if (llPhotoRow.getChildCount() <= 0 && documentList.size() <= 0) {

      Util.showToastMessage(mContext, "Please upload a document first", Toast.LENGTH_LONG);

    } else if (documentList != null
        && documentList.size() > 0
        && (documentList.get(0).contains("/"))) {

      relProgress.setVisibility(View.VISIBLE);
      UploadAllFilesTask uploadFiles = new UploadAllFilesTask();
      uploadFiles.context = mContext;
      // uploadFiles.szFileName = "iqra";
      // uploadFiles.szFilePath =
      // Environment.getExternalStorageDirectory()
      // + "/apk/iqra.jpg";// "/sdcard/apk/pic.jpg";
      uploadFiles.execute();

    } else {
      if (isDeleteSuccess && llPhotoRow.getChildCount() >= 1) {
        Util.setIsDocumentsUploaded(mContext, true);
        finish();
        Intent tutorialIntent = new Intent(mContext, TutorialActivity.class);
        if (bIsFromRegistration)
          tutorialIntent.putExtra(Constants.FROM_REGISTRATION_COMPLETE, true);
        startActivity(tutorialIntent);
      } else {
        Util.showToastMessage(mContext, "Please upload a document first", Toast.LENGTH_LONG);
      }

      // Util.showToastMessage(mContext, "No new document to upload",
      // Toast.LENGTH_LONG);
    }
  }
    @Override
    protected void onPostExecute(String result) {
      // TODO Auto-generated method stub
      super.onPostExecute(result);
      // if (progressUploadDocument != null) {
      // progressUploadDocument.dismiss();
      // }

      if (relProgress != null) {
        relProgress.setVisibility(View.GONE);
        textAddImage.setEnabled(true);
        tvUpload.setEnabled(true);
        tvSkip.setEnabled(true);
      }

      if (result != null && result.equals("success")) {
        Util.setIsDocumentsUploaded(mContext, true);
        finish();
        Intent tutorialIntent = new Intent(mContext, TutorialActivity.class);
        if (bIsFromRegistration)
          tutorialIntent.putExtra(Constants.FROM_REGISTRATION_COMPLETE, true);
        /*
         * As everytime any change in document will redirect to tutorial
         * screen
         */
        startActivity(tutorialIntent);
      } else {
        Util.setIsDocumentsUploaded(mContext, false);
      }
    }
    @Override
    protected void onPostExecute(String result) {
      // TODO Auto-generated method stub
      super.onPostExecute(result);

      if (result.equals("success")) {
        Util.showToastMessage(_context, "Link sent successfully", Toast.LENGTH_LONG);

      } else {
        Util.showToastMessage(_context, "Error occured, Please try again", Toast.LENGTH_LONG);
      }
    }
  void walkupPayment() {
    szEmailPhoneNumber = etEmailOrNumber.getText().toString().trim();
    if (szEmailPhoneNumber.isEmpty()) {
      if (isEmailSelected) {
        Util.showToastMessage(Util.mContext, "Please enter email address", Toast.LENGTH_LONG);
      } else if (isSMSselected) {
        Util.showToastMessage(
            Util.mContext, "Please enter mobile number for SMS", Toast.LENGTH_LONG);
      }
    } else {
      if (isEmailSelected && !szEmailPhoneNumber.matches(Constants.EMAIL_PATTERN)) {
        Util.showToastMessage(
            Util.mContext, "Please enter a valid email address", Toast.LENGTH_LONG);
      } else if (isSMSselected && szEmailPhoneNumber.length() < 10) {
        Util.showToastMessage(
            Util.mContext, "Please enter a valid mobile number", Toast.LENGTH_LONG);
      } else {
        sReceiptType = "";
        if (isEmailSelected) {
          sReceiptType = "email";
        } else if (isSMSselected) {
          sReceiptType = "sms";
        } else {
          sReceiptType = "none";
        }
        if (mBundle != null
            && mBundle.containsKey(Constants.JOB_ID)
            && mBundle.getString(Constants.JOB_ID) != null
            && !mBundle.getString(Constants.JOB_ID).isEmpty()) {
          sJobId = mBundle.getString(Constants.JOB_ID);
        }

        if (sJobId.isEmpty()) { // for walk up jobs
          if (isEmailSelected) {
            sMobileNo = "";
            sInternationalNo = "";
            sEmail = szEmailPhoneNumber;
          } else if (isSMSselected) {
            sMobileNo = szEmailPhoneNumber;
            if (AppValues.driverDetails != null
                && AppValues.driverDetails.getInternationalCode() != null)
              sInternationalNo = AppValues.driverDetails.getInternationalCode();
            sEmail = "";
          }
          sPickUp = "";
          sDropOff = "";
        }
        ProceedWithSendURL();
      }
    }
  }
  @Override
  protected void onPostExecute(String result) {
    // TODO Auto-generated method stub
    super.onPostExecute(result);
    if (pDialog != null) pDialog.dismiss();

    if (result.contains("success")) {
      Util.showToastMessage(Util.mContext, "Payment done successfully", Toast.LENGTH_LONG);
    } else {
      Log.e(TAG, "Error fetching data: " + result);
      Toast.makeText(Util.mContext, result, Toast.LENGTH_LONG).show();
    }

    // Pass value of
    // {"response":"success","cashbackValue":0,"bookingId":246}
    if (mHandler != null) {
      Message msg = Message.obtain();
      Bundle b = new Bundle();
      b.putBoolean("success", true);
      b.putString("jobId", jobId);
      b.putLong("cashBackReturned", cashBackReturned);
      Log.e(TAG, "b: " + b.toString());
      msg.setData(b);
      msg.what = 2;
      mHandler.sendMessage(msg);
      // mHandler.sendEmptyMessage(2);
    }
  }
  void ProceedWithSendURL() {

    sMeterValue = mBundle.getString(Constants.METER_VALUE);
    sTipValue = mBundle.getString(Constants.TIP_VALUE);
    sCardFees = mBundle.getString(Constants.CARD_FEE_VALUE);
    sTotalAmt = mBundle.getString(Constants.TOTAL_VALUE);

    if (NetworkUtil.isNetworkOn(Util.mContext)) {

      rlWalkUpLayout.setVisibility(View.GONE);
      rlResendLayout.setVisibility(View.VISIBLE);

      SendURLforPaymentTask sendURLTask = new SendURLforPaymentTask();
      sendURLTask.szMeterValue = sMeterValue;
      sendURLTask.szTipValue = sTipValue;
      sendURLTask.szCardFees = sCardFees;
      sendURLTask.szTotalAmt = sTotalAmt;
      sendURLTask.szJobId = sJobId;
      sendURLTask.szReceiptType = sReceiptType;
      sendURLTask.szMobileNumber = sMobileNo;
      sendURLTask.szInternationalCode = sInternationalNo;
      sendURLTask.szEmail = sEmail;
      sendURLTask.szPickUpAddress = sPickUp;
      sendURLTask.szDropOffAddress = sDropOff;
      sendURLTask.currency = AppValues.driverSettings.getCurrencySymbol();
      sendURLTask.currencyCode = AppValues.driverSettings.getCurrencyCode();
      sendURLTask.execute();
    } else {
      Util.showToastMessage(
          _context, getResources().getString(R.string.no_network_error), Toast.LENGTH_LONG);
    }
  }
    @Override
    protected String doInBackground(String... params) {
      // TODO Auto-generated method stub
      if (Constants.isDebug)
        Log.e(TAG, "szEmail: " + szEmail + "     szMobileNumber:   " + szMobileNumber);
      PaymentWithURL sendPaymentUrl =
          new PaymentWithURL(
              _context,
              szMeterValue,
              szTipValue,
              szCardFees,
              szTotalAmt,
              szJobId,
              szReceiptType,
              szMobileNumber,
              szInternationalCode,
              szEmail,
              szPickUpAddress,
              szDropOffAddress,
              currency,
              currencyCode);
      String response = sendPaymentUrl.SendPaymentUrlToCustomer();

      if (Constants.isDebug) Log.e(TAG, "SendURLforPaymentTask response::> " + response);

      try {
        JSONObject jObject = new JSONObject(response);
        String errorMessage = "";
        if (jObject.has("response") && jObject.getString("response").equals("success")) {

          /*
           * update cash back value and booking id
           */
          szReturnedBookingId = jObject.getString("bookingId");
          Util.setCashBack(_context, jObject.getString("cashbackValue"));
          return "success";

        } else if (jObject.has("response") && jObject.getString("response").equals("false")) {
          errorMessage = jObject.getString("error");
          return errorMessage;
        } else {
          if (jObject.has("errors")) {
            JSONArray jErrorsArray = jObject.getJSONArray("errors");

            errorMessage = jErrorsArray.getJSONObject(0).getString("message");
            return errorMessage;
          }
        }
      } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

      return response;
    }
    @Override
    protected void onPostExecute(String result) {
      // TODO Auto-generated method stub
      super.onPostExecute(result);

      // etEmailOrNumber.setText("");
      if (result.equals("true")) {
        Util.showToastMessage(_context, "Payment done successfully", Toast.LENGTH_LONG);
        /* on success redirect to jobs screen */
        finish();
        Fragment fragment = null;
        fragment = new com.android.cabapp.fragments.JobsFragment();
        ((MainActivity) Util.mContext).setSlidingMenuPosition(Constants.JOBS_FRAGMENT);
        if (fragment != null) ((MainActivity) Util.mContext).replaceFragment(fragment, true);
      } else if (result.equals("false")) {
        Util.showToastMessage(_context, "Your payment has not received", Toast.LENGTH_LONG);
      } else {
        Util.showToastMessage(_context, "Error occured, Please try again", Toast.LENGTH_LONG);
      }
    }
    @Override
    protected void onPostExecute(String result) {
      // TODO Auto-generated method stub
      super.onPostExecute(result);
      if (progressUploadDocument != null) progressUploadDocument.dismiss();

      // On delete of any document
      ivBack.setVisibility(View.GONE);
      isDeleteSuccess = true;

      if (result != null && result.equals("success")) {
        llPhotoRow.removeView(docDetails.view);
        documentList.remove(docDetails.szDocumentID);
      } else Util.showToastMessage(mContext, result, Toast.LENGTH_LONG);
    }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_document_upload);
    super.initWidgets();
    mContext = this;
    documentBundle = getIntent().getExtras();

    documentList = new ArrayList<String>();
    ivBack.setVisibility(View.GONE);
    llPhotoRow = (LinearLayout) findViewById(R.id.llLicencingDocumentRow);
    textAddImage = (TextView) findViewById(R.id.tvAddImage);
    tvUpload = (TextView) findViewById(R.id.tvUpload);
    tvSkip = (TextView) findViewById(R.id.tvSkip);
    tvSkip.setVisibility(View.GONE);
    tvLicensingDocument = (TextView) findViewById(R.id.tvLicensingDocument);
    rlTopPoint = (RelativeLayout) findViewById(R.id.rlTopPoint);
    tvLicensingDocumentText = (TextView) findViewById(R.id.tvLicensingDocumentText);

    relProgress = (RelativeLayout) findViewById(R.id.rel_progress_sync);
    progressBar = (ProgressBar) findViewById(R.id.progress_sync);
    progressText = (TextView) findViewById(R.id.tv_progress);

    tvUpload.setText("Complete registration");

    progressText = (TextView) findViewById(R.id.tv_progress);

    txtEdit = (TextView) findViewById(R.id.tvEdit);
    txtEdit.setVisibility(View.GONE);
    if (((LinearLayout) llPhotoRow).getChildCount() > 0)
      ((LinearLayout) llPhotoRow).removeAllViews();

    if (AppValues.driverSettings != null && AppValues.driverSettings.getDriverDocuments() != null)
      szDriverDocument = AppValues.driverSettings.getDriverDocuments();

    if (AppValues.driverSettings != null
        && AppValues.driverSettings.getDriverDocumentsList() != null)
      szDriverDocumentsList = AppValues.driverSettings.getDriverDocumentsList();
    tvLicensingDocumentText.setText(" " + szDriverDocumentsList + " ");

    if (mContext != null) {
      szDriverDocument = Util.getDriverDocument(mContext);
      szDriverDocumentsList = Util.getDriverDocumentsList(mContext);
      if (!szDriverDocumentsList.toString().isEmpty())
        tvLicensingDocumentText.setText(" " + szDriverDocumentsList + " ");
    }

    if (documentBundle != null) {
      if (documentBundle.containsKey(Constants.FROM_REGISTRATION_COMPLETE)
          && documentBundle.getBoolean(Constants.FROM_REGISTRATION_COMPLETE)) {
        bIsFromRegistration = documentBundle.getBoolean(Constants.FROM_REGISTRATION_COMPLETE);
      }

      if (documentBundle.containsKey(Constants.FROM_EDIT_MY_ACC_VECHILE_DETAILS)) {
        isComingFromEditMyAccount =
            documentBundle.getBoolean(Constants.FROM_EDIT_MY_ACC_VECHILE_DETAILS);

        if (isComingFromEditMyAccount) {
          tvSkip.setVisibility(View.GONE);
          ivBack.setVisibility(View.VISIBLE);
          rlTopPoint.setVisibility(View.GONE);
          tvUpload.setText("Save");
          tvLicensingDocument.setText("* LICENSING DOCUMENT");

          AlertDialog PendingAlertDialog =
              new AlertDialog.Builder(mContext)
                  .setMessage(
                      "Adding or deleting documents will put your account in pending state.")
                  .setPositiveButton(
                      "OK",
                      new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface argDialog, int argWhich) {}
                      })
                  .create();
          PendingAlertDialog.setCanceledOnTouchOutside(false);
          PendingAlertDialog.show();

          List<Document> documentDetails = AppValues.driverDetails.getDocument();

          if (AppValues.driverDetails != null
              && documentDetails != null
              && documentDetails.size() > 0) {
            for (int i = 0; i < documentDetails.size(); i++) {

              LayoutInflater inflater = LayoutInflater.from(getBaseContext());
              viewAddPhoto = inflater.inflate(R.layout.row_attached_files, null);

              TextView tvAttachedFileName =
                  (TextView) viewAddPhoto.findViewById(R.id.tvAttachedFileName);
              // TextView tvFileSize = (TextView) viewAddPhoto
              // .findViewById(R.id.tvFileSize);

              ImageView ivCancel = (ImageView) viewAddPhoto.findViewById(R.id.ivCancel);
              ImageView ivThumbnail = (ImageView) viewAddPhoto.findViewById(R.id.ivThumbnail);

              ImageLoader.getInstance()
                  .displayImage(documentDetails.get(i).getThumbnail(), ivThumbnail);

              if (Constants.isDebug)
                Log.e(
                    "DocumentUploadActivity", "Filename:: " + documentDetails.get(i).getFilename());
              tvAttachedFileName.setText(documentDetails.get(i).getFilename());
              // tvFileSize.setText("");// + " kb"

              DocumentDetails details = new DocumentDetails();
              details.szFilePath = "";
              details.view = viewAddPhoto;
              details.szDocumentID = documentDetails.get(i).getId();
              documentList.add(details.szDocumentID);
              ivCancel.setTag(details);

              ivCancel.setOnClickListener(
                  new OnClickListener() {

                    @Override
                    public void onClick(final View v) {
                      // TODO Auto-generated method stub
                      AlertDialog.Builder builder =
                          new AlertDialog.Builder(DocumentUploadActivity.this);
                      builder
                          .setMessage("Are you sure you want to delete document?")
                          .setCancelable(false)
                          .setPositiveButton(
                              getString(android.R.string.ok),
                              new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int id) {
                                  DeleteDocumentTask deleteTask = new DeleteDocumentTask();
                                  deleteTask.documentView = v;
                                  deleteTask.execute();
                                }
                              })
                          .setNegativeButton(
                              getString(android.R.string.cancel),
                              new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int id) {
                                  dialog.cancel();
                                }
                              });
                      builder.setTitle("Alert");
                      AlertDialog alert = builder.create();
                      alert.show();
                    }
                  });

              llPhotoRow.addView(viewAddPhoto);
            }
          }
        }
      }
    }
    tvSkip.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            finish();
            // Intent tutorialIntent = new Intent(mContext,
            // TutorialActivity.class);
            // startActivity(tutorialIntent);
          }
        });

    textAddImage.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            int maxUpload = 0;
            maxUpload = Integer.valueOf(szDriverDocument);
            if (llPhotoRow.getChildCount() < maxUpload) {

              AlertDialog.Builder builder = new AlertDialog.Builder(DocumentUploadActivity.this);
              builder.setItems(R.array.add_image_options_upload_documents, mDialogListener);
              AlertDialog dialog = builder.create();
              dialog.show();
            } else {
              Util.showToastMessage(
                  DocumentUploadActivity.this,
                  "Maximum document limit is " + maxUpload,
                  Toast.LENGTH_LONG);
            }
          }
        });

    tvUpload.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            // code for upload
            if (isComingFromEditMyAccount) { // tvUpload.getText().equals("Save")

              if (llPhotoRow.getChildCount() <= 0 && documentList.size() <= 0) {

                Util.showToastMessage(
                    mContext, "Please upload a document first", Toast.LENGTH_LONG);

              } else {
                UploadDocument();

                // final Dialog dialog = new Dialog(mContext,
                // R.style.mydialogstyle);
                // dialog.setContentView(R.layout.confirmation_dialog);
                // dialog.setCanceledOnTouchOutside(false);
                // // dialog.setTitle("Alert!!");
                // dialog.setCancelable(false);
                // dialog.show();
                //
                // TextView tvAlertText = (TextView) dialog
                // .findViewById(R.id.tvAlertText);
                // tvAlertText.setText("");
                // textYes = (TextView) dialog.findViewById(R.id.tvYes);
                // textNo = (TextView) dialog.findViewById(R.id.tvNo);
                // textNo.setOnClickListener(new OnClickListener() {
                //
                // @Override
                // public void onClick(View v) {
                // // TODO Auto-generated method stub
                // dialog.dismiss();
                // }
                // });
                // textYes.setOnClickListener(new OnClickListener() {
                //
                // @Override
                // public void onClick(View v) {
                // // TODO Auto-generated method stub
                // dialog.dismiss();
                // UploadDocument();
                // }
                // });
              }
            } else {
              UploadDocument();
            }
          }
        });
  }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    String imagePath = "";
    String fileName = "";
    long file_size = 0;
    if (resultCode == RESULT_OK) {
      if (requestCode == TAKE_PHOTO_REQUEST) {
        // camera picture
        imagePath = cameraFile.getPath();
        file_size = Integer.parseInt(String.valueOf(cameraFile.length() / 1024));
        if (Constants.isDebug) Log.i(TAG, "Camera Path::>  " + imagePath);

      } else if (requestCode == PICK_PHOTO_REQUEST) {
        // gallery
        Uri selectedImageUri = intent.getData();
        imagePath = getPath(selectedImageUri);
        if (Constants.isDebug) Log.i(TAG, "Gallery Path::>  " + imagePath);

        // File galleryFile = new File(imagePath);
        // file_size = Integer.parseInt(String.valueOf(galleryFile
        // .length() / 1024));

        if (imagePath != null
            && (imagePath.endsWith("mp4")
                || imagePath.endsWith("wmv")
                || imagePath.endsWith("avi"))) {
          Util.showToastMessage(
              DocumentUploadActivity.this, "Video file not supported!", Toast.LENGTH_LONG);
          return;
        }
      }

      if (documentList == null) documentList = new ArrayList<String>();

      if (documentList != null
          && documentList.size() > 0
          && documentList.get(0) != null
          && !documentList.get(0).contains("/")) documentList.clear();

      fileName = extractFileNameFromString(imagePath);

      // Adding new row:
      LayoutInflater inflater = LayoutInflater.from(getBaseContext());
      viewAddPhoto = inflater.inflate(R.layout.row_attached_files, null);

      TextView tvAttachedFileName = (TextView) viewAddPhoto.findViewById(R.id.tvAttachedFileName);
      // TextView tvFileSize = (TextView) viewAddPhoto
      // .findViewById(R.id.tvFileSize);

      ImageView ivCancel = (ImageView) viewAddPhoto.findViewById(R.id.ivCancel);
      ImageView ivThumbnail = (ImageView) viewAddPhoto.findViewById(R.id.ivThumbnail);

      ImageLoader.getInstance().displayImage("file://" + imagePath, ivThumbnail);

      DocumentDetails details = new DocumentDetails();
      details.szFilePath = imagePath;
      details.view = viewAddPhoto;

      ivCancel.setTag(details);

      ivCancel.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              // TODO Auto-generated method stub
              DocumentDetails details = (DocumentDetails) v.getTag();
              llPhotoRow.removeView(details.view);
              documentList.remove(details.szFilePath);
            }
          });

      tvAttachedFileName.setText(fileName);
      // if (file_size > 0) {
      // tvFileSize.setText(String.valueOf(file_size) + " kb");
      // } else {
      // tvFileSize.setText("0 kb");
      // }

      llPhotoRow.addView(viewAddPhoto);
      documentList.add(imagePath);

    } else if (resultCode != RESULT_CANCELED) {
      Util.showToastMessage(mContext, "Sorry, there was an error", Toast.LENGTH_LONG);
    }
  }
示例#12
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    // set the content view
    setContentView(R.layout.activity_main);
    // configure the SlidingMenu
    Util.mContext = mMainActivityContext = this;
    slidingMenu = new SlidingMenu(this);
    slidingMenu.setMode(SlidingMenu.LEFT);
    slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    // slidingMenu.setShadowWidthRes(R.dimen.shadow_width);
    // slidingMenu.setShadowDrawable(R.drawable.shadow);
    slidingMenu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    slidingMenu.setFadeDegree(0.35f);
    slidingMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
    slidingMenu.setMenu(R.layout.slidingmenu);

    mDrawerList = (ListView) findViewById(R.id.list_slidermenu);
    textUserName = (TextView) findViewById(R.id.txtUserName);

    rllistTopbar = (RelativeLayout) findViewById(R.id.list_topbar);
    // textMyAccount = (TextView) findViewById(R.id.txtMyAccount);
    tvCreditNumbers = (TextView) findViewById(R.id.tvCreditNumbers);
    textAddCredits = (TextView) findViewById(R.id.tvAddCredits);
    tvCreditNumbers.setText(String.valueOf(Util.getNumberOfCredits(MainActivity.this)));

    tvPromoCode = (TextView) findViewById(R.id.tvPromoCode);
    tvYourPromoCode = (TextView) findViewById(R.id.tvYourPromoCode);
    tvShare = (TextView) findViewById(R.id.tvShare);
    String szYourPromoCodeText =
        " <font color=#a1a1a1>Your </font><font color=#fd6f01> Promo Code </font>";
    tvYourPromoCode.setText(Html.fromHtml(szYourPromoCodeText));
    tvShare.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            cashBackClick();
          }
        });

    rllistTopbar.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            nSlidingMenuItemPosition = Constants.MY_ACCOUNT_FRAGMENT;
            slidingMenu.toggle();
          }
        });
    textAddCredits.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            nSlidingMenuItemPosition = Constants.BUY_ADD_CREDITS_FRAGMENT;
            slidingMenu.toggle();
          }
        });

    // load slide menu items
    navMenuTitles = getResources().getStringArray(R.array.nav_drawer_items);

    // nav drawer icons from resources
    navMenuIcons = getResources().obtainTypedArray(R.array.nav_drawer_icons);

    navDrawerItems = new ArrayList<NavDrawerItem>();

    for (int i = 0; i < navBadgeCount.length; i++) {
      navDrawerItems.add(
          new NavDrawerItem(
              navMenuTitles[i],
              navMenuIcons.getResourceId(i, -1),
              !navBadgeCount[i].equals(""),
              navBadgeCount[i]));
    }
    // adding nav drawer items to array

    // Recycle the typed array
    navMenuIcons.recycle();

    mDrawerList.setOnItemClickListener(new SlideMenuClickListener());

    // setting the nav drawer list adapter
    navdrawerAdapter = new NavDrawerListAdapter(getApplicationContext(), navDrawerItems);
    mDrawerList.setAdapter(navdrawerAdapter);
    mDrawerList.setItemChecked(0, true);
    mDrawerList.setSelection(0);

    displayView(0);

    slidingMenu.setOnOpenedListener(
        new OnOpenedListener() {

          @Override
          public void onOpened() {
            // TODO Auto-generated method stub
            if (!Util.getIsOverlaySeen(mMainActivityContext, TAG)) {
              Intent intent = new Intent(MainActivity.this, MyJobsOverlayActivity.class);
              startActivity(intent);
            }

            if (AppValues.driverDetails != null) {

              if (Constants.isDebug)
                Log.e("MainActivity", "FirstName:" + AppValues.driverDetails.getFirstname());
              textUserName.setText(AppValues.driverDetails.getFirstname());
            }

            Util.hideSoftKeyBoard(Util.mContext, textUserName);
            if (AppValues.driverSettings != null && AppValues.driverSettings.getPromoCode() != null)
              tvPromoCode.setText(AppValues.driverSettings.getPromoCode());
          }
        });

    slidingMenu.setOnClosedListener(
        new OnClosedListener() {

          @Override
          public void onClosed() {
            // TODO Auto-generated method stub
            if (nSlidingMenuItemPosition != -1) {
              displayView(nSlidingMenuItemPosition);
              nSlidingMenuItemPosition = -1;
            }
          }
        });

    creditsRefreshHandler =
        new Handler() {
          @Override
          public void handleMessage(Message message) {
            super.handleMessage(message);

            if (message.what == 0) {
              if (tvCreditNumbers != null) {
                tvCreditNumbers.setText(String.valueOf(Util.getNumberOfCredits(MainActivity.this)));
              }
            }
          }
        };

    if (getIntent().getExtras() != null) {
      if (getIntent().getExtras().containsKey("appislaunchingfresh")) {
        if (!handlePush(getIntent())) {
          Fragment fragment = new com.android.cabapp.fragments.JobsFragment();
          replaceFragment(fragment, false);
          setSlidingMenuPosition(Constants.JOBS_FRAGMENT);
        }
      }
    }
  }
    @Override
    public void onClick(View v) {
      // TODO Auto-generated method stub
      switch (v.getId()) {
        case R.id.rlSendUrl:
          ivBack.setVisibility(View.GONE);
          Util.hideSoftKeyBoard(_context, tvSendUrl);
          if (sJobId.isEmpty()) { // walk up validation
            walkupPayment();
          } else { // hail jobs
            sReceiptType = "";
            szEmailPhoneNumber = etEmailOrNumber.getText().toString().trim();
            if (isEmailSelected) {
              sReceiptType = "email";
              sEmail = szEmailPhoneNumber;
            } else if (isSMSselected) {
              sReceiptType = "sms";
              sMobileNo = szEmailPhoneNumber;
            } else {
              sReceiptType = "none";
            }
            ProceedWithSendURL();
          }

          break;

        case R.id.ivBack:
          finish();
          break;

        case R.id.rlEmail:
          isEmailSelected = true;
          isSMSselected = false;
          etEmailOrNumber.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
          toogleReceiptMethod(textEmail);
          if (sEmail != null && !sEmail.isEmpty()) {
            etEmailOrNumber.setText(sEmail);
            etEmailOrNumber.setSelection(etEmailOrNumber.getText().length());
          }
          break;

        case R.id.rlSMS:
          isEmailSelected = false;
          isSMSselected = true;
          etEmailOrNumber.setInputType(InputType.TYPE_CLASS_PHONE);
          toogleReceiptMethod(textSMS);
          if (sMobileNo != null && !sMobileNo.isEmpty()) {
            etEmailOrNumber.setSelection(etEmailOrNumber.getText().length());
            etEmailOrNumber.setText(sMobileNo);
          }
          break;

        case R.id.rlResend:
          ivBack.setVisibility(View.VISIBLE);
          rlWalkUpLayout.setVisibility(View.VISIBLE);
          rlResendLayout.setVisibility(View.GONE);
          sJobId = szReturnedBookingId;
          break;

        case R.id.rlConfirm:
          GetPaymentStatusTask getPaymentStatusTask = new GetPaymentStatusTask();
          getPaymentStatusTask.execute();

          break;

        case R.id.radioBtnEmail:
          isEmailSelected = true;
          isSMSselected = false;
          break;

        case R.id.radioBtnSms:
          isEmailSelected = false;
          isSMSselected = true;
          break;
      }
    }