Commit b80b9811 by Lee Munkyeong

Chat UI

parent 00d90361
...@@ -127,8 +127,8 @@ public class ChatRoomDao extends AbstractDao { ...@@ -127,8 +127,8 @@ public class ChatRoomDao extends AbstractDao {
public void deleteChatRoom() { public void deleteChatRoom() {
try { try {
beginTransaction(); beginTransaction();
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_room", null, null);
commit(); commit();
} catch (Exception e) { } catch (Exception e) {
rollback(); rollback();
......
...@@ -202,6 +202,8 @@ public class ShopMemberDao extends AbstractDao { ...@@ -202,6 +202,8 @@ public class ShopMemberDao extends AbstractDao {
public void deleteShopMember() { public void deleteShopMember() {
try { try {
beginTransaction(); beginTransaction();
delete("r_collaboration_member", null, null);
delete("r_shop_member_group", null, null);
delete("m_shop_member", null, null); delete("m_shop_member", null, null);
commit(); commit();
} catch (Exception e) { } catch (Exception e) {
......
...@@ -106,7 +106,7 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -106,7 +106,7 @@ public class CommunicationLogic extends AbstractLogic {
chatMessageMap.put(ABookCommConstants.KEY.MESSAGE, chatMessageDto.message); 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_IMAGE_PATH, chatMessageDto.profileUrl); chatMessageMap.put(ABookCommConstants.KEY.PROFILE_URL, chatMessageDto.profileUrl);
chatMessageMap.put(ABookCommConstants.KEY.SELF_FLG, chatMessageDto.selfFlg); chatMessageMap.put(ABookCommConstants.KEY.SELF_FLG, chatMessageDto.selfFlg);
JSONObject jsonObject = new JSONObject(chatMessageMap); JSONObject jsonObject = new JSONObject(chatMessageMap);
resultJsonArray.put(jsonObject); resultJsonArray.put(jsonObject);
...@@ -498,4 +498,10 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -498,4 +498,10 @@ public class CommunicationLogic extends AbstractLogic {
} }
groupDao.updateFavoriteGroupList(groupDtos); groupDao.updateFavoriteGroupList(groupDtos);
} }
public void clearAllData() {
chatMessageDao.deleteChatMessage();
chatRoomDao.deleteChatRoom();
shopMemberDao.deleteShopMember();
}
} }
...@@ -51,6 +51,7 @@ import jp.agentec.abook.abv.bl.common.exception.NetworkDisconnectedException; ...@@ -51,6 +51,7 @@ 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.GroupDto; import jp.agentec.abook.abv.bl.dto.GroupDto;
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.dto.ShopMemberDto;
...@@ -746,6 +747,19 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -746,6 +747,19 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
} }
@JavascriptInterface @JavascriptInterface
public void joinRoom(String joinRoomId, String joinRoomName) {
roomId = Long.parseLong(joinRoomId);
roomName = joinRoomName;
System.out.println("-----------joinROOM ON android-------"+roomId+"-"+roomName);
mChatWebView.post(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl(CHAT_ROOM_PAGE_URL);
}
});
}
@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);
...@@ -769,19 +783,6 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -769,19 +783,6 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
} }
@JavascriptInterface @JavascriptInterface
public void joinRoom(String joinRoomId, String joinRoomName) {
roomId = Long.parseLong(joinRoomId);
roomName = joinRoomName;
System.out.println("-----------joinROOM ON android-------"+roomId+"-"+roomName);
mChatWebView.post(new Runnable() {
@Override
public void run() {
mChatWebView.loadUrl(CHAT_ROOM_PAGE_URL);
}
});
}
@JavascriptInterface
public String getMyInfo() { public String getMyInfo() {
String myInfoStr = communicationLogic.getMyInfo(); String myInfoStr = communicationLogic.getMyInfo();
return myInfoStr; return myInfoStr;
...@@ -917,7 +918,9 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -917,7 +918,9 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
private void updateMyInfoFromServer() throws NetworkDisconnectedException, AcmsException { private void updateMyInfoFromServer() throws NetworkDisconnectedException, AcmsException {
MyInfoJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getMyInfo(sid); MyInfoJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getMyInfo(sid);
communicationLogic.insertMyInfo(resultJson.shopMemberDto); if (resultJson.shopMemberDto != null) {
communicationLogic.insertMyInfo(resultJson.shopMemberDto);
}
} }
private void updateUserInfoFromServer(String shopMemberId) throws NetworkDisconnectedException, AcmsException { private void updateUserInfoFromServer(String shopMemberId) throws NetworkDisconnectedException, AcmsException {
...@@ -927,6 +930,10 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -927,6 +930,10 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
private boolean insertFavoriteUser(String shopMemberId) throws NetworkDisconnectedException, AcmsException { private boolean insertFavoriteUser(String shopMemberId) throws NetworkDisconnectedException, AcmsException {
boolean result = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).insertFavoriteUser(sid,Integer.parseInt(shopMemberId)); boolean result = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).insertFavoriteUser(sid,Integer.parseInt(shopMemberId));
if (!result) { return false; }
List<Integer> shopMeberIds = new ArrayList<>();
shopMeberIds.add(Integer.parseInt(shopMemberId));
communicationLogic.updateFavoriteUser(shopMeberIds);
return result; return result;
} }
...@@ -962,22 +969,28 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -962,22 +969,28 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
for (String groupId : groupIds.split(",")) { for (String groupId : groupIds.split(",")) {
checkSumList.add(pref.getString(groupId,DEFAULT_CHECKSUM)); checkSumList.add(pref.getString(groupId,DEFAULT_CHECKSUM));
} }
String checkSumListStr = StringUtil.join(",",checkSumList); String checkSumListStr = StringUtil.join(",",checkSumList);
GroupListJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getGroupInfo(sid,groupIds,checkSumListStr); if (groupIds.equals(ABookCommConstants.FLAG.GROUP_REQUEST_ALL.toString())) {
checkSumListStr = DEFAULT_CHECKSUM;
if (CollectionUtil.isNotEmpty(resultJson.groupList)) { }
SharedPreferences.Editor editor = pref.edit(); try {
communicationLogic.updateGroup(resultJson.groupList); GroupListJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getGroupInfo(sid,groupIds,checkSumListStr);
if (groupIds.equals(ABookCommConstants.FLAG.GROUP_REQUEST_ALL.toString())) { if (CollectionUtil.isNotEmpty(resultJson.groupList)) {
editor.putString(ABookCommConstants.FLAG.GROUP_REQUEST_ALL.toString(),resultJson.allGroupLastUpdateDate); SharedPreferences.Editor editor = pref.edit();
} else { communicationLogic.updateGroup(resultJson.groupList);
for (GroupDto groupDto : resultJson.groupList) { if (groupIds.equals(ABookCommConstants.FLAG.GROUP_REQUEST_ALL.toString())) {
editor.putString(Integer.toString(groupDto.groupId),groupDto.updateDate); editor.putString(ABookCommConstants.FLAG.GROUP_REQUEST_ALL.toString(),resultJson.allGroupLastUpdateDate);
} else {
for (GroupDto groupDto : resultJson.groupList) {
editor.putString(Integer.toString(groupDto.groupId),groupDto.updateDate);
}
} }
editor.commit();
} }
editor.commit(); } catch (AcmsException e) {
e.printStackTrace();
} }
} }
private void updateFavoriteUser() throws NetworkDisconnectedException, AcmsException { private void updateFavoriteUser() throws NetworkDisconnectedException, AcmsException {
......
...@@ -10,6 +10,7 @@ import jp.agentec.abook.abv.bl.common.ABVEnvironment; ...@@ -10,6 +10,7 @@ import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.CommonExecutor; import jp.agentec.abook.abv.bl.common.CommonExecutor;
import jp.agentec.abook.abv.bl.common.Constant; import jp.agentec.abook.abv.bl.common.Constant;
import jp.agentec.abook.abv.bl.common.Constant.ExceptionDetailMessage; import jp.agentec.abook.abv.bl.common.Constant.ExceptionDetailMessage;
import jp.agentec.abook.abv.bl.common.constant.ABookCommConstants;
import jp.agentec.abook.abv.bl.common.exception.ABVException; import jp.agentec.abook.abv.bl.common.exception.ABVException;
import jp.agentec.abook.abv.bl.common.exception.ABVExceptionCode; import jp.agentec.abook.abv.bl.common.exception.ABVExceptionCode;
import jp.agentec.abook.abv.bl.common.exception.AcmsException; import jp.agentec.abook.abv.bl.common.exception.AcmsException;
...@@ -24,6 +25,7 @@ import jp.agentec.abook.abv.bl.download.ContentRefresher; ...@@ -24,6 +25,7 @@ import jp.agentec.abook.abv.bl.download.ContentRefresher;
import jp.agentec.abook.abv.bl.dto.MemberInfoDto; import jp.agentec.abook.abv.bl.dto.MemberInfoDto;
import jp.agentec.abook.abv.bl.dto.PasswordLockInfoDto; import jp.agentec.abook.abv.bl.dto.PasswordLockInfoDto;
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.ContractLogic; import jp.agentec.abook.abv.bl.logic.ContractLogic;
import jp.agentec.abook.abv.bl.logic.OperationLogic; import jp.agentec.abook.abv.bl.logic.OperationLogic;
import jp.agentec.abook.abv.bl.logic.UserAuthenticateLogic; import jp.agentec.abook.abv.bl.logic.UserAuthenticateLogic;
...@@ -41,6 +43,7 @@ import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil; ...@@ -41,6 +43,7 @@ import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil;
import jp.agentec.adf.util.StringUtil; import jp.agentec.adf.util.StringUtil;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor; import android.content.SharedPreferences.Editor;
import android.os.Bundle; import android.os.Bundle;
import android.view.Gravity; import android.view.Gravity;
...@@ -66,7 +69,7 @@ public class LoginActivity extends ABVLoginActivity { ...@@ -66,7 +69,7 @@ public class LoginActivity extends ABVLoginActivity {
private static final String TAG = "LoginActivity"; private static final String TAG = "LoginActivity";
private UserAuthenticateLogic userAuthenticateLogic; private UserAuthenticateLogic userAuthenticateLogic;
private CommunicationLogic communicationLogic;
private MemberInfoDao memberInfoDao; private MemberInfoDao memberInfoDao;
private ContractLogic contractLogic; private ContractLogic contractLogic;
...@@ -99,6 +102,7 @@ public class LoginActivity extends ABVLoginActivity { ...@@ -99,6 +102,7 @@ public class LoginActivity extends ABVLoginActivity {
contractLogic = AbstractLogic.getLogic(ContractLogic.class); contractLogic = AbstractLogic.getLogic(ContractLogic.class);
userAuthenticateLogic = AbstractLogic.getLogic(UserAuthenticateLogic.class); userAuthenticateLogic = AbstractLogic.getLogic(UserAuthenticateLogic.class);
communicationLogic = AbstractLogic.getLogic(CommunicationLogic.class);
memberInfoDao = AbstractDao.getDao(MemberInfoDao.class); memberInfoDao = AbstractDao.getDao(MemberInfoDao.class);
imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
...@@ -635,6 +639,7 @@ public class LoginActivity extends ABVLoginActivity { ...@@ -635,6 +639,7 @@ public class LoginActivity extends ABVLoginActivity {
// ユーザ変更があった場合、チャットのルーム情報をクリアする // ユーザ変更があった場合、チャットのルーム情報をクリアする
clearChatLastRoom(); clearChatLastRoom();
abookCommClear();
//ユーザ変更があった場合、FetchDateをクリアする //ユーザ変更があった場合、FetchDateをクリアする
AcmsDao dao = AbstractDao.getDao(AcmsDao.class); AcmsDao dao = AbstractDao.getDao(AcmsDao.class);
...@@ -715,4 +720,11 @@ public class LoginActivity extends ABVLoginActivity { ...@@ -715,4 +720,11 @@ public class LoginActivity extends ABVLoginActivity {
// 最後のチャットのルーム // 最後のチャットのルーム
PreferenceUtil.putUserPref(getApplicationContext(), UserPrefKey.CHAT_LAST_ROOMID, ""); PreferenceUtil.putUserPref(getApplicationContext(), UserPrefKey.CHAT_LAST_ROOMID, "");
} }
// AbookComm関連のデータをクリア
private void abookCommClear() {
//CheckSumクリア
deleteSharedPreferences(ABookCommConstants.TAG);
communicationLogic.clearAllData();
}
} }
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