Commit 24332b62 by Lee Munkyeong

チャット非表示追加。

parent d54d0f7e
......@@ -60,6 +60,7 @@ public class GroupListJSON extends AcmsCommonJSON {
ShopMemberDto shopMemberDto = new ShopMemberDto();
shopMemberDto.shopMemberId = groupMember.getInt(ABookCommConstants.KEY.SHOP_MEMBER_ID);
shopMemberDto.shopMemberName = groupMember.getString(ABookCommConstants.KEY.MEMBER_NAME);
shopMemberDto.delFlg = groupMember.getInt(ABookCommConstants.KEY.DEL_FLG);
if (groupMember.has(ABookCommConstants.KEY.PROFILE_IMAGE_PATH)) {
shopMemberDto.profileUrl = groupMember.getString(ABookCommConstants.KEY.PROFILE_IMAGE_PATH);
}
......
......@@ -75,7 +75,14 @@ public interface ABookCommConstants {
Integer OFF = 0;
Integer ON = 1;
}
interface DEL_FLAG {
Integer EXIST = 0;
Integer DELETE = 1;
}
Integer GROUP_REQUEST_ALL = 0;
}
interface SIZE {
Integer MAX_FAVORITE_COUNT = 100;
}
}
......@@ -45,6 +45,10 @@ public class ChatRoomDao extends AbstractDao {
if (column != -1) {
dto.userCount = cursor.getInt(column);
}
column = cursor.getColumnIndex("view_flg");
if (column != -1) {
dto.viewFlg = cursor.getInt(column);
}
column = cursor.getColumnIndex("favorite_register_date");
if (column != -1) {
dto.favoriteRegisterDate = cursor.getString(column);
......@@ -82,6 +86,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(" ON cr.chat_room_id = cm.chat_room_id ");
sql.append(" WHERE cr.type =? ");
sql.append(" AND (cr.view_flg IS null OR cr.view_flg != 1 )");
sql.append(" GROUP BY cr.chat_room_id ");
sql.append(" ORDER BY CASE WHEN unread_count = 0 THEN 0 ELSE 1 END DESC, cm.insert_date DESC ");
List<ChatRoomDto> list = rawQueryGetDtoList(sql.toString(), new String[]{""+ roomType}, ChatRoomDto.class);
......@@ -130,6 +135,7 @@ public class ChatRoomDao extends AbstractDao {
}
String whereSql = StringUtil.join(" OR ", whereSqlList);
sql.append(whereSql);
sql.append(" AND (cr.view_flg IS null OR cr.view_flg != 1 )");
sql.append(" GROUP BY cr.chat_room_id ");
sql.append(" ORDER BY CASE WHEN unread_count = 0 THEN 0 ELSE 1 END DESC, cm.insert_date DESC ");
List<ChatRoomDto> list = rawQueryGetDtoList(sql.toString(), null, ChatRoomDto.class);
......@@ -145,13 +151,22 @@ public class ChatRoomDao extends AbstractDao {
}
public void insertChatRoom(ChatRoomDto dto) {
insert("insert or replace into t_chat_room (chat_room_id, chat_room_name, type, unread_count, user_count, favorite_register_date) values (?,?,?,?,?,?)", dto.getInsertValues());
Integer chatRoomId = dto.chatRoomId;
if (dto.unreadCount == 0) {
insert("insert or replace into t_chat_room (chat_room_id, chat_room_name, type, unread_count, user_count, favorite_register_date, view_flg) values (?,?,?,?,?,?, (select view_flg from t_chat_room where chat_room_id =" + chatRoomId + "))", dto.getInsertValues());
} else {
insert("insert or replace into t_chat_room (chat_room_id, chat_room_name, type, unread_count, user_count, favorite_register_date, view_flg) values (?,?,?,?,?,?,0)", dto.getInsertValues());
}
}
public void updateChatRoomName(String roomName, Integer roomId) {
update("update t_chat_room set chat_room_name = ? where chat_room_id = ?", new Object[]{roomName, roomId});
}
public void changeRoomViewFlg(Integer roomId) {
update("update t_chat_room set view_flg = 1 where chat_room_id = ?", new String[]{"" + roomId});
}
public void insertChatRoom(List<ChatRoomDto> chatRoomDtoList) {
try {
beginTransaction();
......
......@@ -276,6 +276,29 @@ public class ShopMemberDao extends AbstractDao {
return count > 0;
}
public boolean deleteShopMember(ShopMemberDto dto) {
long count = update("delete from m_shop_member where shop_member_id=?", new String[] {"" + dto.shopMemberId});
return count > 0;
}
public void deleteShopMemberByList(List<ShopMemberDto> dtoList) {
try {
beginTransaction();
for (ShopMemberDto dto : dtoList) {
update("delete from r_shop_member_group where shop_member_id=?", new String[] {"" + dto.shopMemberId});
update("delete from r_chat_room_shop_member where shop_member_id=?", new String[] {"" + dto.shopMemberId});
update("delete from m_shop_member where shop_member_id=?", new String[] {"" + dto.shopMemberId});
}
commit();
} catch (Exception e) {
rollback();
Logger.e("insertShopMember failed.", e);
throw new RuntimeException(e);
} finally {
}
}
public boolean updateFavoriteUser(ShopMemberDto dto) {
long count = update("update m_shop_member set favorite_register_date=? where shop_member_id=?", new Object[]{dto.favoriteRegisterDate, dto.shopMemberId});
return count > 0;
......
......@@ -21,6 +21,7 @@ public class TChatRoom extends SQLiteTableScript {
sql.append(" , type INTEGER NOT NULL ");
sql.append(" , unread_count INTEGER ");
sql.append(" , user_count INTEGER ");
sql.append(" , view_flg INTEGER ");
sql.append(" , favorite_register_date VARCHAR2(64) ");
sql.append(" , PRIMARY KEY (chat_room_id) ");
sql.append(" ) ");
......
......@@ -13,6 +13,7 @@ public class ChatRoomDto extends AbstractDto {
public Integer unreadCount = 0;
public Integer userCount;
public String message;
public Integer viewFlg;
public Integer messageType;
public String insertDate;
public ChatMessageDto lastMessageInfo;
......
......@@ -9,6 +9,7 @@ public class ShopMemberDto extends AbstractDto {
public String profileUrl;
public String favoriteRegisterDate;
public Integer selfFlg;
public Integer delFlg;
public ArrayList<Integer> groupIdList;
@Override
......
......@@ -487,6 +487,12 @@ public class CommunicationLogic extends AbstractLogic {
return favoriteGroupsStr;
}
public Integer getFavoriteCount() {
List<GroupDto> favoriteGroups = groupDao.getFavoriteGroup();
List<ShopMemberDto> favoriteUsers = shopMemberDao.getfavoriteUserList();
return favoriteGroups.size() + favoriteUsers.size();
}
public String getGroupSearchData(Integer groupId) {
//レスポンスになるJSON
......@@ -613,14 +619,24 @@ public class CommunicationLogic extends AbstractLogic {
public void insertShopMember(List<ShopMemberDto> shopMemberDtoList) {
ShopMemberDto myInfo = shopMemberDao.getMyInfo();
List<ShopMemberDto> insertList = new ArrayList<ShopMemberDto>();
List<ShopMemberDto> deleteList = new ArrayList<ShopMemberDto>();
for (ShopMemberDto shopMemberDto : shopMemberDtoList) {
if (myInfo.shopMemberId.equals(shopMemberDto.shopMemberId)) {
shopMemberDto.selfFlg = 1;
if (ABookCommConstants.FLAG.DEL_FLAG.EXIST.equals(shopMemberDto.delFlg)) {
if (myInfo.shopMemberId.equals(shopMemberDto.shopMemberId)) {
shopMemberDto.selfFlg = 1;
} else {
shopMemberDto.selfFlg = 0;
}
insertList.add(shopMemberDto);
} else {
shopMemberDto.selfFlg = 0;
deleteList.add(shopMemberDto);
}
}
shopMemberDao.insertShopMember(shopMemberDtoList);
shopMemberDao.insertShopMember(insertList);
shopMemberDao.deleteShopMemberByList(deleteList);
}
public void updateGroup(List<GroupDto> GroupList) {
......@@ -710,6 +726,9 @@ public class CommunicationLogic extends AbstractLogic {
shopMemberDao.deleteShopMember();
}
public void roomDisplayOff(Integer roomId) {
chatRoomDao.changeRoomViewFlg(roomId);
}
public String getUserList(String userIdList) {
List<ShopMemberDto> selectedUsers = shopMemberDao.getSelectedUsers(userIdList);
JSONArray attendUsers = new JSONArray();
......
......@@ -140,6 +140,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
if (AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).checkSid(sid)) {
isOnline = true;
chatWebviewUrl = CHAT_PAGE_URL;
communicationLogic.clearAllData();
updateMyInfoFromServer();
updateAllGroupInfo();
updateFavoriteInfo();
......@@ -729,7 +730,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
public void updateRoomList() throws NetworkDisconnectedException, AcmsException {
Map<String, Object> chatRoomList;
RoomListJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getRoomList(sid);
communicationLogic.deleteChatRoomList();
//communicationLogic.deleteChatRoomList();
communicationLogic.insertChatRoomList(resultJson.roomList);
}
......@@ -761,7 +762,6 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
mChatWebView.loadUrl(String.format("javascript:CHAT_UI.joinRoom('%s', '%s');", chatRoomId, chatRoomName));
}
});
}
@JavascriptInterface
......@@ -787,6 +787,18 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
});
}
@JavascriptInterface
public void roomDisplayOff() {
communicationLogic.roomDisplayOff(roomId.intValue());
mChatWebView.post(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl(CHAT_PAGE_URL);
}
});
}
@JavascriptInterface
public void inviteUsers(String userIds) throws NetworkDisconnectedException, AcmsException {
boolean result = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).inviteUsers(sid, roomId.intValue(), roomName, userIds);
......@@ -922,15 +934,28 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
}
@JavascriptInterface
public void addFavoriteUser(String shopMemberId) throws NetworkDisconnectedException, AcmsException {
boolean result = insertFavoriteUser(shopMemberId);
if (!result) { return; }
mChatWebView.post(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl("javascript:CHAT_UI.refreshContactScreen();");
}
});
public boolean addFavoriteUser(String shopMemberId) throws NetworkDisconnectedException, AcmsException {
Integer favoriteCount = communicationLogic.getFavoriteCount();
if (favoriteCount >= ABookCommConstants.SIZE.MAX_FAVORITE_COUNT ) {
mChatWebView.post(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl("javascript:alert('" + "お気に入りは最大100件までです。" + "');");
}
});
return false;
} else {
boolean result = insertFavoriteUser(shopMemberId);
if (!result) { return false; }
mChatWebView.post(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl("javascript:CHAT_UI.refreshContactScreen();");
}
});
return true;
}
}
@JavascriptInterface
......@@ -947,15 +972,29 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
}
@JavascriptInterface
public void addFavoriteGroup(String groupId) throws NetworkDisconnectedException, AcmsException {
boolean result = insertFavoriteGroup(groupId);
if (result) {
public boolean addFavoriteGroup(String groupId) throws NetworkDisconnectedException, AcmsException {
Integer favoriteCount = communicationLogic.getFavoriteCount();
if (favoriteCount >= ABookCommConstants.SIZE.MAX_FAVORITE_COUNT) {
mChatWebView.post(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl("javascript:CHAT_UI.refreshContactScreen();");
mChatWebView.loadUrl("javascript:alert('" + "お気に入りは最大100件までです。" + "');");
}
});
return false;
} else {
boolean result = insertFavoriteGroup(groupId);
if (result) {
mChatWebView.post(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl("javascript:CHAT_UI.refreshContactScreen();");
}
});
return true;
}
return false;
}
}
......@@ -1046,7 +1085,8 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
SharedPreferences pref = getSharedPreferences(ABookCommConstants.TAG,MODE_PRIVATE);
for (String groupId : groupIds.split(",")) {
checkSumList.add(pref.getString(groupId,DEFAULT_CHECKSUM));
//checkSumList.add(pref.getString(groupId,DEFAULT_CHECKSUM));
checkSumList.add(DEFAULT_CHECKSUM);
}
String checkSumListStr = StringUtil.join(",",checkSumList);
if (groupIds.equals(ABookCommConstants.FLAG.GROUP_REQUEST_ALL.toString())) {
......
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