/** * constructor * * @throws Exception */ public UIUserActivitiesDisplay() throws Exception { List<SelectItemOption<String>> displayModes = new ArrayList<SelectItemOption<String>>(4); displayModes.add( new SelectItemOption<String>("All_Updates", DisplayMode.ALL_ACTIVITIES.toString())); displayModes.add( new SelectItemOption<String>("Space_Updates", DisplayMode.MY_SPACE.toString())); displayModes.add( new SelectItemOption<String>("Network_Updates", DisplayMode.CONNECTIONS.toString())); displayModes.add( new SelectItemOption<String>("My_Status", DisplayMode.MY_ACTIVITIES.toString())); UIDropDownControl uiDropDownControl = addChild(UIDropDownControl.class, "DisplayModesDropDown", null); uiDropDownControl.setOptions(displayModes); setSelectedMode(uiDropDownControl); addChild(uiDropDownControl); // TODO: init() run two time when initiation this form. // String remoteId = Utils.getOwnerRemoteId(); // this.setOwnerName(remoteId); String selectedDisplayMode = Utils.getCookies( String.format(Utils.ACTIVITY_STREAM_TAB_SELECTED_COOKIED, Utils.getViewerRemoteId())); selectedDisplayMode = (selectedDisplayMode != null) ? selectedDisplayMode : DisplayMode.ALL_ACTIVITIES.name(); // setSelectedDisplayMode(selectedDisplayMode); // set lastUpdatedNumber after init() method invoked inside setSelectedDisplayMode() method // int numberOfUpdates = this.getNumberOfUpdatedActivities(); // setLastUpdatedNum(selectedDisplayMode.toString(), "" + numberOfUpdates); }
private long getLastUpdatedNum(String mode) { String cookieKey = String.format(Utils.LAST_UPDATED_ACTIVITIES_NUM, mode, Utils.getViewerRemoteId()); String strValue = Utils.getCookies(cookieKey); boolean refreshPage = Utils.isRefreshPage(); if (strValue == null || (refreshPage == false && mode.equals(selectedDisplayMode.toString()))) { return 0; } return Long.parseLong(strValue); }
/** * initialize * * @throws Exception */ public void init() throws Exception { Validate.notNull(ownerName, "ownerName must not be null."); Validate.notNull(viewerName, "viewerName must not be null."); // synchronized (locker) { removeChild(UIActivitiesLoader.class); activitiesLoader = addChild(UIActivitiesLoader.class, null, "UIActivitiesLoader"); } // String activityId = Utils.getActivityID(); if (activityId != null && activityId.length() > 0) { activitiesLoader.setPostContext(PostContext.SINGLE); } else { activitiesLoader.setPostContext(PostContext.USER); } // Check if current display page is My Activity Stream String currentUserName = URLUtils.getCurrentUser(); if (currentUserName != null) { selectedDisplayMode = DisplayMode.OWNER_STATUS; } activitiesLoader.setLoadingCapacity(ACTIVITY_PER_PAGE); activitiesLoader.setOwnerName(ownerName); activitiesLoader.setSelectedDisplayMode(selectedDisplayMode.toString()); // // UIActivitiesContainer activitiesContainer = // activitiesLoader.getChild(UIActivitiesContainer.class); // Identity ownerIdentity = Utils.getIdentityManager() .getOrCreateIdentity(OrganizationIdentityProvider.NAME, ownerName, false); ActivityManager activityManager = Utils.getActivityManager(); ListAccess<ExoSocialActivity> activitiesListAccess = null; switch (this.selectedDisplayMode) { case MY_ACTIVITIES: activitiesListAccess = activityManager.getActivitiesWithListAccess(ownerIdentity); activitiesLoader.setActivityListAccess(activitiesListAccess); break; case OWNER_STATUS: if (isActivityStreamOwner == false) { Identity viewerIdentity = Utils.getIdentityManager() .getOrCreateIdentity(OrganizationIdentityProvider.NAME, viewerName, false); activitiesListAccess = activityManager.getActivitiesWithListAccess(ownerIdentity, viewerIdentity); activitiesLoader.setActivityListAccess(activitiesListAccess); } else { activitiesListAccess = activityManager.getActivitiesWithListAccess(ownerIdentity); activitiesLoader.setActivityListAccess(activitiesListAccess); } break; case CONNECTIONS: activitiesListAccess = activityManager.getActivitiesOfConnectionsWithListAccess(ownerIdentity); activitiesLoader.setActivityListAccess(activitiesListAccess); break; case MY_SPACE: activitiesListAccess = activityManager.getActivitiesOfUserSpacesWithListAccess(ownerIdentity); activitiesLoader.setActivityListAccess(activitiesListAccess); break; default: activitiesListAccess = activityManager.getActivityFeedWithListAccess(ownerIdentity); activitiesLoader.setActivityListAccess(activitiesListAccess); break; } // String lastVisitedModeCookieKey = String.format(Utils.ACTIVITY_STREAM_TAB_SELECTED_COOKIED, Utils.getViewerRemoteId()); String lastVisitedMode = Utils.getCookies(lastVisitedModeCookieKey); this.notChangedMode = lastVisitedMode == null ? true : this.selectedDisplayMode.toString().equals(lastVisitedMode.trim()); // setNumberOfUpdatedActivities(getActivigetActivitiesUpdatedNumtiesUpdatedNum(notChangedMode)); setNumberOfUpdatedActivities(0); // activitiesLoader.init(); }