public void setResourceCategory() { if (collectionItemDo.getResource().getResourceFormat() != null) { String resourceType = collectionItemDo.getResource().getResourceFormat().getDisplayName(); resourceType = resourceType.toLowerCase(); if (resourceType.equalsIgnoreCase("lesson") || resourceType.equalsIgnoreCase("textbook") || resourceType.equalsIgnoreCase("handout")) { resourceType = resourceType .replaceAll("lesson", "text") .replaceAll("textbook", "text") .replaceAll("handout", "text"); } if (resourceType.equalsIgnoreCase("slide")) { resourceType = resourceType.replaceAll("slide", "image"); } if (resourceType.equalsIgnoreCase("exam") || resourceType.equalsIgnoreCase("website") || resourceType.equalsIgnoreCase("challenge")) { resourceType = resourceType .replaceAll("exam", "webpage") .replaceAll("website", "webpage") .replaceAll("challenge", "webpage"); } resourceCategory.setText(resourceType); resourceCategory.getElement().setAttribute("alt", resourceType); resourceCategory.getElement().setAttribute("title", resourceType); } }
@UiConstructor public PreviewResourceView(CollectionItemDo collectionItemDo, int itemIndex) { initWidget(uiBinder.createAndBindUi(this)); resourceThumbContainer.getElement().setId("fpnlResourceThumbContainer"); resourceImageContainer.getElement().setId("fpnlResourceImageContainer"); resourceThumbnail.getElement().setId("imgResourceThumbnail"); resourceTypeImage.getElement().setId("lblResourceTypeImage"); resourceNumber.getElement().setId("lblResourceNumber"); resourceTitle.getElement().setId("htmlResourceTitle"); resourceIndex.getElement().setId("lblResourceIndex"); resourceHoverTitle.getElement().setId("htmlResourceHoverTitle"); resourceCategory.getElement().setId("lblResourceCategory"); resourceSourceName.getElement().setId("lblResourceSourceName"); ratingWidgetPanel.getElement().setId("fpnlRatingWidgetPanel"); this.collectionItemDo = collectionItemDo; setNavigationResourceTitle(collectionItemDo.getResource().getTitle()); if (collectionItemDo.getResource().getResourceFormat() != null) { setResourceTypeIcon(collectionItemDo.getResource().getResourceFormat().getDisplayName()); } setResourceCategory(); setReourceSourceName(); setResourceSequence(itemIndex + 1); setResourcePlayLink(); if (AppClientFactory.getCurrentPlaceToken().equalsIgnoreCase(PlaceTokens.COLLECTION_PLAY)) { setAvgRatingWidget(); AppClientFactory.getEventBus() .addHandler(UpdateRatingsInRealTimeEvent.TYPE, setRatingWidgetMetaData); } }
public String getResourceLink() { String collectionId = AppClientFactory.getPlaceManager().getRequestParameter("id", null); if (collectionItemDo.getNarration() != null && !collectionItemDo.getNarration().trim().equals("")) { String resourceLink = "#" + AppClientFactory.getCurrentPlaceToken() + "&id=" + collectionId + "&rid=" + collectionItemDo.getCollectionItemId() + "&tab=narration"; resourceLink += PreviewPlayerPresenter.setConceptPlayerParameters(); return resourceLink; } else { String resourceLink = "#" + AppClientFactory.getCurrentPlaceToken() + "&id=" + collectionId + "&rid=" + collectionItemDo.getCollectionItemId(); resourceLink += PreviewPlayerPresenter.setConceptPlayerParameters(); return resourceLink; } }
@UiHandler("resourceThumbnail") public void onErrorResourceImage(ErrorEvent errorEvent) { resourceThumbnail.setUrl("images/resource_trans.png"); if (collectionItemDo.getResource().getResourceFormat() != null) { String resourceType = collectionItemDo.getResource().getResourceFormat().getDisplayName(); resourceType = resourceType.toLowerCase(); if (resourceType.equalsIgnoreCase("lesson") || resourceType.equalsIgnoreCase("textbook") || resourceType.equalsIgnoreCase("handout")) { resourceType = resourceType .replaceAll("lesson", "text") .replaceAll("textbook", "text") .replaceAll("handout", "text"); } if (resourceType.equalsIgnoreCase("slide")) { resourceType = resourceType.replaceAll("slide", "image"); } if (resourceType.equalsIgnoreCase("exam") || resourceType.equalsIgnoreCase("website") || resourceType.equalsIgnoreCase("challenge")) { resourceType = resourceType .replaceAll("exam", "webpage") .replaceAll("website", "webpage") .replaceAll("challenge", "webpage"); } resourceThumbnail.setStyleName(getResourceDefaultImage(resourceType)); } }
public void setReourceSourceName() { if (collectionItemDo.getResource().getResourceSource() != null) { if ((!collectionItemDo.getResource().getUrl().startsWith("https://docs.google.com")) && (!collectionItemDo.getResource().getUrl().startsWith("http://docs.google.com"))) { resourceSourceName.setText( collectionItemDo.getResource().getResourceSource().getAttribution() != null ? collectionItemDo.getResource().getResourceSource().getAttribution() : ""); resourceSourceName .getElement() .setAttribute( "alt", collectionItemDo.getResource().getResourceSource().getAttribution() != null ? collectionItemDo.getResource().getResourceSource().getAttribution() : ""); resourceSourceName .getElement() .setAttribute( "title", collectionItemDo.getResource().getResourceSource().getAttribution() != null ? collectionItemDo.getResource().getResourceSource().getAttribution() : ""); } } else { resourceSourceName.setText(""); } }
@Override public void updateRatingInRealTime(String gooruOid, double average, Integer count) { if (collectionItemDo != null && collectionItemDo.getResource() != null && collectionItemDo.getResource().getGooruOid() != null && collectionItemDo.getResource().getGooruOid().equals(gooruOid)) { collectionItemDo.getResource().getRatings().setCount(count); collectionItemDo.getResource().getRatings().setAverage(average); setAvgRatingWidget(); } }
/** Average star ratings widget will get integrated. */ private void setAvgRatingWidget() { ratingWidgetView = new RatingWidgetView(); if (collectionItemDo.getResource().getRatings() != null) { if (collectionItemDo.getResource().getRatings().getCount() != null && collectionItemDo.getResource().getRatings().getCount() != 0) { ratingWidgetView.getRatingCountOpenBrace().setText(i18n.GL_SPL_OPEN_SMALL_BRACKET()); ratingWidgetView .getRatingCountLabel() .setText(collectionItemDo.getResource().getRatings().getCount().toString()); ratingWidgetView.getRatingCountCloseBrace().setText(i18n.GL_SPL_CLOSE_SMALL_BRACKET()); ratingWidgetView.setAvgStarRating(collectionItemDo.getResource().getRatings().getAverage()); ratingWidgetPanel.getElement().setId("fpnlRatingWidgetPanel"); } } ratingWidgetPanel.clear(); ratingWidgetPanel.add(ratingWidgetView); }
@Override public void onLoad() { if (collectionItemDo .getResource() .getResourceType() .getName() .equalsIgnoreCase("assessment-question")) { resourceThumbnail.setUrl(getQuestionImage()); } else if (collectionItemDo .getResource() .getResourceType() .getName() .equalsIgnoreCase("video/youtube")) { resourceThumbnail.setUrl( ResourceImageUtil.youtubeImageLink( ResourceImageUtil.getYoutubeVideoId(collectionItemDo.getResource().getUrl()), Window.Location.getProtocol())); } else { resourceThumbnail.setUrl( collectionItemDo.getResource().getThumbnails() != null ? collectionItemDo.getResource().getThumbnails().getUrl() : "images/defaultRes.png"); } }
private String getQuestionImage() { String thumbnailImage = ""; String assetName = ""; try { if (collectionItemDo.getResource().getAssets() != null && collectionItemDo.getResource().getAssets().size() > 0) { assetName = collectionItemDo.getResource().getAssets().get(0).getAsset().getName(); thumbnailImage = collectionItemDo.getResource().getAssetURI() + collectionItemDo.getResource().getFolder() + assetName; } else { thumbnailImage = collectionItemDo.getResource().getThumbnails().getUrl(); } } catch (Exception e) { AppClientFactory.printSevereLogger("PreviewResourceView getQuestionImage:::" + e); } return thumbnailImage != null ? thumbnailImage : "images/defaultRes.png"; }