private void uploadUserDetails(String registrationId, String instanceId) {

    SharedPreferences sharedPreferences =
        StudentAssistApplication.getAppContext()
            .getSharedPreferences(SAConstants.sharedPreferenceName, 0);

    // setting GCM id to user and storing it into shared preferences
    SharedPreferences.Editor editor = sharedPreferences.edit();
    editor.putString(SAConstants.GCM_ID, registrationId);
    editor.putString(SAConstants.INSTANCE_ID, instanceId);
    editor.commit();

    String fbToken = "";

    if (AccessToken.getCurrentAccessToken() != null
        && !AccessToken.getCurrentAccessToken().isExpired()) {

      fbToken = AccessToken.getCurrentAccessToken().getToken();
    } else {
      Toast.makeText(StudentAssistApplication.getAppContext(), "not registered", Toast.LENGTH_LONG)
          .show();
    }

    UrlInterface urlGen = new UrlGenerator();
    try {

      String url = urlGen.createUser(fbToken, instanceId);

      new NotificationBO(
          new NotificationBI() {
            @Override
            public void onResponse(String response) {

              L.m("successfully created user");
            }
          },
          url);

    } catch (Exception e) {
      ErrorReporting.logReport(e);
    }
  }
  /**
   * Populate right spinner and frame accommodationAdds Recycler View URL
   *
   * @param parent
   * @param spinnerView
   * @param position
   * @param spinnerId
   */
  @Override
  public void onItemSelected(
      AdapterView<?> parent, View spinnerView, int position, long spinnerId) {

    try {

      String accommodationAddsUrl = "";

      // left spinner selected
      if (parent.getId() == R.id.leftSpinner) {

        String leftSpinnerValue = leftSpinner.getSelectedItem().toString();

        // condition to check for indefinite firing of onItemSelected listener. If the onClick is
        // called with the spinner
        // containing the same selected value, this if condition filters it
        if (!leftSpinnerSameVal.equals(leftSpinnerValue)) {

          leftSpinnerSameVal = leftSpinnerValue;

          // populating the right side spinner
          final ArrayAdapter<String> rightSpinnerAdapter =
              (ArrayAdapter<String>) rightSpinner.getAdapter();
          rightSpinnerAdapter.clear();

          // Populating the spinners from data that is present in the Activity.
          final AccommodationActivity mActivity = (AccommodationActivity) getActivity();
          final String rightSpinnerValues[] =
              mActivity.spinnerInformation.get(parent.getItemAtPosition(position));

          // When apartmentName is selected in left Spinner. We need to populate the right spinner
          // with Apartment Names. These are fetched
          // from the parent Activity.
          if (rightSpinnerValues == null || rightSpinnerValues.length < 1) {

            // Response from the parnet activity containing data to load the spinners with.
            mActivity.getApartmentNames(
                new AccommodationActivityToFragmentInterface() {
                  @Override
                  public void onApartmentNamesListReady(String[] apartmentStringArray) {

                    rightSpinnerAdapter.addAll(apartmentStringArray);
                    rightSpinnerAdapter.notifyDataSetChanged();

                    if (reEntryFlag) {
                      rightSpinner.setSelection(bundle.getInt(SAConstants.RIGHT_SPINNER), false);
                    } else {
                      rightSpinner.setSelection(0, false);
                    }
                  }
                });

            // Else condition when ApartmentType/Gender is selected in the left spinner
          } else {

            // adding the data to spinner adapters
            rightSpinnerAdapter.addAll(rightSpinnerValues);
            rightSpinnerAdapter.notifyDataSetChanged();

            // Setting the selected item of the spinner to restore the previous state of fragment.
            if (reEntryFlag) {
              rightSpinner.setSelection(bundle.getInt(SAConstants.RIGHT_SPINNER), false);
            } else {
              rightSpinner.setSelection(0, false);
            }
            String rightSpinnerValue = rightSpinner.getSelectedItem().toString();
            accommodationAddsUrl =
                urlGen.getSearchAccommodationAdds(
                    leftSpinner.getSelectedItem().toString(), rightSpinnerValue);
            if (adds.size() < 1) {
              getFromServer(
                  accommodationAddsUrl,
                  leftSpinner.getSelectedItem().toString(),
                  rightSpinnerValue);
            } else {
              populateRecyclerView(adds);
            }
          }
        }

        // Right Spinner selected
      } else {

        String rightSpinnerValue = rightSpinner.getSelectedItem().toString();

        // Checking firing of onItemCLick listener for same value
        if (!rightSpinnerSameVal.equals(rightSpinnerValue)) {

          rightSpinnerSameVal = rightSpinnerValue;

          accommodationAddsUrl =
              urlGen.getSearchAccommodationAdds(
                  leftSpinner.getSelectedItem().toString(), rightSpinnerValue);
          if (reEntryFlag) {
            populateRecyclerView(adds);

          } else {
            getFromServer(
                accommodationAddsUrl, leftSpinner.getSelectedItem().toString(), rightSpinnerValue);
          }
        }
      }
    } catch (UnsupportedEncodingException e) {
      ErrorReporting.logReport(e);
    }
  }