public void onEventMainThread(UserPortraitUploadEvent event) {
    if (!isValidEvent(event)) {
      return;
    }

    if (event.isFailed()) {
      try {
        storeToCacheAndLaunchEvent(false, event, event.getUserId(), event.getPicturePath());
      } catch (Exception e) {
        notifyError(event);
      }
    } else {
      if (event.isRemote()) {
        store(true, event.getUserId(), event.getPicturePath());
      }

      User oldLoggedUser = SessionContext.getLoggedUser();

      if (event.getJSONObject() != null) {
        User user = new User(event.getJSONObject());
        if (oldLoggedUser != null && user.getId() == oldLoggedUser.getId()) {
          SessionContext.setLoggedUser(user);
        }
      }

      try {
        getListener().onUserPortraitUploaded(oldLoggedUser.getId());
      } catch (Exception e) {
        getListener().onUserPortraitUploadFailure(e);
      }
    }
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    Log.v(TAG, "Going to store session");
    SessionContext.storeSession(CredentialsStoreBuilder.StorageType.SHARED_PREFERENCES);
    Log.v(TAG, "session stored");
    _user = SessionContext.getLoggedUser();

    View view = inflater.inflate(R.layout.fragment_home, container, false);
    welcomeHomeId = (TextView) view.findViewById(R.id.welcomeHomeId);
    travelDate = (Button) view.findViewById(R.id.travelDateId);
    fromLocation = (Spinner) view.findViewById(R.id.fromLocationId);
    toLocation = (Spinner) view.findViewById(R.id.toLocationId);
    findBusesButton = (Button) view.findViewById(R.id.findBusId);
    findBusesButton.setOnClickListener(this);
    travelDate.setOnClickListener(this);

    if (_user != null) {
      Log.v(TAG, "In Home user is " + _user.getEmail());
      welcomeHomeId.setText("Welcome " + _user.getFirstName());
    }

    ArrayAdapter<Locations> fromLocationsAdapter =
        new ArrayAdapter<Locations>(
            getActivity(), android.R.layout.simple_spinner_item, Locations.fromLocationsArray);
    fromLocationsAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    fromLocation.setAdapter(fromLocationsAdapter);
    fromLocation.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            Log.v(TAG, "From Drop down clicked ");
            Locations location = (Locations) parent.getItemAtPosition(position);
            Log.v(TAG, "Got location ");
            fromLocationId = location.getLocationId();
            Log.v(TAG, "Selected from location id is " + fromLocationId);
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {}
        });

    ArrayAdapter<Locations> toLocationsAdapter =
        new ArrayAdapter<Locations>(
            getActivity(), android.R.layout.simple_spinner_item, Locations.toLocationsArray);
    toLocationsAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    toLocation.setAdapter(toLocationsAdapter);
    toLocation.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            Locations location = (Locations) parent.getItemAtPosition(position);
            toLocationId = location.getLocationId();
            Log.v(TAG, "Selected to location id is " + toLocationId);
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {}
        });

    return view;
  }