Skip to content

Commit 387c8b5

Browse files
committed
解决文件size太大超过 int 最大值的问题
1 parent 6d077de commit 387c8b5

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

app/src/main/java/net/coding/program/project/detail/AttachmentsDownloadDetailActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,8 @@ private void bindView() {
372372
content.setText(Global.HumanReadableFilesize(mFileObject.getSize()));
373373

374374
tvDownload.setText(String.format(downloadFormat, Global.HumanReadableFilesize(0.0), Global.HumanReadableFilesize(mFileObject.getSize())));
375-
progressBar.setMax(mFileObject.getSize());
375+
long size = mFileObject.getSize();
376+
progressBar.setMax(size > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) size);
376377
mainLayout.setVisibility(View.VISIBLE);
377378

378379
mFile = FileUtil.getDestinationInExternalPublicDir(getFileDownloadPath(), mFileObject.getSaveName(mProjectObjectId));

common-coding/src/main/java/net/coding/program/common/model/AttachmentFileObject.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public class AttachmentFileObject implements Serializable, ShareParam {
8787
public int[] bytesAndStatus;
8888
public AttachmentFolderObject folderObject;
8989
private String name = "";
90-
private int size = 0;
90+
private long size = 0;
9191
private int history_id;
9292
private String share_url = ""; // 早期的版本是使用 share_url,现在的版本改成了 share
9393
private Share share;
@@ -362,7 +362,7 @@ public void setName(String s) {
362362
name = s;
363363
}
364364

365-
public int getSize() {
365+
public long getSize() {
366366
return size;
367367
}
368368

common-coding/src/main/java/net/coding/program/network/model/file/CodingFile.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public class CodingFile implements Serializable {
7575
public int type; // 0 文件夹 2 png 文件
7676
@SerializedName("size")
7777
@Expose
78-
public int size;
78+
public long size;
7979
@SerializedName("name")
8080
@Expose
8181
public String name = "";
@@ -267,7 +267,7 @@ public void setName(String s) {
267267
name = s;
268268
}
269269

270-
public int getSize() {
270+
public long getSize() {
271271
return size;
272272
}
273273

0 commit comments

Comments
 (0)