@Override public void onClick(View v) { final int currentPos = cells.indexOf(formCell); long prevVirtualTimestamp = -1; long nextVirtualTimestamp = -1; if (currentPos != cells.size() - 1) { // The form position is not the end of the list. if (currentPos == 0) { prevVirtualTimestamp = 0; nextVirtualTimestamp = cells.get(currentPos + 1).getVirtualTimestamp(); } else { prevVirtualTimestamp = cells.get(currentPos - 1).getVirtualTimestamp(); nextVirtualTimestamp = cells.get(currentPos + 1).getVirtualTimestamp(); } } if (prevVirtualTimestamp != -1 && nextVirtualTimestamp != -1 && !isSameDate( Post.virtualTimestampToDate(prevVirtualTimestamp), Post.virtualTimestampToDate(nextVirtualTimestamp))) { // Make sure to make a post not to beyond a day. Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("Asia/Tokyo")); cal.setTime(Post.virtualTimestampToDate(prevVirtualTimestamp)); cal.set(Calendar.HOUR_OF_DAY, 23); cal.set(Calendar.MINUTE, 59); cal.set(Calendar.SECOND, 59); cal.set(Calendar.MILLISECOND, 999); nextVirtualTimestamp = Post.dateToVirtualTimestamp(cal.getTime()); } if (v.getId() == R.id.postButton) { Intent intent = new Intent(activity, PostTimelineActivity.class); intent.putExtra(PostTimelineActivity.LECTURE_ID, lectureId); intent.putExtra(PostTimelineActivity.PREV_VIRTUAL_TS, prevVirtualTimestamp); intent.putExtra(PostTimelineActivity.NEXT_VIRTUAL_TS, nextVirtualTimestamp); activity.startActivityForResult(intent, 0); } else if (v.getId() == R.id.postImageButton) { Intent intent = new Intent(activity, PostImageActivity.class); intent.putExtra(PostImageActivity.LECTURE_ID, lectureId); intent.putExtra(PostImageActivity.PREV_VIRTUAL_TS, prevVirtualTimestamp); intent.putExtra(PostImageActivity.NEXT_VIRTUAL_TS, nextVirtualTimestamp); activity.startActivityForResult(intent, 0); } }
@Override public long getVirtualTimestamp() { return Post.dateToVirtualTimestamp(date); }