Commit c73df9b5 by Lee Munkyeong

Modify for offline

parent 4bf67f13
package jp.agentec.abook.abv.bl.data.dao;
import java.util.List;
import jp.agentec.abook.abv.bl.common.db.Cursor;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.dto.ChatRoomDto;
import jp.agentec.abook.abv.bl.dto.MemberInfoDto;
import jp.agentec.abook.abv.bl.dto.ShopMemberDto;
public class ChatRoomDao extends AbstractDao {
/**
* {@link ChatRoomDao} のインスタンスを初期化します。
* アンドロイドの android.content.Context のインスタンス
* @throws ClassCastException 引数のcontextが android.content.Context 又は、その継承クラスではありません。
* @since 1.0.0
*/
/*package*/ ChatRoomDao() {
}
@Override
protected ChatRoomDto convert(Cursor cursor) {
ChatRoomDto dto = new ChatRoomDto();
int column = cursor.getColumnIndex("chat_room_id");
if (column != -1) {
dto.chatRoomId = cursor.getInt(column);
}
column = cursor.getColumnIndex("chat_room_name");
if (column != -1) {
dto.chatRoomName = cursor.getString(column);
}
column = cursor.getColumnIndex("type");
if (column != -1) {
dto.type = cursor.getInt(column);
}
column = cursor.getColumnIndex("favorite_register_date");
if (column != -1) {
dto.favoriteRegisterDate = cursor.getString(column);
}
return dto;
}
public List<ChatRoomDto> getAllChatRoom() {
List<ChatRoomDto> list = rawQueryGetDtoList("select * from t_chat_room", null, ChatRoomDto.class);
return list;
}
public ChatRoomDto getFavoriteChatRoom() {
return rawQueryGetDto("select * from t_chat_room where favorite_register_date is NOT NULL", null, ChatRoomDto.class);
}
public ChatRoomDto getNotFavoriteChatRoom() {
return rawQueryGetDto("select * from t_chat_room where favorite_register_date is NULL", null, ChatRoomDto.class);
}
public void insertChatRoom(ChatRoomDto dto) {
insert("insert into t_chat_room (chat_room_id, chat_room_name, type, favorite_register_date) values (?,?,?,?)", dto.getInsertValues());
}
public boolean updateChatRoom(ChatRoomDto dto) {
long count = update("update t_chat_room set chat_room_name=?, type=?, favorite_register_date=? where chat_room_id=?", dto.getUpdateValues());
return count > 0;
}
public void deleteChatRoom() {
try {
beginTransaction();
delete("t_chat_room", null, null);
commit();
} catch (Exception e) {
rollback();
Logger.e("deleteChatRoom failed.", e);
throw new RuntimeException(e);
} finally {
}
}
}
package jp.agentec.abook.abv.bl.data.dao;
import java.util.Date;
import java.util.List;
import jp.agentec.abook.abv.bl.common.db.Cursor;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.dto.MemberInfoDto;
import jp.agentec.abook.abv.bl.dto.ShopMemberDto;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
public class ShopMemberDao extends AbstractDao {
/**
* {@link ShopMemberDao} のインスタンスを初期化します。
* アンドロイドの android.content.Context のインスタンス
* @throws ClassCastException 引数のcontextが android.content.Context 又は、その継承クラスではありません。
* @since 1.0.0
*/
/*package*/ ShopMemberDao() {
}
@Override
protected ShopMemberDto convert(Cursor cursor) {
ShopMemberDto dto = new ShopMemberDto();
int column = cursor.getColumnIndex("shop_member_id");
if (column != -1) {
dto.shopMemberId = cursor.getInt(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("favorite_register_date");
if (column != -1) {
dto.favoriteRegisterDate = cursor.getString(column);
}
return dto;
}
public List<ShopMemberDto> getAllShopMember() {
List<ShopMemberDto> list = rawQueryGetDtoList("select * from m_shop_member", null, ShopMemberDto.class);
return list;
}
public ShopMemberDto getShopMember(int shopMemberId) {
return rawQueryGetDto("select * from m_shop_member where shop_member_id=?", new String[]{""+ shopMemberId}, ShopMemberDto.class);
}
public void insertShopMember(ShopMemberDto dto) {
insert("insert into m_shop_member (shop_member_id, shop_member_name, profile_url, favorite_register_date) values (?,?,?,?)", dto.getInsertValues());
}
public boolean updateShopMember(MemberInfoDto dto) {
long count = update("update m_shop_member set shop_member_name=?, profile_url=?, favorite_register_date=? where shop_member_id=?", dto.getUpdateValues());
return count > 0;
}
public void deleteShopMember() {
try {
beginTransaction();
delete("m_shop_member", null, null);
commit();
} catch (Exception e) {
rollback();
Logger.e("deleteShopMember failed.", e);
throw new RuntimeException(e);
} finally {
}
}
}
......@@ -20,8 +20,6 @@ public class RChatRoomShopMember extends SQLiteTableScript {
sql.append(" room_id INTEGER NOT NULL ");
sql.append(" , shop_member_id INTEGER NOT NULL ");
sql.append(" , PRIMARY KEY (room_id, shop_member_id) ");
sql.append(" , FOREIGN KEY (room_id) REFERENCES t_chat_room (room_id) ");
sql.append(" , FOREIGN KEY (shop_member_id) REFERENCES m_shop_member (shop_member_id) ");
sql.append(" ) ");
ddl.add(sql.toString());
......
......@@ -6,7 +6,7 @@ public class ChatRoomDto extends AbstractDto {
public Integer chatRoomId;
public String chatRoomName;
public Integer type;
public Date favoriteRegisterDate;
public String favoriteRegisterDate;
@Override
......
......@@ -6,7 +6,7 @@ public class ShopMemberDto extends AbstractDto {
public Integer shopMemberId;
public String shopMemberName;
public String profileUrl;
public Date favoriteRegisterDate;
public String favoriteRegisterDate;
@Override
public Object[] getInsertValues() {
......
......@@ -14,19 +14,26 @@
String.prototype.replaceAll = function(org, dest) {
return this.split(org).join(dest);
}
let CHAT_SERVER_URL = '';
let CMS_SERVER_URL = '';
let ASSET_PATH = './';
let PLATFORM = '';
let IS_MOBILE = true;
function getGlobalParam(chatServerUrl, cmsServerUrl, platform, isMobile) {
let IS_ONLINE = true;
function getGlobalParam(chatServerUrl, cmsServerUrl, platform, isMobile, isOnline) {
console.log('TEST get GP');
CHAT_SERVER_URL = chatServerUrl;
CMS_SERVER_URL = cmsServerUrl;
PLATFORM = platform;
IS_MOBILE = isMobile;
IS_ONLINE = isOnline;
console.log(CHAT_SERVER_URL);
console.log(CMS_SERVER_URL);
console.log(isOnline);
};
android.getGlobalParameter();
</script>
</head>
......
......@@ -63,8 +63,8 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
private final String TAG = "ChatWebviewActivity";
private final String NETWORK_ERROR_PLACE_HOLDER = "file:///android_asset/chat/public/networkError.html";
private final String NETWORK_ERROR_PLACE_HOLDER = "file:///android_asset/chat/public/index.html";
//private final String NETWORK_ERROR_PLACE_HOLDER = "file:///android_asset/chat/public/networkError.html";
private final String CHAT_PAGE_URL = "file:///android_asset/chat/public/index.html";
//AISDevelop
......@@ -73,6 +73,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
private ValueCallback<Uri[]> mUploadMessage;
private String sid, roomName, loginId, shopName;
private boolean isOnline;
private Long roomId;
public AlertDialog myAlertDialog;
......@@ -96,12 +97,14 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
roomName = intent.getStringExtra("roomName");
loginId = intent.getStringExtra("loginId");
shopName = intent.getStringExtra("shopName");
isOnline = false;
//ネットワークがない場合専用のページを表示。
chatWebviewUrl = NETWORK_ERROR_PLACE_HOLDER;
if (ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
try {
if (AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).checkSid(sid)) {
isOnline = true;
chatWebviewUrl = CHAT_PAGE_URL;
}
} catch (Exception e) {
......@@ -519,7 +522,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
chatServerUrl= chatServerUrl.substring(0, chatServerUrl.length() - 3);
String cmsServerUrl = ABVEnvironment.getInstance().acmsAddress+ ABVDataCache.getInstance().getUrlPath();
mChatWebView.loadUrl(String.format("javascript:getGlobalParam('%s', '%s', '%s', '%s');", chatServerUrl, cmsServerUrl, "android", true));
mChatWebView.loadUrl(String.format("javascript:getGlobalParam('%s', '%s', '%s', '%s', '%s');", chatServerUrl, cmsServerUrl, "android", true, isOnline));
}
@Override
......
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