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