사용중인 개발용 기기에서 우리 앱을 실행하는데,

어느날부터 로그캣에 제목과 같은 에러 메시지가 출력되면서 FCM token 값을 가져오지 못하는 문제가 발생했다.

검색을 해봤지만 들어맞는 해결책을 찾지는 못했다.

 

그러다 우연히 '구글 플레이스토어'를 실행하게 되었는데, 정상적으로 실행이 되지 않았다.

플레이스토어가 실행은 되지만 '새로고침' 버튼만 노출되면서 콘텐츠를 가져오지 못하고 있었다.

이상하다 싶어 이런저런 방법을 써봤지만 문제는 해결되지 않았고

결국 해결 방법을 찾지 못해 디바이스 초기화를 진행했다.

이후 플레이스토어는 정상 실행 되었으며, 우리 앱에서도 FCM token 값을 정상적으로 받아오게 되었다.

나 같은 경우엔 기기에 설치된 구글 플레이스토어의 문제였다.

웹뷰에 '당겨서 새로고침' 기능을 적용 경우,

웹 콘텐츠에 가로 스와이프 기능이 들어가 있으면 문제가 발생하는 경우가 있다.

따라서 세로로 스와이프 할때만 새로고침이 되도록 해야 한다.

 

먼저, SwipeRefreshLayout을 확장해서 OnlyVerticalSwipeRefreshLayout 클래스를 생성한다.

OnlyVerticalSwipeRefreshLayout.kt

open class OnlyVerticalSwipeRefreshLayout @JvmOverloads constructor(context: Context, attrs: AttributeSet?=null) :
    SwipeRefreshLayout(context, attrs) {

    private val touchSlop: Int = ViewConfiguration.get(context).scaledTouchSlop
    private var prevX = 0f
    private var declined = false

    override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
        when (event.action) {
            MotionEvent.ACTION_DOWN -> {
                prevX = MotionEvent.obtain(event).x
                declined = false // New action
            }
            MotionEvent.ACTION_MOVE -> {
                val eventX = event.x
                val xDiff = Math.abs(eventX - prevX)
                if (declined || xDiff > touchSlop) {
                    declined = true // Memorize
                    return false
                }
            }
        }
        return super.onInterceptTouchEvent(event)
    }
}

 

사용은 SwipeRefreshLayout을 사용할 때와 동일하다.

<com.ahikuya.OnlyVerticalSwipeRefreshLayout
    android:id="@+id/swipe_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <WebView
        android:id="@+id/web_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:animateLayoutChanges="true"
        android:focusable="true"
        android:focusableInTouchMode="true"/>
</com.ahikuya.OnlyVerticalSwipeRefreshLayout>

 

아래 문서를 참고했다.

https://stackoverflow.com/questions/34136178/swiperefreshlayout-blocking-horizontally-scrolled-recyclerview

+ Recent posts