From 78da98bd1d536198658e9b154384a3bfb116e616 Mon Sep 17 00:00:00 2001 From: rebelonion <87634197+rebelonion@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:36:59 -0600 Subject: [PATCH] fix: keep text state when off screen (commentItem) --- app/src/main/java/ani/dantotsu/MainActivity.kt | 13 ++----------- .../java/ani/dantotsu/media/comments/CommentItem.kt | 5 ++++- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/MainActivity.kt b/app/src/main/java/ani/dantotsu/MainActivity.kt index 8f5dd79f59..1e19ca8a8a 100644 --- a/app/src/main/java/ani/dantotsu/MainActivity.kt +++ b/app/src/main/java/ani/dantotsu/MainActivity.kt @@ -326,21 +326,12 @@ class MainActivity : AppCompatActivity() { } } } - //TODO: Remove this - GlobalScope.launch(Dispatchers.IO) { + lifecycleScope.launch(Dispatchers.IO) { //simple cleanup val index = Helper.downloadManager(this@MainActivity).downloadIndex val downloadCursor = index.getDownloads() while (downloadCursor.moveToNext()) { val download = downloadCursor.download - Log.e("Downloader", download.request.uri.toString()) - Log.e("Downloader", download.request.id) - Log.e("Downloader", download.request.mimeType.toString()) - Log.e("Downloader", download.request.data.size.toString()) - Log.e("Downloader", download.bytesDownloaded.toString()) - Log.e("Downloader", download.state.toString()) - Log.e("Downloader", download.failureReason.toString()) - - if (download.state == Download.STATE_FAILED) { //simple cleanup + if (download.state == Download.STATE_FAILED) { Helper.downloadManager(this@MainActivity).removeDownload(download.request.id) } } diff --git a/app/src/main/java/ani/dantotsu/media/comments/CommentItem.kt b/app/src/main/java/ani/dantotsu/media/comments/CommentItem.kt index faedf58380..859a586c11 100644 --- a/app/src/main/java/ani/dantotsu/media/comments/CommentItem.kt +++ b/app/src/main/java/ani/dantotsu/media/comments/CommentItem.kt @@ -54,10 +54,13 @@ class CommentItem(val comment: Comment, viewBinding.commentDelete.visibility = if (isUserComment || CommentsAPI.isAdmin || CommentsAPI.isMod) View.VISIBLE else View.GONE viewBinding.commentBanUser.visibility = if ((CommentsAPI.isAdmin || CommentsAPI.isMod) && !isUserComment) View.VISIBLE else View.GONE viewBinding.commentEdit.visibility = if (isUserComment) View.VISIBLE else View.GONE + replying(isReplying) //sets default text + editing(isEditing) if ((comment.replyCount ?: 0) > 0) { viewBinding.commentTotalReplies.visibility = View.VISIBLE viewBinding.commentRepliesDivider.visibility = View.VISIBLE - viewBinding.commentTotalReplies.text = "View ${comment.replyCount} repl${if (comment.replyCount == 1) "y" else "ies"}" + viewBinding.commentTotalReplies.text = if(repliesVisible) "Hide Replies" else + "View ${comment.replyCount} repl${if (comment.replyCount == 1) "y" else "ies"}" } else { viewBinding.commentTotalReplies.visibility = View.GONE viewBinding.commentRepliesDivider.visibility = View.GONE