diff options
| author | Clyhtsuriva <aimeric@adjutor.xyz> | 2021-03-23 09:09:40 +0100 | 
|---|---|---|
| committer | Clyhtsuriva <aimeric@adjutor.xyz> | 2021-03-23 09:09:40 +0100 | 
| commit | 9159505004b7d55964653747decd313bcdd6a801 (patch) | |
| tree | dc695347aaddda6661ea488c5d4947128d5b0d64 | |
| parent | 249cdf3a91eab6be7e4f23ae146b1fb91caf6ed4 (diff) | |
Manga : Added a search button replacing return on the keyboard.
| -rw-r--r-- | README.md | 25 | ||||
| -rw-r--r-- | app/src/main/java/xyz/adjutor/aniki/manga/search/SearchMangaPage.kt | 27 | ||||
| -rw-r--r-- | app/src/main/res/layout/search_manga_page.xml | 2 | 
3 files changed, 40 insertions, 14 deletions
| @@ -8,26 +8,27 @@ URL link openable.  Search pages for animes and mangas.  They display the data in a recycler view similar to the tops.  A feature has been added that hides the keyboard when the query is submitted by the user. +We can also submit the query by clicking the "search" button that replace the "return" one.  Multiple calls of the REST API from jikan.moe.  Usage of : -/v3/top/manga -/v3/top/anime -/v3/manga -/v3/anime -/v3/search/manga -/v3/search/anime ++ /v3/top/manga ++ /v3/top/anime ++ /v3/manga ++ /v3/anime ++ /v3/search/manga ++ /v3/search/anime  Data storage with sharedpreferences used for the recycler view of top manga and top anime as well as the details  Saves the detail page of an item when opened, not when the list is shown  Usage of ScrollView in the detail page. Thus, items with long synopsis and background aren't cut down.  Used my "personal" theme colors for the app. -It consists of colors of the pink/purple "family" : -very dark purple : #09022A -very light magenta : #FF70FF -strong pink : #D52C70 -slightly desaturated magenta : #C583B6 -grayish magenta : #C9A6C9 +It consists of some colors of the pink/purple "family" : ++ very dark purple : #09022A ++ very light magenta : #FF70FF ++ strong pink : #D52C70 ++ slightly desaturated magenta : #C583B6 ++ grayish magenta : #C9A6C9  Development done with a Gitflow workflow. 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..7866151 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,11 @@ 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.EditText +import android.widget.TextView.OnEditorActionListener  import androidx.fragment.app.Fragment  import androidx.navigation.fragment.findNavController  import androidx.recyclerview.widget.LinearLayoutManager @@ -23,6 +26,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 +52,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<EditText>(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 +92,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 +130,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_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 | 
