From 53c6b9598f37e2a8a3271a43b9cb68aa61495ea7 Mon Sep 17 00:00:00 2001 From: Ruben Gees Date: Tue, 9 Oct 2018 18:35:06 +0200 Subject: [PATCH] Refactor MessengerViewModel and update Kotlin to latest RC --- gradle/versions.gradle | 2 +- .../me/proxer/app/anime/AnimeActivity.kt | 2 +- .../me/proxer/app/anime/AnimeFragment.kt | 6 +- .../kotlin/me/proxer/app/auth/LoginDialog.kt | 6 +- .../kotlin/me/proxer/app/auth/LogoutDialog.kt | 4 +- .../proxer/app/base/PagedContentFragment.kt | 2 +- .../proxer/app/bookmark/BookmarkFragment.kt | 2 +- .../prv/create/CreateConferenceFragment.kt | 4 +- .../app/chat/prv/message/MessengerFragment.kt | 2 +- .../chat/prv/message/MessengerViewModel.kt | 85 ++++++++----------- .../app/chat/pub/message/ChatReportDialog.kt | 4 +- .../app/chat/pub/message/ChatViewModel.kt | 4 +- .../pub/room/info/ChatRoomInfoViewModel.kt | 4 +- .../me/proxer/app/forum/TopicFragment.kt | 2 +- .../me/proxer/app/manga/MangaActivity.kt | 2 +- .../me/proxer/app/manga/MangaFragment.kt | 6 +- .../me/proxer/app/media/MediaInfoViewModel.kt | 2 +- .../app/media/info/MediaInfoFragment.kt | 8 +- .../app/notification/NotificationFragment.kt | 2 +- .../app/ucp/media/UcpMediaListFragment.kt | 2 +- .../app/ucp/topten/UcpTopTenFragment.kt | 2 +- .../app/ui/view/ExpandableSelectionView.kt | 2 +- .../view/bbcode/prototype/ImagePrototype.kt | 2 +- .../ui/view/bbcode/prototype/PdfPrototype.kt | 2 +- .../me/proxer/app/util/TaggedSocketFactory.kt | 10 +-- .../app/util/extension/ProxerRxExtensions.kt | 2 +- 26 files changed, 78 insertions(+), 93 deletions(-) diff --git a/gradle/versions.gradle b/gradle/versions.gradle index 9498e362..de15a054 100644 --- a/gradle/versions.gradle +++ b/gradle/versions.gradle @@ -16,7 +16,7 @@ ext { // Core plugins androidPluginVersion = '3.3.0-alpha13' - kotlinVersion = '1.3-M2' + kotlinVersion = '1.3.0-rc-146' // Utility plugins detektPluginVersion = '1.0.0.RC9.2' diff --git a/src/main/kotlin/me/proxer/app/anime/AnimeActivity.kt b/src/main/kotlin/me/proxer/app/anime/AnimeActivity.kt index 133b5b54..6d18d808 100644 --- a/src/main/kotlin/me/proxer/app/anime/AnimeActivity.kt +++ b/src/main/kotlin/me/proxer/app/anime/AnimeActivity.kt @@ -135,7 +135,7 @@ class AnimeActivity : DrawerActivity() { supportActionBar?.setDisplayHomeAsUpEnabled(true) toolbar.clicks() .autoDisposable(this.scope()) - .subscribe { _ -> + .subscribe { name?.let { MediaActivity.navigateTo(this, id, it, Category.ANIME) } diff --git a/src/main/kotlin/me/proxer/app/anime/AnimeFragment.kt b/src/main/kotlin/me/proxer/app/anime/AnimeFragment.kt index eafcbf36..697b2270 100644 --- a/src/main/kotlin/me/proxer/app/anime/AnimeFragment.kt +++ b/src/main/kotlin/me/proxer/app/anime/AnimeFragment.kt @@ -218,13 +218,13 @@ class AnimeFragment : BaseContentFragment() { }) viewModel.userStateData.observe(viewLifecycleOwner, Observer { - it?.let { _ -> + it?.let { snackbar(root, R.string.fragment_set_user_info_success) } }) viewModel.userStateError.observe(viewLifecycleOwner, Observer { - it?.let { _ -> + it?.let { multilineSnackbar( root, getString(R.string.error_set_user_info, getString(it.message)), Snackbar.LENGTH_LONG, it.buttonMessage, it.toClickListener(hostingActivity) @@ -287,7 +287,7 @@ class AnimeFragment : BaseContentFragment() { errorContainer.isInvisible = true errorInnerContainer.doOnLayout { - header.doOnLayout { _ -> + header.doOnLayout { val newCenter = root.height / 2f + header.height / 2f val containerCenterCorrection = errorInnerContainer.height / 2f diff --git a/src/main/kotlin/me/proxer/app/auth/LoginDialog.kt b/src/main/kotlin/me/proxer/app/auth/LoginDialog.kt index 0561eba8..5174022f 100644 --- a/src/main/kotlin/me/proxer/app/auth/LoginDialog.kt +++ b/src/main/kotlin/me/proxer/app/auth/LoginDialog.kt @@ -98,7 +98,7 @@ class LoginDialog : BaseDialog() { it.editorActionEvents(Predicate { event -> event.actionId() == EditorInfo.IME_ACTION_GO }) .filter { event -> event.actionId() == EditorInfo.IME_ACTION_GO } .autoDisposable(dialogLifecycleOwner.scope()) - .subscribe { _ -> validateAndLogin() } + .subscribe { validateAndLogin() } } listOf(username to usernameContainer, password to passwordContainer).forEach { (input, container) -> @@ -116,7 +116,7 @@ class LoginDialog : BaseDialog() { private fun setupViewModel() { viewModel.data.observe(dialogLifecycleOwner, Observer { - it?.let { _ -> + it?.let { storageHelper.user = LocalUser(it.loginToken, it.id, username.safeText.trim().toString(), it.image) bus.post(LoginEvent()) @@ -126,7 +126,7 @@ class LoginDialog : BaseDialog() { }) viewModel.error.observe(dialogLifecycleOwner, Observer { - it?.let { _ -> + it?.let { viewModel.error.value = null requireContext().toast(it.message) diff --git a/src/main/kotlin/me/proxer/app/auth/LogoutDialog.kt b/src/main/kotlin/me/proxer/app/auth/LogoutDialog.kt index f51235b1..2415abe5 100644 --- a/src/main/kotlin/me/proxer/app/auth/LogoutDialog.kt +++ b/src/main/kotlin/me/proxer/app/auth/LogoutDialog.kt @@ -40,11 +40,11 @@ class LogoutDialog : BaseDialog() { super.onDialogCreated(savedInstanceState) viewModel.data.observe(dialogLifecycleOwner, Observer { - it?.let { _ -> dismiss() } + it?.let { dismiss() } }) viewModel.error.observe(dialogLifecycleOwner, Observer { - it?.let { _ -> + it?.let { viewModel.error.value = null requireContext().toast(it.message) diff --git a/src/main/kotlin/me/proxer/app/base/PagedContentFragment.kt b/src/main/kotlin/me/proxer/app/base/PagedContentFragment.kt index 92a39405..0a6365f6 100644 --- a/src/main/kotlin/me/proxer/app/base/PagedContentFragment.kt +++ b/src/main/kotlin/me/proxer/app/base/PagedContentFragment.kt @@ -82,7 +82,7 @@ abstract class PagedContentFragment : BaseContentFragment>() { .subscribe { viewModel.loadIfPossible() } viewModel.refreshError.observe(viewLifecycleOwner, Observer { - it?.let { _ -> + it?.let { multilineSnackbar( root, getString(R.string.error_refresh, getString(it.message)), Snackbar.LENGTH_LONG, it.buttonMessage, it.toClickListener(hostingActivity) diff --git a/src/main/kotlin/me/proxer/app/bookmark/BookmarkFragment.kt b/src/main/kotlin/me/proxer/app/bookmark/BookmarkFragment.kt index 2ea2a8f1..ad7d73c1 100644 --- a/src/main/kotlin/me/proxer/app/bookmark/BookmarkFragment.kt +++ b/src/main/kotlin/me/proxer/app/bookmark/BookmarkFragment.kt @@ -113,7 +113,7 @@ class BookmarkFragment : PagedContentFragment() { innerAdapter.glide = GlideApp.with(this) viewModel.itemDeletionError.observe(viewLifecycleOwner, Observer { - it?.let { _ -> + it?.let { multilineSnackbar( root, getString(R.string.error_bookmark_deletion, getString(it.message)), Snackbar.LENGTH_LONG, it.buttonMessage, it.toClickListener(hostingActivity) diff --git a/src/main/kotlin/me/proxer/app/chat/prv/create/CreateConferenceFragment.kt b/src/main/kotlin/me/proxer/app/chat/prv/create/CreateConferenceFragment.kt index fb92697a..d8f1a9ed 100644 --- a/src/main/kotlin/me/proxer/app/chat/prv/create/CreateConferenceFragment.kt +++ b/src/main/kotlin/me/proxer/app/chat/prv/create/CreateConferenceFragment.kt @@ -332,7 +332,7 @@ class CreateConferenceFragment : BaseFragment() { }) viewModel.result.observe(viewLifecycleOwner, Observer { - it?.let { _ -> + it?.let { requireActivity().finish() MessengerActivity.navigateTo(requireActivity(), it) @@ -340,7 +340,7 @@ class CreateConferenceFragment : BaseFragment() { }) viewModel.error.observe(viewLifecycleOwner, Observer { - it?.let { _ -> + it?.let { multilineSnackbar( root, it.message, diff --git a/src/main/kotlin/me/proxer/app/chat/prv/message/MessengerFragment.kt b/src/main/kotlin/me/proxer/app/chat/prv/message/MessengerFragment.kt index 65377a45..3248f241 100644 --- a/src/main/kotlin/me/proxer/app/chat/prv/message/MessengerFragment.kt +++ b/src/main/kotlin/me/proxer/app/chat/prv/message/MessengerFragment.kt @@ -195,7 +195,7 @@ class MessengerFragment : PagedContentFragment() { } viewModel.conference.observe(viewLifecycleOwner, Observer { - it?.let { _ -> conference = it } + it?.let { conference = it } }) recyclerView.scrollEvents() diff --git a/src/main/kotlin/me/proxer/app/chat/prv/message/MessengerViewModel.kt b/src/main/kotlin/me/proxer/app/chat/prv/message/MessengerViewModel.kt index 48a65915..3cdbf873 100644 --- a/src/main/kotlin/me/proxer/app/chat/prv/message/MessengerViewModel.kt +++ b/src/main/kotlin/me/proxer/app/chat/prv/message/MessengerViewModel.kt @@ -34,44 +34,9 @@ class MessengerViewModel(initialConference: LocalConference) : PagedViewModel>() { - - private val source by lazy { messengerDao.getMessagesLiveDataForConference(safeConference.id) } - - override fun onActive() { - super.onActive() - - addSource(source) { - it?.let { _ -> - if (storageHelper.isLoggedIn) { - if (it.isEmpty() && !hasReachedEnd) { - MessengerWorker.enqueueMessageLoad(safeConference.id) - } else { - if (error.value == null) { - dataDisposable?.dispose() - - page = it.size.div(itemsOnPage) - - isLoading.value = false - error.value = null - this.value = it - - Completable.fromAction { messengerDao.markConferenceAsRead(safeConference.id) } - .subscribeOn(Schedulers.io()) - .subscribeAndLogErrors() - } - } - } - } - } - } - - override fun onInactive() { - removeSource(source) - - super.onInactive() - } - } + override val data = MediatorLiveData>() + val conference = MediatorLiveData() + val draft = ResettingMutableLiveData() override val dataSingle: Single> get() = Single.fromCallable { validators.validateLogin() } @@ -84,26 +49,37 @@ class MessengerViewModel(initialConference: LocalConference) : PagedViewModel>() } - val conference = object : MediatorLiveData() { + private val dataSource = { it: List? -> + it?.also { + if (storageHelper.isLoggedIn) { + if (it.isEmpty() && !hasReachedEnd) { + MessengerWorker.enqueueMessageLoad(safeConference.id) + } else { + if (error.value == null) { + dataDisposable?.dispose() - private val source by lazy { messengerDao.getConferenceLiveData(safeConference.id) } + page = it.size.div(itemsOnPage) - override fun onActive() { - super.onActive() + isLoading.value = false + error.value = null + data.value = it - addSource(source) { - it?.let { _ -> this.value = it } + Completable.fromAction { messengerDao.markConferenceAsRead(safeConference.id) } + .subscribeOn(Schedulers.io()) + .subscribeAndLogErrors() + } + } } } - override fun onInactive() { - removeSource(source) - - super.onInactive() - } + Unit } - val draft = ResettingMutableLiveData() + private val conferenceSource = { it: LocalConference? -> + it?.also { conference.value = it } + + Unit + } private val messengerDao by inject() @@ -115,6 +91,15 @@ class MessengerViewModel(initialConference: LocalConference) : PagedViewModel diff --git a/src/main/kotlin/me/proxer/app/chat/pub/message/ChatReportDialog.kt b/src/main/kotlin/me/proxer/app/chat/pub/message/ChatReportDialog.kt index c9b9f731..e6de176f 100644 --- a/src/main/kotlin/me/proxer/app/chat/pub/message/ChatReportDialog.kt +++ b/src/main/kotlin/me/proxer/app/chat/pub/message/ChatReportDialog.kt @@ -78,11 +78,11 @@ class ChatReportDialog : BaseDialog() { .subscribe { setError(messageContainer, null) } viewModel.data.observe(dialogLifecycleOwner, Observer { - it?.let { _ -> dismiss() } + it?.let { dismiss() } }) viewModel.error.observe(dialogLifecycleOwner, Observer { - it?.let { _ -> + it?.let { viewModel.error.value = null requireContext().toast(it.message) diff --git a/src/main/kotlin/me/proxer/app/chat/pub/message/ChatViewModel.kt b/src/main/kotlin/me/proxer/app/chat/pub/message/ChatViewModel.kt index e16cb829..572cd328 100644 --- a/src/main/kotlin/me/proxer/app/chat/pub/message/ChatViewModel.kt +++ b/src/main/kotlin/me/proxer/app/chat/pub/message/ChatViewModel.kt @@ -189,8 +189,8 @@ class ChatViewModel(private val chatRoomId: String) : PagedViewModel message.toParsedMessage() } } - .repeatWhen { it.concatMap { _ -> Flowable.timer(3, TimeUnit.SECONDS) } } - .retryWhen { it.concatMap { _ -> Flowable.timer(3, TimeUnit.SECONDS) } } + .repeatWhen { it.concatMap { Flowable.timer(3, TimeUnit.SECONDS) } } + .retryWhen { it.concatMap { Flowable.timer(3, TimeUnit.SECONDS) } } .map { newData -> mergeNewDataWithExistingData(newData, "0") } .let { if (!immediate) it.delaySubscription(3, TimeUnit.SECONDS) else it } .subscribeOn(Schedulers.io()) diff --git a/src/main/kotlin/me/proxer/app/chat/pub/room/info/ChatRoomInfoViewModel.kt b/src/main/kotlin/me/proxer/app/chat/pub/room/info/ChatRoomInfoViewModel.kt index cf97b56f..434ac034 100644 --- a/src/main/kotlin/me/proxer/app/chat/pub/room/info/ChatRoomInfoViewModel.kt +++ b/src/main/kotlin/me/proxer/app/chat/pub/room/info/ChatRoomInfoViewModel.kt @@ -45,8 +45,8 @@ class ChatRoomInfoViewModel(private val chatRoomId: String) : BaseContentViewMod private fun startPolling() { pollingDisposable = dataSingle - .repeatWhen { it.concatMap { _ -> Flowable.timer(10, TimeUnit.SECONDS) } } - .retryWhen { it.concatMap { _ -> Flowable.timer(10, TimeUnit.SECONDS) } } + .repeatWhen { it.concatMap { Flowable.timer(10, TimeUnit.SECONDS) } } + .retryWhen { it.concatMap { Flowable.timer(10, TimeUnit.SECONDS) } } .delaySubscription(10, TimeUnit.SECONDS) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) diff --git a/src/main/kotlin/me/proxer/app/forum/TopicFragment.kt b/src/main/kotlin/me/proxer/app/forum/TopicFragment.kt index 0ce61d32..5e2f4e98 100644 --- a/src/main/kotlin/me/proxer/app/forum/TopicFragment.kt +++ b/src/main/kotlin/me/proxer/app/forum/TopicFragment.kt @@ -78,7 +78,7 @@ class TopicFragment : PagedContentFragment() { innerAdapter.glide = GlideApp.with(this) viewModel.metaData.observe(viewLifecycleOwner, Observer { - it?.let { _ -> topic = it.subject } + it?.let { topic = it.subject } }) } diff --git a/src/main/kotlin/me/proxer/app/manga/MangaActivity.kt b/src/main/kotlin/me/proxer/app/manga/MangaActivity.kt index 0d8eac86..58a4f47e 100644 --- a/src/main/kotlin/me/proxer/app/manga/MangaActivity.kt +++ b/src/main/kotlin/me/proxer/app/manga/MangaActivity.kt @@ -203,7 +203,7 @@ class MangaActivity : BaseActivity() { supportActionBar?.setDisplayHomeAsUpEnabled(true) toolbar.clicks() .autoDisposable(this.scope()) - .subscribe { _ -> + .subscribe { name?.let { MediaActivity.navigateTo(this, id, name, Category.MANGA) } diff --git a/src/main/kotlin/me/proxer/app/manga/MangaFragment.kt b/src/main/kotlin/me/proxer/app/manga/MangaFragment.kt index 3f170bfe..c550f7d9 100644 --- a/src/main/kotlin/me/proxer/app/manga/MangaFragment.kt +++ b/src/main/kotlin/me/proxer/app/manga/MangaFragment.kt @@ -268,13 +268,13 @@ class MangaFragment : BaseContentFragment() { recyclerView.adapter = adapter viewModel.userStateData.observe(viewLifecycleOwner, Observer { - it?.let { _ -> + it?.let { snackbar(activityRoot, R.string.fragment_set_user_info_success) } }) viewModel.userStateError.observe(viewLifecycleOwner, Observer { - it?.let { _ -> + it?.let { multilineSnackbar( root, getString(R.string.error_set_user_info, getString(it.message)), Snackbar.LENGTH_LONG, it.buttonMessage, it.toClickListener(hostingActivity) @@ -397,7 +397,7 @@ class MangaFragment : BaseContentFragment() { errorContainer.isInvisible = true errorInnerContainer.doOnLayout { - header.doOnLayout { _ -> + header.doOnLayout { val newCenter = root.height / 2f + header.height / 2f val containerCenterCorrection = errorInnerContainer.height / 2f diff --git a/src/main/kotlin/me/proxer/app/media/MediaInfoViewModel.kt b/src/main/kotlin/me/proxer/app/media/MediaInfoViewModel.kt index 078e96aa..22c5e850 100644 --- a/src/main/kotlin/me/proxer/app/media/MediaInfoViewModel.kt +++ b/src/main/kotlin/me/proxer/app/media/MediaInfoViewModel.kt @@ -92,7 +92,7 @@ class MediaInfoViewModel(private val entryId: String) : BaseViewModel + .subscribeAndLogErrors({ userInfoUpdateError.value = null userInfoUpdateData.value = Unit diff --git a/src/main/kotlin/me/proxer/app/media/info/MediaInfoFragment.kt b/src/main/kotlin/me/proxer/app/media/info/MediaInfoFragment.kt index a2fecc2e..133232b0 100644 --- a/src/main/kotlin/me/proxer/app/media/info/MediaInfoFragment.kt +++ b/src/main/kotlin/me/proxer/app/media/info/MediaInfoFragment.kt @@ -159,13 +159,13 @@ class MediaInfoFragment : BaseContentFragment + it?.let { snackbar(root, R.string.fragment_set_user_info_success) } }) viewModel.userInfoUpdateError.observe(viewLifecycleOwner, Observer { - it?.let { _ -> + it?.let { multilineSnackbar( root, getString(R.string.error_set_user_info, getString(it.message)), Snackbar.LENGTH_LONG, it.buttonMessage, it.toClickListener(hostingActivity) @@ -450,13 +450,13 @@ class MediaInfoFragment : BaseContentFragment onClick.invoke(items[index]) } + .subscribe { onClick.invoke(items[index]) } } if (layout is MaxLineFlexboxLayout && !layout.canAddView(chip)) { layout.showAllEvents .autoDisposable(viewLifecycleOwner.scope(Lifecycle.Event.ON_DESTROY)) - .subscribe { _ -> bindChips(layout, items, mapFunction, onClick) } + .subscribe { bindChips(layout, items, mapFunction, onClick) } layout.enableShowAllButton() diff --git a/src/main/kotlin/me/proxer/app/notification/NotificationFragment.kt b/src/main/kotlin/me/proxer/app/notification/NotificationFragment.kt index 11d34850..8ab0ab42 100644 --- a/src/main/kotlin/me/proxer/app/notification/NotificationFragment.kt +++ b/src/main/kotlin/me/proxer/app/notification/NotificationFragment.kt @@ -61,7 +61,7 @@ class NotificationFragment : PagedContentFragment() { super.onViewCreated(view, savedInstanceState) viewModel.deletionError.observe(viewLifecycleOwner, Observer { - it?.let { _ -> + it?.let { multilineSnackbar( root, getString(R.string.error_notification_deletion, getString(it.message)), Snackbar.LENGTH_LONG, it.buttonMessage, it.toClickListener(hostingActivity) diff --git a/src/main/kotlin/me/proxer/app/ucp/media/UcpMediaListFragment.kt b/src/main/kotlin/me/proxer/app/ucp/media/UcpMediaListFragment.kt index 7b6eb1c8..c3074ead 100644 --- a/src/main/kotlin/me/proxer/app/ucp/media/UcpMediaListFragment.kt +++ b/src/main/kotlin/me/proxer/app/ucp/media/UcpMediaListFragment.kt @@ -95,7 +95,7 @@ class UcpMediaListFragment : PagedContentFragment() { innerAdapter.glide = GlideApp.with(this) viewModel.itemDeletionError.observe(viewLifecycleOwner, Observer { - it?.let { _ -> + it?.let { multilineSnackbar( root, getString(R.string.error_ucp_entry_deletion, getString(it.message)), Snackbar.LENGTH_LONG, it.buttonMessage, it.toClickListener(hostingActivity) diff --git a/src/main/kotlin/me/proxer/app/ucp/topten/UcpTopTenFragment.kt b/src/main/kotlin/me/proxer/app/ucp/topten/UcpTopTenFragment.kt index b9e6d2e6..a17ad686 100644 --- a/src/main/kotlin/me/proxer/app/ucp/topten/UcpTopTenFragment.kt +++ b/src/main/kotlin/me/proxer/app/ucp/topten/UcpTopTenFragment.kt @@ -86,7 +86,7 @@ class UcpTopTenFragment : BaseContentFragment() { mangaRecyclerView.adapter = mangaAdapter viewModel.itemDeletionError.observe(viewLifecycleOwner, Observer { - it?.let { _ -> + it?.let { multilineSnackbar( root, getString(R.string.error_topten_entry_removal, getString(it.message)), Snackbar.LENGTH_LONG, it.buttonMessage, it.toClickListener(hostingActivity) diff --git a/src/main/kotlin/me/proxer/app/ui/view/ExpandableSelectionView.kt b/src/main/kotlin/me/proxer/app/ui/view/ExpandableSelectionView.kt index 69f9baff..e038d64f 100644 --- a/src/main/kotlin/me/proxer/app/ui/view/ExpandableSelectionView.kt +++ b/src/main/kotlin/me/proxer/app/ui/view/ExpandableSelectionView.kt @@ -191,7 +191,7 @@ class ExpandableSelectionView @JvmOverloads constructor( items.zip(itemContainer.children.toList()).forEach { (item, view) -> view.clicks() .autoDisposable(ViewScopeProvider.from(this)) - .subscribeAndLogErrors { _ -> + .subscribeAndLogErrors { selection.clear() selection.add(item) diff --git a/src/main/kotlin/me/proxer/app/ui/view/bbcode/prototype/ImagePrototype.kt b/src/main/kotlin/me/proxer/app/ui/view/bbcode/prototype/ImagePrototype.kt index 6f9ee739..e6a6e317 100644 --- a/src/main/kotlin/me/proxer/app/ui/view/bbcode/prototype/ImagePrototype.kt +++ b/src/main/kotlin/me/proxer/app/ui/view/bbcode/prototype/ImagePrototype.kt @@ -66,7 +66,7 @@ object ImagePrototype : AutoClosingPrototype { (parent.context as? Activity)?.let { context -> view.clicks() .autoDisposable(ViewScopeProvider.from(parent)) - .subscribe { _ -> + .subscribe { if (view.getTag(R.id.error_tag) == true) { view.tag = null diff --git a/src/main/kotlin/me/proxer/app/ui/view/bbcode/prototype/PdfPrototype.kt b/src/main/kotlin/me/proxer/app/ui/view/bbcode/prototype/PdfPrototype.kt index 103b6a19..dbcb5b73 100644 --- a/src/main/kotlin/me/proxer/app/ui/view/bbcode/prototype/PdfPrototype.kt +++ b/src/main/kotlin/me/proxer/app/ui/view/bbcode/prototype/PdfPrototype.kt @@ -85,7 +85,7 @@ object PdfPrototype : ConditionalTextMutatorPrototype, AutoClosingPrototype { view.clicks() .filter { view.getTag(R.id.error_tag) == true } .autoDisposable(ViewScopeProvider.from(parent)) - .subscribe { _ -> + .subscribe { view.tag = null args.glide?.let { loadImage(it, view, parsedUrl) } diff --git a/src/main/kotlin/me/proxer/app/util/TaggedSocketFactory.kt b/src/main/kotlin/me/proxer/app/util/TaggedSocketFactory.kt index 729e8682..a15a5286 100644 --- a/src/main/kotlin/me/proxer/app/util/TaggedSocketFactory.kt +++ b/src/main/kotlin/me/proxer/app/util/TaggedSocketFactory.kt @@ -14,12 +14,12 @@ class TaggedSocketFactory : SocketFactory() { override fun createSocket(): Socket { return delegate.createSocket() - .also { _ -> TrafficStats.setThreadStatsTag(1) } + .also { TrafficStats.setThreadStatsTag(1) } } override fun createSocket(host: String?, port: Int): Socket { return delegate.createSocket(host, port) - .also { _ -> TrafficStats.setThreadStatsTag(1) } + .also { TrafficStats.setThreadStatsTag(1) } } override fun createSocket( @@ -29,12 +29,12 @@ class TaggedSocketFactory : SocketFactory() { localPort: Int ): Socket { return delegate.createSocket(host, port, localHost, localPort) - .also { _ -> TrafficStats.setThreadStatsTag(1) } + .also { TrafficStats.setThreadStatsTag(1) } } override fun createSocket(host: InetAddress?, port: Int): Socket { return delegate.createSocket(host, port) - .also { _ -> TrafficStats.setThreadStatsTag(1) } + .also { TrafficStats.setThreadStatsTag(1) } } override fun createSocket( @@ -44,6 +44,6 @@ class TaggedSocketFactory : SocketFactory() { localPort: Int ): Socket { return delegate.createSocket(address, port, localAddress, localPort) - .also { _ -> TrafficStats.setThreadStatsTag(1) } + .also { TrafficStats.setThreadStatsTag(1) } } } diff --git a/src/main/kotlin/me/proxer/app/util/extension/ProxerRxExtensions.kt b/src/main/kotlin/me/proxer/app/util/extension/ProxerRxExtensions.kt index 8d91580c..5f879488 100644 --- a/src/main/kotlin/me/proxer/app/util/extension/ProxerRxExtensions.kt +++ b/src/main/kotlin/me/proxer/app/util/extension/ProxerRxExtensions.kt @@ -107,7 +107,7 @@ fun Call.toBodySingle(): Single = Single.create { emitter -> } fun RecyclerView.endScrolls(threshold: Int = 5): Observable = scrollEvents() - .filter { _ -> + .filter { safeLayoutManager.let { val pastVisibleItems = when (it) { is StaggeredGridLayoutManager -> {