From bbc282d16ac6479dfe770a4a28eebec8aaced5d6 Mon Sep 17 00:00:00 2001 From: 5ec1cff Date: Fri, 6 Oct 2023 09:28:50 +0800 Subject: [PATCH] bump material to 1.10.0 & make compiler happy --- app/build.gradle.kts | 5 +++++ .../a13e300/ro_tieba/api/WebAPIResultConverter.kt | 3 ++- .../a13e300/ro_tieba/ui/forum/ForumFragment.kt | 12 +++++------- .../a13e300/ro_tieba/ui/search/SearchFragment.kt | 2 +- .../a13e300/ro_tieba/ui/thread/ThreadFragment.kt | 2 -- .../io/github/a13e300/ro_tieba/utils/PhotoUtils.kt | 1 + .../java/io/github/a13e300/ro_tieba/view/ItemView.kt | 1 + .../main/res/layout/fragment_forum_thread_item.xml | 2 +- gradle/libs.versions.toml | 2 +- 9 files changed, 17 insertions(+), 13 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 639e9bd..a377893 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -95,6 +95,11 @@ android { } } +// https://discuss.gradle.org/t/what-is-xlint-deprecation-and-how-to-use-it/40270 +tasks.withType { + options.compilerArgs.add("-Xlint:deprecation") +} + dependencies { implementation(libs.core.ktx) diff --git a/app/src/main/java/io/github/a13e300/ro_tieba/api/WebAPIResultConverter.kt b/app/src/main/java/io/github/a13e300/ro_tieba/api/WebAPIResultConverter.kt index 5f1866e..d0f2981 100644 --- a/app/src/main/java/io/github/a13e300/ro_tieba/api/WebAPIResultConverter.kt +++ b/app/src/main/java/io/github/a13e300/ro_tieba/api/WebAPIResultConverter.kt @@ -11,6 +11,7 @@ import retrofit2.Converter import retrofit2.Retrofit import java.lang.reflect.Type +@Suppress("Unchecked_Cast") class WebAPIResultConverter( private val gson: Gson, val type: Type @@ -24,7 +25,7 @@ class WebAPIResultConverter( override fun convert(value: ResponseBody): Any { val jsonReader = gson.newJsonReader(value.charStream()) - return value.use { v -> + return value.use { _ -> val result = adapter.read(jsonReader) if (jsonReader.peek() != JsonToken.END_DOCUMENT) { throw JsonIOException("JSON document was not fully consumed.") diff --git a/app/src/main/java/io/github/a13e300/ro_tieba/ui/forum/ForumFragment.kt b/app/src/main/java/io/github/a13e300/ro_tieba/ui/forum/ForumFragment.kt index 073c85b..6ad120c 100644 --- a/app/src/main/java/io/github/a13e300/ro_tieba/ui/forum/ForumFragment.kt +++ b/app/src/main/java/io/github/a13e300/ro_tieba/ui/forum/ForumFragment.kt @@ -105,11 +105,9 @@ class ForumFragment : BaseFragment() { binding.forumDesc.text = it.desc binding.forumAvatar.displayImage(it.avatarUrl) binding.forumAvatar.setOnClickListener { _ -> - if (it.avatarUrl != null) { - photoViewModel.currentIndex.value = 0 - photoViewModel.photos = listOf(Photo(it.avatarUrl, 0, "rotieba")) - findNavController().navigate(MobileNavigationDirections.viewPhotos()) - } + photoViewModel.currentIndex.value = 0 + photoViewModel.photos = listOf(Photo(it.avatarUrl, 0, "rotieba")) + findNavController().navigate(MobileNavigationDirections.viewPhotos()) } if (!viewModel.historyAdded) { updateHistory() @@ -182,7 +180,7 @@ class ForumFragment : BaseFragment() { } binding.orderButton.apply { viewModel.forumSortType.observe(viewLifecycleOwner) { sort -> - text = when (sort) { + text = when (sort!!) { ForumSortType.REPLY_TIME -> getString(R.string.sort_by_reply_time) ForumSortType.CREATE_TIME -> getString(R.string.sort_by_create_time) } @@ -218,7 +216,7 @@ class ForumFragment : BaseFragment() { id = forumInfo.id.toString(), time = System.currentTimeMillis(), forumName = forumInfo.name, - forumAvatar = forumInfo.avatarUrl!! + forumAvatar = forumInfo.avatarUrl ) ) } diff --git a/app/src/main/java/io/github/a13e300/ro_tieba/ui/search/SearchFragment.kt b/app/src/main/java/io/github/a13e300/ro_tieba/ui/search/SearchFragment.kt index 695dd51..6b678df 100644 --- a/app/src/main/java/io/github/a13e300/ro_tieba/ui/search/SearchFragment.kt +++ b/app/src/main/java/io/github/a13e300/ro_tieba/ui/search/SearchFragment.kt @@ -221,7 +221,7 @@ class SearchFragment : BaseFragment() { } private fun performSearch(t: String, tab: Int) { - binding.searchBar.text = t + binding.searchBar.setText(t) viewModel.currentKeyword = t binding.searchView.hide() if (tab >= 0) diff --git a/app/src/main/java/io/github/a13e300/ro_tieba/ui/thread/ThreadFragment.kt b/app/src/main/java/io/github/a13e300/ro_tieba/ui/thread/ThreadFragment.kt index 0d79feb..0e23ad0 100644 --- a/app/src/main/java/io/github/a13e300/ro_tieba/ui/thread/ThreadFragment.kt +++ b/app/src/main/java/io/github/a13e300/ro_tieba/ui/thread/ThreadFragment.kt @@ -581,8 +581,6 @@ class ThreadFragment : BaseFragment() { Spannable.SPAN_EXCLUSIVE_EXCLUSIVE ) } - - else -> {} } } addTextView() diff --git a/app/src/main/java/io/github/a13e300/ro_tieba/utils/PhotoUtils.kt b/app/src/main/java/io/github/a13e300/ro_tieba/utils/PhotoUtils.kt index 75081ca..8a4839a 100644 --- a/app/src/main/java/io/github/a13e300/ro_tieba/utils/PhotoUtils.kt +++ b/app/src/main/java/io/github/a13e300/ro_tieba/utils/PhotoUtils.kt @@ -73,6 +73,7 @@ object PhotoUtils { } } + @Suppress("deprecation") private fun savePreQ(context: Context, fileName: String, input: InputStream, isVideo: Boolean) { val imagesDir = Environment.getExternalStoragePublicDirectory(if (isVideo) Environment.DIRECTORY_MOVIES else Environment.DIRECTORY_PICTURES) diff --git a/app/src/main/java/io/github/a13e300/ro_tieba/view/ItemView.kt b/app/src/main/java/io/github/a13e300/ro_tieba/view/ItemView.kt index b922cb3..782430b 100644 --- a/app/src/main/java/io/github/a13e300/ro_tieba/view/ItemView.kt +++ b/app/src/main/java/io/github/a13e300/ro_tieba/view/ItemView.kt @@ -8,6 +8,7 @@ import android.view.View import android.widget.FrameLayout import java.lang.ref.WeakReference +@Suppress("Unchecked_Cast") class ItemView : FrameLayout { data class ContextMenuInfo( val data: Any?, diff --git a/app/src/main/res/layout/fragment_forum_thread_item.xml b/app/src/main/res/layout/fragment_forum_thread_item.xml index cda96d6..ce4e7e5 100644 --- a/app/src/main/res/layout/fragment_forum_thread_item.xml +++ b/app/src/main/res/layout/fragment_forum_thread_item.xml @@ -90,7 +90,7 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/thread_title" /> -