aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/xyz/adjutor/aniki/manga
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/xyz/adjutor/aniki/manga')
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/manga/search/SearchMangaPage.kt20
1 files changed, 17 insertions, 3 deletions
diff --git a/app/src/main/java/xyz/adjutor/aniki/manga/search/SearchMangaPage.kt b/app/src/main/java/xyz/adjutor/aniki/manga/search/SearchMangaPage.kt
index 40f9633..f79db36 100644
--- a/app/src/main/java/xyz/adjutor/aniki/manga/search/SearchMangaPage.kt
+++ b/app/src/main/java/xyz/adjutor/aniki/manga/search/SearchMangaPage.kt
@@ -1,9 +1,11 @@
package xyz.adjutor.aniki.manga.search
+import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.view.inputmethod.InputMethodManager
import android.widget.Button
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
@@ -18,6 +20,7 @@ import retrofit2.Callback
import retrofit2.Response
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
+import xyz.adjutor.aniki.MainActivity
import xyz.adjutor.aniki.R
class SearchMangaPage : Fragment() {
@@ -32,9 +35,8 @@ class SearchMangaPage : Fragment() {
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
- val view = inflater.inflate(R.layout.search_manga_page, container, false)
- return view
+ return inflater.inflate(R.layout.search_manga_page, container, false)
}
@@ -48,10 +50,22 @@ class SearchMangaPage : Fragment() {
view.findViewById<Button>(R.id.button_query).setOnClickListener{
val userInput = view.findViewById<TextInputEditText>(R.id.tiet_query).text.toString()
+ hideKeyboard()
makeApiCall(view, baseUrl, userInput)
}
}
+ private fun hideKeyboard() {
+ val activity = activity as MainActivity
+
+ val view = activity.currentFocus
+ if (view != null) {
+ val imm = activity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
+ imm.hideSoftInputFromWindow(view.windowToken, 0)
+ }
+ }
+
+
//display the recyclerview
fun showList(view: View, mangaList: List<SearchManga>) {
val recyclerView: RecyclerView = view.findViewById(R.id.recycler_view)
@@ -99,7 +113,7 @@ class SearchMangaPage : Fragment() {
}
private fun showError() {
- Snackbar.make(requireView(), "API ERROR", Snackbar.LENGTH_LONG)
+ Snackbar.make(requireView(), "API ERROR : Verify your internet connection or your query.", Snackbar.LENGTH_LONG)
.setAction("Action", null).show()
}