private void saveEvent() { String title = etTitle.getText().toString(); String desc = etDesc.getText().toString(); String startDate = bStartDate.getText().toString(); String endDate = bEndDate.getText().toString(); Event event = new Event(); event.setEvent_name(title); event.setEvent_details(desc); event.setStart_time(startDate); event.setEnd_time(endDate); event.setUser_id(Session.loggedUser.getId()); // TODO Support Event Location eventRESTClient .createEvent(event) .enqueue( new Callback<Event>() { @Override public void onResponse(Response<Event> response, Retrofit retrofit) { Log.d(TAG, "Event created!"); setResult(RESULT_OK); finish(); } @Override public void onFailure(Throwable t) { Log.e(TAG, "Problem creating/updating the event"); t.printStackTrace(); Toast.makeText(AddEventActivity.this, "Event created/updated!", Toast.LENGTH_SHORT) .show(); } }); }
private void getEventDetails() { final LayoutInflater inflater = LayoutInflater.from(this); eventRESTClient .getEventById(eventId) .enqueue( new Callback<Event>() { @Override public void onResponse(Response<Event> response, Retrofit retrofit) { Log.d(TAG, "Got event details."); Log.d(TAG, "" + response.body()); Event event = response.body(); tvEventTitle.setText("" + event.getEvent_name()); tvEventDesc.setText("" + event.getEvent_details()); tvEventStart.setText("Starts on: " + event.getStart_time()); tvEventEnd.setText("Ends on: " + event.getEnd_time()); userListView.removeAllViews(); // TODO Support location and user list for (int i = 0; i < event.getUsers().size(); i++) { final User user = event.getUsers().get(i); View view = inflater.inflate( R.layout.row_user, new LinearLayout(EventDetailsActivity.this)); TextView tvUserName = (TextView) view.findViewById(R.id.tvUserName); TextView tvTagline = (TextView) view.findViewById(R.id.tvTagline); tvUserName.setText(user.getName()); tvTagline.setText(user.getTagline()); ImageView dp = (ImageView) view.findViewById(R.id.ivUser); if (user.getDpUrl() != null && user.getDpUrl().length() != 0) { Picasso.with(EventDetailsActivity.this) .load(user.getDpUrl()) .placeholder(R.drawable.user_placeholder) .into(dp); } view.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(EventDetailsActivity.this, UserDetailsActivity.class); intent.putExtra("id", user.getId()); intent.putExtra("name", user.getName()); intent.putExtra("tag", user.getTagline()); intent.putExtra("dp", user.getDpUrl()); startActivity(intent); } }); userListView.addView(view); } } @Override public void onFailure(Throwable t) { Log.e(TAG, "Problem getting the event"); t.printStackTrace(); } }); }