aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/xyz/adjutor/aniki/manga
diff options
context:
space:
mode:
authorClyhtsuriva <aimeric@adjutor.xyz>2021-03-02 14:36:38 +0100
committerClyhtsuriva <aimeric@adjutor.xyz>2021-03-02 14:36:38 +0100
commitd5dd918f2c8c0f29c70379fce6e40b79141c798a (patch)
treef66c52a4a9c13ec16757f7e7134fa75ce3b303bf /app/src/main/java/xyz/adjutor/aniki/manga
parent81a89af9aa3c35a991eced93eeaa5066804e3ee5 (diff)
Added searching for animes.
Auto keyboard hiding method when submitting.
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()
}