本文整理汇总了Java中com.google.samples.apps.iosched.model.ScheduleItem类的典型用法代码示例。如果您正苦于以下问题:Java ScheduleItem类的具体用法?Java ScheduleItem怎么用?Java ScheduleItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScheduleItem类属于com.google.samples.apps.iosched.model包,在下文中一共展示了ScheduleItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: formatTime
import com.google.samples.apps.iosched.model.ScheduleItem; //导入依赖的package包/类
private String formatTime(long now, ScheduleItem item) {
StringBuilder time = new StringBuilder();
if (item.startTime <= now) {
// session is happening now!
if (0 != (item.flags & ScheduleItem.FLAG_HAS_LIVESTREAM)) {
// session has live stream
time.append(mContext.getString(R.string.watch_now));
} else {
time.append(mContext.getString(R.string.session_now));
}
} else {
// session in the future
time.append(TimeUtils.formatShortTime(mContext, new Date(item.startTime)));
}
time.append(" - ");
time.append(TimeUtils.formatShortTime(mContext, new Date(item.endTime)));
return time.toString();
}
示例2: getItemViewType
import com.google.samples.apps.iosched.model.ScheduleItem; //导入依赖的package包/类
@Override
public int getItemViewType(int position) {
if (position < 0 || position >= mItems.size()) {
LOGE(TAG, "Invalid view position passed to MyScheduleAdapter: " + position);
return VIEW_TYPE_NORMAL;
}
ScheduleItem item = mItems.get(position);
long now = UIUtils.getCurrentTime(mContext);
if (item.startTime <= now && now <= item.endTime && item.type == ScheduleItem.SESSION) {
return VIEW_TYPE_NOW;
} else if (item.endTime <= now && now < Config.CONFERENCE_END_MILLIS) {
return VIEW_TYPE_PAST_DURING_CONFERENCE;
} else {
return VIEW_TYPE_NORMAL;
}
}
示例3: onBindViewHolder
import com.google.samples.apps.iosched.model.ScheduleItem; //导入依赖的package包/类
@Override
public void onBindViewHolder(final ItemHolder holder, final int position) {
mCursor.moveToPosition(position);
final String title = mCursor.getString(OverviewSessionLoader.Query.SESSION_TITLE);
final String sessionId = mCursor.getString(OverviewSessionLoader.Query.SESSION_ID);
final long blockStart = mCursor.getLong(OverviewSessionLoader.Query.SESSION_START);
final long blockEnd = mCursor.getLong(OverviewSessionLoader.Query.SESSION_END);
final String sessionTag = mCursor.getString(OverviewSessionLoader.Query.SESSION_TAGS);
final int sessionType = ScheduleItem.detectSessionType(sessionTag);
final String text = UIUtils.formatIntervalTimeString(blockStart, blockEnd,
mStringBuilder, mContext);
holder.itemView.setTag(R.id.tag_session_id, sessionId);
holder.title.setText(title);
holder.text.setText(text);
if (mDisplayIcons) {
holder.image.setImageResource(UIUtils.getSessionIcon(sessionType));
}
}
示例4: getItemViewType
import com.google.samples.apps.iosched.model.ScheduleItem; //导入依赖的package包/类
@Override
public int getItemViewType(int position) {
Object item = mItems.get(position);
if (item instanceof ScheduleItem) {
if (((ScheduleItem) item).type == ScheduleItem.BREAK) {
return VIEW_TYPE_NON_SESSION;
}
return VIEW_TYPE_SESSION;
}
if (item instanceof SeparatorSpacer) {
return VIEW_TYPE_SPACER;
}
if (item instanceof DaySeparator) {
return VIEW_TYPE_DAY_HEADER;
}
if (item instanceof MessageData) {
return VIEW_TYPE_MESSAGE_CARD;
}
return RecyclerView.INVALID_TYPE;
}
示例5: onBindViewHolder
import com.google.samples.apps.iosched.model.ScheduleItem; //导入依赖的package包/类
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
final Object item = mItems.get(position);
switch (holder.getItemViewType()) {
case VIEW_TYPE_SESSION:
((SessionItemViewHolder) holder).bind((ScheduleItem)item, mTagPool, mTagMetadata);
break;
case VIEW_TYPE_NON_SESSION:
((NonSessionItemViewHolder) holder).bind((ScheduleItem) item);
break;
case VIEW_TYPE_DAY_HEADER:
((DaySeparatorViewHolder) holder).bind((DaySeparator) item);
break;
case VIEW_TYPE_MESSAGE_CARD:
((MessageCardViewHolder) holder).onBind((MessageData) item);
break;
}
}
示例6: findPositionForTime
import com.google.samples.apps.iosched.model.ScheduleItem; //导入依赖的package包/类
/**
* Return the position of the first item that has not finished.
*/
int findPositionForTime(final long time) {
for (int i = 0; i < mItems.size(); i++) {
Object item = mItems.get(i);
if (item instanceof ScheduleItem) {
if (((ScheduleItem) item).endTime > time) {
return i;
}
} else if (item instanceof DaySeparator) {
if (((DaySeparator) item).mStartTime > time) {
return i;
}
}
}
return RecyclerView.NO_POSITION;
}
示例7: cursorToModel
import com.google.samples.apps.iosched.model.ScheduleItem; //导入依赖的package包/类
@Override
public List<ScheduleItem> cursorToModel(@NonNull CursorModelLoader<List<ScheduleItem>> loader,
@NonNull Cursor cursor) {
ArrayList<ScheduleItem> items = new ArrayList<>();
if (cursor.moveToFirst()) {
do {
ScheduleItem item = new ScheduleItem();
item.setTypeFromBlockType(cursor.getString(BlocksQuery.BLOCK_TYPE));
item.title = cursor.getString(BlocksQuery.BLOCK_TITLE);
item.room = item.subtitle = cursor.getString(BlocksQuery.BLOCK_SUBTITLE);
item.startTime = cursor.getLong(BlocksQuery.BLOCK_START);
item.endTime = cursor.getLong(BlocksQuery.BLOCK_END);
item.blockKind = cursor.getString(BlocksQuery.BLOCK_KIND);
item.flags |= ScheduleItem.FLAG_NOT_REMOVABLE;
items.add(item);
} while (cursor.moveToNext());
}
return items;
}
示例8: merge
import com.google.samples.apps.iosched.model.ScheduleItem; //导入依赖的package包/类
/**
* Merges session and block items and sorts the merged collection.
*/
private void merge() {
mScheduleItems.clear();
if (mBlockItems != null) {
mScheduleItems.addAll(mBlockItems);
}
if (mSessionItems != null) {
mScheduleItems.addAll(mSessionItems);
}
Collections.sort(mScheduleItems, new Comparator<ScheduleItem>() {
@Override
public int compare(ScheduleItem lhs, ScheduleItem rhs) {
return Long.compare(lhs.startTime, rhs.startTime);
}
});
}
示例9: updateData
import com.google.samples.apps.iosched.model.ScheduleItem; //导入依赖的package包/类
/**
* This updates the data, by calling {@link ScheduleFetcher#getScheduleDataAsync
* (LoadScheduleDataListener, long, long)} for each day. It is protected and not private, to
* allow us to extend this class and use mock data in UI tests (refer {@code
* StubMyScheduleModel} in {@code androidTest}).
*/
protected void updateData(final DataQueryCallback<MyScheduleQueryEnum> callback) {
for (int i = 0; i < Config.CONFERENCE_DAYS.length; i++) {
/**
* The key in {@link #mScheduleData} is 1 for the first day, 2 for the second etc
*/
final int dayId = i + 1;
// Immediately use cached data if available
if (callback != null && mScheduleData.indexOfKey(dayId) >= 0) {
callback.onModelUpdated(this, MyScheduleQueryEnum.SCHEDULE);
}
// Update cached data
mScheduleHelper.getScheduleDataAsync(new LoadScheduleDataListener() {
@Override
public void onDataLoaded(ArrayList<ScheduleItem> scheduleItems) {
updateCache(dayId, scheduleItems, callback);
}
}, Config.CONFERENCE_DAYS[i][0], Config.CONFERENCE_DAYS[i][1], mTagFilterHolder);
}
}
示例10: formatDescription
import com.google.samples.apps.iosched.model.ScheduleItem; //导入依赖的package包/类
private String formatDescription(@NonNull Context context, @NonNull ScheduleItem item,
SessionTimeFormat timeFormat) {
final StringBuilder description = mTmpStringBuilder;
mTmpStringBuilder.setLength(0); // clear the builder
if (timeFormat == DURATION) {
description.append(TimeUtils.formatDuration(context, item.startTime, item.endTime));
} else if (timeFormat == SPAN) {
description.append(TimeUtils.formatShortTime(context, new Date(item.startTime)));
if (!SPECIAL_KEYNOTE.equals(item.mainTag)) {
description.append(" - ");
description.append(TimeUtils.formatShortTime(context, new Date(item.endTime)));
}
}
if (!TextUtils.isEmpty(item.room)) {
description.append(" / ");
description.append(item.room);
}
return description.toString();
}
示例11: onBindViewHolder
import com.google.samples.apps.iosched.model.ScheduleItem; //导入依赖的package包/类
@Override
public void onBindViewHolder(final ViewHolder holder, final int position) {
final Object item = mItems.get(position);
switch (holder.getItemViewType()) {
case ITEM_TYPE_SESSION:
((SessionItemViewHolder) holder).bind((ScheduleItem) item, mTagPool, mTagMetadata);
break;
case ITEM_TYPE_BREAK:
((NonSessionItemViewHolder) holder).bind((ScheduleItem) item);
break;
case ITEM_TYPE_TIME_HEADER:
default:
((TimeSeperatorViewHolder) holder).bind((TimeSeperatorItem) item);
break;
}
}
示例12: updateItems
import com.google.samples.apps.iosched.model.ScheduleItem; //导入依赖的package包/类
public void updateItems(final List<ScheduleItem> items) {
mItems.clear();
if (items == null) {
notifyDataSetChanged();
return;
}
if (!mShowTimeSeparators) {
mItems.addAll(items);
} else {
for (int i = 0, size = items.size(); i < size; i++) {
final ScheduleItem prev = i > 0 ? items.get(i - 1) : null;
final ScheduleItem item = items.get(i);
if (prev == null || !ScheduleItemHelper.sameStartTime(prev, item, true)) {
mItems.add(new TimeSeperatorItem(item));
}
mItems.add(item);
}
}
// TODO use DiffUtil
notifyDataSetChanged();
}
示例13: item
import com.google.samples.apps.iosched.model.ScheduleItem; //导入依赖的package包/类
private ScheduleItem item(String start, String end, String id, boolean conflict, int type) {
ScheduleItem i = new ScheduleItem();
i.title = id;
i.startTime = date(start);
i.endTime = date(end);
i.type = type;
if (conflict) i.flags = ScheduleItem.FLAG_CONFLICTS_WITH_PREVIOUS;
return i;
}
示例14: getSessionIcon
import com.google.samples.apps.iosched.model.ScheduleItem; //导入依赖的package包/类
public static @DrawableRes int getSessionIcon(int sessionType) {
switch (sessionType) {
case ScheduleItem.SESSION_TYPE_SESSION:
return R.drawable.ic_session;
case ScheduleItem.SESSION_TYPE_CODELAB:
return R.drawable.ic_codelab;
case ScheduleItem.SESSION_TYPE_BOXTALK:
return R.drawable.ic_sandbox;
case ScheduleItem.SESSION_TYPE_MISC:
default:
return R.drawable.ic_misc;
}
}
示例15: getItemViewType
import com.google.samples.apps.iosched.model.ScheduleItem; //导入依赖的package包/类
public int getItemViewType(int position) {
if (position < 0 || position >= mScheduleItems.size()) {
LOGE(TAG, "Invalid view position passed to MyScheduleAdapter: " + position);
return VIEW_TYPE_NORMAL;
}
ScheduleItem item = mScheduleItems.get(position);
long now = UIUtils.getCurrentTime(mContext);
if (item.startTime <= now && now <= item.endTime && item.type == ScheduleItem.SESSION) {
return VIEW_TYPE_NOW;
} else {
return VIEW_TYPE_NORMAL;
}
}