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


Java Avatar类代码示例

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


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

示例1: getAvatar

import net.sourceforge.subsonic.domain.Avatar; //导入依赖的package包/类
private Avatar getAvatar(HttpServletRequest request) {
    String id = request.getParameter("id");
    boolean forceCustom = ServletRequestUtils.getBooleanParameter(request, "forceCustom", false);

    if (id != null) {
        return settingsService.getSystemAvatar(Integer.parseInt(id));
    }

    String username = request.getParameter("username");
    if (username == null) {
        return null;
    }

    UserSettings userSettings = settingsService.getUserSettings(username);
    if (userSettings.getAvatarScheme() == AvatarScheme.CUSTOM || forceCustom) {
        return settingsService.getCustomAvatar(username);
    }
    return settingsService.getSystemAvatar(userSettings.getSystemAvatarId());
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:20,代码来源:AvatarController.java

示例2: getAvatar

import net.sourceforge.subsonic.domain.Avatar; //导入依赖的package包/类
private Avatar getAvatar(HttpServletRequest request) {
    String id = request.getParameter("id");
    if (id != null) {
        return settingsService.getSystemAvatar(Integer.parseInt(id));
    }

    String username = request.getParameter("username");
    if (username == null) {
        return null;
    }

    UserSettings userSettings = settingsService.getUserSettings(username);
    if (userSettings.getAvatarScheme() == AvatarScheme.SYSTEM) {
        return settingsService.getSystemAvatar(userSettings.getSystemAvatarId());
    }
    return settingsService.getCustomAvatar(username);
}
 
开发者ID:FutureSonic,项目名称:FutureSonic-Server,代码行数:18,代码来源:AvatarController.java

示例3: getLastModified

import net.sourceforge.subsonic.domain.Avatar; //导入依赖的package包/类
public long getLastModified(HttpServletRequest request) {
    Avatar avatar = getAvatar(request);
    long result = avatar == null ? -1L : avatar.getCreatedDate().getTime();

    String username = request.getParameter("username");
    if (username != null) {
        UserSettings userSettings = settingsService.getUserSettings(username);
        result = Math.max(result, userSettings.getChanged().getTime());
    }

    return result;
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:13,代码来源:AvatarController.java

示例4: handleRequest

import net.sourceforge.subsonic.domain.Avatar; //导入依赖的package包/类
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
    Avatar avatar = getAvatar(request);

    if (avatar == null) {
        response.sendError(HttpServletResponse.SC_NOT_FOUND);
        return null;
    }

    response.setContentType(avatar.getMimeType());
    response.getOutputStream().write(avatar.getData());
    return null;
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:13,代码来源:AvatarController.java

示例5: createAvatar

import net.sourceforge.subsonic.domain.Avatar; //导入依赖的package包/类
private void createAvatar(String fileName, byte[] data, String username, Map<String, Object> map) throws IOException {

        BufferedImage image;
        try {
            image = ImageIO.read(new ByteArrayInputStream(data));
            if (image == null) {
                throw new Exception("Failed to decode incoming image: " + fileName + " (" + data.length + " bytes).");
            }
            int width = image.getWidth();
            int height = image.getHeight();
            String mimeType = StringUtil.getMimeType(FilenameUtils.getExtension(fileName));

            // Scale down image if necessary.
            if (width > MAX_AVATAR_SIZE || height > MAX_AVATAR_SIZE) {
                double scaleFactor = (double) MAX_AVATAR_SIZE / (double) Math.max(width, height);
                height = (int) (height * scaleFactor);
                width = (int) (width * scaleFactor);
                image = CoverArtController.scale(image, width, height);
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                ImageIO.write(image, "jpeg", out);
                data = out.toByteArray();
                mimeType = StringUtil.getMimeType("jpeg");
                map.put("resized", true);
            }
            Avatar avatar = new Avatar(0, fileName, new Date(), mimeType, width, height, data);
            settingsService.setCustomAvatar(avatar, username);
            LOG.info("Created avatar '" + fileName + "' (" + data.length + " bytes) for user " + username);

        } catch (Exception x) {
            LOG.warn("Failed to upload personal image: " + x, x);
            map.put("error", x);
        }
    }
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:34,代码来源:AvatarUploadController.java

示例6: setCustomAvatar

import net.sourceforge.subsonic.domain.Avatar; //导入依赖的package包/类
/**
 * Sets the custom avatar for the given user.
 *
 * @param avatar   The avatar, or <code>null</code> to remove the avatar.
 * @param username The username.
 */
public void setCustomAvatar(Avatar avatar, String username) {
    String sql = "delete from custom_avatar where username=?";
    update(sql, username);

    if (avatar != null) {
        update("insert into custom_avatar(" + COLUMNS + ", username) values(" + questionMarks(COLUMNS) + ", ?)",
               null, avatar.getName(), avatar.getCreatedDate(), avatar.getMimeType(),
               avatar.getWidth(), avatar.getHeight(), avatar.getData(), username);
    }
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:17,代码来源:AvatarDao.java

示例7: handleRequest

import net.sourceforge.subsonic.domain.Avatar; //导入依赖的package包/类
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
    Avatar avatar = getAvatar(request);

    if (avatar == null) {
        response.sendError(HttpServletResponse.SC_NOT_FOUND);
        return null;
    }

    // TODO: specify caching filter.

    response.setContentType(avatar.getMimeType());
    response.getOutputStream().write(avatar.getData());
    return null;
}
 
开发者ID:FutureSonic,项目名称:FutureSonic-Server,代码行数:15,代码来源:AvatarController.java

示例8: mapRow

import net.sourceforge.subsonic.domain.Avatar; //导入依赖的package包/类
public Avatar mapRow(ResultSet rs, int rowNum) throws SQLException {
    return new Avatar(rs.getInt(1), rs.getString(2), rs.getTimestamp(3), rs.getString(4),
                      rs.getInt(5), rs.getInt(6), rs.getBytes(7));
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:5,代码来源:AvatarDao.java

示例9: getAvatars

import net.sourceforge.subsonic.domain.Avatar; //导入依赖的package包/类
public List<Avatar> getAvatars() {
    return avatars;
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:4,代码来源:PersonalSettingsCommand.java

示例10: setAvatars

import net.sourceforge.subsonic.domain.Avatar; //导入依赖的package包/类
public void setAvatars(List<Avatar> avatars) {
    this.avatars = avatars;
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:4,代码来源:PersonalSettingsCommand.java

示例11: getCustomAvatar

import net.sourceforge.subsonic.domain.Avatar; //导入依赖的package包/类
public Avatar getCustomAvatar() {
    return customAvatar;
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:4,代码来源:PersonalSettingsCommand.java

示例12: setCustomAvatar

import net.sourceforge.subsonic.domain.Avatar; //导入依赖的package包/类
public void setCustomAvatar(Avatar customAvatar) {
    this.customAvatar = customAvatar;
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:4,代码来源:PersonalSettingsCommand.java

示例13: getLastModified

import net.sourceforge.subsonic.domain.Avatar; //导入依赖的package包/类
public long getLastModified(HttpServletRequest request) {
    Avatar avatar = getAvatar(request);
    return avatar == null ? -1L : avatar.getCreatedDate().getTime();
}
 
开发者ID:FutureSonic,项目名称:FutureSonic-Server,代码行数:5,代码来源:AvatarController.java


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