aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/anime/search/SearchAnimePage.kt17
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/manga/search/SearchMangaPage.kt26
-rw-r--r--app/src/main/res/layout/search_anime_page.xml2
-rw-r--r--app/src/main/res/layout/search_manga_page.xml2
4 files changed, 44 insertions, 3 deletions
diff --git a/app/src/main/java/xyz/adjutor/aniki/anime/search/SearchAnimePage.kt b/app/src/main/java/xyz/adjutor/aniki/anime/search/SearchAnimePage.kt
index c1596c3..b624069 100644
--- a/app/src/main/java/xyz/adjutor/aniki/anime/search/SearchAnimePage.kt
+++ b/app/src/main/java/xyz/adjutor/aniki/anime/search/SearchAnimePage.kt
@@ -5,8 +5,10 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager
import android.widget.Button
+import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
@@ -48,11 +50,24 @@ class SearchAnimePage : Fragment() {
findNavController().navigate(R.id.action_SearchAnimePage_to_HomePage)
}
- view.findViewById<Button>(R.id.button_query).setOnClickListener{
+ view.findViewById<Button>(R.id.button_query).setOnClickListener {
val userInput = view.findViewById<TextInputEditText>(R.id.tiet_query).text.toString()
hideKeyboard()
makeApiCall(view, baseUrl, userInput)
}
+
+ view.findViewById<TextInputEditText>(R.id.tiet_query)
+ .setOnEditorActionListener(TextView.OnEditorActionListener { v, actionId, event ->
+ if (actionId == EditorInfo.IME_ACTION_SEARCH) {
+ val userInput =
+ view.findViewById<TextInputEditText>(R.id.tiet_query).text.toString()
+ hideKeyboard()
+ makeApiCall(view, baseUrl, userInput)
+ return@OnEditorActionListener true
+ }
+ false
+ })
+
}
private fun hideKeyboard() {
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 f79db36..d236887 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
@@ -5,8 +5,10 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager
import android.widget.Button
+import android.widget.TextView.OnEditorActionListener
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
@@ -23,6 +25,7 @@ import retrofit2.converter.gson.GsonConverterFactory
import xyz.adjutor.aniki.MainActivity
import xyz.adjutor.aniki.R
+
class SearchMangaPage : Fragment() {
val gson: Gson = GsonBuilder()
@@ -48,11 +51,24 @@ class SearchMangaPage : Fragment() {
findNavController().navigate(R.id.action_SearchMangaPage_to_HomePage)
}
- view.findViewById<Button>(R.id.button_query).setOnClickListener{
+ view.findViewById<Button>(R.id.button_query).setOnClickListener {
val userInput = view.findViewById<TextInputEditText>(R.id.tiet_query).text.toString()
hideKeyboard()
makeApiCall(view, baseUrl, userInput)
}
+
+ view.findViewById<TextInputEditText>(R.id.tiet_query)
+ .setOnEditorActionListener(OnEditorActionListener { v, actionId, event ->
+ if (actionId == EditorInfo.IME_ACTION_SEARCH) {
+ val userInput =
+ view.findViewById<TextInputEditText>(R.id.tiet_query).text.toString()
+ hideKeyboard()
+ makeApiCall(view, baseUrl, userInput)
+ return@OnEditorActionListener true
+ }
+ false
+ })
+
}
private fun hideKeyboard() {
@@ -75,6 +91,7 @@ class SearchMangaPage : Fragment() {
(recyclerView.adapter as SearchMangaAdapter).notifyDataSetChanged()
}
+ //call the API and show the list
private fun makeApiCall(view: View, BASE_URL: String, query: String) {
val retrofit = Retrofit.Builder()
@@ -112,8 +129,13 @@ class SearchMangaPage : Fragment() {
})
}
+ //display a snack
private fun showError() {
- Snackbar.make(requireView(), "API ERROR : Verify your internet connection or your query.", Snackbar.LENGTH_LONG)
+ Snackbar.make(
+ requireView(),
+ "API ERROR : Verify your internet connection or your query.",
+ Snackbar.LENGTH_LONG
+ )
.setAction("Action", null).show()
}
diff --git a/app/src/main/res/layout/search_anime_page.xml b/app/src/main/res/layout/search_anime_page.xml
index 631ebde..f91c1d9 100644
--- a/app/src/main/res/layout/search_anime_page.xml
+++ b/app/src/main/res/layout/search_anime_page.xml
@@ -18,6 +18,8 @@
app:layout_constraintBottom_toTopOf="@id/recycler_view"
app:layout_constraintEnd_toStartOf="@id/button_query"
app:layout_constraintStart_toStartOf="parent"
+ android:imeOptions="actionSearch"
+ android:inputType="text"
app:layout_constraintTop_toTopOf="parent" />
<Button
diff --git a/app/src/main/res/layout/search_manga_page.xml b/app/src/main/res/layout/search_manga_page.xml
index 02a62ff..cacab1d 100644
--- a/app/src/main/res/layout/search_manga_page.xml
+++ b/app/src/main/res/layout/search_manga_page.xml
@@ -18,6 +18,8 @@
app:layout_constraintBottom_toTopOf="@id/recycler_view"
app:layout_constraintEnd_toStartOf="@id/button_query"
app:layout_constraintStart_toStartOf="parent"
+ android:imeOptions="actionSearch"
+ android:inputType="text"
app:layout_constraintTop_toTopOf="parent" />
<Button