Commit b5e324fe by Lee Munkyeong

Merge branch 'features/#467_does_not_show_profile_on_offline' into 'features/abcomm_sp6'

オフライン対応

See merge request !105
parents 43e99294 3855619c
...@@ -96,10 +96,18 @@ public interface ABookCommConstants { ...@@ -96,10 +96,18 @@ public interface ABookCommConstants {
Integer DM = 1; Integer DM = 1;
Integer ALL = 2; Integer ALL = 2;
} }
interface MESSAGE_TYPE {
Integer TEXT = 0;
Integer PHOTO = 1;
Integer VIDEO = 2;
Integer SYSTEM = 4;
}
Integer GROUP_REQUEST_ALL = 0; Integer GROUP_REQUEST_ALL = 0;
} }
interface SIZE { interface SIZE {
Integer MAX_FAVORITE_COUNT = 100; Integer MAX_FAVORITE_COUNT = 100;
} }
String FILE_SAVE_PATH = "/data/user/0/jp.co.agentec.abookplus.check/files/";
} }
...@@ -3,6 +3,7 @@ package jp.agentec.abook.abv.bl.logic; ...@@ -3,6 +3,7 @@ package jp.agentec.abook.abv.bl.logic;
import org.json.adf.JSONArray; import org.json.adf.JSONArray;
import org.json.adf.JSONObject; import org.json.adf.JSONObject;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
...@@ -38,6 +39,8 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -38,6 +39,8 @@ public class CommunicationLogic extends AbstractLogic {
private ChatMessageDao chatMessageDao = AbstractDao.getDao(ChatMessageDao.class); private ChatMessageDao chatMessageDao = AbstractDao.getDao(ChatMessageDao.class);
private ShopMemberDao shopMemberDao = AbstractDao.getDao(ShopMemberDao.class); private ShopMemberDao shopMemberDao = AbstractDao.getDao(ShopMemberDao.class);
private ChatGroupDao chatGroupDao = AbstractDao.getDao(ChatGroupDao.class); private ChatGroupDao chatGroupDao = AbstractDao.getDao(ChatGroupDao.class);
private String localFilePath;
private ArchiveDao archiveDao = AbstractDao.getDao(ArchiveDao.class); private ArchiveDao archiveDao = AbstractDao.getDao(ArchiveDao.class);
/** /**
...@@ -66,7 +69,11 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -66,7 +69,11 @@ public class CommunicationLogic extends AbstractLogic {
chatRoomMap.put(ABookCommConstants.KEY.TYPE, chatRoomDto.type); chatRoomMap.put(ABookCommConstants.KEY.TYPE, chatRoomDto.type);
chatRoomMap.put(ABookCommConstants.KEY.FAVORITE_REGISTER_DATE, chatRoomDto.favoriteRegisterDate); chatRoomMap.put(ABookCommConstants.KEY.FAVORITE_REGISTER_DATE, chatRoomDto.favoriteRegisterDate);
chatRoomMap.put(ABookCommConstants.KEY.UNREAD_COUNT, chatRoomDto.unreadCount); chatRoomMap.put(ABookCommConstants.KEY.UNREAD_COUNT, chatRoomDto.unreadCount);
chatRoomMap.put(ABookCommConstants.KEY.MESSAGE, chatRoomDto.message); if (ABookCommConstants.FLAG.MESSAGE_TYPE.PHOTO.equals(chatRoomDto.messageType) || ABookCommConstants.FLAG.MESSAGE_TYPE.VIDEO.equals(chatRoomDto.messageType)) {
chatRoomMap.put(ABookCommConstants.KEY.MESSAGE, getFileUrlPath(chatRoomDto.message));
} else {
chatRoomMap.put(ABookCommConstants.KEY.MESSAGE, chatRoomDto.message);
}
chatRoomMap.put(ABookCommConstants.KEY.MESSAGE_TYPE, chatRoomDto.messageType); chatRoomMap.put(ABookCommConstants.KEY.MESSAGE_TYPE, chatRoomDto.messageType);
chatRoomMap.put(ABookCommConstants.KEY.INSERT_DATE, chatRoomDto.insertDate); chatRoomMap.put(ABookCommConstants.KEY.INSERT_DATE, chatRoomDto.insertDate);
chatRoomMap.put(ABookCommConstants.KEY.USER_COUNT, chatRoomDto.userCount); chatRoomMap.put(ABookCommConstants.KEY.USER_COUNT, chatRoomDto.userCount);
...@@ -77,7 +84,7 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -77,7 +84,7 @@ public class CommunicationLogic extends AbstractLogic {
for (ShopMemberDto user : userList) { for (ShopMemberDto user : userList) {
Map<String, Object> userMap = new HashMap<String, Object>(); Map<String, Object> userMap = new HashMap<String, Object>();
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, user.shopMemberId); userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, user.shopMemberId);
userMap.put(ABookCommConstants.KEY.PROFILE_URL, user.profileUrl); userMap.put(ABookCommConstants.KEY.PROFILE_URL, getProfileUrlPath(user.profileUrl));
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, user.shopMemberName); userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, user.shopMemberName);
JSONObject jsonObject = new JSONObject(userMap); JSONObject jsonObject = new JSONObject(userMap);
attendUsers.put(jsonObject); attendUsers.put(jsonObject);
...@@ -97,7 +104,7 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -97,7 +104,7 @@ public class CommunicationLogic extends AbstractLogic {
for (ShopMemberDto user : userList) { for (ShopMemberDto user : userList) {
Map<String, Object> userMap = new HashMap<String, Object>(); Map<String, Object> userMap = new HashMap<String, Object>();
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, user.shopMemberId); userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, user.shopMemberId);
userMap.put(ABookCommConstants.KEY.PROFILE_URL, user.profileUrl); userMap.put(ABookCommConstants.KEY.PROFILE_URL, getProfileUrlPath(user.profileUrl));
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, user.shopMemberName); userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, user.shopMemberName);
JSONObject jsonObject = new JSONObject(userMap); JSONObject jsonObject = new JSONObject(userMap);
attendUsers.put(jsonObject); attendUsers.put(jsonObject);
...@@ -115,10 +122,14 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -115,10 +122,14 @@ public class CommunicationLogic extends AbstractLogic {
chatMessageMap.put(ABookCommConstants.KEY.CHAT_ROOM_ID, chatMessageDto.chatRoomId); chatMessageMap.put(ABookCommConstants.KEY.CHAT_ROOM_ID, chatMessageDto.chatRoomId);
chatMessageMap.put(ABookCommConstants.KEY.LOGIN_ID, chatMessageDto.shopMemberName); chatMessageMap.put(ABookCommConstants.KEY.LOGIN_ID, chatMessageDto.shopMemberName);
chatMessageMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, chatMessageDto.shopMemberId); chatMessageMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, chatMessageDto.shopMemberId);
chatMessageMap.put(ABookCommConstants.KEY.MESSAGE, chatMessageDto.message); if (ABookCommConstants.FLAG.MESSAGE_TYPE.PHOTO.equals(chatMessageDto.messageType) || ABookCommConstants.FLAG.MESSAGE_TYPE.VIDEO.equals(chatMessageDto.messageType)) {
chatMessageMap.put(ABookCommConstants.KEY.MESSAGE, getFileUrlPath(chatMessageDto.message));
} else {
chatMessageMap.put(ABookCommConstants.KEY.MESSAGE, chatMessageDto.message);
}
chatMessageMap.put(ABookCommConstants.KEY.MESSAGE_TYPE, chatMessageDto.messageType); chatMessageMap.put(ABookCommConstants.KEY.MESSAGE_TYPE, chatMessageDto.messageType);
chatMessageMap.put(ABookCommConstants.KEY.INSERT_DATE, chatMessageDto.insertDate); chatMessageMap.put(ABookCommConstants.KEY.INSERT_DATE, chatMessageDto.insertDate);
chatMessageMap.put(ABookCommConstants.KEY.PROFILE_URL, chatMessageDto.profileUrl); chatMessageMap.put(ABookCommConstants.KEY.PROFILE_URL, getProfileUrlPath(chatMessageDto.profileUrl));
chatMessageMap.put(ABookCommConstants.KEY.SELF_FLG, chatMessageDto.selfFlg); chatMessageMap.put(ABookCommConstants.KEY.SELF_FLG, chatMessageDto.selfFlg);
chatMessageMap.put(ABookCommConstants.KEY.UNREAD_COUNT, chatMessageDto.unreadCount); chatMessageMap.put(ABookCommConstants.KEY.UNREAD_COUNT, chatMessageDto.unreadCount);
JSONObject jsonObject = new JSONObject(chatMessageMap); JSONObject jsonObject = new JSONObject(chatMessageMap);
...@@ -138,10 +149,14 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -138,10 +149,14 @@ public class CommunicationLogic extends AbstractLogic {
chatMessageMap.put(ABookCommConstants.KEY.CHAT_ROOM_ID, chatMessageDto.chatRoomId); chatMessageMap.put(ABookCommConstants.KEY.CHAT_ROOM_ID, chatMessageDto.chatRoomId);
chatMessageMap.put(ABookCommConstants.KEY.LOGIN_ID, chatMessageDto.shopMemberName); chatMessageMap.put(ABookCommConstants.KEY.LOGIN_ID, chatMessageDto.shopMemberName);
chatMessageMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, chatMessageDto.shopMemberId); chatMessageMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, chatMessageDto.shopMemberId);
chatMessageMap.put(ABookCommConstants.KEY.MESSAGE, chatMessageDto.message); if (ABookCommConstants.FLAG.MESSAGE_TYPE.PHOTO.equals(chatMessageDto.messageType) || ABookCommConstants.FLAG.MESSAGE_TYPE.VIDEO.equals(chatMessageDto.messageType)) {
chatMessageMap.put(ABookCommConstants.KEY.MESSAGE, getFileUrlPath(chatMessageDto.message));
} else {
chatMessageMap.put(ABookCommConstants.KEY.MESSAGE, chatMessageDto.message);
}
chatMessageMap.put(ABookCommConstants.KEY.MESSAGE_TYPE, chatMessageDto.messageType); chatMessageMap.put(ABookCommConstants.KEY.MESSAGE_TYPE, chatMessageDto.messageType);
chatMessageMap.put(ABookCommConstants.KEY.INSERT_DATE, chatMessageDto.insertDate); chatMessageMap.put(ABookCommConstants.KEY.INSERT_DATE, chatMessageDto.insertDate);
chatMessageMap.put(ABookCommConstants.KEY.PROFILE_URL, chatMessageDto.profileUrl); chatMessageMap.put(ABookCommConstants.KEY.PROFILE_URL, getProfileUrlPath(chatMessageDto.profileUrl));
chatMessageMap.put(ABookCommConstants.KEY.SELF_FLG, chatMessageDto.selfFlg); chatMessageMap.put(ABookCommConstants.KEY.SELF_FLG, chatMessageDto.selfFlg);
chatMessageMap.put(ABookCommConstants.KEY.UNREAD_COUNT, chatMessageDto.unreadCount); chatMessageMap.put(ABookCommConstants.KEY.UNREAD_COUNT, chatMessageDto.unreadCount);
JSONObject jsonObject = new JSONObject(chatMessageMap); JSONObject jsonObject = new JSONObject(chatMessageMap);
...@@ -170,7 +185,7 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -170,7 +185,7 @@ public class CommunicationLogic extends AbstractLogic {
} }
resultJson.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, shopMemberDto.shopMemberId); resultJson.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, shopMemberDto.shopMemberId);
resultJson.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, shopMemberDto.shopMemberName); resultJson.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, shopMemberDto.shopMemberName);
resultJson.put(ABookCommConstants.KEY.PROFILE_URL, shopMemberDto.profileUrl); resultJson.put(ABookCommConstants.KEY.PROFILE_URL, getProfileUrlPath(shopMemberDto.profileUrl));
resultJson.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathJsonArray); resultJson.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathJsonArray);
boolean hasRegisteredDate = StringUtil.isNullOrEmpty(shopMemberDto.favoriteRegisterDate) == false; boolean hasRegisteredDate = StringUtil.isNullOrEmpty(shopMemberDto.favoriteRegisterDate) == false;
resultJson.put(ABookCommConstants.KEY.IS_FAVORITE, hasRegisteredDate); resultJson.put(ABookCommConstants.KEY.IS_FAVORITE, hasRegisteredDate);
...@@ -184,7 +199,7 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -184,7 +199,7 @@ public class CommunicationLogic extends AbstractLogic {
JSONObject myInfoJson = new JSONObject(); JSONObject myInfoJson = new JSONObject();
myInfoJson.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, myInfo.shopMemberId); myInfoJson.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, myInfo.shopMemberId);
myInfoJson.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, myInfo.shopMemberName); myInfoJson.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, myInfo.shopMemberName);
myInfoJson.put(ABookCommConstants.KEY.PROFILE_URL, myInfo.profileUrl); myInfoJson.put(ABookCommConstants.KEY.PROFILE_URL, getProfileUrlPath(myInfo.profileUrl));
myInfoJson.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathList); myInfoJson.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathList);
String myInfoStr = myInfoJson.toString(); String myInfoStr = myInfoJson.toString();
return myInfoStr; return myInfoStr;
...@@ -204,7 +219,7 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -204,7 +219,7 @@ public class CommunicationLogic extends AbstractLogic {
myGroupUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, groupUser.shopMemberId); myGroupUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, groupUser.shopMemberId);
myGroupUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, groupUser.shopMemberName); myGroupUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, groupUser.shopMemberName);
myGroupUserMap.put(ABookCommConstants.KEY.CHECKED, ""); myGroupUserMap.put(ABookCommConstants.KEY.CHECKED, "");
myGroupUserMap.put(ABookCommConstants.KEY.PROFILE_URL, groupUser.profileUrl); myGroupUserMap.put(ABookCommConstants.KEY.PROFILE_URL, getProfileUrlPath(groupUser.profileUrl));
myGroupUserMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupUser); myGroupUserMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupUser);
if (StringUtil.isNullOrEmpty(groupUser.favoriteRegisterDate)) { if (StringUtil.isNullOrEmpty(groupUser.favoriteRegisterDate)) {
myGroupUserMap.put(ABookCommConstants.KEY.IS_FAVORITE, false); myGroupUserMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
...@@ -235,7 +250,7 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -235,7 +250,7 @@ public class CommunicationLogic extends AbstractLogic {
myGroupUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, groupUser.shopMemberId); myGroupUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, groupUser.shopMemberId);
myGroupUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, groupUser.shopMemberName); myGroupUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, groupUser.shopMemberName);
myGroupUserMap.put(ABookCommConstants.KEY.CHECKED, ""); myGroupUserMap.put(ABookCommConstants.KEY.CHECKED, "");
myGroupUserMap.put(ABookCommConstants.KEY.PROFILE_URL, groupUser.profileUrl); myGroupUserMap.put(ABookCommConstants.KEY.PROFILE_URL, getProfileUrlPath(groupUser.profileUrl));
myGroupUserMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupUser); myGroupUserMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupUser);
if (StringUtil.isNullOrEmpty(groupUser.favoriteRegisterDate)) { if (StringUtil.isNullOrEmpty(groupUser.favoriteRegisterDate)) {
myGroupUserMap.put(ABookCommConstants.KEY.IS_FAVORITE, false); myGroupUserMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
...@@ -271,7 +286,7 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -271,7 +286,7 @@ public class CommunicationLogic extends AbstractLogic {
} }
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, shopMember.shopMemberId); userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, shopMember.shopMemberId);
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, shopMember.shopMemberName); userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, shopMember.shopMemberName);
userMap.put(ABookCommConstants.KEY.PROFILE_URL, shopMember.profileUrl); userMap.put(ABookCommConstants.KEY.PROFILE_URL, getProfileUrlPath(shopMember.profileUrl));
userMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathArray); userMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathArray);
if (StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate)) { if (StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate)) {
userMap.put(ABookCommConstants.KEY.IS_FAVORITE, false); userMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
...@@ -305,7 +320,7 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -305,7 +320,7 @@ public class CommunicationLogic extends AbstractLogic {
} }
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, shopMember.shopMemberId); userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, shopMember.shopMemberId);
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, shopMember.shopMemberName); userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, shopMember.shopMemberName);
userMap.put(ABookCommConstants.KEY.PROFILE_URL, shopMember.profileUrl); userMap.put(ABookCommConstants.KEY.PROFILE_URL, getProfileUrlPath(shopMember.profileUrl));
userMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathArray); userMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathArray);
if (StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate)) { if (StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate)) {
userMap.put(ABookCommConstants.KEY.IS_FAVORITE, false); userMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
...@@ -338,7 +353,7 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -338,7 +353,7 @@ public class CommunicationLogic extends AbstractLogic {
} }
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, shopMember.shopMemberId); userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, shopMember.shopMemberId);
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, shopMember.shopMemberName); userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, shopMember.shopMemberName);
userMap.put(ABookCommConstants.KEY.PROFILE_URL, shopMember.profileUrl); userMap.put(ABookCommConstants.KEY.PROFILE_URL, getProfileUrlPath(shopMember.profileUrl));
userMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathArray); userMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathArray);
if (StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate)) { if (StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate)) {
userMap.put(ABookCommConstants.KEY.IS_FAVORITE, false); userMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
...@@ -373,7 +388,7 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -373,7 +388,7 @@ public class CommunicationLogic extends AbstractLogic {
} }
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, shopMember.shopMemberId); userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, shopMember.shopMemberId);
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, shopMember.shopMemberName); userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, shopMember.shopMemberName);
userMap.put(ABookCommConstants.KEY.PROFILE_URL, shopMember.profileUrl); userMap.put(ABookCommConstants.KEY.PROFILE_URL, getProfileUrlPath(shopMember.profileUrl));
userMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathArray); userMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathArray);
if (StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate)) { if (StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate)) {
userMap.put(ABookCommConstants.KEY.IS_FAVORITE, false); userMap.put(ABookCommConstants.KEY.IS_FAVORITE, false);
...@@ -448,7 +463,7 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -448,7 +463,7 @@ public class CommunicationLogic extends AbstractLogic {
favoriteUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, favoriteUser.shopMemberId); favoriteUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, favoriteUser.shopMemberId);
favoriteUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, favoriteUser.shopMemberName); favoriteUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, favoriteUser.shopMemberName);
favoriteUserMap.put(ABookCommConstants.KEY.CHECKED, ""); favoriteUserMap.put(ABookCommConstants.KEY.CHECKED, "");
favoriteUserMap.put(ABookCommConstants.KEY.PROFILE_URL, favoriteUser.profileUrl); favoriteUserMap.put(ABookCommConstants.KEY.PROFILE_URL, getProfileUrlPath(favoriteUser.profileUrl));
favoriteUserMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathArray); favoriteUserMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathArray);
favoriteUserMap.put(ABookCommConstants.KEY.IS_FAVORITE, true); favoriteUserMap.put(ABookCommConstants.KEY.IS_FAVORITE, true);
JSONObject jsonObject = new JSONObject(favoriteUserMap); JSONObject jsonObject = new JSONObject(favoriteUserMap);
...@@ -478,7 +493,7 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -478,7 +493,7 @@ public class CommunicationLogic extends AbstractLogic {
favoriteUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, favoriteUser.shopMemberId); favoriteUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, favoriteUser.shopMemberId);
favoriteUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, favoriteUser.shopMemberName); favoriteUserMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, favoriteUser.shopMemberName);
favoriteUserMap.put(ABookCommConstants.KEY.CHECKED, ""); favoriteUserMap.put(ABookCommConstants.KEY.CHECKED, "");
favoriteUserMap.put(ABookCommConstants.KEY.PROFILE_URL, favoriteUser.profileUrl); favoriteUserMap.put(ABookCommConstants.KEY.PROFILE_URL, getProfileUrlPath(favoriteUser.profileUrl));
favoriteUserMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathArray); favoriteUserMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, groupPathArray);
favoriteUserMap.put(ABookCommConstants.KEY.IS_FAVORITE, true); favoriteUserMap.put(ABookCommConstants.KEY.IS_FAVORITE, true);
JSONObject jsonObject = new JSONObject(favoriteUserMap); JSONObject jsonObject = new JSONObject(favoriteUserMap);
...@@ -572,7 +587,7 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -572,7 +587,7 @@ public class CommunicationLogic extends AbstractLogic {
Map<String, Object> shopMemberMap = new HashMap<String, Object>(); Map<String, Object> shopMemberMap = new HashMap<String, Object>();
shopMemberMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, shopMember.shopMemberId); shopMemberMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, shopMember.shopMemberId);
shopMemberMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, shopMember.shopMemberName); shopMemberMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, shopMember.shopMemberName);
shopMemberMap.put(ABookCommConstants.KEY.PROFILE_URL, shopMember.profileUrl); shopMemberMap.put(ABookCommConstants.KEY.PROFILE_URL, getProfileUrlPath(shopMember.profileUrl));
shopMemberMap.put(ABookCommConstants.KEY.CHECKED, ""); shopMemberMap.put(ABookCommConstants.KEY.CHECKED, "");
shopMemberMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, chatGroupDao.getUserGroupPathList(shopMember.shopMemberId)); shopMemberMap.put(ABookCommConstants.KEY.GROUP_PATH_LIST, chatGroupDao.getUserGroupPathList(shopMember.shopMemberId));
if (StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate)) { if (StringUtil.isNullOrEmpty(shopMember.favoriteRegisterDate)) {
...@@ -777,13 +792,14 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -777,13 +792,14 @@ public class CommunicationLogic extends AbstractLogic {
public void roomDisplayOff(Integer roomId) { public void roomDisplayOff(Integer roomId) {
chatRoomDao.changeRoomViewFlg(roomId); chatRoomDao.changeRoomViewFlg(roomId);
} }
public String getUserList(String userIdList) { public String getUserList(String userIdList) {
List<ShopMemberDto> selectedUsers = shopMemberDao.getSelectedUsers(userIdList); List<ShopMemberDto> selectedUsers = shopMemberDao.getSelectedUsers(userIdList);
JSONArray attendUsers = new JSONArray(); JSONArray attendUsers = new JSONArray();
for (ShopMemberDto dto : selectedUsers) { for (ShopMemberDto dto : selectedUsers) {
Map<String, Object> userMap = new HashMap<String, Object>(); Map<String, Object> userMap = new HashMap<String, Object>();
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, dto.shopMemberId); userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, dto.shopMemberId);
userMap.put(ABookCommConstants.KEY.PROFILE_URL, dto.profileUrl); userMap.put(ABookCommConstants.KEY.PROFILE_URL, getProfileUrlPath(dto.profileUrl));
userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, dto.shopMemberName); userMap.put(ABookCommConstants.KEY.SHOP_MEMBER_NAME, dto.shopMemberName);
JSONObject jsonObject = new JSONObject(userMap); JSONObject jsonObject = new JSONObject(userMap);
attendUsers.put(jsonObject); attendUsers.put(jsonObject);
...@@ -791,6 +807,46 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -791,6 +807,46 @@ public class CommunicationLogic extends AbstractLogic {
return attendUsers.toString(); return attendUsers.toString();
}; };
public String getProfileUrlPath(String profileUrl) {
if (profileUrl == null) {
return null;
}
String[] filePaths = profileUrl.split("/");
String fileName = filePaths[filePaths.length-1];
String filePath = localFilePath + fileName;
File file = new File(filePath);
if (file.exists()) {
String uri = file.toURI().toString();
return uri;
} else {
return profileUrl;
}
};
public String getFileUrlPath(String fileUrlPath) {
if (!fileUrlPath.contains("fileName=")) {
return fileUrlPath;
}
String fileName = fileUrlPath.split("fileName=")[1].split("&amp;")[0];
String filePath = localFilePath + fileName;
File file = new File(filePath);
if (file.exists()) {
String replaceTarget = "https" + fileUrlPath.split("https")[1].split("\"")[0];
String uri = file.toURI().toString();
String resultPath = fileUrlPath;
while (resultPath.contains(replaceTarget)) {
resultPath = resultPath.replace(replaceTarget, uri);
}
return resultPath;
} else {
return fileUrlPath;
}
};
public void setPackagePath(String localFilePath) {
this.localFilePath = localFilePath;
}
public String getAllArchive() { public String getAllArchive() {
List<ArchiveDto> archiveList = archiveDao.getAllArchive(); List<ArchiveDto> archiveList = archiveDao.getAllArchive();
JSONArray archiveArray = new JSONArray(); JSONArray archiveArray = new JSONArray();
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.GET_TASKS" /><!-- ActivityManager.RunningTaskInfo --> <uses-permission android:name="android.permission.GET_TASKS" /><!-- ActivityManager.RunningTaskInfo -->
<uses-permission android:name="android.permission.WAKE_LOCK" /><!-- using PowerManager WakeLocks to keep processor from sleeping or screen from dimming --> <uses-permission android:name="android.permission.WAKE_LOCK" /><!-- using PowerManager WakeLocks to keep processor from sleeping or screen from dimming -->
<uses-permission android:name="android.permission.READ_LOGS" /><!-- an application to read the low-level system log files. --> <uses-permission android:name="android.permission.READ_LOGS" /><!-- an application to read the low-level system log files. -->
......
package jp.agentec.abook.abv.cl.util; package jp.agentec.abook.abv.cl.util;
import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
...@@ -17,6 +18,7 @@ import android.graphics.BitmapFactory; ...@@ -17,6 +18,7 @@ import android.graphics.BitmapFactory;
import android.graphics.Color; import android.graphics.Color;
import android.media.MediaMetadataRetriever; import android.media.MediaMetadataRetriever;
import android.media.MediaPlayer; import android.media.MediaPlayer;
import android.util.Base64;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.WriterException; import com.google.zxing.WriterException;
...@@ -433,4 +435,21 @@ public class BitmapUtil { ...@@ -433,4 +435,21 @@ public class BitmapUtil {
return bitmapList; return bitmapList;
} }
public static Bitmap convert(String base64Str) throws IllegalArgumentException {
byte[] decodedBytes = Base64.decode(
base64Str.substring(base64Str.indexOf(",") + 1),
Base64.DEFAULT
);
return BitmapFactory.decodeByteArray(decodedBytes, 0, decodedBytes.length);
}
public static String convert(Bitmap bitmap) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, outputStream);
return Base64.encodeToString(outputStream.toByteArray(), Base64.DEFAULT);
}
} }
package jp.agentec.abook.abv.ui.home.activity; package jp.agentec.abook.abv.ui.home.activity;
import android.annotation.SuppressLint;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.app.DownloadManager; import android.app.DownloadManager;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.ContentValues;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkInfo;
import android.net.Uri; import android.net.Uri;
import android.net.wifi.WifiManager;
import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
import android.util.Log; import android.util.Log;
...@@ -30,9 +39,12 @@ import android.widget.ImageView; ...@@ -30,9 +39,12 @@ import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.Toast; import android.widget.Toast;
import org.json.adf.HTTP; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -124,13 +136,14 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -124,13 +136,14 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (isNormalSize()) { if (isNormalSize()) {
setPortraitIfNormal(); setPortraitIfNormal();
} }
setContentView(R.layout.chat_webview); setContentView(R.layout.chat_webview);
Intent intent = getIntent(); Intent intent = getIntent();
communicationLogic.setPackagePath(getFilesDir().getAbsolutePath() + "/");
sid = intent.getStringExtra("sid"); sid = intent.getStringExtra("sid");
roomId = intent.getLongExtra("roomId", 0); roomId = intent.getLongExtra("roomId", 0);
roomName = intent.getStringExtra("roomName"); roomName = intent.getStringExtra("roomName");
...@@ -212,6 +225,8 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -212,6 +225,8 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
mChatWebView.setWebChromeClient(new FullscreenableChromeClient(this) { mChatWebView.setWebChromeClient(new FullscreenableChromeClient(this) {
@Override @Override
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) { public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
boolean result = false; boolean result = false;
...@@ -362,23 +377,64 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -362,23 +377,64 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG).show();
} }
}); });
// ブロードキャストレシーバーの追加 // ブロードキャストレシーバーの追加
receiver = new BroadcastReceiver() { receiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
ConnectivityManager connectivityManager = (ConnectivityManager) getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(intent.getAction())) { if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(intent.getAction())) {
mChatWebView.loadUrl("javascript:CHAT_UI.dismissLoadingIndicator()"); mChatWebView.loadUrl("javascript:CHAT_UI.dismissLoadingIndicator()");
} }
if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
if (networkInfo == null || !networkInfo.isConnectedOrConnecting()) {
isOnline = false;
mChatWebView.loadUrl("javascript:CHAT_UI.refreshForOffline();");
} else {
isOnline = true;
mChatWebView.loadUrl("javascript:CHAT_UI.refreshForOnline();");
}
}
} }
}; };
// レシーバーオブジェクトの生成 // レシーバーオブジェクトの生成
IntentFilter tempIntent = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE); IntentFilter tempIntent = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
tempIntent.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
tempIntent.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
registerReceiver(receiver, tempIntent); registerReceiver(receiver, tempIntent);
mChatWebView.setWebViewClient(new WebViewClient() { mChatWebView.setWebViewClient(new WebViewClient() {
@Override @Override
public void onLoadResource(WebView view, String url) {
if (url.contains("profileFileName")) {
Uri uri = Uri.parse(url);
String fileName = uri.getQueryParameter("profileFileName");
String filePath = getFilesDir().getAbsolutePath() + "/" + fileName;
Logger.d(TAG, filePath);
File file = new File(filePath);
NetworkTask networkTask = new NetworkTask(url, filePath);
networkTask.execute();
} else if (url.contains("/file/getImage")) {
Uri uri = Uri.parse(url);
String fileName = uri.getQueryParameter("fileName");
String filePath = getFilesDir().getAbsolutePath() + "/" + fileName;
Logger.d(TAG, filePath);
File file = new File(filePath);
NetworkTask networkTask = new NetworkTask(url, filePath);
networkTask.execute();
} else {
super.onLoadResource(view, url);
}
}
@Override
public void onReceivedError(WebView view, int errorCode, public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) { String description, String failingUrl) {
...@@ -406,7 +462,8 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -406,7 +462,8 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
DownloadManager mdDownloadManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); DownloadManager mdDownloadManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request( DownloadManager.Request request = new DownloadManager.Request(
Uri.parse(url)); Uri.parse(url));
File destinationFile = new File(Environment.getExternalStorageDirectory(), fileName); request.setDescription("Downloading ..."); File destinationFile = new File(Environment.getExternalStorageDirectory(), fileName);
request.setDescription("Downloading ...");
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationUri(Uri.fromFile(destinationFile)); request.setDestinationUri(Uri.fromFile(destinationFile));
assert mdDownloadManager != null; assert mdDownloadManager != null;
...@@ -957,8 +1014,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -957,8 +1014,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
} }
@JavascriptInterface @JavascriptInterface
public boolean addFavoriteUser(String shopMemberId) throws NetworkDisconnectedException, AcmsException { public boolean addFavoriteUser(String shopMemberId) throws AcmsException {
Integer favoriteCount = communicationLogic.getFavoriteCount(); Integer favoriteCount = communicationLogic.getFavoriteCount();
if (favoriteCount >= ABookCommConstants.SIZE.MAX_FAVORITE_COUNT ) { if (favoriteCount >= ABookCommConstants.SIZE.MAX_FAVORITE_COUNT ) {
mChatWebView.post(new Runnable() { mChatWebView.post(new Runnable() {
...@@ -969,8 +1025,37 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -969,8 +1025,37 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
}); });
return false; return false;
} else { } else {
boolean result = insertFavoriteUser(shopMemberId); boolean result = false;
if (!result) { return false; } try {
result = insertFavoriteUser(shopMemberId);
if (!result) { return false; }
mChatWebView.post(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl("javascript:CHAT_UI.refreshContactScreen();");
}
});
return true;
} catch (NetworkDisconnectedException e) {
mChatWebView.post(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl("javascript:alert('接続しているネットワークがありません。');");
}
});
}
}
return false;
}
@JavascriptInterface
public boolean removeFavoriteUser(String shopMemberId) throws AcmsException {
try {
boolean result = deleteFavoriteUser(shopMemberId);
if (!result) {
return false;
}
mChatWebView.post(new Runnable() { mChatWebView.post(new Runnable() {
@Override @Override
public void run() { public void run() {
...@@ -978,24 +1063,19 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -978,24 +1063,19 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
} }
}); });
return true; return true;
} } catch (NetworkDisconnectedException e) {
}
@JavascriptInterface
public void removeFavoriteUser(String shopMemberId) throws NetworkDisconnectedException, AcmsException {
boolean result = deleteFavoriteUser(shopMemberId);
if (result) {
mChatWebView.post(new Runnable() { mChatWebView.post(new Runnable() {
@Override @Override
public void run() { public void run() {
mChatWebView.loadUrl("javascript:CHAT_UI.refreshContactScreen();"); mChatWebView.loadUrl("javascript:alert('接続しているネットワークがありません。');");
} }
}); });
} }
return false;
} }
@JavascriptInterface @JavascriptInterface
public boolean addFavoriteGroup(String groupId) throws NetworkDisconnectedException, AcmsException { public boolean addFavoriteGroup(String groupId) throws AcmsException {
Integer favoriteCount = communicationLogic.getFavoriteCount(); Integer favoriteCount = communicationLogic.getFavoriteCount();
if (favoriteCount >= ABookCommConstants.SIZE.MAX_FAVORITE_COUNT) { if (favoriteCount >= ABookCommConstants.SIZE.MAX_FAVORITE_COUNT) {
...@@ -1007,8 +1087,12 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -1007,8 +1087,12 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
}); });
return false; return false;
} else { } else {
boolean result = insertFavoriteGroup(groupId); boolean result = false;
if (result) { try {
result = insertFavoriteGroup(groupId);
if (!result) {
return false;
}
mChatWebView.post(new Runnable() { mChatWebView.post(new Runnable() {
@Override @Override
public void run() { public void run() {
...@@ -1016,22 +1100,43 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -1016,22 +1100,43 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
} }
}); });
return true; return true;
} catch (NetworkDisconnectedException e) {
mChatWebView.post(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl("javascript:alert('接続しているネットワークがありません。');");
}
});
} }
return false;
} }
return false;
} }
@JavascriptInterface @JavascriptInterface
public void removeFavoriteGroup(String groupId) throws NetworkDisconnectedException, AcmsException { public boolean removeFavoriteGroup(String groupId) throws AcmsException {
boolean result = deleteFavoriteGroup(groupId); boolean result = false;
if (result) { try {
result = deleteFavoriteGroup(groupId);
if (!result) {
return false;
}
mChatWebView.post(new Runnable() { mChatWebView.post(new Runnable() {
@Override @Override
public void run() { public void run() {
mChatWebView.loadUrl("javascript:CHAT_UI.refreshContactScreen();"); mChatWebView.loadUrl("javascript:CHAT_UI.refreshContactScreen();");
} }
}); });
return true;
} catch (NetworkDisconnectedException e) {
mChatWebView.post(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl("javascript:alert('接続しているネットワークがありません。');");
}
});
} }
return false;
} }
@JavascriptInterface @JavascriptInterface
...@@ -1226,7 +1331,6 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -1226,7 +1331,6 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
intent.setClass(ChatWebviewActivity.this, OperationRelatedContentActivity.class); intent.setClass(ChatWebviewActivity.this, OperationRelatedContentActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent, NaviConsts.Left); startActivity(intent, NaviConsts.Left);
// overridePendingTransition(R.anim.viewin_left_to_right, R.anim.viewin_left_to_right);
} }
// 設定画面へ遷移 // 設定画面へ遷移
...@@ -1236,4 +1340,54 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -1236,4 +1340,54 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
showSetting(); showSetting();
} }
public class NetworkTask extends AsyncTask<Void, Void, Bitmap> {
private String url;
private String filePath;
private ContentValues values;
private Bitmap mBitmap;
public NetworkTask(String url, String filePath) {
this.url = url;
this.filePath = filePath;
}
@Override
protected Bitmap doInBackground(Void... params) {
try {
mBitmap =BitmapFactory.decodeStream((InputStream) new URL(url).getContent());
} catch (IOException e) {
e.printStackTrace();
}
return mBitmap;
}
@Override
protected void onPostExecute(Bitmap resultBitmap) {
super.onPostExecute(resultBitmap);
try {
if (resultBitmap == null) {
return;
}
File f = new File(filePath);
f.createNewFile();
Bitmap bitmap = resultBitmap;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 0, bos);
byte[] bitmapData = bos.toByteArray();
FileOutputStream fos = new FileOutputStream(f);
fos.write(bitmapData);
fos.flush();
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment