Skip to content

Commit

Permalink
Fix imports
Browse files Browse the repository at this point in the history
  • Loading branch information
julieminer committed Jul 17, 2024
1 parent 775f0b3 commit e627301
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/com/melonhead/mangadexfollower/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class App: Application() {
override fun onStop(owner: LifecycleOwner) {
super.onStop(owner)
inForeground = false
com.melonhead.lib_logging.Clog.i("onStop: Creating background task")
Clog.i("onStop: Creating background task")
val refreshWorkRequest = PeriodicWorkRequestBuilder<RefreshWorker>(15.minutes.toJavaDuration()).build()
WorkManager.getInstance(this@App).enqueueUniquePeriodicWork("refresh-task", ExistingPeriodicWorkPolicy.KEEP, refreshWorkRequest)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import io.ktor.client.statement.*
import kotlin.random.Random

suspend inline fun <reified T> HttpClient.catching(logMessage: String, function: HttpClient.() -> HttpResponse): T? {
com.melonhead.lib_logging.Clog.i(logMessage)
Clog.i(logMessage)
var response: HttpResponse? = null
return try {
response = function()
Expand All @@ -21,14 +21,14 @@ suspend inline fun <reified T> HttpClient.catching(logMessage: String, function:
App.authFailed()
}
} else {
com.melonhead.lib_logging.Clog.e("$logMessage: ${response?.bodyAsText() ?: ""}", e)
Clog.e("$logMessage: ${response?.bodyAsText() ?: ""}", e)
}
null
}
}

suspend inline fun HttpClient.catchingSuccess(logMessage: String, function: HttpClient.() -> HttpResponse): Boolean {
com.melonhead.lib_logging.Clog.i(logMessage)
Clog.i(logMessage)
var response: HttpResponse? = null
return try {
response = function()
Expand All @@ -41,7 +41,7 @@ suspend inline fun HttpClient.catchingSuccess(logMessage: String, function: Http
App.authFailed()
}
} else {
com.melonhead.lib_logging.Clog.e("$logMessage: ${response?.bodyAsText() ?: ""}", e)
Clog.e("$logMessage: ${response?.bodyAsText() ?: ""}", e)
}
false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ suspend inline fun <reified T> handlePagination(
if (fetchAll) total = response.total
response.data
} catch (e: Exception) {
com.melonhead.lib_logging.Clog.e("handlePagination: ${result.bodyAsText()}", e)
Clog.e("handlePagination: ${result.bodyAsText()}", e)
break
}
allItems.addAll(items)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ object AuthFailedNotification {

val notificationManager = NotificationManagerCompat.from(context)

com.melonhead.lib_logging.Clog.i("postAuthFailed: Auth failed")
Clog.i("postAuthFailed: Auth failed")
val notification = buildNotification(context)
notificationManager.notify(Random.nextInt(), notification)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ object NewChapterNotification {

val notificationManager = NotificationManagerCompat.from(context)

com.melonhead.lib_logging.Clog.i("post: New chapters for ${series.count()} manga")
Clog.i("post: New chapters for ${series.count()} manga")
series.forEach { manga ->
manga.chapters.filter { it.createdDate >= installDateSeconds }.forEach chapters@{ uiChapter ->
val pendingIntent = pendingIntent(context, manga, uiChapter) ?: return@chapters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class AuthRepository(

suspend fun refreshToken(logoutOnFail: Boolean = false): AuthToken? {
suspend fun signOut() {
com.melonhead.lib_logging.Clog.e("Signing out, refresh failed", Exception())
Clog.e("Signing out, refresh failed", Exception())
mutableIsLoggedIn.value = LoginStatus.LoggedOut
if ((appContext as App).inForeground) return
val notificationManager = NotificationManagerCompat.from(appContext)
Expand All @@ -56,14 +56,14 @@ class AuthRepository(
val userResponse = userService.getInfo(newToken)
val userId = userResponse?.data?.id
if (userId == null) {
com.melonhead.lib_logging.Clog.e("User info returned null", RuntimeException())
Clog.e("User info returned null", RuntimeException())
}
appDataService.updateUserId(userId ?: "")
}
return newToken
}
suspend fun authenticate(email: String, password: String) {
com.melonhead.lib_logging.Clog.i("authenticate")
Clog.i("authenticate")
mutableIsLoggedIn.value = LoginStatus.LoggingIn
val token = loginService.authenticate(email, password)
appDataService.updateToken(token)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,19 @@ class MangaRepository(
// refresh auth
val token = authRepository.refreshToken()
if (token == null) {
com.melonhead.lib_logging.Clog.i("Failed to refresh token")
Clog.i("Failed to refresh token")
return@launch
}

com.melonhead.lib_logging.Clog.i("refreshManga")
Clog.i("refreshManga")

mutableRefreshStatus.value = Following
// fetch chapters from server
val chaptersResponse = userService.getFollowedChapters(token)
val chapterEntities = chaptersResponse.map { ChapterEntity.from(it) }
val newChapters = chapterEntities.filter { !chapterDb.containsChapter(it.id) }

com.melonhead.lib_logging.Clog.i("New chapters: ${newChapters.count()}")
Clog.i("New chapters: ${newChapters.count()}")

if (newChapters.isNotEmpty()) {
mutableRefreshStatus.value = MangaSeries
Expand All @@ -111,7 +111,7 @@ class MangaRepository(

// fetch manga series
val newMangaIds = mangaIds.filter { !mangaDb.containsManga(it) }
com.melonhead.lib_logging.Clog.i("New manga: ${newMangaIds.count()}")
Clog.i("New manga: ${newMangaIds.count()}")

if (newMangaIds.isNotEmpty()) {
val newMangaSeries = mangaService.getManga(token, newMangaIds.toList())
Expand All @@ -135,7 +135,7 @@ class MangaRepository(
val notificationManager = NotificationManagerCompat.from(appContext)
if (!notificationManager.areNotificationsEnabled()) return
val installDateSeconds = appDataService.installDateSeconds.firstOrNull() ?: 0L
com.melonhead.lib_logging.Clog.i("notifyOfNewChapters")
Clog.i("notifyOfNewChapters")

val newChapters = chapterDb.getAllSync().filter { readMarkerDb.isRead(it.mangaId, it.chapter) != true }
val manga = mangaDb.getAllSync()
Expand All @@ -146,7 +146,7 @@ class MangaRepository(
private suspend fun refreshReadStatus() {
// make sure we have a token
val token = appDataService.token.firstOrNull() ?: return
com.melonhead.lib_logging.Clog.i("refreshReadStatus")
Clog.i("refreshReadStatus")
val manga = mangaDb.getAllSync()
val chapters = chapterDb.getAllSync()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class AtHomeServiceImpl(
authToken: AuthToken,
chapterId: String
): AtHomeChapterResponse? {
com.melonhead.lib_logging.Clog.i("getChapterData: $chapterId")
Clog.i("getChapterData: $chapterId")
return client.catching("getChapterData") {
client.get(CHAPTER_DATA_URL + chapterId) {
headers {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class LoginServiceImpl(
val response: AuthResponse? = result.body()
if (response?.result == "ok") response.token else null
} catch (e: Exception) {
com.melonhead.lib_logging.Clog.w(e.localizedMessage ?: "Unknown error")
Clog.w(e.localizedMessage ?: "Unknown error")
if (logoutOnFail) null else token
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class MangaServiceImpl(
private val client: HttpClient,
): MangaService {
override suspend fun getManga(token: AuthToken, mangaIds: List<String>): List<Manga> {
com.melonhead.lib_logging.Clog.i("getManga: ${mangaIds.count()}")
Clog.i("getManga: ${mangaIds.count()}")
val result: List<Manga?> = handlePagination(mangaIds.count()) { offset ->
client.catching("getManga") {
client.get(MANGA_URL) {
Expand All @@ -50,10 +50,10 @@ class MangaServiceImpl(
}

override suspend fun getReadChapters(token: AuthToken, mangaIds: List<String>): List<String> {
com.melonhead.lib_logging.Clog.i("getReadChapters: total ${mangaIds.count()}")
Clog.i("getReadChapters: total ${mangaIds.count()}")
val allChapters = mutableListOf<String>()
mangaIds.chunked(100).map { list ->
com.melonhead.lib_logging.Clog.i("getReadChapters: chunked ${list.count()}")
Clog.i("getReadChapters: chunked ${list.count()}")
val result: MangaReadMarkersResponse? = client.catching("getReadChapters") {
client.get(MANGA_READ_MARKERS_URL) {
headers {
Expand All @@ -74,7 +74,7 @@ class MangaServiceImpl(
}

override suspend fun changeReadStatus(token: AuthToken, uiManga: UIManga, uiChapter: UIChapter, readStatus: Boolean) {
com.melonhead.lib_logging.Clog.i("changeReadStatus: chapter ${uiChapter.title} readStatus $readStatus")
Clog.i("changeReadStatus: chapter ${uiChapter.title} readStatus $readStatus")
client.catchingSuccess("changeReadStatus") {
client.post(MANGA_READ_CHAPTER_MARKERS_URL.replace(ID_PLACEHOLDER, uiManga.id)) {
headers {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class UserServiceImpl(
private val client: HttpClient
): UserService {
override suspend fun getFollowedChapters(token: AuthToken): List<Chapter> {
com.melonhead.lib_logging.Clog.i("getFollowedChapters")
Clog.i("getFollowedChapters")
return handlePagination(50, fetchAll = false) { offset ->
client.catching("getFollowedChapters") {
client.get(HttpRoutes.USER_FOLLOW_CHAPTERS_URL) {
Expand All @@ -41,7 +41,7 @@ class UserServiceImpl(
}

override suspend fun getInfo(token: AuthToken): UserResponse? {
com.melonhead.lib_logging.Clog.i("Get user")
Clog.i("Get user")
return client.catching("getInfo") {
client.get(HttpRoutes.USER_ME_URL) {
headers {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal fun ChapterScreen(

LaunchedEffect(key1 = allPages) {
val preloadPages = 2
com.melonhead.lib_logging.Clog.i("First page - Preloading pages 1 - ${1 + preloadPages}")
Clog.i("First page - Preloading pages 1 - ${1 + preloadPages}")
allPages.slice(min(1, allPages.count() - 1)..min((1 + preloadPages), allPages.count() - 1)).forEach { page ->
preloadImage(page, allPages.indexOf(page))
}
Expand All @@ -67,7 +67,7 @@ internal fun ChapterScreen(
val nextPreloadIndex = currentPageIndex + 2
val start = min(nextPreloadIndex, totalPages - 1)
val end = min(totalPages - 1, nextPreloadIndex + 1)
com.melonhead.lib_logging.Clog.i("Next page - Current Page $currentPageIndex, moving to ${currentPageIndex + 1} Preloading pages $start - $end")
Clog.i("Next page - Current Page $currentPageIndex, moving to ${currentPageIndex + 1} Preloading pages $start - $end")
allPages.slice(start..end).forEach {
preloadImage(it, allPages.indexOf(it))
}
Expand Down Expand Up @@ -157,7 +157,7 @@ private fun ChapterView(
val (width, height) = getWidthHeight()
SubcomposeAsyncImage(
model = currentPageUrl.preloadImageRequest(pageIndex = currentPageIndex, LocalContext.current, width, height, retryHash) {
com.melonhead.lib_logging.Clog.i("Retrying due to load failure")
Clog.i("Retrying due to load failure")
retryHash = !retryHash
},
loading = {
Expand Down Expand Up @@ -193,17 +193,17 @@ private fun String.preloadImageRequest(pageIndex: Int, context: Context, width:
.crossfade(true)
.listener(
onStart = {
com.melonhead.lib_logging.Clog.i("Image Load start: page $pageIndex")
Clog.i("Image Load start: page $pageIndex")
},
onCancel = {
com.melonhead.lib_logging.Clog.i("Image Load cancel: page $pageIndex")
Clog.i("Image Load cancel: page $pageIndex")
},
onSuccess = { _, result ->
com.melonhead.lib_logging.Clog.i("Image Load success: Source ${result.dataSource.name}, page $pageIndex")
Clog.i("Image Load success: Source ${result.dataSource.name}, page $pageIndex")
},
onError = { _, result ->
com.melonhead.lib_logging.Clog.i("Image Load failed: page $pageIndex")
com.melonhead.lib_logging.Clog.e("Image Load failed", result.throwable)
Clog.i("Image Load failed: page $pageIndex")
Clog.e("Image Load failed", result.throwable)
onError()
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ChapterViewModel(
if (!manga.useWebview) {
mangaRepository.setUseWebview(manga, true)
}
com.melonhead.lib_logging.Clog.i("Falling back to webview")
Clog.i("Falling back to webview")
// fallback to secondary render style
val intent = WebViewActivity.newIntent(activity, chapter, manga)
activity.finish()
Expand Down

0 comments on commit e627301

Please sign in to comment.