• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ScheduleWidgetProvider类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.samples.apps.iosched.appwidget.ScheduleWidgetProvider的典型用法代码示例。如果您正苦于以下问题:Java ScheduleWidgetProvider类的具体用法?Java ScheduleWidgetProvider怎么用?Java ScheduleWidgetProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ScheduleWidgetProvider类属于com.google.samples.apps.iosched.appwidget包,在下文中一共展示了ScheduleWidgetProvider类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: requestModelUpdate

import com.google.samples.apps.iosched.appwidget.ScheduleWidgetProvider; //导入依赖的package包/类
@Override
public boolean requestModelUpdate(UserActionEnum action, @Nullable Bundle args) {
    // If the action is a VIDEO_VIEWED we save the information that the video has been viewed by
    // the user in AppData.
    if (action.equals(VideoLibraryUserActionEnum.VIDEO_PLAYED)) {
        if (args != null && args.containsKey(KEY_VIDEO_ID)) {
            String playedVideoId = args.getString(KEY_VIDEO_ID);

            LOGD(TAG, "setVideoViewed id=" + playedVideoId);
            Uri myPlayedVideoUri = ScheduleContract.MyViewedVideos.buildMyViewedVideosUri(
                    AccountUtils.getActiveAccountName(mActivity));

            AsyncQueryHandler handler =
                    new AsyncQueryHandler(mActivity.getContentResolver()) {};
            final ContentValues values = new ContentValues();
            values.put(ScheduleContract.MyViewedVideos.VIDEO_ID, playedVideoId);
            handler.startInsert(-1, null, myPlayedVideoUri, values);

            // Because change listener is set to null during initialization, these
            // won't fire on pageview.
            mActivity.sendBroadcast(ScheduleWidgetProvider.getRefreshBroadcastIntent(mActivity,
                    false));

            // Request an immediate user data sync to reflect the viewed video in the cloud.
            SyncHelper.requestManualSync(AccountUtils.getActiveAccount(mActivity), true);
        } else {
            LOGE(TAG, "The VideoLibraryUserActionEnum.VIDEO_VIEWED action was called without a "
                    + "proper Bundle.");
            return false;
        }
    }
    return true;
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:34,代码来源:VideoLibraryModel.java


示例2: setSessionStarred

import com.google.samples.apps.iosched.appwidget.ScheduleWidgetProvider; //导入依赖的package包/类
public void setSessionStarred(Uri sessionUri, boolean starred, String title) {
    LOGD(TAG, "setSessionStarred uri=" + sessionUri + " starred=" +
            starred + " title=" + title);
    String sessionId = ScheduleContract.Sessions.getSessionId(sessionUri);
    Uri myScheduleUri = ScheduleContract.MySchedule.buildMyScheduleUri(
            AccountUtils.getActiveAccountName(mActivity));

    AsyncQueryHandler handler =
            new AsyncQueryHandler(mActivity.getContentResolver()) {
            };
    final ContentValues values = new ContentValues();
    values.put(ScheduleContract.MySchedule.SESSION_ID, sessionId);
    values.put(ScheduleContract.MySchedule.MY_SCHEDULE_IN_SCHEDULE, starred?1:0);
    handler.startInsert(-1, null, myScheduleUri, values);

    // ANALYTICS EVENT: Add or remove a session from the schedule
    // Contains: Session title, whether it was added or removed (starred or unstarred)
    AnalyticsHelper.sendEvent(
            "Session", starred ? "Starred" : "Unstarred", title);

    // Because change listener is set to null during initialization, these
    // won't fire on pageview.
    mActivity.sendBroadcast(ScheduleWidgetProvider.getRefreshBroadcastIntent(mActivity, false));

    // Request an immediate user data sync to reflect the starred user sessions in the cloud
    SyncHelper.requestManualSync(AccountUtils.getActiveAccount(mActivity), true);
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:28,代码来源:SessionsHelper.java


示例3: notifyChange

import com.google.samples.apps.iosched.appwidget.ScheduleWidgetProvider; //导入依赖的package包/类
private void notifyChange(Uri uri) {
    // We only notify changes if the caller is not the sync adapter.
    // The sync adapter has the responsibility of notifying changes (it can do so
    // more intelligently than we can -- for example, doing it only once at the end
    // of the sync instead of issuing thousands of notifications for each record).
    if (!ScheduleContract.hasCallerIsSyncAdapterParameter(uri)) {
        Context context = getContext();
        context.getContentResolver().notifyChange(uri, null);

        // Widgets can't register content observers so we refresh widgets separately.
        context.sendBroadcast(ScheduleWidgetProvider.getRefreshBroadcastIntent(context, false));
    }
}
 
开发者ID:gdg-bh,项目名称:AppDevFestSudeste2015,代码行数:14,代码来源:ScheduleProvider.java


示例4: setSessionStarred

import com.google.samples.apps.iosched.appwidget.ScheduleWidgetProvider; //导入依赖的package包/类
public void setSessionStarred(Uri sessionUri, boolean starred, String title) {
    LOGD(TAG, "setSessionStarred uri=" + sessionUri + " starred=" +
            starred + " title=" + title);
    String sessionId = ScheduleContract.Sessions.getSessionId(sessionUri);
    Uri myScheduleUri = ScheduleContract.MySchedule.buildMyScheduleUri(mActivity);

    AsyncQueryHandler handler =
            new AsyncQueryHandler(mActivity.getContentResolver()) {
            };
    final ContentValues values = new ContentValues();
    values.put(ScheduleContract.MySchedule.SESSION_ID, sessionId);
    values.put(ScheduleContract.MySchedule.MY_SCHEDULE_IN_SCHEDULE, starred?1:0);
    handler.startInsert(-1, null, myScheduleUri, values);

    /* [ANALYTICS:EVENT]
     * TRIGGER:   Add or remove a session from the schedule.
     * CATEGORY:  'Session'
     * ACTION:    'Starred' or 'Unstarred'
     * LABEL:     session title/subtitle
     * [/ANALYTICS]
     */
    AnalyticsManager.sendEvent(
            "Session", starred ? "Starred" : "Unstarred", title, 0L);

    // Because change listener is set to null during initialization, these
    // won't fire on pageview.
    mActivity.sendBroadcast(ScheduleWidgetProvider.getRefreshBroadcastIntent(mActivity, false));

    // Request an immediate user data sync to reflect the starred user sessions in the cloud
    SyncHelper.requestManualSync(AccountUtils.getActiveAccount(mActivity), true);

}
 
开发者ID:gdg-bh,项目名称:AppDevFestSudeste2015,代码行数:33,代码来源:SessionsHelper.java


示例5: setSessionStarred

import com.google.samples.apps.iosched.appwidget.ScheduleWidgetProvider; //导入依赖的package包/类
public void setSessionStarred(Uri sessionUri, boolean starred, String title) {
    LOGD(TAG, "setSessionStarred uri=" + sessionUri + " starred=" +
            starred + " title=" + title);
    String sessionId = ScheduleContract.Sessions.getSessionId(sessionUri);
    Uri myScheduleUri = ScheduleContract.MySchedule.buildMyScheduleUri(
            AccountUtils.getActiveAccountName(mContext));

    @SuppressLint("HandlerLeak") // this is short-lived
            AsyncQueryHandler handler = new AsyncQueryHandler(mContext.getContentResolver()) {
    };
    final ContentValues values = new ContentValues();
    values.put(ScheduleContract.MySchedule.SESSION_ID, sessionId);
    values.put(ScheduleContract.MySchedule.MY_SCHEDULE_IN_SCHEDULE, starred ? 1 : 0);
    int offset = SyncUtils.getServerTimeOffset(mContext);
    values.put(ScheduleContract.MySchedule.MY_SCHEDULE_TIMESTAMP, new Date().getTime() +
            offset);
    handler.startInsert(-1, null, myScheduleUri, values);

    // ANALYTICS EVENT: Add or remove a session from the schedule
    // Contains: Session title, whether it was added or removed (starred or unstarred)
    AnalyticsHelper.sendEvent("Session", starred ? "Starred" : "Unstarred", "Session: " + title);

    // Because change listener is set to null during initialization, these
    // won't fire on pageview.
    mContext.sendBroadcast(ScheduleWidgetProvider.getRefreshBroadcastIntent(mContext, false));

    // Request an immediate user data sync to reflect the starred user sessions in the cloud
    SyncHelper.requestManualSync(true);

    // No need to manually setup calendar or notifications so they happen on sync
}
 
开发者ID:google,项目名称:iosched,代码行数:32,代码来源:SessionsHelper.java


示例6: sync

import com.google.samples.apps.iosched.appwidget.ScheduleWidgetProvider; //导入依赖的package包/类
/**
 * Create a copy of current pending actions and delegate the
 * proper sync'ing to the concrete subclass on the method syncImpl.
 *
 */
public boolean sync() {
    // get data pending sync:
    Cursor scheduleData = mContext.getContentResolver().query(
            MySchedule.buildMyScheduleUri(mContext, mAccountName), MyScheduleQuery.PROJECTION,
            null, null, null);

    if (scheduleData == null) {
        return false;
    }

    // Although we have a dirty flag per item, we need all schedule to sync, because it's all
    // sync'ed at once to a file on AppData folder. We only use the dirty flag to decide if
    // the local content was changed or not. If it was, we replace the remote content.
    boolean hasPendingLocalData = false;
    ArrayList<UserAction> actions = new ArrayList<UserAction>();
    while (scheduleData.moveToNext()) {

        UserAction userAction = new UserAction();
        userAction.sessionId = scheduleData.getString(MyScheduleQuery.SESSION_ID);
        Integer inSchedule = scheduleData.getInt(MyScheduleQuery.IN_SCHEDULE);
        if (inSchedule == 0) {
            userAction.type = UserAction.TYPE.REMOVE_STAR;
        } else {
            userAction.type = UserAction.TYPE.ADD_STAR;
        }
        userAction.requiresSync = scheduleData.getInt(MyScheduleQuery.DIRTY_FLAG) == 1;
        actions.add(userAction);
        if (!hasPendingLocalData && userAction.requiresSync) {
            hasPendingLocalData = true;
        }
    }
    scheduleData.close();

    Log.d(TAG, "Starting Drive AppData sync. hasPendingData = " + hasPendingLocalData);

    boolean dataChanged = syncImpl(actions, hasPendingLocalData);

    if (hasPendingLocalData) {
        resetDirtyFlag(actions);

        // Notify other devices via GCM
        ServerUtilities.notifyUserDataChanged(mContext);
    }
    if (dataChanged) {
        LOGD(TAG, "Notifying changes on paths related to user data on Content Resolver.");
        ContentResolver resolver = mContext.getContentResolver();
        for (String path : ScheduleContract.USER_DATA_RELATED_PATHS) {
            Uri uri = ScheduleContract.BASE_CONTENT_URI.buildUpon().appendPath(path).build();
            resolver.notifyChange(uri, null);
        }
        mContext.sendBroadcast(ScheduleWidgetProvider.getRefreshBroadcastIntent(mContext, false));
    }
    return dataChanged;
}
 
开发者ID:gdg-bh,项目名称:AppDevFestSudeste2015,代码行数:60,代码来源:AbstractUserDataSyncHelper.java


示例7: notifyChange

import com.google.samples.apps.iosched.appwidget.ScheduleWidgetProvider; //导入依赖的package包/类
/**
 * Notifies the system that the given {@code uri} data has changed.
 * <p/>
 * We only notify changes if the uri wasn't called by the sync adapter, to avoid issuing a large
 * amount of notifications while doing a sync. The
 * {@link com.google.samples.apps.iosched.sync.ConferenceDataHandler} notifies all top level
 * conference paths once the conference data sync is done, and the
 * {@link com.google.samples.apps.iosched.sync.userdata.AbstractUserDataSyncHelper} notifies all
 * user data related paths once the user data sync is done.
 */
private void notifyChange(Uri uri) {
    if (!ScheduleContractHelper.isUriCalledFromSyncAdapter(uri)) {
        Context context = getContext();
        context.getContentResolver().notifyChange(uri, null);

        // Widgets can't register content observers so we refresh widgets separately.
        context.sendBroadcast(ScheduleWidgetProvider.getRefreshBroadcastIntent(context, false));
    }
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:20,代码来源:ScheduleProvider.java



注:本文中的com.google.samples.apps.iosched.appwidget.ScheduleWidgetProvider类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FileMessageHeader类代码示例发布时间:2022-05-22
下一篇:
Java DefaultMatchEngine类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap