/** * @param proxy A proxy to a remote object implementing an UserActivity * @return A local UserActivity object containing the data of the remote object referenced by * proxy */ public static UserActivity extractObject(UserActivityTypPrx proxy) { return new UserActivity( proxy.getActivityUser(), proxy.getActivityTrip(), proxy.getUserActivityType(), proxy.getTimeStampInMillis()); }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder = null; UserActivityTypPrx rowItem = getItem(position); LayoutInflater mInflater = (LayoutInflater) _context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); if (convertView == null) { convertView = mInflater.inflate(_resource, null); holder = new ViewHolder(); holder.imageView = (ImageView) convertView.findViewById(_imageProjectionView); holder.txtTitle = (TextView) convertView.findViewById(_textProjectionView); holder.txtSubtitle = (TextView) convertView.findViewById(_subtextProjectionView); convertView.setTag(holder); } else holder = (ViewHolder) convertView.getTag(); byte[] avatarBytes = null; if (rowItem.getUserActivityType() == ActivityType.TRIPJOIN || rowItem.getUserActivityType() == ActivityType.TRIPREQUESTANSWERED) { List<PassengerTyp> passengers = rowItem.getActivityTrip().getTripPassengers(); avatarBytes = passengers.get(passengers.size() - 1).getPassengerUser().getAvatarBytes(); } else { avatarBytes = rowItem.getActivityTrip().getTripDriver().getAvatarBytes(); } holder.txtTitle.setText(rowItem._toString()); holder.txtSubtitle.setText( SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.SHORT, SimpleDateFormat.MEDIUM) .format(new Date(rowItem.getTimeStampInMillis()))); holder.imageView.setImageBitmap( BitmapFactory.decodeByteArray(avatarBytes, 0, avatarBytes.length)); return convertView; }
@Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { Intent intent; UserActivityTypPrx uActivity = UserActivityTypPrxHelper.checkedCast((ObjectPrx) parent.getItemAtPosition(position)); switch (uActivity.getActivityTrip().getTripType()) { case Trip.TRIP_OFFER_TYPE: intent = new Intent(MyActivityActivity.this, TripOfferDetailsActivity.class); break; case Trip.TRIP_REQUEST_TYPE: intent = new Intent(MyActivityActivity.this, TripRequestDetailsActivity.class); break; case Trip.TRIP_TYPE: default: intent = new Intent(MyActivityActivity.this, TripDetailsActivity.class); } intent.putExtra(TripDetailsActivity.EXTRA_TRIP_ID, uActivity.getActivityTrip().getTripId()); startActivity(intent); }