NIMSDK-AOS  9.16.0
ImageAttachment.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.msg.attachment;
2 
3 import com.netease.nimlib.session.MsgHelper;
4 import com.netease.nimlib.util.JSONHelper;
5 import com.netease.nimlib.util.storage.NimStorageType;
6 
7 import org.json.JSONObject;
8 
12 public class ImageAttachment extends FileAttachment {
16  private int width;
17 
21  private int height;
22 
23  public ImageAttachment() {
24 
25  }
26 
27  public ImageAttachment(String attach) {
28  super(attach);
29  }
30 
36  public int getWidth() {
37  return width;
38  }
39 
45  public void setWidth(int width) {
46  this.width = width;
47  }
48 
54  public int getHeight() {
55  return height;
56  }
57 
63  public void setHeight(int height) {
64  this.height = height;
65  }
66 
72  public String getThumbUrl() {
73  return MsgHelper.getThumbUrl(this, getUrl());
74  }
75 
76  public boolean isHdImage() {
77  return false;
78  }
79 
80  @Override
81  protected NimStorageType storageType() {
82  return NimStorageType.TYPE_IMAGE;
83  }
84 
85  private static final String KEY_WIDTH = "w";
86  private static final String KEY_HEIGHT = "h";
87 
88  @Override
89  protected void save(JSONObject json) {
90  JSONHelper.put(json, KEY_WIDTH, width);
91  JSONHelper.put(json, KEY_HEIGHT, height);
92  }
93 
94  @Override
95  protected void load(JSONObject json) {
96  width = JSONHelper.getInt(json, KEY_WIDTH);
97  height = JSONHelper.getInt(json, KEY_HEIGHT);
98  }
99 }
String getUrl()
获取文件在服务器上的下载url。若文件还未上传,返回null
带有文件的附件类型的基类 描述文件的相关信息