|
|
|
@ -12,6 +12,8 @@ import java.text.ParseException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Created by yishuqian on 28/09/2016.
|
|
|
|
@ -54,6 +56,9 @@ public class NoticeInfo {
|
|
|
|
|
}
|
|
|
|
|
res.put("merchants_type",merchants_type);
|
|
|
|
|
if (content != null){
|
|
|
|
|
if (content.contains("<img")) {
|
|
|
|
|
initImgAutoSize();
|
|
|
|
|
}
|
|
|
|
|
res.put("content",content);
|
|
|
|
|
}
|
|
|
|
|
if (status != null && status != "0"){
|
|
|
|
@ -106,6 +111,31 @@ public class NoticeInfo {
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void initImgAutoSize() {
|
|
|
|
|
String regxpForIMGTag = "<\\s*img\\s+([^>]*)\\s*/>";
|
|
|
|
|
Pattern pattern = Pattern.compile(regxpForIMGTag);
|
|
|
|
|
Matcher matcher = pattern.matcher(content);
|
|
|
|
|
while (matcher.find()) {
|
|
|
|
|
String imgStr = matcher.group(1);
|
|
|
|
|
String regxpForWidth = "width=\"([^\"]+)\"";
|
|
|
|
|
String regxpForHeight = "height=\"([^\"]+)\"";
|
|
|
|
|
Matcher matcherForWidth = Pattern.compile(regxpForWidth).matcher(imgStr);
|
|
|
|
|
if (matcherForWidth.find()){
|
|
|
|
|
setContent(content.replaceAll("(<img[^>]*?)\\s+width\\s*=\\s*\\S+", "$1 width=100%"));
|
|
|
|
|
}else {
|
|
|
|
|
String regex = "(?i)(\\<img)([^\\>]+\\>)";
|
|
|
|
|
setContent(content.replaceAll(regex, "$1 width =\"100%\"$2"));
|
|
|
|
|
}
|
|
|
|
|
Matcher matcherForHeight = Pattern.compile(regxpForHeight).matcher(imgStr);
|
|
|
|
|
if (matcherForHeight.find()){
|
|
|
|
|
setContent(content.replaceAll("(<img[^>]*?)\\s+height\\s*=\\s*\\S+", "$1 height=100%"));
|
|
|
|
|
}else {
|
|
|
|
|
String regex = "(?i)(\\<img)([^\\>]+\\>)";
|
|
|
|
|
setContent(content.replaceAll(regex, "$1 height =\"100%\"$2"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public String getTitle() {
|
|
|
|
|
return title;
|
|
|
|
|
}
|
|
|
|
|