com.klwork.explorer.ui.business.social.SinaWeiboDisplayPage.java Source code

Java tutorial

Introduction

Here is the source code for com.klwork.explorer.ui.business.social.SinaWeiboDisplayPage.java

Source

/* Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.klwork.explorer.ui.business.social;

import com.klwork.business.domain.model.SocialUserAccount;
import com.klwork.business.domain.model.SocialUserWeibo;
import com.klwork.business.utils.SinaSociaTool;
import com.vaadin.server.ExternalResource;
import com.vaadin.ui.Image;
import com.vaadin.ui.Link;

/**
 * The Class AllWeiboPage.
 */
public class SinaWeiboDisplayPage extends AbstractWeiboDisplayPage {

    public SinaWeiboDisplayPage(SocialUserAccount socialUserAccount, int weiboType) {
        super(socialUserAccount, weiboType);
    }

    /**
     * ?
     * @param userWeibo
     * @return
     */
    @Override
    public Link initUserScreenName(final SocialUserWeibo userWeibo) {
        Link goToMain = new Link(userWeibo.getUserScreenName() + ":",
                new ExternalResource(getWeiboMainUrl() + userWeibo.getWeiboUid()));
        goToMain.setTargetName("_blank");
        return goToMain;
    }

    /**
     * ?
     * @param orginWeibo
     * @return
     */
    @Override
    public Link initRetweetedUserScreenName(final SocialUserWeibo orginWeibo) {
        Link link = new Link("@" + orginWeibo.getUserScreenName(),
                new ExternalResource(getWeiboMainUrl() + orginWeibo.getWeiboId()));
        link.setTargetName("_blank");
        return link;
    }

    /**
     * ??
     * @param userWeibo
     * @return
     */
    @Override
    public Image initUserProfileImage(final SocialUserWeibo userWeibo) {
        Image image = currentImage(userWeibo.getUserProfileImageUrl(), "img/weibo/head_01.jpg", "/50");
        return image;
    }

    /**
     * 
     */
    @Override
    public Image initRetweetPic(final SocialUserWeibo orginWeibo) {
        // 
        Image image = currentImage(orginWeibo.getThumbnailPic(), null, "");// ?
        return image;
    }

    @Override
    protected String textTranslate(String text) {
        return SinaSociaTool.textTranslate(text);
    }

    @Override
    public String getWeiboMainUrl() {
        return "http://weibo.com/";
    }

    @Override
    public Image initOriginalPic(final SocialUserWeibo userWeibo) {
        // 
        String origPic = userWeibo.getOriginalPic();
        Image image = currentImage(origPic, null, "");
        // System.out.println("" + image.getHeight());
        if (image != null) {
            image.setHeight("200px");
            image.setWidth("200px");

        }
        return image;
    }

    @Override
    public String getSocialType() {
        return "0";
    }
}