本文整理汇总了Java中com.google.samples.apps.iosched.util.TimeUtils类的典型用法代码示例。如果您正苦于以下问题:Java TimeUtils类的具体用法?Java TimeUtils怎么用?Java TimeUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TimeUtils类属于com.google.samples.apps.iosched.util包,在下文中一共展示了TimeUtils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: formatTime
import com.google.samples.apps.iosched.util.TimeUtils; //导入依赖的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();
}
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:19,代码来源:ScheduleWidgetRemoteViewsService.java
示例2: onCreateLoader
import com.google.samples.apps.iosched.util.TimeUtils; //导入依赖的package包/类
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
if (id != QUERY_TOKEN_SESSION_ROOM && id != QUERY_TOKEN_SUBTITLE) {
return null;
}
final long time = TimeUtils.getCurrentTime(getActivity());
final String roomId = args.getString(QUERY_ARG_ROOMID);
final String roomTitle = args.getString(QUERY_ARG_ROOMTITLE);
final int roomType = args.getInt(QUERY_ARG_ROOMTYPE);
final String iconType = args.getString(QUERY_ARG_ICONTYPE);
if (id == QUERY_TOKEN_SESSION_ROOM) {
return new OverviewSessionLoader(getActivity(), roomId, roomTitle, roomType, iconType,
time);
} else if (id == QUERY_TOKEN_SUBTITLE) {
return new SingleSessionLoader(getActivity(), roomId, roomTitle, roomType, iconType);
}
return null;
}
开发者ID:google,项目名称:iosched,代码行数:21,代码来源:MapInfoFragment.java
示例3: run
import com.google.samples.apps.iosched.util.TimeUtils; //导入依赖的package包/类
@Override
public void run() {
ScheduleActivity activity = ScheduleActivity.this;
if (activity.isDestroyed()) {
LOGD(TAG, "Activity is not valid anymore. Stopping UI Updater");
return;
}
LOGD(TAG, "Running MySchedule UI updater (now=" +
new Date(TimeUtils.getCurrentTime(activity)) + ")");
mPresenter.onUserAction(ScheduleModel.MyScheduleUserActionEnum.REDRAW_UI, null);
if (TimeUtils.isConferenceInProgress(activity)) {
scheduleNextUiUpdate();
}
}
开发者ID:google,项目名称:iosched,代码行数:18,代码来源:ScheduleActivity.java
示例4: formatDescription
import com.google.samples.apps.iosched.util.TimeUtils; //导入依赖的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();
}
开发者ID:google,项目名称:iosched,代码行数:20,代码来源:ScheduleItemViewHolder.java
示例5: scheduleFeedbackAlarm
import com.google.samples.apps.iosched.util.TimeUtils; //导入依赖的package包/类
public void scheduleFeedbackAlarm(final long sessionEnd,
final long alarmOffset, final String sessionTitle) {
// By default, feedback alarms fire 5 minutes before session end time. If alarm offset is
// provided, alarm is set to go off that much time from now (useful for testing).
long alarmTime;
if (alarmOffset == UNDEFINED_ALARM_OFFSET) {
alarmTime = sessionEnd - MILLI_FIVE_MINUTES;
} else {
alarmTime = TimeUtils.getCurrentTime(this) + alarmOffset;
}
LOGD(TAG, "Scheduling session feedback alarm for session '" + sessionTitle + "'");
LOGD(TAG, " -> end time: " + sessionEnd + " = " + (new Date(sessionEnd)).toString());
LOGD(TAG, " -> alarm time: " + alarmTime + " = " + (new Date(alarmTime)).toString());
final Intent feedbackIntent = new Intent(
ACTION_NOTIFY_SESSION_FEEDBACK,
null,
this,
SessionAlarmService.class);
PendingIntent pi = PendingIntent.getService(
this, 1, feedbackIntent, PendingIntent.FLAG_CANCEL_CURRENT);
final AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, alarmTime, pi);
}
开发者ID:google,项目名称:iosched,代码行数:26,代码来源:SessionAlarmService.java
示例6: rewriteKeynoteDetails
import com.google.samples.apps.iosched.util.TimeUtils; //导入依赖的package包/类
private void rewriteKeynoteDetails(SessionData keynoteData) {
long startTime, endTime, currentTime;
currentTime = UIUtils.getCurrentTime(mContext);
if (keynoteData.getStartDate() != null) {
startTime = keynoteData.getStartDate().getTime();
} else {
LOGD(TAG, "Keynote start time wasn't set");
startTime = 0;
}
if (keynoteData.getEndDate() != null) {
endTime = keynoteData.getEndDate().getTime();
} else {
LOGD(TAG, "Keynote end time wasn't set");
endTime = Long.MAX_VALUE;
}
StringBuilder stringBuilder = new StringBuilder();
if (currentTime >= startTime && currentTime < endTime) {
stringBuilder.append(mContext.getString(R.string
.live_now));
} else {
String shortDate = TimeUtils.formatShortDate(mContext, keynoteData.getStartDate());
stringBuilder.append(shortDate);
if (startTime > 0) {
stringBuilder.append(" / " );
stringBuilder.append(TimeUtils.formatShortTime(mContext,
new java.util.Date(startTime)));
}
}
keynoteData.setDetails(stringBuilder.toString());
}
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:33,代码来源:ExploreModel.java
示例7: populateNavDrawer
import com.google.samples.apps.iosched.util.TimeUtils; //导入依赖的package包/类
/**
* Defines the Navigation Drawer items to display by updating {@code mNavDrawerItems} then
* forces the Navigation Drawer to redraw itself.
*/
private void populateNavDrawer() {
boolean attendeeAtVenue = SettingsUtils.isAttendeeAtVenue(this);
boolean conferenceInProgress = TimeUtils.isConferenceInProgress(this);
mNavDrawerItems.clear();
// decide which items will appear in the nav drawer
if (AccountUtils.hasActiveAccount(this)) {
// Only logged-in users can save sessions, so if there is no active account,
// there is no My Schedule
mNavDrawerItems.add(NAVDRAWER_ITEM_MY_SCHEDULE);
} else {
// If no active account, show Sign In
mNavDrawerItems.add(NAVDRAWER_ITEM_SIGN_IN);
}
// Explore is always shown.
mNavDrawerItems.add(NAVDRAWER_ITEM_EXPLORE);
// If the attendee is on-site, show Map on the nav drawer
if (attendeeAtVenue) {
mNavDrawerItems.add(NAVDRAWER_ITEM_MAP);
}
mNavDrawerItems.add(NAVDRAWER_ITEM_SEPARATOR);
// Other items that are always in the nav drawer.
mNavDrawerItems.add(NAVDRAWER_ITEM_SOCIAL);
mNavDrawerItems.add(NAVDRAWER_ITEM_VIDEO_LIBRARY);
mNavDrawerItems.add(NAVDRAWER_ITEM_SEPARATOR_SPECIAL);
mNavDrawerItems.add(NAVDRAWER_ITEM_SETTINGS);
mNavDrawerItems.add(NAVDRAWER_ITEM_ABOUT);
// Debug menu only on debug builds.
if (BuildConfig.DEBUG) {
mNavDrawerItems.add(NAVDRAWER_ITEM_DEBUG);
}
createNavDrawerItems();
}
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:43,代码来源:BaseActivity.java
示例8: formatDescription
import com.google.samples.apps.iosched.util.TimeUtils; //导入依赖的package包/类
private String formatDescription(ScheduleItem item) {
StringBuilder description = new StringBuilder();
description.append(TimeUtils.formatShortTime(mContext, new Date(item.startTime)));
if (!Config.Tags.SPECIAL_KEYNOTE.equals(item.mainTag)) {
description.append(" - ");
description.append(TimeUtils.formatShortTime(mContext, new Date(item.endTime)));
}
if (!TextUtils.isEmpty(item.room)) {
description.append(" / ");
description.append(item.room);
}
return description.toString();
}
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:14,代码来源:MyScheduleAdapter.java
示例9: setupWifiOfferCard
import com.google.samples.apps.iosched.util.TimeUtils; //导入依赖的package包/类
private void setupWifiOfferCard(final MessageCardView card) {
card.setText(getString(TimeUtils.hasConferenceStarted(getActivity()) ?
R.string.question_setup_wifi_after_i_o_start :
R.string.question_setup_wifi_before_i_o_start));
card.setButton(0, getString(R.string.no_thanks), CARD_ANSWER_NO,
false, 0);
card.setButton(1, getString(R.string.setup_wifi_yes), CARD_ANSWER_YES,
true, 0);
final Context context = getActivity().getApplicationContext();
card.setListener(new MessageCardView.OnMessageCardButtonClicked() {
@Override
public void onMessageCardButtonClicked(final String tag) {
card.dismiss(true);
// post delayed to give card time to animate
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
if (CARD_ANSWER_YES.equals(tag)) {
WiFiUtils.showWiFiDialog(SessionsFragment.this.getActivity());
} else {
PrefUtils.markDeclinedWifiSetup(context);
}
}
}, CARD_DISMISS_ACTION_DELAY);
}
});
card.show();
}
开发者ID:gdg-bh,项目名称:AppDevFestSudeste2015,代码行数:30,代码来源:SessionsFragment.java
示例10: moveToCurrentTimeSlot
import com.google.samples.apps.iosched.util.TimeUtils; //导入依赖的package包/类
private void moveToCurrentTimeSlot() {
// don't auto-scroll to current time outside of the conf or if user has manually scrolled
if (mScrolled || !TimeUtils.isConferenceInProgress(getContext())) return;
int nowPos = mAdapter.findPositionForTime(TimeUtils.getCurrentTime(getContext()));
if (nowPos > 0) {
LinearLayoutManager lm = (LinearLayoutManager) mRecyclerView.getLayoutManager();
lm.scrollToPositionWithOffset(nowPos,
getResources().getDimensionPixelOffset(R.dimen.spacing_normal));
}
}
开发者ID:google,项目名称:iosched,代码行数:12,代码来源:MyIOFragment.java
示例11: showLiveStream
import com.google.samples.apps.iosched.util.TimeUtils; //导入依赖的package包/类
/**
* Live stream should be shown if url is available and the session will start in no more than 10
* minutes, or is ongoing or has ended.
*/
public boolean showLiveStream() {
if (!hasLiveStream()) {
return false;
}
long currentTimeMillis = TimeUtils.getCurrentTime(mContext);
return currentTimeMillis >
mSessionStart - SessionDetailConstants.LIVESTREAM_BEFORE_SESSION_START_MS;
}
开发者ID:google,项目名称:iosched,代码行数:13,代码来源:SessionDetailModel.java
示例12: minutesSinceSessionStarted
import com.google.samples.apps.iosched.util.TimeUtils; //导入依赖的package包/类
/**
* Returns the number of minutes, rounded down, since session has started, or 0 if not started
* yet.
*/
public long minutesSinceSessionStarted() {
if (!hasSessionStarted()) {
return 0l;
} else {
long currentTimeMillis = TimeUtils.getCurrentTime(mContext);
// Rounded down number of minutes.
return (currentTimeMillis - mSessionStart) / 60000;
}
}
开发者ID:google,项目名称:iosched,代码行数:14,代码来源:SessionDetailModel.java
示例13: minutesUntilSessionStarts
import com.google.samples.apps.iosched.util.TimeUtils; //导入依赖的package包/类
/**
* Returns the number of minutes, rounded up, until session stars, or 0 if already started.
*/
public long minutesUntilSessionStarts() {
if (hasSessionStarted()) {
return 0l;
} else {
long currentTimeMillis = TimeUtils.getCurrentTime(mContext);
int minutes = (int) ((mSessionStart - currentTimeMillis) / 60000);
// Rounded up number of minutes.
return minutes * 60000 < (mSessionStart - currentTimeMillis) ? minutes + 1 : minutes;
}
}
开发者ID:google,项目名称:iosched,代码行数:14,代码来源:SessionDetailModel.java
示例14: minutesUntilSessionEnds
import com.google.samples.apps.iosched.util.TimeUtils; //导入依赖的package包/类
public long minutesUntilSessionEnds() {
if (hasSessionEnded()) {
// If session has ended, return 0 minutes until end of session.
return 0l;
} else {
long currentTimeMillis = TimeUtils.getCurrentTime(mContext);
int minutes = (int) ((mSessionEnd - currentTimeMillis) / 60000);
// Rounded up number of minutes.
return minutes * 60000 < (mSessionEnd - currentTimeMillis) ? minutes + 1 : minutes;
}
}
开发者ID:google,项目名称:iosched,代码行数:12,代码来源:SessionDetailModel.java
示例15: moveToCurrentTimeSlot
import com.google.samples.apps.iosched.util.TimeUtils; //导入依赖的package包/类
private void moveToCurrentTimeSlot(boolean animate) {
final long now = TimeUtils.getCurrentTime(getContext());
final int pos = mViewAdapter.findTimeHeaderPositionForTime(now);
if (pos >= 0) {
if (animate) {
mRecyclerView.smoothScrollToPosition(pos);
} else {
LinearLayoutManager lm = (LinearLayoutManager) mRecyclerView.getLayoutManager();
lm.scrollToPositionWithOffset(pos,
getResources().getDimensionPixelSize(R.dimen.spacing_normal));
}
}
}
开发者ID:google,项目名称:iosched,代码行数:14,代码来源:ScheduleSingleDayFragment.java
示例16: onResume
import com.google.samples.apps.iosched.util.TimeUtils; //导入依赖的package包/类
@Override
public void onResume() {
super.onResume();
if (TimeUtils.isConferenceInProgress(this)) {
scheduleNextUiUpdate();
}
mModel.addDataObservers();
}
开发者ID:google,项目名称:iosched,代码行数:10,代码来源:ScheduleActivity.java
示例17: calculateCurrentDay
import com.google.samples.apps.iosched.util.TimeUtils; //导入依赖的package包/类
private void calculateCurrentDay() {
final long now = TimeUtils.getCurrentTime(getContext());
// If we are before or after the conference, the first day is considered the current day
mToday = 0;
for (int i = 0; i < Config.CONFERENCE_DAYS.length; i++) {
if (now >= Config.CONFERENCE_DAYS[i][0] && now <= Config.CONFERENCE_DAYS[i][1]) {
// mToday is set to 1 for the first day, 2 for the second etc
mToday = i;
break;
}
}
}
开发者ID:google,项目名称:iosched,代码行数:15,代码来源:SchedulePagerFragment.java
示例18: getActiveSimpleCards
import com.google.samples.apps.iosched.util.TimeUtils; //导入依赖的package包/类
public static List<ConfMessageCard> getActiveSimpleCards(Context context) {
ArrayList<ConfMessageCard> activeSimpleCards = new ArrayList<>();
for (ConfMessageCard card : ConfMessageCard.values()) {
if (card.isSimpleMessageCard() && card.isTimeActive(TimeUtils.getCurrentTime(context))
&& !hasDismissedConfMessageCard(context, card)) {
activeSimpleCards.add(card);
}
}
return activeSimpleCards;
}
开发者ID:google,项目名称:iosched,代码行数:11,代码来源:ConfMessageCardUtils.java
示例19: enableActiveCards
import com.google.samples.apps.iosched.util.TimeUtils; //导入依赖的package包/类
/**
* Mark appropriate cards active.
*
* @param context Context to be used to lookup the {@link android.content.SharedPreferences}.
*/
public static void enableActiveCards(final Context context) {
long currentTime = TimeUtils.getCurrentTime(context);
for (ConfMessageCard card : ConfMessageCard.values()) {
if (card.isTimeActive(currentTime)) {
markShouldShowConfMessageCard(context, card, true);
}
}
}
开发者ID:google,项目名称:iosched,代码行数:14,代码来源:ConfMessageCardUtils.java
示例20: getItemViewType
import com.google.samples.apps.iosched.util.TimeUtils; //导入依赖的package包/类
public int getItemViewType(int position) {
if (position < 0 || position >= mScheduleItems.size()) {
LOGE(TAG, "Invalid view position passed to ScheduleDayAdapter: " + position);
return VIEW_TYPE_NORMAL;
}
ScheduleItem item = mScheduleItems.get(position);
long now = TimeUtils.getCurrentTime(mContext);
if (item.startTime <= now && now <= item.endTime && item.type == ScheduleItem.SESSION) {
return VIEW_TYPE_NOW;
} else {
return VIEW_TYPE_NORMAL;
}
}
开发者ID:google,项目名称:iosched,代码行数:14,代码来源:ScheduleWidgetRemoteViewsService.java
注:本文中的com.google.samples.apps.iosched.util.TimeUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论