Commit 1d256d23 by Lee Munkyeong

Modify to display placeholder when not connected network

parent 502112c3
......@@ -32,8 +32,10 @@ import java.io.File;
import java.util.List;
import java.util.Objects;
import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.constant.ABookKeys;
import jp.agentec.abook.abv.bl.common.exception.NetworkDisconnectedException;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.dto.PushMessageDto;
import jp.agentec.abook.abv.cl.util.PreferenceUtil;
......@@ -48,6 +50,8 @@ import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil;
import jp.agentec.abook.abv.ui.home.helper.ActivityHandlingHelper;
import jp.agentec.abook.abv.ui.viewer.activity.ParentWebViewActivity;
import static org.chromium.net.NetError.ERR_FAILED;
/**
* Created by AIS-NB-048 on 2019/07/31.
*/
......@@ -57,6 +61,9 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
private String chatWebviewUrl;
private final String TAG = "ChatWebviewActivity";
private final String NETWORK_ERROR_PLACE_HOLDER = "file:///android_asset/chat/public/index.html";
//AISDevelop
private JsInf jsInf = new JsInf();
......@@ -81,18 +88,26 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
setContentView(R.layout.chat_webview);
Intent intent = getIntent();
//ネットワークがない場合専用のページを表示。
if (ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
chatWebviewUrl = intent.getStringExtra("chatWebviewUrl");
} else {
chatWebviewUrl = "file:///android_asset/chat/public/index.html";
}
sid = intent.getStringExtra("sid");
roomId = intent.getLongExtra("roomId", 0);
roomName = intent.getStringExtra("roomName");
loginId = intent.getStringExtra("loginId");
shopName = intent.getStringExtra("shopName");
//ネットワークがない場合専用のページを表示。
chatWebviewUrl = NETWORK_ERROR_PLACE_HOLDER;
if (ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
try {
if (AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).checkSid(sid)) {
chatWebviewUrl = intent.getStringExtra("chatWebviewUrl");
}
} catch (Exception e) {
Logger.d("SID_CHECK_ERROR");
}
} else {
Logger.d("DEVICE_NOT_CONNECTED_NETWORK:");
}
mChatWebView = findViewById(R.id.chatWebview2);
mChatWebView.setOverScrollMode(View.OVER_SCROLL_NEVER); //オーバースクロールしない。
mChatWebView.setVerticalScrollBarEnabled(false); //スクロールバーを消す。
......@@ -307,7 +322,15 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
@Override
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
Logger.d("WEB_VIEW_TEST", "error code:" + errorCode + " - " + description);
if (errorCode == ERR_FAILED) {
mChatWebView.removeView(view);
view.removeAllViews();
mChatWebView.reload();
mChatWebView.loadUrl(NETWORK_ERROR_PLACE_HOLDER);
}
Logger.d("WEB_VIEW_ERROR", "error code:" + errorCode + " - " + description);
}
@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