Skip to content

Commit

Permalink
show keyboard bug
Browse files Browse the repository at this point in the history
  • Loading branch information
rimthekid committed Mar 5, 2022
1 parent ccca806 commit 466cbb4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
8 changes: 8 additions & 0 deletions app/src/main/java/com/github/libretube/PlayerFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import android.util.TypedValue
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import android.view.inputmethod.InputMethodManager
import android.widget.*
import androidx.appcompat.app.AlertDialog
import androidx.constraintlayout.motion.widget.MotionLayout
Expand Down Expand Up @@ -81,6 +83,12 @@ class PlayerFragment : Fragment() {
arguments?.let {
videoId = it.getString("videoId")
}
closeKeyboard()
}
private fun closeKeyboard() {
val inputMethodManager: InputMethodManager =
requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
inputMethodManager.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0)
}

override fun onCreateView(
Expand Down
22 changes: 14 additions & 8 deletions app/src/main/java/com/github/libretube/SearchFragment.kt
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
package com.github.libretube

import android.content.Context
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.util.Log
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import android.view.inputmethod.InputMethodManager
import android.widget.ArrayAdapter
import android.widget.AutoCompleteTextView
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.adapters.SearchAdapter
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import retrofit2.HttpException
import com.github.libretube.adapters.SearchAdapter
import java.io.IOException


class SearchFragment : Fragment() {

private val TAG = "SearchFragment"


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
arguments?.let {
Expand Down Expand Up @@ -61,7 +61,7 @@ class SearchFragment : Fragment() {
if(s!! != ""){
GlobalScope.launch {
fetchSuggestions(s.toString(), autoTextView)
delay(2000)
delay(3000)
fetchSearch(s.toString(),recyclerView)
}
}
Expand Down Expand Up @@ -96,7 +96,7 @@ class SearchFragment : Fragment() {
RetrofitInstance.api.getSearchResults(query, "all")
} catch (e: IOException) {
println(e)
Log.e(TAG, "IOException, you might not have internet connection "+e.toString())
Log.e(TAG, "IOException, you might not have internet connection $e")
return@launchWhenCreated
} catch (e: HttpException) {
Log.e(TAG, "HttpException, unexpected response")
Expand All @@ -117,4 +117,10 @@ class SearchFragment : Fragment() {
if (!isAdded) return // Fragment not attached to an Activity
activity?.runOnUiThread(action)
}
}

override fun onResume() {
super.onResume()
requireActivity().window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)
}

}
2 changes: 2 additions & 0 deletions app/src/main/res/layout/fragment_search.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SearchFragment"
android:focusable="true"
android:focusableInTouchMode="true"
>

<com.google.android.material.card.MaterialCardView
Expand Down

0 comments on commit 466cbb4

Please sign in to comment.