From f07216abda538807116871e0797ab1942d9d2cca Mon Sep 17 00:00:00 2001 From: AKIRA TAKEDA Date: Mon, 11 Apr 2022 11:05:56 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=B9=E3=83=AF=E3=82=A4=E3=83=97=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E3=81=A7=E6=9B=B8=E9=A1=9E=E3=82=92=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E3=81=A7=E3=81=8D=E3=81=AA=E3=81=84=20=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../view/ui/documentweb/DocumentWebClient.kt | 2 -- .../ui/documentweb/DocumentWebFragment.kt | 8 +---- .../ui/documentweb/DocumentWebPresenter.kt | 5 --- .../ui/documentweb/DocumentWebViewModel.kt | 3 -- .../view/ui/documentweb/SwipeControl.kt | 31 ++++++------------- 5 files changed, 11 insertions(+), 38 deletions(-) diff --git a/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebClient.kt b/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebClient.kt index 82812530..3e3ad9d2 100644 --- a/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebClient.kt +++ b/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebClient.kt @@ -81,8 +81,6 @@ class DocumentWebViewClient(private val webShare: DocumentWebShare): WebViewClie // ネットワーク切断時Viewを表示する必要があるか設定する(URL変更時) url?.let { webShare.presenter.updateDisconnectViewDisplayState(it) } - // 書類部分のスクロール量を初期化する - webShare.presenter.initDocumentScrollAmount() } companion object { private val FORM_URL_PATTERN = Regex("/xpoint/form\\.do\\b") diff --git a/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebFragment.kt b/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebFragment.kt index 3c8bb21c..0eac0c81 100644 --- a/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebFragment.kt +++ b/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebFragment.kt @@ -154,9 +154,6 @@ class DocumentWebFragment : Fragment(), DocumentWebPresenter { MotionEvent.ACTION_UP -> { swipeControl.updateSwipeRefreshState(it.scrollY == 0) } - MotionEvent.ACTION_MOVE -> { - swipeControl.updateDocumentScrollAmount() - } } gestureDetector.onTouchEvent(event) } @@ -368,13 +365,10 @@ class DocumentWebFragment : Fragment(), DocumentWebPresenter { override fun updateDisconnectViewDisplayState(url: String) { url.let { viewDataBinding.viewModel?.isDisconnectViewDisplay?.value = it.contains("Mobile#docDetail") + swipeControl.checkDisplayDocumentViewer() } } - override fun initDocumentScrollAmount() { - viewDataBinding.viewModel?.documentScrollAmount?.value = 0.0 - } - // ツールバー部分のタイトルを更新する関数 override fun updateTitle(url: String) { try { diff --git a/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebPresenter.kt b/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebPresenter.kt index d86b5641..daaf6faa 100644 --- a/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebPresenter.kt +++ b/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebPresenter.kt @@ -42,9 +42,4 @@ interface DocumentWebPresenter { * ネットワーク切断時View表示フラグ更新 */ fun updateDisconnectViewDisplayState(url: String) - - /** - * 書類部分のスクロール量を初期化する - */ - fun initDocumentScrollAmount() } diff --git a/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebViewModel.kt b/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebViewModel.kt index 75cef402..a1942d5d 100644 --- a/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebViewModel.kt +++ b/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebViewModel.kt @@ -15,7 +15,4 @@ class DocumentWebViewModel : BaseViewModel(){ // ネットワーク切断時View表示/非表示フラグ val layoutDisconnectViewVisibility = MutableLiveData() - - // 書類部分のスクロール量 - val documentScrollAmount = MutableLiveData().apply { value = 0.0 } } \ No newline at end of file diff --git a/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/SwipeControl.kt b/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/SwipeControl.kt index 234fff5e..4d8fdc63 100644 --- a/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/SwipeControl.kt +++ b/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/SwipeControl.kt @@ -27,32 +27,21 @@ class SwipeControl(var swipeRefreshLayout : SwipeRefreshLayout, var viewDataBind fun updateSwipeRefreshState(swipeRefreshState: Boolean) { swipeRefreshLayout.let { swipeLayout -> viewDataBinding.viewModel?.networkConnect?.value?.let { networkConnect -> - if (networkConnect) { - swipeLayout.isEnabled = swipeRefreshState - } else { - swipeLayout.isEnabled = false + viewDataBinding.viewModel?.isDisconnectViewDisplay?.value?.let { isDisconnectViewDisplay -> + if (networkConnect && !isDisconnectViewDisplay) { + swipeLayout.isEnabled = swipeRefreshState + } else { + swipeLayout.isEnabled = false + } } } } } - fun updateDocumentScrollAmount() { - viewDataBinding.viewModel?.isDisconnectViewDisplay?.value?.let { isDisconnectViewDisplay -> - swipeRefreshLayout.let { swipeLayout -> - if (isDisconnectViewDisplay) { - // JavaScriptを実行し、書類部分のスクロール量を取得する - webview?.evaluateJavascript("$baseScript.contentWindow.pageYOffset") { result -> - if (result == "null") { - // 値が取得できない場合、後の変換で落ちるので以降の処理を行わない - return@evaluateJavascript - } - // 現在viewModelに保持しているスクロール量を変数に保存し、新たな値をviewModelに設定する - val oldScrollAmount = viewDataBinding.viewModel?.documentScrollAmount?.value - viewDataBinding.viewModel?.documentScrollAmount?.value = result.toDouble() - // 変数に保存した値と新たに設定した値を比較する - swipeLayout.isEnabled = oldScrollAmount == viewDataBinding.viewModel?.documentScrollAmount?.value - } - } + fun checkDisplayDocumentViewer() { + swipeRefreshLayout.let { swipeLayout -> + viewDataBinding.viewModel?.isDisconnectViewDisplay?.value?.let { isDisconnectViewDisplay -> + swipeLayout.isEnabled = !isDisconnectViewDisplay } } } -- GitLab