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


Java Session类代码示例

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


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

示例1: computeTypeOrder

import com.google.samples.apps.iosched.io.model.Session; //导入依赖的package包/类
private int computeTypeOrder(Session session) {
    int order = Integer.MAX_VALUE;
    int keynoteOrder = -1;
    if (mTagMap == null) {
        throw new IllegalStateException("Attempt to compute type order without tag map.");
    }
    for (String tagId : session.tags) {
        if (Config.Tags.SPECIAL_KEYNOTE.equals(tagId)) {
            return keynoteOrder;
        }
        Tag tag = mTagMap.get(tagId);
        if (tag != null && Config.Tags.SESSION_GROUPING_TAG_CATEGORY.equals(tag.category)) {
            if (tag.order_in_category < order) {
                order = tag.order_in_category;
            }
        }
    }
    return order;
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:20,代码来源:SessionsHandler.java

示例2: buildSessionSpeakerMapping

import com.google.samples.apps.iosched.io.model.Session; //导入依赖的package包/类
private void buildSessionSpeakerMapping(Session session,
                                        ArrayList<ContentProviderOperation> list) {
    final Uri uri = ScheduleContractHelper.setUriAsCalledFromSyncAdapter(
            ScheduleContract.Sessions.buildSpeakersDirUri(session.id));

    // delete any existing relationship between this session and speakers
    list.add(ContentProviderOperation.newDelete(uri).build());

    // add relationship records to indicate the speakers for this session
    if (session.speakers != null) {
        for (String speakerId : session.speakers) {
            list.add(ContentProviderOperation.newInsert(uri)
                    .withValue(ScheduleDatabase.SessionsSpeakers.SESSION_ID, session.id)
                    .withValue(ScheduleDatabase.SessionsSpeakers.SPEAKER_ID, speakerId)
                    .build());
        }
    }
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:19,代码来源:SessionsHandler.java

示例3: buildSessionSpeakerMapping

import com.google.samples.apps.iosched.io.model.Session; //导入依赖的package包/类
private void buildSessionSpeakerMapping(Session session,
                                        ArrayList<ContentProviderOperation> list) {
    final Uri uri = ScheduleContract.addCallerIsSyncAdapterParameter(
            ScheduleContract.Sessions.buildSpeakersDirUri(session.id));

    // delete any existing relationship between this session and speakers
    list.add(ContentProviderOperation.newDelete(uri).build());

    // add relationship records to indicate the speakers for this session
    if (session.speakers != null) {
        for (String speakerId : session.speakers) {
            list.add(ContentProviderOperation.newInsert(uri)
                    .withValue(ScheduleDatabase.SessionsSpeakers.SESSION_ID, session.id)
                    .withValue(ScheduleDatabase.SessionsSpeakers.SPEAKER_ID, speakerId)
                    .build());
        }
    }
}
 
开发者ID:gdg-bh,项目名称:AppDevFestSudeste2015,代码行数:19,代码来源:SessionsHandler.java

示例4: computeTypeOrder

import com.google.samples.apps.iosched.io.model.Session; //导入依赖的package包/类
private int computeTypeOrder(Session session) {
    int order = Integer.MAX_VALUE;
    int keynoteOrder = -1;
    if (mTagMap == null) {
        throw new IllegalStateException("Attempt to compute type order without tag map.");
    }

    if (session.tags != null) {
        for (String tagId : session.tags) {
            if (Config.Tags.SPECIAL_KEYNOTE.equals(tagId)) {
                return keynoteOrder;
            }
            Tag tag = mTagMap.get(tagId);
            if (tag != null && Config.Tags.SESSION_GROUPING_TAG_CATEGORY.equals(tag.category)) {
                if (tag.order_in_category < order) {
                    order = tag.order_in_category;
                }
            }
        }
    }
    return order;
}
 
开发者ID:google,项目名称:iosched,代码行数:23,代码来源:SessionsHandler.java

示例5: buildTagsMapping

import com.google.samples.apps.iosched.io.model.Session; //导入依赖的package包/类
private void buildTagsMapping(Session session, ArrayList<ContentProviderOperation> list) {
    final Uri uri = ScheduleContractHelper.setUriAsCalledFromSyncAdapter(
            ScheduleContract.Sessions.buildTagsDirUri(session.id));

    // delete any existing mappings
    list.add(ContentProviderOperation.newDelete(uri).build());

    // add a mapping (a session+tag tuple) for each tag in the session
    if (session.tags != null) {
        for (String tag : session.tags) {
            list.add(ContentProviderOperation.newInsert(uri)
                    .withValue(ScheduleDatabase.SessionsTags.SESSION_ID, session.id)
                    .withValue(ScheduleDatabase.SessionsTags.TAG_ID, tag)
                    .build());
        }
    }
}
 
开发者ID:google,项目名称:iosched,代码行数:18,代码来源:SessionsHandler.java

示例6: buildTagsMapping

import com.google.samples.apps.iosched.io.model.Session; //导入依赖的package包/类
private void buildTagsMapping(Session session, ArrayList<ContentProviderOperation> list) {
    final Uri uri = ScheduleContractHelper.setUriAsCalledFromSyncAdapter(
            ScheduleContract.Sessions.buildTagsDirUri(session.id));

    // delete any existing mappings
    list.add(ContentProviderOperation.newDelete(uri).build());

    // add a mapping (a session+tag tuple) for each tag in the session
    for (String tag : session.tags) {
        list.add(ContentProviderOperation.newInsert(uri)
                .withValue(ScheduleDatabase.SessionsTags.SESSION_ID, session.id)
                .withValue(ScheduleDatabase.SessionsTags.TAG_ID, tag).build());
    }
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:15,代码来源:SessionsHandler.java

示例7: buildTagsMapping

import com.google.samples.apps.iosched.io.model.Session; //导入依赖的package包/类
private void buildTagsMapping(Session session, ArrayList<ContentProviderOperation> list) {
    final Uri uri = ScheduleContract.addCallerIsSyncAdapterParameter(
            ScheduleContract.Sessions.buildTagsDirUri(session.id));

    // delete any existing mappings
    list.add(ContentProviderOperation.newDelete(uri).build());

    // add a mapping (a session+tag tuple) for each tag in the session
    for (String tag : session.tags) {
        list.add(ContentProviderOperation.newInsert(uri)
                .withValue(ScheduleDatabase.SessionsTags.SESSION_ID, session.id)
                .withValue(ScheduleDatabase.SessionsTags.TAG_ID, tag).build());
    }
}
 
开发者ID:gdg-bh,项目名称:AppDevFestSudeste2015,代码行数:15,代码来源:SessionsHandler.java

示例8: process

import com.google.samples.apps.iosched.io.model.Session; //导入依赖的package包/类
@Override
public void process(JsonElement element) {
    for (Session session : new Gson().fromJson(element, Session[].class)) {
        mSessions.put(session.id, session);
    }
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:7,代码来源:SessionsHandler.java

示例9: makeContentProviderOperations

import com.google.samples.apps.iosched.io.model.Session; //导入依赖的package包/类
@Override
public void makeContentProviderOperations(ArrayList<ContentProviderOperation> list) {
    Uri uri = ScheduleContractHelper.setUriAsCalledFromSyncAdapter(
            ScheduleContract.Sessions.CONTENT_URI);

    // build a map of session to session import hashcode so we know what to update,
    // what to insert, and what to delete
    HashMap<String, String> sessionHashCodes = loadSessionHashCodes();
    boolean incrementalUpdate = (sessionHashCodes != null) && (sessionHashCodes.size() > 0);

    // set of sessions that we want to keep after the sync
    HashSet<String> sessionsToKeep = new HashSet<String>();

    if (incrementalUpdate) {
        LOGD(TAG, "Doing incremental update for sessions.");
    } else {
        LOGD(TAG, "Doing full (non-incremental) update for sessions.");
        list.add(ContentProviderOperation.newDelete(uri).build());
    }

    int updatedSessions = 0;
    for (Session session : mSessions.values()) {
        // Set the session grouping order in the object, so it can be used in hash calculation
        session.groupingOrder = computeTypeOrder(session);

        // compute the incoming session's hashcode to figure out if we need to update
        String hashCode = session.getImportHashCode();
        sessionsToKeep.add(session.id);

        // add session, if necessary
        if (!incrementalUpdate || !sessionHashCodes.containsKey(session.id) ||
                    !sessionHashCodes.get(session.id).equals(hashCode)) {
            ++updatedSessions;
            boolean isNew = !incrementalUpdate || !sessionHashCodes.containsKey(session.id);
            buildSession(isNew, session, list);

            // add relationships to speakers and track
            buildSessionSpeakerMapping(session, list);
            buildTagsMapping(session, list);
        }
    }

    int deletedSessions = 0;
    if (incrementalUpdate) {
        for (String sessionId : sessionHashCodes.keySet()) {
            if (!sessionsToKeep.contains(sessionId)) {
                buildDeleteOperation(sessionId, list);
                ++deletedSessions;
            }
        }
    }

    LOGD(TAG, "Sessions: " + (incrementalUpdate ? "INCREMENTAL" : "FULL") + " update. " +
            updatedSessions + " to update, " + deletedSessions + " to delete. New total: " +
            mSessions.size());
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:57,代码来源:SessionsHandler.java

示例10: makeContentProviderOperations

import com.google.samples.apps.iosched.io.model.Session; //导入依赖的package包/类
@Override
public void makeContentProviderOperations(ArrayList<ContentProviderOperation> list) {
    Uri uri = ScheduleContract.addCallerIsSyncAdapterParameter(
            ScheduleContract.Sessions.CONTENT_URI);

    // build a map of session to session import hashcode so we know what to update,
    // what to insert, and what to delete
    HashMap<String, String> sessionHashCodes = loadSessionHashCodes();
    boolean incrementalUpdate = (sessionHashCodes != null) && (sessionHashCodes.size() > 0);

    // set of sessions that we want to keep after the sync
    HashSet<String> sessionsToKeep = new HashSet<String>();

    if (incrementalUpdate) {
        LOGD(TAG, "Doing incremental update for sessions.");
    } else {
        LOGD(TAG, "Doing full (non-incremental) update for sessions.");
        list.add(ContentProviderOperation.newDelete(uri).build());
    }

    int updatedSessions = 0;
    for (Session session : mSessions.values()) {
        // Set the session grouping order in the object, so it can be used in hash calculation
        session.groupingOrder = computeTypeOrder(session);

        // compute the incoming session's hashcode to figure out if we need to update
        String hashCode = session.getImportHashCode();
        sessionsToKeep.add(session.id);

        // add session, if necessary
        if (!incrementalUpdate || !sessionHashCodes.containsKey(session.id) ||
                    !sessionHashCodes.get(session.id).equals(hashCode)) {
            ++updatedSessions;
            boolean isNew = !incrementalUpdate || !sessionHashCodes.containsKey(session.id);
            buildSession(isNew, session, list);

            // add relationships to speakers and track
            buildSessionSpeakerMapping(session, list);
            buildTagsMapping(session, list);
        }
    }

    int deletedSessions = 0;
    if (incrementalUpdate) {
        for (String sessionId : sessionHashCodes.keySet()) {
            if (!sessionsToKeep.contains(sessionId)) {
                buildDeleteOperation(sessionId, list);
                ++deletedSessions;
            }
        }
    }

    LOGD(TAG, "Sessions: " + (incrementalUpdate ? "INCREMENTAL" : "FULL") + " update. " +
            updatedSessions + " to update, " + deletedSessions + " to delete. New total: " +
            mSessions.size());
}
 
开发者ID:gdg-bh,项目名称:AppDevFestSudeste2015,代码行数:57,代码来源:SessionsHandler.java

示例11: buildSession

import com.google.samples.apps.iosched.io.model.Session; //导入依赖的package包/类
private void buildSession(boolean isInsert,
                          Session session, ArrayList<ContentProviderOperation> list) {
    ContentProviderOperation.Builder builder;
    Uri allSessionsUri = ScheduleContract
            .addCallerIsSyncAdapterParameter(ScheduleContract.Sessions.CONTENT_URI);
    Uri thisSessionUri = ScheduleContract
            .addCallerIsSyncAdapterParameter(ScheduleContract.Sessions.buildSessionUri(
                    session.id));

    if (isInsert) {
        builder = ContentProviderOperation.newInsert(allSessionsUri);
    } else {
        builder = ContentProviderOperation.newUpdate(thisSessionUri);
    }

    String speakerNames = "";
    if (mSpeakerMap != null) {
        // build human-readable list of speakers
        mStringBuilder.setLength(0);
        for (int i = 0; i < session.speakers.length; ++i) {
            if (mSpeakerMap.containsKey(session.speakers[i])) {
                mStringBuilder
                        .append(i == 0 ? "" : i == session.speakers.length - 1 ? " and " : ", ")
                        .append(mSpeakerMap.get(session.speakers[i]).name.trim());
            } else {
                LOGW(TAG, "Unknown speaker ID " + session.speakers[i] + " in session " + session.id);
            }
        }
        speakerNames = mStringBuilder.toString();
    } else {
        LOGE(TAG, "Can't build speaker names -- speaker map is null.");
    }

    int color = mDefaultSessionColor;
    try {
        if (!TextUtils.isEmpty(session.color)) {
            color = Color.parseColor(session.color);
        }
    } catch (IllegalArgumentException ex) {
        LOGD(TAG, "Ignoring invalid formatted session color: "+session.color);
    }
    builder.withValue(ScheduleContract.SyncColumns.UPDATED, System.currentTimeMillis())
            .withValue(ScheduleContract.Sessions.SESSION_ID, session.id)
            .withValue(ScheduleContract.Sessions.SESSION_LEVEL, null)            // Not available
            .withValue(ScheduleContract.Sessions.SESSION_TITLE, session.title)
            .withValue(ScheduleContract.Sessions.SESSION_ABSTRACT, session.description)
            .withValue(ScheduleContract.Sessions.SESSION_HASHTAG, session.hashtag)
            .withValue(ScheduleContract.Sessions.SESSION_START, TimeUtils.timestampToMillis(session.startTimestamp, 0))
            .withValue(ScheduleContract.Sessions.SESSION_END, TimeUtils.timestampToMillis(session.endTimestamp, 0))
            .withValue(ScheduleContract.Sessions.SESSION_TAGS, session.makeTagsList())
                    // Note: we store this comma-separated list of tags IN ADDITION
                    // to storing the tags in proper relational format (in the sessions_tags
                    // relationship table). This is because when querying for sessions,
                    // we don't want to incur the performance penalty of having to do a
                    // subquery for every record to figure out the list of tags of each session.
            .withValue(ScheduleContract.Sessions.SESSION_SPEAKER_NAMES, speakerNames)
                    // Note: we store the human-readable list of speakers (which is redundant
                    // with the sessions_speakers relationship table) so that we can
                    // display it easily in lists without having to make an additional DB query
                    // (or another join) for each record.
            .withValue(ScheduleContract.Sessions.SESSION_KEYWORDS, null)             // Not available
            .withValue(ScheduleContract.Sessions.SESSION_URL, session.url)
            .withValue(ScheduleContract.Sessions.SESSION_LIVESTREAM_URL,
                    session.isLivestream ? session.youtubeUrl : null)
            .withValue(ScheduleContract.Sessions.SESSION_MODERATOR_URL, null)    // Not available
            .withValue(ScheduleContract.Sessions.SESSION_REQUIREMENTS, null)     // Not available
            .withValue(ScheduleContract.Sessions.SESSION_YOUTUBE_URL,
                    session.isLivestream ? null : session.youtubeUrl)
            .withValue(ScheduleContract.Sessions.SESSION_PDF_URL, null)          // Not available
            .withValue(ScheduleContract.Sessions.SESSION_NOTES_URL, null)        // Not available
            .withValue(ScheduleContract.Sessions.ROOM_ID, session.room)
            .withValue(ScheduleContract.Sessions.SESSION_GROUPING_ORDER, session.groupingOrder)
            .withValue(ScheduleContract.Sessions.SESSION_IMPORT_HASHCODE,
                    session.getImportHashCode())
            .withValue(ScheduleContract.Sessions.SESSION_MAIN_TAG, session.mainTag)
            .withValue(ScheduleContract.Sessions.SESSION_CAPTIONS_URL, session.captionsUrl)
            .withValue(ScheduleContract.Sessions.SESSION_PHOTO_URL, session.photoUrl)
            .withValue(ScheduleContract.Sessions.SESSION_RELATED_CONTENT, session.relatedContent)
            .withValue(ScheduleContract.Sessions.SESSION_COLOR, color);
    list.add(builder.build());
}
 
开发者ID:gdg-bh,项目名称:AppDevFestSudeste2015,代码行数:82,代码来源:SessionsHandler.java

示例12: process

import com.google.samples.apps.iosched.io.model.Session; //导入依赖的package包/类
@Override
public void process(@NonNull Gson gson, @NonNull JsonElement element) {
    for (Session session : gson.fromJson(element, Session[].class)) {
        mSessions.put(session.id, session);
    }
}
 
开发者ID:google,项目名称:iosched,代码行数:7,代码来源:SessionsHandler.java

示例13: makeContentProviderOperations

import com.google.samples.apps.iosched.io.model.Session; //导入依赖的package包/类
@Override
public void makeContentProviderOperations(ArrayList<ContentProviderOperation> list) {
    Uri uri = ScheduleContractHelper.setUriAsCalledFromSyncAdapter(
            ScheduleContract.Sessions.CONTENT_URI);

    // build a map of session to session import hashcode so we know what to update,
    // what to insert, and what to delete
    HashMap<String, String> sessionHashCodes = loadSessionHashCodes();
    boolean incrementalUpdate = (sessionHashCodes != null) && (sessionHashCodes.size() > 0);

    // set of sessions that we want to keep after the sync
    HashSet<String> sessionsToKeep = new HashSet<>();

    if (incrementalUpdate) {
        LOGD(TAG, "Doing incremental update for sessions.");
    } else {
        LOGD(TAG, "Doing full (non-incremental) update for sessions.");
        list.add(ContentProviderOperation.newDelete(uri).build());
    }

    int updatedSessions = 0;
    for (Session session : mSessions.values()) {
        // Set the session grouping order in the object, so it can be used in hash calculation
        session.groupingOrder = computeTypeOrder(session);

        // compute the incoming session's hashcode to figure out if we need to update
        String hashCode = session.getImportHashCode();
        sessionsToKeep.add(session.id);

        // add session, if necessary
        if (!incrementalUpdate || !sessionHashCodes.containsKey(session.id) ||
                    !sessionHashCodes.get(session.id).equals(hashCode)) {
            ++updatedSessions;
            boolean isNew = !incrementalUpdate || !sessionHashCodes.containsKey(session.id);
            buildSession(isNew, session, list);

            // add relationships to speakers and track
            buildSessionSpeakerMapping(session, list);
            buildTagsMapping(session, list);
            buildRelatedSessionsMapping(session, list);
        }
    }

    int deletedSessions = 0;
    if (incrementalUpdate) {
        for (String sessionId : sessionHashCodes.keySet()) {
            if (!sessionsToKeep.contains(sessionId)) {
                buildDeleteOperation(sessionId, list);
                ++deletedSessions;
            }
        }
    }

    LOGD(TAG, "Sessions: " + (incrementalUpdate ? "INCREMENTAL" : "FULL") + " update. " +
            updatedSessions + " to update, " + deletedSessions + " to delete. New total: " +
            mSessions.size());
}
 
开发者ID:google,项目名称:iosched,代码行数:58,代码来源:SessionsHandler.java


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