当前位置: 首页>>代码示例>>Java>>正文


Java ScheduleWidgetProvider类代码示例

本文整理汇总了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;未经允许,请勿转载。