Package com.google.livingstories.client

Examples of com.google.livingstories.client.StartPageBundle


    Caches.clearLivingStoryThemeInfo(id);
  }
 
  @Override
  public StartPageBundle getStartPageBundle() {
    StartPageBundle bundle = Caches.getStartPageBundle();
    if (bundle == null) {
      List<LivingStory> unsortedLivingStories = getAllLivingStories(true);
      Map<Long, List<BaseContentItem>> storyIdToUpdateMap =
          new HashMap<Long, List<BaseContentItem>>();
      List<LivingStoryAndLastUpdateTime> livingStoriesAndUpdateTimes =
        new ArrayList<LivingStoryAndLastUpdateTime>();
      // For each living story, get the last 3 updates - the updates are sorted in reverse
      // chronological order
      for (LivingStory livingStory : unsortedLivingStories) {
        List<BaseContentItem> updates =
            contentRpcService.getUpdatesForStartPage(livingStory.getId());
        storyIdToUpdateMap.put(livingStory.getId(), updates);
        livingStoriesAndUpdateTimes.add(
            new LivingStoryAndLastUpdateTime(livingStory,
                updates.isEmpty() ? null : updates.get(0).getTimestamp()));
      }
     
      // After we have the updates for each story, we want to sort them such that the story with
      // the latest update is first
      Collections.sort(livingStoriesAndUpdateTimes, LivingStoryAndLastUpdateTime.getComparator());
      List<LivingStory> sortedLivingStories = new ArrayList<LivingStory>();
      for (LivingStoryAndLastUpdateTime story : livingStoriesAndUpdateTimes) {
        sortedLivingStories.add(story.livingStory);
      }
      bundle = new StartPageBundle(sortedLivingStories, storyIdToUpdateMap);
      Caches.setStartPageBundle(bundle);
    }
    return bundle;
  }
View Full Code Here

TOP

Related Classes of com.google.livingstories.client.StartPageBundle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.