Commit be9625d6 by Kim Peace

Merge branch 'feature/laodingProgressbar_for_AbookComm' into 'features/abcomm_sp6'

Added loading progress bar

See merge request !122
parents 7ed25cb6 af3f882a
......@@ -63,6 +63,7 @@ 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.UserInviteResultJSON;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.CommonExecutor;
import jp.agentec.abook.abv.bl.common.constant.ABookCommConstants;
import jp.agentec.abook.abv.bl.common.constant.ABookKeys;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
......@@ -143,7 +144,21 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
setPortraitIfNormal();
}
setContentView(R.layout.chat_webview);
Intent intent = getIntent();
initializeWebView();
}
private void initializeWebView() {
initiateDatas(getIntent());
setupDefaultChatWebViewURL();
setupChatWebView();
registChatRoomPageLoader();
registJSReactor();
addDownloadListener();
observeNetworkChange();
loadWebViewResource();
}
private void initiateDatas(Intent intent) {
communicationLogic.setPackagePath(getFilesDir().getAbsolutePath() + "/");
sid = intent.getStringExtra("sid");
roomId = intent.getLongExtra("roomId", 0);
......@@ -151,29 +166,45 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
loginId = intent.getStringExtra("loginId");
shopName = intent.getStringExtra("shopName");
isOnline = false;
}
private void setupDefaultChatWebViewURL() {
//ネットワークがない場合専用のページを表示。
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;
communicationLogic.clearAllData();
if (!ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
Logger.d("DEVICE_NOT_CONNECTED_NETWORK:");
return;
}
boolean isSIDValid = false;
try {
isSIDValid = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).checkSid(sid);
} catch (Exception e) {
Logger.d("SID_CHECK_ERROR");
}
if (!isSIDValid) { return; }
isOnline = true;
chatWebviewUrl = CHAT_PAGE_URL;
showProgressPopup();
CommonExecutor.execute(new Runnable() {
@Override
public void run() {
communicationLogic.clearAllData();
try {
updateMyInfoFromServer();
updateAllGroupInfo();
updateFavoriteInfo();
closeProgressPopup();
} catch (Exception e) {
Logger.d("Update error");
}
} catch (Exception e) {
Logger.d("SID_CHECK_ERROR");
}
} else {
Logger.d("DEVICE_NOT_CONNECTED_NETWORK:");
}
});
}
private void setupChatWebView() {
shopMemberId = communicationLogic.getMyShopMemberDto().shopMemberId;
mChatWebView = findViewById(R.id.chatWebview2);
mChatWebView.setOverScrollMode(View.OVER_SCROLL_NEVER); //オーバースクロールしない。
mChatWebView.setVerticalScrollBarEnabled(false); //スクロールバーを消す。
......@@ -195,17 +226,18 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
if (Logger.isDebugEnabled()) {
mChatWebView.setWebContentsDebuggingEnabled(true); //デバッグモード(chromeからinspect可)
}
}
private void registChatRoomPageLoader() {
// 最後のチャットのルーム名
String lastRoomName = PreferenceUtil.getUserPref(getApplicationContext(), AppDefType.UserPrefKey.CHAT_LAST_ROOMNAME, "");
// 最後のチャットのルーム
String lastRoomId = PreferenceUtil.getUserPref(getApplicationContext(), AppDefType.UserPrefKey.CHAT_LAST_ROOMID, "");
mChatWebView.addJavascriptInterface(jsInf, "android");
String fixedParam = "&platform=android&isMobile=true&chatServerUrl=" + ABVEnvironment.getInstance().websocketServerHttpUrl;
//ページをロード
if(roomId != 0 && roomName != null) { // by push message
if (roomId != 0 && roomName != null) { // by push message
try {
jsInf.updateRoomList();
} catch (Exception e) {
......@@ -215,8 +247,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
roomType = communicationLogic.getChatRoom(integerRoomId).type.toString();
String parameterData = "sid=" + sid + "&loginId=" + loginId + "&shopName=" + shopName + "&roomId=" + roomId + "&roomName=" + roomName + fixedParam;
mChatWebView.postUrl(CHAT_ROOM_PAGE_URL, parameterData.getBytes());
}
else { // Chat
} else { // Chat
if (lastRoomName.length() > 0 && lastRoomId.length() > 0) {
String parameterData = "sid=" + sid + "&loginId=" + loginId + "&shopName=" + shopName + "&roomId=" + lastRoomId + "&roomName=" + lastRoomName + fixedParam;
mChatWebView.postUrl(chatWebviewUrl, parameterData.getBytes());
......@@ -225,7 +256,9 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
mChatWebView.postUrl(chatWebviewUrl, parameterData.getBytes());
}
}
}
private void registJSReactor() {
mChatWebView.setWebChromeClient(new FullscreenableChromeClient(this) {
@Override
......@@ -363,7 +396,9 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
return true;
}
});
}
private void addDownloadListener() {
mChatWebView.setDownloadListener(new DownloadListener() {
@Override
public void onDownloadStart(String url, String userAgent,
......@@ -391,8 +426,10 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
Toast.LENGTH_LONG).show();
}
});
// ブロードキャストレシーバーの追加
}
private void observeNetworkChange() {
// ブロードキャストレシーバーの追加
receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
......@@ -414,13 +451,14 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
}
}
};
// レシーバーオブジェクトの生成
IntentFilter tempIntent = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
tempIntent.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
tempIntent.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
registerReceiver(receiver, tempIntent);
}
private void loadWebViewResource() {
mChatWebView.setWebViewClient(new WebViewClient() {
@Override
public void onLoadResource(WebView view, String url) {
......@@ -488,7 +526,6 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
return false;
}
});
}
@Override
......@@ -589,6 +626,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
public void onClick(View view) {
// チャット利用のはネットワークが繋がる時のみ
if (ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
showProgressPopup();
ActivityHandlingHelper.getInstance().startChatWebviewActivity();
mCommunicationMenuDialog.dismiss();
} else {
......
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