import com.parse.ParseObject; //导入方法依赖的package包/类
private void modelToUI() {
ParseObject event = mEvent;
aq.id(R.id.textHospitalName).text(event.getString("hospital"));
String location = event.getString("location");
location+=" "+StringUtils.isNullOrEmpty(event.getString("room"), "");
aq.id(R.id.textLocation).text(location);
aq.id(R.id.textDate).text(StringUtils.formatDate(event.getDate("startTime"), StringUtils.DATE_AND_TIME_SHORT));
int duration = event.getInt("duration");
int clockRes = Reflect.getImageResId("ic_clock_" + duration);
if (clockRes==0)clockRes=R.drawable.ic_clock_60;
aq.id(R.id.imgDate).image(clockRes);
String category = event.getString("category");
category = StringUtils.isNullOrEmpty(category, "lecture").toLowerCase();
int categoryRes = Reflect.getImageResId("ic_event_" + category);
if(categoryRes==0) categoryRes=R.drawable.ic_event_lecture;
aq.id(R.id.imgCategory).image(categoryRes);
List tags = event.getList("tags");
if(tags==null) tags = new ArrayList<>();
TagCloudLinkView hashTags = (TagCloudLinkView) aq.id(R.id.hashtag_tags).getView();
while(hashTags.getTags().size()>0){
hashTags.remove(0);
}
for(String tag : tags){
hashTags.add(new Tag(1, tag));
}
hashTags.drawTags();
ParseObject owner = event.getParseObject("owner");
if(owner!=null)
aq.id(R.id.textOwnerName).text(String.format("%s %s", owner.get("firstName"), owner.get("lastName")));
else
aq.id(R.id.textOwnerName).text("");
aq.id(R.id.textBlurb).text(event.getString("blurb"));
int headCount = event.getInt("headCount");
int quota = event.getInt("quota");
SpannableStringBuilder stringBuilder = new SpannableStringBuilder();
if(headCount>=quota)
StringUtils.appendSpan(stringBuilder, ""+headCount, new ForegroundColorSpan(getResources().getColor(R.color.body_text_1_negative)));
else
stringBuilder.append(""+headCount);
stringBuilder.append(String.format("/%d places taken", quota));
aq.id(R.id.textHeadCount).text(stringBuilder);
ParseUser user = ParseUser.getCurrentUser();
if(user!=null && owner!=null && user.getObjectId().equals(owner.getObjectId())){
aq.id(R.id.btn_submit).text("Cancel").enabled(false);
}
else{
aq.id(R.id.btn_submit).text("Reserve").enabled(!mHasJoined);
}
}