diff --git a/app/src/main/java/com/github/libretube/adapters/SearchHistoryAdapter.kt b/app/src/main/java/com/github/libretube/adapters/SearchHistoryAdapter.kt index 524782471..049ca4bf9 100644 --- a/app/src/main/java/com/github/libretube/adapters/SearchHistoryAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/SearchHistoryAdapter.kt @@ -10,7 +10,6 @@ import com.github.libretube.fragments.SearchFragment import com.github.libretube.preferences.PreferenceHelper class SearchHistoryAdapter( - private val context: Context, private var historyList: List, private val editText: EditText, private val searchFragment: SearchFragment @@ -28,19 +27,19 @@ class SearchHistoryAdapter( } override fun onBindViewHolder(holder: SearchHistoryViewHolder, position: Int) { - val history = historyList[position] + val historyQuery = historyList[position] holder.binding.apply { - historyText.text = history + historyText.text = historyQuery deleteHistory.setOnClickListener { - historyList = historyList - history - PreferenceHelper.saveHistory(historyList) + historyList = historyList - historyQuery + PreferenceHelper.removeFromSearchHistory(historyQuery) notifyDataSetChanged() } root.setOnClickListener { - editText.setText(history) - searchFragment.fetchSearch(history) + editText.setText(historyQuery) + searchFragment.fetchSearch(historyQuery) } } } diff --git a/app/src/main/java/com/github/libretube/dialogs/UpdateDialog.kt b/app/src/main/java/com/github/libretube/dialogs/UpdateDialog.kt index 5324a072b..3bed33348 100644 --- a/app/src/main/java/com/github/libretube/dialogs/UpdateDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/UpdateDialog.kt @@ -47,8 +47,8 @@ class UpdateDialog( private fun getDownloadUrl(updateInfo: UpdateInfo): String? { val supportedArchitectures = Build.SUPPORTED_ABIS supportedArchitectures.forEach { arch -> - updateInfo.assets.forEach { asset -> - if (asset.name.contains(arch)) return asset.browser_download_url + updateInfo.assets?.forEach { asset -> + if (asset.name?.contains(arch) == true) return asset.browser_download_url } } return null diff --git a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt index a6cc9d0d1..8c4e6f420 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt @@ -210,7 +210,7 @@ class PlayerFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - hideKeyboard() + context?.hideKeyboard(view) setUserPrefs() diff --git a/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt b/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt index 8b369e85d..1c3e1c2f1 100644 --- a/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt @@ -150,7 +150,7 @@ class SearchFragment : Fragment() { binding.autoCompleteTextView.setOnEditorActionListener( OnEditorActionListener { _, actionId, _ -> if (actionId == EditorInfo.IME_ACTION_SEARCH) { - hideKeyboard() + view?.let { context?.hideKeyboard(it) } binding.searchRecycler.visibility = VISIBLE binding.historyRecycler.visibility = GONE fetchSearch(binding.autoCompleteTextView.text.toString()) @@ -190,7 +190,7 @@ class SearchFragment : Fragment() { } lifecycleScope.launchWhenCreated { isFetchingSearch = true - hideKeyboard() + view?.let { context?.hideKeyboard(it) } val response = try { RetrofitInstance.api.getSearchResults(query, apiSearchFilter) } catch (e: IOException) { @@ -253,16 +253,15 @@ class SearchFragment : Fragment() { override fun onStop() { super.onStop() - hideKeyboard() + view?.let { context?.hideKeyboard(it) } } private fun showHistory() { binding.searchRecycler.visibility = GONE - val historyList = PreferenceHelper.getHistory() + val historyList = PreferenceHelper.getSearchHistory() if (historyList.isNotEmpty()) { binding.historyRecycler.adapter = SearchHistoryAdapter( - requireContext(), historyList, binding.autoCompleteTextView, this @@ -274,20 +273,8 @@ class SearchFragment : Fragment() { private fun addToHistory(query: String) { val searchHistoryEnabled = PreferenceHelper.getBoolean(PreferenceKeys.SEARCH_HISTORY_TOGGLE, true) - if (searchHistoryEnabled) { - var historyList = PreferenceHelper.getHistory() - - if ((historyList.isNotEmpty() && historyList.contains(query)) || query == "") { - return - } else { - historyList = historyList + query - } - - if (historyList.size > 10) { - historyList = historyList.takeLast(10) - } - - PreferenceHelper.saveHistory(historyList) + if (searchHistoryEnabled && query != "") { + PreferenceHelper.saveToSearchHistory(query) } } } diff --git a/app/src/main/java/com/github/libretube/obj/ChapterSegment.kt b/app/src/main/java/com/github/libretube/obj/ChapterSegment.kt index eb47218b3..e6bdf2eee 100644 --- a/app/src/main/java/com/github/libretube/obj/ChapterSegment.kt +++ b/app/src/main/java/com/github/libretube/obj/ChapterSegment.kt @@ -4,9 +4,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties @JsonIgnoreProperties(ignoreUnknown = true) data class ChapterSegment( - var title: String?, - var image: String?, - var start: Long? -) { - constructor() : this("", "", -1) -} + var title: String? = null, + var image: String? = null, + var start: Long? = null +) diff --git a/app/src/main/java/com/github/libretube/obj/Comment.kt b/app/src/main/java/com/github/libretube/obj/Comment.kt index 40eb6689e..5266c0d47 100644 --- a/app/src/main/java/com/github/libretube/obj/Comment.kt +++ b/app/src/main/java/com/github/libretube/obj/Comment.kt @@ -4,17 +4,15 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties @JsonIgnoreProperties(ignoreUnknown = true) data class Comment( - val author: String?, - val commentId: String?, - val commentText: String?, - val commentedTime: String?, - val commentorUrl: String?, - val repliesPage: String?, - val hearted: Boolean?, - val likeCount: Int?, - val pinned: Boolean?, - val thumbnail: String?, - val verified: Boolean? -) { - constructor() : this("", "", "", "", "", "", null, 0, null, "", null) -} + val author: String? = null, + val commentId: String? = null, + val commentText: String? = null, + val commentedTime: String? = null, + val commentorUrl: String? = null, + val repliesPage: String? = null, + val hearted: Boolean? = null, + val likeCount: Int? = null, + val pinned: Boolean? = null, + val thumbnail: String? = null, + val verified: Boolean? = null +) diff --git a/app/src/main/java/com/github/libretube/obj/CommentsPage.kt b/app/src/main/java/com/github/libretube/obj/CommentsPage.kt index 4ba48f667..1244cc4a9 100644 --- a/app/src/main/java/com/github/libretube/obj/CommentsPage.kt +++ b/app/src/main/java/com/github/libretube/obj/CommentsPage.kt @@ -7,6 +7,4 @@ data class CommentsPage( val comments: MutableList = arrayListOf(), val disabled: Boolean? = null, val nextpage: String? = "" -) { - constructor() : this(arrayListOf(), null, "") -} +) diff --git a/app/src/main/java/com/github/libretube/obj/PipedStream.kt b/app/src/main/java/com/github/libretube/obj/PipedStream.kt index 843698737..59109a210 100644 --- a/app/src/main/java/com/github/libretube/obj/PipedStream.kt +++ b/app/src/main/java/com/github/libretube/obj/PipedStream.kt @@ -4,20 +4,18 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties @JsonIgnoreProperties(ignoreUnknown = true) data class PipedStream( - var url: String?, - var format: String?, - var quality: String?, - var mimeType: String?, - var codec: String?, - var videoOnly: Boolean?, - var bitrate: Int?, - var initStart: Int?, - var initEnd: Int?, - var indexStart: Int?, - var indexEnd: Int?, - var width: Int?, - var height: Int?, - var fps: Int? -) { - constructor() : this("", "", "", "", "", null, -1, -1, -1, -1, -1, -1, -1, -1) -} + var url: String? = null, + var format: String? = null, + var quality: String? = null, + var mimeType: String? = null, + var codec: String? = null, + var videoOnly: Boolean? = null, + var bitrate: Int? = null, + var initStart: Int? = null, + var initEnd: Int? = null, + var indexStart: Int? = null, + var indexEnd: Int? = null, + var width: Int? = null, + var height: Int? = null, + var fps: Int? = null +) diff --git a/app/src/main/java/com/github/libretube/obj/SearchItem.kt b/app/src/main/java/com/github/libretube/obj/SearchItem.kt index 43006239b..50d6d6ec3 100644 --- a/app/src/main/java/com/github/libretube/obj/SearchItem.kt +++ b/app/src/main/java/com/github/libretube/obj/SearchItem.kt @@ -4,25 +4,23 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties @JsonIgnoreProperties(ignoreUnknown = true) data class SearchItem( - var url: String?, - var thumbnail: String?, - var uploaderName: String?, - var uploaded: Long?, - var shortDescription: String?, + var url: String? = null, + var thumbnail: String? = null, + var uploaderName: String? = null, + var uploaded: Long? = null, + var shortDescription: String? = null, // Video only attributes - var title: String?, - var uploaderUrl: String?, - var uploaderAvatar: String?, - var uploadedDate: String?, - var duration: Long?, - var views: Long?, - var uploaderVerified: Boolean?, + var title: String? = null, + var uploaderUrl: String? = null, + var uploaderAvatar: String? = null, + var uploadedDate: String? = null, + var duration: Long? = null, + var views: Long? = null, + var uploaderVerified: Boolean? = null, // Channel and Playlist attributes var name: String? = null, var description: String? = null, var subscribers: Long? = -1, var videos: Long? = -1, var verified: Boolean? = null -) { - constructor() : this("", "", "", 0, "", "", "", "", "", 0, 0, null) -} +) diff --git a/app/src/main/java/com/github/libretube/obj/Segment.kt b/app/src/main/java/com/github/libretube/obj/Segment.kt index 85ab9d344..89d3f8fbb 100644 --- a/app/src/main/java/com/github/libretube/obj/Segment.kt +++ b/app/src/main/java/com/github/libretube/obj/Segment.kt @@ -4,9 +4,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties @JsonIgnoreProperties(ignoreUnknown = true) data class Segment( - val actionType: String?, - val category: String?, - val segment: List? -) { - constructor() : this("", "", arrayListOf()) -} + val actionType: String? = null, + val category: String? = null, + val segment: List? = arrayListOf() +) \ No newline at end of file diff --git a/app/src/main/java/com/github/libretube/obj/Segments.kt b/app/src/main/java/com/github/libretube/obj/Segments.kt index af3628cdc..e7c1b1297 100644 --- a/app/src/main/java/com/github/libretube/obj/Segments.kt +++ b/app/src/main/java/com/github/libretube/obj/Segments.kt @@ -5,6 +5,4 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties @JsonIgnoreProperties(ignoreUnknown = true) data class Segments( val segments: MutableList = arrayListOf() -) { - constructor() : this(arrayListOf()) -} +) diff --git a/app/src/main/java/com/github/libretube/obj/StreamItem.kt b/app/src/main/java/com/github/libretube/obj/StreamItem.kt index f22e4d256..4670d80f7 100644 --- a/app/src/main/java/com/github/libretube/obj/StreamItem.kt +++ b/app/src/main/java/com/github/libretube/obj/StreamItem.kt @@ -4,18 +4,16 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties @JsonIgnoreProperties(ignoreUnknown = true) data class StreamItem( - var url: String?, - var title: String?, - var thumbnail: String?, - var uploaderName: String?, - var uploaderUrl: String?, - var uploaderAvatar: String?, - var uploadedDate: String?, - var duration: Long?, - var views: Long?, - var uploaderVerified: Boolean?, - var uploaded: Long?, - var shortDescription: String? -) { - constructor() : this("", "", "", "", "", "", "", 0, 0, null, 0, "") -} + var url: String? = null, + var title: String? = null, + var thumbnail: String? = null, + var uploaderName: String? = null, + var uploaderUrl: String? = null, + var uploaderAvatar: String? = null, + var uploadedDate: String? = null, + var duration: Long? = null, + var views: Long? = null, + var uploaderVerified: Boolean? = null, + var uploaded: Long? = null, + var shortDescription: String? = null +) \ No newline at end of file diff --git a/app/src/main/java/com/github/libretube/obj/Subtitle.kt b/app/src/main/java/com/github/libretube/obj/Subtitle.kt index fa80f697a..2aa66149f 100644 --- a/app/src/main/java/com/github/libretube/obj/Subtitle.kt +++ b/app/src/main/java/com/github/libretube/obj/Subtitle.kt @@ -4,11 +4,9 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties @JsonIgnoreProperties(ignoreUnknown = true) data class Subtitle( - val url: String?, - val mimeType: String?, - val name: String?, - val code: String?, - val autoGenerated: Boolean? -) { - constructor() : this("", "", "", "", null) -} + val url: String? = null, + val mimeType: String? = null, + val name: String? = null, + val code: String? = null, + val autoGenerated: Boolean? = null +) \ No newline at end of file diff --git a/app/src/main/java/com/github/libretube/obj/WatchHistoryItem.kt b/app/src/main/java/com/github/libretube/obj/WatchHistoryItem.kt index b8eab4111..2e6d047f9 100644 --- a/app/src/main/java/com/github/libretube/obj/WatchHistoryItem.kt +++ b/app/src/main/java/com/github/libretube/obj/WatchHistoryItem.kt @@ -1,12 +1,12 @@ package com.github.libretube.obj data class WatchHistoryItem( - val videoId: String?, - val title: String?, - val uploadDate: String?, - val uploader: String?, - val uploaderUrl: String?, - val uploaderAvatar: String?, - val thumbnailUrl: String?, - val duration: Int? + val videoId: String? = null, + val title: String? = null, + val uploadDate: String? = null, + val uploader: String? = null, + val uploaderUrl: String? = null, + val uploaderAvatar: String? = null, + val thumbnailUrl: String? = null, + val duration: Int? = null ) diff --git a/app/src/main/java/com/github/libretube/obj/WatchPosition.kt b/app/src/main/java/com/github/libretube/obj/WatchPosition.kt index b7b000310..e98b4e812 100644 --- a/app/src/main/java/com/github/libretube/obj/WatchPosition.kt +++ b/app/src/main/java/com/github/libretube/obj/WatchPosition.kt @@ -1,6 +1,6 @@ package com.github.libretube.obj data class WatchPosition( - val videoId: String, - val position: Long + val videoId: String = "", + val position: Long = 0L ) diff --git a/app/src/main/java/com/github/libretube/preferences/PreferenceHelper.kt b/app/src/main/java/com/github/libretube/preferences/PreferenceHelper.kt index c1d327535..8d677c613 100644 --- a/app/src/main/java/com/github/libretube/preferences/PreferenceHelper.kt +++ b/app/src/main/java/com/github/libretube/preferences/PreferenceHelper.kt @@ -114,17 +114,41 @@ object PreferenceHelper { } } - fun getHistory(): List { + fun getSearchHistory(): List { return try { - val set: Set = settings.getStringSet("search_history", HashSet())!! + val set: Set = settings.getStringSet("search_history", LinkedHashSet())!! set.toList() } catch (e: Exception) { emptyList() } } - fun saveHistory(historyList: List) { - val set: Set = HashSet(historyList) + fun saveToSearchHistory(query: String) { + var historyList = getSearchHistory().toMutableList() + + if ((historyList.contains(query))) { + // remove from history list if already contained + historyList -= query + } + + // append new query to history + historyList.add(0, query) + + if (historyList.size > 10) { + historyList.removeAt(historyList.size - 1) + } + + updateSearchHistory(historyList) + } + + fun removeFromSearchHistory(query: String) { + val historyList = getSearchHistory().toMutableList() + historyList -= query + updateSearchHistory(historyList) + } + + private fun updateSearchHistory(historyList: List) { + val set: Set = LinkedHashSet(historyList) editor.putStringSet("search_history", set).apply() } diff --git a/app/src/main/java/com/github/libretube/update/Asset.kt b/app/src/main/java/com/github/libretube/update/Asset.kt index f535a7bf4..a1e4a2c5e 100644 --- a/app/src/main/java/com/github/libretube/update/Asset.kt +++ b/app/src/main/java/com/github/libretube/update/Asset.kt @@ -4,17 +4,17 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties @JsonIgnoreProperties(ignoreUnknown = true) data class Asset( - val browser_download_url: String, - val content_type: String, - val created_at: String, - val download_count: Int, - val id: Int, - val label: Any, - val name: String, - val node_id: String, - val size: Int, - val state: String, - val updated_at: String, - val uploader: Uploader, - val url: String + val browser_download_url: String? = null, + val content_type: String? = null, + val created_at: String? = null, + val download_count: Int? = null, + val id: Int? = null, + val label: Any? = null, + val name: String? = null, + val node_id: String? = null, + val size: Int? = null, + val state: String? = null, + val updated_at: String? = null, + val uploader: Uploader? = null, + val url: String? = null ) diff --git a/app/src/main/java/com/github/libretube/update/Author.kt b/app/src/main/java/com/github/libretube/update/Author.kt index e55675bfb..6b9ecd84d 100644 --- a/app/src/main/java/com/github/libretube/update/Author.kt +++ b/app/src/main/java/com/github/libretube/update/Author.kt @@ -4,22 +4,22 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties @JsonIgnoreProperties(ignoreUnknown = true) data class Author( - val avatar_url: String, - val events_url: String, - val followers_url: String, - val following_url: String, - val gists_url: String, - val gravatar_id: String, - val html_url: String, - val id: Int, - val login: String, - val node_id: String, - val organizations_url: String, - val received_events_url: String, - val repos_url: String, - val site_admin: Boolean, - val starred_url: String, - val subscriptions_url: String, - val type: String, - val url: String + val avatar_url: String? = null, + val events_url: String? = null, + val followers_url: String? = null, + val following_url: String? = null, + val gists_url: String? = null, + val gravatar_id: String? = null, + val html_url: String? = null, + val id: Int? = null, + val login: String? = null, + val node_id: String? = null, + val organizations_url: String? = null, + val received_events_url: String? = null, + val repos_url: String? = null, + val site_admin: Boolean? = null, + val starred_url: String? = null, + val subscriptions_url: String? = null, + val type: String? = null, + val url: String? = null ) diff --git a/app/src/main/java/com/github/libretube/update/Reactions.kt b/app/src/main/java/com/github/libretube/update/Reactions.kt index 4710f199c..9a87fc84d 100644 --- a/app/src/main/java/com/github/libretube/update/Reactions.kt +++ b/app/src/main/java/com/github/libretube/update/Reactions.kt @@ -4,12 +4,12 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties @JsonIgnoreProperties(ignoreUnknown = true) data class Reactions( - val confused: Int, - val eyes: Int, - val heart: Int, - val hooray: Int, - val laugh: Int, - val rocket: Int, - val total_count: Int, - val url: String + val confused: Int? = null, + val eyes: Int? = null, + val heart: Int? = null, + val hooray: Int? = null, + val laugh: Int? = null, + val rocket: Int? = null, + val total_count: Int? = null, + val url: String? = null ) diff --git a/app/src/main/java/com/github/libretube/update/UpdateChecker.kt b/app/src/main/java/com/github/libretube/update/UpdateChecker.kt index 50d236385..00b01b69d 100644 --- a/app/src/main/java/com/github/libretube/update/UpdateChecker.kt +++ b/app/src/main/java/com/github/libretube/update/UpdateChecker.kt @@ -1,5 +1,6 @@ package com.github.libretube.update +import android.util.Log import com.fasterxml.jackson.databind.ObjectMapper import com.github.libretube.GITHUB_API_URL import java.net.URL @@ -10,6 +11,7 @@ object UpdateChecker { // run http request as thread to make it async val thread = Thread { // otherwise crashes without internet + versionInfo = getUpdateInfo() try { versionInfo = getUpdateInfo() } catch (e: Exception) { diff --git a/app/src/main/java/com/github/libretube/update/UpdateInfo.kt b/app/src/main/java/com/github/libretube/update/UpdateInfo.kt index 4629e1789..f72391c3e 100644 --- a/app/src/main/java/com/github/libretube/update/UpdateInfo.kt +++ b/app/src/main/java/com/github/libretube/update/UpdateInfo.kt @@ -4,24 +4,24 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties @JsonIgnoreProperties(ignoreUnknown = true) data class UpdateInfo( - val assets: List, - val assets_url: String, - val author: Author, - val body: String, - val created_at: String, - val draft: Boolean, - val html_url: String, - val id: Int, - val mentions_count: Int, - val name: String, - val node_id: String, - val prerelease: Boolean, - val published_at: String, - val reactions: Reactions, - val tag_name: String, - val tarball_url: String, - val target_commitish: String, - val upload_url: String, - val url: String, - val zipball_url: String + val assets: List? = null, + val assets_url: String? = null, + val author: Author? = null, + val body: String? = null, + val created_at: String? = null, + val draft: Boolean? = null, + val html_url: String? = null, + val id: Int? = null, + val mentions_count: Int? = null, + val name: String? = null, + val node_id: String? = null, + val prerelease: Boolean? = null, + val published_at: String? = null, + val reactions: Reactions? = null, + val tag_name: String? = null, + val tarball_url: String? = null, + val target_commitish: String? = null, + val upload_url: String? = null, + val url: String? = null, + val zipball_url: String? = null ) diff --git a/app/src/main/java/com/github/libretube/update/Uploader.kt b/app/src/main/java/com/github/libretube/update/Uploader.kt index a5e261d60..6c19aff19 100644 --- a/app/src/main/java/com/github/libretube/update/Uploader.kt +++ b/app/src/main/java/com/github/libretube/update/Uploader.kt @@ -4,22 +4,22 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties @JsonIgnoreProperties(ignoreUnknown = true) data class Uploader( - val avatar_url: String, - val events_url: String, - val followers_url: String, - val following_url: String, - val gists_url: String, - val gravatar_id: String, - val html_url: String, - val id: Int, - val login: String, - val node_id: String, - val organizations_url: String, - val received_events_url: String, - val repos_url: String, - val site_admin: Boolean, - val starred_url: String, - val subscriptions_url: String, - val type: String, - val url: String + val avatar_url: String? = null, + val events_url: String? = null, + val followers_url: String? = null, + val following_url: String? = null, + val gists_url: String? = null, + val gravatar_id: String? = null, + val html_url: String? = null, + val id: Int? = null, + val login: String? = null, + val node_id: String? = null, + val organizations_url: String? = null, + val received_events_url: String? = null, + val repos_url: String? = null, + val site_admin: Boolean? = null, + val starred_url: String? = null, + val subscriptions_url: String? = null, + val type: String? = null, + val url: String? = null ) diff --git a/app/src/main/java/com/github/libretube/util/HideKeyboard.kt b/app/src/main/java/com/github/libretube/util/KeyboardHelper.kt similarity index 76% rename from app/src/main/java/com/github/libretube/util/HideKeyboard.kt rename to app/src/main/java/com/github/libretube/util/KeyboardHelper.kt index eab38fb28..de99f682d 100644 --- a/app/src/main/java/com/github/libretube/util/HideKeyboard.kt +++ b/app/src/main/java/com/github/libretube/util/KeyboardHelper.kt @@ -4,11 +4,6 @@ import android.app.Activity import android.content.Context import android.view.View import android.view.inputmethod.InputMethodManager -import androidx.fragment.app.Fragment - -fun Fragment.hideKeyboard() { - view?.let { activity?.hideKeyboard(it) } -} fun Context.hideKeyboard(view: View) { val inputMethodManager = getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager