Commit ec57a518 by Lee Munkyeong

チャット詳細実装

parent a6ff1c56
...@@ -44,7 +44,9 @@ public class GroupListJSON extends AcmsCommonJSON { ...@@ -44,7 +44,9 @@ public class GroupListJSON extends AcmsCommonJSON {
GroupDto groupDto = new GroupDto(); GroupDto groupDto = new GroupDto();
groupDto.groupId = groupListJsonArray.getJSONObject(listCount).getInt(GROUP_ID); groupDto.groupId = groupListJsonArray.getJSONObject(listCount).getInt(GROUP_ID);
groupDto.parentGroupId = groupListJsonArray.getJSONObject(listCount).getInt(PARENT_GROUP_ID); if (groupListJsonArray.getJSONObject(listCount).has(PARENT_GROUP_ID)) {
groupDto.parentGroupId = groupListJsonArray.getJSONObject(listCount).getInt(PARENT_GROUP_ID);
}
groupDto.groupName = groupListJsonArray.getJSONObject(listCount).getString(GROUP_NAME); groupDto.groupName = groupListJsonArray.getJSONObject(listCount).getString(GROUP_NAME);
groupDto.delFlg = groupListJsonArray.getJSONObject(listCount).getInt(DEL_FLG); groupDto.delFlg = groupListJsonArray.getJSONObject(listCount).getInt(DEL_FLG);
......
...@@ -4,10 +4,12 @@ import org.json.adf.JSONArray; ...@@ -4,10 +4,12 @@ import org.json.adf.JSONArray;
import org.json.adf.JSONObject; import org.json.adf.JSONObject;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import jp.agentec.abook.abv.bl.common.exception.AcmsException; import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.exception.JSONValidationException; import jp.agentec.abook.abv.bl.common.exception.JSONValidationException;
import jp.agentec.abook.abv.bl.dto.ChatMessageDto; import jp.agentec.abook.abv.bl.dto.ChatMessageDto;
import jp.agentec.abook.abv.bl.dto.ShopMemberDto;
import jp.agentec.adf.util.DateTimeUtil; import jp.agentec.adf.util.DateTimeUtil;
public class MessageInfoListJSON extends AcmsCommonJSON { public class MessageInfoListJSON extends AcmsCommonJSON {
...@@ -20,9 +22,11 @@ public class MessageInfoListJSON extends AcmsCommonJSON { ...@@ -20,9 +22,11 @@ public class MessageInfoListJSON extends AcmsCommonJSON {
private static final String SHOP_MEMBER_ID = "shopMemberId"; private static final String SHOP_MEMBER_ID = "shopMemberId";
private static final String MESSAGE_TYPE = "messageType"; private static final String MESSAGE_TYPE = "messageType";
private static final String TIME = "time"; private static final String TIME = "time";
private static final String CRYPTED_MEMBER_NAME = "cryptedMemberName"; private static final String MEMBER_NAME = "memberName";
private static final String PROFILE_IMAGE_PATH = "profileImagePath";
public ArrayList<ChatMessageDto> chatMessageDtoList; public ArrayList<ChatMessageDto> chatMessageDtoArrayList;
public ArrayList<ShopMemberDto> shopMemberDtoArrayList;
public MessageInfoListJSON(String jsonString) throws AcmsException { public MessageInfoListJSON(String jsonString) throws AcmsException {
super(jsonString); super(jsonString);
...@@ -33,11 +37,13 @@ public class MessageInfoListJSON extends AcmsCommonJSON { ...@@ -33,11 +37,13 @@ public class MessageInfoListJSON extends AcmsCommonJSON {
// メッセージ情報を取得 // メッセージ情報を取得
if (!json.has(Body)) { return; } if (!json.has(Body)) { return; }
HashMap<Integer, Integer> existShopMmeberMap = new HashMap<Integer, Integer>();
JSONArray messageInfoList = json.getJSONObject(Body).getJSONArray(MESSAGE_INFO_LIST); JSONArray messageInfoList = json.getJSONObject(Body).getJSONArray(MESSAGE_INFO_LIST);
if (messageInfoList == null) { return; } if (messageInfoList == null) { return; }
chatMessageDtoList = new ArrayList<ChatMessageDto>(); chatMessageDtoArrayList = new ArrayList<ChatMessageDto>();
shopMemberDtoArrayList = new ArrayList<ShopMemberDto>();
for (int listCount = 0; listCount < messageInfoList.length(); listCount++) { for (int listCount = 0; listCount < messageInfoList.length(); listCount++) {
if (messageInfoList.getJSONObject(listCount).length() == 0) { if (messageInfoList.getJSONObject(listCount).length() == 0) {
break; break;
...@@ -54,8 +60,19 @@ public class MessageInfoListJSON extends AcmsCommonJSON { ...@@ -54,8 +60,19 @@ public class MessageInfoListJSON extends AcmsCommonJSON {
if (messageInfoJSON.has(TIME)) { if (messageInfoJSON.has(TIME)) {
chatMessageDto.insertDate = DateTimeUtil.millToDateString(messageInfoJSON.getJSONObject(TIME).getLong(TIME)); chatMessageDto.insertDate = DateTimeUtil.millToDateString(messageInfoJSON.getJSONObject(TIME).getLong(TIME));
} }
chatMessageDtoArrayList.add(chatMessageDto);
if (existShopMmeberMap.get(chatMessageDto.shopMemberId) != null) { continue; }
ShopMemberDto shopMemberDto = new ShopMemberDto();
shopMemberDto.shopMemberId = messageInfoJSON.getInt(SHOP_MEMBER_ID);
shopMemberDto.shopMemberName = messageInfoJSON.getString(MEMBER_NAME);
if (messageInfoJSON.has(PROFILE_IMAGE_PATH)) {
shopMemberDto.profileUrl = messageInfoJSON.getString(PROFILE_IMAGE_PATH);
}
existShopMmeberMap.put(shopMemberDto.shopMemberId,shopMemberDto.shopMemberId);
shopMemberDtoArrayList.add(shopMemberDto);
chatMessageDtoList.add(chatMessageDto);
} }
} }
} }
......
...@@ -56,13 +56,46 @@ public class ChatMessageDao extends AbstractDao { ...@@ -56,13 +56,46 @@ public class ChatMessageDao extends AbstractDao {
} }
column = cursor.getColumnIndex("insert_date"); column = cursor.getColumnIndex("insert_date");
if (column != -1) { if (column != -1) {
dto.savePath = cursor.getString(column); dto.insertDate = cursor.getString(column);
}
column = cursor.getColumnIndex("shop_member_name");
if (column != -1) {
dto.shopMemberName = cursor.getString(column);
}
column = cursor.getColumnIndex("profile_url");
if (column != -1) {
dto.profileUrl = cursor.getString(column);
}
column = cursor.getColumnIndex("self_flg");
if (column != -1) {
dto.selfFlg = cursor.getInt(column);
} }
return dto; return dto;
} }
public List<ChatMessageDto> getChatMessage(int chatRoomId) { public List<ChatMessageDto> getChatMessage(int chatRoomId) {
List<ChatMessageDto> list = rawQueryGetDtoList("select * from t_chat_message where chat_room_id = ?", new String[]{""+ chatRoomId}, ChatMessageDto.class); StringBuffer sql = new StringBuffer();
sql.append(" SELECT ");
sql.append(" cm.chat_message_id ");
sql.append(" ,cm.chat_room_id ");
sql.append(" ,cm.shop_member_id ");
sql.append(" ,cm.message ");
sql.append(" ,cm.message_type ");
sql.append(" ,cm.image_name ");
sql.append(" ,cm.download_file_name ");
sql.append(" ,cm.save_path ");
sql.append(" ,cm.insert_date ");
sql.append(" ,sm.shop_member_name ");
sql.append(" ,sm.profile_url ");
sql.append(" ,sm.self_flg ");
sql.append(" FROM ");
sql.append(" t_chat_message AS cm ");
sql.append(" INNER JOIN ");
sql.append(" m_shop_member AS sm ");
sql.append(" ON cm.shop_member_id = sm.shop_member_id ");
sql.append(" WHERE cm.chat_room_id = ? ");
sql.append(" ORDER BY cm.insert_date DESC ");
List<ChatMessageDto> list = rawQueryGetDtoList(sql.toString(), new String[]{""+ chatRoomId}, ChatMessageDto.class);
return list; return list;
} }
......
...@@ -80,7 +80,7 @@ public class ChatRoomDao extends AbstractDao { ...@@ -80,7 +80,7 @@ public class ChatRoomDao extends AbstractDao {
sql.append(" ( SELECT max(insert_date) insert_date, message, message_type, chat_room_id FROM t_chat_message GROUP BY chat_room_id ) AS cm "); sql.append(" ( SELECT max(insert_date) insert_date, message, message_type, chat_room_id FROM t_chat_message GROUP BY chat_room_id ) AS cm ");
sql.append(" ON cr.chat_room_id = cm.chat_room_id "); sql.append(" ON cr.chat_room_id = cm.chat_room_id ");
sql.append(" GROUP BY cr.chat_room_id "); sql.append(" GROUP BY cr.chat_room_id ");
sql.append(" ORDER BY cm.insert_date DESC "); sql.append(" ORDER BY unread_count, cm.insert_date DESC ");
List<ChatRoomDto> list = rawQueryGetDtoList(sql.toString(), null, ChatRoomDto.class); List<ChatRoomDto> list = rawQueryGetDtoList(sql.toString(), null, ChatRoomDto.class);
return list; return list;
} }
...@@ -121,7 +121,6 @@ public class ChatRoomDao extends AbstractDao { ...@@ -121,7 +121,6 @@ public class ChatRoomDao extends AbstractDao {
beginTransaction(); beginTransaction();
delete("t_chat_room", null, null); delete("t_chat_room", null, null);
delete("r_chat_room_shop_member", null, null); delete("r_chat_room_shop_member", null, null);
delete("t_chat_message", null, null);
commit(); commit();
} catch (Exception e) { } catch (Exception e) {
rollback(); rollback();
......
...@@ -59,7 +59,10 @@ public class GroupDao extends AbstractDao { ...@@ -59,7 +59,10 @@ public class GroupDao extends AbstractDao {
if (column != -1) { if (column != -1) {
dto.userGroupFlg = toBool(cursor.getInt(column)); dto.userGroupFlg = toBool(cursor.getInt(column));
} }
column = cursor.getColumnIndex("favorite_register_date");
if (column != -1) {
dto.favoriteRegisterDate = cursor.getString(column);
}
return dto; return dto;
} }
...@@ -549,6 +552,24 @@ public class GroupDao extends AbstractDao { ...@@ -549,6 +552,24 @@ public class GroupDao extends AbstractDao {
} }
} }
public void updateFavoriteGroupList(List<GroupDto> groupList) {
StringBuffer sql = new StringBuffer();
sql.append(" UPDATE m_group ");
sql.append(" , favorite_register_date = ? ");
sql.append(" WHERE group_id = ? ");
try {
beginTransaction();
for (GroupDto groupDto : groupList) {
update(sql.toString(), new Object[] { groupDto.favoriteRegisterDate, groupDto.groupId });
}
commit();
} catch (Exception e) {
rollback();
Logger.e("updateFavoriteGroupList failed.", e);
throw new RuntimeException(e);
}
}
public void deleteGroupList(List<GroupDto> groupList) { public void deleteGroupList(List<GroupDto> groupList) {
StringBuffer sql = new StringBuffer(); StringBuffer sql = new StringBuffer();
sql.append(" delete from m_group "); sql.append(" delete from m_group ");
......
...@@ -62,8 +62,28 @@ public class ShopMemberDao extends AbstractDao { ...@@ -62,8 +62,28 @@ public class ShopMemberDao extends AbstractDao {
try { try {
beginTransaction(); beginTransaction();
insert("insert or replace into m_shop_member (shop_member_id, shop_member_name, profile_url, favorite_register_date, self_flg) values (?,?,?,?,?)", dto.getInsertValues()); insert("insert or replace into m_shop_member (shop_member_id, shop_member_name, profile_url, favorite_register_date, self_flg) values (?,?,?,?,?)", dto.getInsertValues());
for (Integer groupId : dto.groupIdList) { for (Integer groupId : dto.groupIdList) {
insert("insert into r_shop_member_group (shop_member_id, group_id) values ("+dto.shopMemberId+",?)", dto.getGroupIds()); insert("insert or replace into r_shop_member_group (shop_member_id, group_id) values ("+dto.shopMemberId+",?)", dto.getGroupIds());
}
commit();
} catch (Exception e) {
rollback();
Logger.e("insertShopMember failed.", e);
throw new RuntimeException(e);
} finally {
}
}
public void insertShopMember(List<ShopMemberDto> dtoList) {
try {
beginTransaction();
for (ShopMemberDto dto : dtoList) {
insert("insert or replace into m_shop_member (shop_member_id, shop_member_name, profile_url, favorite_register_date, self_flg) values (?,?,?,?,?)", dto.getInsertValues());
if (dto.groupIdList == null) { continue; }
for (Integer groupId : dto.groupIdList) {
insert("insert into r_shop_member_group (shop_member_id, group_id) values ("+dto.shopMemberId+",?)", dto.getGroupIds());
}
} }
commit(); commit();
} catch (Exception e) { } catch (Exception e) {
......
...@@ -34,6 +34,7 @@ public class MGroup extends SQLiteTableScript { ...@@ -34,6 +34,7 @@ public class MGroup extends SQLiteTableScript {
sql.append(" , group_name VARCHAR(64) NOT NULL "); sql.append(" , group_name VARCHAR(64) NOT NULL ");
sql.append(" , group_path TEXT NOT NULL "); // path enumaerationパターンを適用する。since DatabaseVersions.Ver1_5_0 sql.append(" , group_path TEXT NOT NULL "); // path enumaerationパターンを適用する。since DatabaseVersions.Ver1_5_0
sql.append(" , user_group_flg BOOLEAN NOT NULL DEFAULT 0 "); // since DatabaseVersions.Plus_1_1_0 sql.append(" , user_group_flg BOOLEAN NOT NULL DEFAULT 0 "); // since DatabaseVersions.Plus_1_1_0
sql.append(" , favorite_register_date VARCHAR2(64) ");
sql.append(" , PRIMARY KEY (group_relation_id) "); sql.append(" , PRIMARY KEY (group_relation_id) ");
sql.append(" ) "); sql.append(" ) ");
......
...@@ -12,6 +12,9 @@ public class ChatMessageDto extends AbstractDto { ...@@ -12,6 +12,9 @@ public class ChatMessageDto extends AbstractDto {
public String downloadFileName; public String downloadFileName;
public String savePath; public String savePath;
public String insertDate; public String insertDate;
public String shopMemberName;
public String profileUrl;
public Integer selfFlg;
@Override @Override
public Object[] getInsertValues() { public Object[] getInsertValues() {
......
...@@ -15,6 +15,7 @@ public class GroupDto extends AbstractDto { ...@@ -15,6 +15,7 @@ public class GroupDto extends AbstractDto {
public int contentCount = 0; public int contentCount = 0;
public String displayCount; public String displayCount;
public String groupPath; public String groupPath;
public String favoriteRegisterDate = "";
public boolean userGroupFlg; public boolean userGroupFlg;
public int delFlg; public int delFlg;
......
...@@ -70,7 +70,6 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -70,7 +70,6 @@ public class CommunicationLogic extends AbstractLogic {
} }
public String getChatRoomList() { public String getChatRoomList() {
List<ChatRoomDto> chatRoomList = chatRoomDao.getAllChatRoom(); List<ChatRoomDto> chatRoomList = chatRoomDao.getAllChatRoom();
JSONArray resultJsonArray = new JSONArray(); JSONArray resultJsonArray = new JSONArray();
...@@ -92,6 +91,77 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -92,6 +91,77 @@ public class CommunicationLogic extends AbstractLogic {
return roomListToStr; return roomListToStr;
} }
public String getMessages(Integer roomId) {
List<ChatMessageDto> chatMessageDtoList = chatMessageDao.getChatMessage(roomId);
JSONArray resultJsonArray = new JSONArray();
for (ChatMessageDto chatMessageDto : chatMessageDtoList) {
Map<String, Object> chatMessageMap = new HashMap<String, Object>();
chatMessageMap.put("chatRoomId", chatMessageDto.chatRoomId);
chatMessageMap.put("loginId", chatMessageDto.shopMemberName);
chatMessageMap.put("message", chatMessageDto.message);
chatMessageMap.put("messageType", chatMessageDto.messageType);
chatMessageMap.put("insertDate", chatMessageDto.insertDate);
chatMessageMap.put("profileImagePath", chatMessageDto.profileUrl);
chatMessageMap.put("selfFlg", chatMessageDto.selfFlg);
JSONObject jsonObject = new JSONObject(chatMessageMap);
resultJsonArray.put(jsonObject);
}
String messageListStr = resultJsonArray.toString();
return messageListStr;
}
public String getMyInfo() {
ShopMemberDto myInfo = shopMemberDao.getMyInfo();
JSONObject myInfoJson = new JSONObject();
myInfoJson.put("shopMemberId",myInfo.shopMemberId);
myInfoJson.put("shopMemberName",myInfo.shopMemberName);
myInfoJson.put("profileUrl",myInfo.profileUrl);
String myInfoStr = myInfoJson.toString();
return myInfoStr;
}
public String getFavoriteUsers() {
List<ShopMemberDto> favoriteUsers = shopMemberDao.getfavoriteUserList();
JSONArray resultJsonArray = new JSONArray();
for (ShopMemberDto favoriteUser : favoriteUsers) {
Map<String, Object> favoriteUserMap = new HashMap<String, Object>();
favoriteUserMap.put("shopMemberId",favoriteUser.shopMemberId);
favoriteUserMap.put("shopMemberName",favoriteUser.shopMemberName);
favoriteUserMap.put("profileUrl",favoriteUser.profileUrl);
JSONObject jsonObject = new JSONObject(favoriteUserMap);
resultJsonArray.put(jsonObject);
}
String favoriteUsersStr = resultJsonArray.toString();
return favoriteUsersStr;
}
// public String getFavoriteGroups() {
//
// List<ShopMemberDto> favoriteUsers = groupDao.();
//
// JSONArray resultJsonArray = new JSONArray();
// for (ShopMemberDto favoriteUser : favoriteUsers) {
// Map<String, Object> favoriteUserMap = new HashMap<String, Object>();
// favoriteUserMap.put("shopMemberId",favoriteUser.shopMemberId);
// favoriteUserMap.put("shopMemberName",favoriteUser.shopMemberName);
// favoriteUserMap.put("profileUrl",favoriteUser.profileUrl);
// JSONObject jsonObject = new JSONObject(favoriteUserMap);
// resultJsonArray.put(jsonObject);
// }
//
// String favoriteUsersStr = resultJsonArray.toString();
// return favoriteUsersStr;
// }
public void insertChatRoomList(List<ChatRoomDto> roomList) { public void insertChatRoomList(List<ChatRoomDto> roomList) {
List<ChatMessageDto> insertMessageList = new ArrayList<ChatMessageDto>(); List<ChatMessageDto> insertMessageList = new ArrayList<ChatMessageDto>();
for (ChatRoomDto chatRoomDto : roomList) { for (ChatRoomDto chatRoomDto : roomList) {
...@@ -114,6 +184,17 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -114,6 +184,17 @@ public class CommunicationLogic extends AbstractLogic {
public void insertShopMember(ShopMemberDto shopMemberDto) { public void insertShopMember(ShopMemberDto shopMemberDto) {
shopMemberDao.insertShopMember(shopMemberDto); shopMemberDao.insertShopMember(shopMemberDto);
} }
public void insertShopMember(List<ShopMemberDto> shopMemberDtoList) {
ShopMemberDto myInfo = shopMemberDao.getMyInfo();
for (ShopMemberDto shopMemberDto : shopMemberDtoList) {
if (myInfo.shopMemberId.equals(shopMemberDto.shopMemberId)) {
shopMemberDto.selfFlg = 1;
} else {
shopMemberDto.selfFlg = 0;
}
}
shopMemberDao.insertShopMember(shopMemberDtoList);
}
public void updateGroup(List<GroupDto> GroupList) { public void updateGroup(List<GroupDto> GroupList) {
......
...@@ -28,25 +28,17 @@ import android.widget.ImageView; ...@@ -28,25 +28,17 @@ import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.Toast; import android.widget.Toast;
import org.json.JSONArray;
import java.io.File; import java.io.File;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import jp.agentec.abook.abv.bl.acms.client.AcmsClient; import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
import jp.agentec.abook.abv.bl.acms.client.json.AcmsCommonJSON;
import jp.agentec.abook.abv.bl.acms.client.json.CreatedRoomJSON; import jp.agentec.abook.abv.bl.acms.client.json.CreatedRoomJSON;
import jp.agentec.abook.abv.bl.acms.client.json.GroupListJSON; import jp.agentec.abook.abv.bl.acms.client.json.GroupListJSON;
import jp.agentec.abook.abv.bl.acms.client.json.MessageInfoListJSON; import jp.agentec.abook.abv.bl.acms.client.json.MessageInfoListJSON;
import jp.agentec.abook.abv.bl.acms.client.json.MyInfoJSON; import jp.agentec.abook.abv.bl.acms.client.json.MyInfoJSON;
import jp.agentec.abook.abv.bl.acms.client.json.RoomListJSON; import jp.agentec.abook.abv.bl.acms.client.json.RoomListJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ShopMemberListJSON;
import jp.agentec.abook.abv.bl.acms.client.parameters.AcmsParameters;
import jp.agentec.abook.abv.bl.acms.type.AcmsApis;
import jp.agentec.abook.abv.bl.common.ABVEnvironment; import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.constant.ABookKeys; import jp.agentec.abook.abv.bl.common.constant.ABookKeys;
import jp.agentec.abook.abv.bl.common.exception.AcmsException; import jp.agentec.abook.abv.bl.common.exception.AcmsException;
...@@ -54,12 +46,10 @@ import jp.agentec.abook.abv.bl.common.exception.NetworkDisconnectedException; ...@@ -54,12 +46,10 @@ import jp.agentec.abook.abv.bl.common.exception.NetworkDisconnectedException;
import jp.agentec.abook.abv.bl.common.log.Logger; import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.data.ABVDataCache; import jp.agentec.abook.abv.bl.data.ABVDataCache;
import jp.agentec.abook.abv.bl.dto.ChatMessageDto; import jp.agentec.abook.abv.bl.dto.ChatMessageDto;
import jp.agentec.abook.abv.bl.dto.ChatRoomDto;
import jp.agentec.abook.abv.bl.dto.ContentReadingLogDto;
import jp.agentec.abook.abv.bl.dto.PushMessageDto; import jp.agentec.abook.abv.bl.dto.PushMessageDto;
import jp.agentec.abook.abv.bl.dto.ShopMemberDto;
import jp.agentec.abook.abv.bl.logic.AbstractLogic; import jp.agentec.abook.abv.bl.logic.AbstractLogic;
import jp.agentec.abook.abv.bl.logic.CommunicationLogic; import jp.agentec.abook.abv.bl.logic.CommunicationLogic;
import jp.agentec.abook.abv.bl.logic.ContentLogic;
import jp.agentec.abook.abv.cl.util.PreferenceUtil; import jp.agentec.abook.abv.cl.util.PreferenceUtil;
import jp.agentec.abook.abv.launcher.android.R; import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType; import jp.agentec.abook.abv.ui.common.appinfo.AppDefType;
...@@ -71,7 +61,6 @@ import jp.agentec.abook.abv.ui.common.util.ABVToastUtil; ...@@ -71,7 +61,6 @@ import jp.agentec.abook.abv.ui.common.util.ABVToastUtil;
import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil; import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil;
import jp.agentec.abook.abv.ui.home.helper.ActivityHandlingHelper; import jp.agentec.abook.abv.ui.home.helper.ActivityHandlingHelper;
import jp.agentec.abook.abv.ui.viewer.activity.ParentWebViewActivity; import jp.agentec.abook.abv.ui.viewer.activity.ParentWebViewActivity;
import jp.agentec.adf.net.http.HttpResponse;
import static org.chromium.net.NetError.ERR_FAILED; import static org.chromium.net.NetError.ERR_FAILED;
...@@ -94,7 +83,10 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -94,7 +83,10 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
private ValueCallback<Uri[]> mUploadMessage; private ValueCallback<Uri[]> mUploadMessage;
private String sid, roomName, loginId, shopName; private String sid;
private String roomName;
private String loginId;
private String shopName;
private boolean isOnline; private boolean isOnline;
private Long roomId; private Long roomId;
...@@ -130,6 +122,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -130,6 +122,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
if (AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).checkSid(sid)) { if (AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).checkSid(sid)) {
isOnline = true; isOnline = true;
chatWebviewUrl = CHAT_PAGE_URL; chatWebviewUrl = CHAT_PAGE_URL;
updateMyInfoFromServer();
} }
} catch (Exception e) { } catch (Exception e) {
Logger.d("SID_CHECK_ERROR"); Logger.d("SID_CHECK_ERROR");
...@@ -692,7 +685,6 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -692,7 +685,6 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
@JavascriptInterface @JavascriptInterface
public String getRoomList() { public String getRoomList() {
Map<String, Object> chatRoomList;
String chatRoomListStr = communicationLogic.getChatRoomList(); String chatRoomListStr = communicationLogic.getChatRoomList();
return chatRoomListStr; return chatRoomListStr;
} }
...@@ -707,8 +699,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -707,8 +699,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
@JavascriptInterface @JavascriptInterface
public void updateMyInfo() throws NetworkDisconnectedException, AcmsException { public void updateMyInfo() throws NetworkDisconnectedException, AcmsException {
MyInfoJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getMyInfo(sid); updateMyInfoFromServer();
communicationLogic.insertShopMember(resultJson.shopMemberDto);
} }
@JavascriptInterface @JavascriptInterface
...@@ -721,16 +712,47 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -721,16 +712,47 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
public void createChatRoom(String roomType, String userIdList, String encodedRoomName) throws NetworkDisconnectedException, AcmsException { public void createChatRoom(String roomType, String userIdList, String encodedRoomName) throws NetworkDisconnectedException, AcmsException {
CreatedRoomJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).createRoom(sid, roomType, userIdList, encodedRoomName); CreatedRoomJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).createRoom(sid, roomType, userIdList, encodedRoomName);
communicationLogic.insertChatRoom(resultJson.chatRoomDto); communicationLogic.insertChatRoom(resultJson.chatRoomDto);
final Integer chatRoomId = resultJson.chatRoomDto.chatRoomId;
final String chatRoomName = resultJson.chatRoomDto.chatRoomName;
mChatWebView.post(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl(String.format("javascript:CHAT_UI.joinRoom('%s', '%s');", chatRoomId, chatRoomName));
}
});
} }
@JavascriptInterface @JavascriptInterface
public void updateMessages(String roomId) throws NetworkDisconnectedException, AcmsException { public void updateMessages(String roomId) throws NetworkDisconnectedException, AcmsException {
MessageInfoListJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getMessages(sid, roomId); MessageInfoListJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getMessages(sid, roomId);
for (ChatMessageDto chatMessageDto : resultJson.chatMessageDtoList) { for (ChatMessageDto chatMessageDto : resultJson.chatMessageDtoArrayList) {
chatMessageDto.chatRoomId = Integer.parseInt(roomId); chatMessageDto.chatRoomId = Integer.parseInt(roomId);
} }
communicationLogic.insertMessageList(resultJson.chatMessageDtoList); communicationLogic.insertMessageList(resultJson.chatMessageDtoArrayList);
communicationLogic.insertShopMember(resultJson.shopMemberDtoArrayList);
} }
@JavascriptInterface
public String getMessageList(String roomId) {
String messageListStr = communicationLogic.getMessages(Integer.parseInt(roomId));
return messageListStr;
}
@JavascriptInterface
public String getFavoriteUsers() {
String favoriteUsersStr = communicationLogic.getFavoriteUsers();
return favoriteUsersStr;
}
// @JavascriptInterface
// public String getFavoriteGroups() {
// String favoriteGroupsStr = communicationLogic.getFavoriteGroups();
// return favoriteGroupsStr;
// }
} }
/** /**
...@@ -745,6 +767,10 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -745,6 +767,10 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
startActivity(intent, NaviConsts.Left); startActivity(intent, NaviConsts.Left);
} }
private void updateMyInfoFromServer() throws NetworkDisconnectedException, AcmsException {
MyInfoJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getMyInfo(sid);
communicationLogic.insertShopMember(resultJson.shopMemberDto);
}
/**  /** 
* ボタンイベント設定 * ボタンイベント設定
*/ */
...@@ -764,7 +790,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -764,7 +790,7 @@ 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); // overridePendingTransition(R.anim.viewin_left_to_right, R.anim.viewin_left_to_right);
} }
// 設定画面へ遷移 // 設定画面へ遷移
......
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