KMOOC API 301 에러

2024-01-30 17:32:56.367 21324-21343 OpenGLRenderer          com.programmers.kmooc                E  Unable to match the desired swap behavior.
2024-01-30 17:32:56.392 21324-21346 AndroidRuntime          com.programmers.kmooc                E  FATAL EXCEPTION: DefaultDispatcher-worker-1
Process: com.programmers.kmooc, PID: 21324
org.json.JSONException: Value <html> of type java.lang.String cannot be converted to JSONObject
at org.json.JSON.typeMismatch(JSON.java:112)
at org.json.JSONObject.<init>(JSONObject.java:172)
at org.json.JSONObject.<init>(JSONObject.java:185)
at com.programmers.kmooc.data.repositories.KmoocRepository.getLectures(KmoocRepository.kt:19)
at com.programmers.kmooc.ui.list.KmoocListViewModel$load$1.invokeSuspend(KmoocListViewModel.kt:44)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:100)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@178a157, [Dispatchers.IO](<http://dispatchers.io/>)]

301 에러로 보내오는 API 응답 값

"<html>\\r\\n<head><title>301 Moved Permanently</title></head>\\r\\n<body>\\r\\n<center><h1>301 Moved Permanently</h1></center>\\r\\n<hr><center>nginx/1.22.0</center>\\r\\n</body>\\r\\n</html>\\r\\n"

CoroutineScope

CoroutineScope은 .cancel() 함수에 의해 한 번 취소되면 재사용할 수 없다. 취소된 CoroutineScope에 코드를 할당해도 실행되지 않는다. 따라서 다시 사용할 필요가 있을 때 CoroutineScope을 재생성해야 한다.

SwipeRefreshLayout

상단으로 제스쳐해서 목록을 새로고침하는 기능을 구현할 때 용이하다.

Swiperefreshlayout  |  Jetpack  |  Android Developers