diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-10-14 18:16:03 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-10-14 18:16:03 +0200 |
commit | e98460771bac4e2252556ea6cf483c93a1ecf176 (patch) | |
tree | b425a9cd492768027ded2b5047966240d0ca36cc /src/eu/siacs/conversations/entities/Message.java | |
parent | 470410b389bc38ab22fe5f877149c93795c5b0fb (diff) |
read image bounds on downloaded image
Diffstat (limited to 'src/eu/siacs/conversations/entities/Message.java')
-rw-r--r-- | src/eu/siacs/conversations/entities/Message.java | 65 |
1 files changed, 64 insertions, 1 deletions
diff --git a/src/eu/siacs/conversations/entities/Message.java b/src/eu/siacs/conversations/entities/Message.java index b459510c..863288bb 100644 --- a/src/eu/siacs/conversations/entities/Message.java +++ b/src/eu/siacs/conversations/entities/Message.java @@ -9,12 +9,12 @@ import eu.siacs.conversations.R; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; -import android.text.InputFilter.LengthFilter; public class Message extends AbstractEntity { public static final String TABLENAME = "messages"; + public static final int STATUS_RECEIVED_CHECKING = -4; public static final int STATUS_RECEPTION_FAILED = -3; public static final int STATUS_RECEIVED_OFFER = -2; public static final int STATUS_RECEIVING = -1; @@ -396,4 +396,67 @@ public class Message extends AbstractEntity { return false; } } + + public ImageParams getImageParams() { + ImageParams params = new ImageParams(); + if (body==null) { + return params; + } + String parts[] = body.split(","); + if (parts.length==1) { + try { + params.size = Long.parseLong(parts[0]); + } catch (NumberFormatException e) { + params.origin = parts[0]; + } + } else if (parts.length == 2) { + params.origin = parts[0]; + try { + params.size = Long.parseLong(parts[1]); + } catch (NumberFormatException e) { + params.size = 0; + } + } else if (parts.length==3) { + try { + params.size = Long.parseLong(parts[0]); + } catch (NumberFormatException e) { + params.size = 0; + } + try { + params.width = Integer.parseInt(parts[1]); + } catch (NumberFormatException e) { + params.width = 0; + } + try { + params.height = Integer.parseInt(parts[2]); + } catch (NumberFormatException e) { + params.height = 0; + } + } else if (parts.length == 4) { + params.origin = parts[0]; + try { + params.size = Long.parseLong(parts[1]); + } catch (NumberFormatException e) { + params.size = 0; + } + try { + params.width = Integer.parseInt(parts[2]); + } catch (NumberFormatException e) { + params.width = 0; + } + try { + params.height = Integer.parseInt(parts[3]); + } catch (NumberFormatException e) { + params.height = 0; + } + } + return params; + } + + public class ImageParams { + public long size = 0; + public int width = 0; + public int height = 0; + public String origin; + } } |