aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/entities
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/entities')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/entities/FileParams.java14
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/entities/Message.java2
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/entities/Transferable.java4
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/entities/TransferablePlaceholder.java5
4 files changed, 8 insertions, 17 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/entities/FileParams.java b/src/main/java/de/thedevstack/conversationsplus/entities/FileParams.java
index 7d5741d9..b21472ba 100644
--- a/src/main/java/de/thedevstack/conversationsplus/entities/FileParams.java
+++ b/src/main/java/de/thedevstack/conversationsplus/entities/FileParams.java
@@ -1,6 +1,7 @@
package de.thedevstack.conversationsplus.entities;
import de.thedevstack.conversationsplus.enums.FileStatus;
+import de.thedevstack.conversationsplus.utils.FileUtils;
import de.thedevstack.conversationsplus.utils.MimeUtils;
/**
@@ -12,7 +13,7 @@ public class FileParams {
private String path;
private String url;
private String mimeType;
- private long size = 0;
+ private long size = -1;
private int width = 0;
private int height = 0;
private FileStatus fileStatus;
@@ -136,15 +137,12 @@ public class FileParams {
path = (!path.endsWith(this.name)) ? path + "/" + this.name : path;
} else {
if (!path.endsWith("/")) {
- this.setName(path.substring(path.lastIndexOf('/') + 1));
+ this.setName(FileUtils.getFilenameFromPath(path));
}
}
if (null == this.mimeType) {
- int start = path.lastIndexOf('.') + 1;
- if (start < path.length()) {
- String extension = path.substring(start);
- this.mimeType = MimeUtils.guessMimeTypeFromExtension(extension);
- }
+ String extension = FileUtils.getLastExtension(path);
+ this.mimeType = MimeUtils.guessMimeTypeFromExtension(extension);
}
}
@@ -152,7 +150,7 @@ public class FileParams {
}
public boolean isRemoteAvailable() {
- return null != this.url || FileStatus.UPLOADED == this.fileStatus || FileStatus.DELETE_FAILED == this.fileStatus;
+ return (null != this.url || FileStatus.UPLOADED == this.fileStatus || FileStatus.DELETE_FAILED == this.fileStatus) && FileStatus.NOT_FOUND != this.fileStatus;
}
public void setFileStatus(FileStatus fileStatus) {
diff --git a/src/main/java/de/thedevstack/conversationsplus/entities/Message.java b/src/main/java/de/thedevstack/conversationsplus/entities/Message.java
index a553a3e6..4d7697f2 100644
--- a/src/main/java/de/thedevstack/conversationsplus/entities/Message.java
+++ b/src/main/java/de/thedevstack/conversationsplus/entities/Message.java
@@ -18,8 +18,6 @@ public class Message extends AbstractEntity {
public static final String TABLENAME = "messages";
- public static final String MERGE_SEPARATOR = " \u200B\n\n";
-
public static final int STATUS_RECEIVED = 0;
public static final int STATUS_UNSEND = 1;
public static final int STATUS_SEND = 2;
diff --git a/src/main/java/de/thedevstack/conversationsplus/entities/Transferable.java b/src/main/java/de/thedevstack/conversationsplus/entities/Transferable.java
index 8e2ca20e..10bc8bcf 100644
--- a/src/main/java/de/thedevstack/conversationsplus/entities/Transferable.java
+++ b/src/main/java/de/thedevstack/conversationsplus/entities/Transferable.java
@@ -1,6 +1,8 @@
package de.thedevstack.conversationsplus.entities;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
public interface Transferable {
@@ -23,8 +25,6 @@ public interface Transferable {
int getStatus();
- long getFileSize();
-
int getProgress();
void cancel();
diff --git a/src/main/java/de/thedevstack/conversationsplus/entities/TransferablePlaceholder.java b/src/main/java/de/thedevstack/conversationsplus/entities/TransferablePlaceholder.java
index c51320d1..40292e1f 100644
--- a/src/main/java/de/thedevstack/conversationsplus/entities/TransferablePlaceholder.java
+++ b/src/main/java/de/thedevstack/conversationsplus/entities/TransferablePlaceholder.java
@@ -18,11 +18,6 @@ public class TransferablePlaceholder implements Transferable {
}
@Override
- public long getFileSize() {
- return 0;
- }
-
- @Override
public int getProgress() {
return 0;
}